babylon.module.d.ts 6.6 MB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739274027412742274327442745274627472748274927502751275227532754275527562757275827592760276127622763276427652766276727682769277027712772277327742775277627772778277927802781278227832784278527862787278827892790279127922793279427952796279727982799280028012802280328042805280628072808280928102811281228132814281528162817281828192820282128222823282428252826282728282829283028312832283328342835283628372838283928402841284228432844284528462847284828492850285128522853285428552856285728582859286028612862286328642865286628672868286928702871287228732874287528762877287828792880288128822883288428852886288728882889289028912892289328942895289628972898289929002901290229032904290529062907290829092910291129122913291429152916291729182919292029212922292329242925292629272928292929302931293229332934293529362937293829392940294129422943294429452946294729482949295029512952295329542955295629572958295929602961296229632964296529662967296829692970297129722973297429752976297729782979298029812982298329842985298629872988298929902991299229932994299529962997299829993000300130023003300430053006300730083009301030113012301330143015301630173018301930203021302230233024302530263027302830293030303130323033303430353036303730383039304030413042304330443045304630473048304930503051305230533054305530563057305830593060306130623063306430653066306730683069307030713072307330743075307630773078307930803081308230833084308530863087308830893090309130923093309430953096309730983099310031013102310331043105310631073108310931103111311231133114311531163117311831193120312131223123312431253126312731283129313031313132313331343135313631373138313931403141314231433144314531463147314831493150315131523153315431553156315731583159316031613162316331643165316631673168316931703171317231733174317531763177317831793180318131823183318431853186318731883189319031913192319331943195319631973198319932003201320232033204320532063207320832093210321132123213321432153216321732183219322032213222322332243225322632273228322932303231323232333234323532363237323832393240324132423243324432453246324732483249325032513252325332543255325632573258325932603261326232633264326532663267326832693270327132723273327432753276327732783279328032813282328332843285328632873288328932903291329232933294329532963297329832993300330133023303330433053306330733083309331033113312331333143315331633173318331933203321332233233324332533263327332833293330333133323333333433353336333733383339334033413342334333443345334633473348334933503351335233533354335533563357335833593360336133623363336433653366336733683369337033713372337333743375337633773378337933803381338233833384338533863387338833893390339133923393339433953396339733983399340034013402340334043405340634073408340934103411341234133414341534163417341834193420342134223423342434253426342734283429343034313432343334343435343634373438343934403441344234433444344534463447344834493450345134523453345434553456345734583459346034613462346334643465346634673468346934703471347234733474347534763477347834793480348134823483348434853486348734883489349034913492349334943495349634973498349935003501350235033504350535063507350835093510351135123513351435153516351735183519352035213522352335243525352635273528352935303531353235333534353535363537353835393540354135423543354435453546354735483549355035513552355335543555355635573558355935603561356235633564356535663567356835693570357135723573357435753576357735783579358035813582358335843585358635873588358935903591359235933594359535963597359835993600360136023603360436053606360736083609361036113612361336143615361636173618361936203621362236233624362536263627362836293630363136323633363436353636363736383639364036413642364336443645364636473648364936503651365236533654365536563657365836593660366136623663366436653666366736683669367036713672367336743675367636773678367936803681368236833684368536863687368836893690369136923693369436953696369736983699370037013702370337043705370637073708370937103711371237133714371537163717371837193720372137223723372437253726372737283729373037313732373337343735373637373738373937403741374237433744374537463747374837493750375137523753375437553756375737583759376037613762376337643765376637673768376937703771377237733774377537763777377837793780378137823783378437853786378737883789379037913792379337943795379637973798379938003801380238033804380538063807380838093810381138123813381438153816381738183819382038213822382338243825382638273828382938303831383238333834383538363837383838393840384138423843384438453846384738483849385038513852385338543855385638573858385938603861386238633864386538663867386838693870387138723873387438753876387738783879388038813882388338843885388638873888388938903891389238933894389538963897389838993900390139023903390439053906390739083909391039113912391339143915391639173918391939203921392239233924392539263927392839293930393139323933393439353936393739383939394039413942394339443945394639473948394939503951395239533954395539563957395839593960396139623963396439653966396739683969397039713972397339743975397639773978397939803981398239833984398539863987398839893990399139923993399439953996399739983999400040014002400340044005400640074008400940104011401240134014401540164017401840194020402140224023402440254026402740284029403040314032403340344035403640374038403940404041404240434044404540464047404840494050405140524053405440554056405740584059406040614062406340644065406640674068406940704071407240734074407540764077407840794080408140824083408440854086408740884089409040914092409340944095409640974098409941004101410241034104410541064107410841094110411141124113411441154116411741184119412041214122412341244125412641274128412941304131413241334134413541364137413841394140414141424143414441454146414741484149415041514152415341544155415641574158415941604161416241634164416541664167416841694170417141724173417441754176417741784179418041814182418341844185418641874188418941904191419241934194419541964197419841994200420142024203420442054206420742084209421042114212421342144215421642174218421942204221422242234224422542264227422842294230423142324233423442354236423742384239424042414242424342444245424642474248424942504251425242534254425542564257425842594260426142624263426442654266426742684269427042714272427342744275427642774278427942804281428242834284428542864287428842894290429142924293429442954296429742984299430043014302430343044305430643074308430943104311431243134314431543164317431843194320432143224323432443254326432743284329433043314332433343344335433643374338433943404341434243434344434543464347434843494350435143524353435443554356435743584359436043614362436343644365436643674368436943704371437243734374437543764377437843794380438143824383438443854386438743884389439043914392439343944395439643974398439944004401440244034404440544064407440844094410441144124413441444154416441744184419442044214422442344244425442644274428442944304431443244334434443544364437443844394440444144424443444444454446444744484449445044514452445344544455445644574458445944604461446244634464446544664467446844694470447144724473447444754476447744784479448044814482448344844485448644874488448944904491449244934494449544964497449844994500450145024503450445054506450745084509451045114512451345144515451645174518451945204521452245234524452545264527452845294530453145324533453445354536453745384539454045414542454345444545454645474548454945504551455245534554455545564557455845594560456145624563456445654566456745684569457045714572457345744575457645774578457945804581458245834584458545864587458845894590459145924593459445954596459745984599460046014602460346044605460646074608460946104611461246134614461546164617461846194620462146224623462446254626462746284629463046314632463346344635463646374638463946404641464246434644464546464647464846494650465146524653465446554656465746584659466046614662466346644665466646674668466946704671467246734674467546764677467846794680468146824683468446854686468746884689469046914692469346944695469646974698469947004701470247034704470547064707470847094710471147124713471447154716471747184719472047214722472347244725472647274728472947304731473247334734473547364737473847394740474147424743474447454746474747484749475047514752475347544755475647574758475947604761476247634764476547664767476847694770477147724773477447754776477747784779478047814782478347844785478647874788478947904791479247934794479547964797479847994800480148024803480448054806480748084809481048114812481348144815481648174818481948204821482248234824482548264827482848294830483148324833483448354836483748384839484048414842484348444845484648474848484948504851485248534854485548564857485848594860486148624863486448654866486748684869487048714872487348744875487648774878487948804881488248834884488548864887488848894890489148924893489448954896489748984899490049014902490349044905490649074908490949104911491249134914491549164917491849194920492149224923492449254926492749284929493049314932493349344935493649374938493949404941494249434944494549464947494849494950495149524953495449554956495749584959496049614962496349644965496649674968496949704971497249734974497549764977497849794980498149824983498449854986498749884989499049914992499349944995499649974998499950005001500250035004500550065007500850095010501150125013501450155016501750185019502050215022502350245025502650275028502950305031503250335034503550365037503850395040504150425043504450455046504750485049505050515052505350545055505650575058505950605061506250635064506550665067506850695070507150725073507450755076507750785079508050815082508350845085508650875088508950905091509250935094509550965097509850995100510151025103510451055106510751085109511051115112511351145115511651175118511951205121512251235124512551265127512851295130513151325133513451355136513751385139514051415142514351445145514651475148514951505151515251535154515551565157515851595160516151625163516451655166516751685169517051715172517351745175517651775178517951805181518251835184518551865187518851895190519151925193519451955196519751985199520052015202520352045205520652075208520952105211521252135214521552165217521852195220522152225223522452255226522752285229523052315232523352345235523652375238523952405241524252435244524552465247524852495250525152525253525452555256525752585259526052615262526352645265526652675268526952705271527252735274527552765277527852795280528152825283528452855286528752885289529052915292529352945295529652975298529953005301530253035304530553065307530853095310531153125313531453155316531753185319532053215322532353245325532653275328532953305331533253335334533553365337533853395340534153425343534453455346534753485349535053515352535353545355535653575358535953605361536253635364536553665367536853695370537153725373537453755376537753785379538053815382538353845385538653875388538953905391539253935394539553965397539853995400540154025403540454055406540754085409541054115412541354145415541654175418541954205421542254235424542554265427542854295430543154325433543454355436543754385439544054415442544354445445544654475448544954505451545254535454545554565457545854595460546154625463546454655466546754685469547054715472547354745475547654775478547954805481548254835484548554865487548854895490549154925493549454955496549754985499550055015502550355045505550655075508550955105511551255135514551555165517551855195520552155225523552455255526552755285529553055315532553355345535553655375538553955405541554255435544554555465547554855495550555155525553555455555556555755585559556055615562556355645565556655675568556955705571557255735574557555765577557855795580558155825583558455855586558755885589559055915592559355945595559655975598559956005601560256035604560556065607560856095610561156125613561456155616561756185619562056215622562356245625562656275628562956305631563256335634563556365637563856395640564156425643564456455646564756485649565056515652565356545655565656575658565956605661566256635664566556665667566856695670567156725673567456755676567756785679568056815682568356845685568656875688568956905691569256935694569556965697569856995700570157025703570457055706570757085709571057115712571357145715571657175718571957205721572257235724572557265727572857295730573157325733573457355736573757385739574057415742574357445745574657475748574957505751575257535754575557565757575857595760576157625763576457655766576757685769577057715772577357745775577657775778577957805781578257835784578557865787578857895790579157925793579457955796579757985799580058015802580358045805580658075808580958105811581258135814581558165817581858195820582158225823582458255826582758285829583058315832583358345835583658375838583958405841584258435844584558465847584858495850585158525853585458555856585758585859586058615862586358645865586658675868586958705871587258735874587558765877587858795880588158825883588458855886588758885889589058915892589358945895589658975898589959005901590259035904590559065907590859095910591159125913591459155916591759185919592059215922592359245925592659275928592959305931593259335934593559365937593859395940594159425943594459455946594759485949595059515952595359545955595659575958595959605961596259635964596559665967596859695970597159725973597459755976597759785979598059815982598359845985598659875988598959905991599259935994599559965997599859996000600160026003600460056006600760086009601060116012601360146015601660176018601960206021602260236024602560266027602860296030603160326033603460356036603760386039604060416042604360446045604660476048604960506051605260536054605560566057605860596060606160626063606460656066606760686069607060716072607360746075607660776078607960806081608260836084608560866087608860896090609160926093609460956096609760986099610061016102610361046105610661076108610961106111611261136114611561166117611861196120612161226123612461256126612761286129613061316132613361346135613661376138613961406141614261436144614561466147614861496150615161526153615461556156615761586159616061616162616361646165616661676168616961706171617261736174617561766177617861796180618161826183618461856186618761886189619061916192619361946195619661976198619962006201620262036204620562066207620862096210621162126213621462156216621762186219622062216222622362246225622662276228622962306231623262336234623562366237623862396240624162426243624462456246624762486249625062516252625362546255625662576258625962606261626262636264626562666267626862696270627162726273627462756276627762786279628062816282628362846285628662876288628962906291629262936294629562966297629862996300630163026303630463056306630763086309631063116312631363146315631663176318631963206321632263236324632563266327632863296330633163326333633463356336633763386339634063416342634363446345634663476348634963506351635263536354635563566357635863596360636163626363636463656366636763686369637063716372637363746375637663776378637963806381638263836384638563866387638863896390639163926393639463956396639763986399640064016402640364046405640664076408640964106411641264136414641564166417641864196420642164226423642464256426642764286429643064316432643364346435643664376438643964406441644264436444644564466447644864496450645164526453645464556456645764586459646064616462646364646465646664676468646964706471647264736474647564766477647864796480648164826483648464856486648764886489649064916492649364946495649664976498649965006501650265036504650565066507650865096510651165126513651465156516651765186519652065216522652365246525652665276528652965306531653265336534653565366537653865396540654165426543654465456546654765486549655065516552655365546555655665576558655965606561656265636564656565666567656865696570657165726573657465756576657765786579658065816582658365846585658665876588658965906591659265936594659565966597659865996600660166026603660466056606660766086609661066116612661366146615661666176618661966206621662266236624662566266627662866296630663166326633663466356636663766386639664066416642664366446645664666476648664966506651665266536654665566566657665866596660666166626663666466656666666766686669667066716672667366746675667666776678667966806681668266836684668566866687668866896690669166926693669466956696669766986699670067016702670367046705670667076708670967106711671267136714671567166717671867196720672167226723672467256726672767286729673067316732673367346735673667376738673967406741674267436744674567466747674867496750675167526753675467556756675767586759676067616762676367646765676667676768676967706771677267736774677567766777677867796780678167826783678467856786678767886789679067916792679367946795679667976798679968006801680268036804680568066807680868096810681168126813681468156816681768186819682068216822682368246825682668276828682968306831683268336834683568366837683868396840684168426843684468456846684768486849685068516852685368546855685668576858685968606861686268636864686568666867686868696870687168726873687468756876687768786879688068816882688368846885688668876888688968906891689268936894689568966897689868996900690169026903690469056906690769086909691069116912691369146915691669176918691969206921692269236924692569266927692869296930693169326933693469356936693769386939694069416942694369446945694669476948694969506951695269536954695569566957695869596960696169626963696469656966696769686969697069716972697369746975697669776978697969806981698269836984698569866987698869896990699169926993699469956996699769986999700070017002700370047005700670077008700970107011701270137014701570167017701870197020702170227023702470257026702770287029703070317032703370347035703670377038703970407041704270437044704570467047704870497050705170527053705470557056705770587059706070617062706370647065706670677068706970707071707270737074707570767077707870797080708170827083708470857086708770887089709070917092709370947095709670977098709971007101710271037104710571067107710871097110711171127113711471157116711771187119712071217122712371247125712671277128712971307131713271337134713571367137713871397140714171427143714471457146714771487149715071517152715371547155715671577158715971607161716271637164716571667167716871697170717171727173717471757176717771787179718071817182718371847185718671877188718971907191719271937194719571967197719871997200720172027203720472057206720772087209721072117212721372147215721672177218721972207221722272237224722572267227722872297230723172327233723472357236723772387239724072417242724372447245724672477248724972507251725272537254725572567257725872597260726172627263726472657266726772687269727072717272727372747275727672777278727972807281728272837284728572867287728872897290729172927293729472957296729772987299730073017302730373047305730673077308730973107311731273137314731573167317731873197320732173227323732473257326732773287329733073317332733373347335733673377338733973407341734273437344734573467347734873497350735173527353735473557356735773587359736073617362736373647365736673677368736973707371737273737374737573767377737873797380738173827383738473857386738773887389739073917392739373947395739673977398739974007401740274037404740574067407740874097410741174127413741474157416741774187419742074217422742374247425742674277428742974307431743274337434743574367437743874397440744174427443744474457446744774487449745074517452745374547455745674577458745974607461746274637464746574667467746874697470747174727473747474757476747774787479748074817482748374847485748674877488748974907491749274937494749574967497749874997500750175027503750475057506750775087509751075117512751375147515751675177518751975207521752275237524752575267527752875297530753175327533753475357536753775387539754075417542754375447545754675477548754975507551755275537554755575567557755875597560756175627563756475657566756775687569757075717572757375747575757675777578757975807581758275837584758575867587758875897590759175927593759475957596759775987599760076017602760376047605760676077608760976107611761276137614761576167617761876197620762176227623762476257626762776287629763076317632763376347635763676377638763976407641764276437644764576467647764876497650765176527653765476557656765776587659766076617662766376647665766676677668766976707671767276737674767576767677767876797680768176827683768476857686768776887689769076917692769376947695769676977698769977007701770277037704770577067707770877097710771177127713771477157716771777187719772077217722772377247725772677277728772977307731773277337734773577367737773877397740774177427743774477457746774777487749775077517752775377547755775677577758775977607761776277637764776577667767776877697770777177727773777477757776777777787779778077817782778377847785778677877788778977907791779277937794779577967797779877997800780178027803780478057806780778087809781078117812781378147815781678177818781978207821782278237824782578267827782878297830783178327833783478357836783778387839784078417842784378447845784678477848784978507851785278537854785578567857785878597860786178627863786478657866786778687869787078717872787378747875787678777878787978807881788278837884788578867887788878897890789178927893789478957896789778987899790079017902790379047905790679077908790979107911791279137914791579167917791879197920792179227923792479257926792779287929793079317932793379347935793679377938793979407941794279437944794579467947794879497950795179527953795479557956795779587959796079617962796379647965796679677968796979707971797279737974797579767977797879797980798179827983798479857986798779887989799079917992799379947995799679977998799980008001800280038004800580068007800880098010801180128013801480158016801780188019802080218022802380248025802680278028802980308031803280338034803580368037803880398040804180428043804480458046804780488049805080518052805380548055805680578058805980608061806280638064806580668067806880698070807180728073807480758076807780788079808080818082808380848085808680878088808980908091809280938094809580968097809880998100810181028103810481058106810781088109811081118112811381148115811681178118811981208121812281238124812581268127812881298130813181328133813481358136813781388139814081418142814381448145814681478148814981508151815281538154815581568157815881598160816181628163816481658166816781688169817081718172817381748175817681778178817981808181818281838184818581868187818881898190819181928193819481958196819781988199820082018202820382048205820682078208820982108211821282138214821582168217821882198220822182228223822482258226822782288229823082318232823382348235823682378238823982408241824282438244824582468247824882498250825182528253825482558256825782588259826082618262826382648265826682678268826982708271827282738274827582768277827882798280828182828283828482858286828782888289829082918292829382948295829682978298829983008301830283038304830583068307830883098310831183128313831483158316831783188319832083218322832383248325832683278328832983308331833283338334833583368337833883398340834183428343834483458346834783488349835083518352835383548355835683578358835983608361836283638364836583668367836883698370837183728373837483758376837783788379838083818382838383848385838683878388838983908391839283938394839583968397839883998400840184028403840484058406840784088409841084118412841384148415841684178418841984208421842284238424842584268427842884298430843184328433843484358436843784388439844084418442844384448445844684478448844984508451845284538454845584568457845884598460846184628463846484658466846784688469847084718472847384748475847684778478847984808481848284838484848584868487848884898490849184928493849484958496849784988499850085018502850385048505850685078508850985108511851285138514851585168517851885198520852185228523852485258526852785288529853085318532853385348535853685378538853985408541854285438544854585468547854885498550855185528553855485558556855785588559856085618562856385648565856685678568856985708571857285738574857585768577857885798580858185828583858485858586858785888589859085918592859385948595859685978598859986008601860286038604860586068607860886098610861186128613861486158616861786188619862086218622862386248625862686278628862986308631863286338634863586368637863886398640864186428643864486458646864786488649865086518652865386548655865686578658865986608661866286638664866586668667866886698670867186728673867486758676867786788679868086818682868386848685868686878688868986908691869286938694869586968697869886998700870187028703870487058706870787088709871087118712871387148715871687178718871987208721872287238724872587268727872887298730873187328733873487358736873787388739874087418742874387448745874687478748874987508751875287538754875587568757875887598760876187628763876487658766876787688769877087718772877387748775877687778778877987808781878287838784878587868787878887898790879187928793879487958796879787988799880088018802880388048805880688078808880988108811881288138814881588168817881888198820882188228823882488258826882788288829883088318832883388348835883688378838883988408841884288438844884588468847884888498850885188528853885488558856885788588859886088618862886388648865886688678868886988708871887288738874887588768877887888798880888188828883888488858886888788888889889088918892889388948895889688978898889989008901890289038904890589068907890889098910891189128913891489158916891789188919892089218922892389248925892689278928892989308931893289338934893589368937893889398940894189428943894489458946894789488949895089518952895389548955895689578958895989608961896289638964896589668967896889698970897189728973897489758976897789788979898089818982898389848985898689878988898989908991899289938994899589968997899889999000900190029003900490059006900790089009901090119012901390149015901690179018901990209021902290239024902590269027902890299030903190329033903490359036903790389039904090419042904390449045904690479048904990509051905290539054905590569057905890599060906190629063906490659066906790689069907090719072907390749075907690779078907990809081908290839084908590869087908890899090909190929093909490959096909790989099910091019102910391049105910691079108910991109111911291139114911591169117911891199120912191229123912491259126912791289129913091319132913391349135913691379138913991409141914291439144914591469147914891499150915191529153915491559156915791589159916091619162916391649165916691679168916991709171917291739174917591769177917891799180918191829183918491859186918791889189919091919192919391949195919691979198919992009201920292039204920592069207920892099210921192129213921492159216921792189219922092219222922392249225922692279228922992309231923292339234923592369237923892399240924192429243924492459246924792489249925092519252925392549255925692579258925992609261926292639264926592669267926892699270927192729273927492759276927792789279928092819282928392849285928692879288928992909291929292939294929592969297929892999300930193029303930493059306930793089309931093119312931393149315931693179318931993209321932293239324932593269327932893299330933193329333933493359336933793389339934093419342934393449345934693479348934993509351935293539354935593569357935893599360936193629363936493659366936793689369937093719372937393749375937693779378937993809381938293839384938593869387938893899390939193929393939493959396939793989399940094019402940394049405940694079408940994109411941294139414941594169417941894199420942194229423942494259426942794289429943094319432943394349435943694379438943994409441944294439444944594469447944894499450945194529453945494559456945794589459946094619462946394649465946694679468946994709471947294739474947594769477947894799480948194829483948494859486948794889489949094919492949394949495949694979498949995009501950295039504950595069507950895099510951195129513951495159516951795189519952095219522952395249525952695279528952995309531953295339534953595369537953895399540954195429543954495459546954795489549955095519552955395549555955695579558955995609561956295639564956595669567956895699570957195729573957495759576957795789579958095819582958395849585958695879588958995909591959295939594959595969597959895999600960196029603960496059606960796089609961096119612961396149615961696179618961996209621962296239624962596269627962896299630963196329633963496359636963796389639964096419642964396449645964696479648964996509651965296539654965596569657965896599660966196629663966496659666966796689669967096719672967396749675967696779678967996809681968296839684968596869687968896899690969196929693969496959696969796989699970097019702970397049705970697079708970997109711971297139714971597169717971897199720972197229723972497259726972797289729973097319732973397349735973697379738973997409741974297439744974597469747974897499750975197529753975497559756975797589759976097619762976397649765976697679768976997709771977297739774977597769777977897799780978197829783978497859786978797889789979097919792979397949795979697979798979998009801980298039804980598069807980898099810981198129813981498159816981798189819982098219822982398249825982698279828982998309831983298339834983598369837983898399840984198429843984498459846984798489849985098519852985398549855985698579858985998609861986298639864986598669867986898699870987198729873987498759876987798789879988098819882988398849885988698879888988998909891989298939894989598969897989898999900990199029903990499059906990799089909991099119912991399149915991699179918991999209921992299239924992599269927992899299930993199329933993499359936993799389939994099419942994399449945994699479948994999509951995299539954995599569957995899599960996199629963996499659966996799689969997099719972997399749975997699779978997999809981998299839984998599869987998899899990999199929993999499959996999799989999100001000110002100031000410005100061000710008100091001010011100121001310014100151001610017100181001910020100211002210023100241002510026100271002810029100301003110032100331003410035100361003710038100391004010041100421004310044100451004610047100481004910050100511005210053100541005510056100571005810059100601006110062100631006410065100661006710068100691007010071100721007310074100751007610077100781007910080100811008210083100841008510086100871008810089100901009110092100931009410095100961009710098100991010010101101021010310104101051010610107101081010910110101111011210113101141011510116101171011810119101201012110122101231012410125101261012710128101291013010131101321013310134101351013610137101381013910140101411014210143101441014510146101471014810149101501015110152101531015410155101561015710158101591016010161101621016310164101651016610167101681016910170101711017210173101741017510176101771017810179101801018110182101831018410185101861018710188101891019010191101921019310194101951019610197101981019910200102011020210203102041020510206102071020810209102101021110212102131021410215102161021710218102191022010221102221022310224102251022610227102281022910230102311023210233102341023510236102371023810239102401024110242102431024410245102461024710248102491025010251102521025310254102551025610257102581025910260102611026210263102641026510266102671026810269102701027110272102731027410275102761027710278102791028010281102821028310284102851028610287102881028910290102911029210293102941029510296102971029810299103001030110302103031030410305103061030710308103091031010311103121031310314103151031610317103181031910320103211032210323103241032510326103271032810329103301033110332103331033410335103361033710338103391034010341103421034310344103451034610347103481034910350103511035210353103541035510356103571035810359103601036110362103631036410365103661036710368103691037010371103721037310374103751037610377103781037910380103811038210383103841038510386103871038810389103901039110392103931039410395103961039710398103991040010401104021040310404104051040610407104081040910410104111041210413104141041510416104171041810419104201042110422104231042410425104261042710428104291043010431104321043310434104351043610437104381043910440104411044210443104441044510446104471044810449104501045110452104531045410455104561045710458104591046010461104621046310464104651046610467104681046910470104711047210473104741047510476104771047810479104801048110482104831048410485104861048710488104891049010491104921049310494104951049610497104981049910500105011050210503105041050510506105071050810509105101051110512105131051410515105161051710518105191052010521105221052310524105251052610527105281052910530105311053210533105341053510536105371053810539105401054110542105431054410545105461054710548105491055010551105521055310554105551055610557105581055910560105611056210563105641056510566105671056810569105701057110572105731057410575105761057710578105791058010581105821058310584105851058610587105881058910590105911059210593105941059510596105971059810599106001060110602106031060410605106061060710608106091061010611106121061310614106151061610617106181061910620106211062210623106241062510626106271062810629106301063110632106331063410635106361063710638106391064010641106421064310644106451064610647106481064910650106511065210653106541065510656106571065810659106601066110662106631066410665106661066710668106691067010671106721067310674106751067610677106781067910680106811068210683106841068510686106871068810689106901069110692106931069410695106961069710698106991070010701107021070310704107051070610707107081070910710107111071210713107141071510716107171071810719107201072110722107231072410725107261072710728107291073010731107321073310734107351073610737107381073910740107411074210743107441074510746107471074810749107501075110752107531075410755107561075710758107591076010761107621076310764107651076610767107681076910770107711077210773107741077510776107771077810779107801078110782107831078410785107861078710788107891079010791107921079310794107951079610797107981079910800108011080210803108041080510806108071080810809108101081110812108131081410815108161081710818108191082010821108221082310824108251082610827108281082910830108311083210833108341083510836108371083810839108401084110842108431084410845108461084710848108491085010851108521085310854108551085610857108581085910860108611086210863108641086510866108671086810869108701087110872108731087410875108761087710878108791088010881108821088310884108851088610887108881088910890108911089210893108941089510896108971089810899109001090110902109031090410905109061090710908109091091010911109121091310914109151091610917109181091910920109211092210923109241092510926109271092810929109301093110932109331093410935109361093710938109391094010941109421094310944109451094610947109481094910950109511095210953109541095510956109571095810959109601096110962109631096410965109661096710968109691097010971109721097310974109751097610977109781097910980109811098210983109841098510986109871098810989109901099110992109931099410995109961099710998109991100011001110021100311004110051100611007110081100911010110111101211013110141101511016110171101811019110201102111022110231102411025110261102711028110291103011031110321103311034110351103611037110381103911040110411104211043110441104511046110471104811049110501105111052110531105411055110561105711058110591106011061110621106311064110651106611067110681106911070110711107211073110741107511076110771107811079110801108111082110831108411085110861108711088110891109011091110921109311094110951109611097110981109911100111011110211103111041110511106111071110811109111101111111112111131111411115111161111711118111191112011121111221112311124111251112611127111281112911130111311113211133111341113511136111371113811139111401114111142111431114411145111461114711148111491115011151111521115311154111551115611157111581115911160111611116211163111641116511166111671116811169111701117111172111731117411175111761117711178111791118011181111821118311184111851118611187111881118911190111911119211193111941119511196111971119811199112001120111202112031120411205112061120711208112091121011211112121121311214112151121611217112181121911220112211122211223112241122511226112271122811229112301123111232112331123411235112361123711238112391124011241112421124311244112451124611247112481124911250112511125211253112541125511256112571125811259112601126111262112631126411265112661126711268112691127011271112721127311274112751127611277112781127911280112811128211283112841128511286112871128811289112901129111292112931129411295112961129711298112991130011301113021130311304113051130611307113081130911310113111131211313113141131511316113171131811319113201132111322113231132411325113261132711328113291133011331113321133311334113351133611337113381133911340113411134211343113441134511346113471134811349113501135111352113531135411355113561135711358113591136011361113621136311364113651136611367113681136911370113711137211373113741137511376113771137811379113801138111382113831138411385113861138711388113891139011391113921139311394113951139611397113981139911400114011140211403114041140511406114071140811409114101141111412114131141411415114161141711418114191142011421114221142311424114251142611427114281142911430114311143211433114341143511436114371143811439114401144111442114431144411445114461144711448114491145011451114521145311454114551145611457114581145911460114611146211463114641146511466114671146811469114701147111472114731147411475114761147711478114791148011481114821148311484114851148611487114881148911490114911149211493114941149511496114971149811499115001150111502115031150411505115061150711508115091151011511115121151311514115151151611517115181151911520115211152211523115241152511526115271152811529115301153111532115331153411535115361153711538115391154011541115421154311544115451154611547115481154911550115511155211553115541155511556115571155811559115601156111562115631156411565115661156711568115691157011571115721157311574115751157611577115781157911580115811158211583115841158511586115871158811589115901159111592115931159411595115961159711598115991160011601116021160311604116051160611607116081160911610116111161211613116141161511616116171161811619116201162111622116231162411625116261162711628116291163011631116321163311634116351163611637116381163911640116411164211643116441164511646116471164811649116501165111652116531165411655116561165711658116591166011661116621166311664116651166611667116681166911670116711167211673116741167511676116771167811679116801168111682116831168411685116861168711688116891169011691116921169311694116951169611697116981169911700117011170211703117041170511706117071170811709117101171111712117131171411715117161171711718117191172011721117221172311724117251172611727117281172911730117311173211733117341173511736117371173811739117401174111742117431174411745117461174711748117491175011751117521175311754117551175611757117581175911760117611176211763117641176511766117671176811769117701177111772117731177411775117761177711778117791178011781117821178311784117851178611787117881178911790117911179211793117941179511796117971179811799118001180111802118031180411805118061180711808118091181011811118121181311814118151181611817118181181911820118211182211823118241182511826118271182811829118301183111832118331183411835118361183711838118391184011841118421184311844118451184611847118481184911850118511185211853118541185511856118571185811859118601186111862118631186411865118661186711868118691187011871118721187311874118751187611877118781187911880118811188211883118841188511886118871188811889118901189111892118931189411895118961189711898118991190011901119021190311904119051190611907119081190911910119111191211913119141191511916119171191811919119201192111922119231192411925119261192711928119291193011931119321193311934119351193611937119381193911940119411194211943119441194511946119471194811949119501195111952119531195411955119561195711958119591196011961119621196311964119651196611967119681196911970119711197211973119741197511976119771197811979119801198111982119831198411985119861198711988119891199011991119921199311994119951199611997119981199912000120011200212003120041200512006120071200812009120101201112012120131201412015120161201712018120191202012021120221202312024120251202612027120281202912030120311203212033120341203512036120371203812039120401204112042120431204412045120461204712048120491205012051120521205312054120551205612057120581205912060120611206212063120641206512066120671206812069120701207112072120731207412075120761207712078120791208012081120821208312084120851208612087120881208912090120911209212093120941209512096120971209812099121001210112102121031210412105121061210712108121091211012111121121211312114121151211612117121181211912120121211212212123121241212512126121271212812129121301213112132121331213412135121361213712138121391214012141121421214312144121451214612147121481214912150121511215212153121541215512156121571215812159121601216112162121631216412165121661216712168121691217012171121721217312174121751217612177121781217912180121811218212183121841218512186121871218812189121901219112192121931219412195121961219712198121991220012201122021220312204122051220612207122081220912210122111221212213122141221512216122171221812219122201222112222122231222412225122261222712228122291223012231122321223312234122351223612237122381223912240122411224212243122441224512246122471224812249122501225112252122531225412255122561225712258122591226012261122621226312264122651226612267122681226912270122711227212273122741227512276122771227812279122801228112282122831228412285122861228712288122891229012291122921229312294122951229612297122981229912300123011230212303123041230512306123071230812309123101231112312123131231412315123161231712318123191232012321123221232312324123251232612327123281232912330123311233212333123341233512336123371233812339123401234112342123431234412345123461234712348123491235012351123521235312354123551235612357123581235912360123611236212363123641236512366123671236812369123701237112372123731237412375123761237712378123791238012381123821238312384123851238612387123881238912390123911239212393123941239512396123971239812399124001240112402124031240412405124061240712408124091241012411124121241312414124151241612417124181241912420124211242212423124241242512426124271242812429124301243112432124331243412435124361243712438124391244012441124421244312444124451244612447124481244912450124511245212453124541245512456124571245812459124601246112462124631246412465124661246712468124691247012471124721247312474124751247612477124781247912480124811248212483124841248512486124871248812489124901249112492124931249412495124961249712498124991250012501125021250312504125051250612507125081250912510125111251212513125141251512516125171251812519125201252112522125231252412525125261252712528125291253012531125321253312534125351253612537125381253912540125411254212543125441254512546125471254812549125501255112552125531255412555125561255712558125591256012561125621256312564125651256612567125681256912570125711257212573125741257512576125771257812579125801258112582125831258412585125861258712588125891259012591125921259312594125951259612597125981259912600126011260212603126041260512606126071260812609126101261112612126131261412615126161261712618126191262012621126221262312624126251262612627126281262912630126311263212633126341263512636126371263812639126401264112642126431264412645126461264712648126491265012651126521265312654126551265612657126581265912660126611266212663126641266512666126671266812669126701267112672126731267412675126761267712678126791268012681126821268312684126851268612687126881268912690126911269212693126941269512696126971269812699127001270112702127031270412705127061270712708127091271012711127121271312714127151271612717127181271912720127211272212723127241272512726127271272812729127301273112732127331273412735127361273712738127391274012741127421274312744127451274612747127481274912750127511275212753127541275512756127571275812759127601276112762127631276412765127661276712768127691277012771127721277312774127751277612777127781277912780127811278212783127841278512786127871278812789127901279112792127931279412795127961279712798127991280012801128021280312804128051280612807128081280912810128111281212813128141281512816128171281812819128201282112822128231282412825128261282712828128291283012831128321283312834128351283612837128381283912840128411284212843128441284512846128471284812849128501285112852128531285412855128561285712858128591286012861128621286312864128651286612867128681286912870128711287212873128741287512876128771287812879128801288112882128831288412885128861288712888128891289012891128921289312894128951289612897128981289912900129011290212903129041290512906129071290812909129101291112912129131291412915129161291712918129191292012921129221292312924129251292612927129281292912930129311293212933129341293512936129371293812939129401294112942129431294412945129461294712948129491295012951129521295312954129551295612957129581295912960129611296212963129641296512966129671296812969129701297112972129731297412975129761297712978129791298012981129821298312984129851298612987129881298912990129911299212993129941299512996129971299812999130001300113002130031300413005130061300713008130091301013011130121301313014130151301613017130181301913020130211302213023130241302513026130271302813029130301303113032130331303413035130361303713038130391304013041130421304313044130451304613047130481304913050130511305213053130541305513056130571305813059130601306113062130631306413065130661306713068130691307013071130721307313074130751307613077130781307913080130811308213083130841308513086130871308813089130901309113092130931309413095130961309713098130991310013101131021310313104131051310613107131081310913110131111311213113131141311513116131171311813119131201312113122131231312413125131261312713128131291313013131131321313313134131351313613137131381313913140131411314213143131441314513146131471314813149131501315113152131531315413155131561315713158131591316013161131621316313164131651316613167131681316913170131711317213173131741317513176131771317813179131801318113182131831318413185131861318713188131891319013191131921319313194131951319613197131981319913200132011320213203132041320513206132071320813209132101321113212132131321413215132161321713218132191322013221132221322313224132251322613227132281322913230132311323213233132341323513236132371323813239132401324113242132431324413245132461324713248132491325013251132521325313254132551325613257132581325913260132611326213263132641326513266132671326813269132701327113272132731327413275132761327713278132791328013281132821328313284132851328613287132881328913290132911329213293132941329513296132971329813299133001330113302133031330413305133061330713308133091331013311133121331313314133151331613317133181331913320133211332213323133241332513326133271332813329133301333113332133331333413335133361333713338133391334013341133421334313344133451334613347133481334913350133511335213353133541335513356133571335813359133601336113362133631336413365133661336713368133691337013371133721337313374133751337613377133781337913380133811338213383133841338513386133871338813389133901339113392133931339413395133961339713398133991340013401134021340313404134051340613407134081340913410134111341213413134141341513416134171341813419134201342113422134231342413425134261342713428134291343013431134321343313434134351343613437134381343913440134411344213443134441344513446134471344813449134501345113452134531345413455134561345713458134591346013461134621346313464134651346613467134681346913470134711347213473134741347513476134771347813479134801348113482134831348413485134861348713488134891349013491134921349313494134951349613497134981349913500135011350213503135041350513506135071350813509135101351113512135131351413515135161351713518135191352013521135221352313524135251352613527135281352913530135311353213533135341353513536135371353813539135401354113542135431354413545135461354713548135491355013551135521355313554135551355613557135581355913560135611356213563135641356513566135671356813569135701357113572135731357413575135761357713578135791358013581135821358313584135851358613587135881358913590135911359213593135941359513596135971359813599136001360113602136031360413605136061360713608136091361013611136121361313614136151361613617136181361913620136211362213623136241362513626136271362813629136301363113632136331363413635136361363713638136391364013641136421364313644136451364613647136481364913650136511365213653136541365513656136571365813659136601366113662136631366413665136661366713668136691367013671136721367313674136751367613677136781367913680136811368213683136841368513686136871368813689136901369113692136931369413695136961369713698136991370013701137021370313704137051370613707137081370913710137111371213713137141371513716137171371813719137201372113722137231372413725137261372713728137291373013731137321373313734137351373613737137381373913740137411374213743137441374513746137471374813749137501375113752137531375413755137561375713758137591376013761137621376313764137651376613767137681376913770137711377213773137741377513776137771377813779137801378113782137831378413785137861378713788137891379013791137921379313794137951379613797137981379913800138011380213803138041380513806138071380813809138101381113812138131381413815138161381713818138191382013821138221382313824138251382613827138281382913830138311383213833138341383513836138371383813839138401384113842138431384413845138461384713848138491385013851138521385313854138551385613857138581385913860138611386213863138641386513866138671386813869138701387113872138731387413875138761387713878138791388013881138821388313884138851388613887138881388913890138911389213893138941389513896138971389813899139001390113902139031390413905139061390713908139091391013911139121391313914139151391613917139181391913920139211392213923139241392513926139271392813929139301393113932139331393413935139361393713938139391394013941139421394313944139451394613947139481394913950139511395213953139541395513956139571395813959139601396113962139631396413965139661396713968139691397013971139721397313974139751397613977139781397913980139811398213983139841398513986139871398813989139901399113992139931399413995139961399713998139991400014001140021400314004140051400614007140081400914010140111401214013140141401514016140171401814019140201402114022140231402414025140261402714028140291403014031140321403314034140351403614037140381403914040140411404214043140441404514046140471404814049140501405114052140531405414055140561405714058140591406014061140621406314064140651406614067140681406914070140711407214073140741407514076140771407814079140801408114082140831408414085140861408714088140891409014091140921409314094140951409614097140981409914100141011410214103141041410514106141071410814109141101411114112141131411414115141161411714118141191412014121141221412314124141251412614127141281412914130141311413214133141341413514136141371413814139141401414114142141431414414145141461414714148141491415014151141521415314154141551415614157141581415914160141611416214163141641416514166141671416814169141701417114172141731417414175141761417714178141791418014181141821418314184141851418614187141881418914190141911419214193141941419514196141971419814199142001420114202142031420414205142061420714208142091421014211142121421314214142151421614217142181421914220142211422214223142241422514226142271422814229142301423114232142331423414235142361423714238142391424014241142421424314244142451424614247142481424914250142511425214253142541425514256142571425814259142601426114262142631426414265142661426714268142691427014271142721427314274142751427614277142781427914280142811428214283142841428514286142871428814289142901429114292142931429414295142961429714298142991430014301143021430314304143051430614307143081430914310143111431214313143141431514316143171431814319143201432114322143231432414325143261432714328143291433014331143321433314334143351433614337143381433914340143411434214343143441434514346143471434814349143501435114352143531435414355143561435714358143591436014361143621436314364143651436614367143681436914370143711437214373143741437514376143771437814379143801438114382143831438414385143861438714388143891439014391143921439314394143951439614397143981439914400144011440214403144041440514406144071440814409144101441114412144131441414415144161441714418144191442014421144221442314424144251442614427144281442914430144311443214433144341443514436144371443814439144401444114442144431444414445144461444714448144491445014451144521445314454144551445614457144581445914460144611446214463144641446514466144671446814469144701447114472144731447414475144761447714478144791448014481144821448314484144851448614487144881448914490144911449214493144941449514496144971449814499145001450114502145031450414505145061450714508145091451014511145121451314514145151451614517145181451914520145211452214523145241452514526145271452814529145301453114532145331453414535145361453714538145391454014541145421454314544145451454614547145481454914550145511455214553145541455514556145571455814559145601456114562145631456414565145661456714568145691457014571145721457314574145751457614577145781457914580145811458214583145841458514586145871458814589145901459114592145931459414595145961459714598145991460014601146021460314604146051460614607146081460914610146111461214613146141461514616146171461814619146201462114622146231462414625146261462714628146291463014631146321463314634146351463614637146381463914640146411464214643146441464514646146471464814649146501465114652146531465414655146561465714658146591466014661146621466314664146651466614667146681466914670146711467214673146741467514676146771467814679146801468114682146831468414685146861468714688146891469014691146921469314694146951469614697146981469914700147011470214703147041470514706147071470814709147101471114712147131471414715147161471714718147191472014721147221472314724147251472614727147281472914730147311473214733147341473514736147371473814739147401474114742147431474414745147461474714748147491475014751147521475314754147551475614757147581475914760147611476214763147641476514766147671476814769147701477114772147731477414775147761477714778147791478014781147821478314784147851478614787147881478914790147911479214793147941479514796147971479814799148001480114802148031480414805148061480714808148091481014811148121481314814148151481614817148181481914820148211482214823148241482514826148271482814829148301483114832148331483414835148361483714838148391484014841148421484314844148451484614847148481484914850148511485214853148541485514856148571485814859148601486114862148631486414865148661486714868148691487014871148721487314874148751487614877148781487914880148811488214883148841488514886148871488814889148901489114892148931489414895148961489714898148991490014901149021490314904149051490614907149081490914910149111491214913149141491514916149171491814919149201492114922149231492414925149261492714928149291493014931149321493314934149351493614937149381493914940149411494214943149441494514946149471494814949149501495114952149531495414955149561495714958149591496014961149621496314964149651496614967149681496914970149711497214973149741497514976149771497814979149801498114982149831498414985149861498714988149891499014991149921499314994149951499614997149981499915000150011500215003150041500515006150071500815009150101501115012150131501415015150161501715018150191502015021150221502315024150251502615027150281502915030150311503215033150341503515036150371503815039150401504115042150431504415045150461504715048150491505015051150521505315054150551505615057150581505915060150611506215063150641506515066150671506815069150701507115072150731507415075150761507715078150791508015081150821508315084150851508615087150881508915090150911509215093150941509515096150971509815099151001510115102151031510415105151061510715108151091511015111151121511315114151151511615117151181511915120151211512215123151241512515126151271512815129151301513115132151331513415135151361513715138151391514015141151421514315144151451514615147151481514915150151511515215153151541515515156151571515815159151601516115162151631516415165151661516715168151691517015171151721517315174151751517615177151781517915180151811518215183151841518515186151871518815189151901519115192151931519415195151961519715198151991520015201152021520315204152051520615207152081520915210152111521215213152141521515216152171521815219152201522115222152231522415225152261522715228152291523015231152321523315234152351523615237152381523915240152411524215243152441524515246152471524815249152501525115252152531525415255152561525715258152591526015261152621526315264152651526615267152681526915270152711527215273152741527515276152771527815279152801528115282152831528415285152861528715288152891529015291152921529315294152951529615297152981529915300153011530215303153041530515306153071530815309153101531115312153131531415315153161531715318153191532015321153221532315324153251532615327153281532915330153311533215333153341533515336153371533815339153401534115342153431534415345153461534715348153491535015351153521535315354153551535615357153581535915360153611536215363153641536515366153671536815369153701537115372153731537415375153761537715378153791538015381153821538315384153851538615387153881538915390153911539215393153941539515396153971539815399154001540115402154031540415405154061540715408154091541015411154121541315414154151541615417154181541915420154211542215423154241542515426154271542815429154301543115432154331543415435154361543715438154391544015441154421544315444154451544615447154481544915450154511545215453154541545515456154571545815459154601546115462154631546415465154661546715468154691547015471154721547315474154751547615477154781547915480154811548215483154841548515486154871548815489154901549115492154931549415495154961549715498154991550015501155021550315504155051550615507155081550915510155111551215513155141551515516155171551815519155201552115522155231552415525155261552715528155291553015531155321553315534155351553615537155381553915540155411554215543155441554515546155471554815549155501555115552155531555415555155561555715558155591556015561155621556315564155651556615567155681556915570155711557215573155741557515576155771557815579155801558115582155831558415585155861558715588155891559015591155921559315594155951559615597155981559915600156011560215603156041560515606156071560815609156101561115612156131561415615156161561715618156191562015621156221562315624156251562615627156281562915630156311563215633156341563515636156371563815639156401564115642156431564415645156461564715648156491565015651156521565315654156551565615657156581565915660156611566215663156641566515666156671566815669156701567115672156731567415675156761567715678156791568015681156821568315684156851568615687156881568915690156911569215693156941569515696156971569815699157001570115702157031570415705157061570715708157091571015711157121571315714157151571615717157181571915720157211572215723157241572515726157271572815729157301573115732157331573415735157361573715738157391574015741157421574315744157451574615747157481574915750157511575215753157541575515756157571575815759157601576115762157631576415765157661576715768157691577015771157721577315774157751577615777157781577915780157811578215783157841578515786157871578815789157901579115792157931579415795157961579715798157991580015801158021580315804158051580615807158081580915810158111581215813158141581515816158171581815819158201582115822158231582415825158261582715828158291583015831158321583315834158351583615837158381583915840158411584215843158441584515846158471584815849158501585115852158531585415855158561585715858158591586015861158621586315864158651586615867158681586915870158711587215873158741587515876158771587815879158801588115882158831588415885158861588715888158891589015891158921589315894158951589615897158981589915900159011590215903159041590515906159071590815909159101591115912159131591415915159161591715918159191592015921159221592315924159251592615927159281592915930159311593215933159341593515936159371593815939159401594115942159431594415945159461594715948159491595015951159521595315954159551595615957159581595915960159611596215963159641596515966159671596815969159701597115972159731597415975159761597715978159791598015981159821598315984159851598615987159881598915990159911599215993159941599515996159971599815999160001600116002160031600416005160061600716008160091601016011160121601316014160151601616017160181601916020160211602216023160241602516026160271602816029160301603116032160331603416035160361603716038160391604016041160421604316044160451604616047160481604916050160511605216053160541605516056160571605816059160601606116062160631606416065160661606716068160691607016071160721607316074160751607616077160781607916080160811608216083160841608516086160871608816089160901609116092160931609416095160961609716098160991610016101161021610316104161051610616107161081610916110161111611216113161141611516116161171611816119161201612116122161231612416125161261612716128161291613016131161321613316134161351613616137161381613916140161411614216143161441614516146161471614816149161501615116152161531615416155161561615716158161591616016161161621616316164161651616616167161681616916170161711617216173161741617516176161771617816179161801618116182161831618416185161861618716188161891619016191161921619316194161951619616197161981619916200162011620216203162041620516206162071620816209162101621116212162131621416215162161621716218162191622016221162221622316224162251622616227162281622916230162311623216233162341623516236162371623816239162401624116242162431624416245162461624716248162491625016251162521625316254162551625616257162581625916260162611626216263162641626516266162671626816269162701627116272162731627416275162761627716278162791628016281162821628316284162851628616287162881628916290162911629216293162941629516296162971629816299163001630116302163031630416305163061630716308163091631016311163121631316314163151631616317163181631916320163211632216323163241632516326163271632816329163301633116332163331633416335163361633716338163391634016341163421634316344163451634616347163481634916350163511635216353163541635516356163571635816359163601636116362163631636416365163661636716368163691637016371163721637316374163751637616377163781637916380163811638216383163841638516386163871638816389163901639116392163931639416395163961639716398163991640016401164021640316404164051640616407164081640916410164111641216413164141641516416164171641816419164201642116422164231642416425164261642716428164291643016431164321643316434164351643616437164381643916440164411644216443164441644516446164471644816449164501645116452164531645416455164561645716458164591646016461164621646316464164651646616467164681646916470164711647216473164741647516476164771647816479164801648116482164831648416485164861648716488164891649016491164921649316494164951649616497164981649916500165011650216503165041650516506165071650816509165101651116512165131651416515165161651716518165191652016521165221652316524165251652616527165281652916530165311653216533165341653516536165371653816539165401654116542165431654416545165461654716548165491655016551165521655316554165551655616557165581655916560165611656216563165641656516566165671656816569165701657116572165731657416575165761657716578165791658016581165821658316584165851658616587165881658916590165911659216593165941659516596165971659816599166001660116602166031660416605166061660716608166091661016611166121661316614166151661616617166181661916620166211662216623166241662516626166271662816629166301663116632166331663416635166361663716638166391664016641166421664316644166451664616647166481664916650166511665216653166541665516656166571665816659166601666116662166631666416665166661666716668166691667016671166721667316674166751667616677166781667916680166811668216683166841668516686166871668816689166901669116692166931669416695166961669716698166991670016701167021670316704167051670616707167081670916710167111671216713167141671516716167171671816719167201672116722167231672416725167261672716728167291673016731167321673316734167351673616737167381673916740167411674216743167441674516746167471674816749167501675116752167531675416755167561675716758167591676016761167621676316764167651676616767167681676916770167711677216773167741677516776167771677816779167801678116782167831678416785167861678716788167891679016791167921679316794167951679616797167981679916800168011680216803168041680516806168071680816809168101681116812168131681416815168161681716818168191682016821168221682316824168251682616827168281682916830168311683216833168341683516836168371683816839168401684116842168431684416845168461684716848168491685016851168521685316854168551685616857168581685916860168611686216863168641686516866168671686816869168701687116872168731687416875168761687716878168791688016881168821688316884168851688616887168881688916890168911689216893168941689516896168971689816899169001690116902169031690416905169061690716908169091691016911169121691316914169151691616917169181691916920169211692216923169241692516926169271692816929169301693116932169331693416935169361693716938169391694016941169421694316944169451694616947169481694916950169511695216953169541695516956169571695816959169601696116962169631696416965169661696716968169691697016971169721697316974169751697616977169781697916980169811698216983169841698516986169871698816989169901699116992169931699416995169961699716998169991700017001170021700317004170051700617007170081700917010170111701217013170141701517016170171701817019170201702117022170231702417025170261702717028170291703017031170321703317034170351703617037170381703917040170411704217043170441704517046170471704817049170501705117052170531705417055170561705717058170591706017061170621706317064170651706617067170681706917070170711707217073170741707517076170771707817079170801708117082170831708417085170861708717088170891709017091170921709317094170951709617097170981709917100171011710217103171041710517106171071710817109171101711117112171131711417115171161711717118171191712017121171221712317124171251712617127171281712917130171311713217133171341713517136171371713817139171401714117142171431714417145171461714717148171491715017151171521715317154171551715617157171581715917160171611716217163171641716517166171671716817169171701717117172171731717417175171761717717178171791718017181171821718317184171851718617187171881718917190171911719217193171941719517196171971719817199172001720117202172031720417205172061720717208172091721017211172121721317214172151721617217172181721917220172211722217223172241722517226172271722817229172301723117232172331723417235172361723717238172391724017241172421724317244172451724617247172481724917250172511725217253172541725517256172571725817259172601726117262172631726417265172661726717268172691727017271172721727317274172751727617277172781727917280172811728217283172841728517286172871728817289172901729117292172931729417295172961729717298172991730017301173021730317304173051730617307173081730917310173111731217313173141731517316173171731817319173201732117322173231732417325173261732717328173291733017331173321733317334173351733617337173381733917340173411734217343173441734517346173471734817349173501735117352173531735417355173561735717358173591736017361173621736317364173651736617367173681736917370173711737217373173741737517376173771737817379173801738117382173831738417385173861738717388173891739017391173921739317394173951739617397173981739917400174011740217403174041740517406174071740817409174101741117412174131741417415174161741717418174191742017421174221742317424174251742617427174281742917430174311743217433174341743517436174371743817439174401744117442174431744417445174461744717448174491745017451174521745317454174551745617457174581745917460174611746217463174641746517466174671746817469174701747117472174731747417475174761747717478174791748017481174821748317484174851748617487174881748917490174911749217493174941749517496174971749817499175001750117502175031750417505175061750717508175091751017511175121751317514175151751617517175181751917520175211752217523175241752517526175271752817529175301753117532175331753417535175361753717538175391754017541175421754317544175451754617547175481754917550175511755217553175541755517556175571755817559175601756117562175631756417565175661756717568175691757017571175721757317574175751757617577175781757917580175811758217583175841758517586175871758817589175901759117592175931759417595175961759717598175991760017601176021760317604176051760617607176081760917610176111761217613176141761517616176171761817619176201762117622176231762417625176261762717628176291763017631176321763317634176351763617637176381763917640176411764217643176441764517646176471764817649176501765117652176531765417655176561765717658176591766017661176621766317664176651766617667176681766917670176711767217673176741767517676176771767817679176801768117682176831768417685176861768717688176891769017691176921769317694176951769617697176981769917700177011770217703177041770517706177071770817709177101771117712177131771417715177161771717718177191772017721177221772317724177251772617727177281772917730177311773217733177341773517736177371773817739177401774117742177431774417745177461774717748177491775017751177521775317754177551775617757177581775917760177611776217763177641776517766177671776817769177701777117772177731777417775177761777717778177791778017781177821778317784177851778617787177881778917790177911779217793177941779517796177971779817799178001780117802178031780417805178061780717808178091781017811178121781317814178151781617817178181781917820178211782217823178241782517826178271782817829178301783117832178331783417835178361783717838178391784017841178421784317844178451784617847178481784917850178511785217853178541785517856178571785817859178601786117862178631786417865178661786717868178691787017871178721787317874178751787617877178781787917880178811788217883178841788517886178871788817889178901789117892178931789417895178961789717898178991790017901179021790317904179051790617907179081790917910179111791217913179141791517916179171791817919179201792117922179231792417925179261792717928179291793017931179321793317934179351793617937179381793917940179411794217943179441794517946179471794817949179501795117952179531795417955179561795717958179591796017961179621796317964179651796617967179681796917970179711797217973179741797517976179771797817979179801798117982179831798417985179861798717988179891799017991179921799317994179951799617997179981799918000180011800218003180041800518006180071800818009180101801118012180131801418015180161801718018180191802018021180221802318024180251802618027180281802918030180311803218033180341803518036180371803818039180401804118042180431804418045180461804718048180491805018051180521805318054180551805618057180581805918060180611806218063180641806518066180671806818069180701807118072180731807418075180761807718078180791808018081180821808318084180851808618087180881808918090180911809218093180941809518096180971809818099181001810118102181031810418105181061810718108181091811018111181121811318114181151811618117181181811918120181211812218123181241812518126181271812818129181301813118132181331813418135181361813718138181391814018141181421814318144181451814618147181481814918150181511815218153181541815518156181571815818159181601816118162181631816418165181661816718168181691817018171181721817318174181751817618177181781817918180181811818218183181841818518186181871818818189181901819118192181931819418195181961819718198181991820018201182021820318204182051820618207182081820918210182111821218213182141821518216182171821818219182201822118222182231822418225182261822718228182291823018231182321823318234182351823618237182381823918240182411824218243182441824518246182471824818249182501825118252182531825418255182561825718258182591826018261182621826318264182651826618267182681826918270182711827218273182741827518276182771827818279182801828118282182831828418285182861828718288182891829018291182921829318294182951829618297182981829918300183011830218303183041830518306183071830818309183101831118312183131831418315183161831718318183191832018321183221832318324183251832618327183281832918330183311833218333183341833518336183371833818339183401834118342183431834418345183461834718348183491835018351183521835318354183551835618357183581835918360183611836218363183641836518366183671836818369183701837118372183731837418375183761837718378183791838018381183821838318384183851838618387183881838918390183911839218393183941839518396183971839818399184001840118402184031840418405184061840718408184091841018411184121841318414184151841618417184181841918420184211842218423184241842518426184271842818429184301843118432184331843418435184361843718438184391844018441184421844318444184451844618447184481844918450184511845218453184541845518456184571845818459184601846118462184631846418465184661846718468184691847018471184721847318474184751847618477184781847918480184811848218483184841848518486184871848818489184901849118492184931849418495184961849718498184991850018501185021850318504185051850618507185081850918510185111851218513185141851518516185171851818519185201852118522185231852418525185261852718528185291853018531185321853318534185351853618537185381853918540185411854218543185441854518546185471854818549185501855118552185531855418555185561855718558185591856018561185621856318564185651856618567185681856918570185711857218573185741857518576185771857818579185801858118582185831858418585185861858718588185891859018591185921859318594185951859618597185981859918600186011860218603186041860518606186071860818609186101861118612186131861418615186161861718618186191862018621186221862318624186251862618627186281862918630186311863218633186341863518636186371863818639186401864118642186431864418645186461864718648186491865018651186521865318654186551865618657186581865918660186611866218663186641866518666186671866818669186701867118672186731867418675186761867718678186791868018681186821868318684186851868618687186881868918690186911869218693186941869518696186971869818699187001870118702187031870418705187061870718708187091871018711187121871318714187151871618717187181871918720187211872218723187241872518726187271872818729187301873118732187331873418735187361873718738187391874018741187421874318744187451874618747187481874918750187511875218753187541875518756187571875818759187601876118762187631876418765187661876718768187691877018771187721877318774187751877618777187781877918780187811878218783187841878518786187871878818789187901879118792187931879418795187961879718798187991880018801188021880318804188051880618807188081880918810188111881218813188141881518816188171881818819188201882118822188231882418825188261882718828188291883018831188321883318834188351883618837188381883918840188411884218843188441884518846188471884818849188501885118852188531885418855188561885718858188591886018861188621886318864188651886618867188681886918870188711887218873188741887518876188771887818879188801888118882188831888418885188861888718888188891889018891188921889318894188951889618897188981889918900189011890218903189041890518906189071890818909189101891118912189131891418915189161891718918189191892018921189221892318924189251892618927189281892918930189311893218933189341893518936189371893818939189401894118942189431894418945189461894718948189491895018951189521895318954189551895618957189581895918960189611896218963189641896518966189671896818969189701897118972189731897418975189761897718978189791898018981189821898318984189851898618987189881898918990189911899218993189941899518996189971899818999190001900119002190031900419005190061900719008190091901019011190121901319014190151901619017190181901919020190211902219023190241902519026190271902819029190301903119032190331903419035190361903719038190391904019041190421904319044190451904619047190481904919050190511905219053190541905519056190571905819059190601906119062190631906419065190661906719068190691907019071190721907319074190751907619077190781907919080190811908219083190841908519086190871908819089190901909119092190931909419095190961909719098190991910019101191021910319104191051910619107191081910919110191111911219113191141911519116191171911819119191201912119122191231912419125191261912719128191291913019131191321913319134191351913619137191381913919140191411914219143191441914519146191471914819149191501915119152191531915419155191561915719158191591916019161191621916319164191651916619167191681916919170191711917219173191741917519176191771917819179191801918119182191831918419185191861918719188191891919019191191921919319194191951919619197191981919919200192011920219203192041920519206192071920819209192101921119212192131921419215192161921719218192191922019221192221922319224192251922619227192281922919230192311923219233192341923519236192371923819239192401924119242192431924419245192461924719248192491925019251192521925319254192551925619257192581925919260192611926219263192641926519266192671926819269192701927119272192731927419275192761927719278192791928019281192821928319284192851928619287192881928919290192911929219293192941929519296192971929819299193001930119302193031930419305193061930719308193091931019311193121931319314193151931619317193181931919320193211932219323193241932519326193271932819329193301933119332193331933419335193361933719338193391934019341193421934319344193451934619347193481934919350193511935219353193541935519356193571935819359193601936119362193631936419365193661936719368193691937019371193721937319374193751937619377193781937919380193811938219383193841938519386193871938819389193901939119392193931939419395193961939719398193991940019401194021940319404194051940619407194081940919410194111941219413194141941519416194171941819419194201942119422194231942419425194261942719428194291943019431194321943319434194351943619437194381943919440194411944219443194441944519446194471944819449194501945119452194531945419455194561945719458194591946019461194621946319464194651946619467194681946919470194711947219473194741947519476194771947819479194801948119482194831948419485194861948719488194891949019491194921949319494194951949619497194981949919500195011950219503195041950519506195071950819509195101951119512195131951419515195161951719518195191952019521195221952319524195251952619527195281952919530195311953219533195341953519536195371953819539195401954119542195431954419545195461954719548195491955019551195521955319554195551955619557195581955919560195611956219563195641956519566195671956819569195701957119572195731957419575195761957719578195791958019581195821958319584195851958619587195881958919590195911959219593195941959519596195971959819599196001960119602196031960419605196061960719608196091961019611196121961319614196151961619617196181961919620196211962219623196241962519626196271962819629196301963119632196331963419635196361963719638196391964019641196421964319644196451964619647196481964919650196511965219653196541965519656196571965819659196601966119662196631966419665196661966719668196691967019671196721967319674196751967619677196781967919680196811968219683196841968519686196871968819689196901969119692196931969419695196961969719698196991970019701197021970319704197051970619707197081970919710197111971219713197141971519716197171971819719197201972119722197231972419725197261972719728197291973019731197321973319734197351973619737197381973919740197411974219743197441974519746197471974819749197501975119752197531975419755197561975719758197591976019761197621976319764197651976619767197681976919770197711977219773197741977519776197771977819779197801978119782197831978419785197861978719788197891979019791197921979319794197951979619797197981979919800198011980219803198041980519806198071980819809198101981119812198131981419815198161981719818198191982019821198221982319824198251982619827198281982919830198311983219833198341983519836198371983819839198401984119842198431984419845198461984719848198491985019851198521985319854198551985619857198581985919860198611986219863198641986519866198671986819869198701987119872198731987419875198761987719878198791988019881198821988319884198851988619887198881988919890198911989219893198941989519896198971989819899199001990119902199031990419905199061990719908199091991019911199121991319914199151991619917199181991919920199211992219923199241992519926199271992819929199301993119932199331993419935199361993719938199391994019941199421994319944199451994619947199481994919950199511995219953199541995519956199571995819959199601996119962199631996419965199661996719968199691997019971199721997319974199751997619977199781997919980199811998219983199841998519986199871998819989199901999119992199931999419995199961999719998199992000020001200022000320004200052000620007200082000920010200112001220013200142001520016200172001820019200202002120022200232002420025200262002720028200292003020031200322003320034200352003620037200382003920040200412004220043200442004520046200472004820049200502005120052200532005420055200562005720058200592006020061200622006320064200652006620067200682006920070200712007220073200742007520076200772007820079200802008120082200832008420085200862008720088200892009020091200922009320094200952009620097200982009920100201012010220103201042010520106201072010820109201102011120112201132011420115201162011720118201192012020121201222012320124201252012620127201282012920130201312013220133201342013520136201372013820139201402014120142201432014420145201462014720148201492015020151201522015320154201552015620157201582015920160201612016220163201642016520166201672016820169201702017120172201732017420175201762017720178201792018020181201822018320184201852018620187201882018920190201912019220193201942019520196201972019820199202002020120202202032020420205202062020720208202092021020211202122021320214202152021620217202182021920220202212022220223202242022520226202272022820229202302023120232202332023420235202362023720238202392024020241202422024320244202452024620247202482024920250202512025220253202542025520256202572025820259202602026120262202632026420265202662026720268202692027020271202722027320274202752027620277202782027920280202812028220283202842028520286202872028820289202902029120292202932029420295202962029720298202992030020301203022030320304203052030620307203082030920310203112031220313203142031520316203172031820319203202032120322203232032420325203262032720328203292033020331203322033320334203352033620337203382033920340203412034220343203442034520346203472034820349203502035120352203532035420355203562035720358203592036020361203622036320364203652036620367203682036920370203712037220373203742037520376203772037820379203802038120382203832038420385203862038720388203892039020391203922039320394203952039620397203982039920400204012040220403204042040520406204072040820409204102041120412204132041420415204162041720418204192042020421204222042320424204252042620427204282042920430204312043220433204342043520436204372043820439204402044120442204432044420445204462044720448204492045020451204522045320454204552045620457204582045920460204612046220463204642046520466204672046820469204702047120472204732047420475204762047720478204792048020481204822048320484204852048620487204882048920490204912049220493204942049520496204972049820499205002050120502205032050420505205062050720508205092051020511205122051320514205152051620517205182051920520205212052220523205242052520526205272052820529205302053120532205332053420535205362053720538205392054020541205422054320544205452054620547205482054920550205512055220553205542055520556205572055820559205602056120562205632056420565205662056720568205692057020571205722057320574205752057620577205782057920580205812058220583205842058520586205872058820589205902059120592205932059420595205962059720598205992060020601206022060320604206052060620607206082060920610206112061220613206142061520616206172061820619206202062120622206232062420625206262062720628206292063020631206322063320634206352063620637206382063920640206412064220643206442064520646206472064820649206502065120652206532065420655206562065720658206592066020661206622066320664206652066620667206682066920670206712067220673206742067520676206772067820679206802068120682206832068420685206862068720688206892069020691206922069320694206952069620697206982069920700207012070220703207042070520706207072070820709207102071120712207132071420715207162071720718207192072020721207222072320724207252072620727207282072920730207312073220733207342073520736207372073820739207402074120742207432074420745207462074720748207492075020751207522075320754207552075620757207582075920760207612076220763207642076520766207672076820769207702077120772207732077420775207762077720778207792078020781207822078320784207852078620787207882078920790207912079220793207942079520796207972079820799208002080120802208032080420805208062080720808208092081020811208122081320814208152081620817208182081920820208212082220823208242082520826208272082820829208302083120832208332083420835208362083720838208392084020841208422084320844208452084620847208482084920850208512085220853208542085520856208572085820859208602086120862208632086420865208662086720868208692087020871208722087320874208752087620877208782087920880208812088220883208842088520886208872088820889208902089120892208932089420895208962089720898208992090020901209022090320904209052090620907209082090920910209112091220913209142091520916209172091820919209202092120922209232092420925209262092720928209292093020931209322093320934209352093620937209382093920940209412094220943209442094520946209472094820949209502095120952209532095420955209562095720958209592096020961209622096320964209652096620967209682096920970209712097220973209742097520976209772097820979209802098120982209832098420985209862098720988209892099020991209922099320994209952099620997209982099921000210012100221003210042100521006210072100821009210102101121012210132101421015210162101721018210192102021021210222102321024210252102621027210282102921030210312103221033210342103521036210372103821039210402104121042210432104421045210462104721048210492105021051210522105321054210552105621057210582105921060210612106221063210642106521066210672106821069210702107121072210732107421075210762107721078210792108021081210822108321084210852108621087210882108921090210912109221093210942109521096210972109821099211002110121102211032110421105211062110721108211092111021111211122111321114211152111621117211182111921120211212112221123211242112521126211272112821129211302113121132211332113421135211362113721138211392114021141211422114321144211452114621147211482114921150211512115221153211542115521156211572115821159211602116121162211632116421165211662116721168211692117021171211722117321174211752117621177211782117921180211812118221183211842118521186211872118821189211902119121192211932119421195211962119721198211992120021201212022120321204212052120621207212082120921210212112121221213212142121521216212172121821219212202122121222212232122421225212262122721228212292123021231212322123321234212352123621237212382123921240212412124221243212442124521246212472124821249212502125121252212532125421255212562125721258212592126021261212622126321264212652126621267212682126921270212712127221273212742127521276212772127821279212802128121282212832128421285212862128721288212892129021291212922129321294212952129621297212982129921300213012130221303213042130521306213072130821309213102131121312213132131421315213162131721318213192132021321213222132321324213252132621327213282132921330213312133221333213342133521336213372133821339213402134121342213432134421345213462134721348213492135021351213522135321354213552135621357213582135921360213612136221363213642136521366213672136821369213702137121372213732137421375213762137721378213792138021381213822138321384213852138621387213882138921390213912139221393213942139521396213972139821399214002140121402214032140421405214062140721408214092141021411214122141321414214152141621417214182141921420214212142221423214242142521426214272142821429214302143121432214332143421435214362143721438214392144021441214422144321444214452144621447214482144921450214512145221453214542145521456214572145821459214602146121462214632146421465214662146721468214692147021471214722147321474214752147621477214782147921480214812148221483214842148521486214872148821489214902149121492214932149421495214962149721498214992150021501215022150321504215052150621507215082150921510215112151221513215142151521516215172151821519215202152121522215232152421525215262152721528215292153021531215322153321534215352153621537215382153921540215412154221543215442154521546215472154821549215502155121552215532155421555215562155721558215592156021561215622156321564215652156621567215682156921570215712157221573215742157521576215772157821579215802158121582215832158421585215862158721588215892159021591215922159321594215952159621597215982159921600216012160221603216042160521606216072160821609216102161121612216132161421615216162161721618216192162021621216222162321624216252162621627216282162921630216312163221633216342163521636216372163821639216402164121642216432164421645216462164721648216492165021651216522165321654216552165621657216582165921660216612166221663216642166521666216672166821669216702167121672216732167421675216762167721678216792168021681216822168321684216852168621687216882168921690216912169221693216942169521696216972169821699217002170121702217032170421705217062170721708217092171021711217122171321714217152171621717217182171921720217212172221723217242172521726217272172821729217302173121732217332173421735217362173721738217392174021741217422174321744217452174621747217482174921750217512175221753217542175521756217572175821759217602176121762217632176421765217662176721768217692177021771217722177321774217752177621777217782177921780217812178221783217842178521786217872178821789217902179121792217932179421795217962179721798217992180021801218022180321804218052180621807218082180921810218112181221813218142181521816218172181821819218202182121822218232182421825218262182721828218292183021831218322183321834218352183621837218382183921840218412184221843218442184521846218472184821849218502185121852218532185421855218562185721858218592186021861218622186321864218652186621867218682186921870218712187221873218742187521876218772187821879218802188121882218832188421885218862188721888218892189021891218922189321894218952189621897218982189921900219012190221903219042190521906219072190821909219102191121912219132191421915219162191721918219192192021921219222192321924219252192621927219282192921930219312193221933219342193521936219372193821939219402194121942219432194421945219462194721948219492195021951219522195321954219552195621957219582195921960219612196221963219642196521966219672196821969219702197121972219732197421975219762197721978219792198021981219822198321984219852198621987219882198921990219912199221993219942199521996219972199821999220002200122002220032200422005220062200722008220092201022011220122201322014220152201622017220182201922020220212202222023220242202522026220272202822029220302203122032220332203422035220362203722038220392204022041220422204322044220452204622047220482204922050220512205222053220542205522056220572205822059220602206122062220632206422065220662206722068220692207022071220722207322074220752207622077220782207922080220812208222083220842208522086220872208822089220902209122092220932209422095220962209722098220992210022101221022210322104221052210622107221082210922110221112211222113221142211522116221172211822119221202212122122221232212422125221262212722128221292213022131221322213322134221352213622137221382213922140221412214222143221442214522146221472214822149221502215122152221532215422155221562215722158221592216022161221622216322164221652216622167221682216922170221712217222173221742217522176221772217822179221802218122182221832218422185221862218722188221892219022191221922219322194221952219622197221982219922200222012220222203222042220522206222072220822209222102221122212222132221422215222162221722218222192222022221222222222322224222252222622227222282222922230222312223222233222342223522236222372223822239222402224122242222432224422245222462224722248222492225022251222522225322254222552225622257222582225922260222612226222263222642226522266222672226822269222702227122272222732227422275222762227722278222792228022281222822228322284222852228622287222882228922290222912229222293222942229522296222972229822299223002230122302223032230422305223062230722308223092231022311223122231322314223152231622317223182231922320223212232222323223242232522326223272232822329223302233122332223332233422335223362233722338223392234022341223422234322344223452234622347223482234922350223512235222353223542235522356223572235822359223602236122362223632236422365223662236722368223692237022371223722237322374223752237622377223782237922380223812238222383223842238522386223872238822389223902239122392223932239422395223962239722398223992240022401224022240322404224052240622407224082240922410224112241222413224142241522416224172241822419224202242122422224232242422425224262242722428224292243022431224322243322434224352243622437224382243922440224412244222443224442244522446224472244822449224502245122452224532245422455224562245722458224592246022461224622246322464224652246622467224682246922470224712247222473224742247522476224772247822479224802248122482224832248422485224862248722488224892249022491224922249322494224952249622497224982249922500225012250222503225042250522506225072250822509225102251122512225132251422515225162251722518225192252022521225222252322524225252252622527225282252922530225312253222533225342253522536225372253822539225402254122542225432254422545225462254722548225492255022551225522255322554225552255622557225582255922560225612256222563225642256522566225672256822569225702257122572225732257422575225762257722578225792258022581225822258322584225852258622587225882258922590225912259222593225942259522596225972259822599226002260122602226032260422605226062260722608226092261022611226122261322614226152261622617226182261922620226212262222623226242262522626226272262822629226302263122632226332263422635226362263722638226392264022641226422264322644226452264622647226482264922650226512265222653226542265522656226572265822659226602266122662226632266422665226662266722668226692267022671226722267322674226752267622677226782267922680226812268222683226842268522686226872268822689226902269122692226932269422695226962269722698226992270022701227022270322704227052270622707227082270922710227112271222713227142271522716227172271822719227202272122722227232272422725227262272722728227292273022731227322273322734227352273622737227382273922740227412274222743227442274522746227472274822749227502275122752227532275422755227562275722758227592276022761227622276322764227652276622767227682276922770227712277222773227742277522776227772277822779227802278122782227832278422785227862278722788227892279022791227922279322794227952279622797227982279922800228012280222803228042280522806228072280822809228102281122812228132281422815228162281722818228192282022821228222282322824228252282622827228282282922830228312283222833228342283522836228372283822839228402284122842228432284422845228462284722848228492285022851228522285322854228552285622857228582285922860228612286222863228642286522866228672286822869228702287122872228732287422875228762287722878228792288022881228822288322884228852288622887228882288922890228912289222893228942289522896228972289822899229002290122902229032290422905229062290722908229092291022911229122291322914229152291622917229182291922920229212292222923229242292522926229272292822929229302293122932229332293422935229362293722938229392294022941229422294322944229452294622947229482294922950229512295222953229542295522956229572295822959229602296122962229632296422965229662296722968229692297022971229722297322974229752297622977229782297922980229812298222983229842298522986229872298822989229902299122992229932299422995229962299722998229992300023001230022300323004230052300623007230082300923010230112301223013230142301523016230172301823019230202302123022230232302423025230262302723028230292303023031230322303323034230352303623037230382303923040230412304223043230442304523046230472304823049230502305123052230532305423055230562305723058230592306023061230622306323064230652306623067230682306923070230712307223073230742307523076230772307823079230802308123082230832308423085230862308723088230892309023091230922309323094230952309623097230982309923100231012310223103231042310523106231072310823109231102311123112231132311423115231162311723118231192312023121231222312323124231252312623127231282312923130231312313223133231342313523136231372313823139231402314123142231432314423145231462314723148231492315023151231522315323154231552315623157231582315923160231612316223163231642316523166231672316823169231702317123172231732317423175231762317723178231792318023181231822318323184231852318623187231882318923190231912319223193231942319523196231972319823199232002320123202232032320423205232062320723208232092321023211232122321323214232152321623217232182321923220232212322223223232242322523226232272322823229232302323123232232332323423235232362323723238232392324023241232422324323244232452324623247232482324923250232512325223253232542325523256232572325823259232602326123262232632326423265232662326723268232692327023271232722327323274232752327623277232782327923280232812328223283232842328523286232872328823289232902329123292232932329423295232962329723298232992330023301233022330323304233052330623307233082330923310233112331223313233142331523316233172331823319233202332123322233232332423325233262332723328233292333023331233322333323334233352333623337233382333923340233412334223343233442334523346233472334823349233502335123352233532335423355233562335723358233592336023361233622336323364233652336623367233682336923370233712337223373233742337523376233772337823379233802338123382233832338423385233862338723388233892339023391233922339323394233952339623397233982339923400234012340223403234042340523406234072340823409234102341123412234132341423415234162341723418234192342023421234222342323424234252342623427234282342923430234312343223433234342343523436234372343823439234402344123442234432344423445234462344723448234492345023451234522345323454234552345623457234582345923460234612346223463234642346523466234672346823469234702347123472234732347423475234762347723478234792348023481234822348323484234852348623487234882348923490234912349223493234942349523496234972349823499235002350123502235032350423505235062350723508235092351023511235122351323514235152351623517235182351923520235212352223523235242352523526235272352823529235302353123532235332353423535235362353723538235392354023541235422354323544235452354623547235482354923550235512355223553235542355523556235572355823559235602356123562235632356423565235662356723568235692357023571235722357323574235752357623577235782357923580235812358223583235842358523586235872358823589235902359123592235932359423595235962359723598235992360023601236022360323604236052360623607236082360923610236112361223613236142361523616236172361823619236202362123622236232362423625236262362723628236292363023631236322363323634236352363623637236382363923640236412364223643236442364523646236472364823649236502365123652236532365423655236562365723658236592366023661236622366323664236652366623667236682366923670236712367223673236742367523676236772367823679236802368123682236832368423685236862368723688236892369023691236922369323694236952369623697236982369923700237012370223703237042370523706237072370823709237102371123712237132371423715237162371723718237192372023721237222372323724237252372623727237282372923730237312373223733237342373523736237372373823739237402374123742237432374423745237462374723748237492375023751237522375323754237552375623757237582375923760237612376223763237642376523766237672376823769237702377123772237732377423775237762377723778237792378023781237822378323784237852378623787237882378923790237912379223793237942379523796237972379823799238002380123802238032380423805238062380723808238092381023811238122381323814238152381623817238182381923820238212382223823238242382523826238272382823829238302383123832238332383423835238362383723838238392384023841238422384323844238452384623847238482384923850238512385223853238542385523856238572385823859238602386123862238632386423865238662386723868238692387023871238722387323874238752387623877238782387923880238812388223883238842388523886238872388823889238902389123892238932389423895238962389723898238992390023901239022390323904239052390623907239082390923910239112391223913239142391523916239172391823919239202392123922239232392423925239262392723928239292393023931239322393323934239352393623937239382393923940239412394223943239442394523946239472394823949239502395123952239532395423955239562395723958239592396023961239622396323964239652396623967239682396923970239712397223973239742397523976239772397823979239802398123982239832398423985239862398723988239892399023991239922399323994239952399623997239982399924000240012400224003240042400524006240072400824009240102401124012240132401424015240162401724018240192402024021240222402324024240252402624027240282402924030240312403224033240342403524036240372403824039240402404124042240432404424045240462404724048240492405024051240522405324054240552405624057240582405924060240612406224063240642406524066240672406824069240702407124072240732407424075240762407724078240792408024081240822408324084240852408624087240882408924090240912409224093240942409524096240972409824099241002410124102241032410424105241062410724108241092411024111241122411324114241152411624117241182411924120241212412224123241242412524126241272412824129241302413124132241332413424135241362413724138241392414024141241422414324144241452414624147241482414924150241512415224153241542415524156241572415824159241602416124162241632416424165241662416724168241692417024171241722417324174241752417624177241782417924180241812418224183241842418524186241872418824189241902419124192241932419424195241962419724198241992420024201242022420324204242052420624207242082420924210242112421224213242142421524216242172421824219242202422124222242232422424225242262422724228242292423024231242322423324234242352423624237242382423924240242412424224243242442424524246242472424824249242502425124252242532425424255242562425724258242592426024261242622426324264242652426624267242682426924270242712427224273242742427524276242772427824279242802428124282242832428424285242862428724288242892429024291242922429324294242952429624297242982429924300243012430224303243042430524306243072430824309243102431124312243132431424315243162431724318243192432024321243222432324324243252432624327243282432924330243312433224333243342433524336243372433824339243402434124342243432434424345243462434724348243492435024351243522435324354243552435624357243582435924360243612436224363243642436524366243672436824369243702437124372243732437424375243762437724378243792438024381243822438324384243852438624387243882438924390243912439224393243942439524396243972439824399244002440124402244032440424405244062440724408244092441024411244122441324414244152441624417244182441924420244212442224423244242442524426244272442824429244302443124432244332443424435244362443724438244392444024441244422444324444244452444624447244482444924450244512445224453244542445524456244572445824459244602446124462244632446424465244662446724468244692447024471244722447324474244752447624477244782447924480244812448224483244842448524486244872448824489244902449124492244932449424495244962449724498244992450024501245022450324504245052450624507245082450924510245112451224513245142451524516245172451824519245202452124522245232452424525245262452724528245292453024531245322453324534245352453624537245382453924540245412454224543245442454524546245472454824549245502455124552245532455424555245562455724558245592456024561245622456324564245652456624567245682456924570245712457224573245742457524576245772457824579245802458124582245832458424585245862458724588245892459024591245922459324594245952459624597245982459924600246012460224603246042460524606246072460824609246102461124612246132461424615246162461724618246192462024621246222462324624246252462624627246282462924630246312463224633246342463524636246372463824639246402464124642246432464424645246462464724648246492465024651246522465324654246552465624657246582465924660246612466224663246642466524666246672466824669246702467124672246732467424675246762467724678246792468024681246822468324684246852468624687246882468924690246912469224693246942469524696246972469824699247002470124702247032470424705247062470724708247092471024711247122471324714247152471624717247182471924720247212472224723247242472524726247272472824729247302473124732247332473424735247362473724738247392474024741247422474324744247452474624747247482474924750247512475224753247542475524756247572475824759247602476124762247632476424765247662476724768247692477024771247722477324774247752477624777247782477924780247812478224783247842478524786247872478824789247902479124792247932479424795247962479724798247992480024801248022480324804248052480624807248082480924810248112481224813248142481524816248172481824819248202482124822248232482424825248262482724828248292483024831248322483324834248352483624837248382483924840248412484224843248442484524846248472484824849248502485124852248532485424855248562485724858248592486024861248622486324864248652486624867248682486924870248712487224873248742487524876248772487824879248802488124882248832488424885248862488724888248892489024891248922489324894248952489624897248982489924900249012490224903249042490524906249072490824909249102491124912249132491424915249162491724918249192492024921249222492324924249252492624927249282492924930249312493224933249342493524936249372493824939249402494124942249432494424945249462494724948249492495024951249522495324954249552495624957249582495924960249612496224963249642496524966249672496824969249702497124972249732497424975249762497724978249792498024981249822498324984249852498624987249882498924990249912499224993249942499524996249972499824999250002500125002250032500425005250062500725008250092501025011250122501325014250152501625017250182501925020250212502225023250242502525026250272502825029250302503125032250332503425035250362503725038250392504025041250422504325044250452504625047250482504925050250512505225053250542505525056250572505825059250602506125062250632506425065250662506725068250692507025071250722507325074250752507625077250782507925080250812508225083250842508525086250872508825089250902509125092250932509425095250962509725098250992510025101251022510325104251052510625107251082510925110251112511225113251142511525116251172511825119251202512125122251232512425125251262512725128251292513025131251322513325134251352513625137251382513925140251412514225143251442514525146251472514825149251502515125152251532515425155251562515725158251592516025161251622516325164251652516625167251682516925170251712517225173251742517525176251772517825179251802518125182251832518425185251862518725188251892519025191251922519325194251952519625197251982519925200252012520225203252042520525206252072520825209252102521125212252132521425215252162521725218252192522025221252222522325224252252522625227252282522925230252312523225233252342523525236252372523825239252402524125242252432524425245252462524725248252492525025251252522525325254252552525625257252582525925260252612526225263252642526525266252672526825269252702527125272252732527425275252762527725278252792528025281252822528325284252852528625287252882528925290252912529225293252942529525296252972529825299253002530125302253032530425305253062530725308253092531025311253122531325314253152531625317253182531925320253212532225323253242532525326253272532825329253302533125332253332533425335253362533725338253392534025341253422534325344253452534625347253482534925350253512535225353253542535525356253572535825359253602536125362253632536425365253662536725368253692537025371253722537325374253752537625377253782537925380253812538225383253842538525386253872538825389253902539125392253932539425395253962539725398253992540025401254022540325404254052540625407254082540925410254112541225413254142541525416254172541825419254202542125422254232542425425254262542725428254292543025431254322543325434254352543625437254382543925440254412544225443254442544525446254472544825449254502545125452254532545425455254562545725458254592546025461254622546325464254652546625467254682546925470254712547225473254742547525476254772547825479254802548125482254832548425485254862548725488254892549025491254922549325494254952549625497254982549925500255012550225503255042550525506255072550825509255102551125512255132551425515255162551725518255192552025521255222552325524255252552625527255282552925530255312553225533255342553525536255372553825539255402554125542255432554425545255462554725548255492555025551255522555325554255552555625557255582555925560255612556225563255642556525566255672556825569255702557125572255732557425575255762557725578255792558025581255822558325584255852558625587255882558925590255912559225593255942559525596255972559825599256002560125602256032560425605256062560725608256092561025611256122561325614256152561625617256182561925620256212562225623256242562525626256272562825629256302563125632256332563425635256362563725638256392564025641256422564325644256452564625647256482564925650256512565225653256542565525656256572565825659256602566125662256632566425665256662566725668256692567025671256722567325674256752567625677256782567925680256812568225683256842568525686256872568825689256902569125692256932569425695256962569725698256992570025701257022570325704257052570625707257082570925710257112571225713257142571525716257172571825719257202572125722257232572425725257262572725728257292573025731257322573325734257352573625737257382573925740257412574225743257442574525746257472574825749257502575125752257532575425755257562575725758257592576025761257622576325764257652576625767257682576925770257712577225773257742577525776257772577825779257802578125782257832578425785257862578725788257892579025791257922579325794257952579625797257982579925800258012580225803258042580525806258072580825809258102581125812258132581425815258162581725818258192582025821258222582325824258252582625827258282582925830258312583225833258342583525836258372583825839258402584125842258432584425845258462584725848258492585025851258522585325854258552585625857258582585925860258612586225863258642586525866258672586825869258702587125872258732587425875258762587725878258792588025881258822588325884258852588625887258882588925890258912589225893258942589525896258972589825899259002590125902259032590425905259062590725908259092591025911259122591325914259152591625917259182591925920259212592225923259242592525926259272592825929259302593125932259332593425935259362593725938259392594025941259422594325944259452594625947259482594925950259512595225953259542595525956259572595825959259602596125962259632596425965259662596725968259692597025971259722597325974259752597625977259782597925980259812598225983259842598525986259872598825989259902599125992259932599425995259962599725998259992600026001260022600326004260052600626007260082600926010260112601226013260142601526016260172601826019260202602126022260232602426025260262602726028260292603026031260322603326034260352603626037260382603926040260412604226043260442604526046260472604826049260502605126052260532605426055260562605726058260592606026061260622606326064260652606626067260682606926070260712607226073260742607526076260772607826079260802608126082260832608426085260862608726088260892609026091260922609326094260952609626097260982609926100261012610226103261042610526106261072610826109261102611126112261132611426115261162611726118261192612026121261222612326124261252612626127261282612926130261312613226133261342613526136261372613826139261402614126142261432614426145261462614726148261492615026151261522615326154261552615626157261582615926160261612616226163261642616526166261672616826169261702617126172261732617426175261762617726178261792618026181261822618326184261852618626187261882618926190261912619226193261942619526196261972619826199262002620126202262032620426205262062620726208262092621026211262122621326214262152621626217262182621926220262212622226223262242622526226262272622826229262302623126232262332623426235262362623726238262392624026241262422624326244262452624626247262482624926250262512625226253262542625526256262572625826259262602626126262262632626426265262662626726268262692627026271262722627326274262752627626277262782627926280262812628226283262842628526286262872628826289262902629126292262932629426295262962629726298262992630026301263022630326304263052630626307263082630926310263112631226313263142631526316263172631826319263202632126322263232632426325263262632726328263292633026331263322633326334263352633626337263382633926340263412634226343263442634526346263472634826349263502635126352263532635426355263562635726358263592636026361263622636326364263652636626367263682636926370263712637226373263742637526376263772637826379263802638126382263832638426385263862638726388263892639026391263922639326394263952639626397263982639926400264012640226403264042640526406264072640826409264102641126412264132641426415264162641726418264192642026421264222642326424264252642626427264282642926430264312643226433264342643526436264372643826439264402644126442264432644426445264462644726448264492645026451264522645326454264552645626457264582645926460264612646226463264642646526466264672646826469264702647126472264732647426475264762647726478264792648026481264822648326484264852648626487264882648926490264912649226493264942649526496264972649826499265002650126502265032650426505265062650726508265092651026511265122651326514265152651626517265182651926520265212652226523265242652526526265272652826529265302653126532265332653426535265362653726538265392654026541265422654326544265452654626547265482654926550265512655226553265542655526556265572655826559265602656126562265632656426565265662656726568265692657026571265722657326574265752657626577265782657926580265812658226583265842658526586265872658826589265902659126592265932659426595265962659726598265992660026601266022660326604266052660626607266082660926610266112661226613266142661526616266172661826619266202662126622266232662426625266262662726628266292663026631266322663326634266352663626637266382663926640266412664226643266442664526646266472664826649266502665126652266532665426655266562665726658266592666026661266622666326664266652666626667266682666926670266712667226673266742667526676266772667826679266802668126682266832668426685266862668726688266892669026691266922669326694266952669626697266982669926700267012670226703267042670526706267072670826709267102671126712267132671426715267162671726718267192672026721267222672326724267252672626727267282672926730267312673226733267342673526736267372673826739267402674126742267432674426745267462674726748267492675026751267522675326754267552675626757267582675926760267612676226763267642676526766267672676826769267702677126772267732677426775267762677726778267792678026781267822678326784267852678626787267882678926790267912679226793267942679526796267972679826799268002680126802268032680426805268062680726808268092681026811268122681326814268152681626817268182681926820268212682226823268242682526826268272682826829268302683126832268332683426835268362683726838268392684026841268422684326844268452684626847268482684926850268512685226853268542685526856268572685826859268602686126862268632686426865268662686726868268692687026871268722687326874268752687626877268782687926880268812688226883268842688526886268872688826889268902689126892268932689426895268962689726898268992690026901269022690326904269052690626907269082690926910269112691226913269142691526916269172691826919269202692126922269232692426925269262692726928269292693026931269322693326934269352693626937269382693926940269412694226943269442694526946269472694826949269502695126952269532695426955269562695726958269592696026961269622696326964269652696626967269682696926970269712697226973269742697526976269772697826979269802698126982269832698426985269862698726988269892699026991269922699326994269952699626997269982699927000270012700227003270042700527006270072700827009270102701127012270132701427015270162701727018270192702027021270222702327024270252702627027270282702927030270312703227033270342703527036270372703827039270402704127042270432704427045270462704727048270492705027051270522705327054270552705627057270582705927060270612706227063270642706527066270672706827069270702707127072270732707427075270762707727078270792708027081270822708327084270852708627087270882708927090270912709227093270942709527096270972709827099271002710127102271032710427105271062710727108271092711027111271122711327114271152711627117271182711927120271212712227123271242712527126271272712827129271302713127132271332713427135271362713727138271392714027141271422714327144271452714627147271482714927150271512715227153271542715527156271572715827159271602716127162271632716427165271662716727168271692717027171271722717327174271752717627177271782717927180271812718227183271842718527186271872718827189271902719127192271932719427195271962719727198271992720027201272022720327204272052720627207272082720927210272112721227213272142721527216272172721827219272202722127222272232722427225272262722727228272292723027231272322723327234272352723627237272382723927240272412724227243272442724527246272472724827249272502725127252272532725427255272562725727258272592726027261272622726327264272652726627267272682726927270272712727227273272742727527276272772727827279272802728127282272832728427285272862728727288272892729027291272922729327294272952729627297272982729927300273012730227303273042730527306273072730827309273102731127312273132731427315273162731727318273192732027321273222732327324273252732627327273282732927330273312733227333273342733527336273372733827339273402734127342273432734427345273462734727348273492735027351273522735327354273552735627357273582735927360273612736227363273642736527366273672736827369273702737127372273732737427375273762737727378273792738027381273822738327384273852738627387273882738927390273912739227393273942739527396273972739827399274002740127402274032740427405274062740727408274092741027411274122741327414274152741627417274182741927420274212742227423274242742527426274272742827429274302743127432274332743427435274362743727438274392744027441274422744327444274452744627447274482744927450274512745227453274542745527456274572745827459274602746127462274632746427465274662746727468274692747027471274722747327474274752747627477274782747927480274812748227483274842748527486274872748827489274902749127492274932749427495274962749727498274992750027501275022750327504275052750627507275082750927510275112751227513275142751527516275172751827519275202752127522275232752427525275262752727528275292753027531275322753327534275352753627537275382753927540275412754227543275442754527546275472754827549275502755127552275532755427555275562755727558275592756027561275622756327564275652756627567275682756927570275712757227573275742757527576275772757827579275802758127582275832758427585275862758727588275892759027591275922759327594275952759627597275982759927600276012760227603276042760527606276072760827609276102761127612276132761427615276162761727618276192762027621276222762327624276252762627627276282762927630276312763227633276342763527636276372763827639276402764127642276432764427645276462764727648276492765027651276522765327654276552765627657276582765927660276612766227663276642766527666276672766827669276702767127672276732767427675276762767727678276792768027681276822768327684276852768627687276882768927690276912769227693276942769527696276972769827699277002770127702277032770427705277062770727708277092771027711277122771327714277152771627717277182771927720277212772227723277242772527726277272772827729277302773127732277332773427735277362773727738277392774027741277422774327744277452774627747277482774927750277512775227753277542775527756277572775827759277602776127762277632776427765277662776727768277692777027771277722777327774277752777627777277782777927780277812778227783277842778527786277872778827789277902779127792277932779427795277962779727798277992780027801278022780327804278052780627807278082780927810278112781227813278142781527816278172781827819278202782127822278232782427825278262782727828278292783027831278322783327834278352783627837278382783927840278412784227843278442784527846278472784827849278502785127852278532785427855278562785727858278592786027861278622786327864278652786627867278682786927870278712787227873278742787527876278772787827879278802788127882278832788427885278862788727888278892789027891278922789327894278952789627897278982789927900279012790227903279042790527906279072790827909279102791127912279132791427915279162791727918279192792027921279222792327924279252792627927279282792927930279312793227933279342793527936279372793827939279402794127942279432794427945279462794727948279492795027951279522795327954279552795627957279582795927960279612796227963279642796527966279672796827969279702797127972279732797427975279762797727978279792798027981279822798327984279852798627987279882798927990279912799227993279942799527996279972799827999280002800128002280032800428005280062800728008280092801028011280122801328014280152801628017280182801928020280212802228023280242802528026280272802828029280302803128032280332803428035280362803728038280392804028041280422804328044280452804628047280482804928050280512805228053280542805528056280572805828059280602806128062280632806428065280662806728068280692807028071280722807328074280752807628077280782807928080280812808228083280842808528086280872808828089280902809128092280932809428095280962809728098280992810028101281022810328104281052810628107281082810928110281112811228113281142811528116281172811828119281202812128122281232812428125281262812728128281292813028131281322813328134281352813628137281382813928140281412814228143281442814528146281472814828149281502815128152281532815428155281562815728158281592816028161281622816328164281652816628167281682816928170281712817228173281742817528176281772817828179281802818128182281832818428185281862818728188281892819028191281922819328194281952819628197281982819928200282012820228203282042820528206282072820828209282102821128212282132821428215282162821728218282192822028221282222822328224282252822628227282282822928230282312823228233282342823528236282372823828239282402824128242282432824428245282462824728248282492825028251282522825328254282552825628257282582825928260282612826228263282642826528266282672826828269282702827128272282732827428275282762827728278282792828028281282822828328284282852828628287282882828928290282912829228293282942829528296282972829828299283002830128302283032830428305283062830728308283092831028311283122831328314283152831628317283182831928320283212832228323283242832528326283272832828329283302833128332283332833428335283362833728338283392834028341283422834328344283452834628347283482834928350283512835228353283542835528356283572835828359283602836128362283632836428365283662836728368283692837028371283722837328374283752837628377283782837928380283812838228383283842838528386283872838828389283902839128392283932839428395283962839728398283992840028401284022840328404284052840628407284082840928410284112841228413284142841528416284172841828419284202842128422284232842428425284262842728428284292843028431284322843328434284352843628437284382843928440284412844228443284442844528446284472844828449284502845128452284532845428455284562845728458284592846028461284622846328464284652846628467284682846928470284712847228473284742847528476284772847828479284802848128482284832848428485284862848728488284892849028491284922849328494284952849628497284982849928500285012850228503285042850528506285072850828509285102851128512285132851428515285162851728518285192852028521285222852328524285252852628527285282852928530285312853228533285342853528536285372853828539285402854128542285432854428545285462854728548285492855028551285522855328554285552855628557285582855928560285612856228563285642856528566285672856828569285702857128572285732857428575285762857728578285792858028581285822858328584285852858628587285882858928590285912859228593285942859528596285972859828599286002860128602286032860428605286062860728608286092861028611286122861328614286152861628617286182861928620286212862228623286242862528626286272862828629286302863128632286332863428635286362863728638286392864028641286422864328644286452864628647286482864928650286512865228653286542865528656286572865828659286602866128662286632866428665286662866728668286692867028671286722867328674286752867628677286782867928680286812868228683286842868528686286872868828689286902869128692286932869428695286962869728698286992870028701287022870328704287052870628707287082870928710287112871228713287142871528716287172871828719287202872128722287232872428725287262872728728287292873028731287322873328734287352873628737287382873928740287412874228743287442874528746287472874828749287502875128752287532875428755287562875728758287592876028761287622876328764287652876628767287682876928770287712877228773287742877528776287772877828779287802878128782287832878428785287862878728788287892879028791287922879328794287952879628797287982879928800288012880228803288042880528806288072880828809288102881128812288132881428815288162881728818288192882028821288222882328824288252882628827288282882928830288312883228833288342883528836288372883828839288402884128842288432884428845288462884728848288492885028851288522885328854288552885628857288582885928860288612886228863288642886528866288672886828869288702887128872288732887428875288762887728878288792888028881288822888328884288852888628887288882888928890288912889228893288942889528896288972889828899289002890128902289032890428905289062890728908289092891028911289122891328914289152891628917289182891928920289212892228923289242892528926289272892828929289302893128932289332893428935289362893728938289392894028941289422894328944289452894628947289482894928950289512895228953289542895528956289572895828959289602896128962289632896428965289662896728968289692897028971289722897328974289752897628977289782897928980289812898228983289842898528986289872898828989289902899128992289932899428995289962899728998289992900029001290022900329004290052900629007290082900929010290112901229013290142901529016290172901829019290202902129022290232902429025290262902729028290292903029031290322903329034290352903629037290382903929040290412904229043290442904529046290472904829049290502905129052290532905429055290562905729058290592906029061290622906329064290652906629067290682906929070290712907229073290742907529076290772907829079290802908129082290832908429085290862908729088290892909029091290922909329094290952909629097290982909929100291012910229103291042910529106291072910829109291102911129112291132911429115291162911729118291192912029121291222912329124291252912629127291282912929130291312913229133291342913529136291372913829139291402914129142291432914429145291462914729148291492915029151291522915329154291552915629157291582915929160291612916229163291642916529166291672916829169291702917129172291732917429175291762917729178291792918029181291822918329184291852918629187291882918929190291912919229193291942919529196291972919829199292002920129202292032920429205292062920729208292092921029211292122921329214292152921629217292182921929220292212922229223292242922529226292272922829229292302923129232292332923429235292362923729238292392924029241292422924329244292452924629247292482924929250292512925229253292542925529256292572925829259292602926129262292632926429265292662926729268292692927029271292722927329274292752927629277292782927929280292812928229283292842928529286292872928829289292902929129292292932929429295292962929729298292992930029301293022930329304293052930629307293082930929310293112931229313293142931529316293172931829319293202932129322293232932429325293262932729328293292933029331293322933329334293352933629337293382933929340293412934229343293442934529346293472934829349293502935129352293532935429355293562935729358293592936029361293622936329364293652936629367293682936929370293712937229373293742937529376293772937829379293802938129382293832938429385293862938729388293892939029391293922939329394293952939629397293982939929400294012940229403294042940529406294072940829409294102941129412294132941429415294162941729418294192942029421294222942329424294252942629427294282942929430294312943229433294342943529436294372943829439294402944129442294432944429445294462944729448294492945029451294522945329454294552945629457294582945929460294612946229463294642946529466294672946829469294702947129472294732947429475294762947729478294792948029481294822948329484294852948629487294882948929490294912949229493294942949529496294972949829499295002950129502295032950429505295062950729508295092951029511295122951329514295152951629517295182951929520295212952229523295242952529526295272952829529295302953129532295332953429535295362953729538295392954029541295422954329544295452954629547295482954929550295512955229553295542955529556295572955829559295602956129562295632956429565295662956729568295692957029571295722957329574295752957629577295782957929580295812958229583295842958529586295872958829589295902959129592295932959429595295962959729598295992960029601296022960329604296052960629607296082960929610296112961229613296142961529616296172961829619296202962129622296232962429625296262962729628296292963029631296322963329634296352963629637296382963929640296412964229643296442964529646296472964829649296502965129652296532965429655296562965729658296592966029661296622966329664296652966629667296682966929670296712967229673296742967529676296772967829679296802968129682296832968429685296862968729688296892969029691296922969329694296952969629697296982969929700297012970229703297042970529706297072970829709297102971129712297132971429715297162971729718297192972029721297222972329724297252972629727297282972929730297312973229733297342973529736297372973829739297402974129742297432974429745297462974729748297492975029751297522975329754297552975629757297582975929760297612976229763297642976529766297672976829769297702977129772297732977429775297762977729778297792978029781297822978329784297852978629787297882978929790297912979229793297942979529796297972979829799298002980129802298032980429805298062980729808298092981029811298122981329814298152981629817298182981929820298212982229823298242982529826298272982829829298302983129832298332983429835298362983729838298392984029841298422984329844298452984629847298482984929850298512985229853298542985529856298572985829859298602986129862298632986429865298662986729868298692987029871298722987329874298752987629877298782987929880298812988229883298842988529886298872988829889298902989129892298932989429895298962989729898298992990029901299022990329904299052990629907299082990929910299112991229913299142991529916299172991829919299202992129922299232992429925299262992729928299292993029931299322993329934299352993629937299382993929940299412994229943299442994529946299472994829949299502995129952299532995429955299562995729958299592996029961299622996329964299652996629967299682996929970299712997229973299742997529976299772997829979299802998129982299832998429985299862998729988299892999029991299922999329994299952999629997299982999930000300013000230003300043000530006300073000830009300103001130012300133001430015300163001730018300193002030021300223002330024300253002630027300283002930030300313003230033300343003530036300373003830039300403004130042300433004430045300463004730048300493005030051300523005330054300553005630057300583005930060300613006230063300643006530066300673006830069300703007130072300733007430075300763007730078300793008030081300823008330084300853008630087300883008930090300913009230093300943009530096300973009830099301003010130102301033010430105301063010730108301093011030111301123011330114301153011630117301183011930120301213012230123301243012530126301273012830129301303013130132301333013430135301363013730138301393014030141301423014330144301453014630147301483014930150301513015230153301543015530156301573015830159301603016130162301633016430165301663016730168301693017030171301723017330174301753017630177301783017930180301813018230183301843018530186301873018830189301903019130192301933019430195301963019730198301993020030201302023020330204302053020630207302083020930210302113021230213302143021530216302173021830219302203022130222302233022430225302263022730228302293023030231302323023330234302353023630237302383023930240302413024230243302443024530246302473024830249302503025130252302533025430255302563025730258302593026030261302623026330264302653026630267302683026930270302713027230273302743027530276302773027830279302803028130282302833028430285302863028730288302893029030291302923029330294302953029630297302983029930300303013030230303303043030530306303073030830309303103031130312303133031430315303163031730318303193032030321303223032330324303253032630327303283032930330303313033230333303343033530336303373033830339303403034130342303433034430345303463034730348303493035030351303523035330354303553035630357303583035930360303613036230363303643036530366303673036830369303703037130372303733037430375303763037730378303793038030381303823038330384303853038630387303883038930390303913039230393303943039530396303973039830399304003040130402304033040430405304063040730408304093041030411304123041330414304153041630417304183041930420304213042230423304243042530426304273042830429304303043130432304333043430435304363043730438304393044030441304423044330444304453044630447304483044930450304513045230453304543045530456304573045830459304603046130462304633046430465304663046730468304693047030471304723047330474304753047630477304783047930480304813048230483304843048530486304873048830489304903049130492304933049430495304963049730498304993050030501305023050330504305053050630507305083050930510305113051230513305143051530516305173051830519305203052130522305233052430525305263052730528305293053030531305323053330534305353053630537305383053930540305413054230543305443054530546305473054830549305503055130552305533055430555305563055730558305593056030561305623056330564305653056630567305683056930570305713057230573305743057530576305773057830579305803058130582305833058430585305863058730588305893059030591305923059330594305953059630597305983059930600306013060230603306043060530606306073060830609306103061130612306133061430615306163061730618306193062030621306223062330624306253062630627306283062930630306313063230633306343063530636306373063830639306403064130642306433064430645306463064730648306493065030651306523065330654306553065630657306583065930660306613066230663306643066530666306673066830669306703067130672306733067430675306763067730678306793068030681306823068330684306853068630687306883068930690306913069230693306943069530696306973069830699307003070130702307033070430705307063070730708307093071030711307123071330714307153071630717307183071930720307213072230723307243072530726307273072830729307303073130732307333073430735307363073730738307393074030741307423074330744307453074630747307483074930750307513075230753307543075530756307573075830759307603076130762307633076430765307663076730768307693077030771307723077330774307753077630777307783077930780307813078230783307843078530786307873078830789307903079130792307933079430795307963079730798307993080030801308023080330804308053080630807308083080930810308113081230813308143081530816308173081830819308203082130822308233082430825308263082730828308293083030831308323083330834308353083630837308383083930840308413084230843308443084530846308473084830849308503085130852308533085430855308563085730858308593086030861308623086330864308653086630867308683086930870308713087230873308743087530876308773087830879308803088130882308833088430885308863088730888308893089030891308923089330894308953089630897308983089930900309013090230903309043090530906309073090830909309103091130912309133091430915309163091730918309193092030921309223092330924309253092630927309283092930930309313093230933309343093530936309373093830939309403094130942309433094430945309463094730948309493095030951309523095330954309553095630957309583095930960309613096230963309643096530966309673096830969309703097130972309733097430975309763097730978309793098030981309823098330984309853098630987309883098930990309913099230993309943099530996309973099830999310003100131002310033100431005310063100731008310093101031011310123101331014310153101631017310183101931020310213102231023310243102531026310273102831029310303103131032310333103431035310363103731038310393104031041310423104331044310453104631047310483104931050310513105231053310543105531056310573105831059310603106131062310633106431065310663106731068310693107031071310723107331074310753107631077310783107931080310813108231083310843108531086310873108831089310903109131092310933109431095310963109731098310993110031101311023110331104311053110631107311083110931110311113111231113311143111531116311173111831119311203112131122311233112431125311263112731128311293113031131311323113331134311353113631137311383113931140311413114231143311443114531146311473114831149311503115131152311533115431155311563115731158311593116031161311623116331164311653116631167311683116931170311713117231173311743117531176311773117831179311803118131182311833118431185311863118731188311893119031191311923119331194311953119631197311983119931200312013120231203312043120531206312073120831209312103121131212312133121431215312163121731218312193122031221312223122331224312253122631227312283122931230312313123231233312343123531236312373123831239312403124131242312433124431245312463124731248312493125031251312523125331254312553125631257312583125931260312613126231263312643126531266312673126831269312703127131272312733127431275312763127731278312793128031281312823128331284312853128631287312883128931290312913129231293312943129531296312973129831299313003130131302313033130431305313063130731308313093131031311313123131331314313153131631317313183131931320313213132231323313243132531326313273132831329313303133131332313333133431335313363133731338313393134031341313423134331344313453134631347313483134931350313513135231353313543135531356313573135831359313603136131362313633136431365313663136731368313693137031371313723137331374313753137631377313783137931380313813138231383313843138531386313873138831389313903139131392313933139431395313963139731398313993140031401314023140331404314053140631407314083140931410314113141231413314143141531416314173141831419314203142131422314233142431425314263142731428314293143031431314323143331434314353143631437314383143931440314413144231443314443144531446314473144831449314503145131452314533145431455314563145731458314593146031461314623146331464314653146631467314683146931470314713147231473314743147531476314773147831479314803148131482314833148431485314863148731488314893149031491314923149331494314953149631497314983149931500315013150231503315043150531506315073150831509315103151131512315133151431515315163151731518315193152031521315223152331524315253152631527315283152931530315313153231533315343153531536315373153831539315403154131542315433154431545315463154731548315493155031551315523155331554315553155631557315583155931560315613156231563315643156531566315673156831569315703157131572315733157431575315763157731578315793158031581315823158331584315853158631587315883158931590315913159231593315943159531596315973159831599316003160131602316033160431605316063160731608316093161031611316123161331614316153161631617316183161931620316213162231623316243162531626316273162831629316303163131632316333163431635316363163731638316393164031641316423164331644316453164631647316483164931650316513165231653316543165531656316573165831659316603166131662316633166431665316663166731668316693167031671316723167331674316753167631677316783167931680316813168231683316843168531686316873168831689316903169131692316933169431695316963169731698316993170031701317023170331704317053170631707317083170931710317113171231713317143171531716317173171831719317203172131722317233172431725317263172731728317293173031731317323173331734317353173631737317383173931740317413174231743317443174531746317473174831749317503175131752317533175431755317563175731758317593176031761317623176331764317653176631767317683176931770317713177231773317743177531776317773177831779317803178131782317833178431785317863178731788317893179031791317923179331794317953179631797317983179931800318013180231803318043180531806318073180831809318103181131812318133181431815318163181731818318193182031821318223182331824318253182631827318283182931830318313183231833318343183531836318373183831839318403184131842318433184431845318463184731848318493185031851318523185331854318553185631857318583185931860318613186231863318643186531866318673186831869318703187131872318733187431875318763187731878318793188031881318823188331884318853188631887318883188931890318913189231893318943189531896318973189831899319003190131902319033190431905319063190731908319093191031911319123191331914319153191631917319183191931920319213192231923319243192531926319273192831929319303193131932319333193431935319363193731938319393194031941319423194331944319453194631947319483194931950319513195231953319543195531956319573195831959319603196131962319633196431965319663196731968319693197031971319723197331974319753197631977319783197931980319813198231983319843198531986319873198831989319903199131992319933199431995319963199731998319993200032001320023200332004320053200632007320083200932010320113201232013320143201532016320173201832019320203202132022320233202432025320263202732028320293203032031320323203332034320353203632037320383203932040320413204232043320443204532046320473204832049320503205132052320533205432055320563205732058320593206032061320623206332064320653206632067320683206932070320713207232073320743207532076320773207832079320803208132082320833208432085320863208732088320893209032091320923209332094320953209632097320983209932100321013210232103321043210532106321073210832109321103211132112321133211432115321163211732118321193212032121321223212332124321253212632127321283212932130321313213232133321343213532136321373213832139321403214132142321433214432145321463214732148321493215032151321523215332154321553215632157321583215932160321613216232163321643216532166321673216832169321703217132172321733217432175321763217732178321793218032181321823218332184321853218632187321883218932190321913219232193321943219532196321973219832199322003220132202322033220432205322063220732208322093221032211322123221332214322153221632217322183221932220322213222232223322243222532226322273222832229322303223132232322333223432235322363223732238322393224032241322423224332244322453224632247322483224932250322513225232253322543225532256322573225832259322603226132262322633226432265322663226732268322693227032271322723227332274322753227632277322783227932280322813228232283322843228532286322873228832289322903229132292322933229432295322963229732298322993230032301323023230332304323053230632307323083230932310323113231232313323143231532316323173231832319323203232132322323233232432325323263232732328323293233032331323323233332334323353233632337323383233932340323413234232343323443234532346323473234832349323503235132352323533235432355323563235732358323593236032361323623236332364323653236632367323683236932370323713237232373323743237532376323773237832379323803238132382323833238432385323863238732388323893239032391323923239332394323953239632397323983239932400324013240232403324043240532406324073240832409324103241132412324133241432415324163241732418324193242032421324223242332424324253242632427324283242932430324313243232433324343243532436324373243832439324403244132442324433244432445324463244732448324493245032451324523245332454324553245632457324583245932460324613246232463324643246532466324673246832469324703247132472324733247432475324763247732478324793248032481324823248332484324853248632487324883248932490324913249232493324943249532496324973249832499325003250132502325033250432505325063250732508325093251032511325123251332514325153251632517325183251932520325213252232523325243252532526325273252832529325303253132532325333253432535325363253732538325393254032541325423254332544325453254632547325483254932550325513255232553325543255532556325573255832559325603256132562325633256432565325663256732568325693257032571325723257332574325753257632577325783257932580325813258232583325843258532586325873258832589325903259132592325933259432595325963259732598325993260032601326023260332604326053260632607326083260932610326113261232613326143261532616326173261832619326203262132622326233262432625326263262732628326293263032631326323263332634326353263632637326383263932640326413264232643326443264532646326473264832649326503265132652326533265432655326563265732658326593266032661326623266332664326653266632667326683266932670326713267232673326743267532676326773267832679326803268132682326833268432685326863268732688326893269032691326923269332694326953269632697326983269932700327013270232703327043270532706327073270832709327103271132712327133271432715327163271732718327193272032721327223272332724327253272632727327283272932730327313273232733327343273532736327373273832739327403274132742327433274432745327463274732748327493275032751327523275332754327553275632757327583275932760327613276232763327643276532766327673276832769327703277132772327733277432775327763277732778327793278032781327823278332784327853278632787327883278932790327913279232793327943279532796327973279832799328003280132802328033280432805328063280732808328093281032811328123281332814328153281632817328183281932820328213282232823328243282532826328273282832829328303283132832328333283432835328363283732838328393284032841328423284332844328453284632847328483284932850328513285232853328543285532856328573285832859328603286132862328633286432865328663286732868328693287032871328723287332874328753287632877328783287932880328813288232883328843288532886328873288832889328903289132892328933289432895328963289732898328993290032901329023290332904329053290632907329083290932910329113291232913329143291532916329173291832919329203292132922329233292432925329263292732928329293293032931329323293332934329353293632937329383293932940329413294232943329443294532946329473294832949329503295132952329533295432955329563295732958329593296032961329623296332964329653296632967329683296932970329713297232973329743297532976329773297832979329803298132982329833298432985329863298732988329893299032991329923299332994329953299632997329983299933000330013300233003330043300533006330073300833009330103301133012330133301433015330163301733018330193302033021330223302333024330253302633027330283302933030330313303233033330343303533036330373303833039330403304133042330433304433045330463304733048330493305033051330523305333054330553305633057330583305933060330613306233063330643306533066330673306833069330703307133072330733307433075330763307733078330793308033081330823308333084330853308633087330883308933090330913309233093330943309533096330973309833099331003310133102331033310433105331063310733108331093311033111331123311333114331153311633117331183311933120331213312233123331243312533126331273312833129331303313133132331333313433135331363313733138331393314033141331423314333144331453314633147331483314933150331513315233153331543315533156331573315833159331603316133162331633316433165331663316733168331693317033171331723317333174331753317633177331783317933180331813318233183331843318533186331873318833189331903319133192331933319433195331963319733198331993320033201332023320333204332053320633207332083320933210332113321233213332143321533216332173321833219332203322133222332233322433225332263322733228332293323033231332323323333234332353323633237332383323933240332413324233243332443324533246332473324833249332503325133252332533325433255332563325733258332593326033261332623326333264332653326633267332683326933270332713327233273332743327533276332773327833279332803328133282332833328433285332863328733288332893329033291332923329333294332953329633297332983329933300333013330233303333043330533306333073330833309333103331133312333133331433315333163331733318333193332033321333223332333324333253332633327333283332933330333313333233333333343333533336333373333833339333403334133342333433334433345333463334733348333493335033351333523335333354333553335633357333583335933360333613336233363333643336533366333673336833369333703337133372333733337433375333763337733378333793338033381333823338333384333853338633387333883338933390333913339233393333943339533396333973339833399334003340133402334033340433405334063340733408334093341033411334123341333414334153341633417334183341933420334213342233423334243342533426334273342833429334303343133432334333343433435334363343733438334393344033441334423344333444334453344633447334483344933450334513345233453334543345533456334573345833459334603346133462334633346433465334663346733468334693347033471334723347333474334753347633477334783347933480334813348233483334843348533486334873348833489334903349133492334933349433495334963349733498334993350033501335023350333504335053350633507335083350933510335113351233513335143351533516335173351833519335203352133522335233352433525335263352733528335293353033531335323353333534335353353633537335383353933540335413354233543335443354533546335473354833549335503355133552335533355433555335563355733558335593356033561335623356333564335653356633567335683356933570335713357233573335743357533576335773357833579335803358133582335833358433585335863358733588335893359033591335923359333594335953359633597335983359933600336013360233603336043360533606336073360833609336103361133612336133361433615336163361733618336193362033621336223362333624336253362633627336283362933630336313363233633336343363533636336373363833639336403364133642336433364433645336463364733648336493365033651336523365333654336553365633657336583365933660336613366233663336643366533666336673366833669336703367133672336733367433675336763367733678336793368033681336823368333684336853368633687336883368933690336913369233693336943369533696336973369833699337003370133702337033370433705337063370733708337093371033711337123371333714337153371633717337183371933720337213372233723337243372533726337273372833729337303373133732337333373433735337363373733738337393374033741337423374333744337453374633747337483374933750337513375233753337543375533756337573375833759337603376133762337633376433765337663376733768337693377033771337723377333774337753377633777337783377933780337813378233783337843378533786337873378833789337903379133792337933379433795337963379733798337993380033801338023380333804338053380633807338083380933810338113381233813338143381533816338173381833819338203382133822338233382433825338263382733828338293383033831338323383333834338353383633837338383383933840338413384233843338443384533846338473384833849338503385133852338533385433855338563385733858338593386033861338623386333864338653386633867338683386933870338713387233873338743387533876338773387833879338803388133882338833388433885338863388733888338893389033891338923389333894338953389633897338983389933900339013390233903339043390533906339073390833909339103391133912339133391433915339163391733918339193392033921339223392333924339253392633927339283392933930339313393233933339343393533936339373393833939339403394133942339433394433945339463394733948339493395033951339523395333954339553395633957339583395933960339613396233963339643396533966339673396833969339703397133972339733397433975339763397733978339793398033981339823398333984339853398633987339883398933990339913399233993339943399533996339973399833999340003400134002340033400434005340063400734008340093401034011340123401334014340153401634017340183401934020340213402234023340243402534026340273402834029340303403134032340333403434035340363403734038340393404034041340423404334044340453404634047340483404934050340513405234053340543405534056340573405834059340603406134062340633406434065340663406734068340693407034071340723407334074340753407634077340783407934080340813408234083340843408534086340873408834089340903409134092340933409434095340963409734098340993410034101341023410334104341053410634107341083410934110341113411234113341143411534116341173411834119341203412134122341233412434125341263412734128341293413034131341323413334134341353413634137341383413934140341413414234143341443414534146341473414834149341503415134152341533415434155341563415734158341593416034161341623416334164341653416634167341683416934170341713417234173341743417534176341773417834179341803418134182341833418434185341863418734188341893419034191341923419334194341953419634197341983419934200342013420234203342043420534206342073420834209342103421134212342133421434215342163421734218342193422034221342223422334224342253422634227342283422934230342313423234233342343423534236342373423834239342403424134242342433424434245342463424734248342493425034251342523425334254342553425634257342583425934260342613426234263342643426534266342673426834269342703427134272342733427434275342763427734278342793428034281342823428334284342853428634287342883428934290342913429234293342943429534296342973429834299343003430134302343033430434305343063430734308343093431034311343123431334314343153431634317343183431934320343213432234323343243432534326343273432834329343303433134332343333433434335343363433734338343393434034341343423434334344343453434634347343483434934350343513435234353343543435534356343573435834359343603436134362343633436434365343663436734368343693437034371343723437334374343753437634377343783437934380343813438234383343843438534386343873438834389343903439134392343933439434395343963439734398343993440034401344023440334404344053440634407344083440934410344113441234413344143441534416344173441834419344203442134422344233442434425344263442734428344293443034431344323443334434344353443634437344383443934440344413444234443344443444534446344473444834449344503445134452344533445434455344563445734458344593446034461344623446334464344653446634467344683446934470344713447234473344743447534476344773447834479344803448134482344833448434485344863448734488344893449034491344923449334494344953449634497344983449934500345013450234503345043450534506345073450834509345103451134512345133451434515345163451734518345193452034521345223452334524345253452634527345283452934530345313453234533345343453534536345373453834539345403454134542345433454434545345463454734548345493455034551345523455334554345553455634557345583455934560345613456234563345643456534566345673456834569345703457134572345733457434575345763457734578345793458034581345823458334584345853458634587345883458934590345913459234593345943459534596345973459834599346003460134602346033460434605346063460734608346093461034611346123461334614346153461634617346183461934620346213462234623346243462534626346273462834629346303463134632346333463434635346363463734638346393464034641346423464334644346453464634647346483464934650346513465234653346543465534656346573465834659346603466134662346633466434665346663466734668346693467034671346723467334674346753467634677346783467934680346813468234683346843468534686346873468834689346903469134692346933469434695346963469734698346993470034701347023470334704347053470634707347083470934710347113471234713347143471534716347173471834719347203472134722347233472434725347263472734728347293473034731347323473334734347353473634737347383473934740347413474234743347443474534746347473474834749347503475134752347533475434755347563475734758347593476034761347623476334764347653476634767347683476934770347713477234773347743477534776347773477834779347803478134782347833478434785347863478734788347893479034791347923479334794347953479634797347983479934800348013480234803348043480534806348073480834809348103481134812348133481434815348163481734818348193482034821348223482334824348253482634827348283482934830348313483234833348343483534836348373483834839348403484134842348433484434845348463484734848348493485034851348523485334854348553485634857348583485934860348613486234863348643486534866348673486834869348703487134872348733487434875348763487734878348793488034881348823488334884348853488634887348883488934890348913489234893348943489534896348973489834899349003490134902349033490434905349063490734908349093491034911349123491334914349153491634917349183491934920349213492234923349243492534926349273492834929349303493134932349333493434935349363493734938349393494034941349423494334944349453494634947349483494934950349513495234953349543495534956349573495834959349603496134962349633496434965349663496734968349693497034971349723497334974349753497634977349783497934980349813498234983349843498534986349873498834989349903499134992349933499434995349963499734998349993500035001350023500335004350053500635007350083500935010350113501235013350143501535016350173501835019350203502135022350233502435025350263502735028350293503035031350323503335034350353503635037350383503935040350413504235043350443504535046350473504835049350503505135052350533505435055350563505735058350593506035061350623506335064350653506635067350683506935070350713507235073350743507535076350773507835079350803508135082350833508435085350863508735088350893509035091350923509335094350953509635097350983509935100351013510235103351043510535106351073510835109351103511135112351133511435115351163511735118351193512035121351223512335124351253512635127351283512935130351313513235133351343513535136351373513835139351403514135142351433514435145351463514735148351493515035151351523515335154351553515635157351583515935160351613516235163351643516535166351673516835169351703517135172351733517435175351763517735178351793518035181351823518335184351853518635187351883518935190351913519235193351943519535196351973519835199352003520135202352033520435205352063520735208352093521035211352123521335214352153521635217352183521935220352213522235223352243522535226352273522835229352303523135232352333523435235352363523735238352393524035241352423524335244352453524635247352483524935250352513525235253352543525535256352573525835259352603526135262352633526435265352663526735268352693527035271352723527335274352753527635277352783527935280352813528235283352843528535286352873528835289352903529135292352933529435295352963529735298352993530035301353023530335304353053530635307353083530935310353113531235313353143531535316353173531835319353203532135322353233532435325353263532735328353293533035331353323533335334353353533635337353383533935340353413534235343353443534535346353473534835349353503535135352353533535435355353563535735358353593536035361353623536335364353653536635367353683536935370353713537235373353743537535376353773537835379353803538135382353833538435385353863538735388353893539035391353923539335394353953539635397353983539935400354013540235403354043540535406354073540835409354103541135412354133541435415354163541735418354193542035421354223542335424354253542635427354283542935430354313543235433354343543535436354373543835439354403544135442354433544435445354463544735448354493545035451354523545335454354553545635457354583545935460354613546235463354643546535466354673546835469354703547135472354733547435475354763547735478354793548035481354823548335484354853548635487354883548935490354913549235493354943549535496354973549835499355003550135502355033550435505355063550735508355093551035511355123551335514355153551635517355183551935520355213552235523355243552535526355273552835529355303553135532355333553435535355363553735538355393554035541355423554335544355453554635547355483554935550355513555235553355543555535556355573555835559355603556135562355633556435565355663556735568355693557035571355723557335574355753557635577355783557935580355813558235583355843558535586355873558835589355903559135592355933559435595355963559735598355993560035601356023560335604356053560635607356083560935610356113561235613356143561535616356173561835619356203562135622356233562435625356263562735628356293563035631356323563335634356353563635637356383563935640356413564235643356443564535646356473564835649356503565135652356533565435655356563565735658356593566035661356623566335664356653566635667356683566935670356713567235673356743567535676356773567835679356803568135682356833568435685356863568735688356893569035691356923569335694356953569635697356983569935700357013570235703357043570535706357073570835709357103571135712357133571435715357163571735718357193572035721357223572335724357253572635727357283572935730357313573235733357343573535736357373573835739357403574135742357433574435745357463574735748357493575035751357523575335754357553575635757357583575935760357613576235763357643576535766357673576835769357703577135772357733577435775357763577735778357793578035781357823578335784357853578635787357883578935790357913579235793357943579535796357973579835799358003580135802358033580435805358063580735808358093581035811358123581335814358153581635817358183581935820358213582235823358243582535826358273582835829358303583135832358333583435835358363583735838358393584035841358423584335844358453584635847358483584935850358513585235853358543585535856358573585835859358603586135862358633586435865358663586735868358693587035871358723587335874358753587635877358783587935880358813588235883358843588535886358873588835889358903589135892358933589435895358963589735898358993590035901359023590335904359053590635907359083590935910359113591235913359143591535916359173591835919359203592135922359233592435925359263592735928359293593035931359323593335934359353593635937359383593935940359413594235943359443594535946359473594835949359503595135952359533595435955359563595735958359593596035961359623596335964359653596635967359683596935970359713597235973359743597535976359773597835979359803598135982359833598435985359863598735988359893599035991359923599335994359953599635997359983599936000360013600236003360043600536006360073600836009360103601136012360133601436015360163601736018360193602036021360223602336024360253602636027360283602936030360313603236033360343603536036360373603836039360403604136042360433604436045360463604736048360493605036051360523605336054360553605636057360583605936060360613606236063360643606536066360673606836069360703607136072360733607436075360763607736078360793608036081360823608336084360853608636087360883608936090360913609236093360943609536096360973609836099361003610136102361033610436105361063610736108361093611036111361123611336114361153611636117361183611936120361213612236123361243612536126361273612836129361303613136132361333613436135361363613736138361393614036141361423614336144361453614636147361483614936150361513615236153361543615536156361573615836159361603616136162361633616436165361663616736168361693617036171361723617336174361753617636177361783617936180361813618236183361843618536186361873618836189361903619136192361933619436195361963619736198361993620036201362023620336204362053620636207362083620936210362113621236213362143621536216362173621836219362203622136222362233622436225362263622736228362293623036231362323623336234362353623636237362383623936240362413624236243362443624536246362473624836249362503625136252362533625436255362563625736258362593626036261362623626336264362653626636267362683626936270362713627236273362743627536276362773627836279362803628136282362833628436285362863628736288362893629036291362923629336294362953629636297362983629936300363013630236303363043630536306363073630836309363103631136312363133631436315363163631736318363193632036321363223632336324363253632636327363283632936330363313633236333363343633536336363373633836339363403634136342363433634436345363463634736348363493635036351363523635336354363553635636357363583635936360363613636236363363643636536366363673636836369363703637136372363733637436375363763637736378363793638036381363823638336384363853638636387363883638936390363913639236393363943639536396363973639836399364003640136402364033640436405364063640736408364093641036411364123641336414364153641636417364183641936420364213642236423364243642536426364273642836429364303643136432364333643436435364363643736438364393644036441364423644336444364453644636447364483644936450364513645236453364543645536456364573645836459364603646136462364633646436465364663646736468364693647036471364723647336474364753647636477364783647936480364813648236483364843648536486364873648836489364903649136492364933649436495364963649736498364993650036501365023650336504365053650636507365083650936510365113651236513365143651536516365173651836519365203652136522365233652436525365263652736528365293653036531365323653336534365353653636537365383653936540365413654236543365443654536546365473654836549365503655136552365533655436555365563655736558365593656036561365623656336564365653656636567365683656936570365713657236573365743657536576365773657836579365803658136582365833658436585365863658736588365893659036591365923659336594365953659636597365983659936600366013660236603366043660536606366073660836609366103661136612366133661436615366163661736618366193662036621366223662336624366253662636627366283662936630366313663236633366343663536636366373663836639366403664136642366433664436645366463664736648366493665036651366523665336654366553665636657366583665936660366613666236663366643666536666366673666836669366703667136672366733667436675366763667736678366793668036681366823668336684366853668636687366883668936690366913669236693366943669536696366973669836699367003670136702367033670436705367063670736708367093671036711367123671336714367153671636717367183671936720367213672236723367243672536726367273672836729367303673136732367333673436735367363673736738367393674036741367423674336744367453674636747367483674936750367513675236753367543675536756367573675836759367603676136762367633676436765367663676736768367693677036771367723677336774367753677636777367783677936780367813678236783367843678536786367873678836789367903679136792367933679436795367963679736798367993680036801368023680336804368053680636807368083680936810368113681236813368143681536816368173681836819368203682136822368233682436825368263682736828368293683036831368323683336834368353683636837368383683936840368413684236843368443684536846368473684836849368503685136852368533685436855368563685736858368593686036861368623686336864368653686636867368683686936870368713687236873368743687536876368773687836879368803688136882368833688436885368863688736888368893689036891368923689336894368953689636897368983689936900369013690236903369043690536906369073690836909369103691136912369133691436915369163691736918369193692036921369223692336924369253692636927369283692936930369313693236933369343693536936369373693836939369403694136942369433694436945369463694736948369493695036951369523695336954369553695636957369583695936960369613696236963369643696536966369673696836969369703697136972369733697436975369763697736978369793698036981369823698336984369853698636987369883698936990369913699236993369943699536996369973699836999370003700137002370033700437005370063700737008370093701037011370123701337014370153701637017370183701937020370213702237023370243702537026370273702837029370303703137032370333703437035370363703737038370393704037041370423704337044370453704637047370483704937050370513705237053370543705537056370573705837059370603706137062370633706437065370663706737068370693707037071370723707337074370753707637077370783707937080370813708237083370843708537086370873708837089370903709137092370933709437095370963709737098370993710037101371023710337104371053710637107371083710937110371113711237113371143711537116371173711837119371203712137122371233712437125371263712737128371293713037131371323713337134371353713637137371383713937140371413714237143371443714537146371473714837149371503715137152371533715437155371563715737158371593716037161371623716337164371653716637167371683716937170371713717237173371743717537176371773717837179371803718137182371833718437185371863718737188371893719037191371923719337194371953719637197371983719937200372013720237203372043720537206372073720837209372103721137212372133721437215372163721737218372193722037221372223722337224372253722637227372283722937230372313723237233372343723537236372373723837239372403724137242372433724437245372463724737248372493725037251372523725337254372553725637257372583725937260372613726237263372643726537266372673726837269372703727137272372733727437275372763727737278372793728037281372823728337284372853728637287372883728937290372913729237293372943729537296372973729837299373003730137302373033730437305373063730737308373093731037311373123731337314373153731637317373183731937320373213732237323373243732537326373273732837329373303733137332373333733437335373363733737338373393734037341373423734337344373453734637347373483734937350373513735237353373543735537356373573735837359373603736137362373633736437365373663736737368373693737037371373723737337374373753737637377373783737937380373813738237383373843738537386373873738837389373903739137392373933739437395373963739737398373993740037401374023740337404374053740637407374083740937410374113741237413374143741537416374173741837419374203742137422374233742437425374263742737428374293743037431374323743337434374353743637437374383743937440374413744237443374443744537446374473744837449374503745137452374533745437455374563745737458374593746037461374623746337464374653746637467374683746937470374713747237473374743747537476374773747837479374803748137482374833748437485374863748737488374893749037491374923749337494374953749637497374983749937500375013750237503375043750537506375073750837509375103751137512375133751437515375163751737518375193752037521375223752337524375253752637527375283752937530375313753237533375343753537536375373753837539375403754137542375433754437545375463754737548375493755037551375523755337554375553755637557375583755937560375613756237563375643756537566375673756837569375703757137572375733757437575375763757737578375793758037581375823758337584375853758637587375883758937590375913759237593375943759537596375973759837599376003760137602376033760437605376063760737608376093761037611376123761337614376153761637617376183761937620376213762237623376243762537626376273762837629376303763137632376333763437635376363763737638376393764037641376423764337644376453764637647376483764937650376513765237653376543765537656376573765837659376603766137662376633766437665376663766737668376693767037671376723767337674376753767637677376783767937680376813768237683376843768537686376873768837689376903769137692376933769437695376963769737698376993770037701377023770337704377053770637707377083770937710377113771237713377143771537716377173771837719377203772137722377233772437725377263772737728377293773037731377323773337734377353773637737377383773937740377413774237743377443774537746377473774837749377503775137752377533775437755377563775737758377593776037761377623776337764377653776637767377683776937770377713777237773377743777537776377773777837779377803778137782377833778437785377863778737788377893779037791377923779337794377953779637797377983779937800378013780237803378043780537806378073780837809378103781137812378133781437815378163781737818378193782037821378223782337824378253782637827378283782937830378313783237833378343783537836378373783837839378403784137842378433784437845378463784737848378493785037851378523785337854378553785637857378583785937860378613786237863378643786537866378673786837869378703787137872378733787437875378763787737878378793788037881378823788337884378853788637887378883788937890378913789237893378943789537896378973789837899379003790137902379033790437905379063790737908379093791037911379123791337914379153791637917379183791937920379213792237923379243792537926379273792837929379303793137932379333793437935379363793737938379393794037941379423794337944379453794637947379483794937950379513795237953379543795537956379573795837959379603796137962379633796437965379663796737968379693797037971379723797337974379753797637977379783797937980379813798237983379843798537986379873798837989379903799137992379933799437995379963799737998379993800038001380023800338004380053800638007380083800938010380113801238013380143801538016380173801838019380203802138022380233802438025380263802738028380293803038031380323803338034380353803638037380383803938040380413804238043380443804538046380473804838049380503805138052380533805438055380563805738058380593806038061380623806338064380653806638067380683806938070380713807238073380743807538076380773807838079380803808138082380833808438085380863808738088380893809038091380923809338094380953809638097380983809938100381013810238103381043810538106381073810838109381103811138112381133811438115381163811738118381193812038121381223812338124381253812638127381283812938130381313813238133381343813538136381373813838139381403814138142381433814438145381463814738148381493815038151381523815338154381553815638157381583815938160381613816238163381643816538166381673816838169381703817138172381733817438175381763817738178381793818038181381823818338184381853818638187381883818938190381913819238193381943819538196381973819838199382003820138202382033820438205382063820738208382093821038211382123821338214382153821638217382183821938220382213822238223382243822538226382273822838229382303823138232382333823438235382363823738238382393824038241382423824338244382453824638247382483824938250382513825238253382543825538256382573825838259382603826138262382633826438265382663826738268382693827038271382723827338274382753827638277382783827938280382813828238283382843828538286382873828838289382903829138292382933829438295382963829738298382993830038301383023830338304383053830638307383083830938310383113831238313383143831538316383173831838319383203832138322383233832438325383263832738328383293833038331383323833338334383353833638337383383833938340383413834238343383443834538346383473834838349383503835138352383533835438355383563835738358383593836038361383623836338364383653836638367383683836938370383713837238373383743837538376383773837838379383803838138382383833838438385383863838738388383893839038391383923839338394383953839638397383983839938400384013840238403384043840538406384073840838409384103841138412384133841438415384163841738418384193842038421384223842338424384253842638427384283842938430384313843238433384343843538436384373843838439384403844138442384433844438445384463844738448384493845038451384523845338454384553845638457384583845938460384613846238463384643846538466384673846838469384703847138472384733847438475384763847738478384793848038481384823848338484384853848638487384883848938490384913849238493384943849538496384973849838499385003850138502385033850438505385063850738508385093851038511385123851338514385153851638517385183851938520385213852238523385243852538526385273852838529385303853138532385333853438535385363853738538385393854038541385423854338544385453854638547385483854938550385513855238553385543855538556385573855838559385603856138562385633856438565385663856738568385693857038571385723857338574385753857638577385783857938580385813858238583385843858538586385873858838589385903859138592385933859438595385963859738598385993860038601386023860338604386053860638607386083860938610386113861238613386143861538616386173861838619386203862138622386233862438625386263862738628386293863038631386323863338634386353863638637386383863938640386413864238643386443864538646386473864838649386503865138652386533865438655386563865738658386593866038661386623866338664386653866638667386683866938670386713867238673386743867538676386773867838679386803868138682386833868438685386863868738688386893869038691386923869338694386953869638697386983869938700387013870238703387043870538706387073870838709387103871138712387133871438715387163871738718387193872038721387223872338724387253872638727387283872938730387313873238733387343873538736387373873838739387403874138742387433874438745387463874738748387493875038751387523875338754387553875638757387583875938760387613876238763387643876538766387673876838769387703877138772387733877438775387763877738778387793878038781387823878338784387853878638787387883878938790387913879238793387943879538796387973879838799388003880138802388033880438805388063880738808388093881038811388123881338814388153881638817388183881938820388213882238823388243882538826388273882838829388303883138832388333883438835388363883738838388393884038841388423884338844388453884638847388483884938850388513885238853388543885538856388573885838859388603886138862388633886438865388663886738868388693887038871388723887338874388753887638877388783887938880388813888238883388843888538886388873888838889388903889138892388933889438895388963889738898388993890038901389023890338904389053890638907389083890938910389113891238913389143891538916389173891838919389203892138922389233892438925389263892738928389293893038931389323893338934389353893638937389383893938940389413894238943389443894538946389473894838949389503895138952389533895438955389563895738958389593896038961389623896338964389653896638967389683896938970389713897238973389743897538976389773897838979389803898138982389833898438985389863898738988389893899038991389923899338994389953899638997389983899939000390013900239003390043900539006390073900839009390103901139012390133901439015390163901739018390193902039021390223902339024390253902639027390283902939030390313903239033390343903539036390373903839039390403904139042390433904439045390463904739048390493905039051390523905339054390553905639057390583905939060390613906239063390643906539066390673906839069390703907139072390733907439075390763907739078390793908039081390823908339084390853908639087390883908939090390913909239093390943909539096390973909839099391003910139102391033910439105391063910739108391093911039111391123911339114391153911639117391183911939120391213912239123391243912539126391273912839129391303913139132391333913439135391363913739138391393914039141391423914339144391453914639147391483914939150391513915239153391543915539156391573915839159391603916139162391633916439165391663916739168391693917039171391723917339174391753917639177391783917939180391813918239183391843918539186391873918839189391903919139192391933919439195391963919739198391993920039201392023920339204392053920639207392083920939210392113921239213392143921539216392173921839219392203922139222392233922439225392263922739228392293923039231392323923339234392353923639237392383923939240392413924239243392443924539246392473924839249392503925139252392533925439255392563925739258392593926039261392623926339264392653926639267392683926939270392713927239273392743927539276392773927839279392803928139282392833928439285392863928739288392893929039291392923929339294392953929639297392983929939300393013930239303393043930539306393073930839309393103931139312393133931439315393163931739318393193932039321393223932339324393253932639327393283932939330393313933239333393343933539336393373933839339393403934139342393433934439345393463934739348393493935039351393523935339354393553935639357393583935939360393613936239363393643936539366393673936839369393703937139372393733937439375393763937739378393793938039381393823938339384393853938639387393883938939390393913939239393393943939539396393973939839399394003940139402394033940439405394063940739408394093941039411394123941339414394153941639417394183941939420394213942239423394243942539426394273942839429394303943139432394333943439435394363943739438394393944039441394423944339444394453944639447394483944939450394513945239453394543945539456394573945839459394603946139462394633946439465394663946739468394693947039471394723947339474394753947639477394783947939480394813948239483394843948539486394873948839489394903949139492394933949439495394963949739498394993950039501395023950339504395053950639507395083950939510395113951239513395143951539516395173951839519395203952139522395233952439525395263952739528395293953039531395323953339534395353953639537395383953939540395413954239543395443954539546395473954839549395503955139552395533955439555395563955739558395593956039561395623956339564395653956639567395683956939570395713957239573395743957539576395773957839579395803958139582395833958439585395863958739588395893959039591395923959339594395953959639597395983959939600396013960239603396043960539606396073960839609396103961139612396133961439615396163961739618396193962039621396223962339624396253962639627396283962939630396313963239633396343963539636396373963839639396403964139642396433964439645396463964739648396493965039651396523965339654396553965639657396583965939660396613966239663396643966539666396673966839669396703967139672396733967439675396763967739678396793968039681396823968339684396853968639687396883968939690396913969239693396943969539696396973969839699397003970139702397033970439705397063970739708397093971039711397123971339714397153971639717397183971939720397213972239723397243972539726397273972839729397303973139732397333973439735397363973739738397393974039741397423974339744397453974639747397483974939750397513975239753397543975539756397573975839759397603976139762397633976439765397663976739768397693977039771397723977339774397753977639777397783977939780397813978239783397843978539786397873978839789397903979139792397933979439795397963979739798397993980039801398023980339804398053980639807398083980939810398113981239813398143981539816398173981839819398203982139822398233982439825398263982739828398293983039831398323983339834398353983639837398383983939840398413984239843398443984539846398473984839849398503985139852398533985439855398563985739858398593986039861398623986339864398653986639867398683986939870398713987239873398743987539876398773987839879398803988139882398833988439885398863988739888398893989039891398923989339894398953989639897398983989939900399013990239903399043990539906399073990839909399103991139912399133991439915399163991739918399193992039921399223992339924399253992639927399283992939930399313993239933399343993539936399373993839939399403994139942399433994439945399463994739948399493995039951399523995339954399553995639957399583995939960399613996239963399643996539966399673996839969399703997139972399733997439975399763997739978399793998039981399823998339984399853998639987399883998939990399913999239993399943999539996399973999839999400004000140002400034000440005400064000740008400094001040011400124001340014400154001640017400184001940020400214002240023400244002540026400274002840029400304003140032400334003440035400364003740038400394004040041400424004340044400454004640047400484004940050400514005240053400544005540056400574005840059400604006140062400634006440065400664006740068400694007040071400724007340074400754007640077400784007940080400814008240083400844008540086400874008840089400904009140092400934009440095400964009740098400994010040101401024010340104401054010640107401084010940110401114011240113401144011540116401174011840119401204012140122401234012440125401264012740128401294013040131401324013340134401354013640137401384013940140401414014240143401444014540146401474014840149401504015140152401534015440155401564015740158401594016040161401624016340164401654016640167401684016940170401714017240173401744017540176401774017840179401804018140182401834018440185401864018740188401894019040191401924019340194401954019640197401984019940200402014020240203402044020540206402074020840209402104021140212402134021440215402164021740218402194022040221402224022340224402254022640227402284022940230402314023240233402344023540236402374023840239402404024140242402434024440245402464024740248402494025040251402524025340254402554025640257402584025940260402614026240263402644026540266402674026840269402704027140272402734027440275402764027740278402794028040281402824028340284402854028640287402884028940290402914029240293402944029540296402974029840299403004030140302403034030440305403064030740308403094031040311403124031340314403154031640317403184031940320403214032240323403244032540326403274032840329403304033140332403334033440335403364033740338403394034040341403424034340344403454034640347403484034940350403514035240353403544035540356403574035840359403604036140362403634036440365403664036740368403694037040371403724037340374403754037640377403784037940380403814038240383403844038540386403874038840389403904039140392403934039440395403964039740398403994040040401404024040340404404054040640407404084040940410404114041240413404144041540416404174041840419404204042140422404234042440425404264042740428404294043040431404324043340434404354043640437404384043940440404414044240443404444044540446404474044840449404504045140452404534045440455404564045740458404594046040461404624046340464404654046640467404684046940470404714047240473404744047540476404774047840479404804048140482404834048440485404864048740488404894049040491404924049340494404954049640497404984049940500405014050240503405044050540506405074050840509405104051140512405134051440515405164051740518405194052040521405224052340524405254052640527405284052940530405314053240533405344053540536405374053840539405404054140542405434054440545405464054740548405494055040551405524055340554405554055640557405584055940560405614056240563405644056540566405674056840569405704057140572405734057440575405764057740578405794058040581405824058340584405854058640587405884058940590405914059240593405944059540596405974059840599406004060140602406034060440605406064060740608406094061040611406124061340614406154061640617406184061940620406214062240623406244062540626406274062840629406304063140632406334063440635406364063740638406394064040641406424064340644406454064640647406484064940650406514065240653406544065540656406574065840659406604066140662406634066440665406664066740668406694067040671406724067340674406754067640677406784067940680406814068240683406844068540686406874068840689406904069140692406934069440695406964069740698406994070040701407024070340704407054070640707407084070940710407114071240713407144071540716407174071840719407204072140722407234072440725407264072740728407294073040731407324073340734407354073640737407384073940740407414074240743407444074540746407474074840749407504075140752407534075440755407564075740758407594076040761407624076340764407654076640767407684076940770407714077240773407744077540776407774077840779407804078140782407834078440785407864078740788407894079040791407924079340794407954079640797407984079940800408014080240803408044080540806408074080840809408104081140812408134081440815408164081740818408194082040821408224082340824408254082640827408284082940830408314083240833408344083540836408374083840839408404084140842408434084440845408464084740848408494085040851408524085340854408554085640857408584085940860408614086240863408644086540866408674086840869408704087140872408734087440875408764087740878408794088040881408824088340884408854088640887408884088940890408914089240893408944089540896408974089840899409004090140902409034090440905409064090740908409094091040911409124091340914409154091640917409184091940920409214092240923409244092540926409274092840929409304093140932409334093440935409364093740938409394094040941409424094340944409454094640947409484094940950409514095240953409544095540956409574095840959409604096140962409634096440965409664096740968409694097040971409724097340974409754097640977409784097940980409814098240983409844098540986409874098840989409904099140992409934099440995409964099740998409994100041001410024100341004410054100641007410084100941010410114101241013410144101541016410174101841019410204102141022410234102441025410264102741028410294103041031410324103341034410354103641037410384103941040410414104241043410444104541046410474104841049410504105141052410534105441055410564105741058410594106041061410624106341064410654106641067410684106941070410714107241073410744107541076410774107841079410804108141082410834108441085410864108741088410894109041091410924109341094410954109641097410984109941100411014110241103411044110541106411074110841109411104111141112411134111441115411164111741118411194112041121411224112341124411254112641127411284112941130411314113241133411344113541136411374113841139411404114141142411434114441145411464114741148411494115041151411524115341154411554115641157411584115941160411614116241163411644116541166411674116841169411704117141172411734117441175411764117741178411794118041181411824118341184411854118641187411884118941190411914119241193411944119541196411974119841199412004120141202412034120441205412064120741208412094121041211412124121341214412154121641217412184121941220412214122241223412244122541226412274122841229412304123141232412334123441235412364123741238412394124041241412424124341244412454124641247412484124941250412514125241253412544125541256412574125841259412604126141262412634126441265412664126741268412694127041271412724127341274412754127641277412784127941280412814128241283412844128541286412874128841289412904129141292412934129441295412964129741298412994130041301413024130341304413054130641307413084130941310413114131241313413144131541316413174131841319413204132141322413234132441325413264132741328413294133041331413324133341334413354133641337413384133941340413414134241343413444134541346413474134841349413504135141352413534135441355413564135741358413594136041361413624136341364413654136641367413684136941370413714137241373413744137541376413774137841379413804138141382413834138441385413864138741388413894139041391413924139341394413954139641397413984139941400414014140241403414044140541406414074140841409414104141141412414134141441415414164141741418414194142041421414224142341424414254142641427414284142941430414314143241433414344143541436414374143841439414404144141442414434144441445414464144741448414494145041451414524145341454414554145641457414584145941460414614146241463414644146541466414674146841469414704147141472414734147441475414764147741478414794148041481414824148341484414854148641487414884148941490414914149241493414944149541496414974149841499415004150141502415034150441505415064150741508415094151041511415124151341514415154151641517415184151941520415214152241523415244152541526415274152841529415304153141532415334153441535415364153741538415394154041541415424154341544415454154641547415484154941550415514155241553415544155541556415574155841559415604156141562415634156441565415664156741568415694157041571415724157341574415754157641577415784157941580415814158241583415844158541586415874158841589415904159141592415934159441595415964159741598415994160041601416024160341604416054160641607416084160941610416114161241613416144161541616416174161841619416204162141622416234162441625416264162741628416294163041631416324163341634416354163641637416384163941640416414164241643416444164541646416474164841649416504165141652416534165441655416564165741658416594166041661416624166341664416654166641667416684166941670416714167241673416744167541676416774167841679416804168141682416834168441685416864168741688416894169041691416924169341694416954169641697416984169941700417014170241703417044170541706417074170841709417104171141712417134171441715417164171741718417194172041721417224172341724417254172641727417284172941730417314173241733417344173541736417374173841739417404174141742417434174441745417464174741748417494175041751417524175341754417554175641757417584175941760417614176241763417644176541766417674176841769417704177141772417734177441775417764177741778417794178041781417824178341784417854178641787417884178941790417914179241793417944179541796417974179841799418004180141802418034180441805418064180741808418094181041811418124181341814418154181641817418184181941820418214182241823418244182541826418274182841829418304183141832418334183441835418364183741838418394184041841418424184341844418454184641847418484184941850418514185241853418544185541856418574185841859418604186141862418634186441865418664186741868418694187041871418724187341874418754187641877418784187941880418814188241883418844188541886418874188841889418904189141892418934189441895418964189741898418994190041901419024190341904419054190641907419084190941910419114191241913419144191541916419174191841919419204192141922419234192441925419264192741928419294193041931419324193341934419354193641937419384193941940419414194241943419444194541946419474194841949419504195141952419534195441955419564195741958419594196041961419624196341964419654196641967419684196941970419714197241973419744197541976419774197841979419804198141982419834198441985419864198741988419894199041991419924199341994419954199641997419984199942000420014200242003420044200542006420074200842009420104201142012420134201442015420164201742018420194202042021420224202342024420254202642027420284202942030420314203242033420344203542036420374203842039420404204142042420434204442045420464204742048420494205042051420524205342054420554205642057420584205942060420614206242063420644206542066420674206842069420704207142072420734207442075420764207742078420794208042081420824208342084420854208642087420884208942090420914209242093420944209542096420974209842099421004210142102421034210442105421064210742108421094211042111421124211342114421154211642117421184211942120421214212242123421244212542126421274212842129421304213142132421334213442135421364213742138421394214042141421424214342144421454214642147421484214942150421514215242153421544215542156421574215842159421604216142162421634216442165421664216742168421694217042171421724217342174421754217642177421784217942180421814218242183421844218542186421874218842189421904219142192421934219442195421964219742198421994220042201422024220342204422054220642207422084220942210422114221242213422144221542216422174221842219422204222142222422234222442225422264222742228422294223042231422324223342234422354223642237422384223942240422414224242243422444224542246422474224842249422504225142252422534225442255422564225742258422594226042261422624226342264422654226642267422684226942270422714227242273422744227542276422774227842279422804228142282422834228442285422864228742288422894229042291422924229342294422954229642297422984229942300423014230242303423044230542306423074230842309423104231142312423134231442315423164231742318423194232042321423224232342324423254232642327423284232942330423314233242333423344233542336423374233842339423404234142342423434234442345423464234742348423494235042351423524235342354423554235642357423584235942360423614236242363423644236542366423674236842369423704237142372423734237442375423764237742378423794238042381423824238342384423854238642387423884238942390423914239242393423944239542396423974239842399424004240142402424034240442405424064240742408424094241042411424124241342414424154241642417424184241942420424214242242423424244242542426424274242842429424304243142432424334243442435424364243742438424394244042441424424244342444424454244642447424484244942450424514245242453424544245542456424574245842459424604246142462424634246442465424664246742468424694247042471424724247342474424754247642477424784247942480424814248242483424844248542486424874248842489424904249142492424934249442495424964249742498424994250042501425024250342504425054250642507425084250942510425114251242513425144251542516425174251842519425204252142522425234252442525425264252742528425294253042531425324253342534425354253642537425384253942540425414254242543425444254542546425474254842549425504255142552425534255442555425564255742558425594256042561425624256342564425654256642567425684256942570425714257242573425744257542576425774257842579425804258142582425834258442585425864258742588425894259042591425924259342594425954259642597425984259942600426014260242603426044260542606426074260842609426104261142612426134261442615426164261742618426194262042621426224262342624426254262642627426284262942630426314263242633426344263542636426374263842639426404264142642426434264442645426464264742648426494265042651426524265342654426554265642657426584265942660426614266242663426644266542666426674266842669426704267142672426734267442675426764267742678426794268042681426824268342684426854268642687426884268942690426914269242693426944269542696426974269842699427004270142702427034270442705427064270742708427094271042711427124271342714427154271642717427184271942720427214272242723427244272542726427274272842729427304273142732427334273442735427364273742738427394274042741427424274342744427454274642747427484274942750427514275242753427544275542756427574275842759427604276142762427634276442765427664276742768427694277042771427724277342774427754277642777427784277942780427814278242783427844278542786427874278842789427904279142792427934279442795427964279742798427994280042801428024280342804428054280642807428084280942810428114281242813428144281542816428174281842819428204282142822428234282442825428264282742828428294283042831428324283342834428354283642837428384283942840428414284242843428444284542846428474284842849428504285142852428534285442855428564285742858428594286042861428624286342864428654286642867428684286942870428714287242873428744287542876428774287842879428804288142882428834288442885428864288742888428894289042891428924289342894428954289642897428984289942900429014290242903429044290542906429074290842909429104291142912429134291442915429164291742918429194292042921429224292342924429254292642927429284292942930429314293242933429344293542936429374293842939429404294142942429434294442945429464294742948429494295042951429524295342954429554295642957429584295942960429614296242963429644296542966429674296842969429704297142972429734297442975429764297742978429794298042981429824298342984429854298642987429884298942990429914299242993429944299542996429974299842999430004300143002430034300443005430064300743008430094301043011430124301343014430154301643017430184301943020430214302243023430244302543026430274302843029430304303143032430334303443035430364303743038430394304043041430424304343044430454304643047430484304943050430514305243053430544305543056430574305843059430604306143062430634306443065430664306743068430694307043071430724307343074430754307643077430784307943080430814308243083430844308543086430874308843089430904309143092430934309443095430964309743098430994310043101431024310343104431054310643107431084310943110431114311243113431144311543116431174311843119431204312143122431234312443125431264312743128431294313043131431324313343134431354313643137431384313943140431414314243143431444314543146431474314843149431504315143152431534315443155431564315743158431594316043161431624316343164431654316643167431684316943170431714317243173431744317543176431774317843179431804318143182431834318443185431864318743188431894319043191431924319343194431954319643197431984319943200432014320243203432044320543206432074320843209432104321143212432134321443215432164321743218432194322043221432224322343224432254322643227432284322943230432314323243233432344323543236432374323843239432404324143242432434324443245432464324743248432494325043251432524325343254432554325643257432584325943260432614326243263432644326543266432674326843269432704327143272432734327443275432764327743278432794328043281432824328343284432854328643287432884328943290432914329243293432944329543296432974329843299433004330143302433034330443305433064330743308433094331043311433124331343314433154331643317433184331943320433214332243323433244332543326433274332843329433304333143332433334333443335433364333743338433394334043341433424334343344433454334643347433484334943350433514335243353433544335543356433574335843359433604336143362433634336443365433664336743368433694337043371433724337343374433754337643377433784337943380433814338243383433844338543386433874338843389433904339143392433934339443395433964339743398433994340043401434024340343404434054340643407434084340943410434114341243413434144341543416434174341843419434204342143422434234342443425434264342743428434294343043431434324343343434434354343643437434384343943440434414344243443434444344543446434474344843449434504345143452434534345443455434564345743458434594346043461434624346343464434654346643467434684346943470434714347243473434744347543476434774347843479434804348143482434834348443485434864348743488434894349043491434924349343494434954349643497434984349943500435014350243503435044350543506435074350843509435104351143512435134351443515435164351743518435194352043521435224352343524435254352643527435284352943530435314353243533435344353543536435374353843539435404354143542435434354443545435464354743548435494355043551435524355343554435554355643557435584355943560435614356243563435644356543566435674356843569435704357143572435734357443575435764357743578435794358043581435824358343584435854358643587435884358943590435914359243593435944359543596435974359843599436004360143602436034360443605436064360743608436094361043611436124361343614436154361643617436184361943620436214362243623436244362543626436274362843629436304363143632436334363443635436364363743638436394364043641436424364343644436454364643647436484364943650436514365243653436544365543656436574365843659436604366143662436634366443665436664366743668436694367043671436724367343674436754367643677436784367943680436814368243683436844368543686436874368843689436904369143692436934369443695436964369743698436994370043701437024370343704437054370643707437084370943710437114371243713437144371543716437174371843719437204372143722437234372443725437264372743728437294373043731437324373343734437354373643737437384373943740437414374243743437444374543746437474374843749437504375143752437534375443755437564375743758437594376043761437624376343764437654376643767437684376943770437714377243773437744377543776437774377843779437804378143782437834378443785437864378743788437894379043791437924379343794437954379643797437984379943800438014380243803438044380543806438074380843809438104381143812438134381443815438164381743818438194382043821438224382343824438254382643827438284382943830438314383243833438344383543836438374383843839438404384143842438434384443845438464384743848438494385043851438524385343854438554385643857438584385943860438614386243863438644386543866438674386843869438704387143872438734387443875438764387743878438794388043881438824388343884438854388643887438884388943890438914389243893438944389543896438974389843899439004390143902439034390443905439064390743908439094391043911439124391343914439154391643917439184391943920439214392243923439244392543926439274392843929439304393143932439334393443935439364393743938439394394043941439424394343944439454394643947439484394943950439514395243953439544395543956439574395843959439604396143962439634396443965439664396743968439694397043971439724397343974439754397643977439784397943980439814398243983439844398543986439874398843989439904399143992439934399443995439964399743998439994400044001440024400344004440054400644007440084400944010440114401244013440144401544016440174401844019440204402144022440234402444025440264402744028440294403044031440324403344034440354403644037440384403944040440414404244043440444404544046440474404844049440504405144052440534405444055440564405744058440594406044061440624406344064440654406644067440684406944070440714407244073440744407544076440774407844079440804408144082440834408444085440864408744088440894409044091440924409344094440954409644097440984409944100441014410244103441044410544106441074410844109441104411144112441134411444115441164411744118441194412044121441224412344124441254412644127441284412944130441314413244133441344413544136441374413844139441404414144142441434414444145441464414744148441494415044151441524415344154441554415644157441584415944160441614416244163441644416544166441674416844169441704417144172441734417444175441764417744178441794418044181441824418344184441854418644187441884418944190441914419244193441944419544196441974419844199442004420144202442034420444205442064420744208442094421044211442124421344214442154421644217442184421944220442214422244223442244422544226442274422844229442304423144232442334423444235442364423744238442394424044241442424424344244442454424644247442484424944250442514425244253442544425544256442574425844259442604426144262442634426444265442664426744268442694427044271442724427344274442754427644277442784427944280442814428244283442844428544286442874428844289442904429144292442934429444295442964429744298442994430044301443024430344304443054430644307443084430944310443114431244313443144431544316443174431844319443204432144322443234432444325443264432744328443294433044331443324433344334443354433644337443384433944340443414434244343443444434544346443474434844349443504435144352443534435444355443564435744358443594436044361443624436344364443654436644367443684436944370443714437244373443744437544376443774437844379443804438144382443834438444385443864438744388443894439044391443924439344394443954439644397443984439944400444014440244403444044440544406444074440844409444104441144412444134441444415444164441744418444194442044421444224442344424444254442644427444284442944430444314443244433444344443544436444374443844439444404444144442444434444444445444464444744448444494445044451444524445344454444554445644457444584445944460444614446244463444644446544466444674446844469444704447144472444734447444475444764447744478444794448044481444824448344484444854448644487444884448944490444914449244493444944449544496444974449844499445004450144502445034450444505445064450744508445094451044511445124451344514445154451644517445184451944520445214452244523445244452544526445274452844529445304453144532445334453444535445364453744538445394454044541445424454344544445454454644547445484454944550445514455244553445544455544556445574455844559445604456144562445634456444565445664456744568445694457044571445724457344574445754457644577445784457944580445814458244583445844458544586445874458844589445904459144592445934459444595445964459744598445994460044601446024460344604446054460644607446084460944610446114461244613446144461544616446174461844619446204462144622446234462444625446264462744628446294463044631446324463344634446354463644637446384463944640446414464244643446444464544646446474464844649446504465144652446534465444655446564465744658446594466044661446624466344664446654466644667446684466944670446714467244673446744467544676446774467844679446804468144682446834468444685446864468744688446894469044691446924469344694446954469644697446984469944700447014470244703447044470544706447074470844709447104471144712447134471444715447164471744718447194472044721447224472344724447254472644727447284472944730447314473244733447344473544736447374473844739447404474144742447434474444745447464474744748447494475044751447524475344754447554475644757447584475944760447614476244763447644476544766447674476844769447704477144772447734477444775447764477744778447794478044781447824478344784447854478644787447884478944790447914479244793447944479544796447974479844799448004480144802448034480444805448064480744808448094481044811448124481344814448154481644817448184481944820448214482244823448244482544826448274482844829448304483144832448334483444835448364483744838448394484044841448424484344844448454484644847448484484944850448514485244853448544485544856448574485844859448604486144862448634486444865448664486744868448694487044871448724487344874448754487644877448784487944880448814488244883448844488544886448874488844889448904489144892448934489444895448964489744898448994490044901449024490344904449054490644907449084490944910449114491244913449144491544916449174491844919449204492144922449234492444925449264492744928449294493044931449324493344934449354493644937449384493944940449414494244943449444494544946449474494844949449504495144952449534495444955449564495744958449594496044961449624496344964449654496644967449684496944970449714497244973449744497544976449774497844979449804498144982449834498444985449864498744988449894499044991449924499344994449954499644997449984499945000450014500245003450044500545006450074500845009450104501145012450134501445015450164501745018450194502045021450224502345024450254502645027450284502945030450314503245033450344503545036450374503845039450404504145042450434504445045450464504745048450494505045051450524505345054450554505645057450584505945060450614506245063450644506545066450674506845069450704507145072450734507445075450764507745078450794508045081450824508345084450854508645087450884508945090450914509245093450944509545096450974509845099451004510145102451034510445105451064510745108451094511045111451124511345114451154511645117451184511945120451214512245123451244512545126451274512845129451304513145132451334513445135451364513745138451394514045141451424514345144451454514645147451484514945150451514515245153451544515545156451574515845159451604516145162451634516445165451664516745168451694517045171451724517345174451754517645177451784517945180451814518245183451844518545186451874518845189451904519145192451934519445195451964519745198451994520045201452024520345204452054520645207452084520945210452114521245213452144521545216452174521845219452204522145222452234522445225452264522745228452294523045231452324523345234452354523645237452384523945240452414524245243452444524545246452474524845249452504525145252452534525445255452564525745258452594526045261452624526345264452654526645267452684526945270452714527245273452744527545276452774527845279452804528145282452834528445285452864528745288452894529045291452924529345294452954529645297452984529945300453014530245303453044530545306453074530845309453104531145312453134531445315453164531745318453194532045321453224532345324453254532645327453284532945330453314533245333453344533545336453374533845339453404534145342453434534445345453464534745348453494535045351453524535345354453554535645357453584535945360453614536245363453644536545366453674536845369453704537145372453734537445375453764537745378453794538045381453824538345384453854538645387453884538945390453914539245393453944539545396453974539845399454004540145402454034540445405454064540745408454094541045411454124541345414454154541645417454184541945420454214542245423454244542545426454274542845429454304543145432454334543445435454364543745438454394544045441454424544345444454454544645447454484544945450454514545245453454544545545456454574545845459454604546145462454634546445465454664546745468454694547045471454724547345474454754547645477454784547945480454814548245483454844548545486454874548845489454904549145492454934549445495454964549745498454994550045501455024550345504455054550645507455084550945510455114551245513455144551545516455174551845519455204552145522455234552445525455264552745528455294553045531455324553345534455354553645537455384553945540455414554245543455444554545546455474554845549455504555145552455534555445555455564555745558455594556045561455624556345564455654556645567455684556945570455714557245573455744557545576455774557845579455804558145582455834558445585455864558745588455894559045591455924559345594455954559645597455984559945600456014560245603456044560545606456074560845609456104561145612456134561445615456164561745618456194562045621456224562345624456254562645627456284562945630456314563245633456344563545636456374563845639456404564145642456434564445645456464564745648456494565045651456524565345654456554565645657456584565945660456614566245663456644566545666456674566845669456704567145672456734567445675456764567745678456794568045681456824568345684456854568645687456884568945690456914569245693456944569545696456974569845699457004570145702457034570445705457064570745708457094571045711457124571345714457154571645717457184571945720457214572245723457244572545726457274572845729457304573145732457334573445735457364573745738457394574045741457424574345744457454574645747457484574945750457514575245753457544575545756457574575845759457604576145762457634576445765457664576745768457694577045771457724577345774457754577645777457784577945780457814578245783457844578545786457874578845789457904579145792457934579445795457964579745798457994580045801458024580345804458054580645807458084580945810458114581245813458144581545816458174581845819458204582145822458234582445825458264582745828458294583045831458324583345834458354583645837458384583945840458414584245843458444584545846458474584845849458504585145852458534585445855458564585745858458594586045861458624586345864458654586645867458684586945870458714587245873458744587545876458774587845879458804588145882458834588445885458864588745888458894589045891458924589345894458954589645897458984589945900459014590245903459044590545906459074590845909459104591145912459134591445915459164591745918459194592045921459224592345924459254592645927459284592945930459314593245933459344593545936459374593845939459404594145942459434594445945459464594745948459494595045951459524595345954459554595645957459584595945960459614596245963459644596545966459674596845969459704597145972459734597445975459764597745978459794598045981459824598345984459854598645987459884598945990459914599245993459944599545996459974599845999460004600146002460034600446005460064600746008460094601046011460124601346014460154601646017460184601946020460214602246023460244602546026460274602846029460304603146032460334603446035460364603746038460394604046041460424604346044460454604646047460484604946050460514605246053460544605546056460574605846059460604606146062460634606446065460664606746068460694607046071460724607346074460754607646077460784607946080460814608246083460844608546086460874608846089460904609146092460934609446095460964609746098460994610046101461024610346104461054610646107461084610946110461114611246113461144611546116461174611846119461204612146122461234612446125461264612746128461294613046131461324613346134461354613646137461384613946140461414614246143461444614546146461474614846149461504615146152461534615446155461564615746158461594616046161461624616346164461654616646167461684616946170461714617246173461744617546176461774617846179461804618146182461834618446185461864618746188461894619046191461924619346194461954619646197461984619946200462014620246203462044620546206462074620846209462104621146212462134621446215462164621746218462194622046221462224622346224462254622646227462284622946230462314623246233462344623546236462374623846239462404624146242462434624446245462464624746248462494625046251462524625346254462554625646257462584625946260462614626246263462644626546266462674626846269462704627146272462734627446275462764627746278462794628046281462824628346284462854628646287462884628946290462914629246293462944629546296462974629846299463004630146302463034630446305463064630746308463094631046311463124631346314463154631646317463184631946320463214632246323463244632546326463274632846329463304633146332463334633446335463364633746338463394634046341463424634346344463454634646347463484634946350463514635246353463544635546356463574635846359463604636146362463634636446365463664636746368463694637046371463724637346374463754637646377463784637946380463814638246383463844638546386463874638846389463904639146392463934639446395463964639746398463994640046401464024640346404464054640646407464084640946410464114641246413464144641546416464174641846419464204642146422464234642446425464264642746428464294643046431464324643346434464354643646437464384643946440464414644246443464444644546446464474644846449464504645146452464534645446455464564645746458464594646046461464624646346464464654646646467464684646946470464714647246473464744647546476464774647846479464804648146482464834648446485464864648746488464894649046491464924649346494464954649646497464984649946500465014650246503465044650546506465074650846509465104651146512465134651446515465164651746518465194652046521465224652346524465254652646527465284652946530465314653246533465344653546536465374653846539465404654146542465434654446545465464654746548465494655046551465524655346554465554655646557465584655946560465614656246563465644656546566465674656846569465704657146572465734657446575465764657746578465794658046581465824658346584465854658646587465884658946590465914659246593465944659546596465974659846599466004660146602466034660446605466064660746608466094661046611466124661346614466154661646617466184661946620466214662246623466244662546626466274662846629466304663146632466334663446635466364663746638466394664046641466424664346644466454664646647466484664946650466514665246653466544665546656466574665846659466604666146662466634666446665466664666746668466694667046671466724667346674466754667646677466784667946680466814668246683466844668546686466874668846689466904669146692466934669446695466964669746698466994670046701467024670346704467054670646707467084670946710467114671246713467144671546716467174671846719467204672146722467234672446725467264672746728467294673046731467324673346734467354673646737467384673946740467414674246743467444674546746467474674846749467504675146752467534675446755467564675746758467594676046761467624676346764467654676646767467684676946770467714677246773467744677546776467774677846779467804678146782467834678446785467864678746788467894679046791467924679346794467954679646797467984679946800468014680246803468044680546806468074680846809468104681146812468134681446815468164681746818468194682046821468224682346824468254682646827468284682946830468314683246833468344683546836468374683846839468404684146842468434684446845468464684746848468494685046851468524685346854468554685646857468584685946860468614686246863468644686546866468674686846869468704687146872468734687446875468764687746878468794688046881468824688346884468854688646887468884688946890468914689246893468944689546896468974689846899469004690146902469034690446905469064690746908469094691046911469124691346914469154691646917469184691946920469214692246923469244692546926469274692846929469304693146932469334693446935469364693746938469394694046941469424694346944469454694646947469484694946950469514695246953469544695546956469574695846959469604696146962469634696446965469664696746968469694697046971469724697346974469754697646977469784697946980469814698246983469844698546986469874698846989469904699146992469934699446995469964699746998469994700047001470024700347004470054700647007470084700947010470114701247013470144701547016470174701847019470204702147022470234702447025470264702747028470294703047031470324703347034470354703647037470384703947040470414704247043470444704547046470474704847049470504705147052470534705447055470564705747058470594706047061470624706347064470654706647067470684706947070470714707247073470744707547076470774707847079470804708147082470834708447085470864708747088470894709047091470924709347094470954709647097470984709947100471014710247103471044710547106471074710847109471104711147112471134711447115471164711747118471194712047121471224712347124471254712647127471284712947130471314713247133471344713547136471374713847139471404714147142471434714447145471464714747148471494715047151471524715347154471554715647157471584715947160471614716247163471644716547166471674716847169471704717147172471734717447175471764717747178471794718047181471824718347184471854718647187471884718947190471914719247193471944719547196471974719847199472004720147202472034720447205472064720747208472094721047211472124721347214472154721647217472184721947220472214722247223472244722547226472274722847229472304723147232472334723447235472364723747238472394724047241472424724347244472454724647247472484724947250472514725247253472544725547256472574725847259472604726147262472634726447265472664726747268472694727047271472724727347274472754727647277472784727947280472814728247283472844728547286472874728847289472904729147292472934729447295472964729747298472994730047301473024730347304473054730647307473084730947310473114731247313473144731547316473174731847319473204732147322473234732447325473264732747328473294733047331473324733347334473354733647337473384733947340473414734247343473444734547346473474734847349473504735147352473534735447355473564735747358473594736047361473624736347364473654736647367473684736947370473714737247373473744737547376473774737847379473804738147382473834738447385473864738747388473894739047391473924739347394473954739647397473984739947400474014740247403474044740547406474074740847409474104741147412474134741447415474164741747418474194742047421474224742347424474254742647427474284742947430474314743247433474344743547436474374743847439474404744147442474434744447445474464744747448474494745047451474524745347454474554745647457474584745947460474614746247463474644746547466474674746847469474704747147472474734747447475474764747747478474794748047481474824748347484474854748647487474884748947490474914749247493474944749547496474974749847499475004750147502475034750447505475064750747508475094751047511475124751347514475154751647517475184751947520475214752247523475244752547526475274752847529475304753147532475334753447535475364753747538475394754047541475424754347544475454754647547475484754947550475514755247553475544755547556475574755847559475604756147562475634756447565475664756747568475694757047571475724757347574475754757647577475784757947580475814758247583475844758547586475874758847589475904759147592475934759447595475964759747598475994760047601476024760347604476054760647607476084760947610476114761247613476144761547616476174761847619476204762147622476234762447625476264762747628476294763047631476324763347634476354763647637476384763947640476414764247643476444764547646476474764847649476504765147652476534765447655476564765747658476594766047661476624766347664476654766647667476684766947670476714767247673476744767547676476774767847679476804768147682476834768447685476864768747688476894769047691476924769347694476954769647697476984769947700477014770247703477044770547706477074770847709477104771147712477134771447715477164771747718477194772047721477224772347724477254772647727477284772947730477314773247733477344773547736477374773847739477404774147742477434774447745477464774747748477494775047751477524775347754477554775647757477584775947760477614776247763477644776547766477674776847769477704777147772477734777447775477764777747778477794778047781477824778347784477854778647787477884778947790477914779247793477944779547796477974779847799478004780147802478034780447805478064780747808478094781047811478124781347814478154781647817478184781947820478214782247823478244782547826478274782847829478304783147832478334783447835478364783747838478394784047841478424784347844478454784647847478484784947850478514785247853478544785547856478574785847859478604786147862478634786447865478664786747868478694787047871478724787347874478754787647877478784787947880478814788247883478844788547886478874788847889478904789147892478934789447895478964789747898478994790047901479024790347904479054790647907479084790947910479114791247913479144791547916479174791847919479204792147922479234792447925479264792747928479294793047931479324793347934479354793647937479384793947940479414794247943479444794547946479474794847949479504795147952479534795447955479564795747958479594796047961479624796347964479654796647967479684796947970479714797247973479744797547976479774797847979479804798147982479834798447985479864798747988479894799047991479924799347994479954799647997479984799948000480014800248003480044800548006480074800848009480104801148012480134801448015480164801748018480194802048021480224802348024480254802648027480284802948030480314803248033480344803548036480374803848039480404804148042480434804448045480464804748048480494805048051480524805348054480554805648057480584805948060480614806248063480644806548066480674806848069480704807148072480734807448075480764807748078480794808048081480824808348084480854808648087480884808948090480914809248093480944809548096480974809848099481004810148102481034810448105481064810748108481094811048111481124811348114481154811648117481184811948120481214812248123481244812548126481274812848129481304813148132481334813448135481364813748138481394814048141481424814348144481454814648147481484814948150481514815248153481544815548156481574815848159481604816148162481634816448165481664816748168481694817048171481724817348174481754817648177481784817948180481814818248183481844818548186481874818848189481904819148192481934819448195481964819748198481994820048201482024820348204482054820648207482084820948210482114821248213482144821548216482174821848219482204822148222482234822448225482264822748228482294823048231482324823348234482354823648237482384823948240482414824248243482444824548246482474824848249482504825148252482534825448255482564825748258482594826048261482624826348264482654826648267482684826948270482714827248273482744827548276482774827848279482804828148282482834828448285482864828748288482894829048291482924829348294482954829648297482984829948300483014830248303483044830548306483074830848309483104831148312483134831448315483164831748318483194832048321483224832348324483254832648327483284832948330483314833248333483344833548336483374833848339483404834148342483434834448345483464834748348483494835048351483524835348354483554835648357483584835948360483614836248363483644836548366483674836848369483704837148372483734837448375483764837748378483794838048381483824838348384483854838648387483884838948390483914839248393483944839548396483974839848399484004840148402484034840448405484064840748408484094841048411484124841348414484154841648417484184841948420484214842248423484244842548426484274842848429484304843148432484334843448435484364843748438484394844048441484424844348444484454844648447484484844948450484514845248453484544845548456484574845848459484604846148462484634846448465484664846748468484694847048471484724847348474484754847648477484784847948480484814848248483484844848548486484874848848489484904849148492484934849448495484964849748498484994850048501485024850348504485054850648507485084850948510485114851248513485144851548516485174851848519485204852148522485234852448525485264852748528485294853048531485324853348534485354853648537485384853948540485414854248543485444854548546485474854848549485504855148552485534855448555485564855748558485594856048561485624856348564485654856648567485684856948570485714857248573485744857548576485774857848579485804858148582485834858448585485864858748588485894859048591485924859348594485954859648597485984859948600486014860248603486044860548606486074860848609486104861148612486134861448615486164861748618486194862048621486224862348624486254862648627486284862948630486314863248633486344863548636486374863848639486404864148642486434864448645486464864748648486494865048651486524865348654486554865648657486584865948660486614866248663486644866548666486674866848669486704867148672486734867448675486764867748678486794868048681486824868348684486854868648687486884868948690486914869248693486944869548696486974869848699487004870148702487034870448705487064870748708487094871048711487124871348714487154871648717487184871948720487214872248723487244872548726487274872848729487304873148732487334873448735487364873748738487394874048741487424874348744487454874648747487484874948750487514875248753487544875548756487574875848759487604876148762487634876448765487664876748768487694877048771487724877348774487754877648777487784877948780487814878248783487844878548786487874878848789487904879148792487934879448795487964879748798487994880048801488024880348804488054880648807488084880948810488114881248813488144881548816488174881848819488204882148822488234882448825488264882748828488294883048831488324883348834488354883648837488384883948840488414884248843488444884548846488474884848849488504885148852488534885448855488564885748858488594886048861488624886348864488654886648867488684886948870488714887248873488744887548876488774887848879488804888148882488834888448885488864888748888488894889048891488924889348894488954889648897488984889948900489014890248903489044890548906489074890848909489104891148912489134891448915489164891748918489194892048921489224892348924489254892648927489284892948930489314893248933489344893548936489374893848939489404894148942489434894448945489464894748948489494895048951489524895348954489554895648957489584895948960489614896248963489644896548966489674896848969489704897148972489734897448975489764897748978489794898048981489824898348984489854898648987489884898948990489914899248993489944899548996489974899848999490004900149002490034900449005490064900749008490094901049011490124901349014490154901649017490184901949020490214902249023490244902549026490274902849029490304903149032490334903449035490364903749038490394904049041490424904349044490454904649047490484904949050490514905249053490544905549056490574905849059490604906149062490634906449065490664906749068490694907049071490724907349074490754907649077490784907949080490814908249083490844908549086490874908849089490904909149092490934909449095490964909749098490994910049101491024910349104491054910649107491084910949110491114911249113491144911549116491174911849119491204912149122491234912449125491264912749128491294913049131491324913349134491354913649137491384913949140491414914249143491444914549146491474914849149491504915149152491534915449155491564915749158491594916049161491624916349164491654916649167491684916949170491714917249173491744917549176491774917849179491804918149182491834918449185491864918749188491894919049191491924919349194491954919649197491984919949200492014920249203492044920549206492074920849209492104921149212492134921449215492164921749218492194922049221492224922349224492254922649227492284922949230492314923249233492344923549236492374923849239492404924149242492434924449245492464924749248492494925049251492524925349254492554925649257492584925949260492614926249263492644926549266492674926849269492704927149272492734927449275492764927749278492794928049281492824928349284492854928649287492884928949290492914929249293492944929549296492974929849299493004930149302493034930449305493064930749308493094931049311493124931349314493154931649317493184931949320493214932249323493244932549326493274932849329493304933149332493334933449335493364933749338493394934049341493424934349344493454934649347493484934949350493514935249353493544935549356493574935849359493604936149362493634936449365493664936749368493694937049371493724937349374493754937649377493784937949380493814938249383493844938549386493874938849389493904939149392493934939449395493964939749398493994940049401494024940349404494054940649407494084940949410494114941249413494144941549416494174941849419494204942149422494234942449425494264942749428494294943049431494324943349434494354943649437494384943949440494414944249443494444944549446494474944849449494504945149452494534945449455494564945749458494594946049461494624946349464494654946649467494684946949470494714947249473494744947549476494774947849479494804948149482494834948449485494864948749488494894949049491494924949349494494954949649497494984949949500495014950249503495044950549506495074950849509495104951149512495134951449515495164951749518495194952049521495224952349524495254952649527495284952949530495314953249533495344953549536495374953849539495404954149542495434954449545495464954749548495494955049551495524955349554495554955649557495584955949560495614956249563495644956549566495674956849569495704957149572495734957449575495764957749578495794958049581495824958349584495854958649587495884958949590495914959249593495944959549596495974959849599496004960149602496034960449605496064960749608496094961049611496124961349614496154961649617496184961949620496214962249623496244962549626496274962849629496304963149632496334963449635496364963749638496394964049641496424964349644496454964649647496484964949650496514965249653496544965549656496574965849659496604966149662496634966449665496664966749668496694967049671496724967349674496754967649677496784967949680496814968249683496844968549686496874968849689496904969149692496934969449695496964969749698496994970049701497024970349704497054970649707497084970949710497114971249713497144971549716497174971849719497204972149722497234972449725497264972749728497294973049731497324973349734497354973649737497384973949740497414974249743497444974549746497474974849749497504975149752497534975449755497564975749758497594976049761497624976349764497654976649767497684976949770497714977249773497744977549776497774977849779497804978149782497834978449785497864978749788497894979049791497924979349794497954979649797497984979949800498014980249803498044980549806498074980849809498104981149812498134981449815498164981749818498194982049821498224982349824498254982649827498284982949830498314983249833498344983549836498374983849839498404984149842498434984449845498464984749848498494985049851498524985349854498554985649857498584985949860498614986249863498644986549866498674986849869498704987149872498734987449875498764987749878498794988049881498824988349884498854988649887498884988949890498914989249893498944989549896498974989849899499004990149902499034990449905499064990749908499094991049911499124991349914499154991649917499184991949920499214992249923499244992549926499274992849929499304993149932499334993449935499364993749938499394994049941499424994349944499454994649947499484994949950499514995249953499544995549956499574995849959499604996149962499634996449965499664996749968499694997049971499724997349974499754997649977499784997949980499814998249983499844998549986499874998849989499904999149992499934999449995499964999749998499995000050001500025000350004500055000650007500085000950010500115001250013500145001550016500175001850019500205002150022500235002450025500265002750028500295003050031500325003350034500355003650037500385003950040500415004250043500445004550046500475004850049500505005150052500535005450055500565005750058500595006050061500625006350064500655006650067500685006950070500715007250073500745007550076500775007850079500805008150082500835008450085500865008750088500895009050091500925009350094500955009650097500985009950100501015010250103501045010550106501075010850109501105011150112501135011450115501165011750118501195012050121501225012350124501255012650127501285012950130501315013250133501345013550136501375013850139501405014150142501435014450145501465014750148501495015050151501525015350154501555015650157501585015950160501615016250163501645016550166501675016850169501705017150172501735017450175501765017750178501795018050181501825018350184501855018650187501885018950190501915019250193501945019550196501975019850199502005020150202502035020450205502065020750208502095021050211502125021350214502155021650217502185021950220502215022250223502245022550226502275022850229502305023150232502335023450235502365023750238502395024050241502425024350244502455024650247502485024950250502515025250253502545025550256502575025850259502605026150262502635026450265502665026750268502695027050271502725027350274502755027650277502785027950280502815028250283502845028550286502875028850289502905029150292502935029450295502965029750298502995030050301503025030350304503055030650307503085030950310503115031250313503145031550316503175031850319503205032150322503235032450325503265032750328503295033050331503325033350334503355033650337503385033950340503415034250343503445034550346503475034850349503505035150352503535035450355503565035750358503595036050361503625036350364503655036650367503685036950370503715037250373503745037550376503775037850379503805038150382503835038450385503865038750388503895039050391503925039350394503955039650397503985039950400504015040250403504045040550406504075040850409504105041150412504135041450415504165041750418504195042050421504225042350424504255042650427504285042950430504315043250433504345043550436504375043850439504405044150442504435044450445504465044750448504495045050451504525045350454504555045650457504585045950460504615046250463504645046550466504675046850469504705047150472504735047450475504765047750478504795048050481504825048350484504855048650487504885048950490504915049250493504945049550496504975049850499505005050150502505035050450505505065050750508505095051050511505125051350514505155051650517505185051950520505215052250523505245052550526505275052850529505305053150532505335053450535505365053750538505395054050541505425054350544505455054650547505485054950550505515055250553505545055550556505575055850559505605056150562505635056450565505665056750568505695057050571505725057350574505755057650577505785057950580505815058250583505845058550586505875058850589505905059150592505935059450595505965059750598505995060050601506025060350604506055060650607506085060950610506115061250613506145061550616506175061850619506205062150622506235062450625506265062750628506295063050631506325063350634506355063650637506385063950640506415064250643506445064550646506475064850649506505065150652506535065450655506565065750658506595066050661506625066350664506655066650667506685066950670506715067250673506745067550676506775067850679506805068150682506835068450685506865068750688506895069050691506925069350694506955069650697506985069950700507015070250703507045070550706507075070850709507105071150712507135071450715507165071750718507195072050721507225072350724507255072650727507285072950730507315073250733507345073550736507375073850739507405074150742507435074450745507465074750748507495075050751507525075350754507555075650757507585075950760507615076250763507645076550766507675076850769507705077150772507735077450775507765077750778507795078050781507825078350784507855078650787507885078950790507915079250793507945079550796507975079850799508005080150802508035080450805508065080750808508095081050811508125081350814508155081650817508185081950820508215082250823508245082550826508275082850829508305083150832508335083450835508365083750838508395084050841508425084350844508455084650847508485084950850508515085250853508545085550856508575085850859508605086150862508635086450865508665086750868508695087050871508725087350874508755087650877508785087950880508815088250883508845088550886508875088850889508905089150892508935089450895508965089750898508995090050901509025090350904509055090650907509085090950910509115091250913509145091550916509175091850919509205092150922509235092450925509265092750928509295093050931509325093350934509355093650937509385093950940509415094250943509445094550946509475094850949509505095150952509535095450955509565095750958509595096050961509625096350964509655096650967509685096950970509715097250973509745097550976509775097850979509805098150982509835098450985509865098750988509895099050991509925099350994509955099650997509985099951000510015100251003510045100551006510075100851009510105101151012510135101451015510165101751018510195102051021510225102351024510255102651027510285102951030510315103251033510345103551036510375103851039510405104151042510435104451045510465104751048510495105051051510525105351054510555105651057510585105951060510615106251063510645106551066510675106851069510705107151072510735107451075510765107751078510795108051081510825108351084510855108651087510885108951090510915109251093510945109551096510975109851099511005110151102511035110451105511065110751108511095111051111511125111351114511155111651117511185111951120511215112251123511245112551126511275112851129511305113151132511335113451135511365113751138511395114051141511425114351144511455114651147511485114951150511515115251153511545115551156511575115851159511605116151162511635116451165511665116751168511695117051171511725117351174511755117651177511785117951180511815118251183511845118551186511875118851189511905119151192511935119451195511965119751198511995120051201512025120351204512055120651207512085120951210512115121251213512145121551216512175121851219512205122151222512235122451225512265122751228512295123051231512325123351234512355123651237512385123951240512415124251243512445124551246512475124851249512505125151252512535125451255512565125751258512595126051261512625126351264512655126651267512685126951270512715127251273512745127551276512775127851279512805128151282512835128451285512865128751288512895129051291512925129351294512955129651297512985129951300513015130251303513045130551306513075130851309513105131151312513135131451315513165131751318513195132051321513225132351324513255132651327513285132951330513315133251333513345133551336513375133851339513405134151342513435134451345513465134751348513495135051351513525135351354513555135651357513585135951360513615136251363513645136551366513675136851369513705137151372513735137451375513765137751378513795138051381513825138351384513855138651387513885138951390513915139251393513945139551396513975139851399514005140151402514035140451405514065140751408514095141051411514125141351414514155141651417514185141951420514215142251423514245142551426514275142851429514305143151432514335143451435514365143751438514395144051441514425144351444514455144651447514485144951450514515145251453514545145551456514575145851459514605146151462514635146451465514665146751468514695147051471514725147351474514755147651477514785147951480514815148251483514845148551486514875148851489514905149151492514935149451495514965149751498514995150051501515025150351504515055150651507515085150951510515115151251513515145151551516515175151851519515205152151522515235152451525515265152751528515295153051531515325153351534515355153651537515385153951540515415154251543515445154551546515475154851549515505155151552515535155451555515565155751558515595156051561515625156351564515655156651567515685156951570515715157251573515745157551576515775157851579515805158151582515835158451585515865158751588515895159051591515925159351594515955159651597515985159951600516015160251603516045160551606516075160851609516105161151612516135161451615516165161751618516195162051621516225162351624516255162651627516285162951630516315163251633516345163551636516375163851639516405164151642516435164451645516465164751648516495165051651516525165351654516555165651657516585165951660516615166251663516645166551666516675166851669516705167151672516735167451675516765167751678516795168051681516825168351684516855168651687516885168951690516915169251693516945169551696516975169851699517005170151702517035170451705517065170751708517095171051711517125171351714517155171651717517185171951720517215172251723517245172551726517275172851729517305173151732517335173451735517365173751738517395174051741517425174351744517455174651747517485174951750517515175251753517545175551756517575175851759517605176151762517635176451765517665176751768517695177051771517725177351774517755177651777517785177951780517815178251783517845178551786517875178851789517905179151792517935179451795517965179751798517995180051801518025180351804518055180651807518085180951810518115181251813518145181551816518175181851819518205182151822518235182451825518265182751828518295183051831518325183351834518355183651837518385183951840518415184251843518445184551846518475184851849518505185151852518535185451855518565185751858518595186051861518625186351864518655186651867518685186951870518715187251873518745187551876518775187851879518805188151882518835188451885518865188751888518895189051891518925189351894518955189651897518985189951900519015190251903519045190551906519075190851909519105191151912519135191451915519165191751918519195192051921519225192351924519255192651927519285192951930519315193251933519345193551936519375193851939519405194151942519435194451945519465194751948519495195051951519525195351954519555195651957519585195951960519615196251963519645196551966519675196851969519705197151972519735197451975519765197751978519795198051981519825198351984519855198651987519885198951990519915199251993519945199551996519975199851999520005200152002520035200452005520065200752008520095201052011520125201352014520155201652017520185201952020520215202252023520245202552026520275202852029520305203152032520335203452035520365203752038520395204052041520425204352044520455204652047520485204952050520515205252053520545205552056520575205852059520605206152062520635206452065520665206752068520695207052071520725207352074520755207652077520785207952080520815208252083520845208552086520875208852089520905209152092520935209452095520965209752098520995210052101521025210352104521055210652107521085210952110521115211252113521145211552116521175211852119521205212152122521235212452125521265212752128521295213052131521325213352134521355213652137521385213952140521415214252143521445214552146521475214852149521505215152152521535215452155521565215752158521595216052161521625216352164521655216652167521685216952170521715217252173521745217552176521775217852179521805218152182521835218452185521865218752188521895219052191521925219352194521955219652197521985219952200522015220252203522045220552206522075220852209522105221152212522135221452215522165221752218522195222052221522225222352224522255222652227522285222952230522315223252233522345223552236522375223852239522405224152242522435224452245522465224752248522495225052251522525225352254522555225652257522585225952260522615226252263522645226552266522675226852269522705227152272522735227452275522765227752278522795228052281522825228352284522855228652287522885228952290522915229252293522945229552296522975229852299523005230152302523035230452305523065230752308523095231052311523125231352314523155231652317523185231952320523215232252323523245232552326523275232852329523305233152332523335233452335523365233752338523395234052341523425234352344523455234652347523485234952350523515235252353523545235552356523575235852359523605236152362523635236452365523665236752368523695237052371523725237352374523755237652377523785237952380523815238252383523845238552386523875238852389523905239152392523935239452395523965239752398523995240052401524025240352404524055240652407524085240952410524115241252413524145241552416524175241852419524205242152422524235242452425524265242752428524295243052431524325243352434524355243652437524385243952440524415244252443524445244552446524475244852449524505245152452524535245452455524565245752458524595246052461524625246352464524655246652467524685246952470524715247252473524745247552476524775247852479524805248152482524835248452485524865248752488524895249052491524925249352494524955249652497524985249952500525015250252503525045250552506525075250852509525105251152512525135251452515525165251752518525195252052521525225252352524525255252652527525285252952530525315253252533525345253552536525375253852539525405254152542525435254452545525465254752548525495255052551525525255352554525555255652557525585255952560525615256252563525645256552566525675256852569525705257152572525735257452575525765257752578525795258052581525825258352584525855258652587525885258952590525915259252593525945259552596525975259852599526005260152602526035260452605526065260752608526095261052611526125261352614526155261652617526185261952620526215262252623526245262552626526275262852629526305263152632526335263452635526365263752638526395264052641526425264352644526455264652647526485264952650526515265252653526545265552656526575265852659526605266152662526635266452665526665266752668526695267052671526725267352674526755267652677526785267952680526815268252683526845268552686526875268852689526905269152692526935269452695526965269752698526995270052701527025270352704527055270652707527085270952710527115271252713527145271552716527175271852719527205272152722527235272452725527265272752728527295273052731527325273352734527355273652737527385273952740527415274252743527445274552746527475274852749527505275152752527535275452755527565275752758527595276052761527625276352764527655276652767527685276952770527715277252773527745277552776527775277852779527805278152782527835278452785527865278752788527895279052791527925279352794527955279652797527985279952800528015280252803528045280552806528075280852809528105281152812528135281452815528165281752818528195282052821528225282352824528255282652827528285282952830528315283252833528345283552836528375283852839528405284152842528435284452845528465284752848528495285052851528525285352854528555285652857528585285952860528615286252863528645286552866528675286852869528705287152872528735287452875528765287752878528795288052881528825288352884528855288652887528885288952890528915289252893528945289552896528975289852899529005290152902529035290452905529065290752908529095291052911529125291352914529155291652917529185291952920529215292252923529245292552926529275292852929529305293152932529335293452935529365293752938529395294052941529425294352944529455294652947529485294952950529515295252953529545295552956529575295852959529605296152962529635296452965529665296752968529695297052971529725297352974529755297652977529785297952980529815298252983529845298552986529875298852989529905299152992529935299452995529965299752998529995300053001530025300353004530055300653007530085300953010530115301253013530145301553016530175301853019530205302153022530235302453025530265302753028530295303053031530325303353034530355303653037530385303953040530415304253043530445304553046530475304853049530505305153052530535305453055530565305753058530595306053061530625306353064530655306653067530685306953070530715307253073530745307553076530775307853079530805308153082530835308453085530865308753088530895309053091530925309353094530955309653097530985309953100531015310253103531045310553106531075310853109531105311153112531135311453115531165311753118531195312053121531225312353124531255312653127531285312953130531315313253133531345313553136531375313853139531405314153142531435314453145531465314753148531495315053151531525315353154531555315653157531585315953160531615316253163531645316553166531675316853169531705317153172531735317453175531765317753178531795318053181531825318353184531855318653187531885318953190531915319253193531945319553196531975319853199532005320153202532035320453205532065320753208532095321053211532125321353214532155321653217532185321953220532215322253223532245322553226532275322853229532305323153232532335323453235532365323753238532395324053241532425324353244532455324653247532485324953250532515325253253532545325553256532575325853259532605326153262532635326453265532665326753268532695327053271532725327353274532755327653277532785327953280532815328253283532845328553286532875328853289532905329153292532935329453295532965329753298532995330053301533025330353304533055330653307533085330953310533115331253313533145331553316533175331853319533205332153322533235332453325533265332753328533295333053331533325333353334533355333653337533385333953340533415334253343533445334553346533475334853349533505335153352533535335453355533565335753358533595336053361533625336353364533655336653367533685336953370533715337253373533745337553376533775337853379533805338153382533835338453385533865338753388533895339053391533925339353394533955339653397533985339953400534015340253403534045340553406534075340853409534105341153412534135341453415534165341753418534195342053421534225342353424534255342653427534285342953430534315343253433534345343553436534375343853439534405344153442534435344453445534465344753448534495345053451534525345353454534555345653457534585345953460534615346253463534645346553466534675346853469534705347153472534735347453475534765347753478534795348053481534825348353484534855348653487534885348953490534915349253493534945349553496534975349853499535005350153502535035350453505535065350753508535095351053511535125351353514535155351653517535185351953520535215352253523535245352553526535275352853529535305353153532535335353453535535365353753538535395354053541535425354353544535455354653547535485354953550535515355253553535545355553556535575355853559535605356153562535635356453565535665356753568535695357053571535725357353574535755357653577535785357953580535815358253583535845358553586535875358853589535905359153592535935359453595535965359753598535995360053601536025360353604536055360653607536085360953610536115361253613536145361553616536175361853619536205362153622536235362453625536265362753628536295363053631536325363353634536355363653637536385363953640536415364253643536445364553646536475364853649536505365153652536535365453655536565365753658536595366053661536625366353664536655366653667536685366953670536715367253673536745367553676536775367853679536805368153682536835368453685536865368753688536895369053691536925369353694536955369653697536985369953700537015370253703537045370553706537075370853709537105371153712537135371453715537165371753718537195372053721537225372353724537255372653727537285372953730537315373253733537345373553736537375373853739537405374153742537435374453745537465374753748537495375053751537525375353754537555375653757537585375953760537615376253763537645376553766537675376853769537705377153772537735377453775537765377753778537795378053781537825378353784537855378653787537885378953790537915379253793537945379553796537975379853799538005380153802538035380453805538065380753808538095381053811538125381353814538155381653817538185381953820538215382253823538245382553826538275382853829538305383153832538335383453835538365383753838538395384053841538425384353844538455384653847538485384953850538515385253853538545385553856538575385853859538605386153862538635386453865538665386753868538695387053871538725387353874538755387653877538785387953880538815388253883538845388553886538875388853889538905389153892538935389453895538965389753898538995390053901539025390353904539055390653907539085390953910539115391253913539145391553916539175391853919539205392153922539235392453925539265392753928539295393053931539325393353934539355393653937539385393953940539415394253943539445394553946539475394853949539505395153952539535395453955539565395753958539595396053961539625396353964539655396653967539685396953970539715397253973539745397553976539775397853979539805398153982539835398453985539865398753988539895399053991539925399353994539955399653997539985399954000540015400254003540045400554006540075400854009540105401154012540135401454015540165401754018540195402054021540225402354024540255402654027540285402954030540315403254033540345403554036540375403854039540405404154042540435404454045540465404754048540495405054051540525405354054540555405654057540585405954060540615406254063540645406554066540675406854069540705407154072540735407454075540765407754078540795408054081540825408354084540855408654087540885408954090540915409254093540945409554096540975409854099541005410154102541035410454105541065410754108541095411054111541125411354114541155411654117541185411954120541215412254123541245412554126541275412854129541305413154132541335413454135541365413754138541395414054141541425414354144541455414654147541485414954150541515415254153541545415554156541575415854159541605416154162541635416454165541665416754168541695417054171541725417354174541755417654177541785417954180541815418254183541845418554186541875418854189541905419154192541935419454195541965419754198541995420054201542025420354204542055420654207542085420954210542115421254213542145421554216542175421854219542205422154222542235422454225542265422754228542295423054231542325423354234542355423654237542385423954240542415424254243542445424554246542475424854249542505425154252542535425454255542565425754258542595426054261542625426354264542655426654267542685426954270542715427254273542745427554276542775427854279542805428154282542835428454285542865428754288542895429054291542925429354294542955429654297542985429954300543015430254303543045430554306543075430854309543105431154312543135431454315543165431754318543195432054321543225432354324543255432654327543285432954330543315433254333543345433554336543375433854339543405434154342543435434454345543465434754348543495435054351543525435354354543555435654357543585435954360543615436254363543645436554366543675436854369543705437154372543735437454375543765437754378543795438054381543825438354384543855438654387543885438954390543915439254393543945439554396543975439854399544005440154402544035440454405544065440754408544095441054411544125441354414544155441654417544185441954420544215442254423544245442554426544275442854429544305443154432544335443454435544365443754438544395444054441544425444354444544455444654447544485444954450544515445254453544545445554456544575445854459544605446154462544635446454465544665446754468544695447054471544725447354474544755447654477544785447954480544815448254483544845448554486544875448854489544905449154492544935449454495544965449754498544995450054501545025450354504545055450654507545085450954510545115451254513545145451554516545175451854519545205452154522545235452454525545265452754528545295453054531545325453354534545355453654537545385453954540545415454254543545445454554546545475454854549545505455154552545535455454555545565455754558545595456054561545625456354564545655456654567545685456954570545715457254573545745457554576545775457854579545805458154582545835458454585545865458754588545895459054591545925459354594545955459654597545985459954600546015460254603546045460554606546075460854609546105461154612546135461454615546165461754618546195462054621546225462354624546255462654627546285462954630546315463254633546345463554636546375463854639546405464154642546435464454645546465464754648546495465054651546525465354654546555465654657546585465954660546615466254663546645466554666546675466854669546705467154672546735467454675546765467754678546795468054681546825468354684546855468654687546885468954690546915469254693546945469554696546975469854699547005470154702547035470454705547065470754708547095471054711547125471354714547155471654717547185471954720547215472254723547245472554726547275472854729547305473154732547335473454735547365473754738547395474054741547425474354744547455474654747547485474954750547515475254753547545475554756547575475854759547605476154762547635476454765547665476754768547695477054771547725477354774547755477654777547785477954780547815478254783547845478554786547875478854789547905479154792547935479454795547965479754798547995480054801548025480354804548055480654807548085480954810548115481254813548145481554816548175481854819548205482154822548235482454825548265482754828548295483054831548325483354834548355483654837548385483954840548415484254843548445484554846548475484854849548505485154852548535485454855548565485754858548595486054861548625486354864548655486654867548685486954870548715487254873548745487554876548775487854879548805488154882548835488454885548865488754888548895489054891548925489354894548955489654897548985489954900549015490254903549045490554906549075490854909549105491154912549135491454915549165491754918549195492054921549225492354924549255492654927549285492954930549315493254933549345493554936549375493854939549405494154942549435494454945549465494754948549495495054951549525495354954549555495654957549585495954960549615496254963549645496554966549675496854969549705497154972549735497454975549765497754978549795498054981549825498354984549855498654987549885498954990549915499254993549945499554996549975499854999550005500155002550035500455005550065500755008550095501055011550125501355014550155501655017550185501955020550215502255023550245502555026550275502855029550305503155032550335503455035550365503755038550395504055041550425504355044550455504655047550485504955050550515505255053550545505555056550575505855059550605506155062550635506455065550665506755068550695507055071550725507355074550755507655077550785507955080550815508255083550845508555086550875508855089550905509155092550935509455095550965509755098550995510055101551025510355104551055510655107551085510955110551115511255113551145511555116551175511855119551205512155122551235512455125551265512755128551295513055131551325513355134551355513655137551385513955140551415514255143551445514555146551475514855149551505515155152551535515455155551565515755158551595516055161551625516355164551655516655167551685516955170551715517255173551745517555176551775517855179551805518155182551835518455185551865518755188551895519055191551925519355194551955519655197551985519955200552015520255203552045520555206552075520855209552105521155212552135521455215552165521755218552195522055221552225522355224552255522655227552285522955230552315523255233552345523555236552375523855239552405524155242552435524455245552465524755248552495525055251552525525355254552555525655257552585525955260552615526255263552645526555266552675526855269552705527155272552735527455275552765527755278552795528055281552825528355284552855528655287552885528955290552915529255293552945529555296552975529855299553005530155302553035530455305553065530755308553095531055311553125531355314553155531655317553185531955320553215532255323553245532555326553275532855329553305533155332553335533455335553365533755338553395534055341553425534355344553455534655347553485534955350553515535255353553545535555356553575535855359553605536155362553635536455365553665536755368553695537055371553725537355374553755537655377553785537955380553815538255383553845538555386553875538855389553905539155392553935539455395553965539755398553995540055401554025540355404554055540655407554085540955410554115541255413554145541555416554175541855419554205542155422554235542455425554265542755428554295543055431554325543355434554355543655437554385543955440554415544255443554445544555446554475544855449554505545155452554535545455455554565545755458554595546055461554625546355464554655546655467554685546955470554715547255473554745547555476554775547855479554805548155482554835548455485554865548755488554895549055491554925549355494554955549655497554985549955500555015550255503555045550555506555075550855509555105551155512555135551455515555165551755518555195552055521555225552355524555255552655527555285552955530555315553255533555345553555536555375553855539555405554155542555435554455545555465554755548555495555055551555525555355554555555555655557555585555955560555615556255563555645556555566555675556855569555705557155572555735557455575555765557755578555795558055581555825558355584555855558655587555885558955590555915559255593555945559555596555975559855599556005560155602556035560455605556065560755608556095561055611556125561355614556155561655617556185561955620556215562255623556245562555626556275562855629556305563155632556335563455635556365563755638556395564055641556425564355644556455564655647556485564955650556515565255653556545565555656556575565855659556605566155662556635566455665556665566755668556695567055671556725567355674556755567655677556785567955680556815568255683556845568555686556875568855689556905569155692556935569455695556965569755698556995570055701557025570355704557055570655707557085570955710557115571255713557145571555716557175571855719557205572155722557235572455725557265572755728557295573055731557325573355734557355573655737557385573955740557415574255743557445574555746557475574855749557505575155752557535575455755557565575755758557595576055761557625576355764557655576655767557685576955770557715577255773557745577555776557775577855779557805578155782557835578455785557865578755788557895579055791557925579355794557955579655797557985579955800558015580255803558045580555806558075580855809558105581155812558135581455815558165581755818558195582055821558225582355824558255582655827558285582955830558315583255833558345583555836558375583855839558405584155842558435584455845558465584755848558495585055851558525585355854558555585655857558585585955860558615586255863558645586555866558675586855869558705587155872558735587455875558765587755878558795588055881558825588355884558855588655887558885588955890558915589255893558945589555896558975589855899559005590155902559035590455905559065590755908559095591055911559125591355914559155591655917559185591955920559215592255923559245592555926559275592855929559305593155932559335593455935559365593755938559395594055941559425594355944559455594655947559485594955950559515595255953559545595555956559575595855959559605596155962559635596455965559665596755968559695597055971559725597355974559755597655977559785597955980559815598255983559845598555986559875598855989559905599155992559935599455995559965599755998559995600056001560025600356004560055600656007560085600956010560115601256013560145601556016560175601856019560205602156022560235602456025560265602756028560295603056031560325603356034560355603656037560385603956040560415604256043560445604556046560475604856049560505605156052560535605456055560565605756058560595606056061560625606356064560655606656067560685606956070560715607256073560745607556076560775607856079560805608156082560835608456085560865608756088560895609056091560925609356094560955609656097560985609956100561015610256103561045610556106561075610856109561105611156112561135611456115561165611756118561195612056121561225612356124561255612656127561285612956130561315613256133561345613556136561375613856139561405614156142561435614456145561465614756148561495615056151561525615356154561555615656157561585615956160561615616256163561645616556166561675616856169561705617156172561735617456175561765617756178561795618056181561825618356184561855618656187561885618956190561915619256193561945619556196561975619856199562005620156202562035620456205562065620756208562095621056211562125621356214562155621656217562185621956220562215622256223562245622556226562275622856229562305623156232562335623456235562365623756238562395624056241562425624356244562455624656247562485624956250562515625256253562545625556256562575625856259562605626156262562635626456265562665626756268562695627056271562725627356274562755627656277562785627956280562815628256283562845628556286562875628856289562905629156292562935629456295562965629756298562995630056301563025630356304563055630656307563085630956310563115631256313563145631556316563175631856319563205632156322563235632456325563265632756328563295633056331563325633356334563355633656337563385633956340563415634256343563445634556346563475634856349563505635156352563535635456355563565635756358563595636056361563625636356364563655636656367563685636956370563715637256373563745637556376563775637856379563805638156382563835638456385563865638756388563895639056391563925639356394563955639656397563985639956400564015640256403564045640556406564075640856409564105641156412564135641456415564165641756418564195642056421564225642356424564255642656427564285642956430564315643256433564345643556436564375643856439564405644156442564435644456445564465644756448564495645056451564525645356454564555645656457564585645956460564615646256463564645646556466564675646856469564705647156472564735647456475564765647756478564795648056481564825648356484564855648656487564885648956490564915649256493564945649556496564975649856499565005650156502565035650456505565065650756508565095651056511565125651356514565155651656517565185651956520565215652256523565245652556526565275652856529565305653156532565335653456535565365653756538565395654056541565425654356544565455654656547565485654956550565515655256553565545655556556565575655856559565605656156562565635656456565565665656756568565695657056571565725657356574565755657656577565785657956580565815658256583565845658556586565875658856589565905659156592565935659456595565965659756598565995660056601566025660356604566055660656607566085660956610566115661256613566145661556616566175661856619566205662156622566235662456625566265662756628566295663056631566325663356634566355663656637566385663956640566415664256643566445664556646566475664856649566505665156652566535665456655566565665756658566595666056661566625666356664566655666656667566685666956670566715667256673566745667556676566775667856679566805668156682566835668456685566865668756688566895669056691566925669356694566955669656697566985669956700567015670256703567045670556706567075670856709567105671156712567135671456715567165671756718567195672056721567225672356724567255672656727567285672956730567315673256733567345673556736567375673856739567405674156742567435674456745567465674756748567495675056751567525675356754567555675656757567585675956760567615676256763567645676556766567675676856769567705677156772567735677456775567765677756778567795678056781567825678356784567855678656787567885678956790567915679256793567945679556796567975679856799568005680156802568035680456805568065680756808568095681056811568125681356814568155681656817568185681956820568215682256823568245682556826568275682856829568305683156832568335683456835568365683756838568395684056841568425684356844568455684656847568485684956850568515685256853568545685556856568575685856859568605686156862568635686456865568665686756868568695687056871568725687356874568755687656877568785687956880568815688256883568845688556886568875688856889568905689156892568935689456895568965689756898568995690056901569025690356904569055690656907569085690956910569115691256913569145691556916569175691856919569205692156922569235692456925569265692756928569295693056931569325693356934569355693656937569385693956940569415694256943569445694556946569475694856949569505695156952569535695456955569565695756958569595696056961569625696356964569655696656967569685696956970569715697256973569745697556976569775697856979569805698156982569835698456985569865698756988569895699056991569925699356994569955699656997569985699957000570015700257003570045700557006570075700857009570105701157012570135701457015570165701757018570195702057021570225702357024570255702657027570285702957030570315703257033570345703557036570375703857039570405704157042570435704457045570465704757048570495705057051570525705357054570555705657057570585705957060570615706257063570645706557066570675706857069570705707157072570735707457075570765707757078570795708057081570825708357084570855708657087570885708957090570915709257093570945709557096570975709857099571005710157102571035710457105571065710757108571095711057111571125711357114571155711657117571185711957120571215712257123571245712557126571275712857129571305713157132571335713457135571365713757138571395714057141571425714357144571455714657147571485714957150571515715257153571545715557156571575715857159571605716157162571635716457165571665716757168571695717057171571725717357174571755717657177571785717957180571815718257183571845718557186571875718857189571905719157192571935719457195571965719757198571995720057201572025720357204572055720657207572085720957210572115721257213572145721557216572175721857219572205722157222572235722457225572265722757228572295723057231572325723357234572355723657237572385723957240572415724257243572445724557246572475724857249572505725157252572535725457255572565725757258572595726057261572625726357264572655726657267572685726957270572715727257273572745727557276572775727857279572805728157282572835728457285572865728757288572895729057291572925729357294572955729657297572985729957300573015730257303573045730557306573075730857309573105731157312573135731457315573165731757318573195732057321573225732357324573255732657327573285732957330573315733257333573345733557336573375733857339573405734157342573435734457345573465734757348573495735057351573525735357354573555735657357573585735957360573615736257363573645736557366573675736857369573705737157372573735737457375573765737757378573795738057381573825738357384573855738657387573885738957390573915739257393573945739557396573975739857399574005740157402574035740457405574065740757408574095741057411574125741357414574155741657417574185741957420574215742257423574245742557426574275742857429574305743157432574335743457435574365743757438574395744057441574425744357444574455744657447574485744957450574515745257453574545745557456574575745857459574605746157462574635746457465574665746757468574695747057471574725747357474574755747657477574785747957480574815748257483574845748557486574875748857489574905749157492574935749457495574965749757498574995750057501575025750357504575055750657507575085750957510575115751257513575145751557516575175751857519575205752157522575235752457525575265752757528575295753057531575325753357534575355753657537575385753957540575415754257543575445754557546575475754857549575505755157552575535755457555575565755757558575595756057561575625756357564575655756657567575685756957570575715757257573575745757557576575775757857579575805758157582575835758457585575865758757588575895759057591575925759357594575955759657597575985759957600576015760257603576045760557606576075760857609576105761157612576135761457615576165761757618576195762057621576225762357624576255762657627576285762957630576315763257633576345763557636576375763857639576405764157642576435764457645576465764757648576495765057651576525765357654576555765657657576585765957660576615766257663576645766557666576675766857669576705767157672576735767457675576765767757678576795768057681576825768357684576855768657687576885768957690576915769257693576945769557696576975769857699577005770157702577035770457705577065770757708577095771057711577125771357714577155771657717577185771957720577215772257723577245772557726577275772857729577305773157732577335773457735577365773757738577395774057741577425774357744577455774657747577485774957750577515775257753577545775557756577575775857759577605776157762577635776457765577665776757768577695777057771577725777357774577755777657777577785777957780577815778257783577845778557786577875778857789577905779157792577935779457795577965779757798577995780057801578025780357804578055780657807578085780957810578115781257813578145781557816578175781857819578205782157822578235782457825578265782757828578295783057831578325783357834578355783657837578385783957840578415784257843578445784557846578475784857849578505785157852578535785457855578565785757858578595786057861578625786357864578655786657867578685786957870578715787257873578745787557876578775787857879578805788157882578835788457885578865788757888578895789057891578925789357894578955789657897578985789957900579015790257903579045790557906579075790857909579105791157912579135791457915579165791757918579195792057921579225792357924579255792657927579285792957930579315793257933579345793557936579375793857939579405794157942579435794457945579465794757948579495795057951579525795357954579555795657957579585795957960579615796257963579645796557966579675796857969579705797157972579735797457975579765797757978579795798057981579825798357984579855798657987579885798957990579915799257993579945799557996579975799857999580005800158002580035800458005580065800758008580095801058011580125801358014580155801658017580185801958020580215802258023580245802558026580275802858029580305803158032580335803458035580365803758038580395804058041580425804358044580455804658047580485804958050580515805258053580545805558056580575805858059580605806158062580635806458065580665806758068580695807058071580725807358074580755807658077580785807958080580815808258083580845808558086580875808858089580905809158092580935809458095580965809758098580995810058101581025810358104581055810658107581085810958110581115811258113581145811558116581175811858119581205812158122581235812458125581265812758128581295813058131581325813358134581355813658137581385813958140581415814258143581445814558146581475814858149581505815158152581535815458155581565815758158581595816058161581625816358164581655816658167581685816958170581715817258173581745817558176581775817858179581805818158182581835818458185581865818758188581895819058191581925819358194581955819658197581985819958200582015820258203582045820558206582075820858209582105821158212582135821458215582165821758218582195822058221582225822358224582255822658227582285822958230582315823258233582345823558236582375823858239582405824158242582435824458245582465824758248582495825058251582525825358254582555825658257582585825958260582615826258263582645826558266582675826858269582705827158272582735827458275582765827758278582795828058281582825828358284582855828658287582885828958290582915829258293582945829558296582975829858299583005830158302583035830458305583065830758308583095831058311583125831358314583155831658317583185831958320583215832258323583245832558326583275832858329583305833158332583335833458335583365833758338583395834058341583425834358344583455834658347583485834958350583515835258353583545835558356583575835858359583605836158362583635836458365583665836758368583695837058371583725837358374583755837658377583785837958380583815838258383583845838558386583875838858389583905839158392583935839458395583965839758398583995840058401584025840358404584055840658407584085840958410584115841258413584145841558416584175841858419584205842158422584235842458425584265842758428584295843058431584325843358434584355843658437584385843958440584415844258443584445844558446584475844858449584505845158452584535845458455584565845758458584595846058461584625846358464584655846658467584685846958470584715847258473584745847558476584775847858479584805848158482584835848458485584865848758488584895849058491584925849358494584955849658497584985849958500585015850258503585045850558506585075850858509585105851158512585135851458515585165851758518585195852058521585225852358524585255852658527585285852958530585315853258533585345853558536585375853858539585405854158542585435854458545585465854758548585495855058551585525855358554585555855658557585585855958560585615856258563585645856558566585675856858569585705857158572585735857458575585765857758578585795858058581585825858358584585855858658587585885858958590585915859258593585945859558596585975859858599586005860158602586035860458605586065860758608586095861058611586125861358614586155861658617586185861958620586215862258623586245862558626586275862858629586305863158632586335863458635586365863758638586395864058641586425864358644586455864658647586485864958650586515865258653586545865558656586575865858659586605866158662586635866458665586665866758668586695867058671586725867358674586755867658677586785867958680586815868258683586845868558686586875868858689586905869158692586935869458695586965869758698586995870058701587025870358704587055870658707587085870958710587115871258713587145871558716587175871858719587205872158722587235872458725587265872758728587295873058731587325873358734587355873658737587385873958740587415874258743587445874558746587475874858749587505875158752587535875458755587565875758758587595876058761587625876358764587655876658767587685876958770587715877258773587745877558776587775877858779587805878158782587835878458785587865878758788587895879058791587925879358794587955879658797587985879958800588015880258803588045880558806588075880858809588105881158812588135881458815588165881758818588195882058821588225882358824588255882658827588285882958830588315883258833588345883558836588375883858839588405884158842588435884458845588465884758848588495885058851588525885358854588555885658857588585885958860588615886258863588645886558866588675886858869588705887158872588735887458875588765887758878588795888058881588825888358884588855888658887588885888958890588915889258893588945889558896588975889858899589005890158902589035890458905589065890758908589095891058911589125891358914589155891658917589185891958920589215892258923589245892558926589275892858929589305893158932589335893458935589365893758938589395894058941589425894358944589455894658947589485894958950589515895258953589545895558956589575895858959589605896158962589635896458965589665896758968589695897058971589725897358974589755897658977589785897958980589815898258983589845898558986589875898858989589905899158992589935899458995589965899758998589995900059001590025900359004590055900659007590085900959010590115901259013590145901559016590175901859019590205902159022590235902459025590265902759028590295903059031590325903359034590355903659037590385903959040590415904259043590445904559046590475904859049590505905159052590535905459055590565905759058590595906059061590625906359064590655906659067590685906959070590715907259073590745907559076590775907859079590805908159082590835908459085590865908759088590895909059091590925909359094590955909659097590985909959100591015910259103591045910559106591075910859109591105911159112591135911459115591165911759118591195912059121591225912359124591255912659127591285912959130591315913259133591345913559136591375913859139591405914159142591435914459145591465914759148591495915059151591525915359154591555915659157591585915959160591615916259163591645916559166591675916859169591705917159172591735917459175591765917759178591795918059181591825918359184591855918659187591885918959190591915919259193591945919559196591975919859199592005920159202592035920459205592065920759208592095921059211592125921359214592155921659217592185921959220592215922259223592245922559226592275922859229592305923159232592335923459235592365923759238592395924059241592425924359244592455924659247592485924959250592515925259253592545925559256592575925859259592605926159262592635926459265592665926759268592695927059271592725927359274592755927659277592785927959280592815928259283592845928559286592875928859289592905929159292592935929459295592965929759298592995930059301593025930359304593055930659307593085930959310593115931259313593145931559316593175931859319593205932159322593235932459325593265932759328593295933059331593325933359334593355933659337593385933959340593415934259343593445934559346593475934859349593505935159352593535935459355593565935759358593595936059361593625936359364593655936659367593685936959370593715937259373593745937559376593775937859379593805938159382593835938459385593865938759388593895939059391593925939359394593955939659397593985939959400594015940259403594045940559406594075940859409594105941159412594135941459415594165941759418594195942059421594225942359424594255942659427594285942959430594315943259433594345943559436594375943859439594405944159442594435944459445594465944759448594495945059451594525945359454594555945659457594585945959460594615946259463594645946559466594675946859469594705947159472594735947459475594765947759478594795948059481594825948359484594855948659487594885948959490594915949259493594945949559496594975949859499595005950159502595035950459505595065950759508595095951059511595125951359514595155951659517595185951959520595215952259523595245952559526595275952859529595305953159532595335953459535595365953759538595395954059541595425954359544595455954659547595485954959550595515955259553595545955559556595575955859559595605956159562595635956459565595665956759568595695957059571595725957359574595755957659577595785957959580595815958259583595845958559586595875958859589595905959159592595935959459595595965959759598595995960059601596025960359604596055960659607596085960959610596115961259613596145961559616596175961859619596205962159622596235962459625596265962759628596295963059631596325963359634596355963659637596385963959640596415964259643596445964559646596475964859649596505965159652596535965459655596565965759658596595966059661596625966359664596655966659667596685966959670596715967259673596745967559676596775967859679596805968159682596835968459685596865968759688596895969059691596925969359694596955969659697596985969959700597015970259703597045970559706597075970859709597105971159712597135971459715597165971759718597195972059721597225972359724597255972659727597285972959730597315973259733597345973559736597375973859739597405974159742597435974459745597465974759748597495975059751597525975359754597555975659757597585975959760597615976259763597645976559766597675976859769597705977159772597735977459775597765977759778597795978059781597825978359784597855978659787597885978959790597915979259793597945979559796597975979859799598005980159802598035980459805598065980759808598095981059811598125981359814598155981659817598185981959820598215982259823598245982559826598275982859829598305983159832598335983459835598365983759838598395984059841598425984359844598455984659847598485984959850598515985259853598545985559856598575985859859598605986159862598635986459865598665986759868598695987059871598725987359874598755987659877598785987959880598815988259883598845988559886598875988859889598905989159892598935989459895598965989759898598995990059901599025990359904599055990659907599085990959910599115991259913599145991559916599175991859919599205992159922599235992459925599265992759928599295993059931599325993359934599355993659937599385993959940599415994259943599445994559946599475994859949599505995159952599535995459955599565995759958599595996059961599625996359964599655996659967599685996959970599715997259973599745997559976599775997859979599805998159982599835998459985599865998759988599895999059991599925999359994599955999659997599985999960000600016000260003600046000560006600076000860009600106001160012600136001460015600166001760018600196002060021600226002360024600256002660027600286002960030600316003260033600346003560036600376003860039600406004160042600436004460045600466004760048600496005060051600526005360054600556005660057600586005960060600616006260063600646006560066600676006860069600706007160072600736007460075600766007760078600796008060081600826008360084600856008660087600886008960090600916009260093600946009560096600976009860099601006010160102601036010460105601066010760108601096011060111601126011360114601156011660117601186011960120601216012260123601246012560126601276012860129601306013160132601336013460135601366013760138601396014060141601426014360144601456014660147601486014960150601516015260153601546015560156601576015860159601606016160162601636016460165601666016760168601696017060171601726017360174601756017660177601786017960180601816018260183601846018560186601876018860189601906019160192601936019460195601966019760198601996020060201602026020360204602056020660207602086020960210602116021260213602146021560216602176021860219602206022160222602236022460225602266022760228602296023060231602326023360234602356023660237602386023960240602416024260243602446024560246602476024860249602506025160252602536025460255602566025760258602596026060261602626026360264602656026660267602686026960270602716027260273602746027560276602776027860279602806028160282602836028460285602866028760288602896029060291602926029360294602956029660297602986029960300603016030260303603046030560306603076030860309603106031160312603136031460315603166031760318603196032060321603226032360324603256032660327603286032960330603316033260333603346033560336603376033860339603406034160342603436034460345603466034760348603496035060351603526035360354603556035660357603586035960360603616036260363603646036560366603676036860369603706037160372603736037460375603766037760378603796038060381603826038360384603856038660387603886038960390603916039260393603946039560396603976039860399604006040160402604036040460405604066040760408604096041060411604126041360414604156041660417604186041960420604216042260423604246042560426604276042860429604306043160432604336043460435604366043760438604396044060441604426044360444604456044660447604486044960450604516045260453604546045560456604576045860459604606046160462604636046460465604666046760468604696047060471604726047360474604756047660477604786047960480604816048260483604846048560486604876048860489604906049160492604936049460495604966049760498604996050060501605026050360504605056050660507605086050960510605116051260513605146051560516605176051860519605206052160522605236052460525605266052760528605296053060531605326053360534605356053660537605386053960540605416054260543605446054560546605476054860549605506055160552605536055460555605566055760558605596056060561605626056360564605656056660567605686056960570605716057260573605746057560576605776057860579605806058160582605836058460585605866058760588605896059060591605926059360594605956059660597605986059960600606016060260603606046060560606606076060860609606106061160612606136061460615606166061760618606196062060621606226062360624606256062660627606286062960630606316063260633606346063560636606376063860639606406064160642606436064460645606466064760648606496065060651606526065360654606556065660657606586065960660606616066260663606646066560666606676066860669606706067160672606736067460675606766067760678606796068060681606826068360684606856068660687606886068960690606916069260693606946069560696606976069860699607006070160702607036070460705607066070760708607096071060711607126071360714607156071660717607186071960720607216072260723607246072560726607276072860729607306073160732607336073460735607366073760738607396074060741607426074360744607456074660747607486074960750607516075260753607546075560756607576075860759607606076160762607636076460765607666076760768607696077060771607726077360774607756077660777607786077960780607816078260783607846078560786607876078860789607906079160792607936079460795607966079760798607996080060801608026080360804608056080660807608086080960810608116081260813608146081560816608176081860819608206082160822608236082460825608266082760828608296083060831608326083360834608356083660837608386083960840608416084260843608446084560846608476084860849608506085160852608536085460855608566085760858608596086060861608626086360864608656086660867608686086960870608716087260873608746087560876608776087860879608806088160882608836088460885608866088760888608896089060891608926089360894608956089660897608986089960900609016090260903609046090560906609076090860909609106091160912609136091460915609166091760918609196092060921609226092360924609256092660927609286092960930609316093260933609346093560936609376093860939609406094160942609436094460945609466094760948609496095060951609526095360954609556095660957609586095960960609616096260963609646096560966609676096860969609706097160972609736097460975609766097760978609796098060981609826098360984609856098660987609886098960990609916099260993609946099560996609976099860999610006100161002610036100461005610066100761008610096101061011610126101361014610156101661017610186101961020610216102261023610246102561026610276102861029610306103161032610336103461035610366103761038610396104061041610426104361044610456104661047610486104961050610516105261053610546105561056610576105861059610606106161062610636106461065610666106761068610696107061071610726107361074610756107661077610786107961080610816108261083610846108561086610876108861089610906109161092610936109461095610966109761098610996110061101611026110361104611056110661107611086110961110611116111261113611146111561116611176111861119611206112161122611236112461125611266112761128611296113061131611326113361134611356113661137611386113961140611416114261143611446114561146611476114861149611506115161152611536115461155611566115761158611596116061161611626116361164611656116661167611686116961170611716117261173611746117561176611776117861179611806118161182611836118461185611866118761188611896119061191611926119361194611956119661197611986119961200612016120261203612046120561206612076120861209612106121161212612136121461215612166121761218612196122061221612226122361224612256122661227612286122961230612316123261233612346123561236612376123861239612406124161242612436124461245612466124761248612496125061251612526125361254612556125661257612586125961260612616126261263612646126561266612676126861269612706127161272612736127461275612766127761278612796128061281612826128361284612856128661287612886128961290612916129261293612946129561296612976129861299613006130161302613036130461305613066130761308613096131061311613126131361314613156131661317613186131961320613216132261323613246132561326613276132861329613306133161332613336133461335613366133761338613396134061341613426134361344613456134661347613486134961350613516135261353613546135561356613576135861359613606136161362613636136461365613666136761368613696137061371613726137361374613756137661377613786137961380613816138261383613846138561386613876138861389613906139161392613936139461395613966139761398613996140061401614026140361404614056140661407614086140961410614116141261413614146141561416614176141861419614206142161422614236142461425614266142761428614296143061431614326143361434614356143661437614386143961440614416144261443614446144561446614476144861449614506145161452614536145461455614566145761458614596146061461614626146361464614656146661467614686146961470614716147261473614746147561476614776147861479614806148161482614836148461485614866148761488614896149061491614926149361494614956149661497614986149961500615016150261503615046150561506615076150861509615106151161512615136151461515615166151761518615196152061521615226152361524615256152661527615286152961530615316153261533615346153561536615376153861539615406154161542615436154461545615466154761548615496155061551615526155361554615556155661557615586155961560615616156261563615646156561566615676156861569615706157161572615736157461575615766157761578615796158061581615826158361584615856158661587615886158961590615916159261593615946159561596615976159861599616006160161602616036160461605616066160761608616096161061611616126161361614616156161661617616186161961620616216162261623616246162561626616276162861629616306163161632616336163461635616366163761638616396164061641616426164361644616456164661647616486164961650616516165261653616546165561656616576165861659616606166161662616636166461665616666166761668616696167061671616726167361674616756167661677616786167961680616816168261683616846168561686616876168861689616906169161692616936169461695616966169761698616996170061701617026170361704617056170661707617086170961710617116171261713617146171561716617176171861719617206172161722617236172461725617266172761728617296173061731617326173361734617356173661737617386173961740617416174261743617446174561746617476174861749617506175161752617536175461755617566175761758617596176061761617626176361764617656176661767617686176961770617716177261773617746177561776617776177861779617806178161782617836178461785617866178761788617896179061791617926179361794617956179661797617986179961800618016180261803618046180561806618076180861809618106181161812618136181461815618166181761818618196182061821618226182361824618256182661827618286182961830618316183261833618346183561836618376183861839618406184161842618436184461845618466184761848618496185061851618526185361854618556185661857618586185961860618616186261863618646186561866618676186861869618706187161872618736187461875618766187761878618796188061881618826188361884618856188661887618886188961890618916189261893618946189561896618976189861899619006190161902619036190461905619066190761908619096191061911619126191361914619156191661917619186191961920619216192261923619246192561926619276192861929619306193161932619336193461935619366193761938619396194061941619426194361944619456194661947619486194961950619516195261953619546195561956619576195861959619606196161962619636196461965619666196761968619696197061971619726197361974619756197661977619786197961980619816198261983619846198561986619876198861989619906199161992619936199461995619966199761998619996200062001620026200362004620056200662007620086200962010620116201262013620146201562016620176201862019620206202162022620236202462025620266202762028620296203062031620326203362034620356203662037620386203962040620416204262043620446204562046620476204862049620506205162052620536205462055620566205762058620596206062061620626206362064620656206662067620686206962070620716207262073620746207562076620776207862079620806208162082620836208462085620866208762088620896209062091620926209362094620956209662097620986209962100621016210262103621046210562106621076210862109621106211162112621136211462115621166211762118621196212062121621226212362124621256212662127621286212962130621316213262133621346213562136621376213862139621406214162142621436214462145621466214762148621496215062151621526215362154621556215662157621586215962160621616216262163621646216562166621676216862169621706217162172621736217462175621766217762178621796218062181621826218362184621856218662187621886218962190621916219262193621946219562196621976219862199622006220162202622036220462205622066220762208622096221062211622126221362214622156221662217622186221962220622216222262223622246222562226622276222862229622306223162232622336223462235622366223762238622396224062241622426224362244622456224662247622486224962250622516225262253622546225562256622576225862259622606226162262622636226462265622666226762268622696227062271622726227362274622756227662277622786227962280622816228262283622846228562286622876228862289622906229162292622936229462295622966229762298622996230062301623026230362304623056230662307623086230962310623116231262313623146231562316623176231862319623206232162322623236232462325623266232762328623296233062331623326233362334623356233662337623386233962340623416234262343623446234562346623476234862349623506235162352623536235462355623566235762358623596236062361623626236362364623656236662367623686236962370623716237262373623746237562376623776237862379623806238162382623836238462385623866238762388623896239062391623926239362394623956239662397623986239962400624016240262403624046240562406624076240862409624106241162412624136241462415624166241762418624196242062421624226242362424624256242662427624286242962430624316243262433624346243562436624376243862439624406244162442624436244462445624466244762448624496245062451624526245362454624556245662457624586245962460624616246262463624646246562466624676246862469624706247162472624736247462475624766247762478624796248062481624826248362484624856248662487624886248962490624916249262493624946249562496624976249862499625006250162502625036250462505625066250762508625096251062511625126251362514625156251662517625186251962520625216252262523625246252562526625276252862529625306253162532625336253462535625366253762538625396254062541625426254362544625456254662547625486254962550625516255262553625546255562556625576255862559625606256162562625636256462565625666256762568625696257062571625726257362574625756257662577625786257962580625816258262583625846258562586625876258862589625906259162592625936259462595625966259762598625996260062601626026260362604626056260662607626086260962610626116261262613626146261562616626176261862619626206262162622626236262462625626266262762628626296263062631626326263362634626356263662637626386263962640626416264262643626446264562646626476264862649626506265162652626536265462655626566265762658626596266062661626626266362664626656266662667626686266962670626716267262673626746267562676626776267862679626806268162682626836268462685626866268762688626896269062691626926269362694626956269662697626986269962700627016270262703627046270562706627076270862709627106271162712627136271462715627166271762718627196272062721627226272362724627256272662727627286272962730627316273262733627346273562736627376273862739627406274162742627436274462745627466274762748627496275062751627526275362754627556275662757627586275962760627616276262763627646276562766627676276862769627706277162772627736277462775627766277762778627796278062781627826278362784627856278662787627886278962790627916279262793627946279562796627976279862799628006280162802628036280462805628066280762808628096281062811628126281362814628156281662817628186281962820628216282262823628246282562826628276282862829628306283162832628336283462835628366283762838628396284062841628426284362844628456284662847628486284962850628516285262853628546285562856628576285862859628606286162862628636286462865628666286762868628696287062871628726287362874628756287662877628786287962880628816288262883628846288562886628876288862889628906289162892628936289462895628966289762898628996290062901629026290362904629056290662907629086290962910629116291262913629146291562916629176291862919629206292162922629236292462925629266292762928629296293062931629326293362934629356293662937629386293962940629416294262943629446294562946629476294862949629506295162952629536295462955629566295762958629596296062961629626296362964629656296662967629686296962970629716297262973629746297562976629776297862979629806298162982629836298462985629866298762988629896299062991629926299362994629956299662997629986299963000630016300263003630046300563006630076300863009630106301163012630136301463015630166301763018630196302063021630226302363024630256302663027630286302963030630316303263033630346303563036630376303863039630406304163042630436304463045630466304763048630496305063051630526305363054630556305663057630586305963060630616306263063630646306563066630676306863069630706307163072630736307463075630766307763078630796308063081630826308363084630856308663087630886308963090630916309263093630946309563096630976309863099631006310163102631036310463105631066310763108631096311063111631126311363114631156311663117631186311963120631216312263123631246312563126631276312863129631306313163132631336313463135631366313763138631396314063141631426314363144631456314663147631486314963150631516315263153631546315563156631576315863159631606316163162631636316463165631666316763168631696317063171631726317363174631756317663177631786317963180631816318263183631846318563186631876318863189631906319163192631936319463195631966319763198631996320063201632026320363204632056320663207632086320963210632116321263213632146321563216632176321863219632206322163222632236322463225632266322763228632296323063231632326323363234632356323663237632386323963240632416324263243632446324563246632476324863249632506325163252632536325463255632566325763258632596326063261632626326363264632656326663267632686326963270632716327263273632746327563276632776327863279632806328163282632836328463285632866328763288632896329063291632926329363294632956329663297632986329963300633016330263303633046330563306633076330863309633106331163312633136331463315633166331763318633196332063321633226332363324633256332663327633286332963330633316333263333633346333563336633376333863339633406334163342633436334463345633466334763348633496335063351633526335363354633556335663357633586335963360633616336263363633646336563366633676336863369633706337163372633736337463375633766337763378633796338063381633826338363384633856338663387633886338963390633916339263393633946339563396633976339863399634006340163402634036340463405634066340763408634096341063411634126341363414634156341663417634186341963420634216342263423634246342563426634276342863429634306343163432634336343463435634366343763438634396344063441634426344363444634456344663447634486344963450634516345263453634546345563456634576345863459634606346163462634636346463465634666346763468634696347063471634726347363474634756347663477634786347963480634816348263483634846348563486634876348863489634906349163492634936349463495634966349763498634996350063501635026350363504635056350663507635086350963510635116351263513635146351563516635176351863519635206352163522635236352463525635266352763528635296353063531635326353363534635356353663537635386353963540635416354263543635446354563546635476354863549635506355163552635536355463555635566355763558635596356063561635626356363564635656356663567635686356963570635716357263573635746357563576635776357863579635806358163582635836358463585635866358763588635896359063591635926359363594635956359663597635986359963600636016360263603636046360563606636076360863609636106361163612636136361463615636166361763618636196362063621636226362363624636256362663627636286362963630636316363263633636346363563636636376363863639636406364163642636436364463645636466364763648636496365063651636526365363654636556365663657636586365963660636616366263663636646366563666636676366863669636706367163672636736367463675636766367763678636796368063681636826368363684636856368663687636886368963690636916369263693636946369563696636976369863699637006370163702637036370463705637066370763708637096371063711637126371363714637156371663717637186371963720637216372263723637246372563726637276372863729637306373163732637336373463735637366373763738637396374063741637426374363744637456374663747637486374963750637516375263753637546375563756637576375863759637606376163762637636376463765637666376763768637696377063771637726377363774637756377663777637786377963780637816378263783637846378563786637876378863789637906379163792637936379463795637966379763798637996380063801638026380363804638056380663807638086380963810638116381263813638146381563816638176381863819638206382163822638236382463825638266382763828638296383063831638326383363834638356383663837638386383963840638416384263843638446384563846638476384863849638506385163852638536385463855638566385763858638596386063861638626386363864638656386663867638686386963870638716387263873638746387563876638776387863879638806388163882638836388463885638866388763888638896389063891638926389363894638956389663897638986389963900639016390263903639046390563906639076390863909639106391163912639136391463915639166391763918639196392063921639226392363924639256392663927639286392963930639316393263933639346393563936639376393863939639406394163942639436394463945639466394763948639496395063951639526395363954639556395663957639586395963960639616396263963639646396563966639676396863969639706397163972639736397463975639766397763978639796398063981639826398363984639856398663987639886398963990639916399263993639946399563996639976399863999640006400164002640036400464005640066400764008640096401064011640126401364014640156401664017640186401964020640216402264023640246402564026640276402864029640306403164032640336403464035640366403764038640396404064041640426404364044640456404664047640486404964050640516405264053640546405564056640576405864059640606406164062640636406464065640666406764068640696407064071640726407364074640756407664077640786407964080640816408264083640846408564086640876408864089640906409164092640936409464095640966409764098640996410064101641026410364104641056410664107641086410964110641116411264113641146411564116641176411864119641206412164122641236412464125641266412764128641296413064131641326413364134641356413664137641386413964140641416414264143641446414564146641476414864149641506415164152641536415464155641566415764158641596416064161641626416364164641656416664167641686416964170641716417264173641746417564176641776417864179641806418164182641836418464185641866418764188641896419064191641926419364194641956419664197641986419964200642016420264203642046420564206642076420864209642106421164212642136421464215642166421764218642196422064221642226422364224642256422664227642286422964230642316423264233642346423564236642376423864239642406424164242642436424464245642466424764248642496425064251642526425364254642556425664257642586425964260642616426264263642646426564266642676426864269642706427164272642736427464275642766427764278642796428064281642826428364284642856428664287642886428964290642916429264293642946429564296642976429864299643006430164302643036430464305643066430764308643096431064311643126431364314643156431664317643186431964320643216432264323643246432564326643276432864329643306433164332643336433464335643366433764338643396434064341643426434364344643456434664347643486434964350643516435264353643546435564356643576435864359643606436164362643636436464365643666436764368643696437064371643726437364374643756437664377643786437964380643816438264383643846438564386643876438864389643906439164392643936439464395643966439764398643996440064401644026440364404644056440664407644086440964410644116441264413644146441564416644176441864419644206442164422644236442464425644266442764428644296443064431644326443364434644356443664437644386443964440644416444264443644446444564446644476444864449644506445164452644536445464455644566445764458644596446064461644626446364464644656446664467644686446964470644716447264473644746447564476644776447864479644806448164482644836448464485644866448764488644896449064491644926449364494644956449664497644986449964500645016450264503645046450564506645076450864509645106451164512645136451464515645166451764518645196452064521645226452364524645256452664527645286452964530645316453264533645346453564536645376453864539645406454164542645436454464545645466454764548645496455064551645526455364554645556455664557645586455964560645616456264563645646456564566645676456864569645706457164572645736457464575645766457764578645796458064581645826458364584645856458664587645886458964590645916459264593645946459564596645976459864599646006460164602646036460464605646066460764608646096461064611646126461364614646156461664617646186461964620646216462264623646246462564626646276462864629646306463164632646336463464635646366463764638646396464064641646426464364644646456464664647646486464964650646516465264653646546465564656646576465864659646606466164662646636466464665646666466764668646696467064671646726467364674646756467664677646786467964680646816468264683646846468564686646876468864689646906469164692646936469464695646966469764698646996470064701647026470364704647056470664707647086470964710647116471264713647146471564716647176471864719647206472164722647236472464725647266472764728647296473064731647326473364734647356473664737647386473964740647416474264743647446474564746647476474864749647506475164752647536475464755647566475764758647596476064761647626476364764647656476664767647686476964770647716477264773647746477564776647776477864779647806478164782647836478464785647866478764788647896479064791647926479364794647956479664797647986479964800648016480264803648046480564806648076480864809648106481164812648136481464815648166481764818648196482064821648226482364824648256482664827648286482964830648316483264833648346483564836648376483864839648406484164842648436484464845648466484764848648496485064851648526485364854648556485664857648586485964860648616486264863648646486564866648676486864869648706487164872648736487464875648766487764878648796488064881648826488364884648856488664887648886488964890648916489264893648946489564896648976489864899649006490164902649036490464905649066490764908649096491064911649126491364914649156491664917649186491964920649216492264923649246492564926649276492864929649306493164932649336493464935649366493764938649396494064941649426494364944649456494664947649486494964950649516495264953649546495564956649576495864959649606496164962649636496464965649666496764968649696497064971649726497364974649756497664977649786497964980649816498264983649846498564986649876498864989649906499164992649936499464995649966499764998649996500065001650026500365004650056500665007650086500965010650116501265013650146501565016650176501865019650206502165022650236502465025650266502765028650296503065031650326503365034650356503665037650386503965040650416504265043650446504565046650476504865049650506505165052650536505465055650566505765058650596506065061650626506365064650656506665067650686506965070650716507265073650746507565076650776507865079650806508165082650836508465085650866508765088650896509065091650926509365094650956509665097650986509965100651016510265103651046510565106651076510865109651106511165112651136511465115651166511765118651196512065121651226512365124651256512665127651286512965130651316513265133651346513565136651376513865139651406514165142651436514465145651466514765148651496515065151651526515365154651556515665157651586515965160651616516265163651646516565166651676516865169651706517165172651736517465175651766517765178651796518065181651826518365184651856518665187651886518965190651916519265193651946519565196651976519865199652006520165202652036520465205652066520765208652096521065211652126521365214652156521665217652186521965220652216522265223652246522565226652276522865229652306523165232652336523465235652366523765238652396524065241652426524365244652456524665247652486524965250652516525265253652546525565256652576525865259652606526165262652636526465265652666526765268652696527065271652726527365274652756527665277652786527965280652816528265283652846528565286652876528865289652906529165292652936529465295652966529765298652996530065301653026530365304653056530665307653086530965310653116531265313653146531565316653176531865319653206532165322653236532465325653266532765328653296533065331653326533365334653356533665337653386533965340653416534265343653446534565346653476534865349653506535165352653536535465355653566535765358653596536065361653626536365364653656536665367653686536965370653716537265373653746537565376653776537865379653806538165382653836538465385653866538765388653896539065391653926539365394653956539665397653986539965400654016540265403654046540565406654076540865409654106541165412654136541465415654166541765418654196542065421654226542365424654256542665427654286542965430654316543265433654346543565436654376543865439654406544165442654436544465445654466544765448654496545065451654526545365454654556545665457654586545965460654616546265463654646546565466654676546865469654706547165472654736547465475654766547765478654796548065481654826548365484654856548665487654886548965490654916549265493654946549565496654976549865499655006550165502655036550465505655066550765508655096551065511655126551365514655156551665517655186551965520655216552265523655246552565526655276552865529655306553165532655336553465535655366553765538655396554065541655426554365544655456554665547655486554965550655516555265553655546555565556655576555865559655606556165562655636556465565655666556765568655696557065571655726557365574655756557665577655786557965580655816558265583655846558565586655876558865589655906559165592655936559465595655966559765598655996560065601656026560365604656056560665607656086560965610656116561265613656146561565616656176561865619656206562165622656236562465625656266562765628656296563065631656326563365634656356563665637656386563965640656416564265643656446564565646656476564865649656506565165652656536565465655656566565765658656596566065661656626566365664656656566665667656686566965670656716567265673656746567565676656776567865679656806568165682656836568465685656866568765688656896569065691656926569365694656956569665697656986569965700657016570265703657046570565706657076570865709657106571165712657136571465715657166571765718657196572065721657226572365724657256572665727657286572965730657316573265733657346573565736657376573865739657406574165742657436574465745657466574765748657496575065751657526575365754657556575665757657586575965760657616576265763657646576565766657676576865769657706577165772657736577465775657766577765778657796578065781657826578365784657856578665787657886578965790657916579265793657946579565796657976579865799658006580165802658036580465805658066580765808658096581065811658126581365814658156581665817658186581965820658216582265823658246582565826658276582865829658306583165832658336583465835658366583765838658396584065841658426584365844658456584665847658486584965850658516585265853658546585565856658576585865859658606586165862658636586465865658666586765868658696587065871658726587365874658756587665877658786587965880658816588265883658846588565886658876588865889658906589165892658936589465895658966589765898658996590065901659026590365904659056590665907659086590965910659116591265913659146591565916659176591865919659206592165922659236592465925659266592765928659296593065931659326593365934659356593665937659386593965940659416594265943659446594565946659476594865949659506595165952659536595465955659566595765958659596596065961659626596365964659656596665967659686596965970659716597265973659746597565976659776597865979659806598165982659836598465985659866598765988659896599065991659926599365994659956599665997659986599966000660016600266003660046600566006660076600866009660106601166012660136601466015660166601766018660196602066021660226602366024660256602666027660286602966030660316603266033660346603566036660376603866039660406604166042660436604466045660466604766048660496605066051660526605366054660556605666057660586605966060660616606266063660646606566066660676606866069660706607166072660736607466075660766607766078660796608066081660826608366084660856608666087660886608966090660916609266093660946609566096660976609866099661006610166102661036610466105661066610766108661096611066111661126611366114661156611666117661186611966120661216612266123661246612566126661276612866129661306613166132661336613466135661366613766138661396614066141661426614366144661456614666147661486614966150661516615266153661546615566156661576615866159661606616166162661636616466165661666616766168661696617066171661726617366174661756617666177661786617966180661816618266183661846618566186661876618866189661906619166192661936619466195661966619766198661996620066201662026620366204662056620666207662086620966210662116621266213662146621566216662176621866219662206622166222662236622466225662266622766228662296623066231662326623366234662356623666237662386623966240662416624266243662446624566246662476624866249662506625166252662536625466255662566625766258662596626066261662626626366264662656626666267662686626966270662716627266273662746627566276662776627866279662806628166282662836628466285662866628766288662896629066291662926629366294662956629666297662986629966300663016630266303663046630566306663076630866309663106631166312663136631466315663166631766318663196632066321663226632366324663256632666327663286632966330663316633266333663346633566336663376633866339663406634166342663436634466345663466634766348663496635066351663526635366354663556635666357663586635966360663616636266363663646636566366663676636866369663706637166372663736637466375663766637766378663796638066381663826638366384663856638666387663886638966390663916639266393663946639566396663976639866399664006640166402664036640466405664066640766408664096641066411664126641366414664156641666417664186641966420664216642266423664246642566426664276642866429664306643166432664336643466435664366643766438664396644066441664426644366444664456644666447664486644966450664516645266453664546645566456664576645866459664606646166462664636646466465664666646766468664696647066471664726647366474664756647666477664786647966480664816648266483664846648566486664876648866489664906649166492664936649466495664966649766498664996650066501665026650366504665056650666507665086650966510665116651266513665146651566516665176651866519665206652166522665236652466525665266652766528665296653066531665326653366534665356653666537665386653966540665416654266543665446654566546665476654866549665506655166552665536655466555665566655766558665596656066561665626656366564665656656666567665686656966570665716657266573665746657566576665776657866579665806658166582665836658466585665866658766588665896659066591665926659366594665956659666597665986659966600666016660266603666046660566606666076660866609666106661166612666136661466615666166661766618666196662066621666226662366624666256662666627666286662966630666316663266633666346663566636666376663866639666406664166642666436664466645666466664766648666496665066651666526665366654666556665666657666586665966660666616666266663666646666566666666676666866669666706667166672666736667466675666766667766678666796668066681666826668366684666856668666687666886668966690666916669266693666946669566696666976669866699667006670166702667036670466705667066670766708667096671066711667126671366714667156671666717667186671966720667216672266723667246672566726667276672866729667306673166732667336673466735667366673766738667396674066741667426674366744667456674666747667486674966750667516675266753667546675566756667576675866759667606676166762667636676466765667666676766768667696677066771667726677366774667756677666777667786677966780667816678266783667846678566786667876678866789667906679166792667936679466795667966679766798667996680066801668026680366804668056680666807668086680966810668116681266813668146681566816668176681866819668206682166822668236682466825668266682766828668296683066831668326683366834668356683666837668386683966840668416684266843668446684566846668476684866849668506685166852668536685466855668566685766858668596686066861668626686366864668656686666867668686686966870668716687266873668746687566876668776687866879668806688166882668836688466885668866688766888668896689066891668926689366894668956689666897668986689966900669016690266903669046690566906669076690866909669106691166912669136691466915669166691766918669196692066921669226692366924669256692666927669286692966930669316693266933669346693566936669376693866939669406694166942669436694466945669466694766948669496695066951669526695366954669556695666957669586695966960669616696266963669646696566966669676696866969669706697166972669736697466975669766697766978669796698066981669826698366984669856698666987669886698966990669916699266993669946699566996669976699866999670006700167002670036700467005670066700767008670096701067011670126701367014670156701667017670186701967020670216702267023670246702567026670276702867029670306703167032670336703467035670366703767038670396704067041670426704367044670456704667047670486704967050670516705267053670546705567056670576705867059670606706167062670636706467065670666706767068670696707067071670726707367074670756707667077670786707967080670816708267083670846708567086670876708867089670906709167092670936709467095670966709767098670996710067101671026710367104671056710667107671086710967110671116711267113671146711567116671176711867119671206712167122671236712467125671266712767128671296713067131671326713367134671356713667137671386713967140671416714267143671446714567146671476714867149671506715167152671536715467155671566715767158671596716067161671626716367164671656716667167671686716967170671716717267173671746717567176671776717867179671806718167182671836718467185671866718767188671896719067191671926719367194671956719667197671986719967200672016720267203672046720567206672076720867209672106721167212672136721467215672166721767218672196722067221672226722367224672256722667227672286722967230672316723267233672346723567236672376723867239672406724167242672436724467245672466724767248672496725067251672526725367254672556725667257672586725967260672616726267263672646726567266672676726867269672706727167272672736727467275672766727767278672796728067281672826728367284672856728667287672886728967290672916729267293672946729567296672976729867299673006730167302673036730467305673066730767308673096731067311673126731367314673156731667317673186731967320673216732267323673246732567326673276732867329673306733167332673336733467335673366733767338673396734067341673426734367344673456734667347673486734967350673516735267353673546735567356673576735867359673606736167362673636736467365673666736767368673696737067371673726737367374673756737667377673786737967380673816738267383673846738567386673876738867389673906739167392673936739467395673966739767398673996740067401674026740367404674056740667407674086740967410674116741267413674146741567416674176741867419674206742167422674236742467425674266742767428674296743067431674326743367434674356743667437674386743967440674416744267443674446744567446674476744867449674506745167452674536745467455674566745767458674596746067461674626746367464674656746667467674686746967470674716747267473674746747567476674776747867479674806748167482674836748467485674866748767488674896749067491674926749367494674956749667497674986749967500675016750267503675046750567506675076750867509675106751167512675136751467515675166751767518675196752067521675226752367524675256752667527675286752967530675316753267533675346753567536675376753867539675406754167542675436754467545675466754767548675496755067551675526755367554675556755667557675586755967560675616756267563675646756567566675676756867569675706757167572675736757467575675766757767578675796758067581675826758367584675856758667587675886758967590675916759267593675946759567596675976759867599676006760167602676036760467605676066760767608676096761067611676126761367614676156761667617676186761967620676216762267623676246762567626676276762867629676306763167632676336763467635676366763767638676396764067641676426764367644676456764667647676486764967650676516765267653676546765567656676576765867659676606766167662676636766467665676666766767668676696767067671676726767367674676756767667677676786767967680676816768267683676846768567686676876768867689676906769167692676936769467695676966769767698676996770067701677026770367704677056770667707677086770967710677116771267713677146771567716677176771867719677206772167722677236772467725677266772767728677296773067731677326773367734677356773667737677386773967740677416774267743677446774567746677476774867749677506775167752677536775467755677566775767758677596776067761677626776367764677656776667767677686776967770677716777267773677746777567776677776777867779677806778167782677836778467785677866778767788677896779067791677926779367794677956779667797677986779967800678016780267803678046780567806678076780867809678106781167812678136781467815678166781767818678196782067821678226782367824678256782667827678286782967830678316783267833678346783567836678376783867839678406784167842678436784467845678466784767848678496785067851678526785367854678556785667857678586785967860678616786267863678646786567866678676786867869678706787167872678736787467875678766787767878678796788067881678826788367884678856788667887678886788967890678916789267893678946789567896678976789867899679006790167902679036790467905679066790767908679096791067911679126791367914679156791667917679186791967920679216792267923679246792567926679276792867929679306793167932679336793467935679366793767938679396794067941679426794367944679456794667947679486794967950679516795267953679546795567956679576795867959679606796167962679636796467965679666796767968679696797067971679726797367974679756797667977679786797967980679816798267983679846798567986679876798867989679906799167992679936799467995679966799767998679996800068001680026800368004680056800668007680086800968010680116801268013680146801568016680176801868019680206802168022680236802468025680266802768028680296803068031680326803368034680356803668037680386803968040680416804268043680446804568046680476804868049680506805168052680536805468055680566805768058680596806068061680626806368064680656806668067680686806968070680716807268073680746807568076680776807868079680806808168082680836808468085680866808768088680896809068091680926809368094680956809668097680986809968100681016810268103681046810568106681076810868109681106811168112681136811468115681166811768118681196812068121681226812368124681256812668127681286812968130681316813268133681346813568136681376813868139681406814168142681436814468145681466814768148681496815068151681526815368154681556815668157681586815968160681616816268163681646816568166681676816868169681706817168172681736817468175681766817768178681796818068181681826818368184681856818668187681886818968190681916819268193681946819568196681976819868199682006820168202682036820468205682066820768208682096821068211682126821368214682156821668217682186821968220682216822268223682246822568226682276822868229682306823168232682336823468235682366823768238682396824068241682426824368244682456824668247682486824968250682516825268253682546825568256682576825868259682606826168262682636826468265682666826768268682696827068271682726827368274682756827668277682786827968280682816828268283682846828568286682876828868289682906829168292682936829468295682966829768298682996830068301683026830368304683056830668307683086830968310683116831268313683146831568316683176831868319683206832168322683236832468325683266832768328683296833068331683326833368334683356833668337683386833968340683416834268343683446834568346683476834868349683506835168352683536835468355683566835768358683596836068361683626836368364683656836668367683686836968370683716837268373683746837568376683776837868379683806838168382683836838468385683866838768388683896839068391683926839368394683956839668397683986839968400684016840268403684046840568406684076840868409684106841168412684136841468415684166841768418684196842068421684226842368424684256842668427684286842968430684316843268433684346843568436684376843868439684406844168442684436844468445684466844768448684496845068451684526845368454684556845668457684586845968460684616846268463684646846568466684676846868469684706847168472684736847468475684766847768478684796848068481684826848368484684856848668487684886848968490684916849268493684946849568496684976849868499685006850168502685036850468505685066850768508685096851068511685126851368514685156851668517685186851968520685216852268523685246852568526685276852868529685306853168532685336853468535685366853768538685396854068541685426854368544685456854668547685486854968550685516855268553685546855568556685576855868559685606856168562685636856468565685666856768568685696857068571685726857368574685756857668577685786857968580685816858268583685846858568586685876858868589685906859168592685936859468595685966859768598685996860068601686026860368604686056860668607686086860968610686116861268613686146861568616686176861868619686206862168622686236862468625686266862768628686296863068631686326863368634686356863668637686386863968640686416864268643686446864568646686476864868649686506865168652686536865468655686566865768658686596866068661686626866368664686656866668667686686866968670686716867268673686746867568676686776867868679686806868168682686836868468685686866868768688686896869068691686926869368694686956869668697686986869968700687016870268703687046870568706687076870868709687106871168712687136871468715687166871768718687196872068721687226872368724687256872668727687286872968730687316873268733687346873568736687376873868739687406874168742687436874468745687466874768748687496875068751687526875368754687556875668757687586875968760687616876268763687646876568766687676876868769687706877168772687736877468775687766877768778687796878068781687826878368784687856878668787687886878968790687916879268793687946879568796687976879868799688006880168802688036880468805688066880768808688096881068811688126881368814688156881668817688186881968820688216882268823688246882568826688276882868829688306883168832688336883468835688366883768838688396884068841688426884368844688456884668847688486884968850688516885268853688546885568856688576885868859688606886168862688636886468865688666886768868688696887068871688726887368874688756887668877688786887968880688816888268883688846888568886688876888868889688906889168892688936889468895688966889768898688996890068901689026890368904689056890668907689086890968910689116891268913689146891568916689176891868919689206892168922689236892468925689266892768928689296893068931689326893368934689356893668937689386893968940689416894268943689446894568946689476894868949689506895168952689536895468955689566895768958689596896068961689626896368964689656896668967689686896968970689716897268973689746897568976689776897868979689806898168982689836898468985689866898768988689896899068991689926899368994689956899668997689986899969000690016900269003690046900569006690076900869009690106901169012690136901469015690166901769018690196902069021690226902369024690256902669027690286902969030690316903269033690346903569036690376903869039690406904169042690436904469045690466904769048690496905069051690526905369054690556905669057690586905969060690616906269063690646906569066690676906869069690706907169072690736907469075690766907769078690796908069081690826908369084690856908669087690886908969090690916909269093690946909569096690976909869099691006910169102691036910469105691066910769108691096911069111691126911369114691156911669117691186911969120691216912269123691246912569126691276912869129691306913169132691336913469135691366913769138691396914069141691426914369144691456914669147691486914969150691516915269153691546915569156691576915869159691606916169162691636916469165691666916769168691696917069171691726917369174691756917669177691786917969180691816918269183691846918569186691876918869189691906919169192691936919469195691966919769198691996920069201692026920369204692056920669207692086920969210692116921269213692146921569216692176921869219692206922169222692236922469225692266922769228692296923069231692326923369234692356923669237692386923969240692416924269243692446924569246692476924869249692506925169252692536925469255692566925769258692596926069261692626926369264692656926669267692686926969270692716927269273692746927569276692776927869279692806928169282692836928469285692866928769288692896929069291692926929369294692956929669297692986929969300693016930269303693046930569306693076930869309693106931169312693136931469315693166931769318693196932069321693226932369324693256932669327693286932969330693316933269333693346933569336693376933869339693406934169342693436934469345693466934769348693496935069351693526935369354693556935669357693586935969360693616936269363693646936569366693676936869369693706937169372693736937469375693766937769378693796938069381693826938369384693856938669387693886938969390693916939269393693946939569396693976939869399694006940169402694036940469405694066940769408694096941069411694126941369414694156941669417694186941969420694216942269423694246942569426694276942869429694306943169432694336943469435694366943769438694396944069441694426944369444694456944669447694486944969450694516945269453694546945569456694576945869459694606946169462694636946469465694666946769468694696947069471694726947369474694756947669477694786947969480694816948269483694846948569486694876948869489694906949169492694936949469495694966949769498694996950069501695026950369504695056950669507695086950969510695116951269513695146951569516695176951869519695206952169522695236952469525695266952769528695296953069531695326953369534695356953669537695386953969540695416954269543695446954569546695476954869549695506955169552695536955469555695566955769558695596956069561695626956369564695656956669567695686956969570695716957269573695746957569576695776957869579695806958169582695836958469585695866958769588695896959069591695926959369594695956959669597695986959969600696016960269603696046960569606696076960869609696106961169612696136961469615696166961769618696196962069621696226962369624696256962669627696286962969630696316963269633696346963569636696376963869639696406964169642696436964469645696466964769648696496965069651696526965369654696556965669657696586965969660696616966269663696646966569666696676966869669696706967169672696736967469675696766967769678696796968069681696826968369684696856968669687696886968969690696916969269693696946969569696696976969869699697006970169702697036970469705697066970769708697096971069711697126971369714697156971669717697186971969720697216972269723697246972569726697276972869729697306973169732697336973469735697366973769738697396974069741697426974369744697456974669747697486974969750697516975269753697546975569756697576975869759697606976169762697636976469765697666976769768697696977069771697726977369774697756977669777697786977969780697816978269783697846978569786697876978869789697906979169792697936979469795697966979769798697996980069801698026980369804698056980669807698086980969810698116981269813698146981569816698176981869819698206982169822698236982469825698266982769828698296983069831698326983369834698356983669837698386983969840698416984269843698446984569846698476984869849698506985169852698536985469855698566985769858698596986069861698626986369864698656986669867698686986969870698716987269873698746987569876698776987869879698806988169882698836988469885698866988769888698896989069891698926989369894698956989669897698986989969900699016990269903699046990569906699076990869909699106991169912699136991469915699166991769918699196992069921699226992369924699256992669927699286992969930699316993269933699346993569936699376993869939699406994169942699436994469945699466994769948699496995069951699526995369954699556995669957699586995969960699616996269963699646996569966699676996869969699706997169972699736997469975699766997769978699796998069981699826998369984699856998669987699886998969990699916999269993699946999569996699976999869999700007000170002700037000470005700067000770008700097001070011700127001370014700157001670017700187001970020700217002270023700247002570026700277002870029700307003170032700337003470035700367003770038700397004070041700427004370044700457004670047700487004970050700517005270053700547005570056700577005870059700607006170062700637006470065700667006770068700697007070071700727007370074700757007670077700787007970080700817008270083700847008570086700877008870089700907009170092700937009470095700967009770098700997010070101701027010370104701057010670107701087010970110701117011270113701147011570116701177011870119701207012170122701237012470125701267012770128701297013070131701327013370134701357013670137701387013970140701417014270143701447014570146701477014870149701507015170152701537015470155701567015770158701597016070161701627016370164701657016670167701687016970170701717017270173701747017570176701777017870179701807018170182701837018470185701867018770188701897019070191701927019370194701957019670197701987019970200702017020270203702047020570206702077020870209702107021170212702137021470215702167021770218702197022070221702227022370224702257022670227702287022970230702317023270233702347023570236702377023870239702407024170242702437024470245702467024770248702497025070251702527025370254702557025670257702587025970260702617026270263702647026570266702677026870269702707027170272702737027470275702767027770278702797028070281702827028370284702857028670287702887028970290702917029270293702947029570296702977029870299703007030170302703037030470305703067030770308703097031070311703127031370314703157031670317703187031970320703217032270323703247032570326703277032870329703307033170332703337033470335703367033770338703397034070341703427034370344703457034670347703487034970350703517035270353703547035570356703577035870359703607036170362703637036470365703667036770368703697037070371703727037370374703757037670377703787037970380703817038270383703847038570386703877038870389703907039170392703937039470395703967039770398703997040070401704027040370404704057040670407704087040970410704117041270413704147041570416704177041870419704207042170422704237042470425704267042770428704297043070431704327043370434704357043670437704387043970440704417044270443704447044570446704477044870449704507045170452704537045470455704567045770458704597046070461704627046370464704657046670467704687046970470704717047270473704747047570476704777047870479704807048170482704837048470485704867048770488704897049070491704927049370494704957049670497704987049970500705017050270503705047050570506705077050870509705107051170512705137051470515705167051770518705197052070521705227052370524705257052670527705287052970530705317053270533705347053570536705377053870539705407054170542705437054470545705467054770548705497055070551705527055370554705557055670557705587055970560705617056270563705647056570566705677056870569705707057170572705737057470575705767057770578705797058070581705827058370584705857058670587705887058970590705917059270593705947059570596705977059870599706007060170602706037060470605706067060770608706097061070611706127061370614706157061670617706187061970620706217062270623706247062570626706277062870629706307063170632706337063470635706367063770638706397064070641706427064370644706457064670647706487064970650706517065270653706547065570656706577065870659706607066170662706637066470665706667066770668706697067070671706727067370674706757067670677706787067970680706817068270683706847068570686706877068870689706907069170692706937069470695706967069770698706997070070701707027070370704707057070670707707087070970710707117071270713707147071570716707177071870719707207072170722707237072470725707267072770728707297073070731707327073370734707357073670737707387073970740707417074270743707447074570746707477074870749707507075170752707537075470755707567075770758707597076070761707627076370764707657076670767707687076970770707717077270773707747077570776707777077870779707807078170782707837078470785707867078770788707897079070791707927079370794707957079670797707987079970800708017080270803708047080570806708077080870809708107081170812708137081470815708167081770818708197082070821708227082370824708257082670827708287082970830708317083270833708347083570836708377083870839708407084170842708437084470845708467084770848708497085070851708527085370854708557085670857708587085970860708617086270863708647086570866708677086870869708707087170872708737087470875708767087770878708797088070881708827088370884708857088670887708887088970890708917089270893708947089570896708977089870899709007090170902709037090470905709067090770908709097091070911709127091370914709157091670917709187091970920709217092270923709247092570926709277092870929709307093170932709337093470935709367093770938709397094070941709427094370944709457094670947709487094970950709517095270953709547095570956709577095870959709607096170962709637096470965709667096770968709697097070971709727097370974709757097670977709787097970980709817098270983709847098570986709877098870989709907099170992709937099470995709967099770998709997100071001710027100371004710057100671007710087100971010710117101271013710147101571016710177101871019710207102171022710237102471025710267102771028710297103071031710327103371034710357103671037710387103971040710417104271043710447104571046710477104871049710507105171052710537105471055710567105771058710597106071061710627106371064710657106671067710687106971070710717107271073710747107571076710777107871079710807108171082710837108471085710867108771088710897109071091710927109371094710957109671097710987109971100711017110271103711047110571106711077110871109711107111171112711137111471115711167111771118711197112071121711227112371124711257112671127711287112971130711317113271133711347113571136711377113871139711407114171142711437114471145711467114771148711497115071151711527115371154711557115671157711587115971160711617116271163711647116571166711677116871169711707117171172711737117471175711767117771178711797118071181711827118371184711857118671187711887118971190711917119271193711947119571196711977119871199712007120171202712037120471205712067120771208712097121071211712127121371214712157121671217712187121971220712217122271223712247122571226712277122871229712307123171232712337123471235712367123771238712397124071241712427124371244712457124671247712487124971250712517125271253712547125571256712577125871259712607126171262712637126471265712667126771268712697127071271712727127371274712757127671277712787127971280712817128271283712847128571286712877128871289712907129171292712937129471295712967129771298712997130071301713027130371304713057130671307713087130971310713117131271313713147131571316713177131871319713207132171322713237132471325713267132771328713297133071331713327133371334713357133671337713387133971340713417134271343713447134571346713477134871349713507135171352713537135471355713567135771358713597136071361713627136371364713657136671367713687136971370713717137271373713747137571376713777137871379713807138171382713837138471385713867138771388713897139071391713927139371394713957139671397713987139971400714017140271403714047140571406714077140871409714107141171412714137141471415714167141771418714197142071421714227142371424714257142671427714287142971430714317143271433714347143571436714377143871439714407144171442714437144471445714467144771448714497145071451714527145371454714557145671457714587145971460714617146271463714647146571466714677146871469714707147171472714737147471475714767147771478714797148071481714827148371484714857148671487714887148971490714917149271493714947149571496714977149871499715007150171502715037150471505715067150771508715097151071511715127151371514715157151671517715187151971520715217152271523715247152571526715277152871529715307153171532715337153471535715367153771538715397154071541715427154371544715457154671547715487154971550715517155271553715547155571556715577155871559715607156171562715637156471565715667156771568715697157071571715727157371574715757157671577715787157971580715817158271583715847158571586715877158871589715907159171592715937159471595715967159771598715997160071601716027160371604716057160671607716087160971610716117161271613716147161571616716177161871619716207162171622716237162471625716267162771628716297163071631716327163371634716357163671637716387163971640716417164271643716447164571646716477164871649716507165171652716537165471655716567165771658716597166071661716627166371664716657166671667716687166971670716717167271673716747167571676716777167871679716807168171682716837168471685716867168771688716897169071691716927169371694716957169671697716987169971700717017170271703717047170571706717077170871709717107171171712717137171471715717167171771718717197172071721717227172371724717257172671727717287172971730717317173271733717347173571736717377173871739717407174171742717437174471745717467174771748717497175071751717527175371754717557175671757717587175971760717617176271763717647176571766717677176871769717707177171772717737177471775717767177771778717797178071781717827178371784717857178671787717887178971790717917179271793717947179571796717977179871799718007180171802718037180471805718067180771808718097181071811718127181371814718157181671817718187181971820718217182271823718247182571826718277182871829718307183171832718337183471835718367183771838718397184071841718427184371844718457184671847718487184971850718517185271853718547185571856718577185871859718607186171862718637186471865718667186771868718697187071871718727187371874718757187671877718787187971880718817188271883718847188571886718877188871889718907189171892718937189471895718967189771898718997190071901719027190371904719057190671907719087190971910719117191271913719147191571916719177191871919719207192171922719237192471925719267192771928719297193071931719327193371934719357193671937719387193971940719417194271943719447194571946719477194871949719507195171952719537195471955719567195771958719597196071961719627196371964719657196671967719687196971970719717197271973719747197571976719777197871979719807198171982719837198471985719867198771988719897199071991719927199371994719957199671997719987199972000720017200272003720047200572006720077200872009720107201172012720137201472015720167201772018720197202072021720227202372024720257202672027720287202972030720317203272033720347203572036720377203872039720407204172042720437204472045720467204772048720497205072051720527205372054720557205672057720587205972060720617206272063720647206572066720677206872069720707207172072720737207472075720767207772078720797208072081720827208372084720857208672087720887208972090720917209272093720947209572096720977209872099721007210172102721037210472105721067210772108721097211072111721127211372114721157211672117721187211972120721217212272123721247212572126721277212872129721307213172132721337213472135721367213772138721397214072141721427214372144721457214672147721487214972150721517215272153721547215572156721577215872159721607216172162721637216472165721667216772168721697217072171721727217372174721757217672177721787217972180721817218272183721847218572186721877218872189721907219172192721937219472195721967219772198721997220072201722027220372204722057220672207722087220972210722117221272213722147221572216722177221872219722207222172222722237222472225722267222772228722297223072231722327223372234722357223672237722387223972240722417224272243722447224572246722477224872249722507225172252722537225472255722567225772258722597226072261722627226372264722657226672267722687226972270722717227272273722747227572276722777227872279722807228172282722837228472285722867228772288722897229072291722927229372294722957229672297722987229972300723017230272303723047230572306723077230872309723107231172312723137231472315723167231772318723197232072321723227232372324723257232672327723287232972330723317233272333723347233572336723377233872339723407234172342723437234472345723467234772348723497235072351723527235372354723557235672357723587235972360723617236272363723647236572366723677236872369723707237172372723737237472375723767237772378723797238072381723827238372384723857238672387723887238972390723917239272393723947239572396723977239872399724007240172402724037240472405724067240772408724097241072411724127241372414724157241672417724187241972420724217242272423724247242572426724277242872429724307243172432724337243472435724367243772438724397244072441724427244372444724457244672447724487244972450724517245272453724547245572456724577245872459724607246172462724637246472465724667246772468724697247072471724727247372474724757247672477724787247972480724817248272483724847248572486724877248872489724907249172492724937249472495724967249772498724997250072501725027250372504725057250672507725087250972510725117251272513725147251572516725177251872519725207252172522725237252472525725267252772528725297253072531725327253372534725357253672537725387253972540725417254272543725447254572546725477254872549725507255172552725537255472555725567255772558725597256072561725627256372564725657256672567725687256972570725717257272573725747257572576725777257872579725807258172582725837258472585725867258772588725897259072591725927259372594725957259672597725987259972600726017260272603726047260572606726077260872609726107261172612726137261472615726167261772618726197262072621726227262372624726257262672627726287262972630726317263272633726347263572636726377263872639726407264172642726437264472645726467264772648726497265072651726527265372654726557265672657726587265972660726617266272663726647266572666726677266872669726707267172672726737267472675726767267772678726797268072681726827268372684726857268672687726887268972690726917269272693726947269572696726977269872699727007270172702727037270472705727067270772708727097271072711727127271372714727157271672717727187271972720727217272272723727247272572726727277272872729727307273172732727337273472735727367273772738727397274072741727427274372744727457274672747727487274972750727517275272753727547275572756727577275872759727607276172762727637276472765727667276772768727697277072771727727277372774727757277672777727787277972780727817278272783727847278572786727877278872789727907279172792727937279472795727967279772798727997280072801728027280372804728057280672807728087280972810728117281272813728147281572816728177281872819728207282172822728237282472825728267282772828728297283072831728327283372834728357283672837728387283972840728417284272843728447284572846728477284872849728507285172852728537285472855728567285772858728597286072861728627286372864728657286672867728687286972870728717287272873728747287572876728777287872879728807288172882728837288472885728867288772888728897289072891728927289372894728957289672897728987289972900729017290272903729047290572906729077290872909729107291172912729137291472915729167291772918729197292072921729227292372924729257292672927729287292972930729317293272933729347293572936729377293872939729407294172942729437294472945729467294772948729497295072951729527295372954729557295672957729587295972960729617296272963729647296572966729677296872969729707297172972729737297472975729767297772978729797298072981729827298372984729857298672987729887298972990729917299272993729947299572996729977299872999730007300173002730037300473005730067300773008730097301073011730127301373014730157301673017730187301973020730217302273023730247302573026730277302873029730307303173032730337303473035730367303773038730397304073041730427304373044730457304673047730487304973050730517305273053730547305573056730577305873059730607306173062730637306473065730667306773068730697307073071730727307373074730757307673077730787307973080730817308273083730847308573086730877308873089730907309173092730937309473095730967309773098730997310073101731027310373104731057310673107731087310973110731117311273113731147311573116731177311873119731207312173122731237312473125731267312773128731297313073131731327313373134731357313673137731387313973140731417314273143731447314573146731477314873149731507315173152731537315473155731567315773158731597316073161731627316373164731657316673167731687316973170731717317273173731747317573176731777317873179731807318173182731837318473185731867318773188731897319073191731927319373194731957319673197731987319973200732017320273203732047320573206732077320873209732107321173212732137321473215732167321773218732197322073221732227322373224732257322673227732287322973230732317323273233732347323573236732377323873239732407324173242732437324473245732467324773248732497325073251732527325373254732557325673257732587325973260732617326273263732647326573266732677326873269732707327173272732737327473275732767327773278732797328073281732827328373284732857328673287732887328973290732917329273293732947329573296732977329873299733007330173302733037330473305733067330773308733097331073311733127331373314733157331673317733187331973320733217332273323733247332573326733277332873329733307333173332733337333473335733367333773338733397334073341733427334373344733457334673347733487334973350733517335273353733547335573356733577335873359733607336173362733637336473365733667336773368733697337073371733727337373374733757337673377733787337973380733817338273383733847338573386733877338873389733907339173392733937339473395733967339773398733997340073401734027340373404734057340673407734087340973410734117341273413734147341573416734177341873419734207342173422734237342473425734267342773428734297343073431734327343373434734357343673437734387343973440734417344273443734447344573446734477344873449734507345173452734537345473455734567345773458734597346073461734627346373464734657346673467734687346973470734717347273473734747347573476734777347873479734807348173482734837348473485734867348773488734897349073491734927349373494734957349673497734987349973500735017350273503735047350573506735077350873509735107351173512735137351473515735167351773518735197352073521735227352373524735257352673527735287352973530735317353273533735347353573536735377353873539735407354173542735437354473545735467354773548735497355073551735527355373554735557355673557735587355973560735617356273563735647356573566735677356873569735707357173572735737357473575735767357773578735797358073581735827358373584735857358673587735887358973590735917359273593735947359573596735977359873599736007360173602736037360473605736067360773608736097361073611736127361373614736157361673617736187361973620736217362273623736247362573626736277362873629736307363173632736337363473635736367363773638736397364073641736427364373644736457364673647736487364973650736517365273653736547365573656736577365873659736607366173662736637366473665736667366773668736697367073671736727367373674736757367673677736787367973680736817368273683736847368573686736877368873689736907369173692736937369473695736967369773698736997370073701737027370373704737057370673707737087370973710737117371273713737147371573716737177371873719737207372173722737237372473725737267372773728737297373073731737327373373734737357373673737737387373973740737417374273743737447374573746737477374873749737507375173752737537375473755737567375773758737597376073761737627376373764737657376673767737687376973770737717377273773737747377573776737777377873779737807378173782737837378473785737867378773788737897379073791737927379373794737957379673797737987379973800738017380273803738047380573806738077380873809738107381173812738137381473815738167381773818738197382073821738227382373824738257382673827738287382973830738317383273833738347383573836738377383873839738407384173842738437384473845738467384773848738497385073851738527385373854738557385673857738587385973860738617386273863738647386573866738677386873869738707387173872738737387473875738767387773878738797388073881738827388373884738857388673887738887388973890738917389273893738947389573896738977389873899739007390173902739037390473905739067390773908739097391073911739127391373914739157391673917739187391973920739217392273923739247392573926739277392873929739307393173932739337393473935739367393773938739397394073941739427394373944739457394673947739487394973950739517395273953739547395573956739577395873959739607396173962739637396473965739667396773968739697397073971739727397373974739757397673977739787397973980739817398273983739847398573986739877398873989739907399173992739937399473995739967399773998739997400074001740027400374004740057400674007740087400974010740117401274013740147401574016740177401874019740207402174022740237402474025740267402774028740297403074031740327403374034740357403674037740387403974040740417404274043740447404574046740477404874049740507405174052740537405474055740567405774058740597406074061740627406374064740657406674067740687406974070740717407274073740747407574076740777407874079740807408174082740837408474085740867408774088740897409074091740927409374094740957409674097740987409974100741017410274103741047410574106741077410874109741107411174112741137411474115741167411774118741197412074121741227412374124741257412674127741287412974130741317413274133741347413574136741377413874139741407414174142741437414474145741467414774148741497415074151741527415374154741557415674157741587415974160741617416274163741647416574166741677416874169741707417174172741737417474175741767417774178741797418074181741827418374184741857418674187741887418974190741917419274193741947419574196741977419874199742007420174202742037420474205742067420774208742097421074211742127421374214742157421674217742187421974220742217422274223742247422574226742277422874229742307423174232742337423474235742367423774238742397424074241742427424374244742457424674247742487424974250742517425274253742547425574256742577425874259742607426174262742637426474265742667426774268742697427074271742727427374274742757427674277742787427974280742817428274283742847428574286742877428874289742907429174292742937429474295742967429774298742997430074301743027430374304743057430674307743087430974310743117431274313743147431574316743177431874319743207432174322743237432474325743267432774328743297433074331743327433374334743357433674337743387433974340743417434274343743447434574346743477434874349743507435174352743537435474355743567435774358743597436074361743627436374364743657436674367743687436974370743717437274373743747437574376743777437874379743807438174382743837438474385743867438774388743897439074391743927439374394743957439674397743987439974400744017440274403744047440574406744077440874409744107441174412744137441474415744167441774418744197442074421744227442374424744257442674427744287442974430744317443274433744347443574436744377443874439744407444174442744437444474445744467444774448744497445074451744527445374454744557445674457744587445974460744617446274463744647446574466744677446874469744707447174472744737447474475744767447774478744797448074481744827448374484744857448674487744887448974490744917449274493744947449574496744977449874499745007450174502745037450474505745067450774508745097451074511745127451374514745157451674517745187451974520745217452274523745247452574526745277452874529745307453174532745337453474535745367453774538745397454074541745427454374544745457454674547745487454974550745517455274553745547455574556745577455874559745607456174562745637456474565745667456774568745697457074571745727457374574745757457674577745787457974580745817458274583745847458574586745877458874589745907459174592745937459474595745967459774598745997460074601746027460374604746057460674607746087460974610746117461274613746147461574616746177461874619746207462174622746237462474625746267462774628746297463074631746327463374634746357463674637746387463974640746417464274643746447464574646746477464874649746507465174652746537465474655746567465774658746597466074661746627466374664746657466674667746687466974670746717467274673746747467574676746777467874679746807468174682746837468474685746867468774688746897469074691746927469374694746957469674697746987469974700747017470274703747047470574706747077470874709747107471174712747137471474715747167471774718747197472074721747227472374724747257472674727747287472974730747317473274733747347473574736747377473874739747407474174742747437474474745747467474774748747497475074751747527475374754747557475674757747587475974760747617476274763747647476574766747677476874769747707477174772747737477474775747767477774778747797478074781747827478374784747857478674787747887478974790747917479274793747947479574796747977479874799748007480174802748037480474805748067480774808748097481074811748127481374814748157481674817748187481974820748217482274823748247482574826748277482874829748307483174832748337483474835748367483774838748397484074841748427484374844748457484674847748487484974850748517485274853748547485574856748577485874859748607486174862748637486474865748667486774868748697487074871748727487374874748757487674877748787487974880748817488274883748847488574886748877488874889748907489174892748937489474895748967489774898748997490074901749027490374904749057490674907749087490974910749117491274913749147491574916749177491874919749207492174922749237492474925749267492774928749297493074931749327493374934749357493674937749387493974940749417494274943749447494574946749477494874949749507495174952749537495474955749567495774958749597496074961749627496374964749657496674967749687496974970749717497274973749747497574976749777497874979749807498174982749837498474985749867498774988749897499074991749927499374994749957499674997749987499975000750017500275003750047500575006750077500875009750107501175012750137501475015750167501775018750197502075021750227502375024750257502675027750287502975030750317503275033750347503575036750377503875039750407504175042750437504475045750467504775048750497505075051750527505375054750557505675057750587505975060750617506275063750647506575066750677506875069750707507175072750737507475075750767507775078750797508075081750827508375084750857508675087750887508975090750917509275093750947509575096750977509875099751007510175102751037510475105751067510775108751097511075111751127511375114751157511675117751187511975120751217512275123751247512575126751277512875129751307513175132751337513475135751367513775138751397514075141751427514375144751457514675147751487514975150751517515275153751547515575156751577515875159751607516175162751637516475165751667516775168751697517075171751727517375174751757517675177751787517975180751817518275183751847518575186751877518875189751907519175192751937519475195751967519775198751997520075201752027520375204752057520675207752087520975210752117521275213752147521575216752177521875219752207522175222752237522475225752267522775228752297523075231752327523375234752357523675237752387523975240752417524275243752447524575246752477524875249752507525175252752537525475255752567525775258752597526075261752627526375264752657526675267752687526975270752717527275273752747527575276752777527875279752807528175282752837528475285752867528775288752897529075291752927529375294752957529675297752987529975300753017530275303753047530575306753077530875309753107531175312753137531475315753167531775318753197532075321753227532375324753257532675327753287532975330753317533275333753347533575336753377533875339753407534175342753437534475345753467534775348753497535075351753527535375354753557535675357753587535975360753617536275363753647536575366753677536875369753707537175372753737537475375753767537775378753797538075381753827538375384753857538675387753887538975390753917539275393753947539575396753977539875399754007540175402754037540475405754067540775408754097541075411754127541375414754157541675417754187541975420754217542275423754247542575426754277542875429754307543175432754337543475435754367543775438754397544075441754427544375444754457544675447754487544975450754517545275453754547545575456754577545875459754607546175462754637546475465754667546775468754697547075471754727547375474754757547675477754787547975480754817548275483754847548575486754877548875489754907549175492754937549475495754967549775498754997550075501755027550375504755057550675507755087550975510755117551275513755147551575516755177551875519755207552175522755237552475525755267552775528755297553075531755327553375534755357553675537755387553975540755417554275543755447554575546755477554875549755507555175552755537555475555755567555775558755597556075561755627556375564755657556675567755687556975570755717557275573755747557575576755777557875579755807558175582755837558475585755867558775588755897559075591755927559375594755957559675597755987559975600756017560275603756047560575606756077560875609756107561175612756137561475615756167561775618756197562075621756227562375624756257562675627756287562975630756317563275633756347563575636756377563875639756407564175642756437564475645756467564775648756497565075651756527565375654756557565675657756587565975660756617566275663756647566575666756677566875669756707567175672756737567475675756767567775678756797568075681756827568375684756857568675687756887568975690756917569275693756947569575696756977569875699757007570175702757037570475705757067570775708757097571075711757127571375714757157571675717757187571975720757217572275723757247572575726757277572875729757307573175732757337573475735757367573775738757397574075741757427574375744757457574675747757487574975750757517575275753757547575575756757577575875759757607576175762757637576475765757667576775768757697577075771757727577375774757757577675777757787577975780757817578275783757847578575786757877578875789757907579175792757937579475795757967579775798757997580075801758027580375804758057580675807758087580975810758117581275813758147581575816758177581875819758207582175822758237582475825758267582775828758297583075831758327583375834758357583675837758387583975840758417584275843758447584575846758477584875849758507585175852758537585475855758567585775858758597586075861758627586375864758657586675867758687586975870758717587275873758747587575876758777587875879758807588175882758837588475885758867588775888758897589075891758927589375894758957589675897758987589975900759017590275903759047590575906759077590875909759107591175912759137591475915759167591775918759197592075921759227592375924759257592675927759287592975930759317593275933759347593575936759377593875939759407594175942759437594475945759467594775948759497595075951759527595375954759557595675957759587595975960759617596275963759647596575966759677596875969759707597175972759737597475975759767597775978759797598075981759827598375984759857598675987759887598975990759917599275993759947599575996759977599875999760007600176002760037600476005760067600776008760097601076011760127601376014760157601676017760187601976020760217602276023760247602576026760277602876029760307603176032760337603476035760367603776038760397604076041760427604376044760457604676047760487604976050760517605276053760547605576056760577605876059760607606176062760637606476065760667606776068760697607076071760727607376074760757607676077760787607976080760817608276083760847608576086760877608876089760907609176092760937609476095760967609776098760997610076101761027610376104761057610676107761087610976110761117611276113761147611576116761177611876119761207612176122761237612476125761267612776128761297613076131761327613376134761357613676137761387613976140761417614276143761447614576146761477614876149761507615176152761537615476155761567615776158761597616076161761627616376164761657616676167761687616976170761717617276173761747617576176761777617876179761807618176182761837618476185761867618776188761897619076191761927619376194761957619676197761987619976200762017620276203762047620576206762077620876209762107621176212762137621476215762167621776218762197622076221762227622376224762257622676227762287622976230762317623276233762347623576236762377623876239762407624176242762437624476245762467624776248762497625076251762527625376254762557625676257762587625976260762617626276263762647626576266762677626876269762707627176272762737627476275762767627776278762797628076281762827628376284762857628676287762887628976290762917629276293762947629576296762977629876299763007630176302763037630476305763067630776308763097631076311763127631376314763157631676317763187631976320763217632276323763247632576326763277632876329763307633176332763337633476335763367633776338763397634076341763427634376344763457634676347763487634976350763517635276353763547635576356763577635876359763607636176362763637636476365763667636776368763697637076371763727637376374763757637676377763787637976380763817638276383763847638576386763877638876389763907639176392763937639476395763967639776398763997640076401764027640376404764057640676407764087640976410764117641276413764147641576416764177641876419764207642176422764237642476425764267642776428764297643076431764327643376434764357643676437764387643976440764417644276443764447644576446764477644876449764507645176452764537645476455764567645776458764597646076461764627646376464764657646676467764687646976470764717647276473764747647576476764777647876479764807648176482764837648476485764867648776488764897649076491764927649376494764957649676497764987649976500765017650276503765047650576506765077650876509765107651176512765137651476515765167651776518765197652076521765227652376524765257652676527765287652976530765317653276533765347653576536765377653876539765407654176542765437654476545765467654776548765497655076551765527655376554765557655676557765587655976560765617656276563765647656576566765677656876569765707657176572765737657476575765767657776578765797658076581765827658376584765857658676587765887658976590765917659276593765947659576596765977659876599766007660176602766037660476605766067660776608766097661076611766127661376614766157661676617766187661976620766217662276623766247662576626766277662876629766307663176632766337663476635766367663776638766397664076641766427664376644766457664676647766487664976650766517665276653766547665576656766577665876659766607666176662766637666476665766667666776668766697667076671766727667376674766757667676677766787667976680766817668276683766847668576686766877668876689766907669176692766937669476695766967669776698766997670076701767027670376704767057670676707767087670976710767117671276713767147671576716767177671876719767207672176722767237672476725767267672776728767297673076731767327673376734767357673676737767387673976740767417674276743767447674576746767477674876749767507675176752767537675476755767567675776758767597676076761767627676376764767657676676767767687676976770767717677276773767747677576776767777677876779767807678176782767837678476785767867678776788767897679076791767927679376794767957679676797767987679976800768017680276803768047680576806768077680876809768107681176812768137681476815768167681776818768197682076821768227682376824768257682676827768287682976830768317683276833768347683576836768377683876839768407684176842768437684476845768467684776848768497685076851768527685376854768557685676857768587685976860768617686276863768647686576866768677686876869768707687176872768737687476875768767687776878768797688076881768827688376884768857688676887768887688976890768917689276893768947689576896768977689876899769007690176902769037690476905769067690776908769097691076911769127691376914769157691676917769187691976920769217692276923769247692576926769277692876929769307693176932769337693476935769367693776938769397694076941769427694376944769457694676947769487694976950769517695276953769547695576956769577695876959769607696176962769637696476965769667696776968769697697076971769727697376974769757697676977769787697976980769817698276983769847698576986769877698876989769907699176992769937699476995769967699776998769997700077001770027700377004770057700677007770087700977010770117701277013770147701577016770177701877019770207702177022770237702477025770267702777028770297703077031770327703377034770357703677037770387703977040770417704277043770447704577046770477704877049770507705177052770537705477055770567705777058770597706077061770627706377064770657706677067770687706977070770717707277073770747707577076770777707877079770807708177082770837708477085770867708777088770897709077091770927709377094770957709677097770987709977100771017710277103771047710577106771077710877109771107711177112771137711477115771167711777118771197712077121771227712377124771257712677127771287712977130771317713277133771347713577136771377713877139771407714177142771437714477145771467714777148771497715077151771527715377154771557715677157771587715977160771617716277163771647716577166771677716877169771707717177172771737717477175771767717777178771797718077181771827718377184771857718677187771887718977190771917719277193771947719577196771977719877199772007720177202772037720477205772067720777208772097721077211772127721377214772157721677217772187721977220772217722277223772247722577226772277722877229772307723177232772337723477235772367723777238772397724077241772427724377244772457724677247772487724977250772517725277253772547725577256772577725877259772607726177262772637726477265772667726777268772697727077271772727727377274772757727677277772787727977280772817728277283772847728577286772877728877289772907729177292772937729477295772967729777298772997730077301773027730377304773057730677307773087730977310773117731277313773147731577316773177731877319773207732177322773237732477325773267732777328773297733077331773327733377334773357733677337773387733977340773417734277343773447734577346773477734877349773507735177352773537735477355773567735777358773597736077361773627736377364773657736677367773687736977370773717737277373773747737577376773777737877379773807738177382773837738477385773867738777388773897739077391773927739377394773957739677397773987739977400774017740277403774047740577406774077740877409774107741177412774137741477415774167741777418774197742077421774227742377424774257742677427774287742977430774317743277433774347743577436774377743877439774407744177442774437744477445774467744777448774497745077451774527745377454774557745677457774587745977460774617746277463774647746577466774677746877469774707747177472774737747477475774767747777478774797748077481774827748377484774857748677487774887748977490774917749277493774947749577496774977749877499775007750177502775037750477505775067750777508775097751077511775127751377514775157751677517775187751977520775217752277523775247752577526775277752877529775307753177532775337753477535775367753777538775397754077541775427754377544775457754677547775487754977550775517755277553775547755577556775577755877559775607756177562775637756477565775667756777568775697757077571775727757377574775757757677577775787757977580775817758277583775847758577586775877758877589775907759177592775937759477595775967759777598775997760077601776027760377604776057760677607776087760977610776117761277613776147761577616776177761877619776207762177622776237762477625776267762777628776297763077631776327763377634776357763677637776387763977640776417764277643776447764577646776477764877649776507765177652776537765477655776567765777658776597766077661776627766377664776657766677667776687766977670776717767277673776747767577676776777767877679776807768177682776837768477685776867768777688776897769077691776927769377694776957769677697776987769977700777017770277703777047770577706777077770877709777107771177712777137771477715777167771777718777197772077721777227772377724777257772677727777287772977730777317773277733777347773577736777377773877739777407774177742777437774477745777467774777748777497775077751777527775377754777557775677757777587775977760777617776277763777647776577766777677776877769777707777177772777737777477775777767777777778777797778077781777827778377784777857778677787777887778977790777917779277793777947779577796777977779877799778007780177802778037780477805778067780777808778097781077811778127781377814778157781677817778187781977820778217782277823778247782577826778277782877829778307783177832778337783477835778367783777838778397784077841778427784377844778457784677847778487784977850778517785277853778547785577856778577785877859778607786177862778637786477865778667786777868778697787077871778727787377874778757787677877778787787977880778817788277883778847788577886778877788877889778907789177892778937789477895778967789777898778997790077901779027790377904779057790677907779087790977910779117791277913779147791577916779177791877919779207792177922779237792477925779267792777928779297793077931779327793377934779357793677937779387793977940779417794277943779447794577946779477794877949779507795177952779537795477955779567795777958779597796077961779627796377964779657796677967779687796977970779717797277973779747797577976779777797877979779807798177982779837798477985779867798777988779897799077991779927799377994779957799677997779987799978000780017800278003780047800578006780077800878009780107801178012780137801478015780167801778018780197802078021780227802378024780257802678027780287802978030780317803278033780347803578036780377803878039780407804178042780437804478045780467804778048780497805078051780527805378054780557805678057780587805978060780617806278063780647806578066780677806878069780707807178072780737807478075780767807778078780797808078081780827808378084780857808678087780887808978090780917809278093780947809578096780977809878099781007810178102781037810478105781067810778108781097811078111781127811378114781157811678117781187811978120781217812278123781247812578126781277812878129781307813178132781337813478135781367813778138781397814078141781427814378144781457814678147781487814978150781517815278153781547815578156781577815878159781607816178162781637816478165781667816778168781697817078171781727817378174781757817678177781787817978180781817818278183781847818578186781877818878189781907819178192781937819478195781967819778198781997820078201782027820378204782057820678207782087820978210782117821278213782147821578216782177821878219782207822178222782237822478225782267822778228782297823078231782327823378234782357823678237782387823978240782417824278243782447824578246782477824878249782507825178252782537825478255782567825778258782597826078261782627826378264782657826678267782687826978270782717827278273782747827578276782777827878279782807828178282782837828478285782867828778288782897829078291782927829378294782957829678297782987829978300783017830278303783047830578306783077830878309783107831178312783137831478315783167831778318783197832078321783227832378324783257832678327783287832978330783317833278333783347833578336783377833878339783407834178342783437834478345783467834778348783497835078351783527835378354783557835678357783587835978360783617836278363783647836578366783677836878369783707837178372783737837478375783767837778378783797838078381783827838378384783857838678387783887838978390783917839278393783947839578396783977839878399784007840178402784037840478405784067840778408784097841078411784127841378414784157841678417784187841978420784217842278423784247842578426784277842878429784307843178432784337843478435784367843778438784397844078441784427844378444784457844678447784487844978450784517845278453784547845578456784577845878459784607846178462784637846478465784667846778468784697847078471784727847378474784757847678477784787847978480784817848278483784847848578486784877848878489784907849178492784937849478495784967849778498784997850078501785027850378504785057850678507785087850978510785117851278513785147851578516785177851878519785207852178522785237852478525785267852778528785297853078531785327853378534785357853678537785387853978540785417854278543785447854578546785477854878549785507855178552785537855478555785567855778558785597856078561785627856378564785657856678567785687856978570785717857278573785747857578576785777857878579785807858178582785837858478585785867858778588785897859078591785927859378594785957859678597785987859978600786017860278603786047860578606786077860878609786107861178612786137861478615786167861778618786197862078621786227862378624786257862678627786287862978630786317863278633786347863578636786377863878639786407864178642786437864478645786467864778648786497865078651786527865378654786557865678657786587865978660786617866278663786647866578666786677866878669786707867178672786737867478675786767867778678786797868078681786827868378684786857868678687786887868978690786917869278693786947869578696786977869878699787007870178702787037870478705787067870778708787097871078711787127871378714787157871678717787187871978720787217872278723787247872578726787277872878729787307873178732787337873478735787367873778738787397874078741787427874378744787457874678747787487874978750787517875278753787547875578756787577875878759787607876178762787637876478765787667876778768787697877078771787727877378774787757877678777787787877978780787817878278783787847878578786787877878878789787907879178792787937879478795787967879778798787997880078801788027880378804788057880678807788087880978810788117881278813788147881578816788177881878819788207882178822788237882478825788267882778828788297883078831788327883378834788357883678837788387883978840788417884278843788447884578846788477884878849788507885178852788537885478855788567885778858788597886078861788627886378864788657886678867788687886978870788717887278873788747887578876788777887878879788807888178882788837888478885788867888778888788897889078891788927889378894788957889678897788987889978900789017890278903789047890578906789077890878909789107891178912789137891478915789167891778918789197892078921789227892378924789257892678927789287892978930789317893278933789347893578936789377893878939789407894178942789437894478945789467894778948789497895078951789527895378954789557895678957789587895978960789617896278963789647896578966789677896878969789707897178972789737897478975789767897778978789797898078981789827898378984789857898678987789887898978990789917899278993789947899578996789977899878999790007900179002790037900479005790067900779008790097901079011790127901379014790157901679017790187901979020790217902279023790247902579026790277902879029790307903179032790337903479035790367903779038790397904079041790427904379044790457904679047790487904979050790517905279053790547905579056790577905879059790607906179062790637906479065790667906779068790697907079071790727907379074790757907679077790787907979080790817908279083790847908579086790877908879089790907909179092790937909479095790967909779098790997910079101791027910379104791057910679107791087910979110791117911279113791147911579116791177911879119791207912179122791237912479125791267912779128791297913079131791327913379134791357913679137791387913979140791417914279143791447914579146791477914879149791507915179152791537915479155791567915779158791597916079161791627916379164791657916679167791687916979170791717917279173791747917579176791777917879179791807918179182791837918479185791867918779188791897919079191791927919379194791957919679197791987919979200792017920279203792047920579206792077920879209792107921179212792137921479215792167921779218792197922079221792227922379224792257922679227792287922979230792317923279233792347923579236792377923879239792407924179242792437924479245792467924779248792497925079251792527925379254792557925679257792587925979260792617926279263792647926579266792677926879269792707927179272792737927479275792767927779278792797928079281792827928379284792857928679287792887928979290792917929279293792947929579296792977929879299793007930179302793037930479305793067930779308793097931079311793127931379314793157931679317793187931979320793217932279323793247932579326793277932879329793307933179332793337933479335793367933779338793397934079341793427934379344793457934679347793487934979350793517935279353793547935579356793577935879359793607936179362793637936479365793667936779368793697937079371793727937379374793757937679377793787937979380793817938279383793847938579386793877938879389793907939179392793937939479395793967939779398793997940079401794027940379404794057940679407794087940979410794117941279413794147941579416794177941879419794207942179422794237942479425794267942779428794297943079431794327943379434794357943679437794387943979440794417944279443794447944579446794477944879449794507945179452794537945479455794567945779458794597946079461794627946379464794657946679467794687946979470794717947279473794747947579476794777947879479794807948179482794837948479485794867948779488794897949079491794927949379494794957949679497794987949979500795017950279503795047950579506795077950879509795107951179512795137951479515795167951779518795197952079521795227952379524795257952679527795287952979530795317953279533795347953579536795377953879539795407954179542795437954479545795467954779548795497955079551795527955379554795557955679557795587955979560795617956279563795647956579566795677956879569795707957179572795737957479575795767957779578795797958079581795827958379584795857958679587795887958979590795917959279593795947959579596795977959879599796007960179602796037960479605796067960779608796097961079611796127961379614796157961679617796187961979620796217962279623796247962579626796277962879629796307963179632796337963479635796367963779638796397964079641796427964379644796457964679647796487964979650796517965279653796547965579656796577965879659796607966179662796637966479665796667966779668796697967079671796727967379674796757967679677796787967979680796817968279683796847968579686796877968879689796907969179692796937969479695796967969779698796997970079701797027970379704797057970679707797087970979710797117971279713797147971579716797177971879719797207972179722797237972479725797267972779728797297973079731797327973379734797357973679737797387973979740797417974279743797447974579746797477974879749797507975179752797537975479755797567975779758797597976079761797627976379764797657976679767797687976979770797717977279773797747977579776797777977879779797807978179782797837978479785797867978779788797897979079791797927979379794797957979679797797987979979800798017980279803798047980579806798077980879809798107981179812798137981479815798167981779818798197982079821798227982379824798257982679827798287982979830798317983279833798347983579836798377983879839798407984179842798437984479845798467984779848798497985079851798527985379854798557985679857798587985979860798617986279863798647986579866798677986879869798707987179872798737987479875798767987779878798797988079881798827988379884798857988679887798887988979890798917989279893798947989579896798977989879899799007990179902799037990479905799067990779908799097991079911799127991379914799157991679917799187991979920799217992279923799247992579926799277992879929799307993179932799337993479935799367993779938799397994079941799427994379944799457994679947799487994979950799517995279953799547995579956799577995879959799607996179962799637996479965799667996779968799697997079971799727997379974799757997679977799787997979980799817998279983799847998579986799877998879989799907999179992799937999479995799967999779998799998000080001800028000380004800058000680007800088000980010800118001280013800148001580016800178001880019800208002180022800238002480025800268002780028800298003080031800328003380034800358003680037800388003980040800418004280043800448004580046800478004880049800508005180052800538005480055800568005780058800598006080061800628006380064800658006680067800688006980070800718007280073800748007580076800778007880079800808008180082800838008480085800868008780088800898009080091800928009380094800958009680097800988009980100801018010280103801048010580106801078010880109801108011180112801138011480115801168011780118801198012080121801228012380124801258012680127801288012980130801318013280133801348013580136801378013880139801408014180142801438014480145801468014780148801498015080151801528015380154801558015680157801588015980160801618016280163801648016580166801678016880169801708017180172801738017480175801768017780178801798018080181801828018380184801858018680187801888018980190801918019280193801948019580196801978019880199802008020180202802038020480205802068020780208802098021080211802128021380214802158021680217802188021980220802218022280223802248022580226802278022880229802308023180232802338023480235802368023780238802398024080241802428024380244802458024680247802488024980250802518025280253802548025580256802578025880259802608026180262802638026480265802668026780268802698027080271802728027380274802758027680277802788027980280802818028280283802848028580286802878028880289802908029180292802938029480295802968029780298802998030080301803028030380304803058030680307803088030980310803118031280313803148031580316803178031880319803208032180322803238032480325803268032780328803298033080331803328033380334803358033680337803388033980340803418034280343803448034580346803478034880349803508035180352803538035480355803568035780358803598036080361803628036380364803658036680367803688036980370803718037280373803748037580376803778037880379803808038180382803838038480385803868038780388803898039080391803928039380394803958039680397803988039980400804018040280403804048040580406804078040880409804108041180412804138041480415804168041780418804198042080421804228042380424804258042680427804288042980430804318043280433804348043580436804378043880439804408044180442804438044480445804468044780448804498045080451804528045380454804558045680457804588045980460804618046280463804648046580466804678046880469804708047180472804738047480475804768047780478804798048080481804828048380484804858048680487804888048980490804918049280493804948049580496804978049880499805008050180502805038050480505805068050780508805098051080511805128051380514805158051680517805188051980520805218052280523805248052580526805278052880529805308053180532805338053480535805368053780538805398054080541805428054380544805458054680547805488054980550805518055280553805548055580556805578055880559805608056180562805638056480565805668056780568805698057080571805728057380574805758057680577805788057980580805818058280583805848058580586805878058880589805908059180592805938059480595805968059780598805998060080601806028060380604806058060680607806088060980610806118061280613806148061580616806178061880619806208062180622806238062480625806268062780628806298063080631806328063380634806358063680637806388063980640806418064280643806448064580646806478064880649806508065180652806538065480655806568065780658806598066080661806628066380664806658066680667806688066980670806718067280673806748067580676806778067880679806808068180682806838068480685806868068780688806898069080691806928069380694806958069680697806988069980700807018070280703807048070580706807078070880709807108071180712807138071480715807168071780718807198072080721807228072380724807258072680727807288072980730807318073280733807348073580736807378073880739807408074180742807438074480745807468074780748807498075080751807528075380754807558075680757807588075980760807618076280763807648076580766807678076880769807708077180772807738077480775807768077780778807798078080781807828078380784807858078680787807888078980790807918079280793807948079580796807978079880799808008080180802808038080480805808068080780808808098081080811808128081380814808158081680817808188081980820808218082280823808248082580826808278082880829808308083180832808338083480835808368083780838808398084080841808428084380844808458084680847808488084980850808518085280853808548085580856808578085880859808608086180862808638086480865808668086780868808698087080871808728087380874808758087680877808788087980880808818088280883808848088580886808878088880889808908089180892808938089480895808968089780898808998090080901809028090380904809058090680907809088090980910809118091280913809148091580916809178091880919809208092180922809238092480925809268092780928809298093080931809328093380934809358093680937809388093980940809418094280943809448094580946809478094880949809508095180952809538095480955809568095780958809598096080961809628096380964809658096680967809688096980970809718097280973809748097580976809778097880979809808098180982809838098480985809868098780988809898099080991809928099380994809958099680997809988099981000810018100281003810048100581006810078100881009810108101181012810138101481015810168101781018810198102081021810228102381024810258102681027810288102981030810318103281033810348103581036810378103881039810408104181042810438104481045810468104781048810498105081051810528105381054810558105681057810588105981060810618106281063810648106581066810678106881069810708107181072810738107481075810768107781078810798108081081810828108381084810858108681087810888108981090810918109281093810948109581096810978109881099811008110181102811038110481105811068110781108811098111081111811128111381114811158111681117811188111981120811218112281123811248112581126811278112881129811308113181132811338113481135811368113781138811398114081141811428114381144811458114681147811488114981150811518115281153811548115581156811578115881159811608116181162811638116481165811668116781168811698117081171811728117381174811758117681177811788117981180811818118281183811848118581186811878118881189811908119181192811938119481195811968119781198811998120081201812028120381204812058120681207812088120981210812118121281213812148121581216812178121881219812208122181222812238122481225812268122781228812298123081231812328123381234812358123681237812388123981240812418124281243812448124581246812478124881249812508125181252812538125481255812568125781258812598126081261812628126381264812658126681267812688126981270812718127281273812748127581276812778127881279812808128181282812838128481285812868128781288812898129081291812928129381294812958129681297812988129981300813018130281303813048130581306813078130881309813108131181312813138131481315813168131781318813198132081321813228132381324813258132681327813288132981330813318133281333813348133581336813378133881339813408134181342813438134481345813468134781348813498135081351813528135381354813558135681357813588135981360813618136281363813648136581366813678136881369813708137181372813738137481375813768137781378813798138081381813828138381384813858138681387813888138981390813918139281393813948139581396813978139881399814008140181402814038140481405814068140781408814098141081411814128141381414814158141681417814188141981420814218142281423814248142581426814278142881429814308143181432814338143481435814368143781438814398144081441814428144381444814458144681447814488144981450814518145281453814548145581456814578145881459814608146181462814638146481465814668146781468814698147081471814728147381474814758147681477814788147981480814818148281483814848148581486814878148881489814908149181492814938149481495814968149781498814998150081501815028150381504815058150681507815088150981510815118151281513815148151581516815178151881519815208152181522815238152481525815268152781528815298153081531815328153381534815358153681537815388153981540815418154281543815448154581546815478154881549815508155181552815538155481555815568155781558815598156081561815628156381564815658156681567815688156981570815718157281573815748157581576815778157881579815808158181582815838158481585815868158781588815898159081591815928159381594815958159681597815988159981600816018160281603816048160581606816078160881609816108161181612816138161481615816168161781618816198162081621816228162381624816258162681627816288162981630816318163281633816348163581636816378163881639816408164181642816438164481645816468164781648816498165081651816528165381654816558165681657816588165981660816618166281663816648166581666816678166881669816708167181672816738167481675816768167781678816798168081681816828168381684816858168681687816888168981690816918169281693816948169581696816978169881699817008170181702817038170481705817068170781708817098171081711817128171381714817158171681717817188171981720817218172281723817248172581726817278172881729817308173181732817338173481735817368173781738817398174081741817428174381744817458174681747817488174981750817518175281753817548175581756817578175881759817608176181762817638176481765817668176781768817698177081771817728177381774817758177681777817788177981780817818178281783817848178581786817878178881789817908179181792817938179481795817968179781798817998180081801818028180381804818058180681807818088180981810818118181281813818148181581816818178181881819818208182181822818238182481825818268182781828818298183081831818328183381834818358183681837818388183981840818418184281843818448184581846818478184881849818508185181852818538185481855818568185781858818598186081861818628186381864818658186681867818688186981870818718187281873818748187581876818778187881879818808188181882818838188481885818868188781888818898189081891818928189381894818958189681897818988189981900819018190281903819048190581906819078190881909819108191181912819138191481915819168191781918819198192081921819228192381924819258192681927819288192981930819318193281933819348193581936819378193881939819408194181942819438194481945819468194781948819498195081951819528195381954819558195681957819588195981960819618196281963819648196581966819678196881969819708197181972819738197481975819768197781978819798198081981819828198381984819858198681987819888198981990819918199281993819948199581996819978199881999820008200182002820038200482005820068200782008820098201082011820128201382014820158201682017820188201982020820218202282023820248202582026820278202882029820308203182032820338203482035820368203782038820398204082041820428204382044820458204682047820488204982050820518205282053820548205582056820578205882059820608206182062820638206482065820668206782068820698207082071820728207382074820758207682077820788207982080820818208282083820848208582086820878208882089820908209182092820938209482095820968209782098820998210082101821028210382104821058210682107821088210982110821118211282113821148211582116821178211882119821208212182122821238212482125821268212782128821298213082131821328213382134821358213682137821388213982140821418214282143821448214582146821478214882149821508215182152821538215482155821568215782158821598216082161821628216382164821658216682167821688216982170821718217282173821748217582176821778217882179821808218182182821838218482185821868218782188821898219082191821928219382194821958219682197821988219982200822018220282203822048220582206822078220882209822108221182212822138221482215822168221782218822198222082221822228222382224822258222682227822288222982230822318223282233822348223582236822378223882239822408224182242822438224482245822468224782248822498225082251822528225382254822558225682257822588225982260822618226282263822648226582266822678226882269822708227182272822738227482275822768227782278822798228082281822828228382284822858228682287822888228982290822918229282293822948229582296822978229882299823008230182302823038230482305823068230782308823098231082311823128231382314823158231682317823188231982320823218232282323823248232582326823278232882329823308233182332823338233482335823368233782338823398234082341823428234382344823458234682347823488234982350823518235282353823548235582356823578235882359823608236182362823638236482365823668236782368823698237082371823728237382374823758237682377823788237982380823818238282383823848238582386823878238882389823908239182392823938239482395823968239782398823998240082401824028240382404824058240682407824088240982410824118241282413824148241582416824178241882419824208242182422824238242482425824268242782428824298243082431824328243382434824358243682437824388243982440824418244282443824448244582446824478244882449824508245182452824538245482455824568245782458824598246082461824628246382464824658246682467824688246982470824718247282473824748247582476824778247882479824808248182482824838248482485824868248782488824898249082491824928249382494824958249682497824988249982500825018250282503825048250582506825078250882509825108251182512825138251482515825168251782518825198252082521825228252382524825258252682527825288252982530825318253282533825348253582536825378253882539825408254182542825438254482545825468254782548825498255082551825528255382554825558255682557825588255982560825618256282563825648256582566825678256882569825708257182572825738257482575825768257782578825798258082581825828258382584825858258682587825888258982590825918259282593825948259582596825978259882599826008260182602826038260482605826068260782608826098261082611826128261382614826158261682617826188261982620826218262282623826248262582626826278262882629826308263182632826338263482635826368263782638826398264082641826428264382644826458264682647826488264982650826518265282653826548265582656826578265882659826608266182662826638266482665826668266782668826698267082671826728267382674826758267682677826788267982680826818268282683826848268582686826878268882689826908269182692826938269482695826968269782698826998270082701827028270382704827058270682707827088270982710827118271282713827148271582716827178271882719827208272182722827238272482725827268272782728827298273082731827328273382734827358273682737827388273982740827418274282743827448274582746827478274882749827508275182752827538275482755827568275782758827598276082761827628276382764827658276682767827688276982770827718277282773827748277582776827778277882779827808278182782827838278482785827868278782788827898279082791827928279382794827958279682797827988279982800828018280282803828048280582806828078280882809828108281182812828138281482815828168281782818828198282082821828228282382824828258282682827828288282982830828318283282833828348283582836828378283882839828408284182842828438284482845828468284782848828498285082851828528285382854828558285682857828588285982860828618286282863828648286582866828678286882869828708287182872828738287482875828768287782878828798288082881828828288382884828858288682887828888288982890828918289282893828948289582896828978289882899829008290182902829038290482905829068290782908829098291082911829128291382914829158291682917829188291982920829218292282923829248292582926829278292882929829308293182932829338293482935829368293782938829398294082941829428294382944829458294682947829488294982950829518295282953829548295582956829578295882959829608296182962829638296482965829668296782968829698297082971829728297382974829758297682977829788297982980829818298282983829848298582986829878298882989829908299182992829938299482995829968299782998829998300083001830028300383004830058300683007830088300983010830118301283013830148301583016830178301883019830208302183022830238302483025830268302783028830298303083031830328303383034830358303683037830388303983040830418304283043830448304583046830478304883049830508305183052830538305483055830568305783058830598306083061830628306383064830658306683067830688306983070830718307283073830748307583076830778307883079830808308183082830838308483085830868308783088830898309083091830928309383094830958309683097830988309983100831018310283103831048310583106831078310883109831108311183112831138311483115831168311783118831198312083121831228312383124831258312683127831288312983130831318313283133831348313583136831378313883139831408314183142831438314483145831468314783148831498315083151831528315383154831558315683157831588315983160831618316283163831648316583166831678316883169831708317183172831738317483175831768317783178831798318083181831828318383184831858318683187831888318983190831918319283193831948319583196831978319883199832008320183202832038320483205832068320783208832098321083211832128321383214832158321683217832188321983220832218322283223832248322583226832278322883229832308323183232832338323483235832368323783238832398324083241832428324383244832458324683247832488324983250832518325283253832548325583256832578325883259832608326183262832638326483265832668326783268832698327083271832728327383274832758327683277832788327983280832818328283283832848328583286832878328883289832908329183292832938329483295832968329783298832998330083301833028330383304833058330683307833088330983310833118331283313833148331583316833178331883319833208332183322833238332483325833268332783328833298333083331833328333383334833358333683337833388333983340833418334283343833448334583346833478334883349833508335183352833538335483355833568335783358833598336083361833628336383364833658336683367833688336983370833718337283373833748337583376833778337883379833808338183382833838338483385833868338783388833898339083391833928339383394833958339683397833988339983400834018340283403834048340583406834078340883409834108341183412834138341483415834168341783418834198342083421834228342383424834258342683427834288342983430834318343283433834348343583436834378343883439834408344183442834438344483445834468344783448834498345083451834528345383454834558345683457834588345983460834618346283463834648346583466834678346883469834708347183472834738347483475834768347783478834798348083481834828348383484834858348683487834888348983490834918349283493834948349583496834978349883499835008350183502835038350483505835068350783508835098351083511835128351383514835158351683517835188351983520835218352283523835248352583526835278352883529835308353183532835338353483535835368353783538835398354083541835428354383544835458354683547835488354983550835518355283553835548355583556835578355883559835608356183562835638356483565835668356783568835698357083571835728357383574835758357683577835788357983580835818358283583835848358583586835878358883589835908359183592835938359483595835968359783598835998360083601836028360383604836058360683607836088360983610836118361283613836148361583616836178361883619836208362183622836238362483625836268362783628836298363083631836328363383634836358363683637836388363983640836418364283643836448364583646836478364883649836508365183652836538365483655836568365783658836598366083661836628366383664836658366683667836688366983670836718367283673836748367583676836778367883679836808368183682836838368483685836868368783688836898369083691836928369383694836958369683697836988369983700837018370283703837048370583706837078370883709837108371183712837138371483715837168371783718837198372083721837228372383724837258372683727837288372983730837318373283733837348373583736837378373883739837408374183742837438374483745837468374783748837498375083751837528375383754837558375683757837588375983760837618376283763837648376583766837678376883769837708377183772837738377483775837768377783778837798378083781837828378383784837858378683787837888378983790837918379283793837948379583796837978379883799838008380183802838038380483805838068380783808838098381083811838128381383814838158381683817838188381983820838218382283823838248382583826838278382883829838308383183832838338383483835838368383783838838398384083841838428384383844838458384683847838488384983850838518385283853838548385583856838578385883859838608386183862838638386483865838668386783868838698387083871838728387383874838758387683877838788387983880838818388283883838848388583886838878388883889838908389183892838938389483895838968389783898838998390083901839028390383904839058390683907839088390983910839118391283913839148391583916839178391883919839208392183922839238392483925839268392783928839298393083931839328393383934839358393683937839388393983940839418394283943839448394583946839478394883949839508395183952839538395483955839568395783958839598396083961839628396383964839658396683967839688396983970839718397283973839748397583976839778397883979839808398183982839838398483985839868398783988839898399083991839928399383994839958399683997839988399984000840018400284003840048400584006840078400884009840108401184012840138401484015840168401784018840198402084021840228402384024840258402684027840288402984030840318403284033840348403584036840378403884039840408404184042840438404484045840468404784048840498405084051840528405384054840558405684057840588405984060840618406284063840648406584066840678406884069840708407184072840738407484075840768407784078840798408084081840828408384084840858408684087840888408984090840918409284093840948409584096840978409884099841008410184102841038410484105841068410784108841098411084111841128411384114841158411684117841188411984120841218412284123841248412584126841278412884129841308413184132841338413484135841368413784138841398414084141841428414384144841458414684147841488414984150841518415284153841548415584156841578415884159841608416184162841638416484165841668416784168841698417084171841728417384174841758417684177841788417984180841818418284183841848418584186841878418884189841908419184192841938419484195841968419784198841998420084201842028420384204842058420684207842088420984210842118421284213842148421584216842178421884219842208422184222842238422484225842268422784228842298423084231842328423384234842358423684237842388423984240842418424284243842448424584246842478424884249842508425184252842538425484255842568425784258842598426084261842628426384264842658426684267842688426984270842718427284273842748427584276842778427884279842808428184282842838428484285842868428784288842898429084291842928429384294842958429684297842988429984300843018430284303843048430584306843078430884309843108431184312843138431484315843168431784318843198432084321843228432384324843258432684327843288432984330843318433284333843348433584336843378433884339843408434184342843438434484345843468434784348843498435084351843528435384354843558435684357843588435984360843618436284363843648436584366843678436884369843708437184372843738437484375843768437784378843798438084381843828438384384843858438684387843888438984390843918439284393843948439584396843978439884399844008440184402844038440484405844068440784408844098441084411844128441384414844158441684417844188441984420844218442284423844248442584426844278442884429844308443184432844338443484435844368443784438844398444084441844428444384444844458444684447844488444984450844518445284453844548445584456844578445884459844608446184462844638446484465844668446784468844698447084471844728447384474844758447684477844788447984480844818448284483844848448584486844878448884489844908449184492844938449484495844968449784498844998450084501845028450384504845058450684507845088450984510845118451284513845148451584516845178451884519845208452184522845238452484525845268452784528845298453084531845328453384534845358453684537845388453984540845418454284543845448454584546845478454884549845508455184552845538455484555845568455784558845598456084561845628456384564845658456684567845688456984570845718457284573845748457584576845778457884579845808458184582845838458484585845868458784588845898459084591845928459384594845958459684597845988459984600846018460284603846048460584606846078460884609846108461184612846138461484615846168461784618846198462084621846228462384624846258462684627846288462984630846318463284633846348463584636846378463884639846408464184642846438464484645846468464784648846498465084651846528465384654846558465684657846588465984660846618466284663846648466584666846678466884669846708467184672846738467484675846768467784678846798468084681846828468384684846858468684687846888468984690846918469284693846948469584696846978469884699847008470184702847038470484705847068470784708847098471084711847128471384714847158471684717847188471984720847218472284723847248472584726847278472884729847308473184732847338473484735847368473784738847398474084741847428474384744847458474684747847488474984750847518475284753847548475584756847578475884759847608476184762847638476484765847668476784768847698477084771847728477384774847758477684777847788477984780847818478284783847848478584786847878478884789847908479184792847938479484795847968479784798847998480084801848028480384804848058480684807848088480984810848118481284813848148481584816848178481884819848208482184822848238482484825848268482784828848298483084831848328483384834848358483684837848388483984840848418484284843848448484584846848478484884849848508485184852848538485484855848568485784858848598486084861848628486384864848658486684867848688486984870848718487284873848748487584876848778487884879848808488184882848838488484885848868488784888848898489084891848928489384894848958489684897848988489984900849018490284903849048490584906849078490884909849108491184912849138491484915849168491784918849198492084921849228492384924849258492684927849288492984930849318493284933849348493584936849378493884939849408494184942849438494484945849468494784948849498495084951849528495384954849558495684957849588495984960849618496284963849648496584966849678496884969849708497184972849738497484975849768497784978849798498084981849828498384984849858498684987849888498984990849918499284993849948499584996849978499884999850008500185002850038500485005850068500785008850098501085011850128501385014850158501685017850188501985020850218502285023850248502585026850278502885029850308503185032850338503485035850368503785038850398504085041850428504385044850458504685047850488504985050850518505285053850548505585056850578505885059850608506185062850638506485065850668506785068850698507085071850728507385074850758507685077850788507985080850818508285083850848508585086850878508885089850908509185092850938509485095850968509785098850998510085101851028510385104851058510685107851088510985110851118511285113851148511585116851178511885119851208512185122851238512485125851268512785128851298513085131851328513385134851358513685137851388513985140851418514285143851448514585146851478514885149851508515185152851538515485155851568515785158851598516085161851628516385164851658516685167851688516985170851718517285173851748517585176851778517885179851808518185182851838518485185851868518785188851898519085191851928519385194851958519685197851988519985200852018520285203852048520585206852078520885209852108521185212852138521485215852168521785218852198522085221852228522385224852258522685227852288522985230852318523285233852348523585236852378523885239852408524185242852438524485245852468524785248852498525085251852528525385254852558525685257852588525985260852618526285263852648526585266852678526885269852708527185272852738527485275852768527785278852798528085281852828528385284852858528685287852888528985290852918529285293852948529585296852978529885299853008530185302853038530485305853068530785308853098531085311853128531385314853158531685317853188531985320853218532285323853248532585326853278532885329853308533185332853338533485335853368533785338853398534085341853428534385344853458534685347853488534985350853518535285353853548535585356853578535885359853608536185362853638536485365853668536785368853698537085371853728537385374853758537685377853788537985380853818538285383853848538585386853878538885389853908539185392853938539485395853968539785398853998540085401854028540385404854058540685407854088540985410854118541285413854148541585416854178541885419854208542185422854238542485425854268542785428854298543085431854328543385434854358543685437854388543985440854418544285443854448544585446854478544885449854508545185452854538545485455854568545785458854598546085461854628546385464854658546685467854688546985470854718547285473854748547585476854778547885479854808548185482854838548485485854868548785488854898549085491854928549385494854958549685497854988549985500855018550285503855048550585506855078550885509855108551185512855138551485515855168551785518855198552085521855228552385524855258552685527855288552985530855318553285533855348553585536855378553885539855408554185542855438554485545855468554785548855498555085551855528555385554855558555685557855588555985560855618556285563855648556585566855678556885569855708557185572855738557485575855768557785578855798558085581855828558385584855858558685587855888558985590855918559285593855948559585596855978559885599856008560185602856038560485605856068560785608856098561085611856128561385614856158561685617856188561985620856218562285623856248562585626856278562885629856308563185632856338563485635856368563785638856398564085641856428564385644856458564685647856488564985650856518565285653856548565585656856578565885659856608566185662856638566485665856668566785668856698567085671856728567385674856758567685677856788567985680856818568285683856848568585686856878568885689856908569185692856938569485695856968569785698856998570085701857028570385704857058570685707857088570985710857118571285713857148571585716857178571885719857208572185722857238572485725857268572785728857298573085731857328573385734857358573685737857388573985740857418574285743857448574585746857478574885749857508575185752857538575485755857568575785758857598576085761857628576385764857658576685767857688576985770857718577285773857748577585776857778577885779857808578185782857838578485785857868578785788857898579085791857928579385794857958579685797857988579985800858018580285803858048580585806858078580885809858108581185812858138581485815858168581785818858198582085821858228582385824858258582685827858288582985830858318583285833858348583585836858378583885839858408584185842858438584485845858468584785848858498585085851858528585385854858558585685857858588585985860858618586285863858648586585866858678586885869858708587185872858738587485875858768587785878858798588085881858828588385884858858588685887858888588985890858918589285893858948589585896858978589885899859008590185902859038590485905859068590785908859098591085911859128591385914859158591685917859188591985920859218592285923859248592585926859278592885929859308593185932859338593485935859368593785938859398594085941859428594385944859458594685947859488594985950859518595285953859548595585956859578595885959859608596185962859638596485965859668596785968859698597085971859728597385974859758597685977859788597985980859818598285983859848598585986859878598885989859908599185992859938599485995859968599785998859998600086001860028600386004860058600686007860088600986010860118601286013860148601586016860178601886019860208602186022860238602486025860268602786028860298603086031860328603386034860358603686037860388603986040860418604286043860448604586046860478604886049860508605186052860538605486055860568605786058860598606086061860628606386064860658606686067860688606986070860718607286073860748607586076860778607886079860808608186082860838608486085860868608786088860898609086091860928609386094860958609686097860988609986100861018610286103861048610586106861078610886109861108611186112861138611486115861168611786118861198612086121861228612386124861258612686127861288612986130861318613286133861348613586136861378613886139861408614186142861438614486145861468614786148861498615086151861528615386154861558615686157861588615986160861618616286163861648616586166861678616886169861708617186172861738617486175861768617786178861798618086181861828618386184861858618686187861888618986190861918619286193861948619586196861978619886199862008620186202862038620486205862068620786208862098621086211862128621386214862158621686217862188621986220862218622286223862248622586226862278622886229862308623186232862338623486235862368623786238862398624086241862428624386244862458624686247862488624986250862518625286253862548625586256862578625886259862608626186262862638626486265862668626786268862698627086271862728627386274862758627686277862788627986280862818628286283862848628586286862878628886289862908629186292862938629486295862968629786298862998630086301863028630386304863058630686307863088630986310863118631286313863148631586316863178631886319863208632186322863238632486325863268632786328863298633086331863328633386334863358633686337863388633986340863418634286343863448634586346863478634886349863508635186352863538635486355863568635786358863598636086361863628636386364863658636686367863688636986370863718637286373863748637586376863778637886379863808638186382863838638486385863868638786388863898639086391863928639386394863958639686397863988639986400864018640286403864048640586406864078640886409864108641186412864138641486415864168641786418864198642086421864228642386424864258642686427864288642986430864318643286433864348643586436864378643886439864408644186442864438644486445864468644786448864498645086451864528645386454864558645686457864588645986460864618646286463864648646586466864678646886469864708647186472864738647486475864768647786478864798648086481864828648386484864858648686487864888648986490864918649286493864948649586496864978649886499865008650186502865038650486505865068650786508865098651086511865128651386514865158651686517865188651986520865218652286523865248652586526865278652886529865308653186532865338653486535865368653786538865398654086541865428654386544865458654686547865488654986550865518655286553865548655586556865578655886559865608656186562865638656486565865668656786568865698657086571865728657386574865758657686577865788657986580865818658286583865848658586586865878658886589865908659186592865938659486595865968659786598865998660086601866028660386604866058660686607866088660986610866118661286613866148661586616866178661886619866208662186622866238662486625866268662786628866298663086631866328663386634866358663686637866388663986640866418664286643866448664586646866478664886649866508665186652866538665486655866568665786658866598666086661866628666386664866658666686667866688666986670866718667286673866748667586676866778667886679866808668186682866838668486685866868668786688866898669086691866928669386694866958669686697866988669986700867018670286703867048670586706867078670886709867108671186712867138671486715867168671786718867198672086721867228672386724867258672686727867288672986730867318673286733867348673586736867378673886739867408674186742867438674486745867468674786748867498675086751867528675386754867558675686757867588675986760867618676286763867648676586766867678676886769867708677186772867738677486775867768677786778867798678086781867828678386784867858678686787867888678986790867918679286793867948679586796867978679886799868008680186802868038680486805868068680786808868098681086811868128681386814868158681686817868188681986820868218682286823868248682586826868278682886829868308683186832868338683486835868368683786838868398684086841868428684386844868458684686847868488684986850868518685286853868548685586856868578685886859868608686186862868638686486865868668686786868868698687086871868728687386874868758687686877868788687986880868818688286883868848688586886868878688886889868908689186892868938689486895868968689786898868998690086901869028690386904869058690686907869088690986910869118691286913869148691586916869178691886919869208692186922869238692486925869268692786928869298693086931869328693386934869358693686937869388693986940869418694286943869448694586946869478694886949869508695186952869538695486955869568695786958869598696086961869628696386964869658696686967869688696986970869718697286973869748697586976869778697886979869808698186982869838698486985869868698786988869898699086991869928699386994869958699686997869988699987000870018700287003870048700587006870078700887009870108701187012870138701487015870168701787018870198702087021870228702387024870258702687027870288702987030870318703287033870348703587036870378703887039870408704187042870438704487045870468704787048870498705087051870528705387054870558705687057870588705987060870618706287063870648706587066870678706887069870708707187072870738707487075870768707787078870798708087081870828708387084870858708687087870888708987090870918709287093870948709587096870978709887099871008710187102871038710487105871068710787108871098711087111871128711387114871158711687117871188711987120871218712287123871248712587126871278712887129871308713187132871338713487135871368713787138871398714087141871428714387144871458714687147871488714987150871518715287153871548715587156871578715887159871608716187162871638716487165871668716787168871698717087171871728717387174871758717687177871788717987180871818718287183871848718587186871878718887189871908719187192871938719487195871968719787198871998720087201872028720387204872058720687207872088720987210872118721287213872148721587216872178721887219872208722187222872238722487225872268722787228872298723087231872328723387234872358723687237872388723987240872418724287243872448724587246872478724887249872508725187252872538725487255872568725787258872598726087261872628726387264872658726687267872688726987270872718727287273872748727587276872778727887279872808728187282872838728487285872868728787288872898729087291872928729387294872958729687297872988729987300873018730287303873048730587306873078730887309873108731187312873138731487315873168731787318873198732087321873228732387324873258732687327873288732987330873318733287333873348733587336873378733887339873408734187342873438734487345873468734787348873498735087351873528735387354873558735687357873588735987360873618736287363873648736587366873678736887369873708737187372873738737487375873768737787378873798738087381873828738387384873858738687387873888738987390873918739287393873948739587396873978739887399874008740187402874038740487405874068740787408874098741087411874128741387414874158741687417874188741987420874218742287423874248742587426874278742887429874308743187432874338743487435874368743787438874398744087441874428744387444874458744687447874488744987450874518745287453874548745587456874578745887459874608746187462874638746487465874668746787468874698747087471874728747387474874758747687477874788747987480874818748287483874848748587486874878748887489874908749187492874938749487495874968749787498874998750087501875028750387504875058750687507875088750987510875118751287513875148751587516875178751887519875208752187522875238752487525875268752787528875298753087531875328753387534875358753687537875388753987540875418754287543875448754587546875478754887549875508755187552875538755487555875568755787558875598756087561875628756387564875658756687567875688756987570875718757287573875748757587576875778757887579875808758187582875838758487585875868758787588875898759087591875928759387594875958759687597875988759987600876018760287603876048760587606876078760887609876108761187612876138761487615876168761787618876198762087621876228762387624876258762687627876288762987630876318763287633876348763587636876378763887639876408764187642876438764487645876468764787648876498765087651876528765387654876558765687657876588765987660876618766287663876648766587666876678766887669876708767187672876738767487675876768767787678876798768087681876828768387684876858768687687876888768987690876918769287693876948769587696876978769887699877008770187702877038770487705877068770787708877098771087711877128771387714877158771687717877188771987720877218772287723877248772587726877278772887729877308773187732877338773487735877368773787738877398774087741877428774387744877458774687747877488774987750877518775287753877548775587756877578775887759877608776187762877638776487765877668776787768877698777087771877728777387774877758777687777877788777987780877818778287783877848778587786877878778887789877908779187792877938779487795877968779787798877998780087801878028780387804878058780687807878088780987810878118781287813878148781587816878178781887819878208782187822878238782487825878268782787828878298783087831878328783387834878358783687837878388783987840878418784287843878448784587846878478784887849878508785187852878538785487855878568785787858878598786087861878628786387864878658786687867878688786987870878718787287873878748787587876878778787887879878808788187882878838788487885878868788787888878898789087891878928789387894878958789687897878988789987900879018790287903879048790587906879078790887909879108791187912879138791487915879168791787918879198792087921879228792387924879258792687927879288792987930879318793287933879348793587936879378793887939879408794187942879438794487945879468794787948879498795087951879528795387954879558795687957879588795987960879618796287963879648796587966879678796887969879708797187972879738797487975879768797787978879798798087981879828798387984879858798687987879888798987990879918799287993879948799587996879978799887999880008800188002880038800488005880068800788008880098801088011880128801388014880158801688017880188801988020880218802288023880248802588026880278802888029880308803188032880338803488035880368803788038880398804088041880428804388044880458804688047880488804988050880518805288053880548805588056880578805888059880608806188062880638806488065880668806788068880698807088071880728807388074880758807688077880788807988080880818808288083880848808588086880878808888089880908809188092880938809488095880968809788098880998810088101881028810388104881058810688107881088810988110881118811288113881148811588116881178811888119881208812188122881238812488125881268812788128881298813088131881328813388134881358813688137881388813988140881418814288143881448814588146881478814888149881508815188152881538815488155881568815788158881598816088161881628816388164881658816688167881688816988170881718817288173881748817588176881778817888179881808818188182881838818488185881868818788188881898819088191881928819388194881958819688197881988819988200882018820288203882048820588206882078820888209882108821188212882138821488215882168821788218882198822088221882228822388224882258822688227882288822988230882318823288233882348823588236882378823888239882408824188242882438824488245882468824788248882498825088251882528825388254882558825688257882588825988260882618826288263882648826588266882678826888269882708827188272882738827488275882768827788278882798828088281882828828388284882858828688287882888828988290882918829288293882948829588296882978829888299883008830188302883038830488305883068830788308883098831088311883128831388314883158831688317883188831988320883218832288323883248832588326883278832888329883308833188332883338833488335883368833788338883398834088341883428834388344883458834688347883488834988350883518835288353883548835588356883578835888359883608836188362883638836488365883668836788368883698837088371883728837388374883758837688377883788837988380883818838288383883848838588386883878838888389883908839188392883938839488395883968839788398883998840088401884028840388404884058840688407884088840988410884118841288413884148841588416884178841888419884208842188422884238842488425884268842788428884298843088431884328843388434884358843688437884388843988440884418844288443884448844588446884478844888449884508845188452884538845488455884568845788458884598846088461884628846388464884658846688467884688846988470884718847288473884748847588476884778847888479884808848188482884838848488485884868848788488884898849088491884928849388494884958849688497884988849988500885018850288503885048850588506885078850888509885108851188512885138851488515885168851788518885198852088521885228852388524885258852688527885288852988530885318853288533885348853588536885378853888539885408854188542885438854488545885468854788548885498855088551885528855388554885558855688557885588855988560885618856288563885648856588566885678856888569885708857188572885738857488575885768857788578885798858088581885828858388584885858858688587885888858988590885918859288593885948859588596885978859888599886008860188602886038860488605886068860788608886098861088611886128861388614886158861688617886188861988620886218862288623886248862588626886278862888629886308863188632886338863488635886368863788638886398864088641886428864388644886458864688647886488864988650886518865288653886548865588656886578865888659886608866188662886638866488665886668866788668886698867088671886728867388674886758867688677886788867988680886818868288683886848868588686886878868888689886908869188692886938869488695886968869788698886998870088701887028870388704887058870688707887088870988710887118871288713887148871588716887178871888719887208872188722887238872488725887268872788728887298873088731887328873388734887358873688737887388873988740887418874288743887448874588746887478874888749887508875188752887538875488755887568875788758887598876088761887628876388764887658876688767887688876988770887718877288773887748877588776887778877888779887808878188782887838878488785887868878788788887898879088791887928879388794887958879688797887988879988800888018880288803888048880588806888078880888809888108881188812888138881488815888168881788818888198882088821888228882388824888258882688827888288882988830888318883288833888348883588836888378883888839888408884188842888438884488845888468884788848888498885088851888528885388854888558885688857888588885988860888618886288863888648886588866888678886888869888708887188872888738887488875888768887788878888798888088881888828888388884888858888688887888888888988890888918889288893888948889588896888978889888899889008890188902889038890488905889068890788908889098891088911889128891388914889158891688917889188891988920889218892288923889248892588926889278892888929889308893188932889338893488935889368893788938889398894088941889428894388944889458894688947889488894988950889518895288953889548895588956889578895888959889608896188962889638896488965889668896788968889698897088971889728897388974889758897688977889788897988980889818898288983889848898588986889878898888989889908899188992889938899488995889968899788998889998900089001890028900389004890058900689007890088900989010890118901289013890148901589016890178901889019890208902189022890238902489025890268902789028890298903089031890328903389034890358903689037890388903989040890418904289043890448904589046890478904889049890508905189052890538905489055890568905789058890598906089061890628906389064890658906689067890688906989070890718907289073890748907589076890778907889079890808908189082890838908489085890868908789088890898909089091890928909389094890958909689097890988909989100891018910289103891048910589106891078910889109891108911189112891138911489115891168911789118891198912089121891228912389124891258912689127891288912989130891318913289133891348913589136891378913889139891408914189142891438914489145891468914789148891498915089151891528915389154891558915689157891588915989160891618916289163891648916589166891678916889169891708917189172891738917489175891768917789178891798918089181891828918389184891858918689187891888918989190891918919289193891948919589196891978919889199892008920189202892038920489205892068920789208892098921089211892128921389214892158921689217892188921989220892218922289223892248922589226892278922889229892308923189232892338923489235892368923789238892398924089241892428924389244892458924689247892488924989250892518925289253892548925589256892578925889259892608926189262892638926489265892668926789268892698927089271892728927389274892758927689277892788927989280892818928289283892848928589286892878928889289892908929189292892938929489295892968929789298892998930089301893028930389304893058930689307893088930989310893118931289313893148931589316893178931889319893208932189322893238932489325893268932789328893298933089331893328933389334893358933689337893388933989340893418934289343893448934589346893478934889349893508935189352893538935489355893568935789358893598936089361893628936389364893658936689367893688936989370893718937289373893748937589376893778937889379893808938189382893838938489385893868938789388893898939089391893928939389394893958939689397893988939989400894018940289403894048940589406894078940889409894108941189412894138941489415894168941789418894198942089421894228942389424894258942689427894288942989430894318943289433894348943589436894378943889439894408944189442894438944489445894468944789448894498945089451894528945389454894558945689457894588945989460894618946289463894648946589466894678946889469894708947189472894738947489475894768947789478894798948089481894828948389484894858948689487894888948989490894918949289493894948949589496894978949889499895008950189502895038950489505895068950789508895098951089511895128951389514895158951689517895188951989520895218952289523895248952589526895278952889529895308953189532895338953489535895368953789538895398954089541895428954389544895458954689547895488954989550895518955289553895548955589556895578955889559895608956189562895638956489565895668956789568895698957089571895728957389574895758957689577895788957989580895818958289583895848958589586895878958889589895908959189592895938959489595895968959789598895998960089601896028960389604896058960689607896088960989610896118961289613896148961589616896178961889619896208962189622896238962489625896268962789628896298963089631896328963389634896358963689637896388963989640896418964289643896448964589646896478964889649896508965189652896538965489655896568965789658896598966089661896628966389664896658966689667896688966989670896718967289673896748967589676896778967889679896808968189682896838968489685896868968789688896898969089691896928969389694896958969689697896988969989700897018970289703897048970589706897078970889709897108971189712897138971489715897168971789718897198972089721897228972389724897258972689727897288972989730897318973289733897348973589736897378973889739897408974189742897438974489745897468974789748897498975089751897528975389754897558975689757897588975989760897618976289763897648976589766897678976889769897708977189772897738977489775897768977789778897798978089781897828978389784897858978689787897888978989790897918979289793897948979589796897978979889799898008980189802898038980489805898068980789808898098981089811898128981389814898158981689817898188981989820898218982289823898248982589826898278982889829898308983189832898338983489835898368983789838898398984089841898428984389844898458984689847898488984989850898518985289853898548985589856898578985889859898608986189862898638986489865898668986789868898698987089871898728987389874898758987689877898788987989880898818988289883898848988589886898878988889889898908989189892898938989489895898968989789898898998990089901899028990389904899058990689907899088990989910899118991289913899148991589916899178991889919899208992189922899238992489925899268992789928899298993089931899328993389934899358993689937899388993989940899418994289943899448994589946899478994889949899508995189952899538995489955899568995789958899598996089961899628996389964899658996689967899688996989970899718997289973899748997589976899778997889979899808998189982899838998489985899868998789988899898999089991899928999389994899958999689997899988999990000900019000290003900049000590006900079000890009900109001190012900139001490015900169001790018900199002090021900229002390024900259002690027900289002990030900319003290033900349003590036900379003890039900409004190042900439004490045900469004790048900499005090051900529005390054900559005690057900589005990060900619006290063900649006590066900679006890069900709007190072900739007490075900769007790078900799008090081900829008390084900859008690087900889008990090900919009290093900949009590096900979009890099901009010190102901039010490105901069010790108901099011090111901129011390114901159011690117901189011990120901219012290123901249012590126901279012890129901309013190132901339013490135901369013790138901399014090141901429014390144901459014690147901489014990150901519015290153901549015590156901579015890159901609016190162901639016490165901669016790168901699017090171901729017390174901759017690177901789017990180901819018290183901849018590186901879018890189901909019190192901939019490195901969019790198901999020090201902029020390204902059020690207902089020990210902119021290213902149021590216902179021890219902209022190222902239022490225902269022790228902299023090231902329023390234902359023690237902389023990240902419024290243902449024590246902479024890249902509025190252902539025490255902569025790258902599026090261902629026390264902659026690267902689026990270902719027290273902749027590276902779027890279902809028190282902839028490285902869028790288902899029090291902929029390294902959029690297902989029990300903019030290303903049030590306903079030890309903109031190312903139031490315903169031790318903199032090321903229032390324903259032690327903289032990330903319033290333903349033590336903379033890339903409034190342903439034490345903469034790348903499035090351903529035390354903559035690357903589035990360903619036290363903649036590366903679036890369903709037190372903739037490375903769037790378903799038090381903829038390384903859038690387903889038990390903919039290393903949039590396903979039890399904009040190402904039040490405904069040790408904099041090411904129041390414904159041690417904189041990420904219042290423904249042590426904279042890429904309043190432904339043490435904369043790438904399044090441904429044390444904459044690447904489044990450904519045290453904549045590456904579045890459904609046190462904639046490465904669046790468904699047090471904729047390474904759047690477904789047990480904819048290483904849048590486904879048890489904909049190492904939049490495904969049790498904999050090501905029050390504905059050690507905089050990510905119051290513905149051590516905179051890519905209052190522905239052490525905269052790528905299053090531905329053390534905359053690537905389053990540905419054290543905449054590546905479054890549905509055190552905539055490555905569055790558905599056090561905629056390564905659056690567905689056990570905719057290573905749057590576905779057890579905809058190582905839058490585905869058790588905899059090591905929059390594905959059690597905989059990600906019060290603906049060590606906079060890609906109061190612906139061490615906169061790618906199062090621906229062390624906259062690627906289062990630906319063290633906349063590636906379063890639906409064190642906439064490645906469064790648906499065090651906529065390654906559065690657906589065990660906619066290663906649066590666906679066890669906709067190672906739067490675906769067790678906799068090681906829068390684906859068690687906889068990690906919069290693906949069590696906979069890699907009070190702907039070490705907069070790708907099071090711907129071390714907159071690717907189071990720907219072290723907249072590726907279072890729907309073190732907339073490735907369073790738907399074090741907429074390744907459074690747907489074990750907519075290753907549075590756907579075890759907609076190762907639076490765907669076790768907699077090771907729077390774907759077690777907789077990780907819078290783907849078590786907879078890789907909079190792907939079490795907969079790798907999080090801908029080390804908059080690807908089080990810908119081290813908149081590816908179081890819908209082190822908239082490825908269082790828908299083090831908329083390834908359083690837908389083990840908419084290843908449084590846908479084890849908509085190852908539085490855908569085790858908599086090861908629086390864908659086690867908689086990870908719087290873908749087590876908779087890879908809088190882908839088490885908869088790888908899089090891908929089390894908959089690897908989089990900909019090290903909049090590906909079090890909909109091190912909139091490915909169091790918909199092090921909229092390924909259092690927909289092990930909319093290933909349093590936909379093890939909409094190942909439094490945909469094790948909499095090951909529095390954909559095690957909589095990960909619096290963909649096590966909679096890969909709097190972909739097490975909769097790978909799098090981909829098390984909859098690987909889098990990909919099290993909949099590996909979099890999910009100191002910039100491005910069100791008910099101091011910129101391014910159101691017910189101991020910219102291023910249102591026910279102891029910309103191032910339103491035910369103791038910399104091041910429104391044910459104691047910489104991050910519105291053910549105591056910579105891059910609106191062910639106491065910669106791068910699107091071910729107391074910759107691077910789107991080910819108291083910849108591086910879108891089910909109191092910939109491095910969109791098910999110091101911029110391104911059110691107911089110991110911119111291113911149111591116911179111891119911209112191122911239112491125911269112791128911299113091131911329113391134911359113691137911389113991140911419114291143911449114591146911479114891149911509115191152911539115491155911569115791158911599116091161911629116391164911659116691167911689116991170911719117291173911749117591176911779117891179911809118191182911839118491185911869118791188911899119091191911929119391194911959119691197911989119991200912019120291203912049120591206912079120891209912109121191212912139121491215912169121791218912199122091221912229122391224912259122691227912289122991230912319123291233912349123591236912379123891239912409124191242912439124491245912469124791248912499125091251912529125391254912559125691257912589125991260912619126291263912649126591266912679126891269912709127191272912739127491275912769127791278912799128091281912829128391284912859128691287912889128991290912919129291293912949129591296912979129891299913009130191302913039130491305913069130791308913099131091311913129131391314913159131691317913189131991320913219132291323913249132591326913279132891329913309133191332913339133491335913369133791338913399134091341913429134391344913459134691347913489134991350913519135291353913549135591356913579135891359913609136191362913639136491365913669136791368913699137091371913729137391374913759137691377913789137991380913819138291383913849138591386913879138891389913909139191392913939139491395913969139791398913999140091401914029140391404914059140691407914089140991410914119141291413914149141591416914179141891419914209142191422914239142491425914269142791428914299143091431914329143391434914359143691437914389143991440914419144291443914449144591446914479144891449914509145191452914539145491455914569145791458914599146091461914629146391464914659146691467914689146991470914719147291473914749147591476914779147891479914809148191482914839148491485914869148791488914899149091491914929149391494914959149691497914989149991500915019150291503915049150591506915079150891509915109151191512915139151491515915169151791518915199152091521915229152391524915259152691527915289152991530915319153291533915349153591536915379153891539915409154191542915439154491545915469154791548915499155091551915529155391554915559155691557915589155991560915619156291563915649156591566915679156891569915709157191572915739157491575915769157791578915799158091581915829158391584915859158691587915889158991590915919159291593915949159591596915979159891599916009160191602916039160491605916069160791608916099161091611916129161391614916159161691617916189161991620916219162291623916249162591626916279162891629916309163191632916339163491635916369163791638916399164091641916429164391644916459164691647916489164991650916519165291653916549165591656916579165891659916609166191662916639166491665916669166791668916699167091671916729167391674916759167691677916789167991680916819168291683916849168591686916879168891689916909169191692916939169491695916969169791698916999170091701917029170391704917059170691707917089170991710917119171291713917149171591716917179171891719917209172191722917239172491725917269172791728917299173091731917329173391734917359173691737917389173991740917419174291743917449174591746917479174891749917509175191752917539175491755917569175791758917599176091761917629176391764917659176691767917689176991770917719177291773917749177591776917779177891779917809178191782917839178491785917869178791788917899179091791917929179391794917959179691797917989179991800918019180291803918049180591806918079180891809918109181191812918139181491815918169181791818918199182091821918229182391824918259182691827918289182991830918319183291833918349183591836918379183891839918409184191842918439184491845918469184791848918499185091851918529185391854918559185691857918589185991860918619186291863918649186591866918679186891869918709187191872918739187491875918769187791878918799188091881918829188391884918859188691887918889188991890918919189291893918949189591896918979189891899919009190191902919039190491905919069190791908919099191091911919129191391914919159191691917919189191991920919219192291923919249192591926919279192891929919309193191932919339193491935919369193791938919399194091941919429194391944919459194691947919489194991950919519195291953919549195591956919579195891959919609196191962919639196491965919669196791968919699197091971919729197391974919759197691977919789197991980919819198291983919849198591986919879198891989919909199191992919939199491995919969199791998919999200092001920029200392004920059200692007920089200992010920119201292013920149201592016920179201892019920209202192022920239202492025920269202792028920299203092031920329203392034920359203692037920389203992040920419204292043920449204592046920479204892049920509205192052920539205492055920569205792058920599206092061920629206392064920659206692067920689206992070920719207292073920749207592076920779207892079920809208192082920839208492085920869208792088920899209092091920929209392094920959209692097920989209992100921019210292103921049210592106921079210892109921109211192112921139211492115921169211792118921199212092121921229212392124921259212692127921289212992130921319213292133921349213592136921379213892139921409214192142921439214492145921469214792148921499215092151921529215392154921559215692157921589215992160921619216292163921649216592166921679216892169921709217192172921739217492175921769217792178921799218092181921829218392184921859218692187921889218992190921919219292193921949219592196921979219892199922009220192202922039220492205922069220792208922099221092211922129221392214922159221692217922189221992220922219222292223922249222592226922279222892229922309223192232922339223492235922369223792238922399224092241922429224392244922459224692247922489224992250922519225292253922549225592256922579225892259922609226192262922639226492265922669226792268922699227092271922729227392274922759227692277922789227992280922819228292283922849228592286922879228892289922909229192292922939229492295922969229792298922999230092301923029230392304923059230692307923089230992310923119231292313923149231592316923179231892319923209232192322923239232492325923269232792328923299233092331923329233392334923359233692337923389233992340923419234292343923449234592346923479234892349923509235192352923539235492355923569235792358923599236092361923629236392364923659236692367923689236992370923719237292373923749237592376923779237892379923809238192382923839238492385923869238792388923899239092391923929239392394923959239692397923989239992400924019240292403924049240592406924079240892409924109241192412924139241492415924169241792418924199242092421924229242392424924259242692427924289242992430924319243292433924349243592436924379243892439924409244192442924439244492445924469244792448924499245092451924529245392454924559245692457924589245992460924619246292463924649246592466924679246892469924709247192472924739247492475924769247792478924799248092481924829248392484924859248692487924889248992490924919249292493924949249592496924979249892499925009250192502925039250492505925069250792508925099251092511925129251392514925159251692517925189251992520925219252292523925249252592526925279252892529925309253192532925339253492535925369253792538925399254092541925429254392544925459254692547925489254992550925519255292553925549255592556925579255892559925609256192562925639256492565925669256792568925699257092571925729257392574925759257692577925789257992580925819258292583925849258592586925879258892589925909259192592925939259492595925969259792598925999260092601926029260392604926059260692607926089260992610926119261292613926149261592616926179261892619926209262192622926239262492625926269262792628926299263092631926329263392634926359263692637926389263992640926419264292643926449264592646926479264892649926509265192652926539265492655926569265792658926599266092661926629266392664926659266692667926689266992670926719267292673926749267592676926779267892679926809268192682926839268492685926869268792688926899269092691926929269392694926959269692697926989269992700927019270292703927049270592706927079270892709927109271192712927139271492715927169271792718927199272092721927229272392724927259272692727927289272992730927319273292733927349273592736927379273892739927409274192742927439274492745927469274792748927499275092751927529275392754927559275692757927589275992760927619276292763927649276592766927679276892769927709277192772927739277492775927769277792778927799278092781927829278392784927859278692787927889278992790927919279292793927949279592796927979279892799928009280192802928039280492805928069280792808928099281092811928129281392814928159281692817928189281992820928219282292823928249282592826928279282892829928309283192832928339283492835928369283792838928399284092841928429284392844928459284692847928489284992850928519285292853928549285592856928579285892859928609286192862928639286492865928669286792868928699287092871928729287392874928759287692877928789287992880928819288292883928849288592886928879288892889928909289192892928939289492895928969289792898928999290092901929029290392904929059290692907929089290992910929119291292913929149291592916929179291892919929209292192922929239292492925929269292792928929299293092931929329293392934929359293692937929389293992940929419294292943929449294592946929479294892949929509295192952929539295492955929569295792958929599296092961929629296392964929659296692967929689296992970929719297292973929749297592976929779297892979929809298192982929839298492985929869298792988929899299092991929929299392994929959299692997929989299993000930019300293003930049300593006930079300893009930109301193012930139301493015930169301793018930199302093021930229302393024930259302693027930289302993030930319303293033930349303593036930379303893039930409304193042930439304493045930469304793048930499305093051930529305393054930559305693057930589305993060930619306293063930649306593066930679306893069930709307193072930739307493075930769307793078930799308093081930829308393084930859308693087930889308993090930919309293093930949309593096930979309893099931009310193102931039310493105931069310793108931099311093111931129311393114931159311693117931189311993120931219312293123931249312593126931279312893129931309313193132931339313493135931369313793138931399314093141931429314393144931459314693147931489314993150931519315293153931549315593156931579315893159931609316193162931639316493165931669316793168931699317093171931729317393174931759317693177931789317993180931819318293183931849318593186931879318893189931909319193192931939319493195931969319793198931999320093201932029320393204932059320693207932089320993210932119321293213932149321593216932179321893219932209322193222932239322493225932269322793228932299323093231932329323393234932359323693237932389323993240932419324293243932449324593246932479324893249932509325193252932539325493255932569325793258932599326093261932629326393264932659326693267932689326993270932719327293273932749327593276932779327893279932809328193282932839328493285932869328793288932899329093291932929329393294932959329693297932989329993300933019330293303933049330593306933079330893309933109331193312933139331493315933169331793318933199332093321933229332393324933259332693327933289332993330933319333293333933349333593336933379333893339933409334193342933439334493345933469334793348933499335093351933529335393354933559335693357933589335993360933619336293363933649336593366933679336893369933709337193372933739337493375933769337793378933799338093381933829338393384933859338693387933889338993390933919339293393933949339593396933979339893399934009340193402934039340493405934069340793408934099341093411934129341393414934159341693417934189341993420934219342293423934249342593426934279342893429934309343193432934339343493435934369343793438934399344093441934429344393444934459344693447934489344993450934519345293453934549345593456934579345893459934609346193462934639346493465934669346793468934699347093471934729347393474934759347693477934789347993480934819348293483934849348593486934879348893489934909349193492934939349493495934969349793498934999350093501935029350393504935059350693507935089350993510935119351293513935149351593516935179351893519935209352193522935239352493525935269352793528935299353093531935329353393534935359353693537935389353993540935419354293543935449354593546935479354893549935509355193552935539355493555935569355793558935599356093561935629356393564935659356693567935689356993570935719357293573935749357593576935779357893579935809358193582935839358493585935869358793588935899359093591935929359393594935959359693597935989359993600936019360293603936049360593606936079360893609936109361193612936139361493615936169361793618936199362093621936229362393624936259362693627936289362993630936319363293633936349363593636936379363893639936409364193642936439364493645936469364793648936499365093651936529365393654936559365693657936589365993660936619366293663936649366593666936679366893669936709367193672936739367493675936769367793678936799368093681936829368393684936859368693687936889368993690936919369293693936949369593696936979369893699937009370193702937039370493705937069370793708937099371093711937129371393714937159371693717937189371993720937219372293723937249372593726937279372893729937309373193732937339373493735937369373793738937399374093741937429374393744937459374693747937489374993750937519375293753937549375593756937579375893759937609376193762937639376493765937669376793768937699377093771937729377393774937759377693777937789377993780937819378293783937849378593786937879378893789937909379193792937939379493795937969379793798937999380093801938029380393804938059380693807938089380993810938119381293813938149381593816938179381893819938209382193822938239382493825938269382793828938299383093831938329383393834938359383693837938389383993840938419384293843938449384593846938479384893849938509385193852938539385493855938569385793858938599386093861938629386393864938659386693867938689386993870938719387293873938749387593876938779387893879938809388193882938839388493885938869388793888938899389093891938929389393894938959389693897938989389993900939019390293903939049390593906939079390893909939109391193912939139391493915939169391793918939199392093921939229392393924939259392693927939289392993930939319393293933939349393593936939379393893939939409394193942939439394493945939469394793948939499395093951939529395393954939559395693957939589395993960939619396293963939649396593966939679396893969939709397193972939739397493975939769397793978939799398093981939829398393984939859398693987939889398993990939919399293993939949399593996939979399893999940009400194002940039400494005940069400794008940099401094011940129401394014940159401694017940189401994020940219402294023940249402594026940279402894029940309403194032940339403494035940369403794038940399404094041940429404394044940459404694047940489404994050940519405294053940549405594056940579405894059940609406194062940639406494065940669406794068940699407094071940729407394074940759407694077940789407994080940819408294083940849408594086940879408894089940909409194092940939409494095940969409794098940999410094101941029410394104941059410694107941089410994110941119411294113941149411594116941179411894119941209412194122941239412494125941269412794128941299413094131941329413394134941359413694137941389413994140941419414294143941449414594146941479414894149941509415194152941539415494155941569415794158941599416094161941629416394164941659416694167941689416994170941719417294173941749417594176941779417894179941809418194182941839418494185941869418794188941899419094191941929419394194941959419694197941989419994200942019420294203942049420594206942079420894209942109421194212942139421494215942169421794218942199422094221942229422394224942259422694227942289422994230942319423294233942349423594236942379423894239942409424194242942439424494245942469424794248942499425094251942529425394254942559425694257942589425994260942619426294263942649426594266942679426894269942709427194272942739427494275942769427794278942799428094281942829428394284942859428694287942889428994290942919429294293942949429594296942979429894299943009430194302943039430494305943069430794308943099431094311943129431394314943159431694317943189431994320943219432294323943249432594326943279432894329943309433194332943339433494335943369433794338943399434094341943429434394344943459434694347943489434994350943519435294353943549435594356943579435894359943609436194362943639436494365943669436794368943699437094371943729437394374943759437694377943789437994380943819438294383943849438594386943879438894389943909439194392943939439494395943969439794398943999440094401944029440394404944059440694407944089440994410944119441294413944149441594416944179441894419944209442194422944239442494425944269442794428944299443094431944329443394434944359443694437944389443994440944419444294443944449444594446944479444894449944509445194452944539445494455944569445794458944599446094461944629446394464944659446694467944689446994470944719447294473944749447594476944779447894479944809448194482944839448494485944869448794488944899449094491944929449394494944959449694497944989449994500945019450294503945049450594506945079450894509945109451194512945139451494515945169451794518945199452094521945229452394524945259452694527945289452994530945319453294533945349453594536945379453894539945409454194542945439454494545945469454794548945499455094551945529455394554945559455694557945589455994560945619456294563945649456594566945679456894569945709457194572945739457494575945769457794578945799458094581945829458394584945859458694587945889458994590945919459294593945949459594596945979459894599946009460194602946039460494605946069460794608946099461094611946129461394614946159461694617946189461994620946219462294623946249462594626946279462894629946309463194632946339463494635946369463794638946399464094641946429464394644946459464694647946489464994650946519465294653946549465594656946579465894659946609466194662946639466494665946669466794668946699467094671946729467394674946759467694677946789467994680946819468294683946849468594686946879468894689946909469194692946939469494695946969469794698946999470094701947029470394704947059470694707947089470994710947119471294713947149471594716947179471894719947209472194722947239472494725947269472794728947299473094731947329473394734947359473694737947389473994740947419474294743947449474594746947479474894749947509475194752947539475494755947569475794758947599476094761947629476394764947659476694767947689476994770947719477294773947749477594776947779477894779947809478194782947839478494785947869478794788947899479094791947929479394794947959479694797947989479994800948019480294803948049480594806948079480894809948109481194812948139481494815948169481794818948199482094821948229482394824948259482694827948289482994830948319483294833948349483594836948379483894839948409484194842948439484494845948469484794848948499485094851948529485394854948559485694857948589485994860948619486294863948649486594866948679486894869948709487194872948739487494875948769487794878948799488094881948829488394884948859488694887948889488994890948919489294893948949489594896948979489894899949009490194902949039490494905949069490794908949099491094911949129491394914949159491694917949189491994920949219492294923949249492594926949279492894929949309493194932949339493494935949369493794938949399494094941949429494394944949459494694947949489494994950949519495294953949549495594956949579495894959949609496194962949639496494965949669496794968949699497094971949729497394974949759497694977949789497994980949819498294983949849498594986949879498894989949909499194992949939499494995949969499794998949999500095001950029500395004950059500695007950089500995010950119501295013950149501595016950179501895019950209502195022950239502495025950269502795028950299503095031950329503395034950359503695037950389503995040950419504295043950449504595046950479504895049950509505195052950539505495055950569505795058950599506095061950629506395064950659506695067950689506995070950719507295073950749507595076950779507895079950809508195082950839508495085950869508795088950899509095091950929509395094950959509695097950989509995100951019510295103951049510595106951079510895109951109511195112951139511495115951169511795118951199512095121951229512395124951259512695127951289512995130951319513295133951349513595136951379513895139951409514195142951439514495145951469514795148951499515095151951529515395154951559515695157951589515995160951619516295163951649516595166951679516895169951709517195172951739517495175951769517795178951799518095181951829518395184951859518695187951889518995190951919519295193951949519595196951979519895199952009520195202952039520495205952069520795208952099521095211952129521395214952159521695217952189521995220952219522295223952249522595226952279522895229952309523195232952339523495235952369523795238952399524095241952429524395244952459524695247952489524995250952519525295253952549525595256952579525895259952609526195262952639526495265952669526795268952699527095271952729527395274952759527695277952789527995280952819528295283952849528595286952879528895289952909529195292952939529495295952969529795298952999530095301953029530395304953059530695307953089530995310953119531295313953149531595316953179531895319953209532195322953239532495325953269532795328953299533095331953329533395334953359533695337953389533995340953419534295343953449534595346953479534895349953509535195352953539535495355953569535795358953599536095361953629536395364953659536695367953689536995370953719537295373953749537595376953779537895379953809538195382953839538495385953869538795388953899539095391953929539395394953959539695397953989539995400954019540295403954049540595406954079540895409954109541195412954139541495415954169541795418954199542095421954229542395424954259542695427954289542995430954319543295433954349543595436954379543895439954409544195442954439544495445954469544795448954499545095451954529545395454954559545695457954589545995460954619546295463954649546595466954679546895469954709547195472954739547495475954769547795478954799548095481954829548395484954859548695487954889548995490954919549295493954949549595496954979549895499955009550195502955039550495505955069550795508955099551095511955129551395514955159551695517955189551995520955219552295523955249552595526955279552895529955309553195532955339553495535955369553795538955399554095541955429554395544955459554695547955489554995550955519555295553955549555595556955579555895559955609556195562955639556495565955669556795568955699557095571955729557395574955759557695577955789557995580955819558295583955849558595586955879558895589955909559195592955939559495595955969559795598955999560095601956029560395604956059560695607956089560995610956119561295613956149561595616956179561895619956209562195622956239562495625956269562795628956299563095631956329563395634956359563695637956389563995640956419564295643956449564595646956479564895649956509565195652956539565495655956569565795658956599566095661956629566395664956659566695667956689566995670956719567295673956749567595676956779567895679956809568195682956839568495685956869568795688956899569095691956929569395694956959569695697956989569995700957019570295703957049570595706957079570895709957109571195712957139571495715957169571795718957199572095721957229572395724957259572695727957289572995730957319573295733957349573595736957379573895739957409574195742957439574495745957469574795748957499575095751957529575395754957559575695757957589575995760957619576295763957649576595766957679576895769957709577195772957739577495775957769577795778957799578095781957829578395784957859578695787957889578995790957919579295793957949579595796957979579895799958009580195802958039580495805958069580795808958099581095811958129581395814958159581695817958189581995820958219582295823958249582595826958279582895829958309583195832958339583495835958369583795838958399584095841958429584395844958459584695847958489584995850958519585295853958549585595856958579585895859958609586195862958639586495865958669586795868958699587095871958729587395874958759587695877958789587995880958819588295883958849588595886958879588895889958909589195892958939589495895958969589795898958999590095901959029590395904959059590695907959089590995910959119591295913959149591595916959179591895919959209592195922959239592495925959269592795928959299593095931959329593395934959359593695937959389593995940959419594295943959449594595946959479594895949959509595195952959539595495955959569595795958959599596095961959629596395964959659596695967959689596995970959719597295973959749597595976959779597895979959809598195982959839598495985959869598795988959899599095991959929599395994959959599695997959989599996000960019600296003960049600596006960079600896009960109601196012960139601496015960169601796018960199602096021960229602396024960259602696027960289602996030960319603296033960349603596036960379603896039960409604196042960439604496045960469604796048960499605096051960529605396054960559605696057960589605996060960619606296063960649606596066960679606896069960709607196072960739607496075960769607796078960799608096081960829608396084960859608696087960889608996090960919609296093960949609596096960979609896099961009610196102961039610496105961069610796108961099611096111961129611396114961159611696117961189611996120961219612296123961249612596126961279612896129961309613196132961339613496135961369613796138961399614096141961429614396144961459614696147961489614996150961519615296153961549615596156961579615896159961609616196162961639616496165961669616796168961699617096171961729617396174961759617696177961789617996180961819618296183961849618596186961879618896189961909619196192961939619496195961969619796198961999620096201962029620396204962059620696207962089620996210962119621296213962149621596216962179621896219962209622196222962239622496225962269622796228962299623096231962329623396234962359623696237962389623996240962419624296243962449624596246962479624896249962509625196252962539625496255962569625796258962599626096261962629626396264962659626696267962689626996270962719627296273962749627596276962779627896279962809628196282962839628496285962869628796288962899629096291962929629396294962959629696297962989629996300963019630296303963049630596306963079630896309963109631196312963139631496315963169631796318963199632096321963229632396324963259632696327963289632996330963319633296333963349633596336963379633896339963409634196342963439634496345963469634796348963499635096351963529635396354963559635696357963589635996360963619636296363963649636596366963679636896369963709637196372963739637496375963769637796378963799638096381963829638396384963859638696387963889638996390963919639296393963949639596396963979639896399964009640196402964039640496405964069640796408964099641096411964129641396414964159641696417964189641996420964219642296423964249642596426964279642896429964309643196432964339643496435964369643796438964399644096441964429644396444964459644696447964489644996450964519645296453964549645596456964579645896459964609646196462964639646496465964669646796468964699647096471964729647396474964759647696477964789647996480964819648296483964849648596486964879648896489964909649196492964939649496495964969649796498964999650096501965029650396504965059650696507965089650996510965119651296513965149651596516965179651896519965209652196522965239652496525965269652796528965299653096531965329653396534965359653696537965389653996540965419654296543965449654596546965479654896549965509655196552965539655496555965569655796558965599656096561965629656396564965659656696567965689656996570965719657296573965749657596576965779657896579965809658196582965839658496585965869658796588965899659096591965929659396594965959659696597965989659996600966019660296603966049660596606966079660896609966109661196612966139661496615966169661796618966199662096621966229662396624966259662696627966289662996630966319663296633966349663596636966379663896639966409664196642966439664496645966469664796648966499665096651966529665396654966559665696657966589665996660966619666296663966649666596666966679666896669966709667196672966739667496675966769667796678966799668096681966829668396684966859668696687966889668996690966919669296693966949669596696966979669896699967009670196702967039670496705967069670796708967099671096711967129671396714967159671696717967189671996720967219672296723967249672596726967279672896729967309673196732967339673496735967369673796738967399674096741967429674396744967459674696747967489674996750967519675296753967549675596756967579675896759967609676196762967639676496765967669676796768967699677096771967729677396774967759677696777967789677996780967819678296783967849678596786967879678896789967909679196792967939679496795967969679796798967999680096801968029680396804968059680696807968089680996810968119681296813968149681596816968179681896819968209682196822968239682496825968269682796828968299683096831968329683396834968359683696837968389683996840968419684296843968449684596846968479684896849968509685196852968539685496855968569685796858968599686096861968629686396864968659686696867968689686996870968719687296873968749687596876968779687896879968809688196882968839688496885968869688796888968899689096891968929689396894968959689696897968989689996900969019690296903969049690596906969079690896909969109691196912969139691496915969169691796918969199692096921969229692396924969259692696927969289692996930969319693296933969349693596936969379693896939969409694196942969439694496945969469694796948969499695096951969529695396954969559695696957969589695996960969619696296963969649696596966969679696896969969709697196972969739697496975969769697796978969799698096981969829698396984969859698696987969889698996990969919699296993969949699596996969979699896999970009700197002970039700497005970069700797008970099701097011970129701397014970159701697017970189701997020970219702297023970249702597026970279702897029970309703197032970339703497035970369703797038970399704097041970429704397044970459704697047970489704997050970519705297053970549705597056970579705897059970609706197062970639706497065970669706797068970699707097071970729707397074970759707697077970789707997080970819708297083970849708597086970879708897089970909709197092970939709497095970969709797098970999710097101971029710397104971059710697107971089710997110971119711297113971149711597116971179711897119971209712197122971239712497125971269712797128971299713097131971329713397134971359713697137971389713997140971419714297143971449714597146971479714897149971509715197152971539715497155971569715797158971599716097161971629716397164971659716697167971689716997170971719717297173971749717597176971779717897179971809718197182971839718497185971869718797188971899719097191971929719397194971959719697197971989719997200972019720297203972049720597206972079720897209972109721197212972139721497215972169721797218972199722097221972229722397224972259722697227972289722997230972319723297233972349723597236972379723897239972409724197242972439724497245972469724797248972499725097251972529725397254972559725697257972589725997260972619726297263972649726597266972679726897269972709727197272972739727497275972769727797278972799728097281972829728397284972859728697287972889728997290972919729297293972949729597296972979729897299973009730197302973039730497305973069730797308973099731097311973129731397314973159731697317973189731997320973219732297323973249732597326973279732897329973309733197332973339733497335973369733797338973399734097341973429734397344973459734697347973489734997350973519735297353973549735597356973579735897359973609736197362973639736497365973669736797368973699737097371973729737397374973759737697377973789737997380973819738297383973849738597386973879738897389973909739197392973939739497395973969739797398973999740097401974029740397404974059740697407974089740997410974119741297413974149741597416974179741897419974209742197422974239742497425974269742797428974299743097431974329743397434974359743697437974389743997440974419744297443974449744597446974479744897449974509745197452974539745497455974569745797458974599746097461974629746397464974659746697467974689746997470974719747297473974749747597476974779747897479974809748197482974839748497485974869748797488974899749097491974929749397494974959749697497974989749997500975019750297503975049750597506975079750897509975109751197512975139751497515975169751797518975199752097521975229752397524975259752697527975289752997530975319753297533975349753597536975379753897539975409754197542975439754497545975469754797548975499755097551975529755397554975559755697557975589755997560975619756297563975649756597566975679756897569975709757197572975739757497575975769757797578975799758097581975829758397584975859758697587975889758997590975919759297593975949759597596975979759897599976009760197602976039760497605976069760797608976099761097611976129761397614976159761697617976189761997620976219762297623976249762597626976279762897629976309763197632976339763497635976369763797638976399764097641976429764397644976459764697647976489764997650976519765297653976549765597656976579765897659976609766197662976639766497665976669766797668976699767097671976729767397674976759767697677976789767997680976819768297683976849768597686976879768897689976909769197692976939769497695976969769797698976999770097701977029770397704977059770697707977089770997710977119771297713977149771597716977179771897719977209772197722977239772497725977269772797728977299773097731977329773397734977359773697737977389773997740977419774297743977449774597746977479774897749977509775197752977539775497755977569775797758977599776097761977629776397764977659776697767977689776997770977719777297773977749777597776977779777897779977809778197782977839778497785977869778797788977899779097791977929779397794977959779697797977989779997800978019780297803978049780597806978079780897809978109781197812978139781497815978169781797818978199782097821978229782397824978259782697827978289782997830978319783297833978349783597836978379783897839978409784197842978439784497845978469784797848978499785097851978529785397854978559785697857978589785997860978619786297863978649786597866978679786897869978709787197872978739787497875978769787797878978799788097881978829788397884978859788697887978889788997890978919789297893978949789597896978979789897899979009790197902979039790497905979069790797908979099791097911979129791397914979159791697917979189791997920979219792297923979249792597926979279792897929979309793197932979339793497935979369793797938979399794097941979429794397944979459794697947979489794997950979519795297953979549795597956979579795897959979609796197962979639796497965979669796797968979699797097971979729797397974979759797697977979789797997980979819798297983979849798597986979879798897989979909799197992979939799497995979969799797998979999800098001980029800398004980059800698007980089800998010980119801298013980149801598016980179801898019980209802198022980239802498025980269802798028980299803098031980329803398034980359803698037980389803998040980419804298043980449804598046980479804898049980509805198052980539805498055980569805798058980599806098061980629806398064980659806698067980689806998070980719807298073980749807598076980779807898079980809808198082980839808498085980869808798088980899809098091980929809398094980959809698097980989809998100981019810298103981049810598106981079810898109981109811198112981139811498115981169811798118981199812098121981229812398124981259812698127981289812998130981319813298133981349813598136981379813898139981409814198142981439814498145981469814798148981499815098151981529815398154981559815698157981589815998160981619816298163981649816598166981679816898169981709817198172981739817498175981769817798178981799818098181981829818398184981859818698187981889818998190981919819298193981949819598196981979819898199982009820198202982039820498205982069820798208982099821098211982129821398214982159821698217982189821998220982219822298223982249822598226982279822898229982309823198232982339823498235982369823798238982399824098241982429824398244982459824698247982489824998250982519825298253982549825598256982579825898259982609826198262982639826498265982669826798268982699827098271982729827398274982759827698277982789827998280982819828298283982849828598286982879828898289982909829198292982939829498295982969829798298982999830098301983029830398304983059830698307983089830998310983119831298313983149831598316983179831898319983209832198322983239832498325983269832798328983299833098331983329833398334983359833698337983389833998340983419834298343983449834598346983479834898349983509835198352983539835498355983569835798358983599836098361983629836398364983659836698367983689836998370983719837298373983749837598376983779837898379983809838198382983839838498385983869838798388983899839098391983929839398394983959839698397983989839998400984019840298403984049840598406984079840898409984109841198412984139841498415984169841798418984199842098421984229842398424984259842698427984289842998430984319843298433984349843598436984379843898439984409844198442984439844498445984469844798448984499845098451984529845398454984559845698457984589845998460984619846298463984649846598466984679846898469984709847198472984739847498475984769847798478984799848098481984829848398484984859848698487984889848998490984919849298493984949849598496984979849898499985009850198502985039850498505985069850798508985099851098511985129851398514985159851698517985189851998520985219852298523985249852598526985279852898529985309853198532985339853498535985369853798538985399854098541985429854398544985459854698547985489854998550985519855298553985549855598556985579855898559985609856198562985639856498565985669856798568985699857098571985729857398574985759857698577985789857998580985819858298583985849858598586985879858898589985909859198592985939859498595985969859798598985999860098601986029860398604986059860698607986089860998610986119861298613986149861598616986179861898619986209862198622986239862498625986269862798628986299863098631986329863398634986359863698637986389863998640986419864298643986449864598646986479864898649986509865198652986539865498655986569865798658986599866098661986629866398664986659866698667986689866998670986719867298673986749867598676986779867898679986809868198682986839868498685986869868798688986899869098691986929869398694986959869698697986989869998700987019870298703987049870598706987079870898709987109871198712987139871498715987169871798718987199872098721987229872398724987259872698727987289872998730987319873298733987349873598736987379873898739987409874198742987439874498745987469874798748987499875098751987529875398754987559875698757987589875998760987619876298763987649876598766987679876898769987709877198772987739877498775987769877798778987799878098781987829878398784987859878698787987889878998790987919879298793987949879598796987979879898799988009880198802988039880498805988069880798808988099881098811988129881398814988159881698817988189881998820988219882298823988249882598826988279882898829988309883198832988339883498835988369883798838988399884098841988429884398844988459884698847988489884998850988519885298853988549885598856988579885898859988609886198862988639886498865988669886798868988699887098871988729887398874988759887698877988789887998880988819888298883988849888598886988879888898889988909889198892988939889498895988969889798898988999890098901989029890398904989059890698907989089890998910989119891298913989149891598916989179891898919989209892198922989239892498925989269892798928989299893098931989329893398934989359893698937989389893998940989419894298943989449894598946989479894898949989509895198952989539895498955989569895798958989599896098961989629896398964989659896698967989689896998970989719897298973989749897598976989779897898979989809898198982989839898498985989869898798988989899899098991989929899398994989959899698997989989899999000990019900299003990049900599006990079900899009990109901199012990139901499015990169901799018990199902099021990229902399024990259902699027990289902999030990319903299033990349903599036990379903899039990409904199042990439904499045990469904799048990499905099051990529905399054990559905699057990589905999060990619906299063990649906599066990679906899069990709907199072990739907499075990769907799078990799908099081990829908399084990859908699087990889908999090990919909299093990949909599096990979909899099991009910199102991039910499105991069910799108991099911099111991129911399114991159911699117991189911999120991219912299123991249912599126991279912899129991309913199132991339913499135991369913799138991399914099141991429914399144991459914699147991489914999150991519915299153991549915599156991579915899159991609916199162991639916499165991669916799168991699917099171991729917399174991759917699177991789917999180991819918299183991849918599186991879918899189991909919199192991939919499195991969919799198991999920099201992029920399204992059920699207992089920999210992119921299213992149921599216992179921899219992209922199222992239922499225992269922799228992299923099231992329923399234992359923699237992389923999240992419924299243992449924599246992479924899249992509925199252992539925499255992569925799258992599926099261992629926399264992659926699267992689926999270992719927299273992749927599276992779927899279992809928199282992839928499285992869928799288992899929099291992929929399294992959929699297992989929999300993019930299303993049930599306993079930899309993109931199312993139931499315993169931799318993199932099321993229932399324993259932699327993289932999330993319933299333993349933599336993379933899339993409934199342993439934499345993469934799348993499935099351993529935399354993559935699357993589935999360993619936299363993649936599366993679936899369993709937199372993739937499375993769937799378993799938099381993829938399384993859938699387993889938999390993919939299393993949939599396993979939899399994009940199402994039940499405994069940799408994099941099411994129941399414994159941699417994189941999420994219942299423994249942599426994279942899429994309943199432994339943499435994369943799438994399944099441994429944399444994459944699447994489944999450994519945299453994549945599456994579945899459994609946199462994639946499465994669946799468994699947099471994729947399474994759947699477994789947999480994819948299483994849948599486994879948899489994909949199492994939949499495994969949799498994999950099501995029950399504995059950699507995089950999510995119951299513995149951599516995179951899519995209952199522995239952499525995269952799528995299953099531995329953399534995359953699537995389953999540995419954299543995449954599546995479954899549995509955199552995539955499555995569955799558995599956099561995629956399564995659956699567995689956999570995719957299573995749957599576995779957899579995809958199582995839958499585995869958799588995899959099591995929959399594995959959699597995989959999600996019960299603996049960599606996079960899609996109961199612996139961499615996169961799618996199962099621996229962399624996259962699627996289962999630996319963299633996349963599636996379963899639996409964199642996439964499645996469964799648996499965099651996529965399654996559965699657996589965999660996619966299663996649966599666996679966899669996709967199672996739967499675996769967799678996799968099681996829968399684996859968699687996889968999690996919969299693996949969599696996979969899699997009970199702997039970499705997069970799708997099971099711997129971399714997159971699717997189971999720997219972299723997249972599726997279972899729997309973199732997339973499735997369973799738997399974099741997429974399744997459974699747997489974999750997519975299753997549975599756997579975899759997609976199762997639976499765997669976799768997699977099771997729977399774997759977699777997789977999780997819978299783997849978599786997879978899789997909979199792997939979499795997969979799798997999980099801998029980399804998059980699807998089980999810998119981299813998149981599816998179981899819998209982199822998239982499825998269982799828998299983099831998329983399834998359983699837998389983999840998419984299843998449984599846998479984899849998509985199852998539985499855998569985799858998599986099861998629986399864998659986699867998689986999870998719987299873998749987599876998779987899879998809988199882998839988499885998869988799888998899989099891998929989399894998959989699897998989989999900999019990299903999049990599906999079990899909999109991199912999139991499915999169991799918999199992099921999229992399924999259992699927999289992999930999319993299933999349993599936999379993899939999409994199942999439994499945999469994799948999499995099951999529995399954999559995699957999589995999960999619996299963999649996599966999679996899969999709997199972999739997499975999769997799978999799998099981999829998399984999859998699987999889998999990999919999299993999949999599996999979999899999100000100001100002100003100004100005100006100007100008100009100010100011100012100013100014100015100016100017100018100019100020100021100022100023100024100025100026100027100028100029100030100031100032100033100034100035100036100037100038100039100040100041100042100043100044100045100046100047100048100049100050100051100052100053100054100055100056100057100058100059100060100061100062100063100064100065100066100067100068100069100070100071100072100073100074100075100076100077100078100079100080100081100082100083100084100085100086100087100088100089100090100091100092100093100094100095100096100097100098100099100100100101100102100103100104100105100106100107100108100109100110100111100112100113100114100115100116100117100118100119100120100121100122100123100124100125100126100127100128100129100130100131100132100133100134100135100136100137100138100139100140100141100142100143100144100145100146100147100148100149100150100151100152100153100154100155100156100157100158100159100160100161100162100163100164100165100166100167100168100169100170100171100172100173100174100175100176100177100178100179100180100181100182100183100184100185100186100187100188100189100190100191100192100193100194100195100196100197100198100199100200100201100202100203100204100205100206100207100208100209100210100211100212100213100214100215100216100217100218100219100220100221100222100223100224100225100226100227100228100229100230100231100232100233100234100235100236100237100238100239100240100241100242100243100244100245100246100247100248100249100250100251100252100253100254100255100256100257100258100259100260100261100262100263100264100265100266100267100268100269100270100271100272100273100274100275100276100277100278100279100280100281100282100283100284100285100286100287100288100289100290100291100292100293100294100295100296100297100298100299100300100301100302100303100304100305100306100307100308100309100310100311100312100313100314100315100316100317100318100319100320100321100322100323100324100325100326100327100328100329100330100331100332100333100334100335100336100337100338100339100340100341100342100343100344100345100346100347100348100349100350100351100352100353100354100355100356100357100358100359100360100361100362100363100364100365100366100367100368100369100370100371100372100373100374100375100376100377100378100379100380100381100382100383100384100385100386100387100388100389100390100391100392100393100394100395100396100397100398100399100400100401100402100403100404100405100406100407100408100409100410100411100412100413100414100415100416100417100418100419100420100421100422100423100424100425100426100427100428100429100430100431100432100433100434100435100436100437100438100439100440100441100442100443100444100445100446100447100448100449100450100451100452100453100454100455100456100457100458100459100460100461100462100463100464100465100466100467100468100469100470100471100472100473100474100475100476100477100478100479100480100481100482100483100484100485100486100487100488100489100490100491100492100493100494100495100496100497100498100499100500100501100502100503100504100505100506100507100508100509100510100511100512100513100514100515100516100517100518100519100520100521100522100523100524100525100526100527100528100529100530100531100532100533100534100535100536100537100538100539100540100541100542100543100544100545100546100547100548100549100550100551100552100553100554100555100556100557100558100559100560100561100562100563100564100565100566100567100568100569100570100571100572100573100574100575100576100577100578100579100580100581100582100583100584100585100586100587100588100589100590100591100592100593100594100595100596100597100598100599100600100601100602100603100604100605100606100607100608100609100610100611100612100613100614100615100616100617100618100619100620100621100622100623100624100625100626100627100628100629100630100631100632100633100634100635100636100637100638100639100640100641100642100643100644100645100646100647100648100649100650100651100652100653100654100655100656100657100658100659100660100661100662100663100664100665100666100667100668100669100670100671100672100673100674100675100676100677100678100679100680100681100682100683100684100685100686100687100688100689100690100691100692100693100694100695100696100697100698100699100700100701100702100703100704100705100706100707100708100709100710100711100712100713100714100715100716100717100718100719100720100721100722100723100724100725100726100727100728100729100730100731100732100733100734100735100736100737100738100739100740100741100742100743100744100745100746100747100748100749100750100751100752100753100754100755100756100757100758100759100760100761100762100763100764100765100766100767100768100769100770100771100772100773100774100775100776100777100778100779100780100781100782100783100784100785100786100787100788100789100790100791100792100793100794100795100796100797100798100799100800100801100802100803100804100805100806100807100808100809100810100811100812100813100814100815100816100817100818100819100820100821100822100823100824100825100826100827100828100829100830100831100832100833100834100835100836100837100838100839100840100841100842100843100844100845100846100847100848100849100850100851100852100853100854100855100856100857100858100859100860100861100862100863100864100865100866100867100868100869100870100871100872100873100874100875100876100877100878100879100880100881100882100883100884100885100886100887100888100889100890100891100892100893100894100895100896100897100898100899100900100901100902100903100904100905100906100907100908100909100910100911100912100913100914100915100916100917100918100919100920100921100922100923100924100925100926100927100928100929100930100931100932100933100934100935100936100937100938100939100940100941100942100943100944100945100946100947100948100949100950100951100952100953100954100955100956100957100958100959100960100961100962100963100964100965100966100967100968100969100970100971100972100973100974100975100976100977100978100979100980100981100982100983100984100985100986100987100988100989100990100991100992100993100994100995100996100997100998100999101000101001101002101003101004101005101006101007101008101009101010101011101012101013101014101015101016101017101018101019101020101021101022101023101024101025101026101027101028101029101030101031101032101033101034101035101036101037101038101039101040101041101042101043101044101045101046101047101048101049101050101051101052101053101054101055101056101057101058101059101060101061101062101063101064101065101066101067101068101069101070101071101072101073101074101075101076101077101078101079101080101081101082101083101084101085101086101087101088101089101090101091101092101093101094101095101096101097101098101099101100101101101102101103101104101105101106101107101108101109101110101111101112101113101114101115101116101117101118101119101120101121101122101123101124101125101126101127101128101129101130101131101132101133101134101135101136101137101138101139101140101141101142101143101144101145101146101147101148101149101150101151101152101153101154101155101156101157101158101159101160101161101162101163101164101165101166101167101168101169101170101171101172101173101174101175101176101177101178101179101180101181101182101183101184101185101186101187101188101189101190101191101192101193101194101195101196101197101198101199101200101201101202101203101204101205101206101207101208101209101210101211101212101213101214101215101216101217101218101219101220101221101222101223101224101225101226101227101228101229101230101231101232101233101234101235101236101237101238101239101240101241101242101243101244101245101246101247101248101249101250101251101252101253101254101255101256101257101258101259101260101261101262101263101264101265101266101267101268101269101270101271101272101273101274101275101276101277101278101279101280101281101282101283101284101285101286101287101288101289101290101291101292101293101294101295101296101297101298101299101300101301101302101303101304101305101306101307101308101309101310101311101312101313101314101315101316101317101318101319101320101321101322101323101324101325101326101327101328101329101330101331101332101333101334101335101336101337101338101339101340101341101342101343101344101345101346101347101348101349101350101351101352101353101354101355101356101357101358101359101360101361101362101363101364101365101366101367101368101369101370101371101372101373101374101375101376101377101378101379101380101381101382101383101384101385101386101387101388101389101390101391101392101393101394101395101396101397101398101399101400101401101402101403101404101405101406101407101408101409101410101411101412101413101414101415101416101417101418101419101420101421101422101423101424101425101426101427101428101429101430101431101432101433101434101435101436101437101438101439101440101441101442101443101444101445101446101447101448101449101450101451101452101453101454101455101456101457101458101459101460101461101462101463101464101465101466101467101468101469101470101471101472101473101474101475101476101477101478101479101480101481101482101483101484101485101486101487101488101489101490101491101492101493101494101495101496101497101498101499101500101501101502101503101504101505101506101507101508101509101510101511101512101513101514101515101516101517101518101519101520101521101522101523101524101525101526101527101528101529101530101531101532101533101534101535101536101537101538101539101540101541101542101543101544101545101546101547101548101549101550101551101552101553101554101555101556101557101558101559101560101561101562101563101564101565101566101567101568101569101570101571101572101573101574101575101576101577101578101579101580101581101582101583101584101585101586101587101588101589101590101591101592101593101594101595101596101597101598101599101600101601101602101603101604101605101606101607101608101609101610101611101612101613101614101615101616101617101618101619101620101621101622101623101624101625101626101627101628101629101630101631101632101633101634101635101636101637101638101639101640101641101642101643101644101645101646101647101648101649101650101651101652101653101654101655101656101657101658101659101660101661101662101663101664101665101666101667101668101669101670101671101672101673101674101675101676101677101678101679101680101681101682101683101684101685101686101687101688101689101690101691101692101693101694101695101696101697101698101699101700101701101702101703101704101705101706101707101708101709101710101711101712101713101714101715101716101717101718101719101720101721101722101723101724101725101726101727101728101729101730101731101732101733101734101735101736101737101738101739101740101741101742101743101744101745101746101747101748101749101750101751101752101753101754101755101756101757101758101759101760101761101762101763101764101765101766101767101768101769101770101771101772101773101774101775101776101777101778101779101780101781101782101783101784101785101786101787101788101789101790101791101792101793101794101795101796101797101798101799101800101801101802101803101804101805101806101807101808101809101810101811101812101813101814101815101816101817101818101819101820101821101822101823101824101825101826101827101828101829101830101831101832101833101834101835101836101837101838101839101840101841101842101843101844101845101846101847101848101849101850101851101852101853101854101855101856101857101858101859101860101861101862101863101864101865101866101867101868101869101870101871101872101873101874101875101876101877101878101879101880101881101882101883101884101885101886101887101888101889101890101891101892101893101894101895101896101897101898101899101900101901101902101903101904101905101906101907101908101909101910101911101912101913101914101915101916101917101918101919101920101921101922101923101924101925101926101927101928101929101930101931101932101933101934101935101936101937101938101939101940101941101942101943101944101945101946101947101948101949101950101951101952101953101954101955101956101957101958101959101960101961101962101963101964101965101966101967101968101969101970101971101972101973101974101975101976101977101978101979101980101981101982101983101984101985101986101987101988101989101990101991101992101993101994101995101996101997101998101999102000102001102002102003102004102005102006102007102008102009102010102011102012102013102014102015102016102017102018102019102020102021102022102023102024102025102026102027102028102029102030102031102032102033102034102035102036102037102038102039102040102041102042102043102044102045102046102047102048102049102050102051102052102053102054102055102056102057102058102059102060102061102062102063102064102065102066102067102068102069102070102071102072102073102074102075102076102077102078102079102080102081102082102083102084102085102086102087102088102089102090102091102092102093102094102095102096102097102098102099102100102101102102102103102104102105102106102107102108102109102110102111102112102113102114102115102116102117102118102119102120102121102122102123102124102125102126102127102128102129102130102131102132102133102134102135102136102137102138102139102140102141102142102143102144102145102146102147102148102149102150102151102152102153102154102155102156102157102158102159102160102161102162102163102164102165102166102167102168102169102170102171102172102173102174102175102176102177102178102179102180102181102182102183102184102185102186102187102188102189102190102191102192102193102194102195102196102197102198102199102200102201102202102203102204102205102206102207102208102209102210102211102212102213102214102215102216102217102218102219102220102221102222102223102224102225102226102227102228102229102230102231102232102233102234102235102236102237102238102239102240102241102242102243102244102245102246102247102248102249102250102251102252102253102254102255102256102257102258102259102260102261102262102263102264102265102266102267102268102269102270102271102272102273102274102275102276102277102278102279102280102281102282102283102284102285102286102287102288102289102290102291102292102293102294102295102296102297102298102299102300102301102302102303102304102305102306102307102308102309102310102311102312102313102314102315102316102317102318102319102320102321102322102323102324102325102326102327102328102329102330102331102332102333102334102335102336102337102338102339102340102341102342102343102344102345102346102347102348102349102350102351102352102353102354102355102356102357102358102359102360102361102362102363102364102365102366102367102368102369102370102371102372102373102374102375102376102377102378102379102380102381102382102383102384102385102386102387102388102389102390102391102392102393102394102395102396102397102398102399102400102401102402102403102404102405102406102407102408102409102410102411102412102413102414102415102416102417102418102419102420102421102422102423102424102425102426102427102428102429102430102431102432102433102434102435102436102437102438102439102440102441102442102443102444102445102446102447102448102449102450102451102452102453102454102455102456102457102458102459102460102461102462102463102464102465102466102467102468102469102470102471102472102473102474102475102476102477102478102479102480102481102482102483102484102485102486102487102488102489102490102491102492102493102494102495102496102497102498102499102500102501102502102503102504102505102506102507102508102509102510102511102512102513102514102515102516102517102518102519102520102521102522102523102524102525102526102527102528102529102530102531102532102533102534102535102536102537102538102539102540102541102542102543102544102545102546102547102548102549102550102551102552102553102554102555102556102557102558102559102560102561102562102563102564102565102566102567102568102569102570102571102572102573102574102575102576102577102578102579102580102581102582102583102584102585102586102587102588102589102590102591102592102593102594102595102596102597102598102599102600102601102602102603102604102605102606102607102608102609102610102611102612102613102614102615102616102617102618102619102620102621102622102623102624102625102626102627102628102629102630102631102632102633102634102635102636102637102638102639102640102641102642102643102644102645102646102647102648102649102650102651102652102653102654102655102656102657102658102659102660102661102662102663102664102665102666102667102668102669102670102671102672102673102674102675102676102677102678102679102680102681102682102683102684102685102686102687102688102689102690102691102692102693102694102695102696102697102698102699102700102701102702102703102704102705102706102707102708102709102710102711102712102713102714102715102716102717102718102719102720102721102722102723102724102725102726102727102728102729102730102731102732102733102734102735102736102737102738102739102740102741102742102743102744102745102746102747102748102749102750102751102752102753102754102755102756102757102758102759102760102761102762102763102764102765102766102767102768102769102770102771102772102773102774102775102776102777102778102779102780102781102782102783102784102785102786102787102788102789102790102791102792102793102794102795102796102797102798102799102800102801102802102803102804102805102806102807102808102809102810102811102812102813102814102815102816102817102818102819102820102821102822102823102824102825102826102827102828102829102830102831102832102833102834102835102836102837102838102839102840102841102842102843102844102845102846102847102848102849102850102851102852102853102854102855102856102857102858102859102860102861102862102863102864102865102866102867102868102869102870102871102872102873102874102875102876102877102878102879102880102881102882102883102884102885102886102887102888102889102890102891102892102893102894102895102896102897102898102899102900102901102902102903102904102905102906102907102908102909102910102911102912102913102914102915102916102917102918102919102920102921102922102923102924102925102926102927102928102929102930102931102932102933102934102935102936102937102938102939102940102941102942102943102944102945102946102947102948102949102950102951102952102953102954102955102956102957102958102959102960102961102962102963102964102965102966102967102968102969102970102971102972102973102974102975102976102977102978102979102980102981102982102983102984102985102986102987102988102989102990102991102992102993102994102995102996102997102998102999103000103001103002103003103004103005103006103007103008103009103010103011103012103013103014103015103016103017103018103019103020103021103022103023103024103025103026103027103028103029103030103031103032103033103034103035103036103037103038103039103040103041103042103043103044103045103046103047103048103049103050103051103052103053103054103055103056103057103058103059103060103061103062103063103064103065103066103067103068103069103070103071103072103073103074103075103076103077103078103079103080103081103082103083103084103085103086103087103088103089103090103091103092103093103094103095103096103097103098103099103100103101103102103103103104103105103106103107103108103109103110103111103112103113103114103115103116103117103118103119103120103121103122103123103124103125103126103127103128103129103130103131103132103133103134103135103136103137103138103139103140103141103142103143103144103145103146103147103148103149103150103151103152103153103154103155103156103157103158103159103160103161103162103163103164103165103166103167103168103169103170103171103172103173103174103175103176103177103178103179103180103181103182103183103184103185103186103187103188103189103190103191103192103193103194103195103196103197103198103199103200103201103202103203103204103205103206103207103208103209103210103211103212103213103214103215103216103217103218103219103220103221103222103223103224103225103226103227103228103229103230103231103232103233103234103235103236103237103238103239103240103241103242103243103244103245103246103247103248103249103250103251103252103253103254103255103256103257103258103259103260103261103262103263103264103265103266103267103268103269103270103271103272103273103274103275103276103277103278103279103280103281103282103283103284103285103286103287103288103289103290103291103292103293103294103295103296103297103298103299103300103301103302103303103304103305103306103307103308103309103310103311103312103313103314103315103316103317103318103319103320103321103322103323103324103325103326103327103328103329103330103331103332103333103334103335103336103337103338103339103340103341103342103343103344103345103346103347103348103349103350103351103352103353103354103355103356103357103358103359103360103361103362103363103364103365103366103367103368103369103370103371103372103373103374103375103376103377103378103379103380103381103382103383103384103385103386103387103388103389103390103391103392103393103394103395103396103397103398103399103400103401103402103403103404103405103406103407103408103409103410103411103412103413103414103415103416103417103418103419103420103421103422103423103424103425103426103427103428103429103430103431103432103433103434103435103436103437103438103439103440103441103442103443103444103445103446103447103448103449103450103451103452103453103454103455103456103457103458103459103460103461103462103463103464103465103466103467103468103469103470103471103472103473103474103475103476103477103478103479103480103481103482103483103484103485103486103487103488103489103490103491103492103493103494103495103496103497103498103499103500103501103502103503103504103505103506103507103508103509103510103511103512103513103514103515103516103517103518103519103520103521103522103523103524103525103526103527103528103529103530103531103532103533103534103535103536103537103538103539103540103541103542103543103544103545103546103547103548103549103550103551103552103553103554103555103556103557103558103559103560103561103562103563103564103565103566103567103568103569103570103571103572103573103574103575103576103577103578103579103580103581103582103583103584103585103586103587103588103589103590103591103592103593103594103595103596103597103598103599103600103601103602103603103604103605103606103607103608103609103610103611103612103613103614103615103616103617103618103619103620103621103622103623103624103625103626103627103628103629103630103631103632103633103634103635103636103637103638103639103640103641103642103643103644103645103646103647103648103649103650103651103652103653103654103655103656103657103658103659103660103661103662103663103664103665103666103667103668103669103670103671103672103673103674103675103676103677103678103679103680103681103682103683103684103685103686103687103688103689103690103691103692103693103694103695103696103697103698103699103700103701103702103703103704103705103706103707103708103709103710103711103712103713103714103715103716103717103718103719103720103721103722103723103724103725103726103727103728103729103730103731103732103733103734103735103736103737103738103739103740103741103742103743103744103745103746103747103748103749103750103751103752103753103754103755103756103757103758103759103760103761103762103763103764103765103766103767103768103769103770103771103772103773103774103775103776103777103778103779103780103781103782103783103784103785103786103787103788103789103790103791103792103793103794103795103796103797103798103799103800103801103802103803103804103805103806103807103808103809103810103811103812103813103814103815103816103817103818103819103820103821103822103823103824103825103826103827103828103829103830103831103832103833103834103835103836103837103838103839103840103841103842103843103844103845103846103847103848103849103850103851103852103853103854103855103856103857103858103859103860103861103862103863103864103865103866103867103868103869103870103871103872103873103874103875103876103877103878103879103880103881103882103883103884103885103886103887103888103889103890103891103892103893103894103895103896103897103898103899103900103901103902103903103904103905103906103907103908103909103910103911103912103913103914103915103916103917103918103919103920103921103922103923103924103925103926103927103928103929103930103931103932103933103934103935103936103937103938103939103940103941103942103943103944103945103946103947103948103949103950103951103952103953103954103955103956103957103958103959103960103961103962103963103964103965103966103967103968103969103970103971103972103973103974103975103976103977103978103979103980103981103982103983103984103985103986103987103988103989103990103991103992103993103994103995103996103997103998103999104000104001104002104003104004104005104006104007104008104009104010104011104012104013104014104015104016104017104018104019104020104021104022104023104024104025104026104027104028104029104030104031104032104033104034104035104036104037104038104039104040104041104042104043104044104045104046104047104048104049104050104051104052104053104054104055104056104057104058104059104060104061104062104063104064104065104066104067104068104069104070104071104072104073104074104075104076104077104078104079104080104081104082104083104084104085104086104087104088104089104090104091104092104093104094104095104096104097104098104099104100104101104102104103104104104105104106104107104108104109104110104111104112104113104114104115104116104117104118104119104120104121104122104123104124104125104126104127104128104129104130104131104132104133104134104135104136104137104138104139104140104141104142104143104144104145104146104147104148104149104150104151104152104153104154104155104156104157104158104159104160104161104162104163104164104165104166104167104168104169104170104171104172104173104174104175104176104177104178104179104180104181104182104183104184104185104186104187104188104189104190104191104192104193104194104195104196104197104198104199104200104201104202104203104204104205104206104207104208104209104210104211104212104213104214104215104216104217104218104219104220104221104222104223104224104225104226104227104228104229104230104231104232104233104234104235104236104237104238104239104240104241104242104243104244104245104246104247104248104249104250104251104252104253104254104255104256104257104258104259104260104261104262104263104264104265104266104267104268104269104270104271104272104273104274104275104276104277104278104279104280104281104282104283104284104285104286104287104288104289104290104291104292104293104294104295104296104297104298104299104300104301104302104303104304104305104306104307104308104309104310104311104312104313104314104315104316104317104318104319104320104321104322104323104324104325104326104327104328104329104330104331104332104333104334104335104336104337104338104339104340104341104342104343104344104345104346104347104348104349104350104351104352104353104354104355104356104357104358104359104360104361104362104363104364104365104366104367104368104369104370104371104372104373104374104375104376104377104378104379104380104381104382104383104384104385104386104387104388104389104390104391104392104393104394104395104396104397104398104399104400104401104402104403104404104405104406104407104408104409104410104411104412104413104414104415104416104417104418104419104420104421104422104423104424104425104426104427104428104429104430104431104432104433104434104435104436104437104438104439104440104441104442104443104444104445104446104447104448104449104450104451104452104453104454104455104456104457104458104459104460104461104462104463104464104465104466104467104468104469104470104471104472104473104474104475104476104477104478104479104480104481104482104483104484104485104486104487104488104489104490104491104492104493104494104495104496104497104498104499104500104501104502104503104504104505104506104507104508104509104510104511104512104513104514104515104516104517104518104519104520104521104522104523104524104525104526104527104528104529104530104531104532104533104534104535104536104537104538104539104540104541104542104543104544104545104546104547104548104549104550104551104552104553104554104555104556104557104558104559104560104561104562104563104564104565104566104567104568104569104570104571104572104573104574104575104576104577104578104579104580104581104582104583104584104585104586104587104588104589104590104591104592104593104594104595104596104597104598104599104600104601104602104603104604104605104606104607104608104609104610104611104612104613104614104615104616104617104618104619104620104621104622104623104624104625104626104627104628104629104630104631104632104633104634104635104636104637104638104639104640104641104642104643104644104645104646104647104648104649104650104651104652104653104654104655104656104657104658104659104660104661104662104663104664104665104666104667104668104669104670104671104672104673104674104675104676104677104678104679104680104681104682104683104684104685104686104687104688104689104690104691104692104693104694104695104696104697104698104699104700104701104702104703104704104705104706104707104708104709104710104711104712104713104714104715104716104717104718104719104720104721104722104723104724104725104726104727104728104729104730104731104732104733104734104735104736104737104738104739104740104741104742104743104744104745104746104747104748104749104750104751104752104753104754104755104756104757104758104759104760104761104762104763104764104765104766104767104768104769104770104771104772104773104774104775104776104777104778104779104780104781104782104783104784104785104786104787104788104789104790104791104792104793104794104795104796104797104798104799104800104801104802104803104804104805104806104807104808104809104810104811104812104813104814104815104816104817104818104819104820104821104822104823104824104825104826104827104828104829104830104831104832104833104834104835104836104837104838104839104840104841104842104843104844104845104846104847104848104849104850104851104852104853104854104855104856104857104858104859104860104861104862104863104864104865104866104867104868104869104870104871104872104873104874104875104876104877104878104879104880104881104882104883104884104885104886104887104888104889104890104891104892104893104894104895104896104897104898104899104900104901104902104903104904104905104906104907104908104909104910104911104912104913104914104915104916104917104918104919104920104921104922104923104924104925104926104927104928104929104930104931104932104933104934104935104936104937104938104939104940104941104942104943104944104945104946104947104948104949104950104951104952104953104954104955104956104957104958104959104960104961104962104963104964104965104966104967104968104969104970104971104972104973104974104975104976104977104978104979104980104981104982104983104984104985104986104987104988104989104990104991104992104993104994104995104996104997104998104999105000105001105002105003105004105005105006105007105008105009105010105011105012105013105014105015105016105017105018105019105020105021105022105023105024105025105026105027105028105029105030105031105032105033105034105035105036105037105038105039105040105041105042105043105044105045105046105047105048105049105050105051105052105053105054105055105056105057105058105059105060105061105062105063105064105065105066105067105068105069105070105071105072105073105074105075105076105077105078105079105080105081105082105083105084105085105086105087105088105089105090105091105092105093105094105095105096105097105098105099105100105101105102105103105104105105105106105107105108105109105110105111105112105113105114105115105116105117105118105119105120105121105122105123105124105125105126105127105128105129105130105131105132105133105134105135105136105137105138105139105140105141105142105143105144105145105146105147105148105149105150105151105152105153105154105155105156105157105158105159105160105161105162105163105164105165105166105167105168105169105170105171105172105173105174105175105176105177105178105179105180105181105182105183105184105185105186105187105188105189105190105191105192105193105194105195105196105197105198105199105200105201105202105203105204105205105206105207105208105209105210105211105212105213105214105215105216105217105218105219105220105221105222105223105224105225105226105227105228105229105230105231105232105233105234105235105236105237105238105239105240105241105242105243105244105245105246105247105248105249105250105251105252105253105254105255105256105257105258105259105260105261105262105263105264105265105266105267105268105269105270105271105272105273105274105275105276105277105278105279105280105281105282105283105284105285105286105287105288105289105290105291105292105293105294105295105296105297105298105299105300105301105302105303105304105305105306105307105308105309105310105311105312105313105314105315105316105317105318105319105320105321105322105323105324105325105326105327105328105329105330105331105332105333105334105335105336105337105338105339105340105341105342105343105344105345105346105347105348105349105350105351105352105353105354105355105356105357105358105359105360105361105362105363105364105365105366105367105368105369105370105371105372105373105374105375105376105377105378105379105380105381105382105383105384105385105386105387105388105389105390105391105392105393105394105395105396105397105398105399105400105401105402105403105404105405105406105407105408105409105410105411105412105413105414105415105416105417105418105419105420105421105422105423105424105425105426105427105428105429105430105431105432105433105434105435105436105437105438105439105440105441105442105443105444105445105446105447105448105449105450105451105452105453105454105455105456105457105458105459105460105461105462105463105464105465105466105467105468105469105470105471105472105473105474105475105476105477105478105479105480105481105482105483105484105485105486105487105488105489105490105491105492105493105494105495105496105497105498105499105500105501105502105503105504105505105506105507105508105509105510105511105512105513105514105515105516105517105518105519105520105521105522105523105524105525105526105527105528105529105530105531105532105533105534105535105536105537105538105539105540105541105542105543105544105545105546105547105548105549105550105551105552105553105554105555105556105557105558105559105560105561105562105563105564105565105566105567105568105569105570105571105572105573105574105575105576105577105578105579105580105581105582105583105584105585105586105587105588105589105590105591105592105593105594105595105596105597105598105599105600105601105602105603105604105605105606105607105608105609105610105611105612105613105614105615105616105617105618105619105620105621105622105623105624105625105626105627105628105629105630105631105632105633105634105635105636105637105638105639105640105641105642105643105644105645105646105647105648105649105650105651105652105653105654105655105656105657105658105659105660105661105662105663105664105665105666105667105668105669105670105671105672105673105674105675105676105677105678105679105680105681105682105683105684105685105686105687105688105689105690105691105692105693105694105695105696105697105698105699105700105701105702105703105704105705105706105707105708105709105710105711105712105713105714105715105716105717105718105719105720105721105722105723105724105725105726105727105728105729105730105731105732105733105734105735105736105737105738105739105740105741105742105743105744105745105746105747105748105749105750105751105752105753105754105755105756105757105758105759105760105761105762105763105764105765105766105767105768105769105770105771105772105773105774105775105776105777105778105779105780105781105782105783105784105785105786105787105788105789105790105791105792105793105794105795105796105797105798105799105800105801105802105803105804105805105806105807105808105809105810105811105812105813105814105815105816105817105818105819105820105821105822105823105824105825105826105827105828105829105830105831105832105833105834105835105836105837105838105839105840105841105842105843105844105845105846105847105848105849105850105851105852105853105854105855105856105857105858105859105860105861105862105863105864105865105866105867105868105869105870105871105872105873105874105875105876105877105878105879105880105881105882105883105884105885105886105887105888105889105890105891105892105893105894105895105896105897105898105899105900105901105902105903105904105905105906105907105908105909105910105911105912105913105914105915105916105917105918105919105920105921105922105923105924105925105926105927105928105929105930105931105932105933105934105935105936105937105938105939105940105941105942105943105944105945105946105947105948105949105950105951105952105953105954105955105956105957105958105959105960105961105962105963105964105965105966105967105968105969105970105971105972105973105974105975105976105977105978105979105980105981105982105983105984105985105986105987105988105989105990105991105992105993105994105995105996105997105998105999106000106001106002106003106004106005106006106007106008106009106010106011106012106013106014106015106016106017106018106019106020106021106022106023106024106025106026106027106028106029106030106031106032106033106034106035106036106037106038106039106040106041106042106043106044106045106046106047106048106049106050106051106052106053106054106055106056106057106058106059106060106061106062106063106064106065106066106067106068106069106070106071106072106073106074106075106076106077106078106079106080106081106082106083106084106085106086106087106088106089106090106091106092106093106094106095106096106097106098106099106100106101106102106103106104106105106106106107106108106109106110106111106112106113106114106115106116106117106118106119106120106121106122106123106124106125106126106127106128106129106130106131106132106133106134106135106136106137106138106139106140106141106142106143106144106145106146106147106148106149106150106151106152106153106154106155106156106157106158106159106160106161106162106163106164106165106166106167106168106169106170106171106172106173106174106175106176106177106178106179106180106181106182106183106184106185106186106187106188106189106190106191106192106193106194106195106196106197106198106199106200106201106202106203106204106205106206106207106208106209106210106211106212106213106214106215106216106217106218106219106220106221106222106223106224106225106226106227106228106229106230106231106232106233106234106235106236106237106238106239106240106241106242106243106244106245106246106247106248106249106250106251106252106253106254106255106256106257106258106259106260106261106262106263106264106265106266106267106268106269106270106271106272106273106274106275106276106277106278106279106280106281106282106283106284106285106286106287106288106289106290106291106292106293106294106295106296106297106298106299106300106301106302106303106304106305106306106307106308106309106310106311106312106313106314106315106316106317106318106319106320106321106322106323106324106325106326106327106328106329106330106331106332106333106334106335106336106337106338106339106340106341106342106343106344106345106346106347106348106349106350106351106352106353106354106355106356106357106358106359106360106361106362106363106364106365106366106367106368106369106370106371106372106373106374106375106376106377106378106379106380106381106382106383106384106385106386106387106388106389106390106391106392106393106394106395106396106397106398106399106400106401106402106403106404106405106406106407106408106409106410106411106412106413106414106415106416106417106418106419106420106421106422106423106424106425106426106427106428106429106430106431106432106433106434106435106436106437106438106439106440106441106442106443106444106445106446106447106448106449106450106451106452106453106454106455106456106457106458106459106460106461106462106463106464106465106466106467106468106469106470106471106472106473106474106475106476106477106478106479106480106481106482106483106484106485106486106487106488106489106490106491106492106493106494106495106496106497106498106499106500106501106502106503106504106505106506106507106508106509106510106511106512106513106514106515106516106517106518106519106520106521106522106523106524106525106526106527106528106529106530106531106532106533106534106535106536106537106538106539106540106541106542106543106544106545106546106547106548106549106550106551106552106553106554106555106556106557106558106559106560106561106562106563106564106565106566106567106568106569106570106571106572106573106574106575106576106577106578106579106580106581106582106583106584106585106586106587106588106589106590106591106592106593106594106595106596106597106598106599106600106601106602106603106604106605106606106607106608106609106610106611106612106613106614106615106616106617106618106619106620106621106622106623106624106625106626106627106628106629106630106631106632106633106634106635106636106637106638106639106640106641106642106643106644106645106646106647106648106649106650106651106652106653106654106655106656106657106658106659106660106661106662106663106664106665106666106667106668106669106670106671106672106673106674106675106676106677106678106679106680106681106682106683106684106685106686106687106688106689106690106691106692106693106694106695106696106697106698106699106700106701106702106703106704106705106706106707106708106709106710106711106712106713106714106715106716106717106718106719106720106721106722106723106724106725106726106727106728106729106730106731106732106733106734106735106736106737106738106739106740106741106742106743106744106745106746106747106748106749106750106751106752106753106754106755106756106757106758106759106760106761106762106763106764106765106766106767106768106769106770106771106772106773106774106775106776106777106778106779106780106781106782106783106784106785106786106787106788106789106790106791106792106793106794106795106796106797106798106799106800106801106802106803106804106805106806106807106808106809106810106811106812106813106814106815106816106817106818106819106820106821106822106823106824106825106826106827106828106829106830106831106832106833106834106835106836106837106838106839106840106841106842106843106844106845106846106847106848106849106850106851106852106853106854106855106856106857106858106859106860106861106862106863106864106865106866106867106868106869106870106871106872106873106874106875106876106877106878106879106880106881106882106883106884106885106886106887106888106889106890106891106892106893106894106895106896106897106898106899106900106901106902106903106904106905106906106907106908106909106910106911106912106913106914106915106916106917106918106919106920106921106922106923106924106925106926106927106928106929106930106931106932106933106934106935106936106937106938106939106940106941106942106943106944106945106946106947106948106949106950106951106952106953106954106955106956106957106958106959106960106961106962106963106964106965106966106967106968106969106970106971106972106973106974106975106976106977106978106979106980106981106982106983106984106985106986106987106988106989106990106991106992106993106994106995106996106997106998106999107000107001107002107003107004107005107006107007107008107009107010107011107012107013107014107015107016107017107018107019107020107021107022107023107024107025107026107027107028107029107030107031107032107033107034107035107036107037107038107039107040107041107042107043107044107045107046107047107048107049107050107051107052107053107054107055107056107057107058107059107060107061107062107063107064107065107066107067107068107069107070107071107072107073107074107075107076107077107078107079107080107081107082107083107084107085107086107087107088107089107090107091107092107093107094107095107096107097107098107099107100107101107102107103107104107105107106107107107108107109107110107111107112107113107114107115107116107117107118107119107120107121107122107123107124107125107126107127107128107129107130107131107132107133107134107135107136107137107138107139107140107141107142107143107144107145107146107147107148107149107150107151107152107153107154107155107156107157107158107159107160107161107162107163107164107165107166107167107168107169107170107171107172107173107174107175107176107177107178107179107180107181107182107183107184107185107186107187107188107189107190107191107192107193107194107195107196107197107198107199107200107201107202107203107204107205107206107207107208107209107210107211107212107213107214107215107216107217107218107219107220107221107222107223107224107225107226107227107228107229107230107231107232107233107234107235107236107237107238107239107240107241107242107243107244107245107246107247107248107249107250107251107252107253107254107255107256107257107258107259107260107261107262107263107264107265107266107267107268107269107270107271107272107273107274107275107276107277107278107279107280107281107282107283107284107285107286107287107288107289107290107291107292107293107294107295107296107297107298107299107300107301107302107303107304107305107306107307107308107309107310107311107312107313107314107315107316107317107318107319107320107321107322107323107324107325107326107327107328107329107330107331107332107333107334107335107336107337107338107339107340107341107342107343107344107345107346107347107348107349107350107351107352107353107354107355107356107357107358107359107360107361107362107363107364107365107366107367107368107369107370107371107372107373107374107375107376107377107378107379107380107381107382107383107384107385107386107387107388107389107390107391107392107393107394107395107396107397107398107399107400107401107402107403107404107405107406107407107408107409107410107411107412107413107414107415107416107417107418107419107420107421107422107423107424107425107426107427107428107429107430107431107432107433107434107435107436107437107438107439107440107441107442107443107444107445107446107447107448107449107450107451107452107453107454107455107456107457107458107459107460107461107462107463107464107465107466107467107468107469107470107471107472107473107474107475107476107477107478107479107480107481107482107483107484107485107486107487107488107489107490107491107492107493107494107495107496107497107498107499107500107501107502107503107504107505107506107507107508107509107510107511107512107513107514107515107516107517107518107519107520107521107522107523107524107525107526107527107528107529107530107531107532107533107534107535107536107537107538107539107540107541107542107543107544107545107546107547107548107549107550107551107552107553107554107555107556107557107558107559107560107561107562107563107564107565107566107567107568107569107570107571107572107573107574107575107576107577107578107579107580107581107582107583107584107585107586107587107588107589107590107591107592107593107594107595107596107597107598107599107600107601107602107603107604107605107606107607107608107609107610107611107612107613107614107615107616107617107618107619107620107621107622107623107624107625107626107627107628107629107630107631107632107633107634107635107636107637107638107639107640107641107642107643107644107645107646107647107648107649107650107651107652107653107654107655107656107657107658107659107660107661107662107663107664107665107666107667107668107669107670107671107672107673107674107675107676107677107678107679107680107681107682107683107684107685107686107687107688107689107690107691107692107693107694107695107696107697107698107699107700107701107702107703107704107705107706107707107708107709107710107711107712107713107714107715107716107717107718107719107720107721107722107723107724107725107726107727107728107729107730107731107732107733107734107735107736107737107738107739107740107741107742107743107744107745107746107747107748107749107750107751107752107753107754107755107756107757107758107759107760107761107762107763107764107765107766107767107768107769107770107771107772107773107774107775107776107777107778107779107780107781107782107783107784107785107786107787107788107789107790107791107792107793107794107795107796107797107798107799107800107801107802107803107804107805107806107807107808107809107810107811107812107813107814107815107816107817107818107819107820107821107822107823107824107825107826107827107828107829107830107831107832107833107834107835107836107837107838107839107840107841107842107843107844107845107846107847107848107849107850107851107852107853107854107855107856107857107858107859107860107861107862107863107864107865107866107867107868107869107870107871107872107873107874107875107876107877107878107879107880107881107882107883107884107885107886107887107888107889107890107891107892107893107894107895107896107897107898107899107900107901107902107903107904107905107906107907107908107909107910107911107912107913107914107915107916107917107918107919107920107921107922107923107924107925107926107927107928107929107930107931107932107933107934107935107936107937107938107939107940107941107942107943107944107945107946107947107948107949107950107951107952107953107954107955107956107957107958107959107960107961107962107963107964107965107966107967107968107969107970107971107972107973107974107975107976107977107978107979107980107981107982107983107984107985107986107987107988107989107990107991107992107993107994107995107996107997107998107999108000108001108002108003108004108005108006108007108008108009108010108011108012108013108014108015108016108017108018108019108020108021108022108023108024108025108026108027108028108029108030108031108032108033108034108035108036108037108038108039108040108041108042108043108044108045108046108047108048108049108050108051108052108053108054108055108056108057108058108059108060108061108062108063108064108065108066108067108068108069108070108071108072108073108074108075108076108077108078108079108080108081108082108083108084108085108086108087108088108089108090108091108092108093108094108095108096108097108098108099108100108101108102108103108104108105108106108107108108108109108110108111108112108113108114108115108116108117108118108119108120108121108122108123108124108125108126108127108128108129108130108131108132108133108134108135108136108137108138108139108140108141108142108143108144108145108146108147108148108149108150108151108152108153108154108155108156108157108158108159108160108161108162108163108164108165108166108167108168108169108170108171108172108173108174108175108176108177108178108179108180108181108182108183108184108185108186108187108188108189108190108191108192108193108194108195108196108197108198108199108200108201108202108203108204108205108206108207108208108209108210108211108212108213108214108215108216108217108218108219108220108221108222108223108224108225108226108227108228108229108230108231108232108233108234108235108236108237108238108239108240108241108242108243108244108245108246108247108248108249108250108251108252108253108254108255108256108257108258108259108260108261108262108263108264108265108266108267108268108269108270108271108272108273108274108275108276108277108278108279108280108281108282108283108284108285108286108287108288108289108290108291108292108293108294108295108296108297108298108299108300108301108302108303108304108305108306108307108308108309108310108311108312108313108314108315108316108317108318108319108320108321108322108323108324108325108326108327108328108329108330108331108332108333108334108335108336108337108338108339108340108341108342108343108344108345108346108347108348108349108350108351108352108353108354108355108356108357108358108359108360108361108362108363108364108365108366108367108368108369108370108371108372108373108374108375108376108377108378108379108380108381108382108383108384108385108386108387108388108389108390108391108392108393108394108395108396108397108398108399108400108401108402108403108404108405108406108407108408108409108410108411108412108413108414108415108416108417108418108419108420108421108422108423108424108425108426108427108428108429108430108431108432108433108434108435108436108437108438108439108440108441108442108443108444108445108446108447108448108449108450108451108452108453108454108455108456108457108458108459108460108461108462108463108464108465108466108467108468108469108470108471108472108473108474108475108476108477108478108479108480108481108482108483108484108485108486108487108488108489108490108491108492108493108494108495108496108497108498108499108500108501108502108503108504108505108506108507108508108509108510108511108512108513108514108515108516108517108518108519108520108521108522108523108524108525108526108527108528108529108530108531108532108533108534108535108536108537108538108539108540108541108542108543108544108545108546108547108548108549108550108551108552108553108554108555108556108557108558108559108560108561108562108563108564108565108566108567108568108569108570108571108572108573108574108575108576108577108578108579108580108581108582108583108584108585108586108587108588108589108590108591108592108593108594108595108596108597108598108599108600108601108602108603108604108605108606108607108608108609108610108611108612108613108614108615108616108617108618108619108620108621108622108623108624108625108626108627108628108629108630108631108632108633108634108635108636108637108638108639108640108641108642108643108644108645108646108647108648108649108650108651108652108653108654108655108656108657108658108659108660108661108662108663108664108665108666108667108668108669108670108671108672108673108674108675108676108677108678108679108680108681108682108683108684108685108686108687108688108689108690108691108692108693108694108695108696108697108698108699108700108701108702108703108704108705108706108707108708108709108710108711108712108713108714108715108716108717108718108719108720108721108722108723108724108725108726108727108728108729108730108731108732108733108734108735108736108737108738108739108740108741108742108743108744108745108746108747108748108749108750108751108752108753108754108755108756108757108758108759108760108761108762108763108764108765108766108767108768108769108770108771108772108773108774108775108776108777108778108779108780108781108782108783108784108785108786108787108788108789108790108791108792108793108794108795108796108797108798108799108800108801108802108803108804108805108806108807108808108809108810108811108812108813108814108815108816108817108818108819108820108821108822108823108824108825108826108827108828108829108830108831108832108833108834108835108836108837108838108839108840108841108842108843108844108845108846108847108848108849108850108851108852108853108854108855108856108857108858108859108860108861108862108863108864108865108866108867108868108869108870108871108872108873108874108875108876108877108878108879108880108881108882108883108884108885108886108887108888108889108890108891108892108893108894108895108896108897108898108899108900108901108902108903108904108905108906108907108908108909108910108911108912108913108914108915108916108917108918108919108920108921108922108923108924108925108926108927108928108929108930108931108932108933108934108935108936108937108938108939108940108941108942108943108944108945108946108947108948108949108950108951108952108953108954108955108956108957108958108959108960108961108962108963108964108965108966108967108968108969108970108971108972108973108974108975108976108977108978108979108980108981108982108983108984108985108986108987108988108989108990108991108992108993108994108995108996108997108998108999109000109001109002109003109004109005109006109007109008109009109010109011109012109013109014109015109016109017109018109019109020109021109022109023109024109025109026109027109028109029109030109031109032109033109034109035109036109037109038109039109040109041109042109043109044109045109046109047109048109049109050109051109052109053109054109055109056109057109058109059109060109061109062109063109064109065109066109067109068109069109070109071109072109073109074109075109076109077109078109079109080109081109082109083109084109085109086109087109088109089109090109091109092109093109094109095109096109097109098109099109100109101109102109103109104109105109106109107109108109109109110109111109112109113109114109115109116109117109118109119109120109121109122109123109124109125109126109127109128109129109130109131109132109133109134109135109136109137109138109139109140109141109142109143109144109145109146109147109148109149109150109151109152109153109154109155109156109157109158109159109160109161109162109163109164109165109166109167109168109169109170109171109172109173109174109175109176109177109178109179109180109181109182109183109184109185109186109187109188109189109190109191109192109193109194109195109196109197109198109199109200109201109202109203109204109205109206109207109208109209109210109211109212109213109214109215109216109217109218109219109220109221109222109223109224109225109226109227109228109229109230109231109232109233109234109235109236109237109238109239109240109241109242109243109244109245109246109247109248109249109250109251109252109253109254109255109256109257109258109259109260109261109262109263109264109265109266109267109268109269109270109271109272109273109274109275109276109277109278109279109280109281109282109283109284109285109286109287109288109289109290109291109292109293109294109295109296109297109298109299109300109301109302109303109304109305109306109307109308109309109310109311109312109313109314109315109316109317109318109319109320109321109322109323109324109325109326109327109328109329109330109331109332109333109334109335109336109337109338109339109340109341109342109343109344109345109346109347109348109349109350109351109352109353109354109355109356109357109358109359109360109361109362109363109364109365109366109367109368109369109370109371109372109373109374109375109376109377109378109379109380109381109382109383109384109385109386109387109388109389109390109391109392109393109394109395109396109397109398109399109400109401109402109403109404109405109406109407109408109409109410109411109412109413109414109415109416109417109418109419109420109421109422109423109424109425109426109427109428109429109430109431109432109433109434109435109436109437109438109439109440109441109442109443109444109445109446109447109448109449109450109451109452109453109454109455109456109457109458109459109460109461109462109463109464109465109466109467109468109469109470109471109472109473109474109475109476109477109478109479109480109481109482109483109484109485109486109487109488109489109490109491109492109493109494109495109496109497109498109499109500109501109502109503109504109505109506109507109508109509109510109511109512109513109514109515109516109517109518109519109520109521109522109523109524109525109526109527109528109529109530109531109532109533109534109535109536109537109538109539109540109541109542109543109544109545109546109547109548109549109550109551109552109553109554109555109556109557109558109559109560109561109562109563109564109565109566109567109568109569109570109571109572109573109574109575109576109577109578109579109580109581109582109583109584109585109586109587109588109589109590109591109592109593109594109595109596109597109598109599109600109601109602109603109604109605109606109607109608109609109610109611109612109613109614109615109616109617109618109619109620109621109622109623109624109625109626109627109628109629109630109631109632109633109634109635109636109637109638109639109640109641109642109643109644109645109646109647109648109649109650109651109652109653109654109655109656109657109658109659109660109661109662109663109664109665109666109667109668109669109670109671109672109673109674109675109676109677109678109679109680109681109682109683109684109685109686109687109688109689109690109691109692109693109694109695109696109697109698109699109700109701109702109703109704109705109706109707109708109709109710109711109712109713109714109715109716109717109718109719109720109721109722109723109724109725109726109727109728109729109730109731109732109733109734109735109736109737109738109739109740109741109742109743109744109745109746109747109748109749109750109751109752109753109754109755109756109757109758109759109760109761109762109763109764109765109766109767109768109769109770109771109772109773109774109775109776109777109778109779109780109781109782109783109784109785109786109787109788109789109790109791109792109793109794109795109796109797109798109799109800109801109802109803109804109805109806109807109808109809109810109811109812109813109814109815109816109817109818109819109820109821109822109823109824109825109826109827109828109829109830109831109832109833109834109835109836109837109838109839109840109841109842109843109844109845109846109847109848109849109850109851109852109853109854109855109856109857109858109859109860109861109862109863109864109865109866109867109868109869109870109871109872109873109874109875109876109877109878109879109880109881109882109883109884109885109886109887109888109889109890109891109892109893109894109895109896109897109898109899109900109901109902109903109904109905109906109907109908109909109910109911109912109913109914109915109916109917109918109919109920109921109922109923109924109925109926109927109928109929109930109931109932109933109934109935109936109937109938109939109940109941109942109943109944109945109946109947109948109949109950109951109952109953109954109955109956109957109958109959109960109961109962109963109964109965109966109967109968109969109970109971109972109973109974109975109976109977109978109979109980109981109982109983109984109985109986109987109988109989109990109991109992109993109994109995109996109997109998109999110000110001110002110003110004110005110006110007110008110009110010110011110012110013110014110015110016110017110018110019110020110021110022110023110024110025110026110027110028110029110030110031110032110033110034110035110036110037110038110039110040110041110042110043110044110045110046110047110048110049110050110051110052110053110054110055110056110057110058110059110060110061110062110063110064110065110066110067110068110069110070110071110072110073110074110075110076110077110078110079110080110081110082110083110084110085110086110087110088110089110090110091110092110093110094110095110096110097110098110099110100110101110102110103110104110105110106110107110108110109110110110111110112110113110114110115110116110117110118110119110120110121110122110123110124110125110126110127110128110129110130110131110132110133110134110135110136110137110138110139110140110141110142110143110144110145110146110147110148110149110150110151110152110153110154110155110156110157110158110159110160110161110162110163110164110165110166110167110168110169110170110171110172110173110174110175110176110177110178110179110180110181110182110183110184110185110186110187110188110189110190110191110192110193110194110195110196110197110198110199110200110201110202110203110204110205110206110207110208110209110210110211110212110213110214110215110216110217110218110219110220110221110222110223110224110225110226110227110228110229110230110231110232110233110234110235110236110237110238110239110240110241110242110243110244110245110246110247110248110249110250110251110252110253110254110255110256110257110258110259110260110261110262110263110264110265110266110267110268110269110270110271110272110273110274110275110276110277110278110279110280110281110282110283110284110285110286110287110288110289110290110291110292110293110294110295110296110297110298110299110300110301110302110303110304110305110306110307110308110309110310110311110312110313110314110315110316110317110318110319110320110321110322110323110324110325110326110327110328110329110330110331110332110333110334110335110336110337110338110339110340110341110342110343110344110345110346110347110348110349110350110351110352110353110354110355110356110357110358110359110360110361110362110363110364110365110366110367110368110369110370110371110372110373110374110375110376110377110378110379110380110381110382110383110384110385110386110387110388110389110390110391110392110393110394110395110396110397110398110399110400110401110402110403110404110405110406110407110408110409110410110411110412110413110414110415110416110417110418110419110420110421110422110423110424110425110426110427110428110429110430110431110432110433110434110435110436110437110438110439110440110441110442110443110444110445110446110447110448110449110450110451110452110453110454110455110456110457110458110459110460110461110462110463110464110465110466110467110468110469110470110471110472110473110474110475110476110477110478110479110480110481110482110483110484110485110486110487110488110489110490110491110492110493110494110495110496110497110498110499110500110501110502110503110504110505110506110507110508110509110510110511110512110513110514110515110516110517110518110519110520110521110522110523110524110525110526110527110528110529110530110531110532110533110534110535110536110537110538110539110540110541110542110543110544110545110546110547110548110549110550110551110552110553110554110555110556110557110558110559110560110561110562110563110564110565110566110567110568110569110570110571110572110573110574110575110576110577110578110579110580110581110582110583110584110585110586110587110588110589110590110591110592110593110594110595110596110597110598110599110600110601110602110603110604110605110606110607110608110609110610110611110612110613110614110615110616110617110618110619110620110621110622110623110624110625110626110627110628110629110630110631110632110633110634110635110636110637110638110639110640110641110642110643110644110645110646110647110648110649110650110651110652110653110654110655110656110657110658110659110660110661110662110663110664110665110666110667110668110669110670110671110672110673110674110675110676110677110678110679110680110681110682110683110684110685110686110687110688110689110690110691110692110693110694110695110696110697110698110699110700110701110702110703110704110705110706110707110708110709110710110711110712110713110714110715110716110717110718110719110720110721110722110723110724110725110726110727110728110729110730110731110732110733110734110735110736110737110738110739110740110741110742110743110744110745110746110747110748110749110750110751110752110753110754110755110756110757110758110759110760110761110762110763110764110765110766110767110768110769110770110771110772110773110774110775110776110777110778110779110780110781110782110783110784110785110786110787110788110789110790110791110792110793110794110795110796110797110798110799110800110801110802110803110804110805110806110807110808110809110810110811110812110813110814110815110816110817110818110819110820110821110822110823110824110825110826110827110828110829110830110831110832110833110834110835110836110837110838110839110840110841110842110843110844110845110846110847110848110849110850110851110852110853110854110855110856110857110858110859110860110861110862110863110864110865110866110867110868110869110870110871110872110873110874110875110876110877110878110879110880110881110882110883110884110885110886110887110888110889110890110891110892110893110894110895110896110897110898110899110900110901110902110903110904110905110906110907110908110909110910110911110912110913110914110915110916110917110918110919110920110921110922110923110924110925110926110927110928110929110930110931110932110933110934110935110936110937110938110939110940110941110942110943110944110945110946110947110948110949110950110951110952110953110954110955110956110957110958110959110960110961110962110963110964110965110966110967110968110969110970110971110972110973110974110975110976110977110978110979110980110981110982110983110984110985110986110987110988110989110990110991110992110993110994110995110996110997110998110999111000111001111002111003111004111005111006111007111008111009111010111011111012111013111014111015111016111017111018111019111020111021111022111023111024111025111026111027111028111029111030111031111032111033111034111035111036111037111038111039111040111041111042111043111044111045111046111047111048111049111050111051111052111053111054111055111056111057111058111059111060111061111062111063111064111065111066111067111068111069111070111071111072111073111074111075111076111077111078111079111080111081111082111083111084111085111086111087111088111089111090111091111092111093111094111095111096111097111098111099111100111101111102111103111104111105111106111107111108111109111110111111111112111113111114111115111116111117111118111119111120111121111122111123111124111125111126111127111128111129111130111131111132111133111134111135111136111137111138111139111140111141111142111143111144111145111146111147111148111149111150111151111152111153111154111155111156111157111158111159111160111161111162111163111164111165111166111167111168111169111170111171111172111173111174111175111176111177111178111179111180111181111182111183111184111185111186111187111188111189111190111191111192111193111194111195111196111197111198111199111200111201111202111203111204111205111206111207111208111209111210111211111212111213111214111215111216111217111218111219111220111221111222111223111224111225111226111227111228111229111230111231111232111233111234111235111236111237111238111239111240111241111242111243111244111245111246111247111248111249111250111251111252111253111254111255111256111257111258111259111260111261111262111263111264111265111266111267111268111269111270111271111272111273111274111275111276111277111278111279111280111281111282111283111284111285111286111287111288111289111290111291111292111293111294111295111296111297111298111299111300111301111302111303111304111305111306111307111308111309111310111311111312111313111314111315111316111317111318111319111320111321111322111323111324111325111326111327111328111329111330111331111332111333111334111335111336111337111338111339111340111341111342111343111344111345111346111347111348111349111350111351111352111353111354111355111356111357111358111359111360111361111362111363111364111365111366111367111368111369111370111371111372111373111374111375111376111377111378111379111380111381111382111383111384111385111386111387111388111389111390111391111392111393111394111395111396111397111398111399111400111401111402111403111404111405111406111407111408111409111410111411111412111413111414111415111416111417111418111419111420111421111422111423111424111425111426111427111428111429111430111431111432111433111434111435111436111437111438111439111440111441111442111443111444111445111446111447111448111449111450111451111452111453111454111455111456111457111458111459111460111461111462111463111464111465111466111467111468111469111470111471111472111473111474111475111476111477111478111479111480111481111482111483111484111485111486111487111488111489111490111491111492111493111494111495111496111497111498111499111500111501111502111503111504111505111506111507111508111509111510111511111512111513111514111515111516111517111518111519111520111521111522111523111524111525111526111527111528111529111530111531111532111533111534111535111536111537111538111539111540111541111542111543111544111545111546111547111548111549111550111551111552111553111554111555111556111557111558111559111560111561111562111563111564111565111566111567111568111569111570111571111572111573111574111575111576111577111578111579111580111581111582111583111584111585111586111587111588111589111590111591111592111593111594111595111596111597111598111599111600111601111602111603111604111605111606111607111608111609111610111611111612111613111614111615111616111617111618111619111620111621111622111623111624111625111626111627111628111629111630111631111632111633111634111635111636111637111638111639111640111641111642111643111644111645111646111647111648111649111650111651111652111653111654111655111656111657111658111659111660111661111662111663111664111665111666111667111668111669111670111671111672111673111674111675111676111677111678111679111680111681111682111683111684111685111686111687111688111689111690111691111692111693111694111695111696111697111698111699111700111701111702111703111704111705111706111707111708111709111710111711111712111713111714111715111716111717111718111719111720111721111722111723111724111725111726111727111728111729111730111731111732111733111734111735111736111737111738111739111740111741111742111743111744111745111746111747111748111749111750111751111752111753111754111755111756111757111758111759111760111761111762111763111764111765111766111767111768111769111770111771111772111773111774111775111776111777111778111779111780111781111782111783111784111785111786111787111788111789111790111791111792111793111794111795111796111797111798111799111800111801111802111803111804111805111806111807111808111809111810111811111812111813111814111815111816111817111818111819111820111821111822111823111824111825111826111827111828111829111830111831111832111833111834111835111836111837111838111839111840111841111842111843111844111845111846111847111848111849111850111851111852111853111854111855111856111857111858111859111860111861111862111863111864111865111866111867111868111869111870111871111872111873111874111875111876111877111878111879111880111881111882111883111884111885111886111887111888111889111890111891111892111893111894111895111896111897111898111899111900111901111902111903111904111905111906111907111908111909111910111911111912111913111914111915111916111917111918111919111920111921111922111923111924111925111926111927111928111929111930111931111932111933111934111935111936111937111938111939111940111941111942111943111944111945111946111947111948111949111950111951111952111953111954111955111956111957111958111959111960111961111962111963111964111965111966111967111968111969111970111971111972111973111974111975111976111977111978111979111980111981111982111983111984111985111986111987111988111989111990111991111992111993111994111995111996111997111998111999112000112001112002112003112004112005112006112007112008112009112010112011112012112013112014112015112016112017112018112019112020112021112022112023112024112025112026112027112028112029112030112031112032112033112034112035112036112037112038112039112040112041112042112043112044112045112046112047112048112049112050112051112052112053112054112055112056112057112058112059112060112061112062112063112064112065112066112067112068112069112070112071112072112073112074112075112076112077112078112079112080112081112082112083112084112085112086112087112088112089112090112091112092112093112094112095112096112097112098112099112100112101112102112103112104112105112106112107112108112109112110112111112112112113112114112115112116112117112118112119112120112121112122112123112124112125112126112127112128112129112130112131112132112133112134112135112136112137112138112139112140112141112142112143112144112145112146112147112148112149112150112151112152112153112154112155112156112157112158112159112160112161112162112163112164112165112166112167112168112169112170112171112172112173112174112175112176112177112178112179112180112181112182112183112184112185112186112187112188112189112190112191112192112193112194112195112196112197112198112199112200112201112202112203112204112205112206112207112208112209112210112211112212112213112214112215112216112217112218112219112220112221112222112223112224112225112226112227112228112229112230112231112232112233112234112235112236112237112238112239112240112241112242112243112244112245112246112247112248112249112250112251112252112253112254112255112256112257112258112259112260112261112262112263112264112265112266112267112268112269112270112271112272112273112274112275112276112277112278112279112280112281112282112283112284112285112286112287112288112289112290112291112292112293112294112295112296112297112298112299112300112301112302112303112304112305112306112307112308112309112310112311112312112313112314112315112316112317112318112319112320112321112322112323112324112325112326112327112328112329112330112331112332112333112334112335112336112337112338112339112340112341112342112343112344112345112346112347112348112349112350112351112352112353112354112355112356112357112358112359112360112361112362112363112364112365112366112367112368112369112370112371112372112373112374112375112376112377112378112379112380112381112382112383112384112385112386112387112388112389112390112391112392112393112394112395112396112397112398112399112400112401112402112403112404112405112406112407112408112409112410112411112412112413112414112415112416112417112418112419112420112421112422112423112424112425112426112427112428112429112430112431112432112433112434112435112436112437112438112439112440112441112442112443112444112445112446112447112448112449112450112451112452112453112454112455112456112457112458112459112460112461112462112463112464112465112466112467112468112469112470112471112472112473112474112475112476112477112478112479112480112481112482112483112484112485112486112487112488112489112490112491112492112493112494112495112496112497112498112499112500112501112502112503112504112505112506112507112508112509112510112511112512112513112514112515112516112517112518112519112520112521112522112523112524112525112526112527112528112529112530112531112532112533112534112535112536112537112538112539112540112541112542112543112544112545112546112547112548112549112550112551112552112553112554112555112556112557112558112559112560112561112562112563112564112565112566112567112568112569112570112571112572112573112574112575112576112577112578112579112580112581112582112583112584112585112586112587112588112589112590112591112592112593112594112595112596112597112598112599112600112601112602112603112604112605112606112607112608112609112610112611112612112613112614112615112616112617112618112619112620112621112622112623112624112625112626112627112628112629112630112631112632112633112634112635112636112637112638112639112640112641112642112643112644112645112646112647112648112649112650112651112652112653112654112655112656112657112658112659112660112661112662112663112664112665112666112667112668112669112670112671112672112673112674112675112676112677112678112679112680112681112682112683112684112685112686112687112688112689112690112691112692112693112694112695112696112697112698112699112700112701112702112703112704112705112706112707112708112709112710112711112712112713112714112715112716112717112718112719112720112721112722112723112724112725112726112727112728112729112730112731112732112733112734112735112736112737112738112739112740112741112742112743112744112745112746112747112748112749112750112751112752112753112754112755112756112757112758112759112760112761112762112763112764112765112766112767112768112769112770112771112772112773112774112775112776112777112778112779112780112781112782112783112784112785112786112787112788112789112790112791112792112793112794112795112796112797112798112799112800112801112802112803112804112805112806112807112808112809112810112811112812112813112814112815112816112817112818112819112820112821112822112823112824112825112826112827112828112829112830112831112832112833112834112835112836112837112838112839112840112841112842112843112844112845112846112847112848112849112850112851112852112853112854112855112856112857112858112859112860112861112862112863112864112865112866112867112868112869112870112871112872112873112874112875112876112877112878112879112880112881112882112883112884112885112886112887112888112889112890112891112892112893112894112895112896112897112898112899112900112901112902112903112904112905112906112907112908112909112910112911112912112913112914112915112916112917112918112919112920112921112922112923112924112925112926112927112928112929112930112931112932112933112934112935112936112937112938112939112940112941112942112943112944112945112946112947112948112949112950112951112952112953112954112955112956112957112958112959112960112961112962112963112964112965112966112967112968112969112970112971112972112973112974112975112976112977112978112979112980112981112982112983112984112985112986112987112988112989112990112991112992112993112994112995112996112997112998112999113000113001113002113003113004113005113006113007113008113009113010113011113012113013113014113015113016113017113018113019113020113021113022113023113024113025113026113027113028113029113030113031113032113033113034113035113036113037113038113039113040113041113042113043113044113045113046113047113048113049113050113051113052113053113054113055113056113057113058113059113060113061113062113063113064113065113066113067113068113069113070113071113072113073113074113075113076113077113078113079113080113081113082113083113084113085113086113087113088113089113090113091113092113093113094113095113096113097113098113099113100113101113102113103113104113105113106113107113108113109113110113111113112113113113114113115113116113117113118113119113120113121113122113123113124113125113126113127113128113129113130113131113132113133113134113135113136113137113138113139113140113141113142113143113144113145113146113147113148113149113150113151113152113153113154113155113156113157113158113159113160113161113162113163113164113165113166113167113168113169113170113171113172113173113174113175113176113177113178113179113180113181113182113183113184113185113186113187113188113189113190113191113192113193113194113195113196113197113198113199113200113201113202113203113204113205113206113207113208113209113210113211113212113213113214113215113216113217113218113219113220113221113222113223113224113225113226113227113228113229113230113231113232113233113234113235113236113237113238113239113240113241113242113243113244113245113246113247113248113249113250113251113252113253113254113255113256113257113258113259113260113261113262113263113264113265113266113267113268113269113270113271113272113273113274113275113276113277113278113279113280113281113282113283113284113285113286113287113288113289113290113291113292113293113294113295113296113297113298113299113300113301113302113303113304113305113306113307113308113309113310113311113312113313113314113315113316113317113318113319113320113321113322113323113324113325113326113327113328113329113330113331113332113333113334113335113336113337113338113339113340113341113342113343113344113345113346113347113348113349113350113351113352113353113354113355113356113357113358113359113360113361113362113363113364113365113366113367113368113369113370113371113372113373113374113375113376113377113378113379113380113381113382113383113384113385113386113387113388113389113390113391113392113393113394113395113396113397113398113399113400113401113402113403113404113405113406113407113408113409113410113411113412113413113414113415113416113417113418113419113420113421113422113423113424113425113426113427113428113429113430113431113432113433113434113435113436113437113438113439113440113441113442113443113444113445113446113447113448113449113450113451113452113453113454113455113456113457113458113459113460113461113462113463113464113465113466113467113468113469113470113471113472113473113474113475113476113477113478113479113480113481113482113483113484113485113486113487113488113489113490113491113492113493113494113495113496113497113498113499113500113501113502113503113504113505113506113507113508113509113510113511113512113513113514113515113516113517113518113519113520113521113522113523113524113525113526113527113528113529113530113531113532113533113534113535113536113537113538113539113540113541113542113543113544113545113546113547113548113549113550113551113552113553113554113555113556113557113558113559113560113561113562113563113564113565113566113567113568113569113570113571113572113573113574113575113576113577113578113579113580113581113582113583113584113585113586113587113588113589113590113591113592113593113594113595113596113597113598113599113600113601113602113603113604113605113606113607113608113609113610113611113612113613113614113615113616113617113618113619113620113621113622113623113624113625113626113627113628113629113630113631113632113633113634113635113636113637113638113639113640113641113642113643113644113645113646113647113648113649113650113651113652113653113654113655113656113657113658113659113660113661113662113663113664113665113666113667113668113669113670113671113672113673113674113675113676113677113678113679113680113681113682113683113684113685113686113687113688113689113690113691113692113693113694113695113696113697113698113699113700113701113702113703113704113705113706113707113708113709113710113711113712113713113714113715113716113717113718113719113720113721113722113723113724113725113726113727113728113729113730113731113732113733113734113735113736113737113738113739113740113741113742113743113744113745113746113747113748113749113750113751113752113753113754113755113756113757113758113759113760113761113762113763113764113765113766113767113768113769113770113771113772113773113774113775113776113777113778113779113780113781113782113783113784113785113786113787113788113789113790113791113792113793113794113795113796113797113798113799113800113801113802113803113804113805113806113807113808113809113810113811113812113813113814113815113816113817113818113819113820113821113822113823113824113825113826113827113828113829113830113831113832113833113834113835113836113837113838113839113840113841113842113843113844113845113846113847113848113849113850113851113852113853113854113855113856113857113858113859113860113861113862113863113864113865113866113867113868113869113870113871113872113873113874113875113876113877113878113879113880113881113882113883113884113885113886113887113888113889113890113891113892113893113894113895113896113897113898113899113900113901113902113903113904113905113906113907113908113909113910113911113912113913113914113915113916113917113918113919113920113921113922113923113924113925113926113927113928113929113930113931113932113933113934113935113936113937113938113939113940113941113942113943113944113945113946113947113948113949113950113951113952113953113954113955113956113957113958113959113960113961113962113963113964113965113966113967113968113969113970113971113972113973113974113975113976113977113978113979113980113981113982113983113984113985113986113987113988113989113990113991113992113993113994113995113996113997113998113999114000114001114002114003114004114005114006114007114008114009114010114011114012114013114014114015114016114017114018114019114020114021114022114023114024114025114026114027114028114029114030114031114032114033114034114035114036114037114038114039114040114041114042114043114044114045114046114047114048114049114050114051114052114053114054114055114056114057114058114059114060114061114062114063114064114065114066114067114068114069114070114071114072114073114074114075114076114077114078114079114080114081114082114083114084114085114086114087114088114089114090114091114092114093114094114095114096114097114098114099114100114101114102114103114104114105114106114107114108114109114110114111114112114113114114114115114116114117114118114119114120114121114122114123114124114125114126114127114128114129114130114131114132114133114134114135114136114137114138114139114140114141114142114143114144114145114146114147114148114149114150114151114152114153114154114155114156114157114158114159114160114161114162114163114164114165114166114167114168114169114170114171114172114173114174114175114176114177114178114179114180114181114182114183114184114185114186114187114188114189114190114191114192114193114194114195114196114197114198114199114200114201114202114203114204114205114206114207114208114209114210114211114212114213114214114215114216114217114218114219114220114221114222114223114224114225114226114227114228114229114230114231114232114233114234114235114236114237114238114239114240114241114242114243114244114245114246114247114248114249114250114251114252114253114254114255114256114257114258114259114260114261114262114263114264114265114266114267114268114269114270114271114272114273114274114275114276114277114278114279114280114281114282114283114284114285114286114287114288114289114290114291114292114293114294114295114296114297114298114299114300114301114302114303114304114305114306114307114308114309114310114311114312114313114314114315114316114317114318114319114320114321114322114323114324114325114326114327114328114329114330114331114332114333114334114335114336114337114338114339114340114341114342114343114344114345114346114347114348114349114350114351114352114353114354114355114356114357114358114359114360114361114362114363114364114365114366114367114368114369114370114371114372114373114374114375114376114377114378114379114380114381114382114383114384114385114386114387114388114389114390114391114392114393114394114395114396114397114398114399114400114401114402114403114404114405114406114407114408114409114410114411114412114413114414114415114416114417114418114419114420114421114422114423114424114425114426114427114428114429114430114431114432114433114434114435114436114437114438114439114440114441114442114443114444114445114446114447114448114449114450114451114452114453114454114455114456114457114458114459114460114461114462114463114464114465114466114467114468114469114470114471114472114473114474114475114476114477114478114479114480114481114482114483114484114485114486114487114488114489114490114491114492114493114494114495114496114497114498114499114500114501114502114503114504114505114506114507114508114509114510114511114512114513114514114515114516114517114518114519114520114521114522114523114524114525114526114527114528114529114530114531114532114533114534114535114536114537114538114539114540114541114542114543114544114545114546114547114548114549114550114551114552114553114554114555114556114557114558114559114560114561114562114563114564114565114566114567114568114569114570114571114572114573114574114575114576114577114578114579114580114581114582114583114584114585114586114587114588114589114590114591114592114593114594114595114596114597114598114599114600114601114602114603114604114605114606114607114608114609114610114611114612114613114614114615114616114617114618114619114620114621114622114623114624114625114626114627114628114629114630114631114632114633114634114635114636114637114638114639114640114641114642114643114644114645114646114647114648114649114650114651114652114653114654114655114656114657114658114659114660114661114662114663114664114665114666114667114668114669114670114671114672114673114674114675114676114677114678114679114680114681114682114683114684114685114686114687114688114689114690114691114692114693114694114695114696114697114698114699114700114701114702114703114704114705114706114707114708114709114710114711114712114713114714114715114716114717114718114719114720114721114722114723114724114725114726114727114728114729114730114731114732114733114734114735114736114737114738114739114740114741114742114743114744114745114746114747114748114749114750114751114752114753114754114755114756114757114758114759114760114761114762114763114764114765114766114767114768114769114770114771114772114773114774114775114776114777114778114779114780114781114782114783114784114785114786114787114788114789114790114791114792114793114794114795114796114797114798114799114800114801114802114803114804114805114806114807114808114809114810114811114812114813114814114815114816114817114818114819114820114821114822114823114824114825114826114827114828114829114830114831114832114833114834114835114836114837114838114839114840114841114842114843114844114845114846114847114848114849114850114851114852114853114854114855114856114857114858114859114860114861114862114863114864114865114866114867114868114869114870114871114872114873114874114875114876114877114878114879114880114881114882114883114884114885114886114887114888114889114890114891114892114893114894114895114896114897114898114899114900114901114902114903114904114905114906114907114908114909114910114911114912114913114914114915114916114917114918114919114920114921114922114923114924114925114926114927114928114929114930114931114932114933114934114935114936114937114938114939114940114941114942114943114944114945114946114947114948114949114950114951114952114953114954114955114956114957114958114959114960114961114962114963114964114965114966114967114968114969114970114971114972114973114974114975114976114977114978114979114980114981114982114983114984114985114986114987114988114989114990114991114992114993114994114995114996114997114998114999115000115001115002115003115004115005115006115007115008115009115010115011115012115013115014115015115016115017115018115019115020115021115022115023115024115025115026115027115028115029115030115031115032115033115034115035115036115037115038115039115040115041115042115043115044115045115046115047115048115049115050115051115052115053115054115055115056115057115058115059115060115061115062115063115064115065115066115067115068115069115070115071115072115073115074115075115076115077115078115079115080115081115082115083115084115085115086115087115088115089115090115091115092115093115094115095115096115097115098115099115100115101115102115103115104115105115106115107115108115109115110115111115112115113115114115115115116115117115118115119115120115121115122115123115124115125115126115127115128115129115130115131115132115133115134115135115136115137115138115139115140115141115142115143115144115145115146115147115148115149115150115151115152115153115154115155115156115157115158115159115160115161115162115163115164115165115166115167115168115169115170115171115172115173115174115175115176115177115178115179115180115181115182115183115184115185115186115187115188115189115190115191115192115193115194115195115196115197115198115199115200115201115202115203115204115205115206115207115208115209115210115211115212115213115214115215115216115217115218115219115220115221115222115223115224115225115226115227115228115229115230115231115232115233115234115235115236115237115238115239115240115241115242115243115244115245115246115247115248115249115250115251115252115253115254115255115256115257115258115259115260115261115262115263115264115265115266115267115268115269115270115271115272115273115274115275115276115277115278115279115280115281115282115283115284115285115286115287115288115289115290115291115292115293115294115295115296115297115298115299115300115301115302115303115304115305115306115307115308115309115310115311115312115313115314115315115316115317115318115319115320115321115322115323115324115325115326115327115328115329115330115331115332115333115334115335115336115337115338115339115340115341115342115343115344115345115346115347115348115349115350115351115352115353115354115355115356115357115358115359115360115361115362115363115364115365115366115367115368115369115370115371115372115373115374115375115376115377115378115379115380115381115382115383115384115385115386115387115388115389115390115391115392115393115394115395115396115397115398115399115400115401115402115403115404115405115406115407115408115409115410115411115412115413115414115415115416115417115418115419115420115421115422115423115424115425115426115427115428115429115430115431115432115433115434115435115436115437115438115439115440115441115442115443115444115445115446115447115448115449115450115451115452115453115454115455115456115457115458115459115460115461115462115463115464115465115466115467115468115469115470115471115472115473115474115475115476115477115478115479115480115481115482115483115484115485115486115487115488115489115490115491115492115493115494115495115496115497115498115499115500115501115502115503115504115505115506115507115508115509115510115511115512115513115514115515115516115517115518115519115520115521115522115523115524115525115526115527115528115529115530115531115532115533115534115535115536115537115538115539115540115541115542115543115544115545115546115547115548115549115550115551115552115553115554115555115556115557115558115559115560115561115562115563115564115565115566115567115568115569115570115571115572115573115574115575115576115577115578115579115580115581115582115583115584115585115586115587115588115589115590115591115592115593115594115595115596115597115598115599115600115601115602115603115604115605115606115607115608115609115610115611115612115613115614115615115616115617115618115619115620115621115622115623115624115625115626115627115628115629115630115631115632115633115634115635115636115637115638115639115640115641115642115643115644115645115646115647115648115649115650115651115652115653115654115655115656115657115658115659115660115661115662115663115664115665115666115667115668115669115670115671115672115673115674115675115676115677115678115679115680115681115682115683115684115685115686115687115688115689115690115691115692115693115694115695115696115697115698115699115700115701115702115703115704115705115706115707115708115709115710115711115712115713115714115715115716115717115718115719115720115721115722115723115724115725115726115727115728115729115730115731115732115733115734115735115736115737115738115739115740115741115742115743115744115745115746115747115748115749115750115751115752115753115754115755115756115757115758115759115760115761115762115763115764115765115766115767115768115769115770115771115772115773115774115775115776115777115778115779115780115781115782115783115784115785115786115787115788115789115790115791115792115793115794115795115796115797115798115799115800115801115802115803115804115805115806115807115808115809115810115811115812115813115814115815115816115817115818115819115820115821115822115823115824115825115826115827115828115829115830115831115832115833115834115835115836115837115838115839115840115841115842115843115844115845115846115847115848115849115850115851115852115853115854115855115856115857115858115859115860115861115862115863115864115865115866115867115868115869115870115871115872115873115874115875115876115877115878115879115880115881115882115883115884115885115886115887115888115889115890115891115892115893115894115895115896115897115898115899115900115901115902115903115904115905115906115907115908115909115910115911115912115913115914115915115916115917115918115919115920115921115922115923115924115925115926115927115928115929115930115931115932115933115934115935115936115937115938115939115940115941115942115943115944115945115946115947115948115949115950115951115952115953115954115955115956115957115958115959115960115961115962115963115964115965115966115967115968115969115970115971115972115973115974115975115976115977115978115979115980115981115982115983115984115985115986115987115988115989115990115991115992115993115994115995115996115997115998115999116000116001116002116003116004116005116006116007116008116009116010116011116012116013116014116015116016116017116018116019116020116021116022116023116024116025116026116027116028116029116030116031116032116033116034116035116036116037116038116039116040116041116042116043116044116045116046116047116048116049116050116051116052116053116054116055116056116057116058116059116060116061116062116063116064116065116066116067116068116069116070116071116072116073116074116075116076116077116078116079116080116081116082116083116084116085116086116087116088116089116090116091116092116093116094116095116096116097116098116099116100116101116102116103116104116105116106116107116108116109116110116111116112116113116114116115116116116117116118116119116120116121116122116123116124116125116126116127116128116129116130116131116132116133116134116135116136116137116138116139116140116141116142116143116144116145116146116147116148116149116150116151116152116153116154116155116156116157116158116159116160116161116162116163116164116165116166116167116168116169116170116171116172116173116174116175116176116177116178116179116180116181116182116183116184116185116186116187116188116189116190116191116192116193116194116195116196116197116198116199116200116201116202116203116204116205116206116207116208116209116210116211116212116213116214116215116216116217116218116219116220116221116222116223116224116225116226116227116228116229116230116231116232116233116234116235116236116237116238116239116240116241116242116243116244116245116246116247116248116249116250116251116252116253116254116255116256116257116258116259116260116261116262116263116264116265116266116267116268116269116270116271116272116273116274116275116276116277116278116279116280116281116282116283116284116285116286116287116288116289116290116291116292116293116294116295116296116297116298116299116300116301116302116303116304116305116306116307116308116309116310116311116312116313116314116315116316116317116318116319116320116321116322116323116324116325116326116327116328116329116330116331116332116333116334116335116336116337116338116339116340116341116342116343116344116345116346116347116348116349116350116351116352116353116354116355116356116357116358116359116360116361116362116363116364116365116366116367116368116369116370116371116372116373116374116375116376116377116378116379116380116381116382116383116384116385116386116387116388116389116390116391116392116393116394116395116396116397116398116399116400116401116402116403116404116405116406116407116408116409116410116411116412116413116414116415116416116417116418116419116420116421116422116423116424116425116426116427116428116429116430116431116432116433116434116435116436116437116438116439116440116441116442116443116444116445116446116447116448116449116450116451116452116453116454116455116456116457116458116459116460116461116462116463116464116465116466116467116468116469116470116471116472116473116474116475116476116477116478116479116480116481116482116483116484116485116486116487116488116489116490116491116492116493116494116495116496116497116498116499116500116501116502116503116504116505116506116507116508116509116510116511116512116513116514116515116516116517116518116519116520116521116522116523116524116525116526116527116528116529116530116531116532116533116534116535116536116537116538116539116540116541116542116543116544116545116546116547116548116549116550116551116552116553116554116555116556116557116558116559116560116561116562116563116564116565116566116567116568116569116570116571116572116573116574116575116576116577116578116579116580116581116582116583116584116585116586116587116588116589116590116591116592116593116594116595116596116597116598116599116600116601116602116603116604116605116606116607116608116609116610116611116612116613116614116615116616116617116618116619116620116621116622116623116624116625116626116627116628116629116630116631116632116633116634116635116636116637116638116639116640116641116642116643116644116645116646116647116648116649116650116651116652116653116654116655116656116657116658116659116660116661116662116663116664116665116666116667116668116669116670116671116672116673116674116675116676116677116678116679116680116681116682116683116684116685116686116687116688116689116690116691116692116693116694116695116696116697116698116699116700116701116702116703116704116705116706116707116708116709116710116711116712116713116714116715116716116717116718116719116720116721116722116723116724116725116726116727116728116729116730116731116732116733116734116735116736116737116738116739116740116741116742116743116744116745116746116747116748116749116750116751116752116753116754116755116756116757116758116759116760116761116762116763116764116765116766116767116768116769116770116771116772116773116774116775116776116777116778116779116780116781116782116783116784116785116786116787116788116789116790116791116792116793116794116795116796116797116798116799116800116801116802116803116804116805116806116807116808116809116810116811116812116813116814116815116816116817116818116819116820116821116822116823116824116825116826116827116828116829116830116831116832116833116834116835116836116837116838116839116840116841116842116843116844116845116846116847116848116849116850116851116852116853116854116855116856116857116858116859116860116861116862116863116864116865116866116867116868116869116870116871116872116873116874116875116876116877116878116879116880116881116882116883116884116885116886116887116888116889116890116891116892116893116894116895116896116897116898116899116900116901116902116903116904116905116906116907116908116909116910116911116912116913116914116915116916116917116918116919116920116921116922116923116924116925116926116927116928116929116930116931116932116933116934116935116936116937116938116939116940116941116942116943116944116945116946116947116948116949116950116951116952116953116954116955116956116957116958116959116960116961116962116963116964116965116966116967116968116969116970116971116972116973116974116975116976116977116978116979116980116981116982116983116984116985116986116987116988116989116990116991116992116993116994116995116996116997116998116999117000117001117002117003117004117005117006117007117008117009117010117011117012117013117014117015117016117017117018117019117020117021117022117023117024117025117026117027117028117029117030117031117032117033117034117035117036117037117038117039117040117041117042117043117044117045117046117047117048117049117050117051117052117053117054117055117056117057117058117059117060117061117062117063117064117065117066117067117068117069117070117071117072117073117074117075117076117077117078117079117080117081117082117083117084117085117086117087117088117089117090117091117092117093117094117095117096117097117098117099117100117101117102117103117104117105117106117107117108117109117110117111117112117113117114117115117116117117117118117119117120117121117122117123117124117125117126117127117128117129117130117131117132117133117134117135117136117137117138117139117140117141117142117143117144117145117146117147117148117149117150117151117152117153117154117155117156117157117158117159117160117161117162117163117164117165117166117167117168117169117170117171117172117173117174117175117176117177117178117179117180117181117182117183117184117185117186117187117188117189117190117191117192117193117194117195117196117197117198117199117200117201117202117203117204117205117206117207117208117209117210117211117212117213117214117215117216117217117218117219117220117221117222117223117224117225117226117227117228117229117230117231117232117233117234117235117236117237117238117239117240117241117242117243117244117245117246117247117248117249117250117251117252117253117254117255117256117257117258117259117260117261117262117263117264117265117266117267117268117269117270117271117272117273117274117275117276117277117278117279117280117281117282117283117284117285117286117287117288117289117290117291117292117293117294117295117296117297117298117299117300117301117302117303117304117305117306117307117308117309117310117311117312117313117314117315117316117317117318117319117320117321117322117323117324117325117326117327117328117329117330117331117332117333117334117335117336117337117338117339117340117341117342117343117344117345117346117347117348117349117350117351117352117353117354117355117356117357117358117359117360117361117362117363117364117365117366117367117368117369117370117371117372117373117374117375117376117377117378117379117380117381117382117383117384117385117386117387117388117389117390117391117392117393117394117395117396117397117398117399117400117401117402117403117404117405117406117407117408117409117410117411117412117413117414117415117416117417117418117419117420117421117422117423117424117425117426117427117428117429117430117431117432117433117434117435117436117437117438117439117440117441117442117443117444117445117446117447117448117449117450117451117452117453117454117455117456117457117458117459117460117461117462117463117464117465117466117467117468117469117470117471117472117473117474117475117476117477117478117479117480117481117482117483117484117485117486117487117488117489117490117491117492117493117494117495117496117497117498117499117500117501117502117503117504117505117506117507117508117509117510117511117512117513117514117515117516117517117518117519117520117521117522117523117524117525117526117527117528117529117530117531117532117533117534117535117536117537117538117539117540117541117542117543117544117545117546117547117548117549117550117551117552117553117554117555117556117557117558117559117560117561117562117563117564117565117566117567117568117569117570117571117572117573117574117575117576117577117578117579117580117581117582117583117584117585117586117587117588117589117590117591117592117593117594117595117596117597117598117599117600117601117602117603117604117605117606117607117608117609117610117611117612117613117614117615117616117617117618117619117620117621117622117623117624117625117626117627117628117629117630117631117632117633117634117635117636117637117638117639117640117641117642117643117644117645117646117647117648117649117650117651117652117653117654117655117656117657117658117659117660117661117662117663117664117665117666117667117668117669117670117671117672117673117674117675117676117677117678117679117680117681117682117683117684117685117686117687117688117689117690117691117692117693117694117695117696117697117698117699117700117701117702117703117704117705117706117707117708117709117710117711117712117713117714117715117716117717117718117719117720117721117722117723117724117725117726117727117728117729117730117731117732117733117734117735117736117737117738117739117740117741117742117743117744117745117746117747117748117749117750117751117752117753117754117755117756117757117758117759117760117761117762117763117764117765117766117767117768117769117770117771117772117773117774117775117776117777117778117779117780117781117782117783117784117785117786117787117788117789117790117791117792117793117794117795117796117797117798117799117800117801117802117803117804117805117806117807117808117809117810117811117812117813117814117815117816117817117818117819117820117821117822117823117824117825117826117827117828117829117830117831117832117833117834117835117836117837117838117839117840117841117842117843117844117845117846117847117848117849117850117851117852117853117854117855117856117857117858117859117860117861117862117863117864117865117866117867117868117869117870117871117872117873117874117875117876117877117878117879117880117881117882117883117884117885117886117887117888117889117890117891117892117893117894117895117896117897117898117899117900117901117902117903117904117905117906117907117908117909117910117911117912117913117914117915117916117917117918117919117920117921117922117923117924117925117926117927117928117929117930117931117932117933117934117935117936117937117938117939117940117941117942117943117944117945117946117947117948117949117950117951117952117953117954117955117956117957117958117959117960117961117962117963117964117965117966117967117968117969117970117971117972117973117974117975117976117977117978117979117980117981117982117983117984117985117986117987117988117989117990117991117992117993117994117995117996117997117998117999118000118001118002118003118004118005118006118007118008118009118010118011118012118013118014118015118016118017118018118019118020118021118022118023118024118025118026118027118028118029118030118031118032118033118034118035118036118037118038118039118040118041118042118043118044118045118046118047118048118049118050118051118052118053118054118055118056118057118058118059118060118061118062118063118064118065118066118067118068118069118070118071118072118073118074118075118076118077118078118079118080118081118082118083118084118085118086118087118088118089118090118091118092118093118094118095118096118097118098118099118100118101118102118103118104118105118106118107118108118109118110118111118112118113118114118115118116118117118118118119118120118121118122118123118124118125118126118127118128118129118130118131118132118133118134118135118136118137118138118139118140118141118142118143118144118145118146118147118148118149118150118151118152118153118154118155118156118157118158118159118160118161118162118163118164118165118166118167118168118169118170118171118172118173118174118175118176118177118178118179118180118181118182118183118184118185118186118187118188118189118190118191118192118193118194118195118196118197118198118199118200118201118202118203118204118205118206118207118208118209118210118211118212118213118214118215118216118217118218118219118220118221118222118223118224118225118226118227118228118229118230118231118232118233118234118235118236118237118238118239118240118241118242118243118244118245118246118247118248118249118250118251118252118253118254118255118256118257118258118259118260118261118262118263118264118265118266118267118268118269118270118271118272118273118274118275118276118277118278118279118280118281118282118283118284118285118286118287118288118289118290118291118292118293118294118295118296118297118298118299118300118301118302118303118304118305118306118307118308118309118310118311118312118313118314118315118316118317118318118319118320118321118322118323118324118325118326118327118328118329118330118331118332118333118334118335118336118337118338118339118340118341118342118343118344118345118346118347118348118349118350118351118352118353118354118355118356118357118358118359118360118361118362118363118364118365118366118367118368118369118370118371118372118373118374118375118376118377118378118379118380118381118382118383118384118385118386118387118388118389118390118391118392118393118394118395118396118397118398118399118400118401118402118403118404118405118406118407118408118409118410118411118412118413118414118415118416118417118418118419118420118421118422118423118424118425118426118427118428118429118430118431118432118433118434118435118436118437118438118439118440118441118442118443118444118445118446118447118448118449118450118451118452118453118454118455118456118457118458118459118460118461118462118463118464118465118466118467118468118469118470118471118472118473118474118475118476118477118478118479118480118481118482118483118484118485118486118487118488118489118490118491118492118493118494118495118496118497118498118499118500118501118502118503118504118505118506118507118508118509118510118511118512118513118514118515118516118517118518118519118520118521118522118523118524118525118526118527118528118529118530118531118532118533118534118535118536118537118538118539118540118541118542118543118544118545118546118547118548118549118550118551118552118553118554118555118556118557118558118559118560118561118562118563118564118565118566118567118568118569118570118571118572118573118574118575118576118577118578118579118580118581118582118583118584118585118586118587118588118589118590118591118592118593118594118595118596118597118598118599118600118601118602118603118604118605118606118607118608118609118610118611118612118613118614118615118616118617118618118619118620118621118622118623118624118625118626118627118628118629118630118631118632118633118634118635118636118637118638118639118640118641118642118643118644118645118646118647118648118649118650118651118652118653118654118655118656118657118658118659118660118661118662118663118664118665118666118667118668118669118670118671118672118673118674118675118676118677118678118679118680118681118682118683118684118685118686118687118688118689118690118691118692118693118694118695118696118697118698118699118700118701118702118703118704118705118706118707118708118709118710118711118712118713118714118715118716118717118718118719118720118721118722118723118724118725118726118727118728118729118730118731118732118733118734118735118736118737118738118739118740118741118742118743118744118745118746118747118748118749118750118751118752118753118754118755118756118757118758118759118760118761118762118763118764118765118766118767118768118769118770118771118772118773118774118775118776118777118778118779118780118781118782118783118784118785118786118787118788118789118790118791118792118793118794118795118796118797118798118799118800118801118802118803118804118805118806118807118808118809118810118811118812118813118814118815118816118817118818118819118820118821118822118823118824118825118826118827118828118829118830118831118832118833118834118835118836118837118838118839118840118841118842118843118844118845118846118847118848118849118850118851118852118853118854118855118856118857118858118859118860118861118862118863118864118865118866118867118868118869118870118871118872118873118874118875118876118877118878118879118880118881118882118883118884118885118886118887118888118889118890118891118892118893118894118895118896118897118898118899118900118901118902118903118904118905118906118907118908118909118910118911118912118913118914118915118916118917118918118919118920118921118922118923118924118925118926118927118928118929118930118931118932118933118934118935118936118937118938118939118940118941118942118943118944118945118946118947118948118949118950118951118952118953118954118955118956118957118958118959118960118961118962118963118964118965118966118967118968118969118970118971118972118973118974118975118976118977118978118979118980118981118982118983118984118985118986118987118988118989118990118991118992118993118994118995118996118997118998118999119000119001119002119003119004119005119006119007119008119009119010119011119012119013119014119015119016119017119018119019119020119021119022119023119024119025119026119027119028119029119030119031119032119033119034119035119036119037119038119039119040119041119042119043119044119045119046119047119048119049119050119051119052119053119054119055119056119057119058119059119060119061119062119063119064119065119066119067119068119069119070119071119072119073119074119075119076119077119078119079119080119081119082119083119084119085119086119087119088119089119090119091119092119093119094119095119096119097119098119099119100119101119102119103119104119105119106119107119108119109119110119111119112119113119114119115119116119117119118119119119120119121119122119123119124119125119126119127119128119129119130119131119132119133119134119135119136119137119138119139119140119141119142119143119144119145119146119147119148119149119150119151119152119153119154119155119156119157119158119159119160119161119162119163119164119165119166119167119168119169119170119171119172119173119174119175119176119177119178119179119180119181119182119183119184119185119186119187119188119189119190119191119192119193119194119195119196119197119198119199119200119201119202119203119204119205119206119207119208119209119210119211119212119213119214119215119216119217119218119219119220119221119222119223119224119225119226119227119228119229119230119231119232119233119234119235119236119237119238119239119240119241119242119243119244119245119246119247119248119249119250119251119252119253119254119255119256119257119258119259119260119261119262119263119264119265119266119267119268119269119270119271119272119273119274119275119276119277119278119279119280119281119282119283119284119285119286119287119288119289119290119291119292119293119294119295119296119297119298119299119300119301119302119303119304119305119306119307119308119309119310119311119312119313119314119315119316119317119318119319119320119321119322119323119324119325119326119327119328119329119330119331119332119333119334119335119336119337119338119339119340119341119342119343119344119345119346119347119348119349119350119351119352119353119354119355119356119357119358119359119360119361119362119363119364119365119366119367119368119369119370119371119372119373119374119375119376119377119378119379119380119381119382119383119384119385119386119387119388119389119390119391119392119393119394119395119396119397119398119399119400119401119402119403119404119405119406119407119408119409119410119411119412119413119414119415119416119417119418119419119420119421119422119423119424119425119426119427119428119429119430119431119432119433119434119435119436119437119438119439119440119441119442119443119444119445119446119447119448119449119450119451119452119453119454119455119456119457119458119459119460119461119462119463119464119465119466119467119468119469119470119471119472119473119474119475119476119477119478119479119480119481119482119483119484119485119486119487119488119489119490119491119492119493119494119495119496119497119498119499119500119501119502119503119504119505119506119507119508119509119510119511119512119513119514119515119516119517119518119519119520119521119522119523119524119525119526119527119528119529119530119531119532119533119534119535119536119537119538119539119540119541119542119543119544119545119546119547119548119549119550119551119552119553119554119555119556119557119558119559119560119561119562119563119564119565119566119567119568119569119570119571119572119573119574119575119576119577119578119579119580119581119582119583119584119585119586119587119588119589119590119591119592119593119594119595119596119597119598119599119600119601119602119603119604119605119606119607119608119609119610119611119612119613119614119615119616119617119618119619119620119621119622119623119624119625119626119627119628119629119630119631119632119633119634119635119636119637119638119639119640119641119642119643119644119645119646119647119648119649119650119651119652119653119654119655119656119657119658119659119660119661119662119663119664119665119666119667119668119669119670119671119672119673119674119675119676119677119678119679119680119681119682119683119684119685119686119687119688119689119690119691119692119693119694119695119696119697119698119699119700119701119702119703119704119705119706119707119708119709119710119711119712119713119714119715119716119717119718119719119720119721119722119723119724119725119726119727119728119729119730119731119732119733119734119735119736119737119738119739119740119741119742119743119744119745119746119747119748119749119750119751119752119753119754119755119756119757119758119759119760119761119762119763119764119765119766119767119768119769119770119771119772119773119774119775119776119777119778119779119780119781119782119783119784119785119786119787119788119789119790119791119792119793119794119795119796119797119798119799119800119801119802119803119804119805119806119807119808119809119810119811119812119813119814119815119816119817119818119819119820119821119822119823119824119825119826119827119828119829119830119831119832119833119834119835119836119837119838119839119840119841119842119843119844119845119846119847119848119849119850119851119852119853119854119855119856119857119858119859119860119861119862119863119864119865119866119867119868119869119870119871119872119873119874119875119876119877119878119879119880119881119882119883119884119885119886119887119888119889119890119891119892119893119894119895119896119897119898119899119900119901119902119903119904119905119906119907119908119909119910119911119912119913119914119915119916119917119918119919119920119921119922119923119924119925119926119927119928119929119930119931119932119933119934119935119936119937119938119939119940119941119942119943119944119945119946119947119948119949119950119951119952119953119954119955119956119957119958119959119960119961119962119963119964119965119966119967119968119969119970119971119972119973119974119975119976119977119978119979119980119981119982119983119984119985119986119987119988119989119990119991119992119993119994119995119996119997119998119999120000120001120002120003120004120005120006120007120008120009120010120011120012120013120014120015120016120017120018120019120020120021120022120023120024120025120026120027120028120029120030120031120032120033120034120035120036120037120038120039120040120041120042120043120044120045120046120047120048120049120050120051120052120053120054120055120056120057120058120059120060120061120062120063120064120065120066120067120068120069120070120071120072120073120074120075120076120077120078120079120080120081120082120083120084120085120086120087120088120089120090120091120092120093120094120095120096120097120098120099120100120101120102120103120104120105120106120107120108120109120110120111120112120113120114120115120116120117120118120119120120120121120122120123120124120125120126120127120128120129120130120131120132120133120134120135120136120137120138120139120140120141120142120143120144120145120146120147120148120149120150120151120152120153120154120155120156120157120158120159120160120161120162120163120164120165120166120167120168120169120170120171120172120173120174120175120176120177120178120179120180120181120182120183120184120185120186120187120188120189120190120191120192120193120194120195120196120197120198120199120200120201120202120203120204120205120206120207120208120209120210120211120212120213120214120215120216120217120218120219120220120221120222120223120224120225120226120227120228120229120230120231120232120233120234120235120236120237120238120239120240120241120242120243120244120245120246120247120248120249120250120251120252120253120254120255120256120257120258120259120260120261120262120263120264120265120266120267120268120269120270120271120272120273120274120275120276120277120278120279120280120281120282120283120284120285120286120287120288120289120290120291120292120293120294120295120296120297120298120299120300120301120302120303120304120305120306120307120308120309120310120311120312120313120314120315120316120317120318120319120320120321120322120323120324120325120326120327120328120329120330120331120332120333120334120335120336120337120338120339120340120341120342120343120344120345120346120347120348120349120350120351120352120353120354120355120356120357120358120359120360120361120362120363120364120365120366120367120368120369120370120371120372120373120374120375120376120377120378120379120380120381120382120383120384120385120386120387120388120389120390120391120392120393120394120395120396120397120398120399120400120401120402120403120404120405120406120407120408120409120410120411120412120413120414120415120416120417120418120419120420120421120422120423120424120425120426120427120428120429120430120431120432120433120434120435120436120437120438120439120440120441120442120443120444120445120446120447120448120449120450120451120452120453120454120455120456120457120458120459120460120461120462120463120464120465120466120467120468120469120470120471120472120473120474120475120476120477120478120479120480120481120482120483120484120485120486120487120488120489120490120491120492120493120494120495120496120497120498120499120500120501120502120503120504120505120506120507120508120509120510120511120512120513120514120515120516120517120518120519120520120521120522120523120524120525120526120527120528120529120530120531120532120533120534120535120536120537120538120539120540120541120542120543120544120545120546120547120548120549120550120551120552120553120554120555120556120557120558120559120560120561120562120563120564120565120566120567120568120569120570120571120572120573120574120575120576120577120578120579120580120581120582120583120584120585120586120587120588120589120590120591120592120593120594120595120596120597120598120599120600120601120602120603120604120605120606120607120608120609120610120611120612120613120614120615120616120617120618120619120620120621120622120623120624120625120626120627120628120629120630120631120632120633120634120635120636120637120638120639120640120641120642120643120644120645120646120647120648120649120650120651120652120653120654120655120656120657120658120659120660120661120662120663120664120665120666120667120668120669120670120671120672120673120674120675120676120677120678120679120680120681120682120683120684120685120686120687120688120689120690120691120692120693120694120695120696120697120698120699120700120701120702120703120704120705120706120707120708120709120710120711120712120713120714120715120716120717120718120719120720120721120722120723120724120725120726120727120728120729120730120731120732120733120734120735120736120737120738120739120740120741120742120743120744120745120746120747120748120749120750120751120752120753120754120755120756120757120758120759120760120761120762120763120764120765120766120767120768120769120770120771120772120773120774120775120776120777120778120779120780120781120782120783120784120785120786120787120788120789120790120791120792120793120794120795120796120797120798120799120800120801120802120803120804120805120806120807120808120809120810120811120812120813120814120815120816120817120818120819120820120821120822120823120824120825120826120827120828120829120830120831120832120833120834120835120836120837120838120839120840120841120842120843120844120845120846120847120848120849120850120851120852120853120854120855120856120857120858120859120860120861120862120863120864120865120866120867120868120869120870120871120872120873120874120875120876120877120878120879120880120881120882120883120884120885120886120887120888120889120890120891120892120893120894120895120896120897120898120899120900120901120902120903120904120905120906120907120908120909120910120911120912120913120914120915120916120917120918120919120920120921120922120923120924120925120926120927120928120929120930120931120932120933120934120935120936120937120938120939120940120941120942120943120944120945120946120947120948120949120950120951120952120953120954120955120956120957120958120959120960120961120962120963120964120965120966120967120968120969120970120971120972120973120974120975120976120977120978120979120980120981120982120983120984120985120986120987120988120989120990120991120992120993120994120995120996120997120998120999121000121001121002121003121004121005121006121007121008121009121010121011121012121013121014121015121016121017121018121019121020121021121022121023121024121025121026121027121028121029121030121031121032121033121034121035121036121037121038121039121040121041121042121043121044121045121046121047121048121049121050121051121052121053121054121055121056121057121058121059121060121061121062121063121064121065121066121067121068121069121070121071121072121073121074121075121076121077121078121079121080121081121082121083121084121085121086121087121088121089121090121091121092121093121094121095121096121097121098121099121100121101121102121103121104121105121106121107121108121109121110121111121112121113121114121115121116121117121118121119121120121121121122121123121124121125121126121127121128121129121130121131121132121133121134121135121136121137121138121139121140121141121142121143121144121145121146121147121148121149121150121151121152121153121154121155121156121157121158121159121160121161121162121163121164121165121166121167121168121169121170121171121172121173121174121175121176121177121178121179121180121181121182121183121184121185121186121187121188121189121190121191121192121193121194121195121196121197121198121199121200121201121202121203121204121205121206121207121208121209121210121211121212121213121214121215121216121217121218121219121220121221121222121223121224121225121226121227121228121229121230121231121232121233121234121235121236121237121238121239121240121241121242121243121244121245121246121247121248121249121250121251121252121253121254121255121256121257121258121259121260121261121262121263121264121265121266121267121268121269121270121271121272121273121274121275121276121277121278121279121280121281121282121283121284121285121286121287121288121289121290121291121292121293121294121295121296121297121298121299121300121301121302121303121304121305121306121307121308121309121310121311121312121313121314121315121316121317121318121319121320121321121322121323121324121325121326121327121328121329121330121331121332121333121334121335121336121337121338121339121340121341121342121343121344121345121346121347121348121349121350121351121352121353121354121355121356121357121358121359121360121361121362121363121364121365121366121367121368121369121370121371121372121373121374121375121376121377121378121379121380121381121382121383121384121385121386121387121388121389121390121391121392121393121394121395121396121397121398121399121400121401121402121403121404121405121406121407121408121409121410121411121412121413121414121415121416121417121418121419121420121421121422121423121424121425121426121427121428121429121430121431121432121433121434121435121436121437121438121439121440121441121442121443121444121445121446121447121448121449121450121451121452121453121454121455121456121457121458121459121460121461121462121463121464121465121466121467121468121469121470121471121472121473121474121475121476121477121478121479121480121481121482121483121484121485121486121487121488121489121490121491121492121493121494121495121496121497121498121499121500121501121502121503121504121505121506121507121508121509121510121511121512121513121514121515121516121517121518121519121520121521121522121523121524121525121526121527121528121529121530121531121532121533121534121535121536121537121538121539121540121541121542121543121544121545121546121547121548121549121550121551121552121553121554121555121556121557121558121559121560121561121562121563121564121565121566121567121568121569121570121571121572121573121574121575121576121577121578121579121580121581121582121583121584121585121586121587121588121589121590121591121592121593121594121595121596121597121598121599121600121601121602121603121604121605121606121607121608121609121610121611121612121613121614121615121616121617121618121619121620121621121622121623121624121625121626121627121628121629121630121631121632121633121634121635121636121637121638121639121640121641121642121643121644121645121646121647121648121649121650121651121652121653121654121655121656121657121658121659121660121661121662121663121664121665121666121667121668121669121670121671121672121673121674121675121676121677121678121679121680121681121682121683121684121685121686121687121688121689121690121691121692121693121694121695121696121697121698121699121700121701121702121703121704121705121706121707121708121709121710121711121712121713121714121715121716121717121718121719121720121721121722121723121724121725121726121727121728121729121730121731121732121733121734121735121736121737121738121739121740121741121742121743121744121745121746121747121748121749121750121751121752121753121754121755121756121757121758121759121760121761121762121763121764121765121766121767121768121769121770121771121772121773121774121775121776121777121778121779121780121781121782121783121784121785121786121787121788121789121790121791121792121793121794121795121796121797121798121799121800121801121802121803121804121805121806121807121808121809121810121811121812121813121814121815121816121817121818121819121820121821121822121823121824121825121826121827121828121829121830121831121832121833121834121835121836121837121838121839121840121841121842121843121844121845121846121847121848121849121850121851121852121853121854121855121856121857121858121859121860121861121862121863121864121865121866121867121868121869121870121871121872121873121874121875121876121877121878121879121880121881121882121883121884121885121886121887121888121889121890121891121892121893121894121895121896121897121898121899121900121901121902121903121904121905121906121907121908121909121910121911121912121913121914121915121916121917121918121919121920121921121922121923121924121925121926121927121928121929121930121931121932121933121934121935121936121937121938121939121940121941121942121943121944121945121946121947121948121949121950121951121952121953121954121955121956121957121958121959121960121961121962121963121964121965121966121967121968121969121970121971121972121973121974121975121976121977121978121979121980121981121982121983121984121985121986121987121988121989121990121991121992121993121994121995121996121997121998121999122000122001122002122003122004122005122006122007122008122009122010122011122012122013122014122015122016122017122018122019122020122021122022122023122024122025122026122027122028122029122030122031122032122033122034122035122036122037122038122039122040122041122042122043122044122045122046122047122048122049122050122051122052122053122054122055122056122057122058122059122060122061122062122063122064122065122066122067122068122069122070122071122072122073122074122075122076122077122078122079122080122081122082122083122084122085122086122087122088122089122090122091122092122093122094122095122096122097122098122099122100122101122102122103122104122105122106122107122108122109122110122111122112122113122114122115122116122117122118122119122120122121122122122123122124122125122126122127122128122129122130122131122132122133122134122135122136122137122138122139122140122141122142122143122144122145122146122147122148122149122150122151122152122153122154122155122156122157122158122159122160122161122162122163122164122165122166122167122168122169122170122171122172122173122174122175122176122177122178122179122180122181122182122183122184122185122186122187122188122189122190122191122192122193122194122195122196122197122198122199122200122201122202122203122204122205122206122207122208122209122210122211122212122213122214122215122216122217122218122219122220122221122222122223122224122225122226122227122228122229122230122231122232122233122234122235122236122237122238122239122240122241122242122243122244122245122246122247122248122249122250122251122252122253122254122255122256122257122258122259122260122261122262122263122264122265122266122267122268122269122270122271122272122273122274122275122276122277122278122279122280122281122282122283122284122285122286122287122288122289122290122291122292122293122294122295122296122297122298122299122300122301122302122303122304122305122306122307122308122309122310122311122312122313122314122315122316122317122318122319122320122321122322122323122324122325122326122327122328122329122330122331122332122333122334122335122336122337122338122339122340122341122342122343122344122345122346122347122348122349122350122351122352122353122354122355122356122357122358122359122360122361122362122363122364122365122366122367122368122369122370122371122372122373122374122375122376122377122378122379122380122381122382122383122384122385122386122387122388122389122390122391122392122393122394122395122396122397122398122399122400122401122402122403122404122405122406122407122408122409122410122411122412122413122414122415122416122417122418122419122420122421122422122423122424122425122426122427122428122429122430122431122432122433122434122435122436122437122438122439122440122441122442122443122444122445122446122447122448122449122450122451122452122453122454122455122456122457122458122459122460122461122462122463122464122465122466122467122468122469122470122471122472122473122474122475122476122477122478122479122480122481122482122483122484122485122486122487122488122489122490122491122492122493122494122495122496122497122498122499122500122501122502122503122504122505122506122507122508122509122510122511122512122513122514122515122516122517122518122519122520122521122522122523122524122525122526122527122528122529122530122531122532122533122534122535122536122537122538122539122540122541122542122543122544122545122546122547122548122549122550122551122552122553122554122555122556122557122558122559122560122561122562122563122564122565122566122567122568122569122570122571122572122573122574122575122576122577122578122579122580122581122582122583122584122585122586122587122588122589122590122591122592122593122594122595122596122597122598122599122600122601122602122603122604122605122606122607122608122609122610122611122612122613122614122615122616122617122618122619122620122621122622122623122624122625122626122627122628122629122630122631122632122633122634122635122636122637122638122639122640122641122642122643122644122645122646122647122648122649122650122651122652122653122654122655122656122657122658122659122660122661122662122663122664122665122666122667122668122669122670122671122672122673122674122675122676122677122678122679122680122681122682122683122684122685122686122687122688122689122690122691122692122693122694122695122696122697122698122699122700122701122702122703122704122705122706122707122708122709122710122711122712122713122714122715122716122717122718122719122720122721122722122723122724122725122726122727122728122729122730122731122732122733122734122735122736122737122738122739122740122741122742122743122744122745122746122747122748122749122750122751122752122753122754122755122756122757122758122759122760122761122762122763122764122765122766122767122768122769122770122771122772122773122774122775122776122777122778122779122780122781122782122783122784122785122786122787122788122789122790122791122792122793122794122795122796122797122798122799122800122801122802122803122804122805122806122807122808122809122810122811122812122813122814122815122816122817122818122819122820122821122822122823122824122825122826122827122828122829122830122831122832122833122834122835122836122837122838122839122840122841122842122843122844122845122846122847122848122849122850122851122852122853122854122855122856122857122858122859122860122861122862122863122864122865122866122867122868122869122870122871122872122873122874122875122876122877122878122879122880122881122882122883122884122885122886122887122888122889122890122891122892122893122894122895122896122897122898122899122900122901122902122903122904122905122906122907122908122909122910122911122912122913122914122915122916122917122918122919122920122921122922122923122924122925122926122927122928122929122930122931122932122933122934122935122936122937122938122939122940122941122942122943122944122945122946122947122948122949122950122951122952122953122954122955122956122957122958122959122960122961122962122963122964122965122966122967122968122969122970122971122972122973122974122975122976122977122978122979122980122981122982122983122984122985122986122987122988122989122990122991122992122993122994122995122996122997122998122999123000123001123002123003123004123005123006123007123008123009123010123011123012123013123014123015123016123017123018123019123020123021123022123023123024123025123026123027123028123029123030123031123032123033123034123035123036123037123038123039123040123041123042123043123044123045123046123047123048123049123050123051123052123053123054123055123056123057123058123059123060123061123062123063123064123065123066123067123068123069123070123071123072123073123074123075123076123077123078123079123080123081123082123083123084123085123086123087123088123089123090123091123092123093123094123095123096123097123098123099123100123101123102123103123104123105123106123107123108123109123110123111123112123113123114123115123116123117123118123119123120123121123122123123123124123125123126123127123128123129123130123131123132123133123134123135123136123137123138123139123140123141123142123143123144123145123146123147123148123149123150123151123152123153123154123155123156123157123158123159123160123161123162123163123164123165123166123167123168123169123170123171123172123173123174123175123176123177123178123179123180123181123182123183123184123185123186123187123188123189123190123191123192123193123194123195123196123197123198123199123200123201123202123203123204123205123206123207123208123209123210123211123212123213123214123215123216123217123218123219123220123221123222123223123224123225123226123227123228123229123230123231123232123233123234123235123236123237123238123239123240123241123242123243123244123245123246123247123248123249123250123251123252123253123254123255123256123257123258123259123260123261123262123263123264123265123266123267123268123269123270123271123272123273123274123275123276123277123278123279123280123281123282123283123284123285123286123287123288123289123290123291123292123293123294123295123296123297123298123299123300123301123302123303123304123305123306123307123308123309123310123311123312123313123314123315123316123317123318123319123320123321123322123323123324123325123326123327123328123329123330123331123332123333123334123335123336123337123338123339123340123341123342123343123344123345123346123347123348123349123350123351123352123353123354123355123356123357123358123359123360123361123362123363123364123365123366123367123368123369123370123371123372123373123374123375123376123377123378123379123380123381123382123383123384123385123386123387123388123389123390123391123392123393123394123395123396123397123398123399123400123401123402123403123404123405123406123407123408123409123410123411123412123413123414123415123416123417123418123419123420123421123422123423123424123425123426123427123428123429123430123431123432123433123434123435123436123437123438123439123440123441123442123443123444123445123446123447123448123449123450123451123452123453123454123455123456123457123458123459123460123461123462123463123464123465123466123467123468123469123470123471123472123473123474123475123476123477123478123479123480123481123482123483123484123485123486123487123488123489123490123491123492123493123494123495123496123497123498123499123500123501123502123503123504123505123506123507123508123509123510123511123512123513123514123515123516123517123518123519123520123521123522123523123524123525123526123527123528123529123530123531123532123533123534123535123536123537123538123539123540123541123542123543123544123545123546123547123548123549123550123551123552123553123554123555123556123557123558123559123560123561123562123563123564123565123566123567123568123569123570123571123572123573123574123575123576123577123578123579123580123581123582123583123584123585123586123587123588123589123590123591123592123593123594123595123596123597123598123599123600123601123602123603123604123605123606123607123608123609123610123611123612123613123614123615123616123617123618123619123620123621123622123623123624123625123626123627123628123629123630123631123632123633123634123635123636123637123638123639123640123641123642123643123644123645123646123647123648123649123650123651123652123653123654123655123656123657123658123659123660123661123662123663123664123665123666123667123668123669123670123671123672123673123674123675123676123677123678123679123680123681123682123683123684123685123686123687123688123689123690123691123692123693123694123695123696123697123698123699123700123701123702123703123704123705123706123707123708123709123710123711123712123713123714123715123716123717123718123719123720123721123722123723123724123725123726123727123728123729123730123731123732123733123734123735123736123737123738123739123740123741123742123743123744123745123746123747123748123749123750123751123752123753123754123755123756123757123758123759123760123761123762123763123764123765123766123767123768123769123770123771123772123773123774123775123776123777123778123779123780123781123782123783123784123785123786123787123788123789123790123791123792123793123794123795123796123797123798123799123800123801123802123803123804123805123806123807123808123809123810123811123812123813123814123815123816123817123818123819123820123821123822123823123824123825123826123827123828123829123830123831123832123833123834123835123836123837123838123839123840123841123842123843123844123845123846123847123848123849123850123851123852123853123854123855123856123857123858123859123860123861123862123863123864123865123866123867123868123869123870123871123872123873123874123875123876123877123878123879123880123881123882123883123884123885123886123887123888123889123890123891123892123893123894123895123896123897123898123899123900123901123902123903123904123905123906123907123908123909123910123911123912123913123914123915123916123917123918123919123920123921123922123923123924123925123926123927123928123929123930123931123932123933123934123935123936123937123938123939123940123941123942123943123944123945123946123947123948123949123950123951123952123953123954123955123956123957123958123959123960123961123962123963123964123965123966123967123968123969123970123971123972123973123974123975123976123977123978123979123980123981123982123983123984123985123986123987123988123989123990123991123992123993123994123995123996123997123998123999124000124001124002124003124004124005124006124007124008124009124010124011124012124013124014124015124016124017124018124019124020124021124022124023124024124025124026124027124028124029124030124031124032124033124034124035124036124037124038124039124040124041124042124043124044124045124046124047124048124049124050124051124052124053124054124055124056124057124058124059124060124061124062124063124064124065124066124067124068124069124070124071124072124073124074124075124076124077124078124079124080124081124082124083124084124085124086124087124088124089124090124091124092124093124094124095124096124097124098124099124100124101124102124103124104124105124106124107124108124109124110124111124112124113124114124115124116124117124118124119124120124121124122124123124124124125124126124127124128124129124130124131124132124133124134124135124136124137124138124139124140124141124142124143124144124145124146124147124148124149124150124151124152124153124154124155124156124157124158124159124160124161124162124163124164124165124166124167124168124169124170124171124172124173124174124175124176124177124178124179124180124181124182124183124184124185124186124187124188124189124190124191124192124193124194124195124196124197124198124199124200124201124202124203124204124205124206124207124208124209124210124211124212124213124214124215124216124217124218124219124220124221124222124223124224124225124226124227124228124229124230124231124232124233124234124235124236124237124238124239124240124241124242124243124244124245124246124247124248124249124250124251124252124253124254124255124256124257124258124259124260124261124262124263124264124265124266124267124268124269124270124271124272124273124274124275124276124277124278124279124280124281124282124283124284124285124286124287124288124289124290124291124292124293124294124295124296124297124298124299124300124301124302124303124304124305124306124307124308124309124310124311124312124313124314124315124316124317124318124319124320124321124322124323124324124325124326124327124328124329124330124331124332124333124334124335124336124337124338124339124340124341124342124343124344124345124346124347124348124349124350124351124352124353124354124355124356124357124358124359124360124361124362124363124364124365124366124367124368124369124370124371124372124373124374124375124376124377124378124379124380124381124382124383124384124385124386124387124388124389124390124391124392124393124394124395124396124397124398124399124400124401124402124403124404124405124406124407124408124409124410124411124412124413124414124415124416124417124418124419124420124421124422124423124424124425124426124427124428124429124430124431124432124433124434124435124436124437124438124439124440124441124442124443124444124445124446124447124448124449124450124451124452124453124454124455124456124457124458124459124460124461124462124463124464124465124466124467124468124469124470124471124472124473124474124475124476124477124478124479124480124481124482124483124484124485124486124487124488124489124490124491124492124493124494124495124496124497124498124499124500124501124502124503124504124505124506124507124508124509124510124511124512124513124514124515124516124517124518124519124520124521124522124523124524124525124526124527124528124529124530124531124532124533124534124535124536124537124538124539124540124541124542124543124544124545124546124547124548124549124550124551124552124553124554124555124556124557124558124559124560124561124562124563124564124565124566124567124568124569124570124571124572124573124574124575124576124577124578124579124580124581124582124583124584124585124586124587124588124589124590124591124592124593124594124595124596124597124598124599124600124601124602124603124604124605124606124607124608124609124610124611124612124613124614124615124616124617124618124619124620124621124622124623124624124625124626124627124628124629124630124631124632124633124634124635124636124637124638124639124640124641124642124643124644124645124646124647124648124649124650124651124652124653124654124655124656124657124658124659124660124661124662124663124664124665124666124667124668124669124670124671124672124673124674124675124676124677124678124679124680124681124682124683124684124685124686124687124688124689124690124691124692124693124694124695124696124697124698124699124700124701124702124703124704124705124706124707124708124709124710124711124712124713124714124715124716124717124718124719124720124721124722124723124724124725124726124727124728124729124730124731124732124733124734124735124736124737124738124739124740124741124742124743124744124745124746124747124748124749124750124751124752124753124754124755124756124757124758124759124760124761124762124763124764124765124766124767124768124769124770124771124772124773124774124775124776124777124778124779124780124781124782124783124784124785124786124787124788124789124790124791124792124793124794124795124796124797124798124799124800124801124802124803124804124805124806124807124808124809124810124811124812124813124814124815124816124817124818124819124820124821124822124823124824124825124826124827124828124829124830124831124832124833124834124835124836124837124838124839124840124841124842124843124844124845124846124847124848124849124850124851124852124853124854124855124856124857124858124859124860124861124862124863124864124865124866124867124868124869124870124871124872124873124874124875124876124877124878124879124880124881124882124883124884124885124886124887124888124889124890124891124892124893124894124895124896124897124898124899124900124901124902124903124904124905124906124907124908124909124910124911124912124913124914124915124916124917124918124919124920124921124922124923124924124925124926124927124928124929124930124931124932124933124934124935124936124937124938124939124940124941124942124943124944124945124946124947124948124949124950124951124952124953124954124955124956124957124958124959124960124961124962124963124964124965124966124967124968124969124970124971124972124973124974124975124976124977124978124979124980124981124982124983124984124985124986124987124988124989124990124991124992124993124994124995124996124997124998124999125000125001125002125003125004125005125006125007125008125009125010125011125012125013125014125015125016125017125018125019125020125021125022125023125024125025125026125027125028125029125030125031125032125033125034125035125036125037125038125039125040125041125042125043125044125045125046125047125048125049125050125051125052125053125054125055125056125057125058125059125060125061125062125063125064125065125066125067125068125069125070125071125072125073125074125075125076125077125078125079125080125081125082125083125084125085125086125087125088125089125090125091125092125093125094125095125096125097125098125099125100125101125102125103125104125105125106125107125108125109125110125111125112125113125114125115125116125117125118125119125120125121125122125123125124125125125126125127125128125129125130125131125132125133125134125135125136125137125138125139125140125141125142125143125144125145125146125147125148125149125150125151125152125153125154125155125156125157125158125159125160125161125162125163125164125165125166125167125168125169125170125171125172125173125174125175125176125177125178125179125180125181125182125183125184125185125186125187125188125189125190125191125192125193125194125195125196125197125198125199125200125201125202125203125204125205125206125207125208125209125210125211125212125213125214125215125216125217125218125219125220125221125222125223125224125225125226125227125228125229125230125231125232125233125234125235125236125237125238125239125240125241125242125243125244125245125246125247125248125249125250125251125252125253125254125255125256125257125258125259125260125261125262125263125264125265125266125267125268125269125270125271125272125273125274125275125276125277125278125279125280125281125282125283125284125285125286125287125288125289125290125291125292125293125294125295125296125297125298125299125300125301125302125303125304125305125306125307125308125309125310125311125312125313125314125315125316125317125318125319125320125321125322125323125324125325125326125327125328125329125330125331125332125333125334125335125336125337125338125339125340125341125342125343125344125345125346125347125348125349125350125351125352125353125354125355125356125357125358125359125360125361125362125363125364125365125366125367125368125369125370125371125372125373125374125375125376125377125378125379125380125381125382125383125384125385125386125387125388125389125390125391125392125393125394125395125396125397125398125399125400125401125402125403125404125405125406125407125408125409125410125411125412125413125414125415125416125417125418125419125420125421125422125423125424125425125426125427125428125429125430125431125432125433125434125435125436125437125438125439125440125441125442125443125444125445125446125447125448125449125450125451125452125453125454125455125456125457125458125459125460125461125462125463125464125465125466125467125468125469125470125471125472125473125474125475125476125477125478125479125480125481125482125483125484125485125486125487125488125489125490125491125492125493125494125495125496125497125498125499125500125501125502125503125504125505125506125507125508125509125510125511125512125513125514125515125516125517125518125519125520125521125522125523125524125525125526125527125528125529125530125531125532125533125534125535125536125537125538125539125540125541125542125543125544125545125546125547125548125549125550125551125552125553125554125555125556125557125558125559125560125561125562125563125564125565125566125567125568125569125570125571125572125573125574125575125576125577125578125579125580125581125582125583125584125585125586125587125588125589125590125591125592125593125594125595125596125597125598125599125600125601125602125603125604125605125606125607125608125609125610125611125612125613125614125615125616125617125618125619125620125621125622125623125624125625125626125627125628125629125630125631125632125633125634125635125636125637125638125639125640125641125642125643125644125645125646125647125648125649125650125651125652125653125654125655125656125657125658125659125660125661125662125663125664125665125666125667125668125669125670125671125672125673125674125675125676125677125678125679125680125681125682125683125684125685125686125687125688125689125690125691125692125693125694125695125696125697125698125699125700125701125702125703125704125705125706125707125708125709125710125711125712125713125714125715125716125717125718125719125720125721125722125723125724125725125726125727125728125729125730125731125732125733125734125735125736125737125738125739125740125741125742125743125744125745125746125747125748125749125750125751125752125753125754125755125756125757125758125759125760125761125762125763125764125765125766125767125768125769125770125771125772125773125774125775125776125777125778125779125780125781125782125783125784125785125786125787125788125789125790125791125792125793125794125795125796125797125798125799125800125801125802125803125804125805125806125807125808125809125810125811125812125813125814125815125816125817125818125819125820125821125822125823125824125825125826125827125828125829125830125831125832125833125834125835125836125837125838125839125840125841125842125843125844125845125846125847125848125849125850125851125852125853125854125855125856125857125858125859125860125861125862125863125864125865125866125867125868125869125870125871125872125873125874125875125876125877125878125879125880125881125882125883125884125885125886125887125888125889125890125891125892125893125894125895125896125897125898125899125900125901125902125903125904125905125906125907125908125909125910125911125912125913125914125915125916125917125918125919125920125921125922125923125924125925125926125927125928125929125930125931125932125933125934125935125936125937125938125939125940125941125942125943125944125945125946125947125948125949125950125951125952125953125954125955125956125957125958125959125960125961125962125963125964125965125966125967125968125969125970125971125972125973125974125975125976125977125978125979125980125981125982125983125984125985125986125987125988125989125990125991125992125993125994125995125996125997125998125999126000126001126002126003126004126005126006126007126008126009126010126011126012126013126014126015126016126017126018126019126020126021126022126023126024126025126026126027126028126029126030126031126032126033126034126035126036126037126038126039126040126041126042126043126044126045126046126047126048126049126050126051126052126053126054126055126056126057126058126059126060126061126062126063126064126065126066126067126068126069126070126071126072126073126074126075126076126077126078126079126080126081126082126083126084126085126086126087126088126089126090126091126092126093126094126095126096126097126098126099126100126101126102126103126104126105126106126107126108126109126110126111126112126113126114126115126116126117126118126119126120126121126122126123126124126125126126126127126128126129126130126131126132126133126134126135126136126137126138126139126140126141126142126143126144126145126146126147126148126149126150126151126152126153126154126155126156126157126158126159126160126161126162126163126164126165126166126167126168126169126170126171126172126173126174126175126176126177126178126179126180126181126182126183126184126185126186126187126188126189126190126191126192126193126194126195126196126197126198126199126200126201126202126203126204126205126206126207126208126209126210126211126212126213126214126215126216126217126218126219126220126221126222126223126224126225126226126227126228126229126230126231126232126233126234126235126236126237126238126239126240126241126242126243126244126245126246126247126248126249126250126251126252126253126254126255126256126257126258126259126260126261126262126263126264126265126266126267126268126269126270126271126272126273126274126275126276126277126278126279126280126281126282126283126284126285126286126287126288126289126290126291126292126293126294126295126296126297126298126299126300126301126302126303126304126305126306126307126308126309126310126311126312126313126314126315126316126317126318126319126320126321126322126323126324126325126326126327126328126329126330126331126332126333126334126335126336126337126338126339126340126341126342126343126344126345126346126347126348126349126350126351126352126353126354126355126356126357126358126359126360126361126362126363126364126365126366126367126368126369126370126371126372126373126374126375126376126377126378126379126380126381126382126383126384126385126386126387126388126389126390126391126392126393126394126395126396126397126398126399126400126401126402126403126404126405126406126407126408126409126410126411126412126413126414126415126416126417126418126419126420126421126422126423126424126425126426126427126428126429126430126431126432126433126434126435126436126437126438126439126440126441126442126443126444126445126446126447126448126449126450126451126452126453126454126455126456126457126458126459126460126461126462126463126464126465126466126467126468126469126470126471126472126473126474126475126476126477126478126479126480126481126482126483126484126485126486126487126488126489126490126491126492126493126494126495126496126497126498126499126500126501126502126503126504126505126506126507126508126509126510126511126512126513126514126515126516126517126518126519126520126521126522126523126524126525126526126527126528126529126530126531126532126533126534126535126536126537126538126539126540126541126542126543126544126545126546126547126548126549126550126551126552126553126554126555126556126557126558126559126560126561126562126563126564126565126566126567126568126569126570126571126572126573126574126575126576126577126578126579126580126581126582126583126584126585126586126587126588126589126590126591126592126593126594126595126596126597126598126599126600126601126602126603126604126605126606126607126608126609126610126611126612126613126614126615126616126617126618126619126620126621126622126623126624126625126626126627126628126629126630126631126632126633126634126635126636126637126638126639126640126641126642126643126644126645126646126647126648126649126650126651126652126653126654126655126656126657126658126659126660126661126662126663126664126665126666126667126668126669126670126671126672126673126674126675126676126677126678126679126680126681126682126683126684126685126686126687126688126689126690126691126692126693126694126695126696126697126698126699126700126701126702126703126704126705126706126707126708126709126710126711126712126713126714126715126716126717126718126719126720126721126722126723126724126725126726126727126728126729126730126731126732126733126734126735126736126737126738126739126740126741126742126743126744126745126746126747126748126749126750126751126752126753126754126755126756126757126758126759126760126761126762126763126764126765126766126767126768126769126770126771126772126773126774126775126776126777126778126779126780126781126782126783126784126785126786126787126788126789126790126791126792126793126794126795126796126797126798126799126800126801126802126803126804126805126806126807126808126809126810126811126812126813126814126815126816126817126818126819126820126821126822126823126824126825126826126827126828126829126830126831126832126833126834126835126836126837126838126839126840126841126842126843126844126845126846126847126848126849126850126851126852126853126854126855126856126857126858126859126860126861126862126863126864126865126866126867126868126869126870126871126872126873126874126875126876126877126878126879126880126881126882126883126884126885126886126887126888126889126890126891126892126893126894126895126896126897126898126899126900126901126902126903126904126905126906126907126908126909126910126911126912126913126914126915126916126917126918126919126920126921126922126923126924126925126926126927126928126929126930126931126932126933126934126935126936126937126938126939126940126941126942126943126944126945126946126947126948126949126950126951126952126953126954126955126956126957126958126959126960126961126962126963126964126965126966126967126968126969126970126971126972126973126974126975126976126977126978126979126980126981126982126983126984126985126986126987126988126989126990126991126992126993126994126995126996126997126998126999127000127001127002127003127004127005127006127007127008127009127010127011127012127013127014127015127016127017127018127019127020127021127022127023127024127025127026127027127028127029127030127031127032127033127034127035127036127037127038127039127040127041127042127043127044127045127046127047127048127049127050127051127052127053127054127055127056127057127058127059127060127061127062127063127064127065127066127067127068127069127070127071127072127073127074127075127076127077127078127079127080127081127082127083127084127085127086127087127088127089127090127091127092127093127094127095127096127097127098127099127100127101127102127103127104127105127106127107127108127109127110127111127112127113127114127115127116127117127118127119127120127121127122127123127124127125127126127127127128127129127130127131127132127133127134127135127136127137127138127139127140127141127142127143127144127145127146127147127148127149127150127151127152127153127154127155127156127157127158127159127160127161127162127163127164127165127166127167127168127169127170127171127172127173127174127175127176127177127178127179127180127181127182127183127184127185127186127187127188127189127190127191127192127193127194127195127196127197127198127199127200127201127202127203127204127205127206127207127208127209127210127211127212127213127214127215127216127217127218127219127220127221127222127223127224127225127226127227127228127229127230127231127232127233127234127235127236127237127238127239127240127241127242127243127244127245127246127247127248127249127250127251127252127253127254127255127256127257127258127259127260127261127262127263127264127265127266127267127268127269127270127271127272127273127274127275127276127277127278127279127280127281127282127283127284127285127286127287127288127289127290127291127292127293127294127295127296127297127298127299127300127301127302127303127304127305127306127307127308127309127310127311127312127313127314127315127316127317127318127319127320127321127322127323127324127325127326127327127328127329127330127331127332127333127334127335127336127337127338127339127340127341127342127343127344127345127346127347127348127349127350127351127352127353127354127355127356127357127358127359127360127361127362127363127364127365127366127367127368127369127370127371127372127373127374127375127376127377127378127379127380127381127382127383127384127385127386127387127388127389127390127391127392127393127394127395127396127397127398127399127400127401127402127403127404127405127406127407127408127409127410127411127412127413127414127415127416127417127418127419127420127421127422127423127424127425127426127427127428127429127430127431127432127433127434127435127436127437127438127439127440127441127442127443127444127445127446127447127448127449127450127451127452127453127454127455127456127457127458127459127460127461127462127463127464127465127466127467127468127469127470127471127472127473127474127475127476127477127478127479127480127481127482127483127484127485127486127487127488127489127490127491127492127493127494127495127496127497127498127499127500127501127502127503127504127505127506127507127508127509127510127511127512127513127514127515127516127517127518127519127520127521127522127523127524127525127526127527127528127529127530127531127532127533127534127535127536127537127538127539127540127541127542127543127544127545127546127547127548127549127550127551127552127553127554127555127556127557127558127559127560127561127562127563127564127565127566127567127568127569127570127571127572127573127574127575127576127577127578127579127580127581127582127583127584127585127586127587127588127589127590127591127592127593127594127595127596127597127598127599127600127601127602127603127604127605127606127607127608127609127610127611127612127613127614127615127616127617127618127619127620127621127622127623127624127625127626127627127628127629127630127631127632127633127634127635127636127637127638127639127640127641127642127643127644127645127646127647127648127649127650127651127652127653127654127655127656127657127658127659127660127661127662127663127664127665127666127667127668127669127670127671127672127673127674127675127676127677127678127679127680127681127682127683127684127685127686127687127688127689127690127691127692127693127694127695127696127697127698127699127700127701127702127703127704127705127706127707127708127709127710127711127712127713127714127715127716127717127718127719127720127721127722127723127724127725127726127727127728127729127730127731127732127733127734127735127736127737127738127739127740127741127742127743127744127745127746127747127748127749127750127751127752127753127754127755127756127757127758127759127760127761127762127763127764127765127766127767127768127769127770127771127772127773127774127775127776127777127778127779127780127781127782127783127784127785127786127787127788127789127790127791127792127793127794127795127796127797127798127799127800127801127802127803127804127805127806127807127808127809127810127811127812127813127814127815127816127817127818127819127820127821127822127823127824127825127826127827127828127829127830127831127832127833127834127835127836127837127838127839127840127841127842127843127844127845127846127847127848127849127850127851127852127853127854127855127856127857127858127859127860127861127862127863127864127865127866127867127868127869127870127871127872127873127874127875127876127877127878127879127880127881127882127883127884127885127886127887127888127889127890127891127892127893127894127895127896127897127898127899127900127901127902127903127904127905127906127907127908127909127910127911127912127913127914127915127916127917127918127919127920127921127922127923127924127925127926127927127928127929127930127931127932127933127934127935127936127937127938127939127940127941127942127943127944127945127946127947127948127949127950127951127952127953127954127955127956127957127958127959127960127961127962127963127964127965127966127967127968127969127970127971127972127973127974127975127976127977127978127979127980127981127982127983127984127985127986127987127988127989127990127991127992127993127994127995127996127997127998127999128000128001128002128003128004128005128006128007128008128009128010128011128012128013128014128015128016128017128018128019128020128021128022128023128024128025128026128027128028128029128030128031128032128033128034128035128036128037128038128039128040128041128042128043128044128045128046128047128048128049128050128051128052128053128054128055128056128057128058128059128060128061128062128063128064128065128066128067128068128069128070128071128072128073128074128075128076128077128078128079128080128081128082128083128084128085128086128087128088128089128090128091128092128093128094128095128096128097128098128099128100128101128102128103128104128105128106128107128108128109128110128111128112128113128114128115128116128117128118128119128120128121128122128123128124128125128126128127128128128129128130128131128132128133128134128135128136128137128138128139128140128141128142128143128144128145128146128147128148128149128150128151128152128153128154128155128156128157128158128159128160128161128162128163128164128165128166128167128168128169128170128171128172128173128174128175128176128177128178128179128180128181128182128183128184128185128186128187128188128189128190128191128192128193128194128195128196128197128198128199128200128201128202128203128204128205128206128207128208128209128210128211128212128213128214128215128216128217128218128219128220128221128222128223128224128225128226128227128228128229128230128231128232128233128234128235128236128237128238128239128240128241128242128243128244128245128246128247128248128249128250128251128252128253128254128255128256128257128258128259128260128261128262128263128264128265128266128267128268128269128270128271128272128273128274128275128276128277128278128279128280128281128282128283128284128285128286128287128288128289128290128291128292128293128294128295128296128297128298128299128300128301128302128303128304128305128306128307128308128309128310128311128312128313128314128315128316128317128318128319128320128321128322128323128324128325128326128327128328128329128330128331128332128333128334128335128336128337128338128339128340128341128342128343128344128345128346128347128348128349128350128351128352128353128354128355128356128357128358128359128360128361128362128363128364128365128366128367128368128369128370128371128372128373128374128375128376128377128378128379128380128381128382128383128384128385128386128387128388128389128390128391128392128393128394128395128396128397128398128399128400128401128402128403128404128405128406128407128408128409128410128411128412128413128414128415128416128417128418128419128420128421128422128423128424128425128426128427128428128429128430128431128432128433128434128435128436128437128438128439128440128441128442128443128444128445128446128447128448128449128450128451128452128453128454128455128456128457128458128459128460128461128462128463128464128465128466128467128468128469128470128471128472128473128474128475128476128477128478128479128480128481128482128483128484128485128486128487128488128489128490128491128492128493128494128495128496128497128498128499128500128501128502128503128504128505128506128507128508128509128510128511128512128513128514128515128516128517128518128519128520128521128522128523128524128525128526128527128528128529128530128531128532128533128534128535128536128537128538128539128540128541128542128543128544128545128546128547128548128549128550128551128552128553128554128555128556128557128558128559128560128561128562128563128564128565128566128567128568128569128570128571128572128573128574128575128576128577128578128579128580128581128582128583128584128585128586128587128588128589128590128591128592128593128594128595128596128597128598128599128600128601128602128603128604128605128606128607128608128609128610128611128612128613128614128615128616128617128618128619128620128621128622128623128624128625128626128627128628128629128630128631128632128633128634128635128636128637128638128639128640128641128642128643128644128645128646128647128648128649128650128651128652128653128654128655128656128657128658128659128660128661128662128663128664128665128666128667128668128669128670128671128672128673128674128675128676128677128678128679128680128681128682128683128684128685128686128687128688128689128690128691128692128693128694128695128696128697128698128699128700128701128702128703128704128705128706128707128708128709128710128711128712128713128714128715128716128717128718128719128720128721128722128723128724128725128726128727128728128729128730128731128732128733128734128735128736128737128738128739128740128741128742128743128744128745128746128747128748128749128750128751128752128753128754128755128756128757128758128759128760128761128762128763128764128765128766128767128768128769128770128771128772128773128774128775128776128777128778128779128780128781128782128783128784128785128786128787128788128789128790128791128792128793128794128795128796128797128798128799128800128801128802128803128804128805128806128807128808128809128810128811128812128813128814128815128816128817128818128819128820128821128822128823128824128825128826128827128828128829128830128831128832128833128834128835128836128837128838128839128840128841128842128843128844128845128846128847128848128849128850128851128852128853128854128855128856128857128858128859128860128861128862128863128864128865128866128867128868128869128870128871128872128873128874128875128876128877128878128879128880128881128882128883128884128885128886128887128888128889128890128891128892128893128894128895128896128897128898128899128900128901128902128903128904128905128906128907128908128909128910128911128912128913128914128915128916128917128918128919128920128921128922128923128924128925128926128927128928128929128930128931128932128933128934128935128936128937128938128939128940128941128942128943128944128945128946128947128948128949128950128951128952128953128954128955128956128957128958128959128960128961128962128963128964128965128966128967128968128969128970128971128972128973128974128975128976128977128978128979128980128981128982128983128984128985128986128987128988128989128990128991128992128993128994128995128996128997128998128999129000129001129002129003129004129005129006129007129008129009129010129011129012129013129014129015129016129017129018129019129020129021129022129023129024129025129026129027129028129029129030129031129032129033129034129035129036129037129038129039129040129041129042129043129044129045129046129047129048129049129050129051129052129053129054129055129056129057129058129059129060129061129062129063129064129065129066129067129068129069129070129071129072129073129074129075129076129077129078129079129080129081129082129083129084129085129086129087129088129089129090129091129092129093129094129095129096129097129098129099129100129101129102129103129104129105129106129107129108129109129110129111129112129113129114129115129116129117129118129119129120129121129122129123129124129125129126129127129128129129129130129131129132129133129134129135129136129137129138129139129140129141129142129143129144129145129146129147129148129149129150129151129152129153129154129155129156129157129158129159129160129161129162129163129164129165129166129167129168129169129170129171129172129173129174129175129176129177129178129179129180129181129182129183129184129185129186129187129188129189129190129191129192129193129194129195129196129197129198129199129200129201129202129203129204129205129206129207129208129209129210129211129212129213129214129215129216129217129218129219129220129221129222129223129224129225129226129227129228129229129230129231129232129233129234129235129236129237129238129239129240129241129242129243129244129245129246129247129248129249129250129251129252129253129254129255129256129257129258129259129260129261129262129263129264129265129266129267129268129269129270129271129272129273129274129275129276129277129278129279129280129281129282129283129284129285129286129287129288129289129290129291129292129293129294129295129296129297129298129299129300129301129302129303129304129305129306129307129308129309129310129311129312129313129314129315129316129317129318129319129320129321129322129323129324129325129326129327129328129329129330129331129332129333129334129335129336129337129338129339129340129341129342129343129344129345129346129347129348129349129350129351129352129353129354129355129356129357129358129359129360129361129362129363129364129365129366129367129368129369129370129371129372129373129374129375129376129377129378129379129380129381129382129383129384129385129386129387129388129389129390129391129392129393129394129395129396129397129398129399129400129401129402129403129404129405129406129407129408129409129410129411129412129413129414129415129416129417129418129419129420129421129422129423129424129425129426129427129428129429129430129431129432129433129434129435129436129437129438129439129440129441129442129443129444129445129446129447129448129449129450129451129452129453129454129455129456129457129458129459129460129461129462129463129464129465129466129467129468129469129470129471129472129473129474129475129476129477129478129479129480129481129482129483129484129485129486129487129488129489129490129491129492129493129494129495129496129497129498129499129500129501129502129503129504129505129506129507129508129509129510129511129512129513129514129515129516129517129518129519129520129521129522129523129524129525129526129527129528129529129530129531129532129533129534129535129536129537129538129539129540129541129542129543129544129545129546129547129548129549129550129551129552129553129554129555129556129557129558129559129560129561129562129563129564129565129566129567129568129569129570129571129572129573129574129575129576129577129578129579129580129581129582129583129584129585129586129587129588129589129590129591129592129593129594129595129596129597129598129599129600129601129602129603129604129605129606129607129608129609129610129611129612129613129614129615129616129617129618129619129620129621129622129623129624129625129626129627129628129629129630129631129632129633129634129635129636129637129638129639129640129641129642129643129644129645129646129647129648129649129650129651129652129653129654129655129656129657129658129659129660129661129662129663129664129665129666129667129668129669129670129671129672129673129674129675129676129677129678129679129680129681129682129683129684129685129686129687129688129689129690129691129692129693129694129695129696129697129698129699129700129701129702129703129704129705129706129707129708129709129710129711129712129713129714129715129716129717129718129719129720129721129722129723129724129725129726129727129728129729129730129731129732129733129734129735129736129737129738129739129740129741129742129743129744129745129746129747129748129749129750129751129752129753129754129755129756129757129758129759129760129761129762129763129764129765129766129767129768129769129770129771129772129773129774129775129776129777129778129779129780129781129782129783129784129785129786129787129788129789129790129791129792129793129794129795129796129797129798129799129800129801129802129803129804129805129806129807129808129809129810129811129812129813129814129815129816129817129818129819129820129821129822129823129824129825129826129827129828129829129830129831129832129833129834129835129836129837129838129839129840129841129842129843129844129845129846129847129848129849129850129851129852129853129854129855129856129857129858129859129860129861129862129863129864129865129866129867129868129869129870129871129872129873129874129875129876129877129878129879129880129881129882129883129884129885129886129887129888129889129890129891129892129893129894129895129896129897129898129899129900129901129902129903129904129905129906129907129908129909129910129911129912129913129914129915129916129917129918129919129920129921129922129923129924129925129926129927129928129929129930129931129932129933129934129935129936129937129938129939129940129941129942129943129944129945129946129947129948129949129950129951129952129953129954129955129956129957129958129959129960129961129962129963129964129965129966129967129968129969129970129971129972129973129974129975129976129977129978129979129980129981129982129983129984129985129986129987129988129989129990129991129992129993129994129995129996129997129998129999130000130001130002130003130004130005130006130007130008130009130010130011130012130013130014130015130016130017130018130019130020130021130022130023130024130025130026130027130028130029130030130031130032130033130034130035130036130037130038130039130040130041130042130043130044130045130046130047130048130049130050130051130052130053130054130055130056130057130058130059130060130061130062130063130064130065130066130067130068130069130070130071130072130073130074130075130076130077130078130079130080130081130082130083130084130085130086130087130088130089130090130091130092130093130094130095130096130097130098130099130100130101130102130103130104130105130106130107130108130109130110130111130112130113130114130115130116130117130118130119130120130121130122130123130124130125130126130127130128130129130130130131130132130133130134130135130136130137130138130139130140130141130142130143130144130145130146130147130148130149130150130151130152130153130154130155130156130157130158130159130160130161130162130163130164130165130166130167130168130169130170130171130172130173130174130175130176130177130178130179130180130181130182130183130184130185130186130187130188130189130190130191130192130193130194130195130196130197130198130199130200130201130202130203130204130205130206130207130208130209130210130211130212130213130214130215130216130217130218130219130220130221130222130223130224130225130226130227130228130229130230130231130232130233130234130235130236130237130238130239130240130241130242130243130244130245130246130247130248130249130250130251130252130253130254130255130256130257130258130259130260130261130262130263130264130265130266130267130268130269130270130271130272130273130274130275130276130277130278130279130280130281130282130283130284130285130286130287130288130289130290130291130292130293130294130295130296130297130298130299130300130301130302130303130304130305130306130307130308130309130310130311130312130313130314130315130316130317130318130319130320130321130322130323130324130325130326130327130328130329130330130331130332130333130334130335130336130337130338130339130340130341130342130343130344130345130346130347130348130349130350130351130352130353130354130355130356130357130358130359130360130361130362130363130364130365130366130367130368130369130370130371130372130373130374130375130376130377130378130379130380130381130382130383130384130385130386130387130388130389130390130391130392130393130394130395130396130397130398130399130400130401130402130403130404130405130406130407130408130409130410130411130412130413130414130415130416130417130418130419130420130421130422130423130424130425130426130427130428130429130430130431130432130433130434130435130436130437130438130439130440130441130442130443130444130445130446130447130448130449130450130451130452130453130454130455130456130457130458130459130460130461130462130463130464130465130466130467130468130469130470130471130472130473130474130475130476130477130478130479130480130481130482130483130484130485130486130487130488130489130490130491130492130493130494130495130496130497130498130499130500130501130502130503130504130505130506130507130508130509130510130511130512130513130514130515130516130517130518130519130520130521130522130523130524130525130526130527130528130529130530130531130532130533130534130535130536130537130538130539130540130541130542130543130544130545130546130547130548130549130550130551130552130553130554130555130556130557130558130559130560130561130562130563130564130565130566130567130568130569130570130571130572130573130574130575130576130577130578130579130580130581130582130583130584130585130586130587130588130589130590130591130592130593130594130595130596130597130598130599130600130601130602130603130604130605130606130607130608130609130610130611130612130613130614130615130616130617130618130619130620130621130622130623130624130625130626130627130628130629130630130631130632130633130634130635130636130637130638130639130640130641130642130643130644130645130646130647130648130649130650130651130652130653130654130655130656130657130658130659130660130661130662130663130664130665130666130667130668130669130670130671130672130673130674130675130676130677130678130679130680130681130682130683130684130685130686130687130688130689130690130691130692130693130694130695130696130697130698130699130700130701130702130703130704130705130706130707130708130709130710130711130712130713130714130715130716130717130718130719130720130721130722130723130724130725130726130727130728130729130730130731130732130733130734130735130736130737130738130739130740130741130742130743130744130745130746130747130748130749130750130751130752130753130754130755130756130757130758130759130760130761130762130763130764130765130766130767130768130769130770130771130772130773130774130775130776130777130778130779130780130781130782130783130784130785130786130787130788130789130790130791130792130793130794130795130796130797130798130799130800130801130802130803130804130805130806130807130808130809130810130811130812130813130814130815130816130817130818130819130820130821130822130823130824130825130826130827130828130829130830130831130832130833130834130835130836130837130838130839130840130841130842130843130844130845130846130847130848130849130850130851130852130853130854130855130856130857130858130859130860130861130862130863130864130865130866130867130868130869130870130871130872130873130874130875130876130877130878130879130880130881130882130883130884130885130886130887130888130889130890130891130892130893130894130895130896130897130898130899130900130901130902130903130904130905130906130907130908130909130910130911130912130913130914130915130916130917130918130919130920130921130922130923130924130925130926130927130928130929130930130931130932130933130934130935130936130937130938130939130940130941130942130943130944130945130946130947130948130949130950130951130952130953130954130955130956130957130958130959130960130961130962130963130964130965130966130967130968130969130970130971130972130973130974130975130976130977130978130979130980130981130982130983130984130985130986130987130988130989130990130991130992130993130994130995130996130997130998130999131000131001131002131003131004131005131006131007131008131009131010131011131012131013131014131015131016131017131018131019131020131021131022131023131024131025131026131027131028131029131030131031131032131033131034131035131036131037131038131039131040131041131042131043131044131045131046131047131048131049131050131051131052131053131054131055131056131057131058131059131060131061131062131063131064131065131066131067131068131069131070131071131072131073131074131075131076131077131078131079131080131081131082131083131084131085131086131087131088131089131090131091131092131093131094131095131096131097131098131099131100131101131102131103131104131105131106131107131108131109131110131111131112131113131114131115131116131117131118131119131120131121131122131123131124131125131126131127131128131129131130131131131132131133131134131135131136131137131138131139131140131141131142131143131144131145131146131147131148131149131150131151131152131153131154131155131156131157131158131159131160131161131162131163131164131165131166131167131168131169131170131171131172131173131174131175131176131177131178131179131180131181131182131183131184131185131186131187131188131189131190131191131192131193131194131195131196131197131198131199131200131201131202131203131204131205131206131207131208131209131210131211131212131213131214131215131216131217131218131219131220131221131222131223131224131225131226131227131228131229131230131231131232131233131234131235131236131237131238131239131240131241131242131243131244131245131246131247131248131249131250131251131252131253131254131255131256131257131258131259131260131261131262131263131264131265131266131267131268131269131270131271131272131273131274131275131276131277131278131279131280131281131282131283131284131285131286131287131288131289131290131291131292131293131294131295131296131297131298131299131300131301131302131303131304131305131306131307131308131309131310131311131312131313131314131315131316131317131318131319131320131321131322131323131324131325131326131327131328131329131330131331131332131333131334131335131336131337131338131339131340131341131342131343131344131345131346131347131348131349131350131351131352131353131354131355131356131357131358131359131360131361131362131363131364131365131366131367131368131369131370131371131372131373131374131375131376131377131378131379131380131381131382131383131384131385131386131387131388131389131390131391131392131393131394131395131396131397131398131399131400131401131402131403131404131405131406131407131408131409131410131411131412131413131414131415131416131417131418131419131420131421131422131423131424131425131426131427131428131429131430131431131432131433131434131435131436131437131438131439131440131441131442131443131444131445131446131447131448131449131450131451131452131453131454131455131456131457131458131459131460131461131462131463131464131465131466131467131468131469131470131471131472131473131474131475131476131477131478131479131480131481131482131483131484131485131486131487131488131489131490131491131492131493131494131495131496131497131498131499131500131501131502131503131504131505131506131507131508131509131510131511131512131513131514131515131516131517131518131519131520131521131522131523131524131525131526131527131528131529131530131531131532131533131534131535131536131537131538131539131540131541131542131543131544131545131546131547131548131549131550131551131552131553131554131555131556131557131558131559131560131561131562131563131564131565131566131567131568131569131570131571131572131573131574131575131576131577131578131579131580131581131582131583131584131585131586131587131588131589131590131591131592131593131594131595131596131597131598131599131600131601131602131603131604131605131606131607131608131609131610131611131612131613131614131615131616131617131618131619131620131621131622131623131624131625131626131627131628131629131630131631131632131633131634131635131636131637131638131639131640131641131642131643131644131645131646131647131648131649131650131651131652131653131654131655131656131657131658131659131660131661131662131663131664131665131666131667131668131669131670131671131672131673131674131675131676131677131678131679131680131681131682131683131684131685131686131687131688131689131690131691131692131693131694131695131696131697131698131699131700131701131702131703131704131705131706131707131708131709131710131711131712131713131714131715131716131717131718131719131720131721131722131723131724131725131726131727131728131729131730131731131732131733131734131735131736131737131738131739131740131741131742131743131744131745131746131747131748131749131750131751131752131753131754131755131756131757131758131759131760131761131762131763131764131765131766131767131768131769131770131771131772131773131774131775131776131777131778131779131780131781131782131783131784131785131786131787131788131789131790131791131792131793131794131795131796131797131798131799131800131801131802131803131804131805131806131807131808131809131810131811131812131813131814131815131816131817131818131819131820131821131822131823131824131825131826131827131828131829131830131831131832131833131834131835131836131837131838131839131840131841131842131843131844131845131846131847131848131849131850131851131852131853131854131855131856131857131858131859131860131861131862131863131864131865131866131867131868131869131870131871131872131873131874131875131876131877131878131879131880131881131882131883131884131885131886131887131888131889131890131891131892131893131894131895131896131897131898131899131900131901131902131903131904131905131906131907131908131909131910131911131912131913131914131915131916131917131918131919131920131921131922131923131924131925131926131927131928131929131930131931131932131933131934131935131936131937131938131939131940131941131942131943131944131945131946131947131948131949131950131951131952131953131954131955131956131957131958131959131960131961131962131963131964131965131966131967131968131969131970131971131972131973131974131975131976131977131978131979131980131981131982131983131984131985131986131987131988131989131990131991131992131993131994131995131996131997131998131999132000132001132002132003132004132005132006132007132008132009132010132011132012132013132014132015132016132017132018132019132020132021132022132023132024132025132026132027132028132029132030132031132032132033132034132035132036132037132038132039132040132041132042132043132044132045132046132047132048132049132050132051132052132053132054132055132056132057132058132059132060132061132062132063132064132065132066132067132068132069132070132071132072132073132074132075132076132077132078132079132080132081132082132083132084132085132086132087132088132089132090132091132092132093132094132095132096132097132098132099132100132101132102132103132104132105132106132107132108132109132110132111132112132113132114132115132116132117132118132119132120132121132122132123132124132125132126132127132128132129132130132131132132132133132134132135132136132137132138132139132140132141132142132143132144132145132146132147132148132149132150132151132152132153132154132155132156132157132158132159132160132161132162132163132164132165132166132167132168132169132170132171132172132173132174132175132176132177132178132179132180132181132182132183132184132185132186132187132188132189132190132191132192132193132194132195132196132197132198132199132200132201132202132203132204132205132206132207132208132209132210132211132212132213132214132215132216132217132218132219132220132221132222132223132224132225132226132227132228132229132230132231132232132233132234132235132236132237132238132239132240132241132242132243132244132245132246132247132248132249132250132251132252132253132254132255132256132257132258132259132260132261132262132263132264132265132266132267132268132269132270132271132272132273132274132275132276132277132278132279132280132281132282132283132284132285132286132287132288132289132290132291132292132293132294132295132296132297132298132299132300132301132302132303132304132305132306132307132308132309132310132311132312132313132314132315132316132317132318132319132320132321132322132323132324132325132326132327132328132329132330132331132332132333132334132335132336132337132338132339132340132341132342132343132344132345132346132347132348132349132350132351132352132353132354132355132356132357132358132359132360132361132362132363132364132365132366132367132368132369132370132371132372132373132374132375132376132377132378132379132380132381132382132383132384132385132386132387132388132389132390132391132392132393132394132395132396132397132398132399132400132401132402132403132404132405132406132407132408132409132410132411132412132413132414132415132416132417132418132419132420132421132422132423132424132425132426132427132428132429132430132431132432132433132434132435132436132437132438132439132440132441132442132443132444132445132446132447132448132449132450132451132452132453132454132455132456132457132458132459132460132461132462132463132464132465132466132467132468132469132470132471132472132473132474132475132476132477132478132479132480132481132482132483132484132485132486132487132488132489132490132491132492132493132494132495132496132497132498132499132500132501132502132503132504132505132506132507132508132509132510132511132512132513132514132515132516132517132518132519132520132521132522132523132524132525132526132527132528132529132530132531132532132533132534132535132536132537132538132539132540132541132542132543132544132545132546132547132548132549132550132551132552132553132554132555132556132557132558132559132560132561132562132563132564132565132566132567132568132569132570132571132572132573132574132575132576132577132578132579132580132581132582132583132584132585132586132587132588132589132590132591132592132593132594132595132596132597132598132599132600132601132602132603132604132605132606132607132608132609132610132611132612132613132614132615132616132617132618132619132620132621132622132623132624132625132626132627132628132629132630132631132632132633132634132635132636132637132638132639132640132641132642132643132644132645132646132647132648132649132650132651132652132653132654132655132656132657132658132659132660132661132662132663132664132665132666132667132668132669132670132671132672132673132674132675132676132677132678132679132680132681132682132683132684132685132686132687132688132689132690132691132692132693132694132695132696132697132698132699132700132701132702132703132704132705132706132707132708132709132710132711132712132713132714132715132716132717132718132719132720132721132722132723132724132725132726132727132728132729132730132731132732132733132734132735132736132737132738132739132740132741132742132743132744132745132746132747132748132749132750132751132752132753132754132755132756132757132758132759132760132761132762132763132764132765132766132767132768132769132770132771132772132773132774132775132776132777132778132779132780132781132782132783132784132785132786132787132788132789132790132791132792132793132794132795132796132797132798132799132800132801132802132803132804132805132806132807132808132809132810132811132812132813132814132815132816132817132818132819132820132821132822132823132824132825132826132827132828132829132830132831132832132833132834132835132836132837132838132839132840132841132842132843132844132845132846132847132848132849132850132851132852132853132854132855132856132857132858132859132860132861132862132863132864132865132866132867132868132869132870132871132872132873132874132875132876132877132878132879132880132881132882132883132884132885132886132887132888132889132890132891132892132893132894132895132896132897132898132899132900132901132902132903132904132905132906132907132908132909132910132911132912132913132914132915132916132917132918132919132920132921132922132923132924132925132926132927132928132929132930132931132932132933132934132935132936132937132938132939132940132941132942132943132944132945132946132947132948132949132950132951132952132953132954132955132956132957132958132959132960132961132962132963132964132965132966132967132968132969132970132971132972132973132974132975132976132977132978132979132980132981132982132983132984132985132986132987132988132989132990132991132992132993132994132995132996132997132998132999133000133001133002133003133004133005133006133007133008133009133010133011133012133013133014133015133016133017133018133019133020133021133022133023133024133025133026133027133028133029133030133031133032133033133034133035133036133037133038133039133040133041133042133043133044133045133046133047133048133049133050133051133052133053133054133055133056133057133058133059133060133061133062133063133064133065133066133067133068133069133070133071133072133073133074133075133076133077133078133079133080133081133082133083133084133085133086133087133088133089133090133091133092133093133094133095133096133097133098133099133100133101133102133103133104133105133106133107133108133109133110133111133112133113133114133115133116133117133118133119133120133121133122133123133124133125133126133127133128133129133130133131133132133133133134133135133136133137133138133139133140133141133142133143133144133145133146133147133148133149133150133151133152133153133154133155133156133157133158133159133160133161133162133163133164133165133166133167133168133169133170133171133172133173133174133175133176133177133178133179133180133181133182133183133184133185133186133187133188133189133190133191133192133193133194133195133196133197133198133199133200133201133202133203133204133205133206133207133208133209133210133211133212133213133214133215133216133217133218133219133220133221133222133223133224133225133226133227133228133229133230133231133232133233133234133235133236133237133238133239133240133241133242133243133244133245133246133247133248133249133250133251133252133253133254133255133256133257133258133259133260133261133262133263133264133265133266133267133268133269133270133271133272133273133274133275133276133277133278133279133280133281133282133283133284133285133286133287133288133289133290133291133292133293133294133295133296133297133298133299133300133301133302133303133304133305133306133307133308133309133310133311133312133313133314133315133316133317133318133319133320133321133322133323133324133325133326133327133328133329133330133331133332133333133334133335133336133337133338133339133340133341133342133343133344133345133346133347133348133349133350133351133352133353133354133355133356133357133358133359133360133361133362133363133364133365133366133367133368133369133370133371133372133373133374133375133376133377133378133379133380133381133382133383133384133385133386133387133388133389133390133391133392133393133394133395133396133397133398133399133400133401133402133403133404133405133406133407133408133409133410133411133412133413133414133415133416133417133418133419133420133421133422133423133424133425133426133427133428133429133430133431133432133433133434133435133436133437133438133439133440133441133442133443133444133445133446133447133448133449133450133451133452133453133454133455133456133457133458133459133460133461133462133463133464133465133466133467133468133469133470133471133472133473133474133475133476133477133478133479133480133481133482133483133484133485133486133487133488133489133490133491133492133493133494133495133496133497133498133499133500133501133502133503133504133505133506133507133508133509133510133511133512133513133514133515133516133517133518133519133520133521133522133523133524133525133526133527133528133529133530133531133532133533133534133535133536133537133538133539133540133541133542133543133544133545133546133547133548133549133550133551133552133553133554133555133556133557133558133559133560133561133562133563133564133565133566133567133568133569133570133571133572133573133574133575133576133577133578133579133580133581133582133583133584133585133586133587133588133589133590133591133592133593133594133595133596133597133598133599133600133601133602133603133604133605133606133607133608133609133610133611133612133613133614133615133616133617133618133619133620133621133622133623133624133625133626133627133628133629133630133631133632133633133634133635133636133637133638133639133640133641133642133643133644133645133646133647133648133649133650133651133652133653133654133655133656133657133658133659133660133661133662133663133664133665133666133667133668133669133670133671133672133673133674133675133676133677133678133679133680133681133682133683133684133685133686133687133688133689133690133691133692133693133694133695133696133697133698133699133700133701133702133703133704133705133706133707133708133709133710133711133712133713133714133715133716133717133718133719133720133721133722133723133724133725133726133727133728133729133730133731133732133733133734133735133736133737133738133739133740133741133742133743133744133745133746133747133748133749133750133751133752133753133754133755133756133757133758133759133760133761133762133763133764133765133766133767133768133769133770133771133772133773133774133775133776133777133778133779133780133781133782133783133784133785133786133787133788133789133790133791133792133793133794133795133796133797133798133799133800133801133802133803133804133805133806133807133808133809133810133811133812133813133814133815133816133817133818133819133820133821133822133823133824133825133826133827133828133829133830133831133832133833133834133835133836133837133838133839133840133841133842133843133844133845133846133847133848133849133850133851133852133853133854133855133856133857133858133859133860133861133862133863133864133865133866133867133868133869133870133871133872133873133874133875133876133877133878133879133880133881133882133883133884133885133886133887133888133889133890133891133892133893133894133895133896133897133898133899133900133901133902133903133904133905133906133907133908133909133910133911133912133913133914133915133916133917133918133919133920133921133922133923133924133925133926133927133928133929133930133931133932133933133934133935133936133937133938133939133940133941133942133943133944133945133946133947133948133949133950133951133952133953133954133955133956133957133958133959133960133961133962133963133964133965133966133967133968133969133970133971133972133973133974133975133976133977133978133979133980133981133982133983133984133985133986133987133988133989133990133991133992133993133994133995133996133997133998133999134000134001134002134003134004134005134006134007134008134009134010134011134012134013134014134015134016134017134018134019134020134021134022134023134024134025134026134027134028134029134030134031134032134033134034134035134036134037134038134039134040134041134042134043134044134045134046134047134048134049134050134051134052134053134054134055134056134057134058134059134060134061134062134063134064134065134066134067134068134069134070134071134072134073134074134075134076134077134078134079134080134081134082134083134084134085134086134087134088134089134090134091134092134093134094134095134096134097134098134099134100134101134102134103134104134105134106134107134108134109134110134111134112134113134114134115134116134117134118134119134120134121134122134123134124134125134126134127134128134129134130134131134132134133134134134135134136134137134138134139134140134141134142134143134144134145134146134147134148134149134150134151134152134153134154134155134156134157134158134159134160134161134162134163134164134165134166134167134168134169134170134171134172134173134174134175134176134177134178134179134180134181134182134183134184134185134186134187134188134189134190134191134192134193134194134195134196134197134198134199134200134201134202134203134204134205134206134207134208134209134210134211134212134213134214134215134216134217134218134219134220134221134222134223134224134225134226134227134228134229134230134231134232134233134234134235134236134237134238134239134240134241134242134243134244134245134246134247134248134249134250134251134252134253134254134255134256134257134258134259134260134261134262134263134264134265134266134267134268134269134270134271134272134273134274134275134276134277134278134279134280134281134282134283134284134285134286134287134288134289134290134291134292134293134294134295134296134297134298134299134300134301134302134303134304134305134306134307134308134309134310134311134312134313134314134315134316134317134318134319134320134321134322134323134324134325134326134327134328134329134330134331134332134333134334134335134336134337134338134339134340134341134342134343134344134345134346134347134348134349134350134351134352134353134354134355134356134357134358134359134360134361134362134363134364134365134366134367134368134369134370134371134372134373134374134375134376134377134378134379134380134381134382134383134384134385134386134387134388134389134390134391134392134393134394134395134396134397134398134399134400134401134402134403134404134405134406134407134408134409134410134411134412134413134414134415134416134417134418134419134420134421134422134423134424134425134426134427134428134429134430134431134432134433134434134435134436134437134438134439134440134441134442134443134444134445134446134447134448134449134450134451134452134453134454134455134456134457134458134459134460134461134462134463134464134465134466134467134468134469134470134471134472134473134474134475134476134477134478134479134480134481134482134483134484134485134486134487134488134489134490134491134492134493134494134495134496134497134498134499134500134501134502134503134504134505134506134507134508134509134510134511134512134513134514134515134516134517134518134519134520134521134522134523134524134525134526134527134528134529134530134531134532134533134534134535134536134537134538134539134540134541134542134543134544134545134546134547134548134549134550134551134552134553134554134555134556134557134558134559134560134561134562134563134564134565134566134567134568134569134570134571134572134573134574134575134576134577134578134579134580134581134582134583134584134585134586134587134588134589134590134591134592134593134594134595134596134597134598134599134600134601134602134603134604134605134606134607134608134609134610134611134612134613134614134615134616134617134618134619134620134621134622134623134624134625134626134627134628134629134630134631134632134633134634134635134636134637134638134639134640134641134642134643134644134645134646134647134648134649134650134651134652134653134654134655134656134657134658134659134660134661134662134663134664134665134666134667134668134669134670134671134672134673134674134675134676134677134678134679134680134681134682134683134684134685134686134687134688134689134690134691134692134693134694134695134696134697134698134699134700134701134702134703134704134705134706134707134708134709134710134711134712134713134714134715134716134717134718134719134720134721134722134723134724134725134726134727134728134729134730134731134732134733134734134735134736134737134738134739134740134741134742134743134744134745134746134747134748134749134750134751134752134753134754134755134756134757134758134759134760134761134762134763134764134765134766134767134768134769134770134771134772134773134774134775134776134777134778134779134780134781134782134783134784134785134786134787134788134789134790134791134792134793134794134795134796134797134798134799134800134801134802134803134804134805134806134807134808134809134810134811134812134813134814134815134816134817134818134819134820134821134822134823134824134825134826134827134828134829134830134831134832134833134834134835134836134837134838134839134840134841134842134843134844134845134846134847134848134849134850134851134852134853134854134855134856134857134858134859134860134861134862134863134864134865134866134867134868134869134870134871134872134873134874134875134876134877134878134879134880134881134882134883134884134885134886134887134888134889134890134891134892134893134894134895134896134897134898134899134900134901134902134903134904134905134906134907134908134909134910134911134912134913134914134915134916134917134918134919134920134921134922134923134924134925134926134927134928134929134930134931134932134933134934134935134936134937134938134939134940134941134942134943134944134945134946134947134948134949134950134951134952134953134954134955134956134957134958134959134960134961134962134963134964134965134966134967134968134969134970134971134972134973134974134975134976134977134978134979134980134981134982134983134984134985134986134987134988134989134990134991134992134993134994134995134996134997134998134999135000135001135002135003135004135005135006135007135008135009135010135011135012135013135014135015135016135017135018135019135020135021135022135023135024135025135026135027135028135029135030135031135032135033135034135035135036135037135038135039135040135041135042135043135044135045135046135047135048135049135050135051135052135053135054135055135056135057135058135059135060135061135062135063135064135065135066135067135068135069135070135071135072135073135074135075135076135077135078135079135080135081135082135083135084135085135086135087135088135089135090135091135092135093135094135095135096135097135098135099135100135101135102135103135104135105135106135107135108135109135110135111135112135113135114135115135116135117135118135119135120135121135122135123135124135125135126135127135128135129135130135131135132135133135134135135135136135137135138135139135140135141135142135143135144135145135146135147135148135149135150135151135152135153135154135155135156135157135158135159135160135161135162135163135164135165135166135167135168135169135170135171135172135173135174135175135176135177135178135179135180135181135182135183135184135185135186135187135188135189135190135191135192135193135194135195135196135197135198135199135200135201135202135203135204135205135206135207135208135209135210135211135212135213135214135215135216135217135218135219135220135221135222135223135224135225135226135227135228135229135230135231135232135233135234135235135236135237135238135239135240135241135242135243135244135245135246135247135248135249135250135251135252135253135254135255135256135257135258135259135260135261135262135263135264135265135266135267135268135269135270135271135272135273135274135275135276135277135278135279135280135281135282135283135284135285135286135287135288135289135290135291135292135293135294135295135296135297135298135299135300135301135302135303135304135305135306135307135308135309135310135311135312135313135314135315135316135317135318135319135320135321135322135323135324135325135326135327135328135329135330135331135332135333135334135335135336135337135338135339135340135341135342135343135344135345135346135347135348135349135350135351135352135353135354135355135356135357135358135359135360135361135362135363135364135365135366135367135368135369135370135371135372135373135374135375135376135377135378135379135380135381135382135383135384135385135386135387135388135389135390135391135392135393135394135395135396135397135398135399135400135401135402135403135404135405135406135407135408135409135410135411135412135413135414135415135416135417135418135419135420135421135422135423135424135425135426135427135428135429135430135431135432135433135434135435135436135437135438135439135440135441135442135443135444135445135446135447135448135449135450135451135452135453135454135455135456135457135458135459135460135461135462135463135464135465135466135467135468135469135470135471135472135473135474135475135476135477135478135479135480135481135482135483135484135485135486135487135488135489135490135491135492135493135494135495135496135497135498135499135500135501135502135503135504135505135506135507135508135509135510135511135512135513135514135515135516135517135518135519135520135521135522135523135524135525135526135527135528135529135530135531135532135533135534135535135536135537135538135539135540135541135542135543135544135545135546135547135548135549135550135551135552135553135554135555135556135557135558135559135560135561135562135563135564135565135566135567135568135569135570135571135572135573135574135575135576135577135578135579135580135581135582135583135584135585135586135587135588135589135590135591135592135593135594135595135596135597135598135599135600135601135602135603135604135605135606135607135608135609135610135611135612135613135614135615135616135617135618135619135620135621135622135623135624135625135626135627135628135629135630135631135632135633135634135635135636135637135638135639135640135641135642135643135644135645135646135647135648135649135650135651135652135653135654135655135656135657135658135659135660135661135662135663135664135665135666135667135668135669135670135671135672135673135674135675135676135677135678135679135680135681135682135683135684135685135686135687135688135689135690135691135692135693135694135695135696135697135698135699135700135701135702135703135704135705135706135707135708135709135710135711135712135713135714135715135716135717135718135719135720135721135722135723135724135725135726135727135728135729135730135731135732135733135734135735135736135737135738135739135740135741135742135743135744135745135746135747135748135749135750135751135752135753135754135755135756135757135758135759135760135761135762135763135764135765135766135767135768135769135770135771135772135773135774135775135776135777135778135779135780135781135782135783135784135785135786135787135788135789135790135791135792135793135794135795135796135797135798135799135800135801135802135803135804135805135806135807135808135809135810135811135812135813135814135815135816135817135818135819135820135821135822135823135824135825135826135827135828135829135830135831135832135833135834135835135836135837135838135839135840135841135842135843135844135845135846135847135848135849135850135851135852135853135854135855135856135857135858135859135860135861135862135863135864135865135866135867135868135869135870135871135872135873135874135875135876135877135878135879135880135881135882135883135884135885135886135887135888135889135890135891135892135893135894135895135896135897135898135899135900135901135902135903135904135905135906135907135908135909135910135911135912135913135914135915135916135917135918135919135920135921135922135923135924135925135926135927135928135929135930135931135932135933135934135935135936135937135938135939135940135941135942135943135944135945135946135947135948135949135950135951135952135953135954135955135956135957135958135959135960135961135962135963135964135965135966135967135968135969135970135971135972135973135974135975135976135977135978135979135980135981135982135983135984135985135986135987135988135989135990135991135992135993135994135995135996135997135998135999136000136001136002136003136004136005136006136007136008136009136010136011136012136013136014136015136016136017136018136019136020136021136022136023136024136025136026136027136028136029136030136031136032136033136034136035136036136037136038136039136040136041136042136043136044136045136046136047136048136049136050136051136052136053136054136055136056136057136058136059136060136061136062136063136064136065136066136067136068136069136070136071136072136073136074136075136076136077136078136079136080136081136082136083136084136085136086136087136088136089136090136091136092136093136094136095136096136097136098136099136100136101136102136103136104136105136106136107136108136109136110136111136112136113136114136115136116136117136118136119136120136121136122136123136124136125136126136127136128136129136130136131136132136133136134136135136136136137136138136139136140136141136142136143136144136145136146136147136148136149136150136151136152136153136154136155136156136157136158136159136160136161136162136163136164136165136166136167136168136169136170136171136172136173136174136175136176136177136178136179136180136181136182136183136184136185136186136187136188136189136190136191136192136193136194136195136196136197136198136199136200136201136202136203136204136205136206136207136208136209136210136211136212136213136214136215136216136217136218136219136220136221136222136223136224136225136226136227136228136229136230136231136232136233136234136235136236136237136238136239136240136241136242136243136244136245136246136247136248136249136250136251136252136253136254136255136256136257136258136259136260136261136262136263136264136265136266136267136268136269136270136271136272136273136274136275136276136277136278136279136280136281136282136283136284136285136286136287136288136289136290136291136292136293136294136295136296136297136298136299136300136301136302136303136304136305136306136307136308136309136310136311136312136313136314136315136316136317136318136319136320136321136322136323136324136325136326136327136328136329136330136331136332136333136334136335136336136337136338136339136340136341136342136343136344136345136346136347136348136349136350136351136352136353136354136355136356136357136358136359136360136361136362136363136364136365136366136367136368136369136370136371136372136373136374136375136376136377136378136379136380136381136382136383136384136385136386136387136388136389136390136391136392136393136394136395136396136397136398136399136400136401136402136403136404136405136406136407136408136409136410136411136412136413136414136415136416136417136418136419136420136421136422136423136424136425136426136427136428136429136430136431136432136433136434136435136436136437136438136439136440136441136442136443136444136445136446136447136448136449136450136451136452136453136454136455136456136457136458136459136460136461136462136463136464136465136466136467136468136469136470136471136472136473136474136475136476136477136478136479136480136481136482136483136484136485136486136487136488136489136490136491136492136493136494136495136496136497136498136499136500136501136502136503136504136505136506136507136508136509136510136511136512136513136514136515136516136517136518136519136520136521136522136523136524136525136526136527136528136529136530136531136532136533136534136535136536136537136538136539136540136541136542136543136544136545136546136547136548136549136550136551136552136553136554136555136556136557136558136559136560136561136562136563136564136565136566136567136568136569136570136571136572136573136574136575136576136577136578136579136580136581136582136583136584136585136586136587136588136589136590136591136592136593136594136595136596136597136598136599136600136601136602136603136604136605136606136607136608136609136610136611136612136613136614136615136616136617136618136619136620136621136622136623136624136625136626136627136628136629136630136631136632136633136634136635136636136637136638136639136640136641136642136643136644136645136646136647136648136649136650136651136652136653136654136655136656136657136658136659136660136661136662136663136664136665136666136667136668136669136670136671136672136673136674136675136676136677136678136679136680136681136682136683136684136685136686136687136688136689136690136691136692136693136694136695136696136697136698136699136700136701136702136703136704136705136706136707136708136709136710136711136712136713136714136715136716136717136718136719136720136721136722136723136724136725136726136727136728136729136730136731136732136733136734136735136736136737136738136739136740136741136742136743136744136745136746136747136748136749136750136751136752136753136754136755136756136757136758136759136760136761136762136763136764136765136766136767136768136769136770136771136772136773136774136775136776136777136778136779136780136781136782136783136784136785136786136787136788136789136790136791136792136793136794136795136796136797136798136799136800136801136802136803136804136805136806136807136808136809136810136811136812136813136814136815136816136817136818136819136820136821136822136823136824136825136826136827136828136829136830136831136832136833136834136835136836136837136838136839136840136841136842136843136844136845136846136847136848136849136850136851136852136853136854136855136856136857136858136859136860136861136862136863136864136865136866136867136868136869136870136871136872136873136874136875136876136877136878136879136880136881136882136883136884136885136886136887136888136889136890136891136892136893136894136895136896136897136898136899136900136901136902136903136904136905136906136907136908136909136910136911136912136913136914136915136916136917136918136919136920136921136922136923136924136925136926136927136928136929136930136931136932136933136934136935136936136937136938136939136940136941136942136943136944136945136946136947136948136949136950136951136952136953136954136955136956136957136958136959136960136961136962136963136964136965136966136967136968136969136970136971136972136973136974136975136976136977136978136979136980136981136982136983136984136985136986136987136988136989136990136991136992136993136994136995136996136997136998136999137000137001137002137003137004137005137006137007137008137009137010137011137012137013137014137015137016137017137018137019137020137021137022137023137024137025137026137027137028137029137030137031137032137033137034137035137036137037137038137039137040137041137042137043137044137045137046137047137048137049137050137051137052137053137054137055137056137057137058137059137060137061137062137063137064137065137066137067137068137069137070137071137072137073137074137075137076137077137078137079137080137081137082137083137084137085137086137087137088137089137090137091137092137093137094137095137096137097137098137099137100137101137102137103137104137105137106137107137108137109137110137111137112137113137114137115137116137117137118137119137120137121137122137123137124137125137126137127137128137129137130137131137132137133137134137135137136137137137138137139137140137141137142137143137144137145137146137147137148137149137150137151137152137153137154137155137156137157137158137159137160137161137162137163137164137165137166137167137168137169137170137171137172137173137174137175137176137177137178137179137180137181137182137183137184137185137186137187137188137189137190137191137192137193137194137195137196137197137198137199137200137201137202137203137204137205137206137207137208137209137210137211137212137213137214137215137216137217137218137219137220137221137222137223137224137225137226137227137228137229137230137231137232137233137234137235137236137237137238137239137240137241137242137243137244137245137246137247137248137249137250137251137252137253137254137255137256137257137258137259137260137261137262137263137264137265137266137267137268137269137270137271137272137273137274137275137276137277137278137279137280137281137282137283137284137285137286137287137288137289137290137291137292137293137294137295137296137297137298137299137300137301137302137303137304137305137306137307137308137309137310137311137312137313137314137315137316137317137318137319137320137321137322137323137324137325137326137327137328137329137330137331137332137333137334137335137336137337137338137339137340137341137342137343137344137345137346137347137348137349137350137351137352137353137354137355137356137357137358137359137360137361137362137363137364137365137366137367137368137369137370137371137372137373137374137375137376137377137378137379137380137381137382137383137384137385137386137387137388137389137390137391137392137393137394137395137396137397137398137399137400137401137402137403137404137405137406137407137408137409137410137411137412137413137414137415137416137417137418137419137420137421137422137423137424137425137426137427137428137429137430137431137432137433137434137435137436137437137438137439137440137441137442137443137444137445137446137447137448137449137450137451137452137453137454137455137456137457137458137459137460137461137462137463137464137465137466137467137468137469137470137471137472137473137474137475137476137477137478137479137480137481137482137483137484137485137486137487137488137489137490137491137492137493137494137495137496137497137498137499137500137501137502137503137504137505137506137507137508137509137510137511137512137513137514137515137516137517137518137519137520137521137522137523137524137525137526137527137528137529137530137531137532137533137534137535137536137537137538137539137540137541137542137543137544137545137546137547137548137549137550137551137552137553137554137555137556137557137558137559137560137561137562137563137564137565137566137567137568137569137570137571137572137573137574137575137576137577137578137579137580137581137582137583137584137585137586137587137588137589137590137591137592137593137594137595137596137597137598137599137600137601137602137603137604137605137606137607137608137609137610137611137612137613137614137615137616137617137618137619137620137621137622137623137624137625137626137627137628137629137630137631137632137633137634137635137636137637137638137639137640137641137642137643137644137645137646137647137648137649137650137651137652137653137654137655137656137657137658137659137660137661137662137663137664137665137666137667137668137669137670137671137672137673137674137675137676137677137678137679137680137681137682137683137684137685137686137687137688137689137690137691137692137693137694137695137696137697137698137699137700137701137702137703137704137705137706137707137708137709137710137711137712137713137714137715137716137717137718137719137720137721137722137723137724137725137726137727137728137729137730137731137732137733137734137735137736137737137738137739137740137741137742137743137744137745137746137747137748137749137750137751137752137753137754137755137756137757137758137759137760137761137762137763137764137765137766137767137768137769137770137771137772137773137774137775137776137777137778137779137780137781137782137783137784137785137786137787137788137789137790137791137792137793137794137795137796137797137798137799137800137801137802137803137804137805137806137807137808137809137810137811137812137813137814137815137816137817137818137819137820137821137822137823137824137825137826137827137828137829137830137831137832137833137834137835137836137837137838137839137840137841137842137843137844137845137846137847137848137849137850137851137852137853137854137855137856137857137858137859137860137861137862137863137864137865137866137867137868137869137870137871137872137873137874137875137876137877137878137879137880137881137882137883137884137885137886137887137888137889137890137891137892137893137894137895137896137897137898137899137900137901137902137903137904137905137906137907137908137909137910137911137912137913137914137915137916137917137918137919137920137921137922137923137924137925137926137927137928137929137930137931137932137933137934137935137936137937137938137939137940137941137942137943137944137945137946137947137948137949137950137951137952137953137954137955137956137957137958137959137960137961137962137963137964137965137966137967137968137969137970137971137972137973137974137975137976137977137978137979137980137981137982137983137984137985137986137987137988137989137990137991137992137993137994137995137996137997137998137999138000138001138002138003138004138005138006138007138008138009138010138011138012138013138014138015138016138017138018138019138020138021138022138023138024138025138026138027138028138029138030138031138032138033138034138035138036138037138038138039138040138041138042138043138044138045138046138047138048138049138050138051138052138053138054138055138056138057138058138059138060138061138062138063138064138065138066138067138068138069138070138071138072138073138074138075138076138077138078138079138080138081138082138083138084138085138086138087138088138089138090138091138092138093138094138095138096138097138098138099138100138101138102138103138104138105138106138107138108138109138110138111138112138113138114138115138116138117138118138119138120138121138122138123138124138125138126138127138128138129138130138131138132138133138134138135138136138137138138138139138140138141138142138143138144138145138146138147138148138149138150138151138152138153138154138155138156138157138158138159138160138161138162138163138164138165138166138167138168138169138170138171138172138173138174138175138176138177138178138179138180138181138182138183138184138185138186138187138188138189138190138191138192138193138194138195138196138197138198138199138200138201138202138203138204138205138206138207138208138209138210138211138212138213138214138215138216138217138218138219138220138221138222138223138224138225138226138227138228138229138230138231138232138233138234138235138236138237138238138239138240138241138242138243138244138245138246138247138248138249138250138251138252138253138254138255138256138257138258138259138260138261138262138263138264138265138266138267138268138269138270138271138272138273138274138275138276138277138278138279138280138281138282138283138284138285138286138287138288138289138290138291138292138293138294138295138296138297138298138299138300138301138302138303138304138305138306138307138308138309138310138311138312138313138314138315138316138317138318138319138320138321138322138323138324138325138326138327138328138329138330138331138332138333138334138335138336138337138338138339138340138341138342138343138344138345138346138347138348138349138350138351138352138353138354138355138356138357138358138359138360138361138362138363138364138365138366138367138368138369138370138371138372138373138374138375138376138377138378138379138380138381138382138383138384138385138386138387138388138389138390138391138392138393138394138395138396138397138398138399138400138401138402138403138404138405138406138407138408138409138410138411138412138413138414138415138416138417138418138419138420138421138422138423138424138425138426138427138428138429138430138431138432138433138434138435138436138437138438138439138440138441138442138443138444138445138446138447138448138449138450138451138452138453138454138455138456138457138458138459138460138461138462138463138464138465138466138467138468138469138470138471138472138473138474138475138476138477138478138479138480138481138482138483138484138485138486138487138488138489138490138491138492138493138494138495138496138497138498138499138500138501138502138503138504138505138506138507138508138509138510138511138512138513138514138515138516138517138518138519138520138521138522138523138524138525138526138527138528138529138530138531138532138533138534138535138536138537138538138539138540138541138542138543138544138545138546138547138548138549138550138551138552138553138554138555138556138557138558138559138560138561138562138563138564138565138566138567138568138569138570138571138572138573138574138575138576138577138578138579138580138581138582138583138584138585138586138587138588138589138590138591138592138593138594138595138596138597138598138599138600138601138602138603138604138605138606138607138608138609138610138611138612138613138614138615138616138617138618138619138620138621138622138623138624138625138626138627138628138629138630138631138632138633138634138635138636138637138638138639138640138641138642138643138644138645138646138647138648138649138650138651138652138653138654138655138656138657138658138659138660138661138662138663138664138665138666138667138668138669138670138671138672138673138674138675138676138677138678138679138680138681138682138683138684138685138686138687138688138689138690138691138692138693138694138695138696138697138698138699138700138701138702138703138704138705138706138707138708138709138710138711138712138713138714138715138716138717138718138719138720138721138722138723138724138725138726138727138728138729138730138731138732138733138734138735138736138737138738138739138740138741138742138743138744138745138746138747138748138749138750138751138752138753138754138755138756138757138758138759138760138761138762138763138764138765138766138767138768138769138770138771138772138773138774138775138776138777138778138779138780138781138782138783138784138785138786138787138788138789138790138791138792138793138794138795138796138797138798138799138800138801138802138803138804138805138806138807138808138809138810138811138812138813138814138815138816138817138818138819138820138821138822138823138824138825138826138827138828138829138830138831138832138833138834138835138836138837138838138839138840138841138842138843138844138845138846138847138848138849138850138851138852138853138854138855138856138857138858138859138860138861138862138863138864138865138866138867138868138869138870138871138872138873138874138875138876138877138878138879138880138881138882138883138884138885138886138887138888138889138890138891138892138893138894138895138896138897138898138899138900138901138902138903138904138905138906138907138908138909138910138911138912138913138914138915138916138917138918138919138920138921138922138923138924138925138926138927138928138929138930138931138932138933138934138935138936138937138938138939138940138941138942138943138944138945138946138947138948138949138950138951138952138953138954138955138956138957138958138959138960138961138962138963138964138965138966138967138968138969138970138971138972138973138974138975138976138977138978138979138980138981138982138983138984138985138986138987138988138989138990138991138992138993138994138995138996138997138998138999139000139001139002139003139004139005139006139007139008139009139010139011139012139013139014139015139016139017139018139019139020139021139022139023139024139025139026139027139028139029139030139031139032139033139034139035139036139037139038139039139040139041139042139043139044139045139046139047139048139049139050139051139052139053139054139055139056139057139058139059139060139061139062139063139064139065139066139067139068139069139070139071139072139073139074139075139076139077139078139079139080139081139082139083139084139085139086139087139088139089139090139091139092139093139094139095139096139097139098139099139100139101139102139103139104139105139106139107139108139109139110139111139112139113139114139115139116139117139118139119139120139121139122139123139124139125139126139127139128139129139130139131139132139133139134139135139136139137139138139139139140139141139142139143139144139145139146139147139148139149139150139151139152139153139154139155139156139157139158139159139160139161139162139163139164139165139166139167139168139169139170139171139172139173139174139175139176139177139178139179139180139181139182139183139184139185139186139187139188139189139190139191139192139193139194139195139196139197139198139199139200139201139202139203139204139205139206139207139208139209139210139211139212139213139214139215139216139217139218139219139220139221139222139223139224139225139226139227139228139229139230139231139232139233139234139235139236139237139238139239139240139241139242139243139244139245139246139247139248139249139250139251139252139253139254139255139256139257139258139259139260139261139262139263139264139265139266139267139268139269139270139271139272139273139274139275139276139277139278139279139280139281139282139283139284139285139286139287139288139289139290139291139292139293139294139295139296139297139298139299139300139301139302139303139304139305139306139307139308139309139310139311139312139313139314139315139316139317139318139319139320139321139322139323139324139325139326139327139328139329139330139331139332139333139334139335139336139337139338139339139340139341139342139343139344139345139346139347139348139349139350139351139352139353139354139355139356139357139358139359139360139361139362139363139364139365139366139367139368139369139370139371139372139373139374139375139376139377139378139379139380139381139382139383139384139385139386139387139388139389139390139391139392139393139394139395139396139397139398139399139400139401139402139403139404139405139406139407139408139409139410139411139412139413139414139415139416139417139418139419139420139421139422139423139424139425139426139427139428139429139430139431139432139433139434139435139436139437139438139439139440139441139442139443139444139445139446139447139448139449139450139451139452139453139454139455139456139457139458139459139460139461139462139463139464139465139466139467139468139469139470139471139472139473139474139475139476139477139478139479139480139481139482139483139484139485139486139487139488139489139490139491139492139493139494139495139496139497139498139499139500139501139502139503139504139505139506139507139508139509139510139511139512139513139514139515139516139517139518139519139520139521139522139523139524139525139526139527139528139529139530139531139532139533139534139535139536139537139538139539139540139541139542139543139544139545139546139547139548139549139550139551139552139553139554139555139556139557139558139559139560139561139562139563139564139565139566139567139568139569139570139571139572139573139574139575139576139577139578139579139580139581139582139583139584139585139586139587139588139589139590139591139592139593139594139595139596139597139598139599139600139601139602139603139604139605139606139607139608139609139610139611139612139613139614139615139616139617139618139619139620139621139622139623139624139625139626139627139628139629139630139631139632139633139634139635139636139637139638139639139640139641139642139643139644139645139646139647139648139649139650139651139652139653139654139655139656139657139658139659139660139661139662139663139664139665139666139667139668139669139670139671139672139673139674139675139676139677139678139679139680139681139682139683139684139685139686139687139688139689139690139691139692139693139694139695139696139697139698139699139700139701139702139703139704139705139706139707139708139709139710139711139712139713139714139715139716139717139718139719139720139721139722139723139724139725139726139727139728139729139730139731139732139733139734139735139736139737139738139739139740139741139742139743139744139745139746139747139748139749139750139751139752139753139754139755139756139757139758139759139760139761139762139763139764139765139766139767139768139769139770139771139772139773139774139775139776139777139778139779139780139781139782139783139784139785139786139787139788139789139790139791139792139793139794139795139796139797139798139799139800139801139802139803139804139805139806139807139808139809139810139811139812139813139814139815139816139817139818139819139820139821139822139823139824139825139826139827139828139829139830139831139832139833139834139835139836139837139838139839139840139841139842139843139844139845139846139847139848139849139850139851139852139853139854139855139856139857139858139859139860139861139862139863139864139865139866139867139868139869139870139871139872139873139874139875139876139877139878139879139880139881139882139883139884139885139886139887139888139889139890139891139892139893139894139895139896139897139898139899139900139901139902139903139904139905139906139907139908139909139910139911139912139913139914139915139916139917139918139919139920139921139922139923139924139925139926139927139928139929139930139931139932139933139934139935139936139937139938139939139940139941139942139943139944139945139946139947139948139949139950139951139952139953139954139955139956139957139958139959139960139961139962139963139964139965139966139967139968139969139970139971139972139973139974139975139976139977139978139979139980139981139982139983139984139985139986139987139988139989139990139991139992139993139994139995139996139997139998139999140000140001140002140003140004140005140006140007140008140009140010140011140012140013140014140015140016140017140018140019140020140021140022140023140024140025140026140027140028140029140030140031140032140033140034140035140036140037140038140039140040140041140042140043140044140045140046140047140048140049140050140051140052140053140054140055140056140057140058140059140060140061140062140063140064140065140066140067140068140069140070140071140072140073140074140075140076140077140078140079140080140081140082140083140084140085140086140087140088140089140090140091140092140093140094140095140096140097140098140099140100140101140102140103140104140105140106140107140108140109140110140111140112140113140114140115140116140117140118140119140120140121140122140123140124140125140126140127140128140129140130140131140132140133140134140135140136140137140138140139140140140141140142140143140144140145140146140147140148140149140150140151140152140153140154140155140156140157140158140159140160140161140162140163140164140165140166140167140168140169140170140171140172140173140174140175140176140177140178140179140180140181140182140183140184140185140186140187140188140189140190140191140192140193140194140195140196140197140198140199140200140201140202140203140204140205140206140207140208140209140210140211140212140213140214140215140216140217140218140219140220140221140222140223140224140225140226140227140228140229140230140231140232140233140234140235140236140237140238140239140240140241140242140243140244140245140246140247140248140249140250140251140252140253140254140255140256140257140258140259140260140261140262140263140264140265140266140267140268140269140270140271140272140273140274140275140276140277140278140279140280140281140282140283140284140285140286140287140288140289140290140291140292140293140294140295140296140297140298140299140300140301140302140303140304140305140306140307140308140309140310140311140312140313140314140315140316140317140318140319140320140321140322140323140324140325140326140327140328140329140330140331140332140333140334140335140336140337140338140339140340140341140342140343140344140345140346140347140348140349140350140351140352140353140354140355140356140357140358140359140360140361140362140363140364140365140366140367140368140369140370140371140372140373140374140375140376140377140378140379140380140381140382140383140384140385140386140387140388140389140390140391140392140393140394140395140396140397140398140399140400140401140402140403140404140405140406140407140408140409140410140411140412140413140414140415140416140417140418140419140420140421140422140423140424140425140426140427140428140429140430140431140432140433140434140435140436140437140438140439140440140441140442140443140444140445140446140447140448140449140450140451140452140453140454140455140456140457140458140459140460140461140462140463140464140465140466140467140468140469140470140471140472140473140474140475140476140477140478140479140480140481140482140483140484140485140486140487140488140489140490140491140492140493140494140495140496140497140498140499140500140501140502140503140504140505140506140507140508140509140510140511140512140513140514140515140516140517140518140519140520140521140522140523140524140525140526140527140528140529140530140531140532140533140534140535140536140537140538140539140540140541140542140543140544140545140546140547140548140549140550140551140552140553140554140555140556140557140558140559140560140561140562140563140564140565140566140567140568140569140570140571140572140573140574140575140576140577140578140579140580140581140582140583140584140585140586140587140588140589140590140591140592140593140594140595140596140597140598140599140600140601140602140603140604140605140606140607140608140609140610140611140612140613140614140615140616140617140618140619140620140621140622140623140624140625140626140627140628140629140630140631140632140633140634140635140636140637140638140639140640140641140642140643140644140645140646140647140648140649140650140651140652140653140654140655140656140657140658140659140660140661140662140663140664140665140666140667140668140669140670140671140672140673140674140675140676140677140678140679140680140681140682140683140684140685140686140687140688140689140690140691140692140693140694140695140696140697140698140699140700140701140702140703140704140705140706140707140708140709140710140711140712140713140714140715140716140717140718140719140720140721140722140723140724140725140726140727140728140729140730140731140732140733140734140735140736140737140738140739140740140741140742140743140744140745140746140747140748140749140750140751140752140753140754140755140756140757140758140759140760140761140762140763140764140765140766140767140768140769140770140771140772140773140774140775140776140777140778140779140780140781140782140783140784140785140786140787140788140789140790140791140792140793140794140795140796140797140798140799140800140801140802140803140804140805140806140807140808140809140810140811140812140813140814140815140816140817140818140819140820140821140822140823140824140825140826140827140828140829140830140831140832140833140834140835140836140837140838140839140840140841140842140843140844140845140846140847140848140849140850140851140852140853140854140855140856140857140858140859140860140861140862140863140864140865140866140867140868140869140870140871140872140873140874140875140876140877140878140879140880140881140882140883140884140885140886140887140888140889140890140891140892140893140894140895140896140897140898140899140900140901140902140903140904140905140906140907140908140909140910140911140912140913140914140915140916140917140918140919140920140921140922140923140924140925140926140927140928140929140930140931140932140933140934140935140936140937140938140939140940140941140942140943140944140945140946140947140948140949140950140951140952140953140954140955140956140957140958140959140960140961140962140963140964140965140966140967140968140969140970140971140972140973140974140975140976140977140978140979140980140981140982140983140984140985140986140987140988140989140990140991140992140993140994140995140996140997140998140999141000141001141002141003141004141005141006141007141008141009141010141011141012141013141014141015141016141017141018141019141020141021141022141023141024141025141026141027141028141029141030141031141032141033141034141035141036141037141038141039141040141041141042141043141044141045141046141047141048141049141050141051141052141053141054141055141056141057141058141059141060141061141062141063141064141065141066141067141068141069141070141071141072141073141074141075141076141077141078141079141080141081141082141083141084141085141086141087141088141089141090141091141092141093141094141095141096141097141098141099141100141101141102141103141104141105141106141107141108141109141110141111141112141113141114141115141116141117141118141119141120141121141122141123141124141125141126141127141128141129141130141131141132141133141134141135141136141137141138141139141140141141141142141143141144141145141146141147141148141149141150141151141152141153141154141155141156141157141158141159141160141161141162141163141164141165141166141167141168141169141170141171141172141173141174141175141176141177141178141179141180141181141182141183141184141185141186141187141188141189141190141191141192141193141194141195141196141197141198141199141200141201141202141203141204141205141206141207141208141209141210141211141212141213141214141215141216141217141218141219141220141221141222141223141224141225141226141227141228141229141230141231141232141233141234141235141236141237141238141239141240141241141242141243141244141245141246141247141248141249141250141251141252141253141254141255141256141257141258141259141260141261141262141263141264141265141266141267141268141269141270141271141272141273141274141275141276141277141278141279141280141281141282141283141284141285141286141287141288141289141290141291141292141293141294141295141296141297141298141299141300141301141302141303141304141305141306141307141308141309141310141311141312141313141314141315141316141317141318141319141320141321141322141323141324141325141326141327141328141329141330141331141332141333141334141335141336141337141338141339141340141341141342141343141344141345141346141347141348141349141350141351141352141353141354141355141356141357141358141359141360141361141362141363141364141365141366141367141368141369141370141371141372141373141374141375141376141377141378141379141380141381141382141383141384141385141386141387141388141389141390141391141392141393141394141395141396141397141398141399141400141401141402141403141404141405141406141407141408141409141410141411141412141413141414141415141416141417141418141419141420141421141422141423141424141425141426141427141428141429141430141431141432141433141434141435141436141437141438141439141440141441141442141443141444141445141446141447141448141449141450141451141452141453141454141455141456141457141458141459141460141461141462141463141464141465141466141467141468141469141470141471141472141473141474141475141476141477141478141479141480141481141482141483141484141485141486141487141488141489141490141491141492141493141494141495141496141497141498141499141500141501141502141503141504141505141506141507141508141509141510141511141512141513141514141515141516141517141518141519141520141521141522141523141524141525141526141527141528141529141530141531141532141533141534141535141536141537141538141539141540141541141542141543141544141545141546141547141548141549141550141551141552141553141554141555141556141557141558141559141560141561141562141563141564141565141566141567141568141569141570141571141572141573141574141575141576141577141578141579141580141581141582141583141584141585141586141587141588141589141590141591141592141593141594141595141596141597141598141599141600141601141602141603141604141605141606141607141608141609141610141611141612141613141614141615141616141617141618141619141620141621141622141623141624141625141626141627141628141629141630141631141632141633141634141635141636141637141638141639141640141641141642141643141644141645141646141647141648141649141650141651141652141653141654141655141656141657141658141659141660141661141662141663141664141665141666141667141668141669141670141671141672141673141674141675141676141677141678141679141680141681141682141683141684141685141686141687141688141689141690141691141692141693141694141695141696141697141698141699141700141701141702141703141704141705141706141707141708141709141710141711141712141713141714141715141716141717141718141719141720141721141722141723141724141725141726141727141728141729141730141731141732141733141734141735141736141737141738141739141740141741141742141743141744141745141746141747141748141749141750141751141752141753141754141755141756141757141758141759141760141761141762141763141764141765141766141767141768141769141770141771141772141773141774141775141776141777141778141779141780141781141782141783141784141785141786141787141788141789141790141791141792141793141794141795141796141797141798141799141800141801141802141803141804141805141806141807141808141809141810141811141812141813141814141815141816141817141818141819141820141821141822141823141824141825141826141827141828141829141830141831141832141833141834141835141836141837141838141839141840141841141842141843141844141845141846141847141848141849141850141851141852141853141854141855141856141857141858141859141860141861141862141863141864141865141866141867141868141869141870141871141872141873141874141875141876141877141878141879141880141881141882141883141884141885141886141887141888141889141890141891141892141893141894141895141896141897141898141899141900141901141902141903141904141905141906141907141908141909141910141911141912141913141914141915141916141917141918141919141920141921141922141923141924141925141926141927141928141929141930141931141932141933141934141935141936141937141938141939141940141941141942141943141944141945141946141947141948141949141950141951141952141953141954141955141956141957141958141959141960141961141962141963141964141965141966141967141968141969141970141971141972141973141974141975141976141977141978141979141980141981141982141983141984141985141986141987141988141989141990141991141992141993141994141995141996141997141998141999142000142001142002142003142004142005142006142007142008142009142010142011142012142013142014142015142016142017142018142019142020142021142022142023142024142025142026142027142028142029142030142031142032142033142034142035142036142037142038142039142040142041142042142043142044142045142046142047142048142049142050142051142052142053142054142055142056142057142058142059142060142061142062142063142064142065142066142067142068142069142070142071142072142073142074142075142076142077142078142079142080142081142082142083142084142085142086142087142088142089142090142091142092142093142094142095142096142097142098142099142100142101142102142103142104142105142106142107142108142109142110142111142112142113142114142115142116142117142118142119142120142121142122142123142124142125142126142127142128142129142130142131142132142133142134142135142136142137142138142139142140142141142142142143142144142145142146142147142148142149142150142151142152142153142154142155142156142157142158142159142160142161142162142163142164142165142166142167142168142169142170142171142172142173142174142175142176142177142178142179142180142181142182142183142184142185142186142187142188142189142190142191142192142193142194142195142196142197142198142199142200142201142202142203142204142205142206142207142208142209142210142211142212142213142214142215142216142217142218142219142220142221142222142223142224142225142226142227142228142229142230142231142232142233142234142235142236142237142238142239142240142241142242142243142244142245142246142247142248142249142250142251142252142253142254142255142256142257142258142259142260142261142262142263142264142265142266142267142268142269142270142271142272142273142274142275142276142277142278142279142280142281142282142283142284142285142286142287142288142289142290142291142292142293142294142295142296142297142298142299142300142301142302142303142304142305142306142307142308142309142310142311142312142313142314142315142316142317142318142319142320142321142322142323142324142325142326142327142328142329142330142331142332142333142334142335142336142337142338142339142340142341142342142343142344142345142346142347142348142349142350142351142352142353142354142355142356142357142358142359142360142361142362142363142364142365142366142367142368142369142370142371142372142373142374142375142376142377142378142379142380142381142382142383142384142385142386142387142388142389142390142391142392142393142394142395142396142397142398142399142400142401142402142403142404142405142406142407142408142409142410142411142412142413142414142415142416142417142418142419142420142421142422142423142424142425142426142427142428142429142430142431142432142433142434142435142436142437142438142439142440142441142442142443142444142445142446142447142448142449142450142451142452142453142454142455142456142457142458142459142460142461142462142463142464142465142466142467142468142469142470142471142472142473142474142475142476142477142478142479142480142481142482142483142484142485142486142487142488142489142490142491142492142493142494142495142496142497142498142499142500142501142502142503142504142505142506142507142508142509142510142511142512142513142514142515142516142517142518142519142520142521142522142523142524142525142526142527142528142529142530142531142532142533142534142535142536142537142538142539142540142541142542142543142544142545142546142547142548142549142550142551142552142553142554142555142556142557142558142559142560142561142562142563142564142565142566142567142568142569142570142571142572142573142574142575142576142577142578142579142580142581142582142583142584142585142586142587142588142589142590142591142592142593142594142595142596142597142598142599142600142601142602142603142604142605142606142607142608142609142610142611142612142613142614142615142616142617142618142619142620142621142622142623142624142625142626142627142628142629142630142631142632142633142634142635142636142637142638142639142640142641142642142643142644142645142646142647142648142649142650142651142652142653142654142655142656142657142658142659142660142661142662142663142664142665142666142667142668142669142670142671142672142673142674142675142676142677142678142679142680142681142682142683142684142685142686142687142688142689142690142691142692142693142694142695142696142697142698142699142700142701142702142703142704142705142706142707142708142709142710142711142712142713142714142715142716142717142718142719142720142721142722142723142724142725142726142727142728142729142730142731142732142733142734142735142736142737142738142739142740142741142742142743142744142745142746142747142748142749142750142751142752142753142754142755142756142757142758142759142760142761142762142763142764142765142766142767142768142769142770142771142772142773142774142775142776142777142778142779142780142781142782142783142784142785142786142787142788142789142790142791142792142793142794142795142796142797142798142799142800142801142802142803142804142805142806142807142808142809142810142811142812142813142814142815142816142817142818142819142820142821142822142823142824142825142826142827142828142829142830142831142832142833142834142835142836142837142838142839142840142841142842142843142844142845142846142847142848142849142850142851142852142853142854142855142856142857142858142859142860142861142862142863142864142865142866142867142868142869142870142871142872142873142874142875142876142877142878142879142880142881142882142883142884142885142886142887142888142889142890142891142892142893142894142895142896142897142898142899142900142901142902142903142904142905142906142907142908142909142910142911142912142913142914142915142916142917142918142919142920142921142922142923142924142925142926142927142928142929142930142931142932142933142934142935142936142937142938142939142940142941142942142943142944142945142946142947142948142949142950142951142952142953142954142955142956142957142958142959142960142961142962142963142964142965142966142967142968142969142970142971142972142973142974142975142976142977142978142979142980142981142982142983142984142985142986142987142988142989142990142991142992142993142994142995142996142997142998142999143000143001143002143003143004143005143006143007143008143009143010143011143012143013143014143015143016143017143018143019143020143021143022143023143024143025143026143027143028143029143030143031143032143033143034143035143036143037143038143039143040143041143042143043143044143045143046143047143048143049143050143051143052143053143054143055143056143057143058143059143060143061143062143063143064143065143066143067143068143069143070143071143072143073143074143075143076143077143078143079143080143081143082143083143084143085143086143087143088143089143090143091143092143093143094143095143096143097143098143099143100143101143102143103143104143105143106143107143108143109143110143111143112143113143114143115143116143117143118143119143120143121143122143123143124143125143126143127143128143129143130143131143132143133143134143135143136143137143138143139143140143141143142143143143144143145143146143147143148143149143150143151143152143153143154143155143156143157143158143159143160143161143162143163143164143165143166143167143168143169143170143171143172143173143174143175143176143177143178143179143180143181143182143183143184143185143186143187143188143189143190143191143192143193143194143195143196143197143198143199143200143201143202143203143204143205143206143207143208143209143210143211143212143213143214143215143216143217143218143219143220143221143222143223143224143225143226143227143228143229143230143231143232143233143234143235143236143237143238143239143240143241143242143243143244143245143246143247143248143249143250143251143252143253143254143255143256143257143258143259143260143261143262143263143264143265143266143267143268143269143270143271143272143273143274143275143276143277143278143279143280143281143282143283143284143285143286143287143288143289143290143291143292143293143294143295143296143297143298143299143300143301143302143303143304143305143306143307143308143309143310143311143312143313143314143315143316143317143318143319143320143321143322143323143324143325143326143327143328143329143330143331143332143333143334143335143336143337143338143339143340143341143342143343143344143345143346143347143348143349143350143351143352143353143354143355143356143357143358143359143360143361143362143363143364143365143366143367143368143369143370143371143372143373143374143375143376143377143378143379143380143381143382143383143384143385143386143387143388143389143390143391143392143393143394143395143396143397143398143399143400143401143402143403143404143405143406143407143408143409143410143411143412143413143414143415143416143417143418143419143420143421143422143423143424143425143426143427143428143429143430143431143432143433143434143435143436143437143438143439143440143441143442143443143444143445143446143447143448143449143450143451143452143453143454143455143456143457143458143459143460143461143462143463143464143465143466143467143468143469143470143471143472143473143474143475143476143477143478143479143480143481143482143483143484143485143486143487143488143489143490143491143492143493143494143495143496143497143498143499143500143501143502143503143504143505143506143507143508143509143510143511143512143513143514143515143516143517143518143519143520143521143522143523143524143525143526143527143528143529143530143531143532143533143534143535143536143537143538143539143540143541143542143543143544143545143546143547143548143549143550143551143552143553143554143555143556143557143558143559143560143561143562143563143564143565143566143567143568143569143570143571143572143573143574143575143576143577143578143579143580143581143582143583143584143585143586143587143588143589143590143591143592143593143594143595143596143597143598143599143600143601143602143603143604143605143606143607143608143609143610143611143612143613143614143615143616143617143618143619143620143621143622143623143624143625143626143627143628143629143630143631143632143633143634143635143636143637143638143639143640143641143642143643143644143645143646143647143648143649143650143651143652143653143654143655143656143657143658143659143660143661143662143663143664143665143666143667143668143669143670143671143672143673143674143675143676143677143678143679143680143681143682143683143684143685143686143687143688143689143690143691143692143693143694143695143696143697143698143699143700143701143702143703143704143705143706143707143708143709143710143711143712143713143714143715143716143717143718143719143720143721143722143723143724143725143726143727143728143729143730143731143732143733143734143735143736143737143738143739143740143741143742143743143744143745143746143747143748143749143750143751143752143753143754143755143756143757143758143759143760143761143762143763143764143765143766143767143768143769143770143771143772143773143774143775143776143777143778143779143780143781143782143783143784143785143786143787143788143789143790143791143792143793143794143795143796143797143798143799143800143801143802143803143804143805143806143807143808143809143810143811143812143813143814143815143816143817143818143819143820143821143822143823143824143825143826143827143828143829143830143831143832143833143834143835143836143837143838143839143840143841143842143843143844143845143846143847143848143849143850143851143852143853143854143855143856143857143858143859143860143861143862143863143864143865143866143867143868143869143870143871143872143873143874143875143876143877143878143879143880143881143882143883143884143885143886143887143888143889143890143891143892143893143894143895143896143897143898143899143900143901143902143903143904143905143906143907143908143909143910143911143912143913143914143915143916143917143918143919143920143921143922143923143924143925143926143927143928143929143930143931143932143933143934143935143936143937143938143939143940143941143942143943143944143945143946143947143948143949143950143951143952143953143954143955143956143957143958143959143960143961143962143963143964143965143966143967143968143969143970143971143972143973143974143975143976143977143978143979143980143981143982143983143984143985143986143987143988143989143990143991143992143993143994143995143996143997143998143999144000144001144002144003144004144005144006144007144008144009144010144011144012144013144014144015144016144017144018144019144020144021144022144023144024144025144026144027144028144029144030144031144032144033144034144035144036144037144038144039144040144041144042144043144044144045144046144047144048144049144050144051144052144053144054144055144056144057144058144059144060144061144062144063144064144065144066144067144068144069144070144071144072144073144074144075144076144077144078144079144080144081144082144083144084144085144086144087144088144089144090144091144092144093144094144095144096144097144098144099144100144101144102144103144104144105144106144107144108144109144110144111144112144113144114144115144116144117144118144119144120144121144122144123144124144125144126144127144128144129144130144131144132144133144134144135144136144137144138144139144140144141144142144143144144144145144146144147144148144149144150144151144152144153144154144155144156144157144158144159144160144161144162144163144164144165144166144167144168144169144170144171144172144173144174144175144176144177144178144179144180144181144182144183144184144185144186144187144188144189144190144191144192144193144194144195144196144197144198144199144200144201144202144203144204144205144206144207144208144209144210144211144212144213144214144215144216144217144218144219144220144221144222144223144224144225144226144227144228144229144230144231144232144233144234144235144236144237144238144239144240144241144242144243144244144245144246144247144248144249144250144251144252144253144254144255144256144257144258144259144260144261144262144263144264144265144266144267144268144269144270144271144272144273144274144275144276144277144278144279144280144281144282144283144284144285144286144287144288144289144290144291144292144293144294144295144296144297144298144299144300144301144302144303144304144305144306144307144308144309144310144311144312144313144314144315144316144317144318144319144320144321144322144323144324144325144326144327144328144329144330144331144332144333144334144335144336144337144338144339144340144341144342144343144344144345144346144347144348144349144350144351144352144353144354144355144356144357144358144359144360144361144362144363144364144365144366144367144368144369144370144371144372144373144374144375144376144377144378144379144380144381144382144383144384144385144386144387144388144389144390144391144392144393144394144395144396144397144398144399144400144401144402144403144404144405144406144407144408144409144410144411144412144413144414144415144416144417144418144419144420144421144422144423144424144425144426144427144428144429144430144431144432144433144434144435144436144437144438144439144440144441144442144443144444144445144446144447144448144449144450144451144452144453144454144455144456144457144458144459144460144461144462144463144464144465144466144467144468144469144470144471144472144473144474144475144476144477144478144479144480144481144482144483144484144485144486144487144488144489144490144491144492144493144494144495144496144497144498144499144500144501144502144503144504144505144506144507144508144509144510144511144512144513144514144515144516144517144518144519144520144521144522144523144524144525144526144527144528144529144530144531144532144533144534144535144536144537144538144539144540144541144542144543144544144545144546144547144548144549144550144551144552144553144554144555144556144557144558144559144560144561144562144563144564144565144566144567144568144569144570144571144572144573144574144575144576144577144578144579144580144581144582144583144584144585144586144587144588144589144590144591144592144593144594144595144596144597144598144599144600144601144602144603144604144605144606144607144608144609144610144611144612144613144614144615144616144617144618144619144620144621144622144623144624144625144626144627144628144629144630144631144632144633144634144635144636144637144638144639144640144641144642144643144644144645144646144647144648144649144650144651144652144653144654144655144656144657144658144659144660144661144662144663144664144665144666144667144668144669144670144671144672144673144674144675144676144677144678144679144680144681144682144683144684144685144686144687144688144689144690144691144692144693144694144695144696144697144698144699144700144701144702144703144704144705144706144707144708144709144710144711144712144713144714144715144716144717144718144719144720144721144722144723144724144725144726144727144728144729144730144731144732144733144734144735144736144737144738144739144740144741144742144743144744144745144746144747144748144749144750144751144752144753144754144755144756144757144758144759144760144761144762144763144764144765144766144767144768144769144770144771144772144773144774144775144776144777144778144779144780144781144782144783144784144785144786144787144788144789144790144791144792144793144794144795144796144797144798144799144800144801144802144803144804144805144806144807144808144809144810144811144812144813144814144815144816144817144818144819144820144821144822144823144824144825144826144827144828144829144830144831144832144833144834144835144836144837144838144839144840144841144842144843144844144845144846144847144848144849144850144851144852144853144854144855144856144857144858144859144860144861144862144863144864144865144866144867144868144869144870144871144872144873144874144875144876144877144878144879144880144881144882144883144884144885144886144887144888144889144890144891144892144893144894144895144896144897144898144899144900144901144902144903144904144905144906144907144908144909144910144911144912144913144914144915144916144917144918144919144920144921144922144923144924144925144926144927144928144929144930144931144932144933144934144935144936144937144938144939144940144941144942144943144944144945144946144947144948144949144950144951144952144953144954144955144956144957144958144959144960144961144962144963144964144965144966144967144968144969144970144971144972144973144974144975144976144977144978144979144980144981144982144983144984144985144986144987144988144989144990144991144992144993144994144995144996144997144998144999145000145001145002145003145004145005145006145007145008145009145010145011145012145013145014145015145016145017145018145019145020145021145022145023145024145025145026145027145028145029145030145031145032145033145034145035145036145037145038145039145040145041145042145043145044145045145046145047145048145049145050145051145052145053145054145055145056145057145058145059145060145061145062145063145064145065145066145067145068145069145070145071145072145073145074145075145076145077145078145079145080145081145082145083145084145085145086145087145088145089145090145091145092145093145094145095145096145097145098145099145100145101145102145103145104145105145106145107145108145109145110145111145112145113145114145115145116145117145118145119145120145121145122145123145124145125145126145127145128145129145130145131145132145133145134145135145136145137145138145139145140145141145142145143145144145145145146145147145148145149145150145151145152145153145154145155145156145157145158145159145160145161145162145163145164145165145166145167145168145169145170145171145172145173145174145175145176145177145178145179145180145181145182145183145184145185145186145187145188145189145190145191145192145193145194145195145196145197145198145199145200145201145202145203145204145205145206145207145208145209145210145211145212145213145214145215145216145217145218145219145220145221145222145223145224145225145226145227145228145229145230145231145232145233145234145235145236145237145238145239145240145241145242145243145244145245145246145247145248145249145250145251145252145253145254145255145256145257145258145259145260145261145262145263145264145265145266145267145268145269145270145271145272145273145274145275145276145277145278145279145280145281145282145283145284145285145286145287145288145289145290145291145292145293145294145295145296145297145298145299145300145301145302145303145304145305145306145307145308145309145310145311145312145313145314145315145316145317145318145319145320145321145322145323145324145325145326145327145328145329145330145331145332145333145334145335145336145337145338145339145340145341145342145343145344145345145346145347145348145349145350145351145352145353145354145355145356145357145358145359145360145361145362145363145364145365145366145367145368145369145370145371145372145373145374145375145376145377145378145379145380145381145382145383145384145385145386145387145388145389145390145391145392145393145394145395145396145397145398145399145400145401145402145403145404145405145406145407145408145409145410145411145412145413145414145415145416145417145418145419145420145421145422145423145424145425145426145427145428145429145430145431145432145433145434145435145436145437145438145439145440145441145442145443145444145445145446145447145448145449145450145451145452145453145454145455145456145457145458145459145460145461145462145463145464145465145466145467145468145469145470145471145472145473145474145475145476145477145478145479145480145481145482145483145484145485145486145487145488145489145490145491145492145493145494145495145496145497145498145499145500145501145502145503145504145505145506145507145508145509145510145511145512145513145514145515145516145517145518145519145520145521145522145523145524145525145526145527145528145529145530145531145532145533145534145535145536145537145538145539145540145541145542145543145544145545145546145547145548145549145550145551145552145553145554145555145556145557145558145559145560145561145562145563145564145565145566145567145568145569145570145571145572145573145574145575145576145577145578145579145580145581145582145583145584145585145586145587145588145589145590145591145592145593145594145595145596145597145598145599145600145601145602145603145604145605145606145607145608145609145610145611145612145613145614145615145616145617145618145619145620145621145622145623145624145625145626145627145628145629145630145631145632145633145634145635145636145637145638145639145640145641145642145643145644145645145646145647145648145649145650145651145652145653145654145655145656145657145658145659145660145661145662145663145664145665145666145667145668145669145670145671145672145673145674145675145676145677145678145679145680145681145682145683145684145685145686145687145688145689145690145691145692145693145694145695145696145697145698145699145700145701145702145703145704145705145706145707145708145709145710145711145712145713145714145715145716145717145718145719145720145721145722145723145724145725145726145727145728145729145730145731145732145733145734145735145736145737145738145739145740145741145742145743145744145745145746145747145748145749145750145751145752145753145754145755145756145757145758145759145760145761145762145763145764145765145766145767145768145769145770145771145772145773145774145775145776145777145778145779145780145781145782145783145784145785145786145787145788145789145790145791145792145793145794145795145796145797145798145799145800145801145802145803145804145805145806145807145808145809145810145811145812145813145814145815145816145817145818145819145820145821145822145823145824145825145826145827145828145829145830145831145832145833145834145835145836145837145838145839145840145841145842145843145844145845145846145847145848145849145850145851145852145853145854145855145856145857145858145859145860145861145862145863145864145865145866145867145868145869145870145871145872145873145874145875145876145877145878145879145880145881145882145883145884145885145886145887145888145889145890145891145892145893145894145895145896145897145898145899145900145901145902145903145904145905145906145907145908145909145910145911145912145913145914145915145916145917145918145919145920145921145922145923145924145925145926145927145928145929145930145931145932145933145934145935145936145937145938145939145940145941145942145943145944145945145946145947145948145949145950145951145952145953145954145955145956145957145958145959145960145961145962145963145964145965145966145967145968145969145970145971145972145973145974145975145976145977145978145979145980145981145982145983145984145985145986145987145988145989145990145991145992145993145994145995145996145997145998145999146000146001146002146003146004146005146006146007146008146009146010146011146012146013146014146015146016146017146018146019146020146021146022146023146024146025146026146027146028146029146030146031146032146033146034146035146036146037146038146039146040146041146042146043146044146045146046146047146048146049146050146051146052146053146054146055146056146057146058146059146060146061146062146063146064146065146066146067146068146069146070146071146072146073146074146075146076146077146078146079146080146081146082146083146084146085146086146087146088146089146090146091146092146093146094146095146096146097146098146099146100146101146102146103146104146105146106146107146108146109146110146111146112146113146114146115146116146117146118146119146120146121146122146123146124146125146126146127146128146129146130146131146132146133146134146135146136146137146138146139146140146141146142146143146144146145146146146147146148146149146150146151146152146153146154146155146156146157146158146159146160146161146162146163146164146165146166146167146168146169146170146171146172146173146174146175146176146177146178146179146180146181146182146183146184146185146186146187146188146189146190146191146192146193146194146195146196146197146198146199146200146201146202146203146204146205146206146207146208146209146210146211146212146213146214146215146216146217146218146219146220146221146222146223146224146225146226146227146228146229146230146231146232146233146234146235146236146237146238146239146240146241146242146243146244146245146246146247146248146249146250146251146252146253146254146255146256146257146258146259146260146261146262146263146264146265146266146267146268146269146270146271146272146273146274146275146276146277146278146279146280146281146282146283146284146285146286146287146288146289146290146291146292146293146294146295146296146297146298146299146300146301146302146303146304146305146306146307146308146309146310146311146312146313146314146315146316146317146318146319146320146321146322146323146324146325146326146327146328146329146330146331146332146333146334146335146336146337146338146339146340146341146342146343146344146345146346146347146348146349146350146351146352146353146354146355146356146357146358146359146360146361146362146363146364146365146366146367146368146369146370146371146372146373146374146375146376146377146378146379146380146381146382146383146384146385146386146387146388146389146390146391146392146393146394146395146396146397146398146399146400146401146402146403146404146405146406146407146408146409146410146411146412146413146414146415146416146417146418146419146420146421146422146423146424146425146426146427146428146429146430146431146432146433146434146435146436146437146438146439146440146441146442146443146444146445146446146447146448146449146450146451146452146453146454146455146456146457146458146459146460146461146462146463146464146465146466146467146468146469146470146471146472146473146474146475146476146477146478146479146480146481146482146483146484146485146486146487146488146489146490146491146492146493146494146495146496146497146498146499146500146501146502146503146504146505146506146507146508146509146510146511146512146513146514146515146516146517146518146519146520146521146522146523146524146525146526146527146528146529146530146531146532146533146534146535146536146537146538146539146540146541146542146543146544146545146546146547146548146549146550146551146552146553146554146555146556146557146558146559146560146561146562146563146564146565146566146567146568146569146570146571146572146573146574146575146576146577146578146579146580146581146582146583146584146585146586146587146588146589146590146591146592146593146594146595146596146597146598146599146600146601146602146603146604146605146606146607146608146609146610146611146612146613146614146615146616146617146618146619146620146621146622146623146624146625146626146627146628146629146630146631146632146633146634146635146636146637146638146639146640146641146642146643146644146645146646146647146648146649146650146651146652146653146654146655146656146657146658146659146660146661146662146663146664146665146666146667146668146669146670146671146672146673146674146675146676146677146678146679146680146681146682146683146684146685146686146687146688146689146690146691146692146693146694146695146696146697146698146699146700146701146702146703146704146705146706146707146708146709146710146711146712146713146714146715146716146717146718146719146720146721146722146723146724146725146726146727146728146729146730146731146732146733146734146735146736146737146738146739146740146741146742146743146744146745146746146747146748146749146750146751146752146753146754146755146756146757146758146759146760146761146762146763146764146765146766146767146768146769146770146771146772146773146774146775146776146777146778146779146780146781146782146783146784146785146786146787146788146789146790146791146792146793146794146795146796146797146798146799146800146801146802146803146804146805146806146807146808146809146810146811146812146813146814146815146816146817146818146819146820146821146822146823146824146825146826146827146828146829146830146831146832146833146834146835146836146837146838146839146840146841146842146843146844146845146846146847146848146849146850146851146852146853146854146855146856146857146858146859146860146861146862146863146864146865146866146867146868146869146870146871146872146873146874146875146876146877146878146879146880146881146882146883146884146885146886146887146888146889146890146891146892146893146894146895146896146897146898146899146900146901146902146903146904146905146906146907146908146909146910146911146912146913146914146915146916146917146918146919146920146921146922146923146924146925146926146927146928146929146930146931146932146933146934146935146936146937146938146939146940146941146942146943146944146945146946146947146948146949146950146951146952146953146954146955146956146957146958146959146960146961146962146963146964146965146966146967146968146969146970146971146972146973146974146975146976146977146978146979146980146981146982146983146984146985146986146987146988146989146990146991146992146993146994146995146996146997146998146999147000147001147002147003147004147005147006147007147008147009147010147011147012147013147014147015147016147017147018147019147020147021147022147023147024147025147026147027147028147029147030147031147032147033147034147035147036147037147038147039147040147041147042147043147044147045147046147047147048147049147050147051147052147053147054147055147056147057147058147059147060147061147062147063147064147065147066147067147068147069147070147071147072147073147074147075147076147077147078147079147080147081147082147083147084147085147086147087147088147089147090147091147092147093147094147095147096147097147098147099147100147101147102147103147104147105147106147107147108147109147110147111147112147113147114147115147116147117147118147119147120147121147122147123147124147125147126147127147128147129147130147131147132147133147134147135147136147137147138147139147140147141147142147143147144147145147146147147147148147149147150147151147152147153147154147155147156147157147158147159147160147161147162147163147164147165147166147167147168147169147170147171147172147173147174147175147176147177147178147179147180147181147182147183147184147185147186147187147188147189147190147191147192147193147194147195147196147197147198147199147200147201147202147203147204147205147206147207147208147209147210147211147212147213147214147215147216147217147218147219147220147221147222147223147224147225147226147227147228147229147230147231147232147233147234147235147236147237147238147239147240147241147242147243147244147245147246147247147248147249147250147251147252147253147254147255147256147257147258147259147260147261147262147263147264147265147266147267147268147269147270147271147272147273147274147275147276147277147278147279147280147281147282147283147284147285147286147287147288147289147290147291147292147293147294147295147296147297147298147299147300147301147302147303147304147305147306147307147308147309147310147311147312147313147314147315147316147317147318147319147320147321147322147323147324147325147326147327147328147329147330147331147332147333147334147335147336147337147338147339147340147341147342147343147344147345147346147347147348147349147350147351147352147353147354147355147356147357147358147359147360147361147362147363147364147365147366147367147368147369147370147371147372147373147374147375147376147377147378147379147380147381147382147383147384147385147386147387147388147389147390147391147392147393147394147395147396147397147398147399147400147401147402147403147404147405147406147407147408147409147410147411147412147413147414147415147416147417147418147419147420147421147422147423147424147425147426147427147428147429147430147431147432147433147434147435147436147437147438147439147440147441147442147443147444147445147446147447147448147449147450147451147452147453147454147455147456147457147458147459147460147461147462147463147464147465147466147467147468147469147470147471147472147473147474147475147476147477147478147479147480147481147482147483147484147485147486147487147488147489147490147491147492147493147494147495147496147497147498147499147500147501147502147503147504147505147506147507147508147509147510147511147512147513147514147515147516147517147518147519147520147521147522147523147524147525147526147527147528147529147530147531147532147533147534147535147536147537147538147539147540147541147542147543147544147545147546147547147548147549147550147551147552147553147554147555147556147557147558147559147560147561147562147563147564147565147566147567147568147569147570147571147572147573147574147575147576147577147578147579147580147581147582147583147584147585147586147587147588147589147590147591147592147593147594147595147596147597147598147599147600147601147602147603147604147605147606147607147608147609147610147611147612147613147614147615147616147617147618147619147620147621147622147623147624147625147626147627147628147629147630147631147632147633147634147635147636147637147638147639147640147641147642147643147644147645147646147647147648147649147650147651147652147653147654147655147656147657147658147659147660147661147662147663147664147665147666147667147668147669147670147671147672147673147674147675147676147677147678147679147680147681147682147683147684147685147686147687147688147689147690147691147692147693147694147695147696147697147698147699147700147701147702147703147704147705147706147707147708147709147710147711147712147713147714147715147716147717147718147719147720147721147722147723147724147725147726147727147728147729147730147731147732147733147734147735147736147737147738147739147740147741147742147743147744147745147746147747147748147749147750147751147752147753147754147755147756147757147758147759147760147761147762147763147764147765147766147767147768147769147770147771147772147773147774147775147776147777147778147779147780147781147782147783147784147785147786147787147788147789147790147791147792147793147794147795147796147797147798147799147800147801147802147803147804147805147806147807147808147809147810147811147812147813147814147815147816147817147818147819147820147821147822147823147824147825147826147827147828147829147830147831147832147833147834147835147836147837147838147839147840147841147842147843147844147845147846147847147848147849147850147851147852147853147854147855147856147857147858147859147860147861147862147863147864147865147866147867147868147869147870147871147872147873147874147875147876147877147878147879147880147881147882147883147884147885147886147887147888147889147890147891147892147893147894147895147896147897147898147899147900147901147902147903147904147905147906147907147908147909147910147911147912147913147914147915147916147917147918147919147920147921147922147923147924147925147926147927147928147929147930147931147932147933147934147935147936147937147938147939147940147941147942147943147944147945147946147947147948147949147950147951147952147953147954147955147956147957147958147959147960147961147962147963147964147965147966147967147968147969147970147971147972147973147974147975147976147977147978147979147980147981147982147983147984147985147986147987147988147989147990147991147992147993147994147995147996147997147998147999148000148001148002148003148004148005148006148007148008148009148010148011148012148013148014148015148016148017148018148019148020148021148022148023148024148025148026148027148028148029148030148031148032148033148034148035148036148037148038148039148040148041148042148043148044148045148046148047148048148049148050148051148052148053148054148055148056148057148058148059148060148061148062148063148064148065148066148067148068148069148070148071148072148073148074148075148076148077148078148079148080148081148082148083148084148085148086148087148088148089148090148091148092148093148094148095148096148097148098148099148100148101148102148103148104148105148106148107148108148109148110148111148112148113148114148115148116148117148118148119148120148121148122148123148124148125148126148127148128148129148130148131148132148133148134148135148136148137148138148139148140148141148142148143148144148145148146148147148148148149148150148151148152148153148154148155148156148157148158148159148160148161148162148163148164148165148166148167148168148169148170148171148172148173148174148175148176148177148178148179148180148181148182148183148184148185148186148187148188148189148190148191148192148193148194148195148196148197148198148199148200148201148202148203148204148205148206148207148208148209148210148211148212148213148214148215148216148217148218148219148220148221148222148223148224148225148226148227148228148229148230148231148232148233148234148235148236148237148238148239148240148241148242148243148244148245148246148247148248148249148250148251148252148253148254148255148256148257148258148259148260148261148262148263148264148265148266148267148268148269148270148271148272148273148274148275148276148277148278148279148280148281148282148283148284148285148286148287148288148289148290148291148292148293148294148295148296148297148298148299148300148301148302148303148304148305148306148307148308148309148310148311148312148313148314148315148316148317148318148319148320148321148322148323148324148325148326148327148328148329148330148331148332148333148334148335148336148337148338148339148340148341148342148343148344148345148346148347148348148349148350148351148352148353148354148355148356148357148358148359148360148361148362148363148364148365148366148367148368148369148370148371148372148373148374148375148376148377148378148379148380148381148382148383148384148385148386148387148388148389148390148391148392148393148394148395148396148397148398148399148400148401148402148403148404148405148406148407148408148409148410148411148412148413148414148415148416148417148418148419148420148421148422148423148424148425148426148427148428148429148430148431148432148433148434148435148436148437148438148439148440148441148442148443148444148445148446148447148448148449148450148451148452148453148454148455148456148457148458148459148460148461148462148463148464148465148466148467148468148469148470148471148472148473148474148475148476148477148478148479148480148481148482148483148484148485148486148487148488148489148490148491148492148493148494148495148496148497148498148499148500148501148502148503148504148505148506148507148508148509148510148511148512148513148514148515148516148517148518148519148520148521148522148523148524148525148526148527148528148529148530148531148532148533148534148535148536148537148538148539148540148541148542148543148544148545148546148547148548148549148550148551148552148553148554148555148556148557148558148559148560148561148562148563148564148565148566148567148568148569148570148571148572148573148574148575148576148577148578148579148580148581148582148583148584148585148586148587148588148589148590148591148592148593148594148595148596148597148598148599148600148601148602148603148604148605148606148607148608148609148610148611148612148613148614148615148616148617148618148619148620148621148622148623148624148625148626148627148628148629148630148631148632148633148634148635148636148637148638148639148640148641148642148643148644148645148646148647148648148649148650148651148652148653148654148655148656148657148658148659148660148661148662148663148664148665148666148667148668148669148670148671148672148673148674148675148676148677148678148679148680148681148682148683148684148685148686148687148688148689148690148691148692148693148694148695148696148697148698148699148700148701148702148703148704148705148706148707148708148709148710148711148712148713148714148715148716148717148718148719148720148721148722148723148724148725148726148727148728148729148730148731148732148733148734148735148736148737148738148739148740148741148742148743148744148745148746148747148748148749148750148751148752148753148754148755148756148757148758148759148760148761148762148763148764148765148766148767148768148769148770148771148772148773148774148775148776148777148778148779148780148781148782148783148784148785148786148787148788148789148790148791148792148793148794148795148796148797148798148799148800148801148802148803148804148805148806148807148808148809148810148811148812148813148814148815148816148817148818148819148820148821148822148823148824148825148826148827148828148829148830148831148832148833148834148835148836148837148838148839148840148841148842148843148844148845148846148847148848148849148850148851148852148853148854148855148856148857148858148859148860148861148862148863148864148865148866148867148868148869148870148871148872148873148874148875148876148877148878148879148880148881148882148883148884148885148886148887148888148889148890148891148892148893148894148895148896148897148898148899148900148901148902148903148904148905148906148907148908148909148910148911148912148913148914148915148916148917148918148919148920148921148922148923148924148925148926148927148928148929148930148931148932148933148934148935148936148937148938148939148940148941148942148943148944148945148946148947148948148949148950148951148952148953148954148955148956148957148958148959148960148961148962148963148964148965148966148967148968148969148970148971148972148973148974148975148976148977148978148979148980148981148982148983148984148985148986148987148988148989148990148991148992148993148994148995148996148997148998148999149000149001149002149003149004149005149006149007149008149009149010149011149012149013149014149015149016149017149018149019149020149021149022149023149024149025149026149027149028149029149030149031149032149033149034149035149036149037149038149039149040149041149042149043149044149045149046149047149048149049149050149051149052149053149054149055149056149057149058149059149060149061149062149063149064149065149066149067149068149069149070149071149072149073149074149075149076149077149078149079149080149081149082149083149084149085149086149087149088149089149090149091149092149093149094149095149096149097149098149099149100149101149102149103149104149105149106149107149108149109149110149111149112149113149114149115149116149117149118149119149120149121149122149123149124149125149126149127149128149129149130149131149132149133149134149135149136149137149138149139149140149141149142149143149144149145149146149147149148149149149150149151149152149153149154149155149156149157149158149159149160149161149162149163149164149165149166149167149168149169149170149171149172149173149174149175149176149177149178149179149180149181149182149183149184149185149186149187149188149189149190149191149192149193149194149195149196149197149198149199149200149201149202149203149204149205149206149207149208149209149210149211149212149213149214149215149216149217149218149219149220149221149222149223149224149225149226149227149228149229149230149231149232149233149234149235149236149237149238149239149240149241149242149243149244149245149246149247149248149249149250149251149252149253149254149255149256149257149258149259149260149261149262149263149264149265149266149267149268149269149270149271149272149273149274149275149276149277149278149279149280149281149282149283149284149285149286149287149288149289149290149291149292149293149294149295149296149297149298149299149300149301149302149303149304149305149306149307149308149309149310149311149312149313149314149315149316149317149318149319149320149321149322149323149324149325149326149327149328149329149330149331149332149333149334149335149336149337149338149339149340149341149342149343149344149345149346149347149348149349149350149351149352149353149354149355149356149357149358149359149360149361149362149363149364149365149366149367149368149369149370149371149372149373149374149375149376149377149378149379149380149381149382149383149384149385149386149387149388149389149390149391149392149393149394149395149396149397149398149399149400149401149402149403149404149405149406149407149408149409149410149411149412149413149414149415149416149417149418149419149420149421149422149423149424149425149426149427149428149429149430149431149432149433149434149435149436149437149438149439149440149441149442149443149444149445149446149447149448149449149450149451149452149453149454149455149456149457149458149459149460149461149462149463149464149465149466149467149468149469149470149471149472149473149474149475149476149477149478149479149480149481149482149483149484149485149486149487149488149489149490149491149492149493149494149495149496149497149498149499149500149501149502149503149504149505149506149507149508149509149510149511149512149513149514149515149516149517149518149519149520149521149522149523149524149525149526149527149528149529149530149531149532149533149534149535149536149537149538149539149540149541149542149543149544149545149546149547149548149549149550149551149552149553149554149555149556149557149558149559149560149561149562149563149564149565149566149567149568149569149570149571149572149573149574149575149576149577149578149579149580149581149582149583149584149585149586149587149588149589149590149591149592149593149594149595149596149597149598149599149600149601149602149603149604149605149606149607149608149609149610149611149612149613149614149615149616149617149618149619149620149621149622149623149624149625149626149627149628149629149630149631149632149633149634149635149636149637149638149639149640149641149642149643149644149645149646149647149648149649149650149651149652149653149654149655149656149657149658149659149660149661149662149663149664149665149666149667149668149669149670149671149672149673149674149675149676149677149678149679149680149681149682149683149684149685149686149687149688149689149690149691149692149693149694149695149696149697149698149699149700149701149702149703149704149705149706149707149708149709149710149711149712149713149714149715149716149717149718149719149720149721149722149723149724149725149726149727149728149729149730149731149732149733149734149735149736149737149738149739149740149741149742149743149744149745149746149747149748149749149750149751149752149753149754149755149756149757149758149759149760149761149762149763149764149765149766149767149768149769149770149771149772149773149774149775149776149777149778149779149780149781149782149783149784149785149786149787149788149789149790149791149792149793149794149795149796149797149798149799149800149801149802149803149804149805149806149807149808149809149810149811149812149813149814149815149816149817149818149819149820149821149822149823149824149825149826149827149828149829149830149831149832149833149834149835149836149837149838149839149840149841149842149843149844149845149846149847149848149849149850149851149852149853149854149855149856149857149858149859149860149861149862149863149864149865149866149867149868149869149870149871149872149873149874149875149876149877149878149879149880149881149882149883149884149885149886149887149888149889149890149891149892149893149894149895149896149897149898149899149900149901149902149903149904149905149906149907149908149909149910149911149912149913149914149915149916149917149918149919149920149921149922149923149924149925149926149927149928149929149930149931149932149933149934149935149936149937149938149939149940149941149942149943149944149945149946149947149948149949149950149951149952149953149954149955149956149957149958149959149960149961149962149963149964149965149966149967149968149969149970149971149972149973149974149975149976149977149978149979149980149981149982149983149984149985149986149987149988149989149990149991149992149993149994149995149996149997149998149999150000150001150002150003150004150005150006150007150008150009150010150011150012150013150014150015150016150017150018150019150020150021150022150023150024150025150026150027150028150029150030150031150032150033150034150035150036150037150038150039150040150041150042150043150044150045150046150047150048150049150050150051150052150053150054150055150056150057150058150059150060150061150062150063150064150065150066150067150068150069150070150071150072150073150074150075150076150077150078150079150080150081150082150083150084150085150086150087150088150089150090150091150092150093150094150095150096150097150098150099150100150101150102150103150104150105150106150107150108150109150110150111150112150113150114150115150116150117150118150119150120150121150122150123150124150125150126150127150128150129150130150131150132150133150134150135150136150137150138150139150140150141150142150143150144150145150146150147150148150149150150150151150152150153150154150155150156150157150158150159150160150161150162150163150164150165150166150167150168150169150170150171150172150173150174150175150176150177150178150179150180150181150182150183150184150185150186150187150188150189150190150191150192150193150194150195150196150197150198150199150200150201150202150203150204150205150206150207150208150209150210150211150212150213150214150215150216150217150218150219150220150221150222150223150224150225150226150227150228150229150230150231150232150233150234150235150236150237150238150239150240150241150242150243150244150245150246150247150248150249150250150251150252150253150254150255150256150257150258150259150260150261150262150263150264150265150266150267150268150269150270150271150272150273150274150275150276150277150278150279150280150281150282150283150284150285150286150287150288150289150290150291150292150293150294150295150296150297150298150299150300150301150302150303150304150305150306150307150308150309150310150311150312150313150314150315150316150317150318150319150320150321150322150323150324150325150326150327150328150329150330150331150332150333150334150335150336150337150338150339150340150341150342150343150344150345150346150347150348150349150350150351150352150353150354150355150356150357150358150359150360150361150362150363150364150365150366150367150368150369150370150371150372150373150374150375150376150377150378150379150380150381150382150383150384150385150386150387150388150389150390150391150392150393150394150395150396150397150398150399150400150401150402150403150404150405150406150407150408150409150410150411150412150413150414150415150416150417150418150419150420150421150422150423150424150425150426150427150428150429150430150431150432150433150434150435150436150437150438150439150440150441150442150443150444150445150446150447150448150449150450150451150452150453150454150455150456150457150458150459150460150461150462150463150464150465150466150467150468150469150470150471150472150473150474150475150476150477150478150479150480150481150482150483150484150485150486150487150488150489150490150491150492150493150494150495150496150497150498150499150500150501150502150503150504150505150506150507150508150509150510150511150512150513150514150515150516150517150518150519150520150521150522150523150524150525150526150527150528150529150530150531150532150533150534150535150536150537150538150539150540150541150542150543150544150545150546150547150548150549150550150551150552150553150554150555150556150557150558150559150560150561150562150563150564150565150566150567150568150569150570150571150572150573150574150575150576150577150578150579150580150581150582150583150584150585150586150587150588150589150590150591150592150593150594150595150596150597150598150599150600150601150602150603150604150605150606150607150608150609150610150611150612150613150614150615150616150617150618150619150620150621150622150623150624150625150626150627150628150629150630150631150632150633150634150635150636150637150638150639150640150641150642150643150644150645150646150647150648150649150650150651150652150653150654150655150656150657150658150659150660150661150662150663150664150665150666150667150668150669150670150671150672150673150674150675150676150677150678150679150680150681150682150683150684150685150686150687150688150689150690150691150692150693150694150695150696150697150698150699150700150701150702150703150704150705150706150707150708150709150710150711150712150713150714150715150716150717150718150719150720150721150722150723150724150725150726150727150728150729150730150731150732150733150734150735150736150737150738150739150740150741150742150743150744150745150746150747150748150749150750150751150752150753150754150755150756150757150758150759150760150761150762150763150764150765150766150767150768150769150770150771150772150773150774150775150776150777150778150779150780150781150782150783150784150785150786150787150788150789150790150791150792150793150794150795150796150797150798150799150800150801150802150803150804150805150806150807150808150809150810150811150812150813150814150815150816150817150818150819150820150821150822150823150824150825150826150827150828150829150830150831150832150833150834150835150836150837150838150839150840150841150842150843150844150845150846150847150848150849150850150851150852150853150854150855150856150857150858150859150860150861150862150863150864150865150866150867150868150869150870150871150872150873150874150875150876150877150878150879150880150881150882150883150884150885150886150887150888150889150890150891150892150893150894150895150896150897150898150899150900150901150902150903150904150905150906150907150908150909150910150911150912150913150914150915150916150917150918150919150920150921150922150923150924150925150926150927150928150929150930150931150932150933150934150935150936150937150938150939150940150941150942150943150944150945150946150947150948150949150950150951150952150953150954150955150956150957150958150959150960150961150962150963150964150965150966150967150968150969150970150971150972150973150974150975150976150977150978150979150980150981150982150983150984150985150986150987150988150989150990150991150992150993150994150995150996150997150998150999151000151001151002151003151004151005151006151007151008151009151010151011151012151013151014151015151016151017151018151019151020151021151022151023151024151025151026151027151028151029151030151031151032151033151034151035151036151037151038151039151040151041151042151043151044151045151046151047151048151049151050151051151052151053151054151055151056151057151058151059151060151061151062151063151064151065151066151067151068151069151070151071151072151073151074151075151076151077151078151079151080151081151082151083151084151085151086151087151088151089151090151091151092151093151094151095151096151097151098151099151100151101151102151103151104151105151106151107151108151109151110151111151112151113151114151115151116151117151118151119151120151121151122151123151124151125151126151127151128151129151130151131151132151133151134151135151136151137151138151139151140151141151142151143151144151145151146151147151148151149151150151151151152151153151154151155151156151157151158151159151160151161151162151163151164151165151166151167151168151169151170151171151172151173151174151175151176151177151178151179151180151181151182151183151184151185151186151187151188151189151190151191151192151193151194151195151196151197151198151199151200151201151202151203151204151205151206151207151208151209151210151211151212151213151214151215151216151217151218151219151220151221151222151223151224151225151226151227151228151229151230151231151232151233151234151235151236151237151238151239151240151241151242151243151244151245151246151247151248151249151250151251151252151253151254151255151256151257151258151259151260151261151262151263151264151265151266151267151268151269151270151271151272151273151274151275151276151277151278151279151280151281151282151283151284151285151286151287151288151289151290151291151292151293151294151295151296151297151298151299151300151301151302151303151304151305151306151307151308151309151310151311151312151313151314151315151316151317151318151319151320151321151322151323151324151325151326151327151328151329151330151331151332151333151334151335151336151337151338151339151340151341151342151343151344151345151346151347151348151349151350151351151352151353151354151355151356151357151358151359151360151361151362151363151364151365151366151367151368151369151370151371151372151373151374151375151376151377151378151379151380151381151382151383151384151385151386151387151388151389151390151391151392151393151394151395151396151397151398151399151400151401151402151403151404151405151406151407151408151409151410151411151412151413151414151415151416151417151418151419151420151421151422151423151424151425151426151427151428151429151430151431151432151433151434151435151436151437151438151439151440151441151442151443151444151445151446151447151448151449151450151451151452151453151454151455151456151457151458151459151460151461151462151463151464151465151466151467151468151469151470151471151472151473151474151475151476151477151478151479151480151481151482151483151484151485151486151487151488151489151490151491151492151493151494151495151496151497151498151499151500151501151502151503151504151505151506151507151508151509151510151511151512151513151514151515151516151517151518151519151520151521151522151523151524151525151526151527151528151529151530151531151532151533151534151535151536151537151538151539151540151541151542151543151544151545151546151547151548151549151550151551151552151553151554151555151556151557151558151559151560151561151562151563151564151565151566151567151568151569151570151571151572151573151574151575151576151577151578151579151580151581151582151583151584151585151586151587151588151589151590151591151592151593151594151595151596151597151598151599151600151601151602151603151604151605151606151607151608151609151610151611151612151613151614151615151616151617151618151619151620151621151622151623151624151625151626151627151628151629151630151631151632151633151634151635151636151637151638151639151640151641151642151643151644151645151646151647151648151649151650151651151652151653151654151655151656151657151658151659151660151661151662151663151664151665151666151667151668151669151670151671151672151673151674151675151676151677151678151679151680151681151682151683151684151685151686151687151688151689151690151691151692151693151694151695151696151697151698151699151700151701151702151703151704151705151706151707151708151709151710151711151712151713151714151715151716151717151718151719151720151721151722151723151724151725151726151727151728151729151730151731151732151733151734151735151736151737151738151739151740151741151742151743151744151745151746151747151748151749151750151751151752151753151754151755151756151757151758151759151760151761151762151763151764151765151766151767151768151769151770151771151772151773151774151775151776151777151778151779151780151781151782151783151784151785151786151787151788151789151790151791151792151793151794151795151796151797151798151799151800151801151802151803151804151805151806151807151808151809151810151811151812151813151814151815151816151817151818151819151820151821151822151823151824151825151826151827151828151829151830151831151832151833151834151835151836151837151838151839151840151841151842151843151844151845151846151847151848151849151850151851151852151853151854151855151856151857151858151859151860151861151862151863151864151865151866151867151868151869151870151871151872151873151874151875151876151877151878151879151880151881151882151883151884151885151886151887151888151889151890151891151892151893151894151895151896151897151898151899151900151901151902151903151904151905151906151907151908151909151910151911151912151913151914151915151916151917151918151919151920151921151922151923151924151925151926151927151928151929151930151931151932151933151934151935151936151937151938151939151940151941151942151943151944151945151946151947151948151949151950151951151952151953151954151955151956151957151958151959151960151961151962151963151964151965151966151967151968151969151970151971151972151973151974151975151976151977151978151979151980151981151982151983151984151985151986151987151988151989151990151991151992151993151994151995151996151997151998151999152000152001152002152003152004152005152006152007152008152009152010152011152012152013152014152015152016152017152018152019152020152021152022152023152024152025152026152027152028152029152030152031152032152033152034152035152036152037152038152039152040152041152042152043152044152045152046152047152048152049152050152051152052152053152054152055152056152057152058152059152060152061152062152063152064152065152066152067152068152069152070152071152072152073152074152075152076152077152078152079152080152081152082152083152084152085152086152087152088152089152090152091152092152093152094152095152096152097152098152099152100152101152102152103152104152105152106152107152108152109152110152111152112152113152114152115152116152117152118152119152120152121152122152123152124152125152126152127152128152129152130152131152132152133152134152135152136152137152138152139152140152141152142152143152144152145152146152147152148152149152150152151152152152153152154152155152156152157152158152159152160152161152162152163152164152165152166152167152168152169152170152171152172152173152174152175152176152177152178152179152180152181152182152183152184152185152186152187152188152189152190152191152192152193152194152195152196152197152198152199152200152201152202152203152204152205152206152207152208152209152210152211152212152213152214152215152216152217152218152219152220152221152222152223152224152225152226152227152228152229152230152231152232152233152234152235152236152237152238152239152240152241152242152243152244152245152246152247152248152249152250152251152252152253152254152255152256152257152258152259152260152261152262152263152264152265152266152267152268152269152270152271152272152273152274152275152276152277152278152279152280152281152282152283152284152285152286152287152288152289152290152291152292152293152294152295152296152297152298152299152300152301152302152303152304152305152306152307152308152309152310152311152312152313152314152315152316152317152318152319152320152321152322152323152324152325152326152327152328152329152330152331152332152333152334152335152336152337152338152339152340152341152342152343152344152345152346152347152348152349152350152351152352152353152354152355152356152357152358152359152360152361152362152363152364152365152366152367152368152369152370152371152372152373152374152375152376152377152378152379152380152381152382152383152384152385152386152387152388152389152390152391152392152393152394152395152396152397152398152399152400152401152402152403152404152405152406152407152408152409152410152411152412152413152414152415152416152417152418152419152420152421152422152423152424152425152426152427152428152429152430152431152432152433152434152435152436152437152438152439152440152441152442152443152444152445152446152447152448152449152450152451152452152453152454152455152456152457152458152459152460152461152462152463152464152465152466152467152468152469152470152471152472152473152474152475152476152477152478152479152480152481152482152483152484152485152486152487152488152489152490152491152492152493152494152495152496152497152498152499152500152501152502152503152504152505152506152507152508152509152510152511152512152513152514152515152516152517152518152519152520152521152522152523152524152525152526152527152528152529152530152531152532152533152534152535152536152537152538152539152540152541152542152543152544152545152546152547152548152549152550152551152552152553152554152555152556152557152558152559152560152561152562152563152564152565152566152567152568152569152570152571152572152573152574152575152576152577152578152579152580152581152582152583152584152585152586152587152588152589152590152591152592152593152594152595152596152597152598152599152600152601152602152603152604152605152606152607152608152609152610152611152612152613152614152615152616152617152618152619152620152621152622152623152624152625152626152627152628152629152630152631152632152633152634152635152636152637152638152639152640152641152642152643152644152645152646152647152648152649152650152651152652152653152654152655152656152657152658152659152660152661152662152663152664152665152666152667152668152669152670152671152672152673152674152675152676152677152678152679152680152681152682152683152684152685152686152687152688152689152690152691152692152693152694152695152696152697152698152699152700152701152702152703152704152705152706152707152708152709152710152711152712152713152714152715152716152717152718152719152720152721152722152723152724152725152726152727152728152729152730152731152732152733152734152735152736152737152738152739152740152741152742152743152744152745152746152747152748152749152750152751152752152753152754152755152756152757152758152759152760152761152762152763152764152765152766152767152768152769152770152771152772152773152774152775152776152777152778152779152780152781152782152783152784152785152786152787152788152789152790152791152792152793152794152795152796152797152798152799152800152801152802152803152804152805152806152807152808152809152810152811152812152813152814152815152816152817152818152819152820152821152822152823152824152825152826152827152828152829152830152831152832152833152834152835152836152837152838152839152840152841152842152843152844152845152846152847152848152849152850152851152852152853152854152855152856152857152858152859152860152861152862152863152864152865152866152867152868152869152870152871152872152873152874152875152876152877152878152879152880152881152882152883152884152885152886152887152888152889152890152891152892152893152894152895152896152897152898152899152900152901152902152903152904152905152906152907152908152909152910152911152912152913152914152915152916152917152918152919152920152921152922152923152924152925152926152927152928152929152930152931152932152933152934152935152936152937152938152939152940152941152942152943152944152945152946152947152948152949152950152951152952152953152954152955152956152957152958152959152960152961152962152963152964152965152966152967152968152969152970152971152972152973152974152975152976152977152978152979152980152981152982152983152984152985152986152987152988152989152990152991152992152993152994152995152996152997152998152999153000153001153002153003153004153005153006153007153008153009153010153011153012153013153014153015153016153017153018153019153020153021153022153023153024153025153026153027153028153029153030153031153032153033153034153035153036153037153038153039153040153041153042153043153044153045153046153047153048153049153050153051153052153053153054153055153056153057153058153059153060153061153062153063153064153065153066153067153068153069153070153071153072153073153074153075153076153077153078153079153080153081153082153083153084153085153086153087153088153089153090153091153092153093153094153095153096153097153098153099153100153101153102153103153104153105153106153107153108153109153110153111153112153113153114153115153116153117153118153119153120153121153122153123153124153125153126153127153128153129153130153131153132153133153134153135153136153137153138153139153140153141153142153143153144153145153146153147153148153149153150153151153152153153153154153155153156153157153158153159153160153161153162153163153164153165153166153167153168153169153170153171153172153173153174153175153176153177153178153179153180153181153182153183153184153185153186153187153188153189153190153191153192153193153194153195153196153197153198153199153200153201153202153203153204153205153206153207153208153209153210153211153212153213153214153215153216153217153218153219153220153221153222153223153224153225153226153227153228153229153230153231153232153233153234153235153236153237153238153239153240153241153242153243153244153245153246153247153248153249153250153251153252153253153254153255153256153257153258153259153260153261153262153263153264153265153266153267153268153269153270153271153272153273153274153275153276153277153278153279153280153281153282153283153284153285153286153287153288153289153290153291153292153293153294153295153296153297153298153299153300153301153302153303153304153305153306153307153308153309153310153311153312153313153314153315153316153317153318153319153320153321153322153323153324153325153326153327153328153329153330153331153332153333153334153335153336153337153338153339153340153341153342153343153344153345153346153347153348153349153350153351153352153353153354153355153356153357153358153359153360153361153362153363153364153365153366153367153368153369153370153371153372153373153374153375153376153377153378153379153380153381153382153383153384153385153386153387153388153389153390153391153392153393153394153395153396153397153398153399153400153401153402153403153404153405153406153407153408153409153410153411153412153413153414153415153416153417153418153419153420153421153422153423153424153425153426153427153428153429153430153431153432153433153434153435153436153437153438153439153440153441153442153443153444153445153446153447153448153449153450153451153452153453153454153455153456153457153458153459153460153461153462153463153464153465153466153467153468153469153470153471153472153473153474153475153476153477153478153479153480153481153482153483153484153485153486153487153488153489153490153491153492153493153494153495153496153497153498153499153500153501153502153503153504153505153506153507153508153509153510153511153512153513153514153515153516153517153518153519153520153521153522153523153524153525153526153527153528153529153530153531153532153533153534153535153536153537153538153539153540153541153542153543153544153545153546153547153548153549153550153551153552153553153554153555153556153557153558153559153560153561153562153563153564153565153566153567153568153569153570153571153572153573153574153575153576153577153578153579153580153581153582153583153584153585153586153587153588153589153590153591153592153593153594153595153596153597153598153599153600153601153602153603153604153605153606153607153608153609153610153611153612153613153614153615153616153617153618153619153620153621153622153623153624153625153626153627153628153629153630153631153632153633153634153635153636153637153638153639153640153641153642153643153644153645153646153647153648153649153650153651153652153653153654153655153656153657153658153659153660153661153662153663153664153665153666153667153668153669153670153671153672153673153674153675153676153677153678153679153680153681153682153683153684153685153686153687153688153689153690153691153692153693153694153695153696153697153698153699153700153701153702153703153704153705153706153707153708153709153710153711153712153713153714153715153716153717153718153719153720153721153722153723153724153725153726153727153728153729153730153731153732153733153734153735153736153737153738153739153740153741153742153743153744153745153746153747153748153749153750153751153752153753153754153755153756153757153758153759153760153761153762153763153764153765153766153767153768153769153770153771153772153773153774153775153776153777153778153779153780153781153782153783153784153785153786153787153788153789153790153791153792153793153794153795153796153797153798153799153800153801153802153803153804153805153806153807153808153809153810153811153812153813153814153815153816153817153818153819153820153821153822153823153824153825153826153827153828153829153830153831153832153833153834153835153836153837153838153839153840153841153842153843153844153845153846153847153848153849153850153851153852153853153854153855153856153857153858153859153860153861153862153863153864153865153866153867153868153869153870153871153872153873153874153875153876153877153878153879153880153881153882153883153884153885153886153887153888153889153890153891153892153893153894153895153896153897153898153899153900153901153902153903153904153905153906153907153908153909153910153911153912153913153914153915153916153917153918153919153920153921153922153923153924153925153926153927153928153929153930153931153932153933153934153935153936153937153938153939153940153941153942153943153944153945153946153947153948153949153950153951153952153953153954153955153956153957153958153959153960153961153962153963153964153965153966153967153968153969153970153971153972153973153974153975153976153977153978153979153980153981153982153983153984153985153986153987153988153989153990153991153992153993153994153995153996153997153998153999154000154001154002154003154004154005154006154007154008154009154010154011154012154013154014154015154016154017154018154019154020154021154022154023154024154025154026154027154028154029154030154031154032154033154034154035154036154037154038154039154040154041154042154043154044154045154046154047154048154049154050154051154052154053154054154055154056154057154058154059154060154061154062154063154064154065154066154067154068154069154070154071154072154073154074154075154076154077154078154079154080154081154082154083154084154085154086154087154088154089154090154091154092154093154094154095154096154097154098154099154100154101154102154103154104154105154106154107154108154109154110154111154112154113154114154115154116154117154118154119154120154121154122154123154124154125154126154127154128154129154130154131154132154133154134154135154136154137154138154139154140154141154142154143154144154145154146154147154148154149154150154151154152154153154154154155154156154157154158154159154160154161154162154163154164154165154166154167154168154169154170154171154172154173154174154175154176154177154178154179154180154181154182154183154184154185154186154187154188154189154190154191154192154193154194154195154196154197154198154199154200154201154202154203154204154205154206154207154208154209154210154211154212154213154214154215154216154217154218154219154220154221154222154223154224154225154226154227154228154229154230154231154232154233154234154235154236154237154238154239154240154241154242154243154244154245154246154247154248154249154250154251154252154253154254154255154256154257154258154259154260154261154262154263154264154265154266154267154268154269154270154271154272154273154274154275154276154277154278154279154280154281154282154283154284154285154286154287154288154289154290154291154292154293154294154295154296154297154298154299154300154301154302154303154304154305154306154307154308154309154310154311154312154313154314154315154316154317154318154319154320154321154322154323154324154325154326154327154328154329154330154331154332154333154334154335154336154337154338154339154340154341154342154343154344154345154346154347154348154349154350154351154352154353154354154355154356154357154358154359154360154361154362154363154364154365154366154367154368154369154370154371154372154373154374154375154376154377154378154379154380154381154382154383154384154385154386154387154388154389154390154391154392154393154394154395154396154397154398154399154400154401154402154403154404154405154406154407154408154409154410154411154412154413154414154415154416154417154418154419154420154421154422154423154424154425154426154427154428154429154430154431154432154433154434154435154436154437154438154439154440154441154442154443154444154445154446154447154448154449154450154451154452154453154454154455154456154457154458154459154460154461154462154463154464154465154466154467154468154469154470154471154472154473154474154475154476154477154478154479154480154481154482154483154484154485154486154487154488154489154490154491154492154493154494154495154496154497154498154499154500154501154502154503154504154505154506154507154508154509154510154511154512154513154514154515154516154517154518154519154520154521154522154523154524154525154526154527154528154529154530154531154532154533154534154535154536154537154538154539154540154541154542154543154544154545154546154547154548154549154550154551154552154553154554154555154556154557154558154559154560154561154562154563154564154565154566154567154568154569154570154571154572154573154574154575154576154577154578154579154580154581154582154583154584154585154586154587154588154589154590154591154592154593154594154595154596154597154598154599154600154601154602154603154604154605154606154607154608154609154610154611154612154613154614154615154616154617154618154619154620154621154622154623154624154625154626154627154628154629154630154631154632154633154634154635154636154637154638154639154640154641154642154643154644154645154646154647154648154649154650154651154652154653154654154655154656154657154658154659154660154661154662154663154664154665154666154667154668154669154670154671154672154673154674154675154676154677154678154679154680154681154682154683154684154685154686154687154688154689154690154691154692154693154694154695154696154697154698154699154700154701154702154703154704154705154706154707154708154709154710154711154712154713154714154715154716154717154718154719154720154721154722154723154724154725154726154727154728154729154730154731154732154733154734154735154736154737154738154739154740154741154742154743154744154745154746154747154748154749154750154751154752154753154754154755154756154757154758154759154760154761154762154763154764154765154766154767154768154769154770154771154772154773154774154775154776154777154778154779154780154781154782154783154784154785154786154787154788154789154790154791154792154793154794154795154796154797154798154799154800154801154802154803154804154805154806154807154808154809154810154811154812154813154814154815154816154817154818154819154820154821154822154823154824154825154826154827154828154829154830154831154832154833154834154835154836154837154838154839154840154841154842154843154844154845154846154847154848154849154850154851154852154853154854154855154856154857154858154859154860154861154862154863154864154865154866154867154868154869154870154871154872154873154874154875154876154877154878154879154880154881154882154883154884154885154886154887154888154889154890154891154892154893154894154895154896154897154898154899154900154901154902154903154904154905154906154907154908154909154910154911154912154913154914154915154916154917154918154919154920154921154922154923154924154925154926154927154928154929154930154931154932154933154934154935154936154937154938154939154940154941154942154943154944154945154946154947154948154949154950154951154952154953154954154955154956154957154958154959154960154961154962154963154964154965154966154967154968154969154970154971154972154973154974154975154976154977154978154979154980154981154982154983154984154985154986154987154988154989154990154991154992154993154994154995154996154997154998154999155000155001155002155003155004155005155006155007155008155009155010155011155012155013155014155015155016155017155018155019155020155021155022155023155024155025155026155027155028155029155030155031155032155033155034155035155036155037155038155039155040155041155042155043155044155045155046155047155048155049155050155051155052155053155054155055155056155057155058155059155060155061155062155063155064155065155066155067155068155069155070155071155072155073155074155075155076155077155078155079155080155081155082155083155084155085155086155087155088155089155090155091155092155093155094155095155096155097155098155099155100155101155102155103155104155105155106155107155108155109155110155111155112155113155114155115155116155117155118155119155120155121155122155123155124155125155126155127155128155129155130155131155132155133155134155135155136155137155138155139155140155141155142155143155144155145155146155147155148155149155150155151155152155153155154155155155156155157155158155159155160155161155162155163155164155165155166155167155168155169155170155171155172155173155174155175155176155177155178155179155180155181155182155183155184155185155186155187155188155189155190155191155192155193155194155195155196155197155198155199155200155201155202155203155204155205155206155207155208155209155210155211155212155213155214155215155216155217155218155219155220155221155222155223155224155225155226155227155228155229155230155231155232155233155234155235155236155237155238155239155240155241155242155243155244155245155246155247155248155249155250155251155252155253155254155255155256155257155258155259155260155261155262155263155264155265155266155267155268155269155270155271155272155273155274155275155276155277155278155279155280155281155282155283155284155285155286155287155288155289155290155291155292155293155294155295155296155297155298155299155300155301155302155303155304155305155306155307155308155309155310155311155312155313155314155315155316155317155318155319155320155321155322155323155324155325155326155327155328155329155330155331155332155333155334155335155336155337155338155339155340155341155342155343155344155345155346155347155348155349155350155351155352155353155354155355155356155357155358155359155360155361155362155363155364155365155366155367155368155369155370155371155372155373155374155375155376155377155378155379155380155381155382155383155384155385155386155387155388155389155390155391155392155393155394155395155396155397155398155399155400155401155402155403155404155405155406155407155408155409155410155411155412155413155414155415155416155417155418155419155420155421155422155423155424155425155426155427155428155429155430155431155432155433155434155435155436155437155438155439155440155441155442155443155444155445155446155447155448155449155450155451155452155453155454155455155456155457155458155459155460155461155462155463155464155465155466155467155468155469155470155471155472155473155474155475155476155477155478155479155480155481155482155483155484155485155486155487155488155489155490155491155492155493155494155495155496155497155498155499155500155501155502155503155504155505155506155507155508155509155510155511155512155513155514155515155516155517155518155519155520155521155522155523155524155525155526155527155528155529155530155531155532155533155534155535155536155537155538155539155540155541155542155543155544155545155546155547155548155549155550155551155552155553155554155555155556155557155558155559155560155561155562155563155564155565155566155567155568155569155570155571155572155573155574155575155576155577155578155579155580155581155582155583155584155585155586155587155588155589155590155591155592155593155594155595155596155597155598155599155600155601155602155603155604155605155606155607155608155609155610155611155612155613155614155615155616155617155618155619155620155621155622155623155624155625155626155627155628155629155630155631155632155633155634155635155636155637155638155639155640155641155642155643155644155645155646155647155648155649155650155651155652155653155654155655155656155657155658155659155660155661155662155663155664155665155666155667155668155669155670155671155672155673155674155675155676155677155678155679155680155681155682155683155684155685155686155687155688155689155690155691155692155693155694155695155696155697155698155699155700155701155702155703155704155705155706155707155708155709155710155711155712155713155714155715155716155717155718155719155720155721155722155723155724155725155726155727155728155729155730155731155732155733155734155735155736155737155738155739155740155741155742155743155744155745155746155747155748155749155750155751155752155753155754155755155756155757155758155759155760155761155762155763155764155765155766155767155768155769155770155771155772155773155774155775155776155777155778155779155780155781155782155783155784155785155786155787155788155789155790155791155792155793155794155795155796155797155798155799155800155801155802155803155804155805155806155807155808155809155810155811155812155813155814155815
  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. protected _postMultiplyPivotMatrix: boolean;
  15088. protected _isWorldMatrixFrozen: boolean;
  15089. /** @hidden */
  15090. _indexInSceneTransformNodesArray: number;
  15091. /**
  15092. * An event triggered after the world matrix is updated
  15093. */
  15094. onAfterWorldMatrixUpdateObservable: Observable<TransformNode>;
  15095. constructor(name: string, scene?: Nullable<Scene>, isPure?: boolean);
  15096. /**
  15097. * Gets a string identifying the name of the class
  15098. * @returns "TransformNode" string
  15099. */
  15100. getClassName(): string;
  15101. /**
  15102. * Gets or set the node position (default is (0.0, 0.0, 0.0))
  15103. */
  15104. get position(): Vector3;
  15105. set position(newPosition: Vector3);
  15106. /**
  15107. * 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)).
  15108. * If rotation quaternion is set, this Vector3 will be ignored and copy from the quaternion
  15109. */
  15110. get rotation(): Vector3;
  15111. set rotation(newRotation: Vector3);
  15112. /**
  15113. * 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)).
  15114. */
  15115. get scaling(): Vector3;
  15116. set scaling(newScaling: Vector3);
  15117. /**
  15118. * 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).
  15119. * If set, only the rotationQuaternion is then used to compute the node rotation (ie. node.rotation will be ignored)
  15120. */
  15121. get rotationQuaternion(): Nullable<Quaternion>;
  15122. set rotationQuaternion(quaternion: Nullable<Quaternion>);
  15123. /**
  15124. * The forward direction of that transform in world space.
  15125. */
  15126. get forward(): Vector3;
  15127. /**
  15128. * The up direction of that transform in world space.
  15129. */
  15130. get up(): Vector3;
  15131. /**
  15132. * The right direction of that transform in world space.
  15133. */
  15134. get right(): Vector3;
  15135. /**
  15136. * Copies the parameter passed Matrix into the mesh Pose matrix.
  15137. * @param matrix the matrix to copy the pose from
  15138. * @returns this TransformNode.
  15139. */
  15140. updatePoseMatrix(matrix: Matrix): TransformNode;
  15141. /**
  15142. * Returns the mesh Pose matrix.
  15143. * @returns the pose matrix
  15144. */
  15145. getPoseMatrix(): Matrix;
  15146. /** @hidden */
  15147. _isSynchronized(): boolean;
  15148. /** @hidden */
  15149. _initCache(): void;
  15150. /**
  15151. * Flag the transform node as dirty (Forcing it to update everything)
  15152. * @param property if set to "rotation" the objects rotationQuaternion will be set to null
  15153. * @returns this transform node
  15154. */
  15155. markAsDirty(property: string): TransformNode;
  15156. /**
  15157. * Returns the current mesh absolute position.
  15158. * Returns a Vector3.
  15159. */
  15160. get absolutePosition(): Vector3;
  15161. /**
  15162. * Returns the current mesh absolute scaling.
  15163. * Returns a Vector3.
  15164. */
  15165. get absoluteScaling(): Vector3;
  15166. /**
  15167. * Returns the current mesh absolute rotation.
  15168. * Returns a Quaternion.
  15169. */
  15170. get absoluteRotationQuaternion(): Quaternion;
  15171. /**
  15172. * Sets a new matrix to apply before all other transformation
  15173. * @param matrix defines the transform matrix
  15174. * @returns the current TransformNode
  15175. */
  15176. setPreTransformMatrix(matrix: Matrix): TransformNode;
  15177. /**
  15178. * Sets a new pivot matrix to the current node
  15179. * @param matrix defines the new pivot matrix to use
  15180. * @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
  15181. * @returns the current TransformNode
  15182. */
  15183. setPivotMatrix(matrix: DeepImmutable<Matrix>, postMultiplyPivotMatrix?: boolean): TransformNode;
  15184. /**
  15185. * Returns the mesh pivot matrix.
  15186. * Default : Identity.
  15187. * @returns the matrix
  15188. */
  15189. getPivotMatrix(): Matrix;
  15190. /**
  15191. * Instantiate (when possible) or clone that node with its hierarchy
  15192. * @param newParent defines the new parent to use for the instance (or clone)
  15193. * @param options defines options to configure how copy is done
  15194. * @param onNewNodeCreated defines an option callback to call when a clone or an instance is created
  15195. * @returns an instance (or a clone) of the current node with its hiearchy
  15196. */
  15197. instantiateHierarchy(newParent?: Nullable<TransformNode>, options?: {
  15198. doNotInstantiate: boolean;
  15199. }, onNewNodeCreated?: (source: TransformNode, clone: TransformNode) => void): Nullable<TransformNode>;
  15200. /**
  15201. * Prevents the World matrix to be computed any longer
  15202. * @param newWorldMatrix defines an optional matrix to use as world matrix
  15203. * @returns the TransformNode.
  15204. */
  15205. freezeWorldMatrix(newWorldMatrix?: Nullable<Matrix>): TransformNode;
  15206. /**
  15207. * Allows back the World matrix computation.
  15208. * @returns the TransformNode.
  15209. */
  15210. unfreezeWorldMatrix(): this;
  15211. /**
  15212. * True if the World matrix has been frozen.
  15213. */
  15214. get isWorldMatrixFrozen(): boolean;
  15215. /**
  15216. * Retuns the mesh absolute position in the World.
  15217. * @returns a Vector3.
  15218. */
  15219. getAbsolutePosition(): Vector3;
  15220. /**
  15221. * Sets the mesh absolute position in the World from a Vector3 or an Array(3).
  15222. * @param absolutePosition the absolute position to set
  15223. * @returns the TransformNode.
  15224. */
  15225. setAbsolutePosition(absolutePosition: Vector3): TransformNode;
  15226. /**
  15227. * Sets the mesh position in its local space.
  15228. * @param vector3 the position to set in localspace
  15229. * @returns the TransformNode.
  15230. */
  15231. setPositionWithLocalVector(vector3: Vector3): TransformNode;
  15232. /**
  15233. * Returns the mesh position in the local space from the current World matrix values.
  15234. * @returns a new Vector3.
  15235. */
  15236. getPositionExpressedInLocalSpace(): Vector3;
  15237. /**
  15238. * Translates the mesh along the passed Vector3 in its local space.
  15239. * @param vector3 the distance to translate in localspace
  15240. * @returns the TransformNode.
  15241. */
  15242. locallyTranslate(vector3: Vector3): TransformNode;
  15243. private static _lookAtVectorCache;
  15244. /**
  15245. * Orients a mesh towards a target point. Mesh must be drawn facing user.
  15246. * @param targetPoint the position (must be in same space as current mesh) to look at
  15247. * @param yawCor optional yaw (y-axis) correction in radians
  15248. * @param pitchCor optional pitch (x-axis) correction in radians
  15249. * @param rollCor optional roll (z-axis) correction in radians
  15250. * @param space the choosen space of the target
  15251. * @returns the TransformNode.
  15252. */
  15253. lookAt(targetPoint: Vector3, yawCor?: number, pitchCor?: number, rollCor?: number, space?: Space): TransformNode;
  15254. /**
  15255. * Returns a new Vector3 that is the localAxis, expressed in the mesh local space, rotated like the mesh.
  15256. * This Vector3 is expressed in the World space.
  15257. * @param localAxis axis to rotate
  15258. * @returns a new Vector3 that is the localAxis, expressed in the mesh local space, rotated like the mesh.
  15259. */
  15260. getDirection(localAxis: Vector3): Vector3;
  15261. /**
  15262. * Sets the Vector3 "result" as the rotated Vector3 "localAxis" in the same rotation than the mesh.
  15263. * localAxis is expressed in the mesh local space.
  15264. * result is computed in the Wordl space from the mesh World matrix.
  15265. * @param localAxis axis to rotate
  15266. * @param result the resulting transformnode
  15267. * @returns this TransformNode.
  15268. */
  15269. getDirectionToRef(localAxis: Vector3, result: Vector3): TransformNode;
  15270. /**
  15271. * Sets this transform node rotation to the given local axis.
  15272. * @param localAxis the axis in local space
  15273. * @param yawCor optional yaw (y-axis) correction in radians
  15274. * @param pitchCor optional pitch (x-axis) correction in radians
  15275. * @param rollCor optional roll (z-axis) correction in radians
  15276. * @returns this TransformNode
  15277. */
  15278. setDirection(localAxis: Vector3, yawCor?: number, pitchCor?: number, rollCor?: number): TransformNode;
  15279. /**
  15280. * Sets a new pivot point to the current node
  15281. * @param point defines the new pivot point to use
  15282. * @param space defines if the point is in world or local space (local by default)
  15283. * @returns the current TransformNode
  15284. */
  15285. setPivotPoint(point: Vector3, space?: Space): TransformNode;
  15286. /**
  15287. * Returns a new Vector3 set with the mesh pivot point coordinates in the local space.
  15288. * @returns the pivot point
  15289. */
  15290. getPivotPoint(): Vector3;
  15291. /**
  15292. * Sets the passed Vector3 "result" with the coordinates of the mesh pivot point in the local space.
  15293. * @param result the vector3 to store the result
  15294. * @returns this TransformNode.
  15295. */
  15296. getPivotPointToRef(result: Vector3): TransformNode;
  15297. /**
  15298. * Returns a new Vector3 set with the mesh pivot point World coordinates.
  15299. * @returns a new Vector3 set with the mesh pivot point World coordinates.
  15300. */
  15301. getAbsolutePivotPoint(): Vector3;
  15302. /**
  15303. * Sets the Vector3 "result" coordinates with the mesh pivot point World coordinates.
  15304. * @param result vector3 to store the result
  15305. * @returns this TransformNode.
  15306. */
  15307. getAbsolutePivotPointToRef(result: Vector3): TransformNode;
  15308. /**
  15309. * Defines the passed node as the parent of the current node.
  15310. * The node will remain exactly where it is and its position / rotation will be updated accordingly
  15311. * @see https://doc.babylonjs.com/how_to/parenting
  15312. * @param node the node ot set as the parent
  15313. * @returns this TransformNode.
  15314. */
  15315. setParent(node: Nullable<Node>): TransformNode;
  15316. private _nonUniformScaling;
  15317. /**
  15318. * True if the scaling property of this object is non uniform eg. (1,2,1)
  15319. */
  15320. get nonUniformScaling(): boolean;
  15321. /** @hidden */
  15322. _updateNonUniformScalingState(value: boolean): boolean;
  15323. /**
  15324. * Attach the current TransformNode to another TransformNode associated with a bone
  15325. * @param bone Bone affecting the TransformNode
  15326. * @param affectedTransformNode TransformNode associated with the bone
  15327. * @returns this object
  15328. */
  15329. attachToBone(bone: Bone, affectedTransformNode: TransformNode): TransformNode;
  15330. /**
  15331. * Detach the transform node if its associated with a bone
  15332. * @returns this object
  15333. */
  15334. detachFromBone(): TransformNode;
  15335. private static _rotationAxisCache;
  15336. /**
  15337. * Rotates the mesh around the axis vector for the passed angle (amount) expressed in radians, in the given space.
  15338. * space (default LOCAL) can be either Space.LOCAL, either Space.WORLD.
  15339. * Note that the property `rotationQuaternion` is then automatically updated and the property `rotation` is set to (0,0,0) and no longer used.
  15340. * The passed axis is also normalized.
  15341. * @param axis the axis to rotate around
  15342. * @param amount the amount to rotate in radians
  15343. * @param space Space to rotate in (Default: local)
  15344. * @returns the TransformNode.
  15345. */
  15346. rotate(axis: Vector3, amount: number, space?: Space): TransformNode;
  15347. /**
  15348. * Rotates the mesh around the axis vector for the passed angle (amount) expressed in radians, in world space.
  15349. * Note that the property `rotationQuaternion` is then automatically updated and the property `rotation` is set to (0,0,0) and no longer used.
  15350. * The passed axis is also normalized. .
  15351. * Method is based on http://www.euclideanspace.com/maths/geometry/affine/aroundPoint/index.htm
  15352. * @param point the point to rotate around
  15353. * @param axis the axis to rotate around
  15354. * @param amount the amount to rotate in radians
  15355. * @returns the TransformNode
  15356. */
  15357. rotateAround(point: Vector3, axis: Vector3, amount: number): TransformNode;
  15358. /**
  15359. * Translates the mesh along the axis vector for the passed distance in the given space.
  15360. * space (default LOCAL) can be either Space.LOCAL, either Space.WORLD.
  15361. * @param axis the axis to translate in
  15362. * @param distance the distance to translate
  15363. * @param space Space to rotate in (Default: local)
  15364. * @returns the TransformNode.
  15365. */
  15366. translate(axis: Vector3, distance: number, space?: Space): TransformNode;
  15367. /**
  15368. * Adds a rotation step to the mesh current rotation.
  15369. * x, y, z are Euler angles expressed in radians.
  15370. * This methods updates the current mesh rotation, either mesh.rotation, either mesh.rotationQuaternion if it's set.
  15371. * This means this rotation is made in the mesh local space only.
  15372. * It's useful to set a custom rotation order different from the BJS standard one YXZ.
  15373. * Example : this rotates the mesh first around its local X axis, then around its local Z axis, finally around its local Y axis.
  15374. * ```javascript
  15375. * mesh.addRotation(x1, 0, 0).addRotation(0, 0, z2).addRotation(0, 0, y3);
  15376. * ```
  15377. * Note that `addRotation()` accumulates the passed rotation values to the current ones and computes the .rotation or .rotationQuaternion updated values.
  15378. * 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.
  15379. * @param x Rotation to add
  15380. * @param y Rotation to add
  15381. * @param z Rotation to add
  15382. * @returns the TransformNode.
  15383. */
  15384. addRotation(x: number, y: number, z: number): TransformNode;
  15385. /**
  15386. * @hidden
  15387. */
  15388. protected _getEffectiveParent(): Nullable<Node>;
  15389. /**
  15390. * Computes the world matrix of the node
  15391. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  15392. * @returns the world matrix
  15393. */
  15394. computeWorldMatrix(force?: boolean): Matrix;
  15395. /**
  15396. * Resets this nodeTransform's local matrix to Matrix.Identity().
  15397. * @param independentOfChildren indicates if all child nodeTransform's world-space transform should be preserved.
  15398. */
  15399. resetLocalMatrix(independentOfChildren?: boolean): void;
  15400. protected _afterComputeWorldMatrix(): void;
  15401. /**
  15402. * If you'd like to be called back after the mesh position, rotation or scaling has been updated.
  15403. * @param func callback function to add
  15404. *
  15405. * @returns the TransformNode.
  15406. */
  15407. registerAfterWorldMatrixUpdate(func: (mesh: TransformNode) => void): TransformNode;
  15408. /**
  15409. * Removes a registered callback function.
  15410. * @param func callback function to remove
  15411. * @returns the TransformNode.
  15412. */
  15413. unregisterAfterWorldMatrixUpdate(func: (mesh: TransformNode) => void): TransformNode;
  15414. /**
  15415. * Gets the position of the current mesh in camera space
  15416. * @param camera defines the camera to use
  15417. * @returns a position
  15418. */
  15419. getPositionInCameraSpace(camera?: Nullable<Camera>): Vector3;
  15420. /**
  15421. * Returns the distance from the mesh to the active camera
  15422. * @param camera defines the camera to use
  15423. * @returns the distance
  15424. */
  15425. getDistanceToCamera(camera?: Nullable<Camera>): number;
  15426. /**
  15427. * Clone the current transform node
  15428. * @param name Name of the new clone
  15429. * @param newParent New parent for the clone
  15430. * @param doNotCloneChildren Do not clone children hierarchy
  15431. * @returns the new transform node
  15432. */
  15433. clone(name: string, newParent: Nullable<Node>, doNotCloneChildren?: boolean): Nullable<TransformNode>;
  15434. /**
  15435. * Serializes the objects information.
  15436. * @param currentSerializationObject defines the object to serialize in
  15437. * @returns the serialized object
  15438. */
  15439. serialize(currentSerializationObject?: any): any;
  15440. /**
  15441. * Returns a new TransformNode object parsed from the source provided.
  15442. * @param parsedTransformNode is the source.
  15443. * @param scene the scne the object belongs to
  15444. * @param rootUrl is a string, it's the root URL to prefix the `delayLoadingFile` property with
  15445. * @returns a new TransformNode object parsed from the source provided.
  15446. */
  15447. static Parse(parsedTransformNode: any, scene: Scene, rootUrl: string): TransformNode;
  15448. /**
  15449. * Get all child-transformNodes of this node
  15450. * @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
  15451. * @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
  15452. * @returns an array of TransformNode
  15453. */
  15454. getChildTransformNodes(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): TransformNode[];
  15455. /**
  15456. * Releases resources associated with this transform node.
  15457. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  15458. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  15459. */
  15460. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  15461. /**
  15462. * Uniformly scales the mesh to fit inside of a unit cube (1 X 1 X 1 units)
  15463. * @param includeDescendants Use the hierarchy's bounding box instead of the mesh's bounding box. Default is false
  15464. * @param ignoreRotation ignore rotation when computing the scale (ie. object will be axis aligned). Default is false
  15465. * @param predicate predicate that is passed in to getHierarchyBoundingVectors when selecting which object should be included when scaling
  15466. * @returns the current mesh
  15467. */
  15468. normalizeToUnitCube(includeDescendants?: boolean, ignoreRotation?: boolean, predicate?: Nullable<(node: AbstractMesh) => boolean>): TransformNode;
  15469. private _syncAbsoluteScalingAndRotation;
  15470. }
  15471. }
  15472. declare module "babylonjs/Animations/animationPropertiesOverride" {
  15473. /**
  15474. * Class used to override all child animations of a given target
  15475. */
  15476. export class AnimationPropertiesOverride {
  15477. /**
  15478. * Gets or sets a value indicating if animation blending must be used
  15479. */
  15480. enableBlending: boolean;
  15481. /**
  15482. * Gets or sets the blending speed to use when enableBlending is true
  15483. */
  15484. blendingSpeed: number;
  15485. /**
  15486. * Gets or sets the default loop mode to use
  15487. */
  15488. loopMode: number;
  15489. }
  15490. }
  15491. declare module "babylonjs/Bones/bone" {
  15492. import { Skeleton } from "babylonjs/Bones/skeleton";
  15493. import { Vector3, Quaternion, Matrix } from "babylonjs/Maths/math.vector";
  15494. import { Nullable } from "babylonjs/types";
  15495. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  15496. import { TransformNode } from "babylonjs/Meshes/transformNode";
  15497. import { Node } from "babylonjs/node";
  15498. import { Space } from "babylonjs/Maths/math.axis";
  15499. import { AnimationPropertiesOverride } from "babylonjs/Animations/animationPropertiesOverride";
  15500. /**
  15501. * Class used to store bone information
  15502. * @see https://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  15503. */
  15504. export class Bone extends Node {
  15505. /**
  15506. * defines the bone name
  15507. */
  15508. name: string;
  15509. private static _tmpVecs;
  15510. private static _tmpQuat;
  15511. private static _tmpMats;
  15512. /**
  15513. * Gets the list of child bones
  15514. */
  15515. children: Bone[];
  15516. /** Gets the animations associated with this bone */
  15517. animations: import("babylonjs/Animations/animation").Animation[];
  15518. /**
  15519. * Gets or sets bone length
  15520. */
  15521. length: number;
  15522. /**
  15523. * @hidden Internal only
  15524. * Set this value to map this bone to a different index in the transform matrices
  15525. * Set this value to -1 to exclude the bone from the transform matrices
  15526. */
  15527. _index: Nullable<number>;
  15528. private _skeleton;
  15529. private _localMatrix;
  15530. private _restPose;
  15531. private _bindPose;
  15532. private _baseMatrix;
  15533. private _absoluteTransform;
  15534. private _invertedAbsoluteTransform;
  15535. private _parent;
  15536. private _scalingDeterminant;
  15537. private _worldTransform;
  15538. private _localScaling;
  15539. private _localRotation;
  15540. private _localPosition;
  15541. private _needToDecompose;
  15542. private _needToCompose;
  15543. /** @hidden */
  15544. _linkedTransformNode: Nullable<TransformNode>;
  15545. /** @hidden */
  15546. _waitingTransformNodeId: Nullable<string>;
  15547. /** @hidden */
  15548. get _matrix(): Matrix;
  15549. /** @hidden */
  15550. set _matrix(value: Matrix);
  15551. /**
  15552. * Create a new bone
  15553. * @param name defines the bone name
  15554. * @param skeleton defines the parent skeleton
  15555. * @param parentBone defines the parent (can be null if the bone is the root)
  15556. * @param localMatrix defines the local matrix
  15557. * @param restPose defines the rest pose matrix
  15558. * @param baseMatrix defines the base matrix
  15559. * @param index defines index of the bone in the hiearchy
  15560. */
  15561. constructor(
  15562. /**
  15563. * defines the bone name
  15564. */
  15565. name: string, skeleton: Skeleton, parentBone?: Nullable<Bone>, localMatrix?: Nullable<Matrix>, restPose?: Nullable<Matrix>, baseMatrix?: Nullable<Matrix>, index?: Nullable<number>);
  15566. /**
  15567. * Gets the current object class name.
  15568. * @return the class name
  15569. */
  15570. getClassName(): string;
  15571. /**
  15572. * Gets the parent skeleton
  15573. * @returns a skeleton
  15574. */
  15575. getSkeleton(): Skeleton;
  15576. /**
  15577. * Gets parent bone
  15578. * @returns a bone or null if the bone is the root of the bone hierarchy
  15579. */
  15580. getParent(): Nullable<Bone>;
  15581. /**
  15582. * Returns an array containing the root bones
  15583. * @returns an array containing the root bones
  15584. */
  15585. getChildren(): Array<Bone>;
  15586. /**
  15587. * Gets the node index in matrix array generated for rendering
  15588. * @returns the node index
  15589. */
  15590. getIndex(): number;
  15591. /**
  15592. * Sets the parent bone
  15593. * @param parent defines the parent (can be null if the bone is the root)
  15594. * @param updateDifferenceMatrix defines if the difference matrix must be updated
  15595. */
  15596. setParent(parent: Nullable<Bone>, updateDifferenceMatrix?: boolean): void;
  15597. /**
  15598. * Gets the local matrix
  15599. * @returns a matrix
  15600. */
  15601. getLocalMatrix(): Matrix;
  15602. /**
  15603. * Gets the base matrix (initial matrix which remains unchanged)
  15604. * @returns a matrix
  15605. */
  15606. getBaseMatrix(): Matrix;
  15607. /**
  15608. * Gets the rest pose matrix
  15609. * @returns a matrix
  15610. */
  15611. getRestPose(): Matrix;
  15612. /**
  15613. * Sets the rest pose matrix
  15614. * @param matrix the local-space rest pose to set for this bone
  15615. */
  15616. setRestPose(matrix: Matrix): void;
  15617. /**
  15618. * Gets the bind pose matrix
  15619. * @returns the bind pose matrix
  15620. */
  15621. getBindPose(): Matrix;
  15622. /**
  15623. * Sets the bind pose matrix
  15624. * @param matrix the local-space bind pose to set for this bone
  15625. */
  15626. setBindPose(matrix: Matrix): void;
  15627. /**
  15628. * Gets a matrix used to store world matrix (ie. the matrix sent to shaders)
  15629. */
  15630. getWorldMatrix(): Matrix;
  15631. /**
  15632. * Sets the local matrix to rest pose matrix
  15633. */
  15634. returnToRest(): void;
  15635. /**
  15636. * Gets the inverse of the absolute transform matrix.
  15637. * This matrix will be multiplied by local matrix to get the difference matrix (ie. the difference between original state and current state)
  15638. * @returns a matrix
  15639. */
  15640. getInvertedAbsoluteTransform(): Matrix;
  15641. /**
  15642. * Gets the absolute transform matrix (ie base matrix * parent world matrix)
  15643. * @returns a matrix
  15644. */
  15645. getAbsoluteTransform(): Matrix;
  15646. /**
  15647. * Links with the given transform node.
  15648. * The local matrix of this bone is copied from the transform node every frame.
  15649. * @param transformNode defines the transform node to link to
  15650. */
  15651. linkTransformNode(transformNode: Nullable<TransformNode>): void;
  15652. /**
  15653. * Gets the node used to drive the bone's transformation
  15654. * @returns a transform node or null
  15655. */
  15656. getTransformNode(): Nullable<TransformNode>;
  15657. /** Gets or sets current position (in local space) */
  15658. get position(): Vector3;
  15659. set position(newPosition: Vector3);
  15660. /** Gets or sets current rotation (in local space) */
  15661. get rotation(): Vector3;
  15662. set rotation(newRotation: Vector3);
  15663. /** Gets or sets current rotation quaternion (in local space) */
  15664. get rotationQuaternion(): Quaternion;
  15665. set rotationQuaternion(newRotation: Quaternion);
  15666. /** Gets or sets current scaling (in local space) */
  15667. get scaling(): Vector3;
  15668. set scaling(newScaling: Vector3);
  15669. /**
  15670. * Gets the animation properties override
  15671. */
  15672. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  15673. private _decompose;
  15674. private _compose;
  15675. /**
  15676. * Update the base and local matrices
  15677. * @param matrix defines the new base or local matrix
  15678. * @param updateDifferenceMatrix defines if the difference matrix must be updated
  15679. * @param updateLocalMatrix defines if the local matrix should be updated
  15680. */
  15681. updateMatrix(matrix: Matrix, updateDifferenceMatrix?: boolean, updateLocalMatrix?: boolean): void;
  15682. /** @hidden */
  15683. _updateDifferenceMatrix(rootMatrix?: Matrix, updateChildren?: boolean): void;
  15684. /**
  15685. * Flag the bone as dirty (Forcing it to update everything)
  15686. */
  15687. markAsDirty(): void;
  15688. /** @hidden */
  15689. _markAsDirtyAndCompose(): void;
  15690. private _markAsDirtyAndDecompose;
  15691. /**
  15692. * Translate the bone in local or world space
  15693. * @param vec The amount to translate the bone
  15694. * @param space The space that the translation is in
  15695. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15696. */
  15697. translate(vec: Vector3, space?: Space, mesh?: AbstractMesh): void;
  15698. /**
  15699. * Set the postion of the bone in local or world space
  15700. * @param position The position to set the bone
  15701. * @param space The space that the position is in
  15702. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15703. */
  15704. setPosition(position: Vector3, space?: Space, mesh?: AbstractMesh): void;
  15705. /**
  15706. * Set the absolute position of the bone (world space)
  15707. * @param position The position to set the bone
  15708. * @param mesh The mesh that this bone is attached to
  15709. */
  15710. setAbsolutePosition(position: Vector3, mesh?: AbstractMesh): void;
  15711. /**
  15712. * Scale the bone on the x, y and z axes (in local space)
  15713. * @param x The amount to scale the bone on the x axis
  15714. * @param y The amount to scale the bone on the y axis
  15715. * @param z The amount to scale the bone on the z axis
  15716. * @param scaleChildren sets this to true if children of the bone should be scaled as well (false by default)
  15717. */
  15718. scale(x: number, y: number, z: number, scaleChildren?: boolean): void;
  15719. /**
  15720. * Set the bone scaling in local space
  15721. * @param scale defines the scaling vector
  15722. */
  15723. setScale(scale: Vector3): void;
  15724. /**
  15725. * Gets the current scaling in local space
  15726. * @returns the current scaling vector
  15727. */
  15728. getScale(): Vector3;
  15729. /**
  15730. * Gets the current scaling in local space and stores it in a target vector
  15731. * @param result defines the target vector
  15732. */
  15733. getScaleToRef(result: Vector3): void;
  15734. /**
  15735. * Set the yaw, pitch, and roll of the bone in local or world space
  15736. * @param yaw The rotation of the bone on the y axis
  15737. * @param pitch The rotation of the bone on the x axis
  15738. * @param roll The rotation of the bone on the z axis
  15739. * @param space The space that the axes of rotation are in
  15740. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15741. */
  15742. setYawPitchRoll(yaw: number, pitch: number, roll: number, space?: Space, mesh?: AbstractMesh): void;
  15743. /**
  15744. * Add a rotation to the bone on an axis in local or world space
  15745. * @param axis The axis to rotate the bone on
  15746. * @param amount The amount to rotate the bone
  15747. * @param space The space that the axis is in
  15748. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15749. */
  15750. rotate(axis: Vector3, amount: number, space?: Space, mesh?: AbstractMesh): void;
  15751. /**
  15752. * Set the rotation of the bone to a particular axis angle in local or world space
  15753. * @param axis The axis to rotate the bone on
  15754. * @param angle The angle that the bone should be rotated to
  15755. * @param space The space that the axis is in
  15756. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15757. */
  15758. setAxisAngle(axis: Vector3, angle: number, space?: Space, mesh?: AbstractMesh): void;
  15759. /**
  15760. * Set the euler rotation of the bone in local of world space
  15761. * @param rotation The euler rotation that the bone should be set to
  15762. * @param space The space that the rotation is in
  15763. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15764. */
  15765. setRotation(rotation: Vector3, space?: Space, mesh?: AbstractMesh): void;
  15766. /**
  15767. * Set the quaternion rotation of the bone in local of world space
  15768. * @param quat The quaternion rotation that the bone should be set to
  15769. * @param space The space that the rotation is in
  15770. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15771. */
  15772. setRotationQuaternion(quat: Quaternion, space?: Space, mesh?: AbstractMesh): void;
  15773. /**
  15774. * Set the rotation matrix of the bone in local of world space
  15775. * @param rotMat The rotation matrix that the bone should be set to
  15776. * @param space The space that the rotation is in
  15777. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15778. */
  15779. setRotationMatrix(rotMat: Matrix, space?: Space, mesh?: AbstractMesh): void;
  15780. private _rotateWithMatrix;
  15781. private _getNegativeRotationToRef;
  15782. /**
  15783. * Get the position of the bone in local or world space
  15784. * @param space The space that the returned position is in
  15785. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15786. * @returns The position of the bone
  15787. */
  15788. getPosition(space?: Space, mesh?: Nullable<AbstractMesh>): Vector3;
  15789. /**
  15790. * Copy the position of the bone to a vector3 in local or world space
  15791. * @param space The space that the returned position is in
  15792. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15793. * @param result The vector3 to copy the position to
  15794. */
  15795. getPositionToRef(space: Space | undefined, mesh: Nullable<AbstractMesh>, result: Vector3): void;
  15796. /**
  15797. * Get the absolute position of the bone (world space)
  15798. * @param mesh The mesh that this bone is attached to
  15799. * @returns The absolute position of the bone
  15800. */
  15801. getAbsolutePosition(mesh?: Nullable<AbstractMesh>): Vector3;
  15802. /**
  15803. * Copy the absolute position of the bone (world space) to the result param
  15804. * @param mesh The mesh that this bone is attached to
  15805. * @param result The vector3 to copy the absolute position to
  15806. */
  15807. getAbsolutePositionToRef(mesh: AbstractMesh, result: Vector3): void;
  15808. /**
  15809. * Compute the absolute transforms of this bone and its children
  15810. */
  15811. computeAbsoluteTransforms(): void;
  15812. /**
  15813. * Get the world direction from an axis that is in the local space of the bone
  15814. * @param localAxis The local direction that is used to compute the world direction
  15815. * @param mesh The mesh that this bone is attached to
  15816. * @returns The world direction
  15817. */
  15818. getDirection(localAxis: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  15819. /**
  15820. * Copy the world direction to a vector3 from an axis that is in the local space of the bone
  15821. * @param localAxis The local direction that is used to compute the world direction
  15822. * @param mesh The mesh that this bone is attached to
  15823. * @param result The vector3 that the world direction will be copied to
  15824. */
  15825. getDirectionToRef(localAxis: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  15826. /**
  15827. * Get the euler rotation of the bone in local or world space
  15828. * @param space The space that the rotation should be in
  15829. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15830. * @returns The euler rotation
  15831. */
  15832. getRotation(space?: Space, mesh?: Nullable<AbstractMesh>): Vector3;
  15833. /**
  15834. * Copy the euler rotation of the bone to a vector3. The rotation can be in either local or world space
  15835. * @param space The space that the rotation should be in
  15836. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15837. * @param result The vector3 that the rotation should be copied to
  15838. */
  15839. getRotationToRef(space: Space | undefined, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  15840. /**
  15841. * Get the quaternion rotation of the bone in either local or world space
  15842. * @param space The space that the rotation should be in
  15843. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15844. * @returns The quaternion rotation
  15845. */
  15846. getRotationQuaternion(space?: Space, mesh?: Nullable<AbstractMesh>): Quaternion;
  15847. /**
  15848. * Copy the quaternion rotation of the bone to a quaternion. The rotation can be in either local or world space
  15849. * @param space The space that the rotation should be in
  15850. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15851. * @param result The quaternion that the rotation should be copied to
  15852. */
  15853. getRotationQuaternionToRef(space: Space | undefined, mesh: AbstractMesh | null | undefined, result: Quaternion): void;
  15854. /**
  15855. * Get the rotation matrix of the bone in local or world space
  15856. * @param space The space that the rotation should be in
  15857. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15858. * @returns The rotation matrix
  15859. */
  15860. getRotationMatrix(space: Space | undefined, mesh: AbstractMesh): Matrix;
  15861. /**
  15862. * Copy the rotation matrix of the bone to a matrix. The rotation can be in either local or world space
  15863. * @param space The space that the rotation should be in
  15864. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15865. * @param result The quaternion that the rotation should be copied to
  15866. */
  15867. getRotationMatrixToRef(space: Space | undefined, mesh: AbstractMesh, result: Matrix): void;
  15868. /**
  15869. * Get the world position of a point that is in the local space of the bone
  15870. * @param position The local position
  15871. * @param mesh The mesh that this bone is attached to
  15872. * @returns The world position
  15873. */
  15874. getAbsolutePositionFromLocal(position: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  15875. /**
  15876. * Get the world position of a point that is in the local space of the bone and copy it to the result param
  15877. * @param position The local position
  15878. * @param mesh The mesh that this bone is attached to
  15879. * @param result The vector3 that the world position should be copied to
  15880. */
  15881. getAbsolutePositionFromLocalToRef(position: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  15882. /**
  15883. * Get the local position of a point that is in world space
  15884. * @param position The world position
  15885. * @param mesh The mesh that this bone is attached to
  15886. * @returns The local position
  15887. */
  15888. getLocalPositionFromAbsolute(position: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  15889. /**
  15890. * Get the local position of a point that is in world space and copy it to the result param
  15891. * @param position The world position
  15892. * @param mesh The mesh that this bone is attached to
  15893. * @param result The vector3 that the local position should be copied to
  15894. */
  15895. getLocalPositionFromAbsoluteToRef(position: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  15896. }
  15897. }
  15898. declare module "babylonjs/Animations/runtimeAnimation" {
  15899. import { Animation, _IAnimationState } from "babylonjs/Animations/animation";
  15900. import { Animatable } from "babylonjs/Animations/animatable";
  15901. import { Scene } from "babylonjs/scene";
  15902. /**
  15903. * Defines a runtime animation
  15904. */
  15905. export class RuntimeAnimation {
  15906. private _events;
  15907. /**
  15908. * The current frame of the runtime animation
  15909. */
  15910. private _currentFrame;
  15911. /**
  15912. * The animation used by the runtime animation
  15913. */
  15914. private _animation;
  15915. /**
  15916. * The target of the runtime animation
  15917. */
  15918. private _target;
  15919. /**
  15920. * The initiating animatable
  15921. */
  15922. private _host;
  15923. /**
  15924. * The original value of the runtime animation
  15925. */
  15926. private _originalValue;
  15927. /**
  15928. * The original blend value of the runtime animation
  15929. */
  15930. private _originalBlendValue;
  15931. /**
  15932. * The offsets cache of the runtime animation
  15933. */
  15934. private _offsetsCache;
  15935. /**
  15936. * The high limits cache of the runtime animation
  15937. */
  15938. private _highLimitsCache;
  15939. /**
  15940. * Specifies if the runtime animation has been stopped
  15941. */
  15942. private _stopped;
  15943. /**
  15944. * The blending factor of the runtime animation
  15945. */
  15946. private _blendingFactor;
  15947. /**
  15948. * The BabylonJS scene
  15949. */
  15950. private _scene;
  15951. /**
  15952. * The current value of the runtime animation
  15953. */
  15954. private _currentValue;
  15955. /** @hidden */
  15956. _animationState: _IAnimationState;
  15957. /**
  15958. * The active target of the runtime animation
  15959. */
  15960. private _activeTargets;
  15961. private _currentActiveTarget;
  15962. private _directTarget;
  15963. /**
  15964. * The target path of the runtime animation
  15965. */
  15966. private _targetPath;
  15967. /**
  15968. * The weight of the runtime animation
  15969. */
  15970. private _weight;
  15971. /**
  15972. * The ratio offset of the runtime animation
  15973. */
  15974. private _ratioOffset;
  15975. /**
  15976. * The previous delay of the runtime animation
  15977. */
  15978. private _previousDelay;
  15979. /**
  15980. * The previous ratio of the runtime animation
  15981. */
  15982. private _previousRatio;
  15983. private _enableBlending;
  15984. private _keys;
  15985. private _minFrame;
  15986. private _maxFrame;
  15987. private _minValue;
  15988. private _maxValue;
  15989. private _targetIsArray;
  15990. /**
  15991. * Gets the current frame of the runtime animation
  15992. */
  15993. get currentFrame(): number;
  15994. /**
  15995. * Gets the weight of the runtime animation
  15996. */
  15997. get weight(): number;
  15998. /**
  15999. * Gets the current value of the runtime animation
  16000. */
  16001. get currentValue(): any;
  16002. /**
  16003. * Gets the target path of the runtime animation
  16004. */
  16005. get targetPath(): string;
  16006. /**
  16007. * Gets the actual target of the runtime animation
  16008. */
  16009. get target(): any;
  16010. /**
  16011. * Gets the additive state of the runtime animation
  16012. */
  16013. get isAdditive(): boolean;
  16014. /** @hidden */
  16015. _onLoop: () => void;
  16016. /**
  16017. * Create a new RuntimeAnimation object
  16018. * @param target defines the target of the animation
  16019. * @param animation defines the source animation object
  16020. * @param scene defines the hosting scene
  16021. * @param host defines the initiating Animatable
  16022. */
  16023. constructor(target: any, animation: Animation, scene: Scene, host: Animatable);
  16024. private _preparePath;
  16025. /**
  16026. * Gets the animation from the runtime animation
  16027. */
  16028. get animation(): Animation;
  16029. /**
  16030. * Resets the runtime animation to the beginning
  16031. * @param restoreOriginal defines whether to restore the target property to the original value
  16032. */
  16033. reset(restoreOriginal?: boolean): void;
  16034. /**
  16035. * Specifies if the runtime animation is stopped
  16036. * @returns Boolean specifying if the runtime animation is stopped
  16037. */
  16038. isStopped(): boolean;
  16039. /**
  16040. * Disposes of the runtime animation
  16041. */
  16042. dispose(): void;
  16043. /**
  16044. * Apply the interpolated value to the target
  16045. * @param currentValue defines the value computed by the animation
  16046. * @param weight defines the weight to apply to this value (Defaults to 1.0)
  16047. */
  16048. setValue(currentValue: any, weight: number): void;
  16049. private _getOriginalValues;
  16050. private _setValue;
  16051. /**
  16052. * Gets the loop pmode of the runtime animation
  16053. * @returns Loop Mode
  16054. */
  16055. private _getCorrectLoopMode;
  16056. /**
  16057. * Move the current animation to a given frame
  16058. * @param frame defines the frame to move to
  16059. */
  16060. goToFrame(frame: number): void;
  16061. /**
  16062. * @hidden Internal use only
  16063. */
  16064. _prepareForSpeedRatioChange(newSpeedRatio: number): void;
  16065. /**
  16066. * Execute the current animation
  16067. * @param delay defines the delay to add to the current frame
  16068. * @param from defines the lower bound of the animation range
  16069. * @param to defines the upper bound of the animation range
  16070. * @param loop defines if the current animation must loop
  16071. * @param speedRatio defines the current speed ratio
  16072. * @param weight defines the weight of the animation (default is -1 so no weight)
  16073. * @param onLoop optional callback called when animation loops
  16074. * @returns a boolean indicating if the animation is running
  16075. */
  16076. animate(delay: number, from: number, to: number, loop: boolean, speedRatio: number, weight?: number): boolean;
  16077. }
  16078. }
  16079. declare module "babylonjs/Animations/animatable" {
  16080. import { Animation } from "babylonjs/Animations/animation";
  16081. import { RuntimeAnimation } from "babylonjs/Animations/runtimeAnimation";
  16082. import { Nullable } from "babylonjs/types";
  16083. import { Observable } from "babylonjs/Misc/observable";
  16084. import { Scene } from "babylonjs/scene";
  16085. import { Matrix, Quaternion, Vector3 } from "babylonjs/Maths/math.vector";
  16086. import { Node } from "babylonjs/node";
  16087. /**
  16088. * Class used to store an actual running animation
  16089. */
  16090. export class Animatable {
  16091. /** defines the target object */
  16092. target: any;
  16093. /** defines the starting frame number (default is 0) */
  16094. fromFrame: number;
  16095. /** defines the ending frame number (default is 100) */
  16096. toFrame: number;
  16097. /** defines if the animation must loop (default is false) */
  16098. loopAnimation: boolean;
  16099. /** defines a callback to call when animation ends if it is not looping */
  16100. onAnimationEnd?: (() => void) | null | undefined;
  16101. /** defines a callback to call when animation loops */
  16102. onAnimationLoop?: (() => void) | null | undefined;
  16103. /** defines whether the animation should be evaluated additively */
  16104. isAdditive: boolean;
  16105. private _localDelayOffset;
  16106. private _pausedDelay;
  16107. private _runtimeAnimations;
  16108. private _paused;
  16109. private _scene;
  16110. private _speedRatio;
  16111. private _weight;
  16112. private _syncRoot;
  16113. /**
  16114. * Gets or sets a boolean indicating if the animatable must be disposed and removed at the end of the animation.
  16115. * This will only apply for non looping animation (default is true)
  16116. */
  16117. disposeOnEnd: boolean;
  16118. /**
  16119. * Gets a boolean indicating if the animation has started
  16120. */
  16121. animationStarted: boolean;
  16122. /**
  16123. * Observer raised when the animation ends
  16124. */
  16125. onAnimationEndObservable: Observable<Animatable>;
  16126. /**
  16127. * Observer raised when the animation loops
  16128. */
  16129. onAnimationLoopObservable: Observable<Animatable>;
  16130. /**
  16131. * Gets the root Animatable used to synchronize and normalize animations
  16132. */
  16133. get syncRoot(): Nullable<Animatable>;
  16134. /**
  16135. * Gets the current frame of the first RuntimeAnimation
  16136. * Used to synchronize Animatables
  16137. */
  16138. get masterFrame(): number;
  16139. /**
  16140. * Gets or sets the animatable weight (-1.0 by default meaning not weighted)
  16141. */
  16142. get weight(): number;
  16143. set weight(value: number);
  16144. /**
  16145. * Gets or sets the speed ratio to apply to the animatable (1.0 by default)
  16146. */
  16147. get speedRatio(): number;
  16148. set speedRatio(value: number);
  16149. /**
  16150. * Creates a new Animatable
  16151. * @param scene defines the hosting scene
  16152. * @param target defines the target object
  16153. * @param fromFrame defines the starting frame number (default is 0)
  16154. * @param toFrame defines the ending frame number (default is 100)
  16155. * @param loopAnimation defines if the animation must loop (default is false)
  16156. * @param speedRatio defines the factor to apply to animation speed (default is 1)
  16157. * @param onAnimationEnd defines a callback to call when animation ends if it is not looping
  16158. * @param animations defines a group of animation to add to the new Animatable
  16159. * @param onAnimationLoop defines a callback to call when animation loops
  16160. * @param isAdditive defines whether the animation should be evaluated additively
  16161. */
  16162. constructor(scene: Scene,
  16163. /** defines the target object */
  16164. target: any,
  16165. /** defines the starting frame number (default is 0) */
  16166. fromFrame?: number,
  16167. /** defines the ending frame number (default is 100) */
  16168. toFrame?: number,
  16169. /** defines if the animation must loop (default is false) */
  16170. loopAnimation?: boolean, speedRatio?: number,
  16171. /** defines a callback to call when animation ends if it is not looping */
  16172. onAnimationEnd?: (() => void) | null | undefined, animations?: Animation[],
  16173. /** defines a callback to call when animation loops */
  16174. onAnimationLoop?: (() => void) | null | undefined,
  16175. /** defines whether the animation should be evaluated additively */
  16176. isAdditive?: boolean);
  16177. /**
  16178. * Synchronize and normalize current Animatable with a source Animatable
  16179. * This is useful when using animation weights and when animations are not of the same length
  16180. * @param root defines the root Animatable to synchronize with
  16181. * @returns the current Animatable
  16182. */
  16183. syncWith(root: Animatable): Animatable;
  16184. /**
  16185. * Gets the list of runtime animations
  16186. * @returns an array of RuntimeAnimation
  16187. */
  16188. getAnimations(): RuntimeAnimation[];
  16189. /**
  16190. * Adds more animations to the current animatable
  16191. * @param target defines the target of the animations
  16192. * @param animations defines the new animations to add
  16193. */
  16194. appendAnimations(target: any, animations: Animation[]): void;
  16195. /**
  16196. * Gets the source animation for a specific property
  16197. * @param property defines the propertyu to look for
  16198. * @returns null or the source animation for the given property
  16199. */
  16200. getAnimationByTargetProperty(property: string): Nullable<Animation>;
  16201. /**
  16202. * Gets the runtime animation for a specific property
  16203. * @param property defines the propertyu to look for
  16204. * @returns null or the runtime animation for the given property
  16205. */
  16206. getRuntimeAnimationByTargetProperty(property: string): Nullable<RuntimeAnimation>;
  16207. /**
  16208. * Resets the animatable to its original state
  16209. */
  16210. reset(): void;
  16211. /**
  16212. * Allows the animatable to blend with current running animations
  16213. * @see https://doc.babylonjs.com/babylon101/animations#animation-blending
  16214. * @param blendingSpeed defines the blending speed to use
  16215. */
  16216. enableBlending(blendingSpeed: number): void;
  16217. /**
  16218. * Disable animation blending
  16219. * @see https://doc.babylonjs.com/babylon101/animations#animation-blending
  16220. */
  16221. disableBlending(): void;
  16222. /**
  16223. * Jump directly to a given frame
  16224. * @param frame defines the frame to jump to
  16225. */
  16226. goToFrame(frame: number): void;
  16227. /**
  16228. * Pause the animation
  16229. */
  16230. pause(): void;
  16231. /**
  16232. * Restart the animation
  16233. */
  16234. restart(): void;
  16235. private _raiseOnAnimationEnd;
  16236. /**
  16237. * Stop and delete the current animation
  16238. * @param animationName defines a string used to only stop some of the runtime animations instead of all
  16239. * @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)
  16240. */
  16241. stop(animationName?: string, targetMask?: (target: any) => boolean): void;
  16242. /**
  16243. * Wait asynchronously for the animation to end
  16244. * @returns a promise which will be fullfilled when the animation ends
  16245. */
  16246. waitAsync(): Promise<Animatable>;
  16247. /** @hidden */
  16248. _animate(delay: number): boolean;
  16249. }
  16250. module "babylonjs/scene" {
  16251. interface Scene {
  16252. /** @hidden */
  16253. _registerTargetForLateAnimationBinding(runtimeAnimation: RuntimeAnimation, originalValue: any): void;
  16254. /** @hidden */
  16255. _processLateAnimationBindingsForMatrices(holder: {
  16256. totalWeight: number;
  16257. totalAdditiveWeight: number;
  16258. animations: RuntimeAnimation[];
  16259. additiveAnimations: RuntimeAnimation[];
  16260. originalValue: Matrix;
  16261. }): any;
  16262. /** @hidden */
  16263. _processLateAnimationBindingsForQuaternions(holder: {
  16264. totalWeight: number;
  16265. totalAdditiveWeight: number;
  16266. animations: RuntimeAnimation[];
  16267. additiveAnimations: RuntimeAnimation[];
  16268. originalValue: Quaternion;
  16269. }, refQuaternion: Quaternion): Quaternion;
  16270. /** @hidden */
  16271. _processLateAnimationBindings(): void;
  16272. /**
  16273. * Will start the animation sequence of a given target
  16274. * @param target defines the target
  16275. * @param from defines from which frame should animation start
  16276. * @param to defines until which frame should animation run.
  16277. * @param weight defines the weight to apply to the animation (1.0 by default)
  16278. * @param loop defines if the animation loops
  16279. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  16280. * @param onAnimationEnd defines the function to be executed when the animation ends
  16281. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  16282. * @param targetMask defines if the target should be animated if animations are present (this is called recursively on descendant animatables regardless of return value)
  16283. * @param onAnimationLoop defines the callback to call when an animation loops
  16284. * @param isAdditive defines whether the animation should be evaluated additively (false by default)
  16285. * @returns the animatable object created for this animation
  16286. */
  16287. 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;
  16288. /**
  16289. * Will start the animation sequence of a given target
  16290. * @param target defines the target
  16291. * @param from defines from which frame should animation start
  16292. * @param to defines until which frame should animation run.
  16293. * @param loop defines if the animation loops
  16294. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  16295. * @param onAnimationEnd defines the function to be executed when the animation ends
  16296. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  16297. * @param stopCurrent defines if the current animations must be stopped first (true by default)
  16298. * @param targetMask defines if the target should be animate if animations are present (this is called recursively on descendant animatables regardless of return value)
  16299. * @param onAnimationLoop defines the callback to call when an animation loops
  16300. * @param isAdditive defines whether the animation should be evaluated additively (false by default)
  16301. * @returns the animatable object created for this animation
  16302. */
  16303. 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;
  16304. /**
  16305. * Will start the animation sequence of a given target and its hierarchy
  16306. * @param target defines the target
  16307. * @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.
  16308. * @param from defines from which frame should animation start
  16309. * @param to defines until which frame should animation run.
  16310. * @param loop defines if the animation loops
  16311. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  16312. * @param onAnimationEnd defines the function to be executed when the animation ends
  16313. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  16314. * @param stopCurrent defines if the current animations must be stopped first (true by default)
  16315. * @param targetMask defines if the target should be animated if animations are present (this is called recursively on descendant animatables regardless of return value)
  16316. * @param onAnimationLoop defines the callback to call when an animation loops
  16317. * @param isAdditive defines whether the animation should be evaluated additively (false by default)
  16318. * @returns the list of created animatables
  16319. */
  16320. 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[];
  16321. /**
  16322. * Begin a new animation on a given node
  16323. * @param target defines the target where the animation will take place
  16324. * @param animations defines the list of animations to start
  16325. * @param from defines the initial value
  16326. * @param to defines the final value
  16327. * @param loop defines if you want animation to loop (off by default)
  16328. * @param speedRatio defines the speed ratio to apply to all animations
  16329. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  16330. * @param onAnimationLoop defines the callback to call when an animation loops
  16331. * @param isAdditive defines whether the animation should be evaluated additively (false by default)
  16332. * @returns the list of created animatables
  16333. */
  16334. beginDirectAnimation(target: any, animations: Animation[], from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, onAnimationLoop?: () => void, isAdditive?: boolean): Animatable;
  16335. /**
  16336. * Begin a new animation on a given node and its hierarchy
  16337. * @param target defines the root node where the animation will take place
  16338. * @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.
  16339. * @param animations defines the list of animations to start
  16340. * @param from defines the initial value
  16341. * @param to defines the final value
  16342. * @param loop defines if you want animation to loop (off by default)
  16343. * @param speedRatio defines the speed ratio to apply to all animations
  16344. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  16345. * @param onAnimationLoop defines the callback to call when an animation loops
  16346. * @param isAdditive defines whether the animation should be evaluated additively (false by default)
  16347. * @returns the list of animatables created for all nodes
  16348. */
  16349. beginDirectHierarchyAnimation(target: Node, directDescendantsOnly: boolean, animations: Animation[], from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, onAnimationLoop?: () => void, isAdditive?: boolean): Animatable[];
  16350. /**
  16351. * Gets the animatable associated with a specific target
  16352. * @param target defines the target of the animatable
  16353. * @returns the required animatable if found
  16354. */
  16355. getAnimatableByTarget(target: any): Nullable<Animatable>;
  16356. /**
  16357. * Gets all animatables associated with a given target
  16358. * @param target defines the target to look animatables for
  16359. * @returns an array of Animatables
  16360. */
  16361. getAllAnimatablesByTarget(target: any): Array<Animatable>;
  16362. /**
  16363. * Stops and removes all animations that have been applied to the scene
  16364. */
  16365. stopAllAnimations(): void;
  16366. /**
  16367. * Gets the current delta time used by animation engine
  16368. */
  16369. deltaTime: number;
  16370. }
  16371. }
  16372. module "babylonjs/Bones/bone" {
  16373. interface Bone {
  16374. /**
  16375. * Copy an animation range from another bone
  16376. * @param source defines the source bone
  16377. * @param rangeName defines the range name to copy
  16378. * @param frameOffset defines the frame offset
  16379. * @param rescaleAsRequired defines if rescaling must be applied if required
  16380. * @param skelDimensionsRatio defines the scaling ratio
  16381. * @returns true if operation was successful
  16382. */
  16383. copyAnimationRange(source: Bone, rangeName: string, frameOffset: number, rescaleAsRequired: boolean, skelDimensionsRatio: Nullable<Vector3>): boolean;
  16384. }
  16385. }
  16386. }
  16387. declare module "babylonjs/Bones/skeleton" {
  16388. import { Bone } from "babylonjs/Bones/bone";
  16389. import { Observable } from "babylonjs/Misc/observable";
  16390. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  16391. import { Scene } from "babylonjs/scene";
  16392. import { Nullable } from "babylonjs/types";
  16393. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  16394. import { RawTexture } from "babylonjs/Materials/Textures/rawTexture";
  16395. import { Animatable } from "babylonjs/Animations/animatable";
  16396. import { AnimationPropertiesOverride } from "babylonjs/Animations/animationPropertiesOverride";
  16397. import { Animation } from "babylonjs/Animations/animation";
  16398. import { AnimationRange } from "babylonjs/Animations/animationRange";
  16399. import { IInspectable } from "babylonjs/Misc/iInspectable";
  16400. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  16401. /**
  16402. * Class used to handle skinning animations
  16403. * @see https://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  16404. */
  16405. export class Skeleton implements IAnimatable {
  16406. /** defines the skeleton name */
  16407. name: string;
  16408. /** defines the skeleton Id */
  16409. id: string;
  16410. /**
  16411. * Defines the list of child bones
  16412. */
  16413. bones: Bone[];
  16414. /**
  16415. * Defines an estimate of the dimension of the skeleton at rest
  16416. */
  16417. dimensionsAtRest: Vector3;
  16418. /**
  16419. * Defines a boolean indicating if the root matrix is provided by meshes or by the current skeleton (this is the default value)
  16420. */
  16421. needInitialSkinMatrix: boolean;
  16422. /**
  16423. * Defines a mesh that override the matrix used to get the world matrix (null by default).
  16424. */
  16425. overrideMesh: Nullable<AbstractMesh>;
  16426. /**
  16427. * Gets the list of animations attached to this skeleton
  16428. */
  16429. animations: Array<Animation>;
  16430. private _scene;
  16431. private _isDirty;
  16432. private _transformMatrices;
  16433. private _transformMatrixTexture;
  16434. private _meshesWithPoseMatrix;
  16435. private _animatables;
  16436. private _identity;
  16437. private _synchronizedWithMesh;
  16438. private _ranges;
  16439. private _lastAbsoluteTransformsUpdateId;
  16440. private _canUseTextureForBones;
  16441. private _uniqueId;
  16442. /** @hidden */
  16443. _numBonesWithLinkedTransformNode: number;
  16444. /** @hidden */
  16445. _hasWaitingData: Nullable<boolean>;
  16446. /** @hidden */
  16447. _waitingOverrideMeshId: Nullable<string>;
  16448. /**
  16449. * Specifies if the skeleton should be serialized
  16450. */
  16451. doNotSerialize: boolean;
  16452. private _useTextureToStoreBoneMatrices;
  16453. /**
  16454. * Gets or sets a boolean indicating that bone matrices should be stored as a texture instead of using shader uniforms (default is true).
  16455. * Please note that this option is not available if the hardware does not support it
  16456. */
  16457. get useTextureToStoreBoneMatrices(): boolean;
  16458. set useTextureToStoreBoneMatrices(value: boolean);
  16459. private _animationPropertiesOverride;
  16460. /**
  16461. * Gets or sets the animation properties override
  16462. */
  16463. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  16464. set animationPropertiesOverride(value: Nullable<AnimationPropertiesOverride>);
  16465. /**
  16466. * List of inspectable custom properties (used by the Inspector)
  16467. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  16468. */
  16469. inspectableCustomProperties: IInspectable[];
  16470. /**
  16471. * An observable triggered before computing the skeleton's matrices
  16472. */
  16473. onBeforeComputeObservable: Observable<Skeleton>;
  16474. /**
  16475. * Gets a boolean indicating that the skeleton effectively stores matrices into a texture
  16476. */
  16477. get isUsingTextureForMatrices(): boolean;
  16478. /**
  16479. * Gets the unique ID of this skeleton
  16480. */
  16481. get uniqueId(): number;
  16482. /**
  16483. * Creates a new skeleton
  16484. * @param name defines the skeleton name
  16485. * @param id defines the skeleton Id
  16486. * @param scene defines the hosting scene
  16487. */
  16488. constructor(
  16489. /** defines the skeleton name */
  16490. name: string,
  16491. /** defines the skeleton Id */
  16492. id: string, scene: Scene);
  16493. /**
  16494. * Gets the current object class name.
  16495. * @return the class name
  16496. */
  16497. getClassName(): string;
  16498. /**
  16499. * Returns an array containing the root bones
  16500. * @returns an array containing the root bones
  16501. */
  16502. getChildren(): Array<Bone>;
  16503. /**
  16504. * Gets the list of transform matrices to send to shaders (one matrix per bone)
  16505. * @param mesh defines the mesh to use to get the root matrix (if needInitialSkinMatrix === true)
  16506. * @returns a Float32Array containing matrices data
  16507. */
  16508. getTransformMatrices(mesh: AbstractMesh): Float32Array;
  16509. /**
  16510. * Gets the list of transform matrices to send to shaders inside a texture (one matrix per bone)
  16511. * @param mesh defines the mesh to use to get the root matrix (if needInitialSkinMatrix === true)
  16512. * @returns a raw texture containing the data
  16513. */
  16514. getTransformMatrixTexture(mesh: AbstractMesh): Nullable<RawTexture>;
  16515. /**
  16516. * Gets the current hosting scene
  16517. * @returns a scene object
  16518. */
  16519. getScene(): Scene;
  16520. /**
  16521. * Gets a string representing the current skeleton data
  16522. * @param fullDetails defines a boolean indicating if we want a verbose version
  16523. * @returns a string representing the current skeleton data
  16524. */
  16525. toString(fullDetails?: boolean): string;
  16526. /**
  16527. * Get bone's index searching by name
  16528. * @param name defines bone's name to search for
  16529. * @return the indice of the bone. Returns -1 if not found
  16530. */
  16531. getBoneIndexByName(name: string): number;
  16532. /**
  16533. * Creater a new animation range
  16534. * @param name defines the name of the range
  16535. * @param from defines the start key
  16536. * @param to defines the end key
  16537. */
  16538. createAnimationRange(name: string, from: number, to: number): void;
  16539. /**
  16540. * Delete a specific animation range
  16541. * @param name defines the name of the range
  16542. * @param deleteFrames defines if frames must be removed as well
  16543. */
  16544. deleteAnimationRange(name: string, deleteFrames?: boolean): void;
  16545. /**
  16546. * Gets a specific animation range
  16547. * @param name defines the name of the range to look for
  16548. * @returns the requested animation range or null if not found
  16549. */
  16550. getAnimationRange(name: string): Nullable<AnimationRange>;
  16551. /**
  16552. * Gets the list of all animation ranges defined on this skeleton
  16553. * @returns an array
  16554. */
  16555. getAnimationRanges(): Nullable<AnimationRange>[];
  16556. /**
  16557. * Copy animation range from a source skeleton.
  16558. * This is not for a complete retargeting, only between very similar skeleton's with only possible bone length differences
  16559. * @param source defines the source skeleton
  16560. * @param name defines the name of the range to copy
  16561. * @param rescaleAsRequired defines if rescaling must be applied if required
  16562. * @returns true if operation was successful
  16563. */
  16564. copyAnimationRange(source: Skeleton, name: string, rescaleAsRequired?: boolean): boolean;
  16565. /**
  16566. * Forces the skeleton to go to rest pose
  16567. */
  16568. returnToRest(): void;
  16569. private _getHighestAnimationFrame;
  16570. /**
  16571. * Begin a specific animation range
  16572. * @param name defines the name of the range to start
  16573. * @param loop defines if looping must be turned on (false by default)
  16574. * @param speedRatio defines the speed ratio to apply (1 by default)
  16575. * @param onAnimationEnd defines a callback which will be called when animation will end
  16576. * @returns a new animatable
  16577. */
  16578. beginAnimation(name: string, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Nullable<Animatable>;
  16579. /**
  16580. * Convert the keyframes for a range of animation on a skeleton to be relative to a given reference frame.
  16581. * @param skeleton defines the Skeleton containing the animation range to convert
  16582. * @param referenceFrame defines the frame that keyframes in the range will be relative to
  16583. * @param range defines the name of the AnimationRange belonging to the Skeleton to convert
  16584. * @returns the original skeleton
  16585. */
  16586. static MakeAnimationAdditive(skeleton: Skeleton, referenceFrame: number | undefined, range: string): Nullable<Skeleton>;
  16587. /** @hidden */
  16588. _markAsDirty(): void;
  16589. /** @hidden */
  16590. _registerMeshWithPoseMatrix(mesh: AbstractMesh): void;
  16591. /** @hidden */
  16592. _unregisterMeshWithPoseMatrix(mesh: AbstractMesh): void;
  16593. private _computeTransformMatrices;
  16594. /**
  16595. * Build all resources required to render a skeleton
  16596. */
  16597. prepare(): void;
  16598. /**
  16599. * Gets the list of animatables currently running for this skeleton
  16600. * @returns an array of animatables
  16601. */
  16602. getAnimatables(): IAnimatable[];
  16603. /**
  16604. * Clone the current skeleton
  16605. * @param name defines the name of the new skeleton
  16606. * @param id defines the id of the new skeleton
  16607. * @returns the new skeleton
  16608. */
  16609. clone(name: string, id?: string): Skeleton;
  16610. /**
  16611. * Enable animation blending for this skeleton
  16612. * @param blendingSpeed defines the blending speed to apply
  16613. * @see https://doc.babylonjs.com/babylon101/animations#animation-blending
  16614. */
  16615. enableBlending(blendingSpeed?: number): void;
  16616. /**
  16617. * Releases all resources associated with the current skeleton
  16618. */
  16619. dispose(): void;
  16620. /**
  16621. * Serialize the skeleton in a JSON object
  16622. * @returns a JSON object
  16623. */
  16624. serialize(): any;
  16625. /**
  16626. * Creates a new skeleton from serialized data
  16627. * @param parsedSkeleton defines the serialized data
  16628. * @param scene defines the hosting scene
  16629. * @returns a new skeleton
  16630. */
  16631. static Parse(parsedSkeleton: any, scene: Scene): Skeleton;
  16632. /**
  16633. * Compute all node absolute transforms
  16634. * @param forceUpdate defines if computation must be done even if cache is up to date
  16635. */
  16636. computeAbsoluteTransforms(forceUpdate?: boolean): void;
  16637. /**
  16638. * Gets the root pose matrix
  16639. * @returns a matrix
  16640. */
  16641. getPoseMatrix(): Nullable<Matrix>;
  16642. /**
  16643. * Sorts bones per internal index
  16644. */
  16645. sortBones(): void;
  16646. private _sortBones;
  16647. }
  16648. }
  16649. declare module "babylonjs/Meshes/instancedMesh" {
  16650. import { Nullable, FloatArray, IndicesArray } from "babylonjs/types";
  16651. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  16652. import { Camera } from "babylonjs/Cameras/camera";
  16653. import { Node } from "babylonjs/node";
  16654. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  16655. import { Mesh } from "babylonjs/Meshes/mesh";
  16656. import { Material } from "babylonjs/Materials/material";
  16657. import { Skeleton } from "babylonjs/Bones/skeleton";
  16658. import { Light } from "babylonjs/Lights/light";
  16659. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  16660. /**
  16661. * Creates an instance based on a source mesh.
  16662. */
  16663. export class InstancedMesh extends AbstractMesh {
  16664. private _sourceMesh;
  16665. private _currentLOD;
  16666. /** @hidden */
  16667. _indexInSourceMeshInstanceArray: number;
  16668. constructor(name: string, source: Mesh);
  16669. /**
  16670. * Returns the string "InstancedMesh".
  16671. */
  16672. getClassName(): string;
  16673. /** Gets the list of lights affecting that mesh */
  16674. get lightSources(): Light[];
  16675. _resyncLightSources(): void;
  16676. _resyncLightSource(light: Light): void;
  16677. _removeLightSource(light: Light, dispose: boolean): void;
  16678. /**
  16679. * If the source mesh receives shadows
  16680. */
  16681. get receiveShadows(): boolean;
  16682. /**
  16683. * The material of the source mesh
  16684. */
  16685. get material(): Nullable<Material>;
  16686. /**
  16687. * Visibility of the source mesh
  16688. */
  16689. get visibility(): number;
  16690. /**
  16691. * Skeleton of the source mesh
  16692. */
  16693. get skeleton(): Nullable<Skeleton>;
  16694. /**
  16695. * Rendering ground id of the source mesh
  16696. */
  16697. get renderingGroupId(): number;
  16698. set renderingGroupId(value: number);
  16699. /**
  16700. * Returns the total number of vertices (integer).
  16701. */
  16702. getTotalVertices(): number;
  16703. /**
  16704. * Returns a positive integer : the total number of indices in this mesh geometry.
  16705. * @returns the numner of indices or zero if the mesh has no geometry.
  16706. */
  16707. getTotalIndices(): number;
  16708. /**
  16709. * The source mesh of the instance
  16710. */
  16711. get sourceMesh(): Mesh;
  16712. /**
  16713. * Creates a new InstancedMesh object from the mesh model.
  16714. * @see https://doc.babylonjs.com/how_to/how_to_use_instances
  16715. * @param name defines the name of the new instance
  16716. * @returns a new InstancedMesh
  16717. */
  16718. createInstance(name: string): InstancedMesh;
  16719. /**
  16720. * Is this node ready to be used/rendered
  16721. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  16722. * @return {boolean} is it ready
  16723. */
  16724. isReady(completeCheck?: boolean): boolean;
  16725. /**
  16726. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  16727. * @param kind kind of verticies to retreive (eg. positons, normals, uvs, etc.)
  16728. * @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.
  16729. * @returns a float array or a Float32Array of the requested kind of data : positons, normals, uvs, etc.
  16730. */
  16731. getVerticesData(kind: string, copyWhenShared?: boolean): Nullable<FloatArray>;
  16732. /**
  16733. * Sets the vertex data of the mesh geometry for the requested `kind`.
  16734. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  16735. * The `data` are either a numeric array either a Float32Array.
  16736. * The parameter `updatable` is passed as is to the underlying Geometry object constructor (if initianilly none) or updater.
  16737. * 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).
  16738. * Note that a new underlying VertexBuffer object is created each call.
  16739. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  16740. *
  16741. * Possible `kind` values :
  16742. * - VertexBuffer.PositionKind
  16743. * - VertexBuffer.UVKind
  16744. * - VertexBuffer.UV2Kind
  16745. * - VertexBuffer.UV3Kind
  16746. * - VertexBuffer.UV4Kind
  16747. * - VertexBuffer.UV5Kind
  16748. * - VertexBuffer.UV6Kind
  16749. * - VertexBuffer.ColorKind
  16750. * - VertexBuffer.MatricesIndicesKind
  16751. * - VertexBuffer.MatricesIndicesExtraKind
  16752. * - VertexBuffer.MatricesWeightsKind
  16753. * - VertexBuffer.MatricesWeightsExtraKind
  16754. *
  16755. * Returns the Mesh.
  16756. */
  16757. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  16758. /**
  16759. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  16760. * If the mesh has no geometry, it is simply returned as it is.
  16761. * The `data` are either a numeric array either a Float32Array.
  16762. * No new underlying VertexBuffer object is created.
  16763. * 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.
  16764. * If the parameter `makeItUnique` is true, a new global geometry is created from this positions and is set to the mesh.
  16765. *
  16766. * Possible `kind` values :
  16767. * - VertexBuffer.PositionKind
  16768. * - VertexBuffer.UVKind
  16769. * - VertexBuffer.UV2Kind
  16770. * - VertexBuffer.UV3Kind
  16771. * - VertexBuffer.UV4Kind
  16772. * - VertexBuffer.UV5Kind
  16773. * - VertexBuffer.UV6Kind
  16774. * - VertexBuffer.ColorKind
  16775. * - VertexBuffer.MatricesIndicesKind
  16776. * - VertexBuffer.MatricesIndicesExtraKind
  16777. * - VertexBuffer.MatricesWeightsKind
  16778. * - VertexBuffer.MatricesWeightsExtraKind
  16779. *
  16780. * Returns the Mesh.
  16781. */
  16782. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): Mesh;
  16783. /**
  16784. * Sets the mesh indices.
  16785. * Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array).
  16786. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  16787. * This method creates a new index buffer each call.
  16788. * Returns the Mesh.
  16789. */
  16790. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>): Mesh;
  16791. /**
  16792. * Boolean : True if the mesh owns the requested kind of data.
  16793. */
  16794. isVerticesDataPresent(kind: string): boolean;
  16795. /**
  16796. * Returns an array of indices (IndicesArray).
  16797. */
  16798. getIndices(): Nullable<IndicesArray>;
  16799. get _positions(): Nullable<Vector3[]>;
  16800. /**
  16801. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  16802. * This means the mesh underlying bounding box and sphere are recomputed.
  16803. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  16804. * @returns the current mesh
  16805. */
  16806. refreshBoundingInfo(applySkeleton?: boolean): InstancedMesh;
  16807. /** @hidden */
  16808. _preActivate(): InstancedMesh;
  16809. /** @hidden */
  16810. _activate(renderId: number, intermediateRendering: boolean): boolean;
  16811. /** @hidden */
  16812. _postActivate(): void;
  16813. getWorldMatrix(): Matrix;
  16814. get isAnInstance(): boolean;
  16815. /**
  16816. * Returns the current associated LOD AbstractMesh.
  16817. */
  16818. getLOD(camera: Camera): AbstractMesh;
  16819. /** @hidden */
  16820. _preActivateForIntermediateRendering(renderId: number): Mesh;
  16821. /** @hidden */
  16822. _syncSubMeshes(): InstancedMesh;
  16823. /** @hidden */
  16824. _generatePointsArray(): boolean;
  16825. /** @hidden */
  16826. _updateBoundingInfo(): AbstractMesh;
  16827. /**
  16828. * Creates a new InstancedMesh from the current mesh.
  16829. * - name (string) : the cloned mesh name
  16830. * - newParent (optional Node) : the optional Node to parent the clone to.
  16831. * - doNotCloneChildren (optional boolean, default `false`) : if `true` the model children aren't cloned.
  16832. *
  16833. * Returns the clone.
  16834. */
  16835. clone(name: string, newParent?: Nullable<Node>, doNotCloneChildren?: boolean): InstancedMesh;
  16836. /**
  16837. * Disposes the InstancedMesh.
  16838. * Returns nothing.
  16839. */
  16840. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  16841. }
  16842. module "babylonjs/Meshes/mesh" {
  16843. interface Mesh {
  16844. /**
  16845. * Register a custom buffer that will be instanced
  16846. * @see https://doc.babylonjs.com/how_to/how_to_use_instances#custom-buffers
  16847. * @param kind defines the buffer kind
  16848. * @param stride defines the stride in floats
  16849. */
  16850. registerInstancedBuffer(kind: string, stride: number): void;
  16851. /**
  16852. * true to use the edge renderer for all instances of this mesh
  16853. */
  16854. edgesShareWithInstances: boolean;
  16855. /** @hidden */
  16856. _userInstancedBuffersStorage: {
  16857. data: {
  16858. [key: string]: Float32Array;
  16859. };
  16860. sizes: {
  16861. [key: string]: number;
  16862. };
  16863. vertexBuffers: {
  16864. [key: string]: Nullable<VertexBuffer>;
  16865. };
  16866. strides: {
  16867. [key: string]: number;
  16868. };
  16869. };
  16870. }
  16871. }
  16872. module "babylonjs/Meshes/abstractMesh" {
  16873. interface AbstractMesh {
  16874. /**
  16875. * Object used to store instanced buffers defined by user
  16876. * @see https://doc.babylonjs.com/how_to/how_to_use_instances#custom-buffers
  16877. */
  16878. instancedBuffers: {
  16879. [key: string]: any;
  16880. };
  16881. }
  16882. }
  16883. }
  16884. declare module "babylonjs/Materials/shaderMaterial" {
  16885. import { Nullable } from "babylonjs/types";
  16886. import { Scene } from "babylonjs/scene";
  16887. import { Matrix, Vector3, Vector2, Vector4 } from "babylonjs/Maths/math.vector";
  16888. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  16889. import { Mesh } from "babylonjs/Meshes/mesh";
  16890. import { SubMesh } from "babylonjs/Meshes/subMesh";
  16891. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  16892. import { Effect } from "babylonjs/Materials/effect";
  16893. import { Material } from "babylonjs/Materials/material";
  16894. import { Color3, Color4 } from "babylonjs/Maths/math.color";
  16895. /**
  16896. * Defines the options associated with the creation of a shader material.
  16897. */
  16898. export interface IShaderMaterialOptions {
  16899. /**
  16900. * Does the material work in alpha blend mode
  16901. */
  16902. needAlphaBlending: boolean;
  16903. /**
  16904. * Does the material work in alpha test mode
  16905. */
  16906. needAlphaTesting: boolean;
  16907. /**
  16908. * The list of attribute names used in the shader
  16909. */
  16910. attributes: string[];
  16911. /**
  16912. * The list of unifrom names used in the shader
  16913. */
  16914. uniforms: string[];
  16915. /**
  16916. * The list of UBO names used in the shader
  16917. */
  16918. uniformBuffers: string[];
  16919. /**
  16920. * The list of sampler names used in the shader
  16921. */
  16922. samplers: string[];
  16923. /**
  16924. * The list of defines used in the shader
  16925. */
  16926. defines: string[];
  16927. }
  16928. /**
  16929. * 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.
  16930. *
  16931. * This returned material effects how the mesh will look based on the code in the shaders.
  16932. *
  16933. * @see https://doc.babylonjs.com/how_to/shader_material
  16934. */
  16935. export class ShaderMaterial extends Material {
  16936. private _shaderPath;
  16937. private _options;
  16938. private _textures;
  16939. private _textureArrays;
  16940. private _floats;
  16941. private _ints;
  16942. private _floatsArrays;
  16943. private _colors3;
  16944. private _colors3Arrays;
  16945. private _colors4;
  16946. private _colors4Arrays;
  16947. private _vectors2;
  16948. private _vectors3;
  16949. private _vectors4;
  16950. private _matrices;
  16951. private _matrixArrays;
  16952. private _matrices3x3;
  16953. private _matrices2x2;
  16954. private _vectors2Arrays;
  16955. private _vectors3Arrays;
  16956. private _vectors4Arrays;
  16957. private _cachedWorldViewMatrix;
  16958. private _cachedWorldViewProjectionMatrix;
  16959. private _renderId;
  16960. private _multiview;
  16961. private _cachedDefines;
  16962. /** Define the Url to load snippets */
  16963. static SnippetUrl: string;
  16964. /** Snippet ID if the material was created from the snippet server */
  16965. snippetId: string;
  16966. /**
  16967. * Instantiate a new shader material.
  16968. * 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.
  16969. * This returned material effects how the mesh will look based on the code in the shaders.
  16970. * @see https://doc.babylonjs.com/how_to/shader_material
  16971. * @param name Define the name of the material in the scene
  16972. * @param scene Define the scene the material belongs to
  16973. * @param shaderPath Defines the route to the shader code in one of three ways:
  16974. * * object: { vertex: "custom", fragment: "custom" }, used with Effect.ShadersStore["customVertexShader"] and Effect.ShadersStore["customFragmentShader"]
  16975. * * object: { vertexElement: "vertexShaderCode", fragmentElement: "fragmentShaderCode" }, used with shader code in script tags
  16976. * * object: { vertexSource: "vertex shader code string", fragmentSource: "fragment shader code string" } using with strings containing the shaders code
  16977. * * string: "./COMMON_NAME", used with external files COMMON_NAME.vertex.fx and COMMON_NAME.fragment.fx in index.html folder.
  16978. * @param options Define the options used to create the shader
  16979. */
  16980. constructor(name: string, scene: Scene, shaderPath: any, options?: Partial<IShaderMaterialOptions>);
  16981. /**
  16982. * Gets the shader path used to define the shader code
  16983. * It can be modified to trigger a new compilation
  16984. */
  16985. get shaderPath(): any;
  16986. /**
  16987. * Sets the shader path used to define the shader code
  16988. * It can be modified to trigger a new compilation
  16989. */
  16990. set shaderPath(shaderPath: any);
  16991. /**
  16992. * Gets the options used to compile the shader.
  16993. * They can be modified to trigger a new compilation
  16994. */
  16995. get options(): IShaderMaterialOptions;
  16996. /**
  16997. * Gets the current class name of the material e.g. "ShaderMaterial"
  16998. * Mainly use in serialization.
  16999. * @returns the class name
  17000. */
  17001. getClassName(): string;
  17002. /**
  17003. * Specifies if the material will require alpha blending
  17004. * @returns a boolean specifying if alpha blending is needed
  17005. */
  17006. needAlphaBlending(): boolean;
  17007. /**
  17008. * Specifies if this material should be rendered in alpha test mode
  17009. * @returns a boolean specifying if an alpha test is needed.
  17010. */
  17011. needAlphaTesting(): boolean;
  17012. private _checkUniform;
  17013. /**
  17014. * Set a texture in the shader.
  17015. * @param name Define the name of the uniform samplers as defined in the shader
  17016. * @param texture Define the texture to bind to this sampler
  17017. * @return the material itself allowing "fluent" like uniform updates
  17018. */
  17019. setTexture(name: string, texture: BaseTexture): ShaderMaterial;
  17020. /**
  17021. * Set a texture array in the shader.
  17022. * @param name Define the name of the uniform sampler array as defined in the shader
  17023. * @param textures Define the list of textures to bind to this sampler
  17024. * @return the material itself allowing "fluent" like uniform updates
  17025. */
  17026. setTextureArray(name: string, textures: BaseTexture[]): ShaderMaterial;
  17027. /**
  17028. * Set a float in the shader.
  17029. * @param name Define the name of the uniform as defined in the shader
  17030. * @param value Define the value to give to the uniform
  17031. * @return the material itself allowing "fluent" like uniform updates
  17032. */
  17033. setFloat(name: string, value: number): ShaderMaterial;
  17034. /**
  17035. * Set a int in the shader.
  17036. * @param name Define the name of the uniform as defined in the shader
  17037. * @param value Define the value to give to the uniform
  17038. * @return the material itself allowing "fluent" like uniform updates
  17039. */
  17040. setInt(name: string, value: number): ShaderMaterial;
  17041. /**
  17042. * Set an array of floats in the shader.
  17043. * @param name Define the name of the uniform as defined in the shader
  17044. * @param value Define the value to give to the uniform
  17045. * @return the material itself allowing "fluent" like uniform updates
  17046. */
  17047. setFloats(name: string, value: number[]): ShaderMaterial;
  17048. /**
  17049. * Set a vec3 in the shader from a Color3.
  17050. * @param name Define the name of the uniform as defined in the shader
  17051. * @param value Define the value to give to the uniform
  17052. * @return the material itself allowing "fluent" like uniform updates
  17053. */
  17054. setColor3(name: string, value: Color3): ShaderMaterial;
  17055. /**
  17056. * Set a vec3 array in the shader from a Color3 array.
  17057. * @param name Define the name of the uniform as defined in the shader
  17058. * @param value Define the value to give to the uniform
  17059. * @return the material itself allowing "fluent" like uniform updates
  17060. */
  17061. setColor3Array(name: string, value: Color3[]): ShaderMaterial;
  17062. /**
  17063. * Set a vec4 in the shader from a Color4.
  17064. * @param name Define the name of the uniform as defined in the shader
  17065. * @param value Define the value to give to the uniform
  17066. * @return the material itself allowing "fluent" like uniform updates
  17067. */
  17068. setColor4(name: string, value: Color4): ShaderMaterial;
  17069. /**
  17070. * Set a vec4 array in the shader from a Color4 array.
  17071. * @param name Define the name of the uniform as defined in the shader
  17072. * @param value Define the value to give to the uniform
  17073. * @return the material itself allowing "fluent" like uniform updates
  17074. */
  17075. setColor4Array(name: string, value: Color4[]): ShaderMaterial;
  17076. /**
  17077. * Set a vec2 in the shader from a Vector2.
  17078. * @param name Define the name of the uniform as defined in the shader
  17079. * @param value Define the value to give to the uniform
  17080. * @return the material itself allowing "fluent" like uniform updates
  17081. */
  17082. setVector2(name: string, value: Vector2): ShaderMaterial;
  17083. /**
  17084. * Set a vec3 in the shader from a Vector3.
  17085. * @param name Define the name of the uniform as defined in the shader
  17086. * @param value Define the value to give to the uniform
  17087. * @return the material itself allowing "fluent" like uniform updates
  17088. */
  17089. setVector3(name: string, value: Vector3): ShaderMaterial;
  17090. /**
  17091. * Set a vec4 in the shader from a Vector4.
  17092. * @param name Define the name of the uniform as defined in the shader
  17093. * @param value Define the value to give to the uniform
  17094. * @return the material itself allowing "fluent" like uniform updates
  17095. */
  17096. setVector4(name: string, value: Vector4): ShaderMaterial;
  17097. /**
  17098. * Set a mat4 in the shader from a Matrix.
  17099. * @param name Define the name of the uniform as defined in the shader
  17100. * @param value Define the value to give to the uniform
  17101. * @return the material itself allowing "fluent" like uniform updates
  17102. */
  17103. setMatrix(name: string, value: Matrix): ShaderMaterial;
  17104. /**
  17105. * Set a float32Array in the shader from a matrix array.
  17106. * @param name Define the name of the uniform as defined in the shader
  17107. * @param value Define the value to give to the uniform
  17108. * @return the material itself allowing "fluent" like uniform updates
  17109. */
  17110. setMatrices(name: string, value: Matrix[]): ShaderMaterial;
  17111. /**
  17112. * Set a mat3 in the shader from a Float32Array.
  17113. * @param name Define the name of the uniform as defined in the shader
  17114. * @param value Define the value to give to the uniform
  17115. * @return the material itself allowing "fluent" like uniform updates
  17116. */
  17117. setMatrix3x3(name: string, value: Float32Array | Array<number>): ShaderMaterial;
  17118. /**
  17119. * Set a mat2 in the shader from a Float32Array.
  17120. * @param name Define the name of the uniform as defined in the shader
  17121. * @param value Define the value to give to the uniform
  17122. * @return the material itself allowing "fluent" like uniform updates
  17123. */
  17124. setMatrix2x2(name: string, value: Float32Array | Array<number>): ShaderMaterial;
  17125. /**
  17126. * Set a vec2 array in the shader from a number array.
  17127. * @param name Define the name of the uniform as defined in the shader
  17128. * @param value Define the value to give to the uniform
  17129. * @return the material itself allowing "fluent" like uniform updates
  17130. */
  17131. setArray2(name: string, value: number[]): ShaderMaterial;
  17132. /**
  17133. * Set a vec3 array in the shader from a number array.
  17134. * @param name Define the name of the uniform as defined in the shader
  17135. * @param value Define the value to give to the uniform
  17136. * @return the material itself allowing "fluent" like uniform updates
  17137. */
  17138. setArray3(name: string, value: number[]): ShaderMaterial;
  17139. /**
  17140. * Set a vec4 array in the shader from a number array.
  17141. * @param name Define the name of the uniform as defined in the shader
  17142. * @param value Define the value to give to the uniform
  17143. * @return the material itself allowing "fluent" like uniform updates
  17144. */
  17145. setArray4(name: string, value: number[]): ShaderMaterial;
  17146. private _checkCache;
  17147. /**
  17148. * Specifies that the submesh is ready to be used
  17149. * @param mesh defines the mesh to check
  17150. * @param subMesh defines which submesh to check
  17151. * @param useInstances specifies that instances should be used
  17152. * @returns a boolean indicating that the submesh is ready or not
  17153. */
  17154. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  17155. /**
  17156. * Checks if the material is ready to render the requested mesh
  17157. * @param mesh Define the mesh to render
  17158. * @param useInstances Define whether or not the material is used with instances
  17159. * @returns true if ready, otherwise false
  17160. */
  17161. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  17162. /**
  17163. * Binds the world matrix to the material
  17164. * @param world defines the world transformation matrix
  17165. * @param effectOverride - If provided, use this effect instead of internal effect
  17166. */
  17167. bindOnlyWorldMatrix(world: Matrix, effectOverride?: Nullable<Effect>): void;
  17168. /**
  17169. * Binds the submesh to this material by preparing the effect and shader to draw
  17170. * @param world defines the world transformation matrix
  17171. * @param mesh defines the mesh containing the submesh
  17172. * @param subMesh defines the submesh to bind the material to
  17173. */
  17174. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  17175. /**
  17176. * Binds the material to the mesh
  17177. * @param world defines the world transformation matrix
  17178. * @param mesh defines the mesh to bind the material to
  17179. * @param effectOverride - If provided, use this effect instead of internal effect
  17180. */
  17181. bind(world: Matrix, mesh?: Mesh, effectOverride?: Nullable<Effect>): void;
  17182. protected _afterBind(mesh?: Mesh): void;
  17183. /**
  17184. * Gets the active textures from the material
  17185. * @returns an array of textures
  17186. */
  17187. getActiveTextures(): BaseTexture[];
  17188. /**
  17189. * Specifies if the material uses a texture
  17190. * @param texture defines the texture to check against the material
  17191. * @returns a boolean specifying if the material uses the texture
  17192. */
  17193. hasTexture(texture: BaseTexture): boolean;
  17194. /**
  17195. * Makes a duplicate of the material, and gives it a new name
  17196. * @param name defines the new name for the duplicated material
  17197. * @returns the cloned material
  17198. */
  17199. clone(name: string): ShaderMaterial;
  17200. /**
  17201. * Disposes the material
  17202. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  17203. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  17204. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  17205. */
  17206. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  17207. /**
  17208. * Serializes this material in a JSON representation
  17209. * @returns the serialized material object
  17210. */
  17211. serialize(): any;
  17212. /**
  17213. * Creates a shader material from parsed shader material data
  17214. * @param source defines the JSON represnetation of the material
  17215. * @param scene defines the hosting scene
  17216. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  17217. * @returns a new material
  17218. */
  17219. static Parse(source: any, scene: Scene, rootUrl: string): ShaderMaterial;
  17220. /**
  17221. * Creates a new ShaderMaterial from a snippet saved in a remote file
  17222. * @param name defines the name of the ShaderMaterial to create (can be null or empty to use the one from the json data)
  17223. * @param url defines the url to load from
  17224. * @param scene defines the hosting scene
  17225. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  17226. * @returns a promise that will resolve to the new ShaderMaterial
  17227. */
  17228. static ParseFromFileAsync(name: Nullable<string>, url: string, scene: Scene, rootUrl?: string): Promise<ShaderMaterial>;
  17229. /**
  17230. * Creates a ShaderMaterial from a snippet saved by the Inspector
  17231. * @param snippetId defines the snippet to load
  17232. * @param scene defines the hosting scene
  17233. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  17234. * @returns a promise that will resolve to the new ShaderMaterial
  17235. */
  17236. static CreateFromSnippetAsync(snippetId: string, scene: Scene, rootUrl?: string): Promise<ShaderMaterial>;
  17237. }
  17238. }
  17239. declare module "babylonjs/Shaders/color.fragment" {
  17240. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration";
  17241. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragment";
  17242. /** @hidden */
  17243. export var colorPixelShader: {
  17244. name: string;
  17245. shader: string;
  17246. };
  17247. }
  17248. declare module "babylonjs/Shaders/color.vertex" {
  17249. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  17250. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration";
  17251. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  17252. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  17253. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  17254. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertex";
  17255. /** @hidden */
  17256. export var colorVertexShader: {
  17257. name: string;
  17258. shader: string;
  17259. };
  17260. }
  17261. declare module "babylonjs/Meshes/linesMesh" {
  17262. import { Nullable } from "babylonjs/types";
  17263. import { Scene } from "babylonjs/scene";
  17264. import { Color3 } from "babylonjs/Maths/math.color";
  17265. import { Node } from "babylonjs/node";
  17266. import { SubMesh } from "babylonjs/Meshes/subMesh";
  17267. import { Mesh } from "babylonjs/Meshes/mesh";
  17268. import { InstancedMesh } from "babylonjs/Meshes/instancedMesh";
  17269. import { Effect } from "babylonjs/Materials/effect";
  17270. import { Material } from "babylonjs/Materials/material";
  17271. import "babylonjs/Shaders/color.fragment";
  17272. import "babylonjs/Shaders/color.vertex";
  17273. /**
  17274. * Line mesh
  17275. * @see https://doc.babylonjs.com/babylon101/parametric_shapes
  17276. */
  17277. export class LinesMesh extends Mesh {
  17278. /**
  17279. * If vertex color should be applied to the mesh
  17280. */
  17281. readonly useVertexColor?: boolean | undefined;
  17282. /**
  17283. * If vertex alpha should be applied to the mesh
  17284. */
  17285. readonly useVertexAlpha?: boolean | undefined;
  17286. /**
  17287. * Color of the line (Default: White)
  17288. */
  17289. color: Color3;
  17290. /**
  17291. * Alpha of the line (Default: 1)
  17292. */
  17293. alpha: number;
  17294. /**
  17295. * The intersection Threshold is the margin applied when intersection a segment of the LinesMesh with a Ray.
  17296. * This margin is expressed in world space coordinates, so its value may vary.
  17297. * Default value is 0.1
  17298. */
  17299. intersectionThreshold: number;
  17300. private _colorShader;
  17301. private color4;
  17302. /**
  17303. * Creates a new LinesMesh
  17304. * @param name defines the name
  17305. * @param scene defines the hosting scene
  17306. * @param parent defines the parent mesh if any
  17307. * @param source defines the optional source LinesMesh used to clone data from
  17308. * @param doNotCloneChildren When cloning, skip cloning child meshes of source, default False.
  17309. * When false, achieved by calling a clone(), also passing False.
  17310. * This will make creation of children, recursive.
  17311. * @param useVertexColor defines if this LinesMesh supports vertex color
  17312. * @param useVertexAlpha defines if this LinesMesh supports vertex alpha
  17313. */
  17314. constructor(name: string, scene?: Nullable<Scene>, parent?: Nullable<Node>, source?: Nullable<LinesMesh>, doNotCloneChildren?: boolean,
  17315. /**
  17316. * If vertex color should be applied to the mesh
  17317. */
  17318. useVertexColor?: boolean | undefined,
  17319. /**
  17320. * If vertex alpha should be applied to the mesh
  17321. */
  17322. useVertexAlpha?: boolean | undefined);
  17323. private _addClipPlaneDefine;
  17324. private _removeClipPlaneDefine;
  17325. isReady(): boolean;
  17326. /**
  17327. * Returns the string "LineMesh"
  17328. */
  17329. getClassName(): string;
  17330. /**
  17331. * @hidden
  17332. */
  17333. get material(): Material;
  17334. /**
  17335. * @hidden
  17336. */
  17337. set material(value: Material);
  17338. /**
  17339. * @hidden
  17340. */
  17341. get checkCollisions(): boolean;
  17342. /** @hidden */
  17343. _bind(subMesh: SubMesh, effect: Effect, fillMode: number): Mesh;
  17344. /** @hidden */
  17345. _draw(subMesh: SubMesh, fillMode: number, instancesCount?: number): Mesh;
  17346. /**
  17347. * Disposes of the line mesh
  17348. * @param doNotRecurse If children should be disposed
  17349. */
  17350. dispose(doNotRecurse?: boolean): void;
  17351. /**
  17352. * Returns a new LineMesh object cloned from the current one.
  17353. */
  17354. clone(name: string, newParent?: Nullable<Node>, doNotCloneChildren?: boolean): LinesMesh;
  17355. /**
  17356. * Creates a new InstancedLinesMesh object from the mesh model.
  17357. * @see https://doc.babylonjs.com/how_to/how_to_use_instances
  17358. * @param name defines the name of the new instance
  17359. * @returns a new InstancedLinesMesh
  17360. */
  17361. createInstance(name: string): InstancedLinesMesh;
  17362. }
  17363. /**
  17364. * Creates an instance based on a source LinesMesh
  17365. */
  17366. export class InstancedLinesMesh extends InstancedMesh {
  17367. /**
  17368. * The intersection Threshold is the margin applied when intersection a segment of the LinesMesh with a Ray.
  17369. * This margin is expressed in world space coordinates, so its value may vary.
  17370. * Initilized with the intersectionThreshold value of the source LinesMesh
  17371. */
  17372. intersectionThreshold: number;
  17373. constructor(name: string, source: LinesMesh);
  17374. /**
  17375. * Returns the string "InstancedLinesMesh".
  17376. */
  17377. getClassName(): string;
  17378. }
  17379. }
  17380. declare module "babylonjs/Shaders/line.fragment" {
  17381. /** @hidden */
  17382. export var linePixelShader: {
  17383. name: string;
  17384. shader: string;
  17385. };
  17386. }
  17387. declare module "babylonjs/Shaders/line.vertex" {
  17388. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  17389. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  17390. /** @hidden */
  17391. export var lineVertexShader: {
  17392. name: string;
  17393. shader: string;
  17394. };
  17395. }
  17396. declare module "babylonjs/Rendering/edgesRenderer" {
  17397. import { Nullable } from "babylonjs/types";
  17398. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  17399. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  17400. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  17401. import { IDisposable } from "babylonjs/scene";
  17402. import { ShaderMaterial } from "babylonjs/Materials/shaderMaterial";
  17403. import "babylonjs/Shaders/line.fragment";
  17404. import "babylonjs/Shaders/line.vertex";
  17405. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  17406. import { SmartArray } from "babylonjs/Misc/smartArray";
  17407. module "babylonjs/scene" {
  17408. interface Scene {
  17409. /** @hidden */
  17410. _edgeRenderLineShader: Nullable<ShaderMaterial>;
  17411. }
  17412. }
  17413. module "babylonjs/Meshes/abstractMesh" {
  17414. interface AbstractMesh {
  17415. /**
  17416. * Gets the edgesRenderer associated with the mesh
  17417. */
  17418. edgesRenderer: Nullable<EdgesRenderer>;
  17419. }
  17420. }
  17421. module "babylonjs/Meshes/linesMesh" {
  17422. interface LinesMesh {
  17423. /**
  17424. * Enables the edge rendering mode on the mesh.
  17425. * This mode makes the mesh edges visible
  17426. * @param epsilon defines the maximal distance between two angles to detect a face
  17427. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  17428. * @returns the currentAbstractMesh
  17429. * @see https://www.babylonjs-playground.com/#19O9TU#0
  17430. */
  17431. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): AbstractMesh;
  17432. }
  17433. }
  17434. module "babylonjs/Meshes/linesMesh" {
  17435. interface InstancedLinesMesh {
  17436. /**
  17437. * Enables the edge rendering mode on the mesh.
  17438. * This mode makes the mesh edges visible
  17439. * @param epsilon defines the maximal distance between two angles to detect a face
  17440. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  17441. * @returns the current InstancedLinesMesh
  17442. * @see https://www.babylonjs-playground.com/#19O9TU#0
  17443. */
  17444. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): InstancedLinesMesh;
  17445. }
  17446. }
  17447. /**
  17448. * Defines the minimum contract an Edges renderer should follow.
  17449. */
  17450. export interface IEdgesRenderer extends IDisposable {
  17451. /**
  17452. * Gets or sets a boolean indicating if the edgesRenderer is active
  17453. */
  17454. isEnabled: boolean;
  17455. /**
  17456. * Renders the edges of the attached mesh,
  17457. */
  17458. render(): void;
  17459. /**
  17460. * Checks wether or not the edges renderer is ready to render.
  17461. * @return true if ready, otherwise false.
  17462. */
  17463. isReady(): boolean;
  17464. /**
  17465. * List of instances to render in case the source mesh has instances
  17466. */
  17467. customInstances: SmartArray<Matrix>;
  17468. }
  17469. /**
  17470. * Defines the additional options of the edges renderer
  17471. */
  17472. export interface IEdgesRendererOptions {
  17473. /**
  17474. * Gets or sets a boolean indicating that the alternate edge finder algorithm must be used
  17475. * If not defined, the default value is true
  17476. */
  17477. useAlternateEdgeFinder?: boolean;
  17478. /**
  17479. * Gets or sets a boolean indicating that the vertex merger fast processing must be used.
  17480. * If not defined, the default value is true.
  17481. * 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)
  17482. * This option is used only if useAlternateEdgeFinder = true
  17483. */
  17484. useFastVertexMerger?: boolean;
  17485. /**
  17486. * During edges processing, the vertices are merged if they are close enough: epsilonVertexMerge is the limit whithin which vertices are considered to be equal.
  17487. * The default value is 1e-6
  17488. * This option is used only if useAlternateEdgeFinder = true
  17489. */
  17490. epsilonVertexMerge?: number;
  17491. /**
  17492. * 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
  17493. * 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.
  17494. * This option is used only if useAlternateEdgeFinder = true
  17495. */
  17496. applyTessellation?: boolean;
  17497. /**
  17498. * 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
  17499. * The default value is 1e-6
  17500. * This option is used only if useAlternateEdgeFinder = true
  17501. */
  17502. epsilonVertexAligned?: number;
  17503. }
  17504. /**
  17505. * This class is used to generate edges of the mesh that could then easily be rendered in a scene.
  17506. */
  17507. export class EdgesRenderer implements IEdgesRenderer {
  17508. /**
  17509. * Define the size of the edges with an orthographic camera
  17510. */
  17511. edgesWidthScalerForOrthographic: number;
  17512. /**
  17513. * Define the size of the edges with a perspective camera
  17514. */
  17515. edgesWidthScalerForPerspective: number;
  17516. protected _source: AbstractMesh;
  17517. protected _linesPositions: number[];
  17518. protected _linesNormals: number[];
  17519. protected _linesIndices: number[];
  17520. protected _epsilon: number;
  17521. protected _indicesCount: number;
  17522. protected _lineShader: ShaderMaterial;
  17523. protected _ib: DataBuffer;
  17524. protected _buffers: {
  17525. [key: string]: Nullable<VertexBuffer>;
  17526. };
  17527. protected _buffersForInstances: {
  17528. [key: string]: Nullable<VertexBuffer>;
  17529. };
  17530. protected _checkVerticesInsteadOfIndices: boolean;
  17531. protected _options: Nullable<IEdgesRendererOptions>;
  17532. private _meshRebuildObserver;
  17533. private _meshDisposeObserver;
  17534. /** Gets or sets a boolean indicating if the edgesRenderer is active */
  17535. isEnabled: boolean;
  17536. /**
  17537. * List of instances to render in case the source mesh has instances
  17538. */
  17539. customInstances: SmartArray<Matrix>;
  17540. private static GetShader;
  17541. /**
  17542. * Creates an instance of the EdgesRenderer. It is primarily use to display edges of a mesh.
  17543. * Beware when you use this class with complex objects as the adjacencies computation can be really long
  17544. * @param source Mesh used to create edges
  17545. * @param epsilon sum of angles in adjacency to check for edge
  17546. * @param checkVerticesInsteadOfIndices bases the edges detection on vertices vs indices. Note that this parameter is not used if options.useAlternateEdgeFinder = true
  17547. * @param generateEdgesLines - should generate Lines or only prepare resources.
  17548. * @param options The options to apply when generating the edges
  17549. */
  17550. constructor(source: AbstractMesh, epsilon?: number, checkVerticesInsteadOfIndices?: boolean, generateEdgesLines?: boolean, options?: IEdgesRendererOptions);
  17551. protected _prepareRessources(): void;
  17552. /** @hidden */
  17553. _rebuild(): void;
  17554. /**
  17555. * Releases the required resources for the edges renderer
  17556. */
  17557. dispose(): void;
  17558. protected _processEdgeForAdjacencies(pa: number, pb: number, p0: number, p1: number, p2: number): number;
  17559. protected _processEdgeForAdjacenciesWithVertices(pa: Vector3, pb: Vector3, p0: Vector3, p1: Vector3, p2: Vector3): number;
  17560. /**
  17561. * Checks if the pair of p0 and p1 is en edge
  17562. * @param faceIndex
  17563. * @param edge
  17564. * @param faceNormals
  17565. * @param p0
  17566. * @param p1
  17567. * @private
  17568. */
  17569. protected _checkEdge(faceIndex: number, edge: number, faceNormals: Array<Vector3>, p0: Vector3, p1: Vector3): void;
  17570. /**
  17571. * push line into the position, normal and index buffer
  17572. * @protected
  17573. */
  17574. protected createLine(p0: Vector3, p1: Vector3, offset: number): void;
  17575. /**
  17576. * See https://playground.babylonjs.com/#R3JR6V#1 for a visual display of the algorithm
  17577. */
  17578. private _tessellateTriangle;
  17579. private _generateEdgesLinesAlternate;
  17580. /**
  17581. * Generates lines edges from adjacencjes
  17582. * @private
  17583. */
  17584. _generateEdgesLines(): void;
  17585. /**
  17586. * Checks wether or not the edges renderer is ready to render.
  17587. * @return true if ready, otherwise false.
  17588. */
  17589. isReady(): boolean;
  17590. /**
  17591. * Renders the edges of the attached mesh,
  17592. */
  17593. render(): void;
  17594. }
  17595. /**
  17596. * LineEdgesRenderer for LineMeshes to remove unnecessary triangulation
  17597. */
  17598. export class LineEdgesRenderer extends EdgesRenderer {
  17599. /**
  17600. * This constructor turns off auto generating edges line in Edges Renderer to make it here.
  17601. * @param source LineMesh used to generate edges
  17602. * @param epsilon not important (specified angle for edge detection)
  17603. * @param checkVerticesInsteadOfIndices not important for LineMesh
  17604. */
  17605. constructor(source: AbstractMesh, epsilon?: number, checkVerticesInsteadOfIndices?: boolean);
  17606. /**
  17607. * Generate edges for each line in LinesMesh. Every Line should be rendered as edge.
  17608. */
  17609. _generateEdgesLines(): void;
  17610. }
  17611. }
  17612. declare module "babylonjs/Rendering/renderingGroup" {
  17613. import { SmartArray, SmartArrayNoDuplicate } from "babylonjs/Misc/smartArray";
  17614. import { SubMesh } from "babylonjs/Meshes/subMesh";
  17615. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  17616. import { Nullable } from "babylonjs/types";
  17617. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  17618. import { IEdgesRenderer } from "babylonjs/Rendering/edgesRenderer";
  17619. import { ISpriteManager } from "babylonjs/Sprites/spriteManager";
  17620. import { Material } from "babylonjs/Materials/material";
  17621. import { Scene } from "babylonjs/scene";
  17622. /**
  17623. * This represents the object necessary to create a rendering group.
  17624. * This is exclusively used and created by the rendering manager.
  17625. * To modify the behavior, you use the available helpers in your scene or meshes.
  17626. * @hidden
  17627. */
  17628. export class RenderingGroup {
  17629. index: number;
  17630. private static _zeroVector;
  17631. private _scene;
  17632. private _opaqueSubMeshes;
  17633. private _transparentSubMeshes;
  17634. private _alphaTestSubMeshes;
  17635. private _depthOnlySubMeshes;
  17636. private _particleSystems;
  17637. private _spriteManagers;
  17638. private _opaqueSortCompareFn;
  17639. private _alphaTestSortCompareFn;
  17640. private _transparentSortCompareFn;
  17641. private _renderOpaque;
  17642. private _renderAlphaTest;
  17643. private _renderTransparent;
  17644. /** @hidden */
  17645. _edgesRenderers: SmartArrayNoDuplicate<IEdgesRenderer>;
  17646. onBeforeTransparentRendering: () => void;
  17647. /**
  17648. * Set the opaque sort comparison function.
  17649. * If null the sub meshes will be render in the order they were created
  17650. */
  17651. set opaqueSortCompareFn(value: Nullable<(a: SubMesh, b: SubMesh) => number>);
  17652. /**
  17653. * Set the alpha test sort comparison function.
  17654. * If null the sub meshes will be render in the order they were created
  17655. */
  17656. set alphaTestSortCompareFn(value: Nullable<(a: SubMesh, b: SubMesh) => number>);
  17657. /**
  17658. * Set the transparent sort comparison function.
  17659. * If null the sub meshes will be render in the order they were created
  17660. */
  17661. set transparentSortCompareFn(value: Nullable<(a: SubMesh, b: SubMesh) => number>);
  17662. /**
  17663. * Creates a new rendering group.
  17664. * @param index The rendering group index
  17665. * @param opaqueSortCompareFn The opaque sort comparison function. If null no order is applied
  17666. * @param alphaTestSortCompareFn The alpha test sort comparison function. If null no order is applied
  17667. * @param transparentSortCompareFn The transparent sort comparison function. If null back to front + alpha index sort is applied
  17668. */
  17669. 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>);
  17670. /**
  17671. * Render all the sub meshes contained in the group.
  17672. * @param customRenderFunction Used to override the default render behaviour of the group.
  17673. * @returns true if rendered some submeshes.
  17674. */
  17675. render(customRenderFunction: Nullable<(opaqueSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>) => void>, renderSprites: boolean, renderParticles: boolean, activeMeshes: Nullable<AbstractMesh[]>): void;
  17676. /**
  17677. * Renders the opaque submeshes in the order from the opaqueSortCompareFn.
  17678. * @param subMeshes The submeshes to render
  17679. */
  17680. private renderOpaqueSorted;
  17681. /**
  17682. * Renders the opaque submeshes in the order from the alphatestSortCompareFn.
  17683. * @param subMeshes The submeshes to render
  17684. */
  17685. private renderAlphaTestSorted;
  17686. /**
  17687. * Renders the opaque submeshes in the order from the transparentSortCompareFn.
  17688. * @param subMeshes The submeshes to render
  17689. */
  17690. private renderTransparentSorted;
  17691. /**
  17692. * Renders the submeshes in a specified order.
  17693. * @param subMeshes The submeshes to sort before render
  17694. * @param sortCompareFn The comparison function use to sort
  17695. * @param cameraPosition The camera position use to preprocess the submeshes to help sorting
  17696. * @param transparent Specifies to activate blending if true
  17697. */
  17698. private static renderSorted;
  17699. /**
  17700. * Renders the submeshes in the order they were dispatched (no sort applied).
  17701. * @param subMeshes The submeshes to render
  17702. */
  17703. private static renderUnsorted;
  17704. /**
  17705. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  17706. * are rendered back to front if in the same alpha index.
  17707. *
  17708. * @param a The first submesh
  17709. * @param b The second submesh
  17710. * @returns The result of the comparison
  17711. */
  17712. static defaultTransparentSortCompare(a: SubMesh, b: SubMesh): number;
  17713. /**
  17714. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  17715. * are rendered back to front.
  17716. *
  17717. * @param a The first submesh
  17718. * @param b The second submesh
  17719. * @returns The result of the comparison
  17720. */
  17721. static backToFrontSortCompare(a: SubMesh, b: SubMesh): number;
  17722. /**
  17723. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  17724. * are rendered front to back (prevent overdraw).
  17725. *
  17726. * @param a The first submesh
  17727. * @param b The second submesh
  17728. * @returns The result of the comparison
  17729. */
  17730. static frontToBackSortCompare(a: SubMesh, b: SubMesh): number;
  17731. /**
  17732. * Resets the different lists of submeshes to prepare a new frame.
  17733. */
  17734. prepare(): void;
  17735. dispose(): void;
  17736. /**
  17737. * Inserts the submesh in its correct queue depending on its material.
  17738. * @param subMesh The submesh to dispatch
  17739. * @param [mesh] Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  17740. * @param [material] Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  17741. */
  17742. dispatch(subMesh: SubMesh, mesh?: AbstractMesh, material?: Nullable<Material>): void;
  17743. dispatchSprites(spriteManager: ISpriteManager): void;
  17744. dispatchParticles(particleSystem: IParticleSystem): void;
  17745. private _renderParticles;
  17746. private _renderSprites;
  17747. }
  17748. }
  17749. declare module "babylonjs/Rendering/renderingManager" {
  17750. import { Nullable } from "babylonjs/types";
  17751. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  17752. import { SubMesh } from "babylonjs/Meshes/subMesh";
  17753. import { SmartArray } from "babylonjs/Misc/smartArray";
  17754. import { ISpriteManager } from "babylonjs/Sprites/spriteManager";
  17755. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  17756. import { Material } from "babylonjs/Materials/material";
  17757. import { Scene } from "babylonjs/scene";
  17758. import { Camera } from "babylonjs/Cameras/camera";
  17759. /**
  17760. * Interface describing the different options available in the rendering manager
  17761. * regarding Auto Clear between groups.
  17762. */
  17763. export interface IRenderingManagerAutoClearSetup {
  17764. /**
  17765. * Defines whether or not autoclear is enable.
  17766. */
  17767. autoClear: boolean;
  17768. /**
  17769. * Defines whether or not to autoclear the depth buffer.
  17770. */
  17771. depth: boolean;
  17772. /**
  17773. * Defines whether or not to autoclear the stencil buffer.
  17774. */
  17775. stencil: boolean;
  17776. }
  17777. /**
  17778. * This class is used by the onRenderingGroupObservable
  17779. */
  17780. export class RenderingGroupInfo {
  17781. /**
  17782. * The Scene that being rendered
  17783. */
  17784. scene: Scene;
  17785. /**
  17786. * The camera currently used for the rendering pass
  17787. */
  17788. camera: Nullable<Camera>;
  17789. /**
  17790. * The ID of the renderingGroup being processed
  17791. */
  17792. renderingGroupId: number;
  17793. }
  17794. /**
  17795. * This is the manager responsible of all the rendering for meshes sprites and particles.
  17796. * It is enable to manage the different groups as well as the different necessary sort functions.
  17797. * This should not be used directly aside of the few static configurations
  17798. */
  17799. export class RenderingManager {
  17800. /**
  17801. * The max id used for rendering groups (not included)
  17802. */
  17803. static MAX_RENDERINGGROUPS: number;
  17804. /**
  17805. * The min id used for rendering groups (included)
  17806. */
  17807. static MIN_RENDERINGGROUPS: number;
  17808. /**
  17809. * Used to globally prevent autoclearing scenes.
  17810. */
  17811. static AUTOCLEAR: boolean;
  17812. /**
  17813. * @hidden
  17814. */
  17815. _useSceneAutoClearSetup: boolean;
  17816. private _scene;
  17817. private _renderingGroups;
  17818. private _depthStencilBufferAlreadyCleaned;
  17819. private _autoClearDepthStencil;
  17820. private _customOpaqueSortCompareFn;
  17821. private _customAlphaTestSortCompareFn;
  17822. private _customTransparentSortCompareFn;
  17823. private _renderingGroupInfo;
  17824. /**
  17825. * Instantiates a new rendering group for a particular scene
  17826. * @param scene Defines the scene the groups belongs to
  17827. */
  17828. constructor(scene: Scene);
  17829. private _clearDepthStencilBuffer;
  17830. /**
  17831. * Renders the entire managed groups. This is used by the scene or the different rennder targets.
  17832. * @hidden
  17833. */
  17834. render(customRenderFunction: Nullable<(opaqueSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>) => void>, activeMeshes: Nullable<AbstractMesh[]>, renderParticles: boolean, renderSprites: boolean): void;
  17835. /**
  17836. * Resets the different information of the group to prepare a new frame
  17837. * @hidden
  17838. */
  17839. reset(): void;
  17840. /**
  17841. * Dispose and release the group and its associated resources.
  17842. * @hidden
  17843. */
  17844. dispose(): void;
  17845. /**
  17846. * Clear the info related to rendering groups preventing retention points during dispose.
  17847. */
  17848. freeRenderingGroups(): void;
  17849. private _prepareRenderingGroup;
  17850. /**
  17851. * Add a sprite manager to the rendering manager in order to render it this frame.
  17852. * @param spriteManager Define the sprite manager to render
  17853. */
  17854. dispatchSprites(spriteManager: ISpriteManager): void;
  17855. /**
  17856. * Add a particle system to the rendering manager in order to render it this frame.
  17857. * @param particleSystem Define the particle system to render
  17858. */
  17859. dispatchParticles(particleSystem: IParticleSystem): void;
  17860. /**
  17861. * Add a submesh to the manager in order to render it this frame
  17862. * @param subMesh The submesh to dispatch
  17863. * @param mesh Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  17864. * @param material Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  17865. */
  17866. dispatch(subMesh: SubMesh, mesh?: AbstractMesh, material?: Nullable<Material>): void;
  17867. /**
  17868. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  17869. * This allowed control for front to back rendering or reversly depending of the special needs.
  17870. *
  17871. * @param renderingGroupId The rendering group id corresponding to its index
  17872. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  17873. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  17874. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  17875. */
  17876. 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;
  17877. /**
  17878. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  17879. *
  17880. * @param renderingGroupId The rendering group id corresponding to its index
  17881. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  17882. * @param depth Automatically clears depth between groups if true and autoClear is true.
  17883. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  17884. */
  17885. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  17886. /**
  17887. * Gets the current auto clear configuration for one rendering group of the rendering
  17888. * manager.
  17889. * @param index the rendering group index to get the information for
  17890. * @returns The auto clear setup for the requested rendering group
  17891. */
  17892. getAutoClearDepthStencilSetup(index: number): IRenderingManagerAutoClearSetup;
  17893. }
  17894. }
  17895. declare module "babylonjs/Lights/Shadows/shadowGenerator" {
  17896. import { SmartArray } from "babylonjs/Misc/smartArray";
  17897. import { Nullable } from "babylonjs/types";
  17898. import { Scene } from "babylonjs/scene";
  17899. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  17900. import { SubMesh } from "babylonjs/Meshes/subMesh";
  17901. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  17902. import { Mesh } from "babylonjs/Meshes/mesh";
  17903. import { IShadowLight } from "babylonjs/Lights/shadowLight";
  17904. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  17905. import { Effect } from "babylonjs/Materials/effect";
  17906. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  17907. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  17908. import "babylonjs/Shaders/shadowMap.fragment";
  17909. import "babylonjs/Shaders/shadowMap.vertex";
  17910. import "babylonjs/Shaders/depthBoxBlur.fragment";
  17911. import "babylonjs/Shaders/ShadersInclude/shadowMapFragmentSoftTransparentShadow";
  17912. import { Observable } from "babylonjs/Misc/observable";
  17913. /**
  17914. * Defines the options associated with the creation of a custom shader for a shadow generator.
  17915. */
  17916. export interface ICustomShaderOptions {
  17917. /**
  17918. * Gets or sets the custom shader name to use
  17919. */
  17920. shaderName: string;
  17921. /**
  17922. * The list of attribute names used in the shader
  17923. */
  17924. attributes?: string[];
  17925. /**
  17926. * The list of unifrom names used in the shader
  17927. */
  17928. uniforms?: string[];
  17929. /**
  17930. * The list of sampler names used in the shader
  17931. */
  17932. samplers?: string[];
  17933. /**
  17934. * The list of defines used in the shader
  17935. */
  17936. defines?: string[];
  17937. }
  17938. /**
  17939. * Interface to implement to create a shadow generator compatible with BJS.
  17940. */
  17941. export interface IShadowGenerator {
  17942. /** Gets or set the id of the shadow generator. It will be the one from the light if not defined */
  17943. id: string;
  17944. /**
  17945. * Gets the main RTT containing the shadow map (usually storing depth from the light point of view).
  17946. * @returns The render target texture if present otherwise, null
  17947. */
  17948. getShadowMap(): Nullable<RenderTargetTexture>;
  17949. /**
  17950. * Determine wheter the shadow generator is ready or not (mainly all effects and related post processes needs to be ready).
  17951. * @param subMesh The submesh we want to render in the shadow map
  17952. * @param useInstances Defines wether will draw in the map using instances
  17953. * @param isTransparent Indicates that isReady is called for a transparent subMesh
  17954. * @returns true if ready otherwise, false
  17955. */
  17956. isReady(subMesh: SubMesh, useInstances: boolean, isTransparent: boolean): boolean;
  17957. /**
  17958. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  17959. * @param defines Defines of the material we want to update
  17960. * @param lightIndex Index of the light in the enabled light list of the material
  17961. */
  17962. prepareDefines(defines: MaterialDefines, lightIndex: number): void;
  17963. /**
  17964. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  17965. * defined in the generator but impacting the effect).
  17966. * It implies the unifroms available on the materials are the standard BJS ones.
  17967. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  17968. * @param effect The effect we are binfing the information for
  17969. */
  17970. bindShadowLight(lightIndex: string, effect: Effect): void;
  17971. /**
  17972. * Gets the transformation matrix used to project the meshes into the map from the light point of view.
  17973. * (eq to shadow prjection matrix * light transform matrix)
  17974. * @returns The transform matrix used to create the shadow map
  17975. */
  17976. getTransformMatrix(): Matrix;
  17977. /**
  17978. * Recreates the shadow map dependencies like RTT and post processes. This can be used during the switch between
  17979. * Cube and 2D textures for instance.
  17980. */
  17981. recreateShadowMap(): void;
  17982. /**
  17983. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  17984. * @param onCompiled Callback triggered at the and of the effects compilation
  17985. * @param options Sets of optional options forcing the compilation with different modes
  17986. */
  17987. forceCompilation(onCompiled?: (generator: IShadowGenerator) => void, options?: Partial<{
  17988. useInstances: boolean;
  17989. }>): void;
  17990. /**
  17991. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  17992. * @param options Sets of optional options forcing the compilation with different modes
  17993. * @returns A promise that resolves when the compilation completes
  17994. */
  17995. forceCompilationAsync(options?: Partial<{
  17996. useInstances: boolean;
  17997. }>): Promise<void>;
  17998. /**
  17999. * Serializes the shadow generator setup to a json object.
  18000. * @returns The serialized JSON object
  18001. */
  18002. serialize(): any;
  18003. /**
  18004. * Disposes the Shadow map and related Textures and effects.
  18005. */
  18006. dispose(): void;
  18007. }
  18008. /**
  18009. * Default implementation IShadowGenerator.
  18010. * This is the main object responsible of generating shadows in the framework.
  18011. * Documentation: https://doc.babylonjs.com/babylon101/shadows
  18012. */
  18013. export class ShadowGenerator implements IShadowGenerator {
  18014. /**
  18015. * Name of the shadow generator class
  18016. */
  18017. static CLASSNAME: string;
  18018. /**
  18019. * Shadow generator mode None: no filtering applied.
  18020. */
  18021. static readonly FILTER_NONE: number;
  18022. /**
  18023. * Shadow generator mode ESM: Exponential Shadow Mapping.
  18024. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  18025. */
  18026. static readonly FILTER_EXPONENTIALSHADOWMAP: number;
  18027. /**
  18028. * Shadow generator mode Poisson Sampling: Percentage Closer Filtering.
  18029. * (Multiple Tap around evenly distributed around the pixel are used to evaluate the shadow strength)
  18030. */
  18031. static readonly FILTER_POISSONSAMPLING: number;
  18032. /**
  18033. * Shadow generator mode ESM: Blurred Exponential Shadow Mapping.
  18034. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  18035. */
  18036. static readonly FILTER_BLUREXPONENTIALSHADOWMAP: number;
  18037. /**
  18038. * Shadow generator mode ESM: Exponential Shadow Mapping using the inverse of the exponential preventing
  18039. * edge artifacts on steep falloff.
  18040. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  18041. */
  18042. static readonly FILTER_CLOSEEXPONENTIALSHADOWMAP: number;
  18043. /**
  18044. * Shadow generator mode ESM: Blurred Exponential Shadow Mapping using the inverse of the exponential preventing
  18045. * edge artifacts on steep falloff.
  18046. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  18047. */
  18048. static readonly FILTER_BLURCLOSEEXPONENTIALSHADOWMAP: number;
  18049. /**
  18050. * Shadow generator mode PCF: Percentage Closer Filtering
  18051. * benefits from Webgl 2 shadow samplers. Fallback to Poisson Sampling in Webgl 1
  18052. * (https://developer.nvidia.com/gpugems/GPUGems/gpugems_ch11.html)
  18053. */
  18054. static readonly FILTER_PCF: number;
  18055. /**
  18056. * Shadow generator mode PCSS: Percentage Closering Soft Shadow.
  18057. * benefits from Webgl 2 shadow samplers. Fallback to Poisson Sampling in Webgl 1
  18058. * Contact Hardening
  18059. */
  18060. static readonly FILTER_PCSS: number;
  18061. /**
  18062. * Reserved for PCF and PCSS
  18063. * Highest Quality.
  18064. *
  18065. * Execute PCF on a 5*5 kernel improving a lot the shadow aliasing artifacts.
  18066. *
  18067. * Execute PCSS with 32 taps blocker search and 64 taps PCF.
  18068. */
  18069. static readonly QUALITY_HIGH: number;
  18070. /**
  18071. * Reserved for PCF and PCSS
  18072. * Good tradeoff for quality/perf cross devices
  18073. *
  18074. * Execute PCF on a 3*3 kernel.
  18075. *
  18076. * Execute PCSS with 16 taps blocker search and 32 taps PCF.
  18077. */
  18078. static readonly QUALITY_MEDIUM: number;
  18079. /**
  18080. * Reserved for PCF and PCSS
  18081. * The lowest quality but the fastest.
  18082. *
  18083. * Execute PCF on a 1*1 kernel.
  18084. *
  18085. * Execute PCSS with 16 taps blocker search and 16 taps PCF.
  18086. */
  18087. static readonly QUALITY_LOW: number;
  18088. /** Gets or set the id of the shadow generator. It will be the one from the light if not defined */
  18089. id: string;
  18090. /** Gets or sets the custom shader name to use */
  18091. customShaderOptions: ICustomShaderOptions;
  18092. /**
  18093. * Observable triggered before the shadow is rendered. Can be used to update internal effect state
  18094. */
  18095. onBeforeShadowMapRenderObservable: Observable<Effect>;
  18096. /**
  18097. * Observable triggered after the shadow is rendered. Can be used to restore internal effect state
  18098. */
  18099. onAfterShadowMapRenderObservable: Observable<Effect>;
  18100. /**
  18101. * Observable triggered before a mesh is rendered in the shadow map.
  18102. * Can be used to update internal effect state (that you can get from the onBeforeShadowMapRenderObservable)
  18103. */
  18104. onBeforeShadowMapRenderMeshObservable: Observable<Mesh>;
  18105. /**
  18106. * Observable triggered after a mesh is rendered in the shadow map.
  18107. * Can be used to update internal effect state (that you can get from the onAfterShadowMapRenderObservable)
  18108. */
  18109. onAfterShadowMapRenderMeshObservable: Observable<Mesh>;
  18110. protected _bias: number;
  18111. /**
  18112. * Gets the bias: offset applied on the depth preventing acnea (in light direction).
  18113. */
  18114. get bias(): number;
  18115. /**
  18116. * Sets the bias: offset applied on the depth preventing acnea (in light direction).
  18117. */
  18118. set bias(bias: number);
  18119. protected _normalBias: number;
  18120. /**
  18121. * Gets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportinal to the light/normal angle).
  18122. */
  18123. get normalBias(): number;
  18124. /**
  18125. * Sets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportinal to the light/normal angle).
  18126. */
  18127. set normalBias(normalBias: number);
  18128. protected _blurBoxOffset: number;
  18129. /**
  18130. * Gets the blur box offset: offset applied during the blur pass.
  18131. * Only useful if useKernelBlur = false
  18132. */
  18133. get blurBoxOffset(): number;
  18134. /**
  18135. * Sets the blur box offset: offset applied during the blur pass.
  18136. * Only useful if useKernelBlur = false
  18137. */
  18138. set blurBoxOffset(value: number);
  18139. protected _blurScale: number;
  18140. /**
  18141. * Gets the blur scale: scale of the blurred texture compared to the main shadow map.
  18142. * 2 means half of the size.
  18143. */
  18144. get blurScale(): number;
  18145. /**
  18146. * Sets the blur scale: scale of the blurred texture compared to the main shadow map.
  18147. * 2 means half of the size.
  18148. */
  18149. set blurScale(value: number);
  18150. protected _blurKernel: number;
  18151. /**
  18152. * Gets the blur kernel: kernel size of the blur pass.
  18153. * Only useful if useKernelBlur = true
  18154. */
  18155. get blurKernel(): number;
  18156. /**
  18157. * Sets the blur kernel: kernel size of the blur pass.
  18158. * Only useful if useKernelBlur = true
  18159. */
  18160. set blurKernel(value: number);
  18161. protected _useKernelBlur: boolean;
  18162. /**
  18163. * Gets whether the blur pass is a kernel blur (if true) or box blur.
  18164. * Only useful in filtered mode (useBlurExponentialShadowMap...)
  18165. */
  18166. get useKernelBlur(): boolean;
  18167. /**
  18168. * Sets whether the blur pass is a kernel blur (if true) or box blur.
  18169. * Only useful in filtered mode (useBlurExponentialShadowMap...)
  18170. */
  18171. set useKernelBlur(value: boolean);
  18172. protected _depthScale: number;
  18173. /**
  18174. * Gets the depth scale used in ESM mode.
  18175. */
  18176. get depthScale(): number;
  18177. /**
  18178. * Sets the depth scale used in ESM mode.
  18179. * This can override the scale stored on the light.
  18180. */
  18181. set depthScale(value: number);
  18182. protected _validateFilter(filter: number): number;
  18183. protected _filter: number;
  18184. /**
  18185. * Gets the current mode of the shadow generator (normal, PCF, ESM...).
  18186. * The returned value is a number equal to one of the available mode defined in ShadowMap.FILTER_x like _FILTER_NONE
  18187. */
  18188. get filter(): number;
  18189. /**
  18190. * Sets the current mode of the shadow generator (normal, PCF, ESM...).
  18191. * The returned value is a number equal to one of the available mode defined in ShadowMap.FILTER_x like _FILTER_NONE
  18192. */
  18193. set filter(value: number);
  18194. /**
  18195. * Gets if the current filter is set to Poisson Sampling.
  18196. */
  18197. get usePoissonSampling(): boolean;
  18198. /**
  18199. * Sets the current filter to Poisson Sampling.
  18200. */
  18201. set usePoissonSampling(value: boolean);
  18202. /**
  18203. * Gets if the current filter is set to ESM.
  18204. */
  18205. get useExponentialShadowMap(): boolean;
  18206. /**
  18207. * Sets the current filter is to ESM.
  18208. */
  18209. set useExponentialShadowMap(value: boolean);
  18210. /**
  18211. * Gets if the current filter is set to filtered ESM.
  18212. */
  18213. get useBlurExponentialShadowMap(): boolean;
  18214. /**
  18215. * Gets if the current filter is set to filtered ESM.
  18216. */
  18217. set useBlurExponentialShadowMap(value: boolean);
  18218. /**
  18219. * Gets if the current filter is set to "close ESM" (using the inverse of the
  18220. * exponential to prevent steep falloff artifacts).
  18221. */
  18222. get useCloseExponentialShadowMap(): boolean;
  18223. /**
  18224. * Sets the current filter to "close ESM" (using the inverse of the
  18225. * exponential to prevent steep falloff artifacts).
  18226. */
  18227. set useCloseExponentialShadowMap(value: boolean);
  18228. /**
  18229. * Gets if the current filter is set to filtered "close ESM" (using the inverse of the
  18230. * exponential to prevent steep falloff artifacts).
  18231. */
  18232. get useBlurCloseExponentialShadowMap(): boolean;
  18233. /**
  18234. * Sets the current filter to filtered "close ESM" (using the inverse of the
  18235. * exponential to prevent steep falloff artifacts).
  18236. */
  18237. set useBlurCloseExponentialShadowMap(value: boolean);
  18238. /**
  18239. * Gets if the current filter is set to "PCF" (percentage closer filtering).
  18240. */
  18241. get usePercentageCloserFiltering(): boolean;
  18242. /**
  18243. * Sets the current filter to "PCF" (percentage closer filtering).
  18244. */
  18245. set usePercentageCloserFiltering(value: boolean);
  18246. protected _filteringQuality: number;
  18247. /**
  18248. * Gets the PCF or PCSS Quality.
  18249. * Only valid if usePercentageCloserFiltering or usePercentageCloserFiltering is true.
  18250. */
  18251. get filteringQuality(): number;
  18252. /**
  18253. * Sets the PCF or PCSS Quality.
  18254. * Only valid if usePercentageCloserFiltering or usePercentageCloserFiltering is true.
  18255. */
  18256. set filteringQuality(filteringQuality: number);
  18257. /**
  18258. * Gets if the current filter is set to "PCSS" (contact hardening).
  18259. */
  18260. get useContactHardeningShadow(): boolean;
  18261. /**
  18262. * Sets the current filter to "PCSS" (contact hardening).
  18263. */
  18264. set useContactHardeningShadow(value: boolean);
  18265. protected _contactHardeningLightSizeUVRatio: number;
  18266. /**
  18267. * Gets the Light Size (in shadow map uv unit) used in PCSS to determine the blocker search area and the penumbra size.
  18268. * Using a ratio helps keeping shape stability independently of the map size.
  18269. *
  18270. * It does not account for the light projection as it was having too much
  18271. * instability during the light setup or during light position changes.
  18272. *
  18273. * Only valid if useContactHardeningShadow is true.
  18274. */
  18275. get contactHardeningLightSizeUVRatio(): number;
  18276. /**
  18277. * Sets the Light Size (in shadow map uv unit) used in PCSS to determine the blocker search area and the penumbra size.
  18278. * Using a ratio helps keeping shape stability independently of the map size.
  18279. *
  18280. * It does not account for the light projection as it was having too much
  18281. * instability during the light setup or during light position changes.
  18282. *
  18283. * Only valid if useContactHardeningShadow is true.
  18284. */
  18285. set contactHardeningLightSizeUVRatio(contactHardeningLightSizeUVRatio: number);
  18286. protected _darkness: number;
  18287. /** Gets or sets the actual darkness of a shadow */
  18288. get darkness(): number;
  18289. set darkness(value: number);
  18290. /**
  18291. * Returns the darkness value (float). This can only decrease the actual darkness of a shadow.
  18292. * 0 means strongest and 1 would means no shadow.
  18293. * @returns the darkness.
  18294. */
  18295. getDarkness(): number;
  18296. /**
  18297. * Sets the darkness value (float). This can only decrease the actual darkness of a shadow.
  18298. * @param darkness The darkness value 0 means strongest and 1 would means no shadow.
  18299. * @returns the shadow generator allowing fluent coding.
  18300. */
  18301. setDarkness(darkness: number): ShadowGenerator;
  18302. protected _transparencyShadow: boolean;
  18303. /** Gets or sets the ability to have transparent shadow */
  18304. get transparencyShadow(): boolean;
  18305. set transparencyShadow(value: boolean);
  18306. /**
  18307. * Sets the ability to have transparent shadow (boolean).
  18308. * @param transparent True if transparent else False
  18309. * @returns the shadow generator allowing fluent coding
  18310. */
  18311. setTransparencyShadow(transparent: boolean): ShadowGenerator;
  18312. /**
  18313. * Enables or disables shadows with varying strength based on the transparency
  18314. * When it is enabled, the strength of the shadow is taken equal to mesh.visibility
  18315. * If you enabled an alpha texture on your material, the alpha value red from the texture is also combined to compute the strength:
  18316. * mesh.visibility * alphaTexture.a
  18317. * Note that by definition transparencyShadow must be set to true for enableSoftTransparentShadow to work!
  18318. */
  18319. enableSoftTransparentShadow: boolean;
  18320. protected _shadowMap: Nullable<RenderTargetTexture>;
  18321. protected _shadowMap2: Nullable<RenderTargetTexture>;
  18322. /**
  18323. * Gets the main RTT containing the shadow map (usually storing depth from the light point of view).
  18324. * @returns The render target texture if present otherwise, null
  18325. */
  18326. getShadowMap(): Nullable<RenderTargetTexture>;
  18327. /**
  18328. * Gets the RTT used during rendering (can be a blurred version of the shadow map or the shadow map itself).
  18329. * @returns The render target texture if the shadow map is present otherwise, null
  18330. */
  18331. getShadowMapForRendering(): Nullable<RenderTargetTexture>;
  18332. /**
  18333. * Gets the class name of that object
  18334. * @returns "ShadowGenerator"
  18335. */
  18336. getClassName(): string;
  18337. /**
  18338. * Helper function to add a mesh and its descendants to the list of shadow casters.
  18339. * @param mesh Mesh to add
  18340. * @param includeDescendants boolean indicating if the descendants should be added. Default to true
  18341. * @returns the Shadow Generator itself
  18342. */
  18343. addShadowCaster(mesh: AbstractMesh, includeDescendants?: boolean): ShadowGenerator;
  18344. /**
  18345. * Helper function to remove a mesh and its descendants from the list of shadow casters
  18346. * @param mesh Mesh to remove
  18347. * @param includeDescendants boolean indicating if the descendants should be removed. Default to true
  18348. * @returns the Shadow Generator itself
  18349. */
  18350. removeShadowCaster(mesh: AbstractMesh, includeDescendants?: boolean): ShadowGenerator;
  18351. /**
  18352. * Controls the extent to which the shadows fade out at the edge of the frustum
  18353. */
  18354. frustumEdgeFalloff: number;
  18355. protected _light: IShadowLight;
  18356. /**
  18357. * Returns the associated light object.
  18358. * @returns the light generating the shadow
  18359. */
  18360. getLight(): IShadowLight;
  18361. /**
  18362. * If true the shadow map is generated by rendering the back face of the mesh instead of the front face.
  18363. * This can help with self-shadowing as the geometry making up the back of objects is slightly offset.
  18364. * It might on the other hand introduce peter panning.
  18365. */
  18366. forceBackFacesOnly: boolean;
  18367. protected _scene: Scene;
  18368. protected _lightDirection: Vector3;
  18369. protected _effect: Effect;
  18370. protected _viewMatrix: Matrix;
  18371. protected _projectionMatrix: Matrix;
  18372. protected _transformMatrix: Matrix;
  18373. protected _cachedPosition: Vector3;
  18374. protected _cachedDirection: Vector3;
  18375. protected _cachedDefines: string;
  18376. protected _currentRenderID: number;
  18377. protected _boxBlurPostprocess: Nullable<PostProcess>;
  18378. protected _kernelBlurXPostprocess: Nullable<PostProcess>;
  18379. protected _kernelBlurYPostprocess: Nullable<PostProcess>;
  18380. protected _blurPostProcesses: PostProcess[];
  18381. protected _mapSize: number;
  18382. protected _currentFaceIndex: number;
  18383. protected _currentFaceIndexCache: number;
  18384. protected _textureType: number;
  18385. protected _defaultTextureMatrix: Matrix;
  18386. protected _storedUniqueId: Nullable<number>;
  18387. /** @hidden */
  18388. static _SceneComponentInitialization: (scene: Scene) => void;
  18389. /**
  18390. * Creates a ShadowGenerator object.
  18391. * A ShadowGenerator is the required tool to use the shadows.
  18392. * Each light casting shadows needs to use its own ShadowGenerator.
  18393. * Documentation : https://doc.babylonjs.com/babylon101/shadows
  18394. * @param mapSize The size of the texture what stores the shadows. Example : 1024.
  18395. * @param light The light object generating the shadows.
  18396. * @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.
  18397. */
  18398. constructor(mapSize: number, light: IShadowLight, usefulFloatFirst?: boolean);
  18399. protected _initializeGenerator(): void;
  18400. protected _createTargetRenderTexture(): void;
  18401. protected _initializeShadowMap(): void;
  18402. protected _initializeBlurRTTAndPostProcesses(): void;
  18403. protected _renderForShadowMap(opaqueSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>): void;
  18404. protected _bindCustomEffectForRenderSubMeshForShadowMap(subMesh: SubMesh, effect: Effect, matriceNames: any, mesh: AbstractMesh): void;
  18405. protected _renderSubMeshForShadowMap(subMesh: SubMesh, isTransparent?: boolean): void;
  18406. protected _applyFilterValues(): void;
  18407. /**
  18408. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  18409. * @param onCompiled Callback triggered at the and of the effects compilation
  18410. * @param options Sets of optional options forcing the compilation with different modes
  18411. */
  18412. forceCompilation(onCompiled?: (generator: IShadowGenerator) => void, options?: Partial<{
  18413. useInstances: boolean;
  18414. }>): void;
  18415. /**
  18416. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  18417. * @param options Sets of optional options forcing the compilation with different modes
  18418. * @returns A promise that resolves when the compilation completes
  18419. */
  18420. forceCompilationAsync(options?: Partial<{
  18421. useInstances: boolean;
  18422. }>): Promise<void>;
  18423. protected _isReadyCustomDefines(defines: any, subMesh: SubMesh, useInstances: boolean): void;
  18424. private _prepareShadowDefines;
  18425. /**
  18426. * Determine wheter the shadow generator is ready or not (mainly all effects and related post processes needs to be ready).
  18427. * @param subMesh The submesh we want to render in the shadow map
  18428. * @param useInstances Defines wether will draw in the map using instances
  18429. * @param isTransparent Indicates that isReady is called for a transparent subMesh
  18430. * @returns true if ready otherwise, false
  18431. */
  18432. isReady(subMesh: SubMesh, useInstances: boolean, isTransparent: boolean): boolean;
  18433. /**
  18434. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  18435. * @param defines Defines of the material we want to update
  18436. * @param lightIndex Index of the light in the enabled light list of the material
  18437. */
  18438. prepareDefines(defines: any, lightIndex: number): void;
  18439. /**
  18440. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  18441. * defined in the generator but impacting the effect).
  18442. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  18443. * @param effect The effect we are binfing the information for
  18444. */
  18445. bindShadowLight(lightIndex: string, effect: Effect): void;
  18446. /**
  18447. * Gets the transformation matrix used to project the meshes into the map from the light point of view.
  18448. * (eq to shadow prjection matrix * light transform matrix)
  18449. * @returns The transform matrix used to create the shadow map
  18450. */
  18451. getTransformMatrix(): Matrix;
  18452. /**
  18453. * Recreates the shadow map dependencies like RTT and post processes. This can be used during the switch between
  18454. * Cube and 2D textures for instance.
  18455. */
  18456. recreateShadowMap(): void;
  18457. protected _disposeBlurPostProcesses(): void;
  18458. protected _disposeRTTandPostProcesses(): void;
  18459. /**
  18460. * Disposes the ShadowGenerator.
  18461. * Returns nothing.
  18462. */
  18463. dispose(): void;
  18464. /**
  18465. * Serializes the shadow generator setup to a json object.
  18466. * @returns The serialized JSON object
  18467. */
  18468. serialize(): any;
  18469. /**
  18470. * Parses a serialized ShadowGenerator and returns a new ShadowGenerator.
  18471. * @param parsedShadowGenerator The JSON object to parse
  18472. * @param scene The scene to create the shadow map for
  18473. * @param constr A function that builds a shadow generator or undefined to create an instance of the default shadow generator
  18474. * @returns The parsed shadow generator
  18475. */
  18476. static Parse(parsedShadowGenerator: any, scene: Scene, constr?: (mapSize: number, light: IShadowLight) => ShadowGenerator): ShadowGenerator;
  18477. }
  18478. }
  18479. declare module "babylonjs/Lights/light" {
  18480. import { Nullable } from "babylonjs/types";
  18481. import { Scene } from "babylonjs/scene";
  18482. import { Vector3 } from "babylonjs/Maths/math.vector";
  18483. import { Color3 } from "babylonjs/Maths/math.color";
  18484. import { Node } from "babylonjs/node";
  18485. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  18486. import { Effect } from "babylonjs/Materials/effect";
  18487. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  18488. import { IShadowGenerator } from "babylonjs/Lights/Shadows/shadowGenerator";
  18489. /**
  18490. * Base class of all the lights in Babylon. It groups all the generic information about lights.
  18491. * Lights are used, as you would expect, to affect how meshes are seen, in terms of both illumination and colour.
  18492. * 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.
  18493. */
  18494. export abstract class Light extends Node {
  18495. /**
  18496. * Falloff Default: light is falling off following the material specification:
  18497. * standard material is using standard falloff whereas pbr material can request special falloff per materials.
  18498. */
  18499. static readonly FALLOFF_DEFAULT: number;
  18500. /**
  18501. * Falloff Physical: light is falling off following the inverse squared distance law.
  18502. */
  18503. static readonly FALLOFF_PHYSICAL: number;
  18504. /**
  18505. * Falloff gltf: light is falling off as described in the gltf moving to PBR document
  18506. * to enhance interoperability with other engines.
  18507. */
  18508. static readonly FALLOFF_GLTF: number;
  18509. /**
  18510. * Falloff Standard: light is falling off like in the standard material
  18511. * to enhance interoperability with other materials.
  18512. */
  18513. static readonly FALLOFF_STANDARD: number;
  18514. /**
  18515. * If every light affecting the material is in this lightmapMode,
  18516. * material.lightmapTexture adds or multiplies
  18517. * (depends on material.useLightmapAsShadowmap)
  18518. * after every other light calculations.
  18519. */
  18520. static readonly LIGHTMAP_DEFAULT: number;
  18521. /**
  18522. * material.lightmapTexture as only diffuse lighting from this light
  18523. * adds only specular lighting from this light
  18524. * adds dynamic shadows
  18525. */
  18526. static readonly LIGHTMAP_SPECULAR: number;
  18527. /**
  18528. * material.lightmapTexture as only lighting
  18529. * no light calculation from this light
  18530. * only adds dynamic shadows from this light
  18531. */
  18532. static readonly LIGHTMAP_SHADOWSONLY: number;
  18533. /**
  18534. * Each light type uses the default quantity according to its type:
  18535. * point/spot lights use luminous intensity
  18536. * directional lights use illuminance
  18537. */
  18538. static readonly INTENSITYMODE_AUTOMATIC: number;
  18539. /**
  18540. * lumen (lm)
  18541. */
  18542. static readonly INTENSITYMODE_LUMINOUSPOWER: number;
  18543. /**
  18544. * candela (lm/sr)
  18545. */
  18546. static readonly INTENSITYMODE_LUMINOUSINTENSITY: number;
  18547. /**
  18548. * lux (lm/m^2)
  18549. */
  18550. static readonly INTENSITYMODE_ILLUMINANCE: number;
  18551. /**
  18552. * nit (cd/m^2)
  18553. */
  18554. static readonly INTENSITYMODE_LUMINANCE: number;
  18555. /**
  18556. * Light type const id of the point light.
  18557. */
  18558. static readonly LIGHTTYPEID_POINTLIGHT: number;
  18559. /**
  18560. * Light type const id of the directional light.
  18561. */
  18562. static readonly LIGHTTYPEID_DIRECTIONALLIGHT: number;
  18563. /**
  18564. * Light type const id of the spot light.
  18565. */
  18566. static readonly LIGHTTYPEID_SPOTLIGHT: number;
  18567. /**
  18568. * Light type const id of the hemispheric light.
  18569. */
  18570. static readonly LIGHTTYPEID_HEMISPHERICLIGHT: number;
  18571. /**
  18572. * Diffuse gives the basic color to an object.
  18573. */
  18574. diffuse: Color3;
  18575. /**
  18576. * Specular produces a highlight color on an object.
  18577. * Note: This is note affecting PBR materials.
  18578. */
  18579. specular: Color3;
  18580. /**
  18581. * Defines the falloff type for this light. This lets overrriding how punctual light are
  18582. * falling off base on range or angle.
  18583. * This can be set to any values in Light.FALLOFF_x.
  18584. *
  18585. * Note: This is only useful for PBR Materials at the moment. This could be extended if required to
  18586. * other types of materials.
  18587. */
  18588. falloffType: number;
  18589. /**
  18590. * Strength of the light.
  18591. * Note: By default it is define in the framework own unit.
  18592. * Note: In PBR materials the intensityMode can be use to chose what unit the intensity is defined in.
  18593. */
  18594. intensity: number;
  18595. private _range;
  18596. protected _inverseSquaredRange: number;
  18597. /**
  18598. * Defines how far from the source the light is impacting in scene units.
  18599. * Note: Unused in PBR material as the distance light falloff is defined following the inverse squared falloff.
  18600. */
  18601. get range(): number;
  18602. /**
  18603. * Defines how far from the source the light is impacting in scene units.
  18604. * Note: Unused in PBR material as the distance light falloff is defined following the inverse squared falloff.
  18605. */
  18606. set range(value: number);
  18607. /**
  18608. * Cached photometric scale default to 1.0 as the automatic intensity mode defaults to 1.0 for every type
  18609. * of light.
  18610. */
  18611. private _photometricScale;
  18612. private _intensityMode;
  18613. /**
  18614. * Gets the photometric scale used to interpret the intensity.
  18615. * This is only relevant with PBR Materials where the light intensity can be defined in a physical way.
  18616. */
  18617. get intensityMode(): number;
  18618. /**
  18619. * Sets the photometric scale used to interpret the intensity.
  18620. * This is only relevant with PBR Materials where the light intensity can be defined in a physical way.
  18621. */
  18622. set intensityMode(value: number);
  18623. private _radius;
  18624. /**
  18625. * Gets the light radius used by PBR Materials to simulate soft area lights.
  18626. */
  18627. get radius(): number;
  18628. /**
  18629. * sets the light radius used by PBR Materials to simulate soft area lights.
  18630. */
  18631. set radius(value: number);
  18632. private _renderPriority;
  18633. /**
  18634. * Defines the rendering priority of the lights. It can help in case of fallback or number of lights
  18635. * exceeding the number allowed of the materials.
  18636. */
  18637. renderPriority: number;
  18638. private _shadowEnabled;
  18639. /**
  18640. * Gets wether or not the shadows are enabled for this light. This can help turning off/on shadow without detaching
  18641. * the current shadow generator.
  18642. */
  18643. get shadowEnabled(): boolean;
  18644. /**
  18645. * Sets wether or not the shadows are enabled for this light. This can help turning off/on shadow without detaching
  18646. * the current shadow generator.
  18647. */
  18648. set shadowEnabled(value: boolean);
  18649. private _includedOnlyMeshes;
  18650. /**
  18651. * Gets the only meshes impacted by this light.
  18652. */
  18653. get includedOnlyMeshes(): AbstractMesh[];
  18654. /**
  18655. * Sets the only meshes impacted by this light.
  18656. */
  18657. set includedOnlyMeshes(value: AbstractMesh[]);
  18658. private _excludedMeshes;
  18659. /**
  18660. * Gets the meshes not impacted by this light.
  18661. */
  18662. get excludedMeshes(): AbstractMesh[];
  18663. /**
  18664. * Sets the meshes not impacted by this light.
  18665. */
  18666. set excludedMeshes(value: AbstractMesh[]);
  18667. private _excludeWithLayerMask;
  18668. /**
  18669. * Gets the layer id use to find what meshes are not impacted by the light.
  18670. * Inactive if 0
  18671. */
  18672. get excludeWithLayerMask(): number;
  18673. /**
  18674. * Sets the layer id use to find what meshes are not impacted by the light.
  18675. * Inactive if 0
  18676. */
  18677. set excludeWithLayerMask(value: number);
  18678. private _includeOnlyWithLayerMask;
  18679. /**
  18680. * Gets the layer id use to find what meshes are impacted by the light.
  18681. * Inactive if 0
  18682. */
  18683. get includeOnlyWithLayerMask(): number;
  18684. /**
  18685. * Sets the layer id use to find what meshes are impacted by the light.
  18686. * Inactive if 0
  18687. */
  18688. set includeOnlyWithLayerMask(value: number);
  18689. private _lightmapMode;
  18690. /**
  18691. * Gets the lightmap mode of this light (should be one of the constants defined by Light.LIGHTMAP_x)
  18692. */
  18693. get lightmapMode(): number;
  18694. /**
  18695. * Sets the lightmap mode of this light (should be one of the constants defined by Light.LIGHTMAP_x)
  18696. */
  18697. set lightmapMode(value: number);
  18698. /**
  18699. * Shadow generator associted to the light.
  18700. * @hidden Internal use only.
  18701. */
  18702. _shadowGenerator: Nullable<IShadowGenerator>;
  18703. /**
  18704. * @hidden Internal use only.
  18705. */
  18706. _excludedMeshesIds: string[];
  18707. /**
  18708. * @hidden Internal use only.
  18709. */
  18710. _includedOnlyMeshesIds: string[];
  18711. /**
  18712. * The current light unifom buffer.
  18713. * @hidden Internal use only.
  18714. */
  18715. _uniformBuffer: UniformBuffer;
  18716. /** @hidden */
  18717. _renderId: number;
  18718. /**
  18719. * Creates a Light object in the scene.
  18720. * Documentation : https://doc.babylonjs.com/babylon101/lights
  18721. * @param name The firendly name of the light
  18722. * @param scene The scene the light belongs too
  18723. */
  18724. constructor(name: string, scene: Scene);
  18725. protected abstract _buildUniformLayout(): void;
  18726. /**
  18727. * Sets the passed Effect "effect" with the Light information.
  18728. * @param effect The effect to update
  18729. * @param lightIndex The index of the light in the effect to update
  18730. * @returns The light
  18731. */
  18732. abstract transferToEffect(effect: Effect, lightIndex: string): Light;
  18733. /**
  18734. * Sets the passed Effect "effect" with the Light textures.
  18735. * @param effect The effect to update
  18736. * @param lightIndex The index of the light in the effect to update
  18737. * @returns The light
  18738. */
  18739. transferTexturesToEffect(effect: Effect, lightIndex: string): Light;
  18740. /**
  18741. * Binds the lights information from the scene to the effect for the given mesh.
  18742. * @param lightIndex Light index
  18743. * @param scene The scene where the light belongs to
  18744. * @param effect The effect we are binding the data to
  18745. * @param useSpecular Defines if specular is supported
  18746. * @param rebuildInParallel Specifies whether the shader is rebuilding in parallel
  18747. */
  18748. _bindLight(lightIndex: number, scene: Scene, effect: Effect, useSpecular: boolean, rebuildInParallel?: boolean): void;
  18749. /**
  18750. * Sets the passed Effect "effect" with the Light information.
  18751. * @param effect The effect to update
  18752. * @param lightDataUniformName The uniform used to store light data (position or direction)
  18753. * @returns The light
  18754. */
  18755. abstract transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): Light;
  18756. /**
  18757. * Returns the string "Light".
  18758. * @returns the class name
  18759. */
  18760. getClassName(): string;
  18761. /** @hidden */
  18762. readonly _isLight: boolean;
  18763. /**
  18764. * Converts the light information to a readable string for debug purpose.
  18765. * @param fullDetails Supports for multiple levels of logging within scene loading
  18766. * @returns the human readable light info
  18767. */
  18768. toString(fullDetails?: boolean): string;
  18769. /** @hidden */
  18770. protected _syncParentEnabledState(): void;
  18771. /**
  18772. * Set the enabled state of this node.
  18773. * @param value - the new enabled state
  18774. */
  18775. setEnabled(value: boolean): void;
  18776. /**
  18777. * Returns the Light associated shadow generator if any.
  18778. * @return the associated shadow generator.
  18779. */
  18780. getShadowGenerator(): Nullable<IShadowGenerator>;
  18781. /**
  18782. * Returns a Vector3, the absolute light position in the World.
  18783. * @returns the world space position of the light
  18784. */
  18785. getAbsolutePosition(): Vector3;
  18786. /**
  18787. * Specifies if the light will affect the passed mesh.
  18788. * @param mesh The mesh to test against the light
  18789. * @return true the mesh is affected otherwise, false.
  18790. */
  18791. canAffectMesh(mesh: AbstractMesh): boolean;
  18792. /**
  18793. * Sort function to order lights for rendering.
  18794. * @param a First Light object to compare to second.
  18795. * @param b Second Light object to compare first.
  18796. * @return -1 to reduce's a's index relative to be, 0 for no change, 1 to increase a's index relative to b.
  18797. */
  18798. static CompareLightsPriority(a: Light, b: Light): number;
  18799. /**
  18800. * Releases resources associated with this node.
  18801. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  18802. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  18803. */
  18804. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  18805. /**
  18806. * Returns the light type ID (integer).
  18807. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  18808. */
  18809. getTypeID(): number;
  18810. /**
  18811. * Returns the intensity scaled by the Photometric Scale according to the light type and intensity mode.
  18812. * @returns the scaled intensity in intensity mode unit
  18813. */
  18814. getScaledIntensity(): number;
  18815. /**
  18816. * Returns a new Light object, named "name", from the current one.
  18817. * @param name The name of the cloned light
  18818. * @param newParent The parent of this light, if it has one
  18819. * @returns the new created light
  18820. */
  18821. clone(name: string, newParent?: Nullable<Node>): Nullable<Light>;
  18822. /**
  18823. * Serializes the current light into a Serialization object.
  18824. * @returns the serialized object.
  18825. */
  18826. serialize(): any;
  18827. /**
  18828. * Creates a new typed light from the passed type (integer) : point light = 0, directional light = 1, spot light = 2, hemispheric light = 3.
  18829. * This new light is named "name" and added to the passed scene.
  18830. * @param type Type according to the types available in Light.LIGHTTYPEID_x
  18831. * @param name The friendly name of the light
  18832. * @param scene The scene the new light will belong to
  18833. * @returns the constructor function
  18834. */
  18835. static GetConstructorFromName(type: number, name: string, scene: Scene): Nullable<() => Light>;
  18836. /**
  18837. * Parses the passed "parsedLight" and returns a new instanced Light from this parsing.
  18838. * @param parsedLight The JSON representation of the light
  18839. * @param scene The scene to create the parsed light in
  18840. * @returns the created light after parsing
  18841. */
  18842. static Parse(parsedLight: any, scene: Scene): Nullable<Light>;
  18843. private _hookArrayForExcluded;
  18844. private _hookArrayForIncludedOnly;
  18845. private _resyncMeshes;
  18846. /**
  18847. * Forces the meshes to update their light related information in their rendering used effects
  18848. * @hidden Internal Use Only
  18849. */
  18850. _markMeshesAsLightDirty(): void;
  18851. /**
  18852. * Recomputes the cached photometric scale if needed.
  18853. */
  18854. private _computePhotometricScale;
  18855. /**
  18856. * Returns the Photometric Scale according to the light type and intensity mode.
  18857. */
  18858. private _getPhotometricScale;
  18859. /**
  18860. * Reorder the light in the scene according to their defined priority.
  18861. * @hidden Internal Use Only
  18862. */
  18863. _reorderLightsInScene(): void;
  18864. /**
  18865. * Prepares the list of defines specific to the light type.
  18866. * @param defines the list of defines
  18867. * @param lightIndex defines the index of the light for the effect
  18868. */
  18869. abstract prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  18870. }
  18871. }
  18872. declare module "babylonjs/Cameras/targetCamera" {
  18873. import { Nullable } from "babylonjs/types";
  18874. import { Camera } from "babylonjs/Cameras/camera";
  18875. import { Scene } from "babylonjs/scene";
  18876. import { Quaternion, Matrix, Vector3, Vector2 } from "babylonjs/Maths/math.vector";
  18877. /**
  18878. * A target camera takes a mesh or position as a target and continues to look at it while it moves.
  18879. * This is the base of the follow, arc rotate cameras and Free camera
  18880. * @see https://doc.babylonjs.com/features/cameras
  18881. */
  18882. export class TargetCamera extends Camera {
  18883. private static _RigCamTransformMatrix;
  18884. private static _TargetTransformMatrix;
  18885. private static _TargetFocalPoint;
  18886. private _tmpUpVector;
  18887. private _tmpTargetVector;
  18888. /**
  18889. * Define the current direction the camera is moving to
  18890. */
  18891. cameraDirection: Vector3;
  18892. /**
  18893. * Define the current rotation the camera is rotating to
  18894. */
  18895. cameraRotation: Vector2;
  18896. /** Gets or sets a boolean indicating that the scaling of the parent hierarchy will not be taken in account by the camera */
  18897. ignoreParentScaling: boolean;
  18898. /**
  18899. * When set, the up vector of the camera will be updated by the rotation of the camera
  18900. */
  18901. updateUpVectorFromRotation: boolean;
  18902. private _tmpQuaternion;
  18903. /**
  18904. * Define the current rotation of the camera
  18905. */
  18906. rotation: Vector3;
  18907. /**
  18908. * Define the current rotation of the camera as a quaternion to prevent Gimbal lock
  18909. */
  18910. rotationQuaternion: Quaternion;
  18911. /**
  18912. * Define the current speed of the camera
  18913. */
  18914. speed: number;
  18915. /**
  18916. * Add constraint to the camera to prevent it to move freely in all directions and
  18917. * around all axis.
  18918. */
  18919. noRotationConstraint: boolean;
  18920. /**
  18921. * Reverses mouselook direction to 'natural' panning as opposed to traditional direct
  18922. * panning
  18923. */
  18924. invertRotation: boolean;
  18925. /**
  18926. * Speed multiplier for inverse camera panning
  18927. */
  18928. inverseRotationSpeed: number;
  18929. /**
  18930. * Define the current target of the camera as an object or a position.
  18931. */
  18932. lockedTarget: any;
  18933. /** @hidden */
  18934. _currentTarget: Vector3;
  18935. /** @hidden */
  18936. _initialFocalDistance: number;
  18937. /** @hidden */
  18938. _viewMatrix: Matrix;
  18939. /** @hidden */
  18940. _camMatrix: Matrix;
  18941. /** @hidden */
  18942. _cameraTransformMatrix: Matrix;
  18943. /** @hidden */
  18944. _cameraRotationMatrix: Matrix;
  18945. /** @hidden */
  18946. _referencePoint: Vector3;
  18947. /** @hidden */
  18948. _transformedReferencePoint: Vector3;
  18949. /** @hidden */
  18950. _reset: () => void;
  18951. private _defaultUp;
  18952. /**
  18953. * Instantiates a target camera that takes a mesh or position as a target and continues to look at it while it moves.
  18954. * This is the base of the follow, arc rotate cameras and Free camera
  18955. * @see https://doc.babylonjs.com/features/cameras
  18956. * @param name Defines the name of the camera in the scene
  18957. * @param position Defines the start position of the camera in the scene
  18958. * @param scene Defines the scene the camera belongs to
  18959. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  18960. */
  18961. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  18962. /**
  18963. * Gets the position in front of the camera at a given distance.
  18964. * @param distance The distance from the camera we want the position to be
  18965. * @returns the position
  18966. */
  18967. getFrontPosition(distance: number): Vector3;
  18968. /** @hidden */
  18969. _getLockedTargetPosition(): Nullable<Vector3>;
  18970. private _storedPosition;
  18971. private _storedRotation;
  18972. private _storedRotationQuaternion;
  18973. /**
  18974. * Store current camera state of the camera (fov, position, rotation, etc..)
  18975. * @returns the camera
  18976. */
  18977. storeState(): Camera;
  18978. /**
  18979. * Restored camera state. You must call storeState() first
  18980. * @returns whether it was successful or not
  18981. * @hidden
  18982. */
  18983. _restoreStateValues(): boolean;
  18984. /** @hidden */
  18985. _initCache(): void;
  18986. /** @hidden */
  18987. _updateCache(ignoreParentClass?: boolean): void;
  18988. /** @hidden */
  18989. _isSynchronizedViewMatrix(): boolean;
  18990. /** @hidden */
  18991. _computeLocalCameraSpeed(): number;
  18992. /**
  18993. * Defines the target the camera should look at.
  18994. * @param target Defines the new target as a Vector or a mesh
  18995. */
  18996. setTarget(target: Vector3): void;
  18997. /**
  18998. * Defines the target point of the camera.
  18999. * The camera looks towards it form the radius distance.
  19000. */
  19001. get target(): Vector3;
  19002. set target(value: Vector3);
  19003. /**
  19004. * Return the current target position of the camera. This value is expressed in local space.
  19005. * @returns the target position
  19006. */
  19007. getTarget(): Vector3;
  19008. /** @hidden */
  19009. _decideIfNeedsToMove(): boolean;
  19010. /** @hidden */
  19011. _updatePosition(): void;
  19012. /** @hidden */
  19013. _checkInputs(): void;
  19014. protected _updateCameraRotationMatrix(): void;
  19015. /**
  19016. * 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)
  19017. * @returns the current camera
  19018. */
  19019. private _rotateUpVectorWithCameraRotationMatrix;
  19020. private _cachedRotationZ;
  19021. private _cachedQuaternionRotationZ;
  19022. /** @hidden */
  19023. _getViewMatrix(): Matrix;
  19024. protected _computeViewMatrix(position: Vector3, target: Vector3, up: Vector3): void;
  19025. /**
  19026. * @hidden
  19027. */
  19028. createRigCamera(name: string, cameraIndex: number): Nullable<Camera>;
  19029. /**
  19030. * @hidden
  19031. */
  19032. _updateRigCameras(): void;
  19033. private _getRigCamPositionAndTarget;
  19034. /**
  19035. * Gets the current object class name.
  19036. * @return the class name
  19037. */
  19038. getClassName(): string;
  19039. }
  19040. }
  19041. declare module "babylonjs/Events/keyboardEvents" {
  19042. /**
  19043. * Gather the list of keyboard event types as constants.
  19044. */
  19045. export class KeyboardEventTypes {
  19046. /**
  19047. * The keydown event is fired when a key becomes active (pressed).
  19048. */
  19049. static readonly KEYDOWN: number;
  19050. /**
  19051. * The keyup event is fired when a key has been released.
  19052. */
  19053. static readonly KEYUP: number;
  19054. }
  19055. /**
  19056. * This class is used to store keyboard related info for the onKeyboardObservable event.
  19057. */
  19058. export class KeyboardInfo {
  19059. /**
  19060. * Defines the type of event (KeyboardEventTypes)
  19061. */
  19062. type: number;
  19063. /**
  19064. * Defines the related dom event
  19065. */
  19066. event: KeyboardEvent;
  19067. /**
  19068. * Instantiates a new keyboard info.
  19069. * This class is used to store keyboard related info for the onKeyboardObservable event.
  19070. * @param type Defines the type of event (KeyboardEventTypes)
  19071. * @param event Defines the related dom event
  19072. */
  19073. constructor(
  19074. /**
  19075. * Defines the type of event (KeyboardEventTypes)
  19076. */
  19077. type: number,
  19078. /**
  19079. * Defines the related dom event
  19080. */
  19081. event: KeyboardEvent);
  19082. }
  19083. /**
  19084. * This class is used to store keyboard related info for the onPreKeyboardObservable event.
  19085. * Set the skipOnKeyboardObservable property to true if you want the engine to stop any process after this event is triggered, even not calling onKeyboardObservable
  19086. */
  19087. export class KeyboardInfoPre extends KeyboardInfo {
  19088. /**
  19089. * Defines the type of event (KeyboardEventTypes)
  19090. */
  19091. type: number;
  19092. /**
  19093. * Defines the related dom event
  19094. */
  19095. event: KeyboardEvent;
  19096. /**
  19097. * Defines whether the engine should skip the next onKeyboardObservable associated to this pre.
  19098. */
  19099. skipOnPointerObservable: boolean;
  19100. /**
  19101. * Instantiates a new keyboard pre info.
  19102. * This class is used to store keyboard related info for the onPreKeyboardObservable event.
  19103. * @param type Defines the type of event (KeyboardEventTypes)
  19104. * @param event Defines the related dom event
  19105. */
  19106. constructor(
  19107. /**
  19108. * Defines the type of event (KeyboardEventTypes)
  19109. */
  19110. type: number,
  19111. /**
  19112. * Defines the related dom event
  19113. */
  19114. event: KeyboardEvent);
  19115. }
  19116. }
  19117. declare module "babylonjs/Cameras/Inputs/freeCameraKeyboardMoveInput" {
  19118. import { Nullable } from "babylonjs/types";
  19119. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  19120. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  19121. /**
  19122. * Manage the keyboard inputs to control the movement of a free camera.
  19123. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  19124. */
  19125. export class FreeCameraKeyboardMoveInput implements ICameraInput<FreeCamera> {
  19126. /**
  19127. * Defines the camera the input is attached to.
  19128. */
  19129. camera: FreeCamera;
  19130. /**
  19131. * Gets or Set the list of keyboard keys used to control the forward move of the camera.
  19132. */
  19133. keysUp: number[];
  19134. /**
  19135. * Gets or Set the list of keyboard keys used to control the upward move of the camera.
  19136. */
  19137. keysUpward: number[];
  19138. /**
  19139. * Gets or Set the list of keyboard keys used to control the backward move of the camera.
  19140. */
  19141. keysDown: number[];
  19142. /**
  19143. * Gets or Set the list of keyboard keys used to control the downward move of the camera.
  19144. */
  19145. keysDownward: number[];
  19146. /**
  19147. * Gets or Set the list of keyboard keys used to control the left strafe move of the camera.
  19148. */
  19149. keysLeft: number[];
  19150. /**
  19151. * Gets or Set the list of keyboard keys used to control the right strafe move of the camera.
  19152. */
  19153. keysRight: number[];
  19154. private _keys;
  19155. private _onCanvasBlurObserver;
  19156. private _onKeyboardObserver;
  19157. private _engine;
  19158. private _scene;
  19159. /**
  19160. * Attach the input controls to a specific dom element to get the input from.
  19161. * @param element Defines the element the controls should be listened from
  19162. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  19163. */
  19164. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  19165. /**
  19166. * Detach the current controls from the specified dom element.
  19167. * @param element Defines the element to stop listening the inputs from
  19168. */
  19169. detachControl(element: Nullable<HTMLElement>): void;
  19170. /**
  19171. * Update the current camera state depending on the inputs that have been used this frame.
  19172. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  19173. */
  19174. checkInputs(): void;
  19175. /**
  19176. * Gets the class name of the current intput.
  19177. * @returns the class name
  19178. */
  19179. getClassName(): string;
  19180. /** @hidden */
  19181. _onLostFocus(): void;
  19182. /**
  19183. * Get the friendly name associated with the input class.
  19184. * @returns the input friendly name
  19185. */
  19186. getSimpleName(): string;
  19187. }
  19188. }
  19189. declare module "babylonjs/Events/pointerEvents" {
  19190. import { Nullable } from "babylonjs/types";
  19191. import { Vector2 } from "babylonjs/Maths/math.vector";
  19192. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  19193. import { Ray } from "babylonjs/Culling/ray";
  19194. /**
  19195. * Gather the list of pointer event types as constants.
  19196. */
  19197. export class PointerEventTypes {
  19198. /**
  19199. * 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.
  19200. */
  19201. static readonly POINTERDOWN: number;
  19202. /**
  19203. * The pointerup event is fired when a pointer is no longer active.
  19204. */
  19205. static readonly POINTERUP: number;
  19206. /**
  19207. * The pointermove event is fired when a pointer changes coordinates.
  19208. */
  19209. static readonly POINTERMOVE: number;
  19210. /**
  19211. * The pointerwheel event is fired when a mouse wheel has been rotated.
  19212. */
  19213. static readonly POINTERWHEEL: number;
  19214. /**
  19215. * The pointerpick event is fired when a mesh or sprite has been picked by the pointer.
  19216. */
  19217. static readonly POINTERPICK: number;
  19218. /**
  19219. * The pointertap event is fired when a the object has been touched and released without drag.
  19220. */
  19221. static readonly POINTERTAP: number;
  19222. /**
  19223. * The pointerdoubletap event is fired when a the object has been touched and released twice without drag.
  19224. */
  19225. static readonly POINTERDOUBLETAP: number;
  19226. }
  19227. /**
  19228. * Base class of pointer info types.
  19229. */
  19230. export class PointerInfoBase {
  19231. /**
  19232. * Defines the type of event (PointerEventTypes)
  19233. */
  19234. type: number;
  19235. /**
  19236. * Defines the related dom event
  19237. */
  19238. event: PointerEvent | MouseWheelEvent;
  19239. /**
  19240. * Instantiates the base class of pointers info.
  19241. * @param type Defines the type of event (PointerEventTypes)
  19242. * @param event Defines the related dom event
  19243. */
  19244. constructor(
  19245. /**
  19246. * Defines the type of event (PointerEventTypes)
  19247. */
  19248. type: number,
  19249. /**
  19250. * Defines the related dom event
  19251. */
  19252. event: PointerEvent | MouseWheelEvent);
  19253. }
  19254. /**
  19255. * This class is used to store pointer related info for the onPrePointerObservable event.
  19256. * Set the skipOnPointerObservable property to true if you want the engine to stop any process after this event is triggered, even not calling onPointerObservable
  19257. */
  19258. export class PointerInfoPre extends PointerInfoBase {
  19259. /**
  19260. * Ray from a pointer if availible (eg. 6dof controller)
  19261. */
  19262. ray: Nullable<Ray>;
  19263. /**
  19264. * Defines the local position of the pointer on the canvas.
  19265. */
  19266. localPosition: Vector2;
  19267. /**
  19268. * Defines whether the engine should skip the next OnPointerObservable associated to this pre.
  19269. */
  19270. skipOnPointerObservable: boolean;
  19271. /**
  19272. * Instantiates a PointerInfoPre to store pointer related info to the onPrePointerObservable event.
  19273. * @param type Defines the type of event (PointerEventTypes)
  19274. * @param event Defines the related dom event
  19275. * @param localX Defines the local x coordinates of the pointer when the event occured
  19276. * @param localY Defines the local y coordinates of the pointer when the event occured
  19277. */
  19278. constructor(type: number, event: PointerEvent | MouseWheelEvent, localX: number, localY: number);
  19279. }
  19280. /**
  19281. * This type contains all the data related to a pointer event in Babylon.js.
  19282. * 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.
  19283. */
  19284. export class PointerInfo extends PointerInfoBase {
  19285. /**
  19286. * Defines the picking info associated to the info (if any)\
  19287. */
  19288. pickInfo: Nullable<PickingInfo>;
  19289. /**
  19290. * Instantiates a PointerInfo to store pointer related info to the onPointerObservable event.
  19291. * @param type Defines the type of event (PointerEventTypes)
  19292. * @param event Defines the related dom event
  19293. * @param pickInfo Defines the picking info associated to the info (if any)\
  19294. */
  19295. constructor(type: number, event: PointerEvent | MouseWheelEvent,
  19296. /**
  19297. * Defines the picking info associated to the info (if any)\
  19298. */
  19299. pickInfo: Nullable<PickingInfo>);
  19300. }
  19301. /**
  19302. * Data relating to a touch event on the screen.
  19303. */
  19304. export interface PointerTouch {
  19305. /**
  19306. * X coordinate of touch.
  19307. */
  19308. x: number;
  19309. /**
  19310. * Y coordinate of touch.
  19311. */
  19312. y: number;
  19313. /**
  19314. * Id of touch. Unique for each finger.
  19315. */
  19316. pointerId: number;
  19317. /**
  19318. * Event type passed from DOM.
  19319. */
  19320. type: any;
  19321. }
  19322. }
  19323. declare module "babylonjs/Cameras/Inputs/freeCameraMouseInput" {
  19324. import { Observable } from "babylonjs/Misc/observable";
  19325. import { Nullable } from "babylonjs/types";
  19326. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  19327. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  19328. /**
  19329. * Manage the mouse inputs to control the movement of a free camera.
  19330. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  19331. */
  19332. export class FreeCameraMouseInput implements ICameraInput<FreeCamera> {
  19333. /**
  19334. * Define if touch is enabled in the mouse input
  19335. */
  19336. touchEnabled: boolean;
  19337. /**
  19338. * Defines the camera the input is attached to.
  19339. */
  19340. camera: FreeCamera;
  19341. /**
  19342. * Defines the buttons associated with the input to handle camera move.
  19343. */
  19344. buttons: number[];
  19345. /**
  19346. * Defines the pointer angular sensibility along the X and Y axis or how fast is the camera rotating.
  19347. */
  19348. angularSensibility: number;
  19349. private _pointerInput;
  19350. private _onMouseMove;
  19351. private _observer;
  19352. private previousPosition;
  19353. /**
  19354. * Observable for when a pointer move event occurs containing the move offset
  19355. */
  19356. onPointerMovedObservable: Observable<{
  19357. offsetX: number;
  19358. offsetY: number;
  19359. }>;
  19360. /**
  19361. * @hidden
  19362. * If the camera should be rotated automatically based on pointer movement
  19363. */
  19364. _allowCameraRotation: boolean;
  19365. /**
  19366. * Manage the mouse inputs to control the movement of a free camera.
  19367. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  19368. * @param touchEnabled Defines if touch is enabled or not
  19369. */
  19370. constructor(
  19371. /**
  19372. * Define if touch is enabled in the mouse input
  19373. */
  19374. touchEnabled?: boolean);
  19375. /**
  19376. * Attach the input controls to a specific dom element to get the input from.
  19377. * @param element Defines the element the controls should be listened from
  19378. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  19379. */
  19380. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  19381. /**
  19382. * Called on JS contextmenu event.
  19383. * Override this method to provide functionality.
  19384. */
  19385. protected onContextMenu(evt: PointerEvent): void;
  19386. /**
  19387. * Detach the current controls from the specified dom element.
  19388. * @param element Defines the element to stop listening the inputs from
  19389. */
  19390. detachControl(element: Nullable<HTMLElement>): void;
  19391. /**
  19392. * Gets the class name of the current intput.
  19393. * @returns the class name
  19394. */
  19395. getClassName(): string;
  19396. /**
  19397. * Get the friendly name associated with the input class.
  19398. * @returns the input friendly name
  19399. */
  19400. getSimpleName(): string;
  19401. }
  19402. }
  19403. declare module "babylonjs/Cameras/Inputs/freeCameraTouchInput" {
  19404. import { Nullable } from "babylonjs/types";
  19405. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  19406. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  19407. /**
  19408. * Manage the touch inputs to control the movement of a free camera.
  19409. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  19410. */
  19411. export class FreeCameraTouchInput implements ICameraInput<FreeCamera> {
  19412. /**
  19413. * Define if mouse events can be treated as touch events
  19414. */
  19415. allowMouse: boolean;
  19416. /**
  19417. * Defines the camera the input is attached to.
  19418. */
  19419. camera: FreeCamera;
  19420. /**
  19421. * Defines the touch sensibility for rotation.
  19422. * The higher the faster.
  19423. */
  19424. touchAngularSensibility: number;
  19425. /**
  19426. * Defines the touch sensibility for move.
  19427. * The higher the faster.
  19428. */
  19429. touchMoveSensibility: number;
  19430. private _offsetX;
  19431. private _offsetY;
  19432. private _pointerPressed;
  19433. private _pointerInput;
  19434. private _observer;
  19435. private _onLostFocus;
  19436. /**
  19437. * Manage the touch inputs to control the movement of a free camera.
  19438. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  19439. * @param allowMouse Defines if mouse events can be treated as touch events
  19440. */
  19441. constructor(
  19442. /**
  19443. * Define if mouse events can be treated as touch events
  19444. */
  19445. allowMouse?: boolean);
  19446. /**
  19447. * Attach the input controls to a specific dom element to get the input from.
  19448. * @param element Defines the element the controls should be listened from
  19449. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  19450. */
  19451. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  19452. /**
  19453. * Detach the current controls from the specified dom element.
  19454. * @param element Defines the element to stop listening the inputs from
  19455. */
  19456. detachControl(element: Nullable<HTMLElement>): void;
  19457. /**
  19458. * Update the current camera state depending on the inputs that have been used this frame.
  19459. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  19460. */
  19461. checkInputs(): void;
  19462. /**
  19463. * Gets the class name of the current intput.
  19464. * @returns the class name
  19465. */
  19466. getClassName(): string;
  19467. /**
  19468. * Get the friendly name associated with the input class.
  19469. * @returns the input friendly name
  19470. */
  19471. getSimpleName(): string;
  19472. }
  19473. }
  19474. declare module "babylonjs/Cameras/freeCameraInputsManager" {
  19475. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  19476. import { CameraInputsManager } from "babylonjs/Cameras/cameraInputsManager";
  19477. import { FreeCameraMouseInput } from "babylonjs/Cameras/Inputs/freeCameraMouseInput";
  19478. import { Nullable } from "babylonjs/types";
  19479. /**
  19480. * Default Inputs manager for the FreeCamera.
  19481. * It groups all the default supported inputs for ease of use.
  19482. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  19483. */
  19484. export class FreeCameraInputsManager extends CameraInputsManager<FreeCamera> {
  19485. /**
  19486. * @hidden
  19487. */
  19488. _mouseInput: Nullable<FreeCameraMouseInput>;
  19489. /**
  19490. * Instantiates a new FreeCameraInputsManager.
  19491. * @param camera Defines the camera the inputs belong to
  19492. */
  19493. constructor(camera: FreeCamera);
  19494. /**
  19495. * Add keyboard input support to the input manager.
  19496. * @returns the current input manager
  19497. */
  19498. addKeyboard(): FreeCameraInputsManager;
  19499. /**
  19500. * Add mouse input support to the input manager.
  19501. * @param touchEnabled if the FreeCameraMouseInput should support touch (default: true)
  19502. * @returns the current input manager
  19503. */
  19504. addMouse(touchEnabled?: boolean): FreeCameraInputsManager;
  19505. /**
  19506. * Removes the mouse input support from the manager
  19507. * @returns the current input manager
  19508. */
  19509. removeMouse(): FreeCameraInputsManager;
  19510. /**
  19511. * Add touch input support to the input manager.
  19512. * @returns the current input manager
  19513. */
  19514. addTouch(): FreeCameraInputsManager;
  19515. /**
  19516. * Remove all attached input methods from a camera
  19517. */
  19518. clear(): void;
  19519. }
  19520. }
  19521. declare module "babylonjs/Cameras/freeCamera" {
  19522. import { Vector3 } from "babylonjs/Maths/math.vector";
  19523. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  19524. import { Scene } from "babylonjs/scene";
  19525. import { TargetCamera } from "babylonjs/Cameras/targetCamera";
  19526. import { FreeCameraInputsManager } from "babylonjs/Cameras/freeCameraInputsManager";
  19527. /**
  19528. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  19529. * Please consider using the new UniversalCamera instead as it adds more functionality like the gamepad.
  19530. * @see https://doc.babylonjs.com/features/cameras#universal-camera
  19531. */
  19532. export class FreeCamera extends TargetCamera {
  19533. /**
  19534. * Define the collision ellipsoid of the camera.
  19535. * This is helpful to simulate a camera body like the player body around the camera
  19536. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  19537. */
  19538. ellipsoid: Vector3;
  19539. /**
  19540. * Define an offset for the position of the ellipsoid around the camera.
  19541. * This can be helpful to determine the center of the body near the gravity center of the body
  19542. * instead of its head.
  19543. */
  19544. ellipsoidOffset: Vector3;
  19545. /**
  19546. * Enable or disable collisions of the camera with the rest of the scene objects.
  19547. */
  19548. checkCollisions: boolean;
  19549. /**
  19550. * Enable or disable gravity on the camera.
  19551. */
  19552. applyGravity: boolean;
  19553. /**
  19554. * Define the input manager associated to the camera.
  19555. */
  19556. inputs: FreeCameraInputsManager;
  19557. /**
  19558. * Gets the input sensibility for a mouse input. (default is 2000.0)
  19559. * Higher values reduce sensitivity.
  19560. */
  19561. get angularSensibility(): number;
  19562. /**
  19563. * Sets the input sensibility for a mouse input. (default is 2000.0)
  19564. * Higher values reduce sensitivity.
  19565. */
  19566. set angularSensibility(value: number);
  19567. /**
  19568. * Gets or Set the list of keyboard keys used to control the forward move of the camera.
  19569. */
  19570. get keysUp(): number[];
  19571. set keysUp(value: number[]);
  19572. /**
  19573. * Gets or Set the list of keyboard keys used to control the upward move of the camera.
  19574. */
  19575. get keysUpward(): number[];
  19576. set keysUpward(value: number[]);
  19577. /**
  19578. * Gets or Set the list of keyboard keys used to control the backward move of the camera.
  19579. */
  19580. get keysDown(): number[];
  19581. set keysDown(value: number[]);
  19582. /**
  19583. * Gets or Set the list of keyboard keys used to control the downward move of the camera.
  19584. */
  19585. get keysDownward(): number[];
  19586. set keysDownward(value: number[]);
  19587. /**
  19588. * Gets or Set the list of keyboard keys used to control the left strafe move of the camera.
  19589. */
  19590. get keysLeft(): number[];
  19591. set keysLeft(value: number[]);
  19592. /**
  19593. * Gets or Set the list of keyboard keys used to control the right strafe move of the camera.
  19594. */
  19595. get keysRight(): number[];
  19596. set keysRight(value: number[]);
  19597. /**
  19598. * Event raised when the camera collide with a mesh in the scene.
  19599. */
  19600. onCollide: (collidedMesh: AbstractMesh) => void;
  19601. private _collider;
  19602. private _needMoveForGravity;
  19603. private _oldPosition;
  19604. private _diffPosition;
  19605. private _newPosition;
  19606. /** @hidden */
  19607. _localDirection: Vector3;
  19608. /** @hidden */
  19609. _transformedDirection: Vector3;
  19610. /**
  19611. * Instantiates a Free Camera.
  19612. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  19613. * Please consider using the new UniversalCamera instead as it adds more functionality like touch to this camera.
  19614. * @see https://doc.babylonjs.com/features/cameras#universal-camera
  19615. * @param name Define the name of the camera in the scene
  19616. * @param position Define the start position of the camera in the scene
  19617. * @param scene Define the scene the camera belongs to
  19618. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  19619. */
  19620. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  19621. /**
  19622. * Attached controls to the current camera.
  19623. * @param element Defines the element the controls should be listened from
  19624. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  19625. */
  19626. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  19627. /**
  19628. * Detach the current controls from the camera.
  19629. * The camera will stop reacting to inputs.
  19630. * @param element Defines the element to stop listening the inputs from
  19631. */
  19632. detachControl(element: HTMLElement): void;
  19633. private _collisionMask;
  19634. /**
  19635. * Define a collision mask to limit the list of object the camera can collide with
  19636. */
  19637. get collisionMask(): number;
  19638. set collisionMask(mask: number);
  19639. /** @hidden */
  19640. _collideWithWorld(displacement: Vector3): void;
  19641. private _onCollisionPositionChange;
  19642. /** @hidden */
  19643. _checkInputs(): void;
  19644. /** @hidden */
  19645. _decideIfNeedsToMove(): boolean;
  19646. /** @hidden */
  19647. _updatePosition(): void;
  19648. /**
  19649. * Destroy the camera and release the current resources hold by it.
  19650. */
  19651. dispose(): void;
  19652. /**
  19653. * Gets the current object class name.
  19654. * @return the class name
  19655. */
  19656. getClassName(): string;
  19657. }
  19658. }
  19659. declare module "babylonjs/Gamepads/gamepad" {
  19660. import { Observable } from "babylonjs/Misc/observable";
  19661. /**
  19662. * Represents a gamepad control stick position
  19663. */
  19664. export class StickValues {
  19665. /**
  19666. * The x component of the control stick
  19667. */
  19668. x: number;
  19669. /**
  19670. * The y component of the control stick
  19671. */
  19672. y: number;
  19673. /**
  19674. * Initializes the gamepad x and y control stick values
  19675. * @param x The x component of the gamepad control stick value
  19676. * @param y The y component of the gamepad control stick value
  19677. */
  19678. constructor(
  19679. /**
  19680. * The x component of the control stick
  19681. */
  19682. x: number,
  19683. /**
  19684. * The y component of the control stick
  19685. */
  19686. y: number);
  19687. }
  19688. /**
  19689. * An interface which manages callbacks for gamepad button changes
  19690. */
  19691. export interface GamepadButtonChanges {
  19692. /**
  19693. * Called when a gamepad has been changed
  19694. */
  19695. changed: boolean;
  19696. /**
  19697. * Called when a gamepad press event has been triggered
  19698. */
  19699. pressChanged: boolean;
  19700. /**
  19701. * Called when a touch event has been triggered
  19702. */
  19703. touchChanged: boolean;
  19704. /**
  19705. * Called when a value has changed
  19706. */
  19707. valueChanged: boolean;
  19708. }
  19709. /**
  19710. * Represents a gamepad
  19711. */
  19712. export class Gamepad {
  19713. /**
  19714. * The id of the gamepad
  19715. */
  19716. id: string;
  19717. /**
  19718. * The index of the gamepad
  19719. */
  19720. index: number;
  19721. /**
  19722. * The browser gamepad
  19723. */
  19724. browserGamepad: any;
  19725. /**
  19726. * Specifies what type of gamepad this represents
  19727. */
  19728. type: number;
  19729. private _leftStick;
  19730. private _rightStick;
  19731. /** @hidden */
  19732. _isConnected: boolean;
  19733. private _leftStickAxisX;
  19734. private _leftStickAxisY;
  19735. private _rightStickAxisX;
  19736. private _rightStickAxisY;
  19737. /**
  19738. * Triggered when the left control stick has been changed
  19739. */
  19740. private _onleftstickchanged;
  19741. /**
  19742. * Triggered when the right control stick has been changed
  19743. */
  19744. private _onrightstickchanged;
  19745. /**
  19746. * Represents a gamepad controller
  19747. */
  19748. static GAMEPAD: number;
  19749. /**
  19750. * Represents a generic controller
  19751. */
  19752. static GENERIC: number;
  19753. /**
  19754. * Represents an XBox controller
  19755. */
  19756. static XBOX: number;
  19757. /**
  19758. * Represents a pose-enabled controller
  19759. */
  19760. static POSE_ENABLED: number;
  19761. /**
  19762. * Represents an Dual Shock controller
  19763. */
  19764. static DUALSHOCK: number;
  19765. /**
  19766. * Specifies whether the left control stick should be Y-inverted
  19767. */
  19768. protected _invertLeftStickY: boolean;
  19769. /**
  19770. * Specifies if the gamepad has been connected
  19771. */
  19772. get isConnected(): boolean;
  19773. /**
  19774. * Initializes the gamepad
  19775. * @param id The id of the gamepad
  19776. * @param index The index of the gamepad
  19777. * @param browserGamepad The browser gamepad
  19778. * @param leftStickX The x component of the left joystick
  19779. * @param leftStickY The y component of the left joystick
  19780. * @param rightStickX The x component of the right joystick
  19781. * @param rightStickY The y component of the right joystick
  19782. */
  19783. constructor(
  19784. /**
  19785. * The id of the gamepad
  19786. */
  19787. id: string,
  19788. /**
  19789. * The index of the gamepad
  19790. */
  19791. index: number,
  19792. /**
  19793. * The browser gamepad
  19794. */
  19795. browserGamepad: any, leftStickX?: number, leftStickY?: number, rightStickX?: number, rightStickY?: number);
  19796. /**
  19797. * Callback triggered when the left joystick has changed
  19798. * @param callback
  19799. */
  19800. onleftstickchanged(callback: (values: StickValues) => void): void;
  19801. /**
  19802. * Callback triggered when the right joystick has changed
  19803. * @param callback
  19804. */
  19805. onrightstickchanged(callback: (values: StickValues) => void): void;
  19806. /**
  19807. * Gets the left joystick
  19808. */
  19809. get leftStick(): StickValues;
  19810. /**
  19811. * Sets the left joystick values
  19812. */
  19813. set leftStick(newValues: StickValues);
  19814. /**
  19815. * Gets the right joystick
  19816. */
  19817. get rightStick(): StickValues;
  19818. /**
  19819. * Sets the right joystick value
  19820. */
  19821. set rightStick(newValues: StickValues);
  19822. /**
  19823. * Updates the gamepad joystick positions
  19824. */
  19825. update(): void;
  19826. /**
  19827. * Disposes the gamepad
  19828. */
  19829. dispose(): void;
  19830. }
  19831. /**
  19832. * Represents a generic gamepad
  19833. */
  19834. export class GenericPad extends Gamepad {
  19835. private _buttons;
  19836. private _onbuttondown;
  19837. private _onbuttonup;
  19838. /**
  19839. * Observable triggered when a button has been pressed
  19840. */
  19841. onButtonDownObservable: Observable<number>;
  19842. /**
  19843. * Observable triggered when a button has been released
  19844. */
  19845. onButtonUpObservable: Observable<number>;
  19846. /**
  19847. * Callback triggered when a button has been pressed
  19848. * @param callback Called when a button has been pressed
  19849. */
  19850. onbuttondown(callback: (buttonPressed: number) => void): void;
  19851. /**
  19852. * Callback triggered when a button has been released
  19853. * @param callback Called when a button has been released
  19854. */
  19855. onbuttonup(callback: (buttonReleased: number) => void): void;
  19856. /**
  19857. * Initializes the generic gamepad
  19858. * @param id The id of the generic gamepad
  19859. * @param index The index of the generic gamepad
  19860. * @param browserGamepad The browser gamepad
  19861. */
  19862. constructor(id: string, index: number, browserGamepad: any);
  19863. private _setButtonValue;
  19864. /**
  19865. * Updates the generic gamepad
  19866. */
  19867. update(): void;
  19868. /**
  19869. * Disposes the generic gamepad
  19870. */
  19871. dispose(): void;
  19872. }
  19873. }
  19874. declare module "babylonjs/Gamepads/Controllers/poseEnabledController" {
  19875. import { Observable } from "babylonjs/Misc/observable";
  19876. import { Nullable } from "babylonjs/types";
  19877. import { Quaternion, Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  19878. import { TransformNode } from "babylonjs/Meshes/transformNode";
  19879. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  19880. import { Ray } from "babylonjs/Culling/ray";
  19881. import { Gamepad } from "babylonjs/Gamepads/gamepad";
  19882. import { PoseControlled, DevicePose } from "babylonjs/Cameras/VR/webVRCamera";
  19883. import { TargetCamera } from "babylonjs/Cameras/targetCamera";
  19884. /**
  19885. * Defines the types of pose enabled controllers that are supported
  19886. */
  19887. export enum PoseEnabledControllerType {
  19888. /**
  19889. * HTC Vive
  19890. */
  19891. VIVE = 0,
  19892. /**
  19893. * Oculus Rift
  19894. */
  19895. OCULUS = 1,
  19896. /**
  19897. * Windows mixed reality
  19898. */
  19899. WINDOWS = 2,
  19900. /**
  19901. * Samsung gear VR
  19902. */
  19903. GEAR_VR = 3,
  19904. /**
  19905. * Google Daydream
  19906. */
  19907. DAYDREAM = 4,
  19908. /**
  19909. * Generic
  19910. */
  19911. GENERIC = 5
  19912. }
  19913. /**
  19914. * Defines the MutableGamepadButton interface for the state of a gamepad button
  19915. */
  19916. export interface MutableGamepadButton {
  19917. /**
  19918. * Value of the button/trigger
  19919. */
  19920. value: number;
  19921. /**
  19922. * If the button/trigger is currently touched
  19923. */
  19924. touched: boolean;
  19925. /**
  19926. * If the button/trigger is currently pressed
  19927. */
  19928. pressed: boolean;
  19929. }
  19930. /**
  19931. * Defines the ExtendedGamepadButton interface for a gamepad button which includes state provided by a pose controller
  19932. * @hidden
  19933. */
  19934. export interface ExtendedGamepadButton extends GamepadButton {
  19935. /**
  19936. * If the button/trigger is currently pressed
  19937. */
  19938. readonly pressed: boolean;
  19939. /**
  19940. * If the button/trigger is currently touched
  19941. */
  19942. readonly touched: boolean;
  19943. /**
  19944. * Value of the button/trigger
  19945. */
  19946. readonly value: number;
  19947. }
  19948. /** @hidden */
  19949. export interface _GamePadFactory {
  19950. /**
  19951. * Returns whether or not the current gamepad can be created for this type of controller.
  19952. * @param gamepadInfo Defines the gamepad info as received from the controller APIs.
  19953. * @returns true if it can be created, otherwise false
  19954. */
  19955. canCreate(gamepadInfo: any): boolean;
  19956. /**
  19957. * Creates a new instance of the Gamepad.
  19958. * @param gamepadInfo Defines the gamepad info as received from the controller APIs.
  19959. * @returns the new gamepad instance
  19960. */
  19961. create(gamepadInfo: any): Gamepad;
  19962. }
  19963. /**
  19964. * Defines the PoseEnabledControllerHelper object that is used initialize a gamepad as the controller type it is specified as (eg. windows mixed reality controller)
  19965. */
  19966. export class PoseEnabledControllerHelper {
  19967. /** @hidden */
  19968. static _ControllerFactories: _GamePadFactory[];
  19969. /** @hidden */
  19970. static _DefaultControllerFactory: Nullable<(gamepadInfo: any) => Gamepad>;
  19971. /**
  19972. * Initializes a gamepad as the controller type it is specified as (eg. windows mixed reality controller)
  19973. * @param vrGamepad the gamepad to initialized
  19974. * @returns a vr controller of the type the gamepad identified as
  19975. */
  19976. static InitiateController(vrGamepad: any): Gamepad;
  19977. }
  19978. /**
  19979. * Defines the PoseEnabledController object that contains state of a vr capable controller
  19980. */
  19981. export class PoseEnabledController extends Gamepad implements PoseControlled {
  19982. /**
  19983. * If the controller is used in a webXR session
  19984. */
  19985. isXR: boolean;
  19986. private _deviceRoomPosition;
  19987. private _deviceRoomRotationQuaternion;
  19988. /**
  19989. * The device position in babylon space
  19990. */
  19991. devicePosition: Vector3;
  19992. /**
  19993. * The device rotation in babylon space
  19994. */
  19995. deviceRotationQuaternion: Quaternion;
  19996. /**
  19997. * The scale factor of the device in babylon space
  19998. */
  19999. deviceScaleFactor: number;
  20000. /**
  20001. * (Likely devicePosition should be used instead) The device position in its room space
  20002. */
  20003. position: Vector3;
  20004. /**
  20005. * (Likely deviceRotationQuaternion should be used instead) The device rotation in its room space
  20006. */
  20007. rotationQuaternion: Quaternion;
  20008. /**
  20009. * The type of controller (Eg. Windows mixed reality)
  20010. */
  20011. controllerType: PoseEnabledControllerType;
  20012. protected _calculatedPosition: Vector3;
  20013. private _calculatedRotation;
  20014. /**
  20015. * The raw pose from the device
  20016. */
  20017. rawPose: DevicePose;
  20018. private _trackPosition;
  20019. private _maxRotationDistFromHeadset;
  20020. private _draggedRoomRotation;
  20021. /**
  20022. * @hidden
  20023. */
  20024. _disableTrackPosition(fixedPosition: Vector3): void;
  20025. /**
  20026. * Internal, the mesh attached to the controller
  20027. * @hidden
  20028. */
  20029. _mesh: Nullable<AbstractMesh>;
  20030. private _poseControlledCamera;
  20031. private _leftHandSystemQuaternion;
  20032. /**
  20033. * Internal, matrix used to convert room space to babylon space
  20034. * @hidden
  20035. */
  20036. _deviceToWorld: Matrix;
  20037. /**
  20038. * Node to be used when casting a ray from the controller
  20039. * @hidden
  20040. */
  20041. _pointingPoseNode: Nullable<TransformNode>;
  20042. /**
  20043. * Name of the child mesh that can be used to cast a ray from the controller
  20044. */
  20045. static readonly POINTING_POSE: string;
  20046. /**
  20047. * Creates a new PoseEnabledController from a gamepad
  20048. * @param browserGamepad the gamepad that the PoseEnabledController should be created from
  20049. */
  20050. constructor(browserGamepad: any);
  20051. private _workingMatrix;
  20052. /**
  20053. * Updates the state of the pose enbaled controller and mesh based on the current position and rotation of the controller
  20054. */
  20055. update(): void;
  20056. /**
  20057. * Updates only the pose device and mesh without doing any button event checking
  20058. */
  20059. protected _updatePoseAndMesh(): void;
  20060. /**
  20061. * Updates the state of the pose enbaled controller based on the raw pose data from the device
  20062. * @param poseData raw pose fromthe device
  20063. */
  20064. updateFromDevice(poseData: DevicePose): void;
  20065. /**
  20066. * @hidden
  20067. */
  20068. _meshAttachedObservable: Observable<AbstractMesh>;
  20069. /**
  20070. * Attaches a mesh to the controller
  20071. * @param mesh the mesh to be attached
  20072. */
  20073. attachToMesh(mesh: AbstractMesh): void;
  20074. /**
  20075. * Attaches the controllers mesh to a camera
  20076. * @param camera the camera the mesh should be attached to
  20077. */
  20078. attachToPoseControlledCamera(camera: TargetCamera): void;
  20079. /**
  20080. * Disposes of the controller
  20081. */
  20082. dispose(): void;
  20083. /**
  20084. * The mesh that is attached to the controller
  20085. */
  20086. get mesh(): Nullable<AbstractMesh>;
  20087. /**
  20088. * Gets the ray of the controller in the direction the controller is pointing
  20089. * @param length the length the resulting ray should be
  20090. * @returns a ray in the direction the controller is pointing
  20091. */
  20092. getForwardRay(length?: number): Ray;
  20093. }
  20094. }
  20095. declare module "babylonjs/Gamepads/Controllers/webVRController" {
  20096. import { Observable } from "babylonjs/Misc/observable";
  20097. import { Scene } from "babylonjs/scene";
  20098. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  20099. import { PoseEnabledController, ExtendedGamepadButton, MutableGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  20100. import { StickValues, GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  20101. import { Nullable } from "babylonjs/types";
  20102. /**
  20103. * Defines the WebVRController object that represents controllers tracked in 3D space
  20104. */
  20105. export abstract class WebVRController extends PoseEnabledController {
  20106. /**
  20107. * Internal, the default controller model for the controller
  20108. */
  20109. protected _defaultModel: Nullable<AbstractMesh>;
  20110. /**
  20111. * Fired when the trigger state has changed
  20112. */
  20113. onTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  20114. /**
  20115. * Fired when the main button state has changed
  20116. */
  20117. onMainButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  20118. /**
  20119. * Fired when the secondary button state has changed
  20120. */
  20121. onSecondaryButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  20122. /**
  20123. * Fired when the pad state has changed
  20124. */
  20125. onPadStateChangedObservable: Observable<ExtendedGamepadButton>;
  20126. /**
  20127. * Fired when controllers stick values have changed
  20128. */
  20129. onPadValuesChangedObservable: Observable<StickValues>;
  20130. /**
  20131. * Array of button availible on the controller
  20132. */
  20133. protected _buttons: Array<MutableGamepadButton>;
  20134. private _onButtonStateChange;
  20135. /**
  20136. * Fired when a controller button's state has changed
  20137. * @param callback the callback containing the button that was modified
  20138. */
  20139. onButtonStateChange(callback: (controlledIndex: number, buttonIndex: number, state: ExtendedGamepadButton) => void): void;
  20140. /**
  20141. * X and Y axis corresponding to the controllers joystick
  20142. */
  20143. pad: StickValues;
  20144. /**
  20145. * 'left' or 'right', see https://w3c.github.io/gamepad/extensions.html#gamepadhand-enum
  20146. */
  20147. hand: string;
  20148. /**
  20149. * The default controller model for the controller
  20150. */
  20151. get defaultModel(): Nullable<AbstractMesh>;
  20152. /**
  20153. * Creates a new WebVRController from a gamepad
  20154. * @param vrGamepad the gamepad that the WebVRController should be created from
  20155. */
  20156. constructor(vrGamepad: any);
  20157. /**
  20158. * Updates the state of the controller and mesh based on the current position and rotation of the controller
  20159. */
  20160. update(): void;
  20161. /**
  20162. * Function to be called when a button is modified
  20163. */
  20164. protected abstract _handleButtonChange(buttonIdx: number, value: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  20165. /**
  20166. * Loads a mesh and attaches it to the controller
  20167. * @param scene the scene the mesh should be added to
  20168. * @param meshLoaded callback for when the mesh has been loaded
  20169. */
  20170. abstract initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  20171. private _setButtonValue;
  20172. private _changes;
  20173. private _checkChanges;
  20174. /**
  20175. * Disposes of th webVRCOntroller
  20176. */
  20177. dispose(): void;
  20178. }
  20179. }
  20180. declare module "babylonjs/Lights/hemisphericLight" {
  20181. import { Nullable } from "babylonjs/types";
  20182. import { Scene } from "babylonjs/scene";
  20183. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  20184. import { Color3 } from "babylonjs/Maths/math.color";
  20185. import { Effect } from "babylonjs/Materials/effect";
  20186. import { Light } from "babylonjs/Lights/light";
  20187. import { IShadowGenerator } from "babylonjs/Lights/Shadows/shadowGenerator";
  20188. /**
  20189. * The HemisphericLight simulates the ambient environment light,
  20190. * so the passed direction is the light reflection direction, not the incoming direction.
  20191. */
  20192. export class HemisphericLight extends Light {
  20193. /**
  20194. * The groundColor is the light in the opposite direction to the one specified during creation.
  20195. * 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.
  20196. */
  20197. groundColor: Color3;
  20198. /**
  20199. * The light reflection direction, not the incoming direction.
  20200. */
  20201. direction: Vector3;
  20202. /**
  20203. * Creates a HemisphericLight object in the scene according to the passed direction (Vector3).
  20204. * The HemisphericLight simulates the ambient environment light, so the passed direction is the light reflection direction, not the incoming direction.
  20205. * The HemisphericLight can't cast shadows.
  20206. * Documentation : https://doc.babylonjs.com/babylon101/lights
  20207. * @param name The friendly name of the light
  20208. * @param direction The direction of the light reflection
  20209. * @param scene The scene the light belongs to
  20210. */
  20211. constructor(name: string, direction: Vector3, scene: Scene);
  20212. protected _buildUniformLayout(): void;
  20213. /**
  20214. * Returns the string "HemisphericLight".
  20215. * @return The class name
  20216. */
  20217. getClassName(): string;
  20218. /**
  20219. * Sets the HemisphericLight direction towards the passed target (Vector3).
  20220. * Returns the updated direction.
  20221. * @param target The target the direction should point to
  20222. * @return The computed direction
  20223. */
  20224. setDirectionToTarget(target: Vector3): Vector3;
  20225. /**
  20226. * Returns the shadow generator associated to the light.
  20227. * @returns Always null for hemispheric lights because it does not support shadows.
  20228. */
  20229. getShadowGenerator(): Nullable<IShadowGenerator>;
  20230. /**
  20231. * Sets the passed Effect object with the HemisphericLight normalized direction and color and the passed name (string).
  20232. * @param effect The effect to update
  20233. * @param lightIndex The index of the light in the effect to update
  20234. * @returns The hemispheric light
  20235. */
  20236. transferToEffect(effect: Effect, lightIndex: string): HemisphericLight;
  20237. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): this;
  20238. /**
  20239. * Computes the world matrix of the node
  20240. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  20241. * @param useWasUpdatedFlag defines a reserved property
  20242. * @returns the world matrix
  20243. */
  20244. computeWorldMatrix(): Matrix;
  20245. /**
  20246. * Returns the integer 3.
  20247. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  20248. */
  20249. getTypeID(): number;
  20250. /**
  20251. * Prepares the list of defines specific to the light type.
  20252. * @param defines the list of defines
  20253. * @param lightIndex defines the index of the light for the effect
  20254. */
  20255. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  20256. }
  20257. }
  20258. declare module "babylonjs/Shaders/vrMultiviewToSingleview.fragment" {
  20259. /** @hidden */
  20260. export var vrMultiviewToSingleviewPixelShader: {
  20261. name: string;
  20262. shader: string;
  20263. };
  20264. }
  20265. declare module "babylonjs/Materials/Textures/MultiviewRenderTarget" {
  20266. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  20267. import { Scene } from "babylonjs/scene";
  20268. /**
  20269. * Renders to multiple views with a single draw call
  20270. * @see https://www.khronos.org/registry/webgl/extensions/WEBGL_multiview/
  20271. */
  20272. export class MultiviewRenderTarget extends RenderTargetTexture {
  20273. /**
  20274. * Creates a multiview render target
  20275. * @param scene scene used with the render target
  20276. * @param size the size of the render target (used for each view)
  20277. */
  20278. constructor(scene: Scene, size?: number | {
  20279. width: number;
  20280. height: number;
  20281. } | {
  20282. ratio: number;
  20283. });
  20284. /**
  20285. * @hidden
  20286. * @param faceIndex the face index, if its a cube texture
  20287. */
  20288. _bindFrameBuffer(faceIndex?: number): void;
  20289. /**
  20290. * Gets the number of views the corresponding to the texture (eg. a MultiviewRenderTarget will have > 1)
  20291. * @returns the view count
  20292. */
  20293. getViewCount(): number;
  20294. }
  20295. }
  20296. declare module "babylonjs/Engines/Extensions/engine.multiview" {
  20297. import { Camera } from "babylonjs/Cameras/camera";
  20298. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  20299. import { Nullable } from "babylonjs/types";
  20300. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  20301. import { Matrix } from "babylonjs/Maths/math.vector";
  20302. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  20303. module "babylonjs/Engines/engine" {
  20304. interface Engine {
  20305. /**
  20306. * Creates a new multiview render target
  20307. * @param width defines the width of the texture
  20308. * @param height defines the height of the texture
  20309. * @returns the created multiview texture
  20310. */
  20311. createMultiviewRenderTargetTexture(width: number, height: number): InternalTexture;
  20312. /**
  20313. * Binds a multiview framebuffer to be drawn to
  20314. * @param multiviewTexture texture to bind
  20315. */
  20316. bindMultiviewFramebuffer(multiviewTexture: InternalTexture): void;
  20317. }
  20318. }
  20319. module "babylonjs/Cameras/camera" {
  20320. interface Camera {
  20321. /**
  20322. * @hidden
  20323. * 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)
  20324. */
  20325. _useMultiviewToSingleView: boolean;
  20326. /**
  20327. * @hidden
  20328. * 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)
  20329. */
  20330. _multiviewTexture: Nullable<RenderTargetTexture>;
  20331. /**
  20332. * @hidden
  20333. * ensures the multiview texture of the camera exists and has the specified width/height
  20334. * @param width height to set on the multiview texture
  20335. * @param height width to set on the multiview texture
  20336. */
  20337. _resizeOrCreateMultiviewTexture(width: number, height: number): void;
  20338. }
  20339. }
  20340. module "babylonjs/scene" {
  20341. interface Scene {
  20342. /** @hidden */
  20343. _transformMatrixR: Matrix;
  20344. /** @hidden */
  20345. _multiviewSceneUbo: Nullable<UniformBuffer>;
  20346. /** @hidden */
  20347. _createMultiviewUbo(): void;
  20348. /** @hidden */
  20349. _updateMultiviewUbo(viewR?: Matrix, projectionR?: Matrix): void;
  20350. /** @hidden */
  20351. _renderMultiviewToSingleView(camera: Camera): void;
  20352. }
  20353. }
  20354. }
  20355. declare module "babylonjs/PostProcesses/vrMultiviewToSingleviewPostProcess" {
  20356. import { Camera } from "babylonjs/Cameras/camera";
  20357. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  20358. import "babylonjs/Shaders/vrMultiviewToSingleview.fragment";
  20359. import "babylonjs/Engines/Extensions/engine.multiview";
  20360. /**
  20361. * VRMultiviewToSingleview used to convert multiview texture arrays to standard textures for scenarios such as webVR
  20362. * This will not be used for webXR as it supports displaying texture arrays directly
  20363. */
  20364. export class VRMultiviewToSingleviewPostProcess extends PostProcess {
  20365. /**
  20366. * Gets a string identifying the name of the class
  20367. * @returns "VRMultiviewToSingleviewPostProcess" string
  20368. */
  20369. getClassName(): string;
  20370. /**
  20371. * Initializes a VRMultiviewToSingleview
  20372. * @param name name of the post process
  20373. * @param camera camera to be applied to
  20374. * @param scaleFactor scaling factor to the size of the output texture
  20375. */
  20376. constructor(name: string, camera: Camera, scaleFactor: number);
  20377. }
  20378. }
  20379. declare module "babylonjs/Cameras/RigModes/webVRRigMode" { }
  20380. declare module "babylonjs/Engines/Extensions/engine.webVR" {
  20381. import { Nullable } from "babylonjs/types";
  20382. import { Size } from "babylonjs/Maths/math.size";
  20383. import { Observable } from "babylonjs/Misc/observable";
  20384. import { WebVROptions } from "babylonjs/Cameras/VR/webVRCamera";
  20385. /**
  20386. * Interface used to define additional presentation attributes
  20387. */
  20388. export interface IVRPresentationAttributes {
  20389. /**
  20390. * Defines a boolean indicating that we want to get 72hz mode on Oculus Browser (default is off eg. 60hz)
  20391. */
  20392. highRefreshRate: boolean;
  20393. /**
  20394. * Enables foveation in VR to improve perf. 0 none, 1 low, 2 medium, 3 high (Default is 1)
  20395. */
  20396. foveationLevel: number;
  20397. }
  20398. module "babylonjs/Engines/engine" {
  20399. interface Engine {
  20400. /** @hidden */
  20401. _vrDisplay: any;
  20402. /** @hidden */
  20403. _vrSupported: boolean;
  20404. /** @hidden */
  20405. _oldSize: Size;
  20406. /** @hidden */
  20407. _oldHardwareScaleFactor: number;
  20408. /** @hidden */
  20409. _vrExclusivePointerMode: boolean;
  20410. /** @hidden */
  20411. _webVRInitPromise: Promise<IDisplayChangedEventArgs>;
  20412. /** @hidden */
  20413. _onVRDisplayPointerRestricted: () => void;
  20414. /** @hidden */
  20415. _onVRDisplayPointerUnrestricted: () => void;
  20416. /** @hidden */
  20417. _onVrDisplayConnect: Nullable<(display: any) => void>;
  20418. /** @hidden */
  20419. _onVrDisplayDisconnect: Nullable<() => void>;
  20420. /** @hidden */
  20421. _onVrDisplayPresentChange: Nullable<() => void>;
  20422. /**
  20423. * Observable signaled when VR display mode changes
  20424. */
  20425. onVRDisplayChangedObservable: Observable<IDisplayChangedEventArgs>;
  20426. /**
  20427. * Observable signaled when VR request present is complete
  20428. */
  20429. onVRRequestPresentComplete: Observable<boolean>;
  20430. /**
  20431. * Observable signaled when VR request present starts
  20432. */
  20433. onVRRequestPresentStart: Observable<Engine>;
  20434. /**
  20435. * Gets a boolean indicating that the engine is currently in VR exclusive mode for the pointers
  20436. * @see https://docs.microsoft.com/en-us/microsoft-edge/webvr/essentials#mouse-input
  20437. */
  20438. isInVRExclusivePointerMode: boolean;
  20439. /**
  20440. * Gets a boolean indicating if a webVR device was detected
  20441. * @returns true if a webVR device was detected
  20442. */
  20443. isVRDevicePresent(): boolean;
  20444. /**
  20445. * Gets the current webVR device
  20446. * @returns the current webVR device (or null)
  20447. */
  20448. getVRDevice(): any;
  20449. /**
  20450. * Initializes a webVR display and starts listening to display change events
  20451. * The onVRDisplayChangedObservable will be notified upon these changes
  20452. * @returns A promise containing a VRDisplay and if vr is supported
  20453. */
  20454. initWebVRAsync(): Promise<IDisplayChangedEventArgs>;
  20455. /** @hidden */
  20456. _getVRDisplaysAsync(): Promise<IDisplayChangedEventArgs>;
  20457. /**
  20458. * Gets or sets the presentation attributes used to configure VR rendering
  20459. */
  20460. vrPresentationAttributes?: IVRPresentationAttributes;
  20461. /**
  20462. * Call this function to switch to webVR mode
  20463. * Will do nothing if webVR is not supported or if there is no webVR device
  20464. * @param options the webvr options provided to the camera. mainly used for multiview
  20465. * @see https://doc.babylonjs.com/how_to/webvr_camera
  20466. */
  20467. enableVR(options: WebVROptions): void;
  20468. /** @hidden */
  20469. _onVRFullScreenTriggered(): void;
  20470. }
  20471. }
  20472. }
  20473. declare module "babylonjs/Cameras/VR/webVRCamera" {
  20474. import { Nullable } from "babylonjs/types";
  20475. import { Observable } from "babylonjs/Misc/observable";
  20476. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  20477. import { Scene } from "babylonjs/scene";
  20478. import { Quaternion, Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  20479. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  20480. import { Node } from "babylonjs/node";
  20481. import { Ray } from "babylonjs/Culling/ray";
  20482. import "babylonjs/Cameras/RigModes/webVRRigMode";
  20483. import "babylonjs/Engines/Extensions/engine.webVR";
  20484. /**
  20485. * This is a copy of VRPose. See https://developer.mozilla.org/en-US/docs/Web/API/VRPose
  20486. * IMPORTANT!! The data is right-hand data.
  20487. * @export
  20488. * @interface DevicePose
  20489. */
  20490. export interface DevicePose {
  20491. /**
  20492. * The position of the device, values in array are [x,y,z].
  20493. */
  20494. readonly position: Nullable<Float32Array>;
  20495. /**
  20496. * The linearVelocity of the device, values in array are [x,y,z].
  20497. */
  20498. readonly linearVelocity: Nullable<Float32Array>;
  20499. /**
  20500. * The linearAcceleration of the device, values in array are [x,y,z].
  20501. */
  20502. readonly linearAcceleration: Nullable<Float32Array>;
  20503. /**
  20504. * The orientation of the device in a quaternion array, values in array are [x,y,z,w].
  20505. */
  20506. readonly orientation: Nullable<Float32Array>;
  20507. /**
  20508. * The angularVelocity of the device, values in array are [x,y,z].
  20509. */
  20510. readonly angularVelocity: Nullable<Float32Array>;
  20511. /**
  20512. * The angularAcceleration of the device, values in array are [x,y,z].
  20513. */
  20514. readonly angularAcceleration: Nullable<Float32Array>;
  20515. }
  20516. /**
  20517. * Interface representing a pose controlled object in Babylon.
  20518. * A pose controlled object has both regular pose values as well as pose values
  20519. * from an external device such as a VR head mounted display
  20520. */
  20521. export interface PoseControlled {
  20522. /**
  20523. * The position of the object in babylon space.
  20524. */
  20525. position: Vector3;
  20526. /**
  20527. * The rotation quaternion of the object in babylon space.
  20528. */
  20529. rotationQuaternion: Quaternion;
  20530. /**
  20531. * The position of the device in babylon space.
  20532. */
  20533. devicePosition?: Vector3;
  20534. /**
  20535. * The rotation quaternion of the device in babylon space.
  20536. */
  20537. deviceRotationQuaternion: Quaternion;
  20538. /**
  20539. * The raw pose coming from the device.
  20540. */
  20541. rawPose: Nullable<DevicePose>;
  20542. /**
  20543. * The scale of the device to be used when translating from device space to babylon space.
  20544. */
  20545. deviceScaleFactor: number;
  20546. /**
  20547. * Updates the poseControlled values based on the input device pose.
  20548. * @param poseData the pose data to update the object with
  20549. */
  20550. updateFromDevice(poseData: DevicePose): void;
  20551. }
  20552. /**
  20553. * Set of options to customize the webVRCamera
  20554. */
  20555. export interface WebVROptions {
  20556. /**
  20557. * Sets if the webVR camera should be tracked to the vrDevice. (default: true)
  20558. */
  20559. trackPosition?: boolean;
  20560. /**
  20561. * Sets the scale of the vrDevice in babylon space. (default: 1)
  20562. */
  20563. positionScale?: number;
  20564. /**
  20565. * If there are more than one VRDisplays, this will choose the display matching this name. (default: pick first vrDisplay)
  20566. */
  20567. displayName?: string;
  20568. /**
  20569. * Should the native controller meshes be initialized. (default: true)
  20570. */
  20571. controllerMeshes?: boolean;
  20572. /**
  20573. * Creating a default HemiLight only on controllers. (default: true)
  20574. */
  20575. defaultLightingOnControllers?: boolean;
  20576. /**
  20577. * If you don't want to use the default VR button of the helper. (default: false)
  20578. */
  20579. useCustomVRButton?: boolean;
  20580. /**
  20581. * If you'd like to provide your own button to the VRHelper. (default: standard babylon vr button)
  20582. */
  20583. customVRButton?: HTMLButtonElement;
  20584. /**
  20585. * To change the length of the ray for gaze/controllers. Will be scaled by positionScale. (default: 100)
  20586. */
  20587. rayLength?: number;
  20588. /**
  20589. * To change the default offset from the ground to account for user's height in meters. Will be scaled by positionScale. (default: 1.7)
  20590. */
  20591. defaultHeight?: number;
  20592. /**
  20593. * If multiview should be used if availible (default: false)
  20594. */
  20595. useMultiview?: boolean;
  20596. }
  20597. /**
  20598. * This represents a WebVR camera.
  20599. * The WebVR camera is Babylon's simple interface to interaction with Windows Mixed Reality, HTC Vive and Oculus Rift.
  20600. * @example https://doc.babylonjs.com/how_to/webvr_camera
  20601. */
  20602. export class WebVRFreeCamera extends FreeCamera implements PoseControlled {
  20603. private webVROptions;
  20604. /**
  20605. * @hidden
  20606. * The vrDisplay tied to the camera. See https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay
  20607. */
  20608. _vrDevice: any;
  20609. /**
  20610. * The rawPose of the vrDevice.
  20611. */
  20612. rawPose: Nullable<DevicePose>;
  20613. private _onVREnabled;
  20614. private _specsVersion;
  20615. private _attached;
  20616. private _frameData;
  20617. protected _descendants: Array<Node>;
  20618. private _deviceRoomPosition;
  20619. /** @hidden */
  20620. _deviceRoomRotationQuaternion: Quaternion;
  20621. private _standingMatrix;
  20622. /**
  20623. * Represents device position in babylon space.
  20624. */
  20625. devicePosition: Vector3;
  20626. /**
  20627. * Represents device rotation in babylon space.
  20628. */
  20629. deviceRotationQuaternion: Quaternion;
  20630. /**
  20631. * The scale of the device to be used when translating from device space to babylon space.
  20632. */
  20633. deviceScaleFactor: number;
  20634. private _deviceToWorld;
  20635. private _worldToDevice;
  20636. /**
  20637. * References to the webVR controllers for the vrDevice.
  20638. */
  20639. controllers: Array<WebVRController>;
  20640. /**
  20641. * Emits an event when a controller is attached.
  20642. */
  20643. onControllersAttachedObservable: Observable<WebVRController[]>;
  20644. /**
  20645. * Emits an event when a controller's mesh has been loaded;
  20646. */
  20647. onControllerMeshLoadedObservable: Observable<WebVRController>;
  20648. /**
  20649. * Emits an event when the HMD's pose has been updated.
  20650. */
  20651. onPoseUpdatedFromDeviceObservable: Observable<any>;
  20652. private _poseSet;
  20653. /**
  20654. * If the rig cameras be used as parent instead of this camera.
  20655. */
  20656. rigParenting: boolean;
  20657. private _lightOnControllers;
  20658. private _defaultHeight?;
  20659. /**
  20660. * Instantiates a WebVRFreeCamera.
  20661. * @param name The name of the WebVRFreeCamera
  20662. * @param position The starting anchor position for the camera
  20663. * @param scene The scene the camera belongs to
  20664. * @param webVROptions a set of customizable options for the webVRCamera
  20665. */
  20666. constructor(name: string, position: Vector3, scene: Scene, webVROptions?: WebVROptions);
  20667. /**
  20668. * Gets the device distance from the ground in meters.
  20669. * @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.
  20670. */
  20671. deviceDistanceToRoomGround(): number;
  20672. /**
  20673. * Enables the standing matrix when supported. This can be used to position the user's view the correct height from the ground.
  20674. * @param callback will be called when the standing matrix is set. Callback parameter is if the standing matrix is supported.
  20675. */
  20676. useStandingMatrix(callback?: (bool: boolean) => void): void;
  20677. /**
  20678. * Enables the standing matrix when supported. This can be used to position the user's view the correct height from the ground.
  20679. * @returns A promise with a boolean set to if the standing matrix is supported.
  20680. */
  20681. useStandingMatrixAsync(): Promise<boolean>;
  20682. /**
  20683. * Disposes the camera
  20684. */
  20685. dispose(): void;
  20686. /**
  20687. * Gets a vrController by name.
  20688. * @param name The name of the controller to retreive
  20689. * @returns the controller matching the name specified or null if not found
  20690. */
  20691. getControllerByName(name: string): Nullable<WebVRController>;
  20692. private _leftController;
  20693. /**
  20694. * The controller corresponding to the users left hand.
  20695. */
  20696. get leftController(): Nullable<WebVRController>;
  20697. private _rightController;
  20698. /**
  20699. * The controller corresponding to the users right hand.
  20700. */
  20701. get rightController(): Nullable<WebVRController>;
  20702. /**
  20703. * Casts a ray forward from the vrCamera's gaze.
  20704. * @param length Length of the ray (default: 100)
  20705. * @returns the ray corresponding to the gaze
  20706. */
  20707. getForwardRay(length?: number): Ray;
  20708. /**
  20709. * @hidden
  20710. * Updates the camera based on device's frame data
  20711. */
  20712. _checkInputs(): void;
  20713. /**
  20714. * Updates the poseControlled values based on the input device pose.
  20715. * @param poseData Pose coming from the device
  20716. */
  20717. updateFromDevice(poseData: DevicePose): void;
  20718. private _htmlElementAttached;
  20719. private _detachIfAttached;
  20720. /**
  20721. * WebVR's attach control will start broadcasting frames to the device.
  20722. * Note that in certain browsers (chrome for example) this function must be called
  20723. * within a user-interaction callback. Example:
  20724. * <pre> scene.onPointerDown = function() { camera.attachControl(canvas); }</pre>
  20725. *
  20726. * @param element html element to attach the vrDevice to
  20727. * @param noPreventDefault prevent the default html element operation when attaching the vrDevice
  20728. */
  20729. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  20730. /**
  20731. * Detaches the camera from the html element and disables VR
  20732. *
  20733. * @param element html element to detach from
  20734. */
  20735. detachControl(element: HTMLElement): void;
  20736. /**
  20737. * @returns the name of this class
  20738. */
  20739. getClassName(): string;
  20740. /**
  20741. * Calls resetPose on the vrDisplay
  20742. * See: https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay/resetPose
  20743. */
  20744. resetToCurrentRotation(): void;
  20745. /**
  20746. * @hidden
  20747. * Updates the rig cameras (left and right eye)
  20748. */
  20749. _updateRigCameras(): void;
  20750. private _workingVector;
  20751. private _oneVector;
  20752. private _workingMatrix;
  20753. private updateCacheCalled;
  20754. private _correctPositionIfNotTrackPosition;
  20755. /**
  20756. * @hidden
  20757. * Updates the cached values of the camera
  20758. * @param ignoreParentClass ignores updating the parent class's cache (default: false)
  20759. */
  20760. _updateCache(ignoreParentClass?: boolean): void;
  20761. /**
  20762. * @hidden
  20763. * Get current device position in babylon world
  20764. */
  20765. _computeDevicePosition(): void;
  20766. /**
  20767. * Updates the current device position and rotation in the babylon world
  20768. */
  20769. update(): void;
  20770. /**
  20771. * @hidden
  20772. * Gets the view matrix of this camera (Always set to identity as left and right eye cameras contain the actual view matrix)
  20773. * @returns an identity matrix
  20774. */
  20775. _getViewMatrix(): Matrix;
  20776. private _tmpMatrix;
  20777. /**
  20778. * This function is called by the two RIG cameras.
  20779. * 'this' is the left or right camera (and NOT (!!!) the WebVRFreeCamera instance)
  20780. * @hidden
  20781. */
  20782. _getWebVRViewMatrix(): Matrix;
  20783. /** @hidden */
  20784. _getWebVRProjectionMatrix(): Matrix;
  20785. private _onGamepadConnectedObserver;
  20786. private _onGamepadDisconnectedObserver;
  20787. private _updateCacheWhenTrackingDisabledObserver;
  20788. /**
  20789. * Initializes the controllers and their meshes
  20790. */
  20791. initControllers(): void;
  20792. }
  20793. }
  20794. declare module "babylonjs/Materials/materialHelper" {
  20795. import { Nullable } from "babylonjs/types";
  20796. import { Scene } from "babylonjs/scene";
  20797. import { Engine } from "babylonjs/Engines/engine";
  20798. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  20799. import { Light } from "babylonjs/Lights/light";
  20800. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  20801. import { Effect, IEffectCreationOptions } from "babylonjs/Materials/effect";
  20802. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  20803. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  20804. import { EffectFallbacks } from "babylonjs/Materials/effectFallbacks";
  20805. /**
  20806. * "Static Class" containing the most commonly used helper while dealing with material for rendering purpose.
  20807. *
  20808. * It contains the basic tools to help defining defines, binding uniform for the common part of the materials.
  20809. *
  20810. * This works by convention in BabylonJS but is meant to be use only with shader following the in place naming rules and conventions.
  20811. */
  20812. export class MaterialHelper {
  20813. /**
  20814. * Bind the current view position to an effect.
  20815. * @param effect The effect to be bound
  20816. * @param scene The scene the eyes position is used from
  20817. * @param variableName name of the shader variable that will hold the eye position
  20818. */
  20819. static BindEyePosition(effect: Effect, scene: Scene, variableName?: string): void;
  20820. /**
  20821. * Helps preparing the defines values about the UVs in used in the effect.
  20822. * UVs are shared as much as we can accross channels in the shaders.
  20823. * @param texture The texture we are preparing the UVs for
  20824. * @param defines The defines to update
  20825. * @param key The channel key "diffuse", "specular"... used in the shader
  20826. */
  20827. static PrepareDefinesForMergedUV(texture: BaseTexture, defines: any, key: string): void;
  20828. /**
  20829. * Binds a texture matrix value to its corrsponding uniform
  20830. * @param texture The texture to bind the matrix for
  20831. * @param uniformBuffer The uniform buffer receivin the data
  20832. * @param key The channel key "diffuse", "specular"... used in the shader
  20833. */
  20834. static BindTextureMatrix(texture: BaseTexture, uniformBuffer: UniformBuffer, key: string): void;
  20835. /**
  20836. * Gets the current status of the fog (should it be enabled?)
  20837. * @param mesh defines the mesh to evaluate for fog support
  20838. * @param scene defines the hosting scene
  20839. * @returns true if fog must be enabled
  20840. */
  20841. static GetFogState(mesh: AbstractMesh, scene: Scene): boolean;
  20842. /**
  20843. * Helper used to prepare the list of defines associated with misc. values for shader compilation
  20844. * @param mesh defines the current mesh
  20845. * @param scene defines the current scene
  20846. * @param useLogarithmicDepth defines if logarithmic depth has to be turned on
  20847. * @param pointsCloud defines if point cloud rendering has to be turned on
  20848. * @param fogEnabled defines if fog has to be turned on
  20849. * @param alphaTest defines if alpha testing has to be turned on
  20850. * @param defines defines the current list of defines
  20851. */
  20852. static PrepareDefinesForMisc(mesh: AbstractMesh, scene: Scene, useLogarithmicDepth: boolean, pointsCloud: boolean, fogEnabled: boolean, alphaTest: boolean, defines: any): void;
  20853. /**
  20854. * Helper used to prepare the list of defines associated with frame values for shader compilation
  20855. * @param scene defines the current scene
  20856. * @param engine defines the current engine
  20857. * @param defines specifies the list of active defines
  20858. * @param useInstances defines if instances have to be turned on
  20859. * @param useClipPlane defines if clip plane have to be turned on
  20860. * @param useInstances defines if instances have to be turned on
  20861. * @param useThinInstances defines if thin instances have to be turned on
  20862. */
  20863. static PrepareDefinesForFrameBoundValues(scene: Scene, engine: Engine, defines: any, useInstances: boolean, useClipPlane?: Nullable<boolean>, useThinInstances?: boolean): void;
  20864. /**
  20865. * Prepares the defines for bones
  20866. * @param mesh The mesh containing the geometry data we will draw
  20867. * @param defines The defines to update
  20868. */
  20869. static PrepareDefinesForBones(mesh: AbstractMesh, defines: any): void;
  20870. /**
  20871. * Prepares the defines for morph targets
  20872. * @param mesh The mesh containing the geometry data we will draw
  20873. * @param defines The defines to update
  20874. */
  20875. static PrepareDefinesForMorphTargets(mesh: AbstractMesh, defines: any): void;
  20876. /**
  20877. * Prepares the defines used in the shader depending on the attributes data available in the mesh
  20878. * @param mesh The mesh containing the geometry data we will draw
  20879. * @param defines The defines to update
  20880. * @param useVertexColor Precise whether vertex colors should be used or not (override mesh info)
  20881. * @param useBones Precise whether bones should be used or not (override mesh info)
  20882. * @param useMorphTargets Precise whether morph targets should be used or not (override mesh info)
  20883. * @param useVertexAlpha Precise whether vertex alpha should be used or not (override mesh info)
  20884. * @returns false if defines are considered not dirty and have not been checked
  20885. */
  20886. static PrepareDefinesForAttributes(mesh: AbstractMesh, defines: any, useVertexColor: boolean, useBones: boolean, useMorphTargets?: boolean, useVertexAlpha?: boolean): boolean;
  20887. /**
  20888. * Prepares the defines related to multiview
  20889. * @param scene The scene we are intending to draw
  20890. * @param defines The defines to update
  20891. */
  20892. static PrepareDefinesForMultiview(scene: Scene, defines: any): void;
  20893. /**
  20894. * Prepares the defines related to the prepass
  20895. * @param scene The scene we are intending to draw
  20896. * @param defines The defines to update
  20897. * @param canRenderToMRT Indicates if this material renders to several textures in the prepass
  20898. */
  20899. static PrepareDefinesForPrePass(scene: Scene, defines: any, canRenderToMRT: boolean): void;
  20900. /**
  20901. * Prepares the defines related to the light information passed in parameter
  20902. * @param scene The scene we are intending to draw
  20903. * @param mesh The mesh the effect is compiling for
  20904. * @param light The light the effect is compiling for
  20905. * @param lightIndex The index of the light
  20906. * @param defines The defines to update
  20907. * @param specularSupported Specifies whether specular is supported or not (override lights data)
  20908. * @param state Defines the current state regarding what is needed (normals, etc...)
  20909. */
  20910. static PrepareDefinesForLight(scene: Scene, mesh: AbstractMesh, light: Light, lightIndex: number, defines: any, specularSupported: boolean, state: {
  20911. needNormals: boolean;
  20912. needRebuild: boolean;
  20913. shadowEnabled: boolean;
  20914. specularEnabled: boolean;
  20915. lightmapMode: boolean;
  20916. }): void;
  20917. /**
  20918. * Prepares the defines related to the light information passed in parameter
  20919. * @param scene The scene we are intending to draw
  20920. * @param mesh The mesh the effect is compiling for
  20921. * @param defines The defines to update
  20922. * @param specularSupported Specifies whether specular is supported or not (override lights data)
  20923. * @param maxSimultaneousLights Specfies how manuy lights can be added to the effect at max
  20924. * @param disableLighting Specifies whether the lighting is disabled (override scene and light)
  20925. * @returns true if normals will be required for the rest of the effect
  20926. */
  20927. static PrepareDefinesForLights(scene: Scene, mesh: AbstractMesh, defines: any, specularSupported: boolean, maxSimultaneousLights?: number, disableLighting?: boolean): boolean;
  20928. /**
  20929. * Prepares the uniforms and samplers list to be used in the effect (for a specific light)
  20930. * @param lightIndex defines the light index
  20931. * @param uniformsList The uniform list
  20932. * @param samplersList The sampler list
  20933. * @param projectedLightTexture defines if projected texture must be used
  20934. * @param uniformBuffersList defines an optional list of uniform buffers
  20935. */
  20936. static PrepareUniformsAndSamplersForLight(lightIndex: number, uniformsList: string[], samplersList: string[], projectedLightTexture?: any, uniformBuffersList?: Nullable<string[]>): void;
  20937. /**
  20938. * Prepares the uniforms and samplers list to be used in the effect
  20939. * @param uniformsListOrOptions The uniform names to prepare or an EffectCreationOptions containing the liist and extra information
  20940. * @param samplersList The sampler list
  20941. * @param defines The defines helping in the list generation
  20942. * @param maxSimultaneousLights The maximum number of simultanous light allowed in the effect
  20943. */
  20944. static PrepareUniformsAndSamplersList(uniformsListOrOptions: string[] | IEffectCreationOptions, samplersList?: string[], defines?: any, maxSimultaneousLights?: number): void;
  20945. /**
  20946. * This helps decreasing rank by rank the shadow quality (0 being the highest rank and quality)
  20947. * @param defines The defines to update while falling back
  20948. * @param fallbacks The authorized effect fallbacks
  20949. * @param maxSimultaneousLights The maximum number of lights allowed
  20950. * @param rank the current rank of the Effect
  20951. * @returns The newly affected rank
  20952. */
  20953. static HandleFallbacksForShadows(defines: any, fallbacks: EffectFallbacks, maxSimultaneousLights?: number, rank?: number): number;
  20954. private static _TmpMorphInfluencers;
  20955. /**
  20956. * Prepares the list of attributes required for morph targets according to the effect defines.
  20957. * @param attribs The current list of supported attribs
  20958. * @param mesh The mesh to prepare the morph targets attributes for
  20959. * @param influencers The number of influencers
  20960. */
  20961. static PrepareAttributesForMorphTargetsInfluencers(attribs: string[], mesh: AbstractMesh, influencers: number): void;
  20962. /**
  20963. * Prepares the list of attributes required for morph targets according to the effect defines.
  20964. * @param attribs The current list of supported attribs
  20965. * @param mesh The mesh to prepare the morph targets attributes for
  20966. * @param defines The current Defines of the effect
  20967. */
  20968. static PrepareAttributesForMorphTargets(attribs: string[], mesh: AbstractMesh, defines: any): void;
  20969. /**
  20970. * Prepares the list of attributes required for bones according to the effect defines.
  20971. * @param attribs The current list of supported attribs
  20972. * @param mesh The mesh to prepare the bones attributes for
  20973. * @param defines The current Defines of the effect
  20974. * @param fallbacks The current efffect fallback strategy
  20975. */
  20976. static PrepareAttributesForBones(attribs: string[], mesh: AbstractMesh, defines: any, fallbacks: EffectFallbacks): void;
  20977. /**
  20978. * Check and prepare the list of attributes required for instances according to the effect defines.
  20979. * @param attribs The current list of supported attribs
  20980. * @param defines The current MaterialDefines of the effect
  20981. */
  20982. static PrepareAttributesForInstances(attribs: string[], defines: MaterialDefines): void;
  20983. /**
  20984. * Add the list of attributes required for instances to the attribs array.
  20985. * @param attribs The current list of supported attribs
  20986. */
  20987. static PushAttributesForInstances(attribs: string[]): void;
  20988. /**
  20989. * Binds the light information to the effect.
  20990. * @param light The light containing the generator
  20991. * @param effect The effect we are binding the data to
  20992. * @param lightIndex The light index in the effect used to render
  20993. */
  20994. static BindLightProperties(light: Light, effect: Effect, lightIndex: number): void;
  20995. /**
  20996. * Binds the lights information from the scene to the effect for the given mesh.
  20997. * @param light Light to bind
  20998. * @param lightIndex Light index
  20999. * @param scene The scene where the light belongs to
  21000. * @param effect The effect we are binding the data to
  21001. * @param useSpecular Defines if specular is supported
  21002. * @param rebuildInParallel Specifies whether the shader is rebuilding in parallel
  21003. */
  21004. static BindLight(light: Light, lightIndex: number, scene: Scene, effect: Effect, useSpecular: boolean, rebuildInParallel?: boolean): void;
  21005. /**
  21006. * Binds the lights information from the scene to the effect for the given mesh.
  21007. * @param scene The scene the lights belongs to
  21008. * @param mesh The mesh we are binding the information to render
  21009. * @param effect The effect we are binding the data to
  21010. * @param defines The generated defines for the effect
  21011. * @param maxSimultaneousLights The maximum number of light that can be bound to the effect
  21012. * @param rebuildInParallel Specifies whether the shader is rebuilding in parallel
  21013. */
  21014. static BindLights(scene: Scene, mesh: AbstractMesh, effect: Effect, defines: any, maxSimultaneousLights?: number, rebuildInParallel?: boolean): void;
  21015. private static _tempFogColor;
  21016. /**
  21017. * Binds the fog information from the scene to the effect for the given mesh.
  21018. * @param scene The scene the lights belongs to
  21019. * @param mesh The mesh we are binding the information to render
  21020. * @param effect The effect we are binding the data to
  21021. * @param linearSpace Defines if the fog effect is applied in linear space
  21022. */
  21023. static BindFogParameters(scene: Scene, mesh: AbstractMesh, effect: Effect, linearSpace?: boolean): void;
  21024. /**
  21025. * Binds the bones information from the mesh to the effect.
  21026. * @param mesh The mesh we are binding the information to render
  21027. * @param effect The effect we are binding the data to
  21028. */
  21029. static BindBonesParameters(mesh?: AbstractMesh, effect?: Effect): void;
  21030. /**
  21031. * Binds the morph targets information from the mesh to the effect.
  21032. * @param abstractMesh The mesh we are binding the information to render
  21033. * @param effect The effect we are binding the data to
  21034. */
  21035. static BindMorphTargetParameters(abstractMesh: AbstractMesh, effect: Effect): void;
  21036. /**
  21037. * Binds the logarithmic depth information from the scene to the effect for the given defines.
  21038. * @param defines The generated defines used in the effect
  21039. * @param effect The effect we are binding the data to
  21040. * @param scene The scene we are willing to render with logarithmic scale for
  21041. */
  21042. static BindLogDepth(defines: any, effect: Effect, scene: Scene): void;
  21043. /**
  21044. * Binds the clip plane information from the scene to the effect.
  21045. * @param scene The scene the clip plane information are extracted from
  21046. * @param effect The effect we are binding the data to
  21047. */
  21048. static BindClipPlane(effect: Effect, scene: Scene): void;
  21049. }
  21050. }
  21051. declare module "babylonjs/Materials/Node/Blocks/Input/inputBlock" {
  21052. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  21053. import { NodeMaterialBlockConnectionPointTypes } from "babylonjs/Materials/Node/Enums/nodeMaterialBlockConnectionPointTypes";
  21054. import { NodeMaterialSystemValues } from "babylonjs/Materials/Node/Enums/nodeMaterialSystemValues";
  21055. import { Nullable } from "babylonjs/types";
  21056. import { Effect } from "babylonjs/Materials/effect";
  21057. import { Matrix } from "babylonjs/Maths/math.vector";
  21058. import { Scene } from "babylonjs/scene";
  21059. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  21060. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  21061. import { NodeMaterialBlockTargets } from "babylonjs/Materials/Node/Enums/nodeMaterialBlockTargets";
  21062. import { AnimatedInputBlockTypes } from "babylonjs/Materials/Node/Blocks/Input/animatedInputBlockTypes";
  21063. import { Observable } from "babylonjs/Misc/observable";
  21064. /**
  21065. * Block used to expose an input value
  21066. */
  21067. export class InputBlock extends NodeMaterialBlock {
  21068. private _mode;
  21069. private _associatedVariableName;
  21070. private _storedValue;
  21071. private _valueCallback;
  21072. private _type;
  21073. private _animationType;
  21074. /** Gets or set a value used to limit the range of float values */
  21075. min: number;
  21076. /** Gets or set a value used to limit the range of float values */
  21077. max: number;
  21078. /** Gets or set a value indicating that this input can only get 0 and 1 values */
  21079. isBoolean: boolean;
  21080. /** Gets or sets a value used by the Node Material editor to determine how to configure the current value if it is a matrix */
  21081. matrixMode: number;
  21082. /** @hidden */
  21083. _systemValue: Nullable<NodeMaterialSystemValues>;
  21084. /** Gets or sets a boolean indicating that this input can be edited in the Inspector (false by default) */
  21085. visibleInInspector: boolean;
  21086. /** Gets or sets a boolean indicating that the value of this input will not change after a build */
  21087. isConstant: boolean;
  21088. /** Gets or sets the group to use to display this block in the Inspector */
  21089. groupInInspector: string;
  21090. /** Gets an observable raised when the value is changed */
  21091. onValueChangedObservable: Observable<InputBlock>;
  21092. /**
  21093. * Gets or sets the connection point type (default is float)
  21094. */
  21095. get type(): NodeMaterialBlockConnectionPointTypes;
  21096. /**
  21097. * Creates a new InputBlock
  21098. * @param name defines the block name
  21099. * @param target defines the target of that block (Vertex by default)
  21100. * @param type defines the type of the input (can be set to NodeMaterialBlockConnectionPointTypes.AutoDetect)
  21101. */
  21102. constructor(name: string, target?: NodeMaterialBlockTargets, type?: NodeMaterialBlockConnectionPointTypes);
  21103. /**
  21104. * Validates if a name is a reserve word.
  21105. * @param newName the new name to be given to the node.
  21106. * @returns false if the name is a reserve word, else true.
  21107. */
  21108. validateBlockName(newName: string): boolean;
  21109. /**
  21110. * Gets the output component
  21111. */
  21112. get output(): NodeMaterialConnectionPoint;
  21113. /**
  21114. * Set the source of this connection point to a vertex attribute
  21115. * @param attributeName defines the attribute name (position, uv, normal, etc...). If not specified it will take the connection point name
  21116. * @returns the current connection point
  21117. */
  21118. setAsAttribute(attributeName?: string): InputBlock;
  21119. /**
  21120. * Set the source of this connection point to a system value
  21121. * @param value define the system value to use (world, view, etc...) or null to switch to manual value
  21122. * @returns the current connection point
  21123. */
  21124. setAsSystemValue(value: Nullable<NodeMaterialSystemValues>): InputBlock;
  21125. /**
  21126. * Gets or sets the value of that point.
  21127. * Please note that this value will be ignored if valueCallback is defined
  21128. */
  21129. get value(): any;
  21130. set value(value: any);
  21131. /**
  21132. * Gets or sets a callback used to get the value of that point.
  21133. * Please note that setting this value will force the connection point to ignore the value property
  21134. */
  21135. get valueCallback(): () => any;
  21136. set valueCallback(value: () => any);
  21137. /**
  21138. * Gets or sets the associated variable name in the shader
  21139. */
  21140. get associatedVariableName(): string;
  21141. set associatedVariableName(value: string);
  21142. /** Gets or sets the type of animation applied to the input */
  21143. get animationType(): AnimatedInputBlockTypes;
  21144. set animationType(value: AnimatedInputBlockTypes);
  21145. /**
  21146. * Gets a boolean indicating that this connection point not defined yet
  21147. */
  21148. get isUndefined(): boolean;
  21149. /**
  21150. * Gets or sets a boolean indicating that this connection point is coming from an uniform.
  21151. * In this case the connection point name must be the name of the uniform to use.
  21152. * Can only be set on inputs
  21153. */
  21154. get isUniform(): boolean;
  21155. set isUniform(value: boolean);
  21156. /**
  21157. * Gets or sets a boolean indicating that this connection point is coming from an attribute.
  21158. * In this case the connection point name must be the name of the attribute to use
  21159. * Can only be set on inputs
  21160. */
  21161. get isAttribute(): boolean;
  21162. set isAttribute(value: boolean);
  21163. /**
  21164. * Gets or sets a boolean indicating that this connection point is generating a varying variable.
  21165. * Can only be set on exit points
  21166. */
  21167. get isVarying(): boolean;
  21168. set isVarying(value: boolean);
  21169. /**
  21170. * Gets a boolean indicating that the current connection point is a system value
  21171. */
  21172. get isSystemValue(): boolean;
  21173. /**
  21174. * Gets or sets the current well known value or null if not defined as a system value
  21175. */
  21176. get systemValue(): Nullable<NodeMaterialSystemValues>;
  21177. set systemValue(value: Nullable<NodeMaterialSystemValues>);
  21178. /**
  21179. * Gets the current class name
  21180. * @returns the class name
  21181. */
  21182. getClassName(): string;
  21183. /**
  21184. * Animate the input if animationType !== None
  21185. * @param scene defines the rendering scene
  21186. */
  21187. animate(scene: Scene): void;
  21188. private _emitDefine;
  21189. initialize(state: NodeMaterialBuildState): void;
  21190. /**
  21191. * Set the input block to its default value (based on its type)
  21192. */
  21193. setDefaultValue(): void;
  21194. private _emitConstant;
  21195. /** @hidden */
  21196. get _noContextSwitch(): boolean;
  21197. private _emit;
  21198. /** @hidden */
  21199. _transmitWorld(effect: Effect, world: Matrix, worldView: Matrix, worldViewProjection: Matrix): void;
  21200. /** @hidden */
  21201. _transmit(effect: Effect, scene: Scene): void;
  21202. protected _buildBlock(state: NodeMaterialBuildState): void;
  21203. protected _dumpPropertiesCode(): string;
  21204. dispose(): void;
  21205. serialize(): any;
  21206. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  21207. }
  21208. }
  21209. declare module "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint" {
  21210. import { NodeMaterialBlockConnectionPointTypes } from "babylonjs/Materials/Node/Enums/nodeMaterialBlockConnectionPointTypes";
  21211. import { NodeMaterialBlockTargets } from "babylonjs/Materials/Node/Enums/nodeMaterialBlockTargets";
  21212. import { Nullable } from "babylonjs/types";
  21213. import { InputBlock } from "babylonjs/Materials/Node/Blocks/Input/inputBlock";
  21214. import { Observable } from "babylonjs/Misc/observable";
  21215. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  21216. /**
  21217. * Enum used to define the compatibility state between two connection points
  21218. */
  21219. export enum NodeMaterialConnectionPointCompatibilityStates {
  21220. /** Points are compatibles */
  21221. Compatible = 0,
  21222. /** Points are incompatible because of their types */
  21223. TypeIncompatible = 1,
  21224. /** Points are incompatible because of their targets (vertex vs fragment) */
  21225. TargetIncompatible = 2
  21226. }
  21227. /**
  21228. * Defines the direction of a connection point
  21229. */
  21230. export enum NodeMaterialConnectionPointDirection {
  21231. /** Input */
  21232. Input = 0,
  21233. /** Output */
  21234. Output = 1
  21235. }
  21236. /**
  21237. * Defines a connection point for a block
  21238. */
  21239. export class NodeMaterialConnectionPoint {
  21240. /** @hidden */
  21241. _ownerBlock: NodeMaterialBlock;
  21242. /** @hidden */
  21243. _connectedPoint: Nullable<NodeMaterialConnectionPoint>;
  21244. private _endpoints;
  21245. private _associatedVariableName;
  21246. private _direction;
  21247. /** @hidden */
  21248. _typeConnectionSource: Nullable<NodeMaterialConnectionPoint>;
  21249. /** @hidden */
  21250. _linkedConnectionSource: Nullable<NodeMaterialConnectionPoint>;
  21251. private _type;
  21252. /** @hidden */
  21253. _enforceAssociatedVariableName: boolean;
  21254. /** Gets the direction of the point */
  21255. get direction(): NodeMaterialConnectionPointDirection;
  21256. /** Indicates that this connection point needs dual validation before being connected to another point */
  21257. needDualDirectionValidation: boolean;
  21258. /**
  21259. * Gets or sets the additional types supported by this connection point
  21260. */
  21261. acceptedConnectionPointTypes: NodeMaterialBlockConnectionPointTypes[];
  21262. /**
  21263. * Gets or sets the additional types excluded by this connection point
  21264. */
  21265. excludedConnectionPointTypes: NodeMaterialBlockConnectionPointTypes[];
  21266. /**
  21267. * Observable triggered when this point is connected
  21268. */
  21269. onConnectionObservable: Observable<NodeMaterialConnectionPoint>;
  21270. /**
  21271. * Gets or sets the associated variable name in the shader
  21272. */
  21273. get associatedVariableName(): string;
  21274. set associatedVariableName(value: string);
  21275. /** Get the inner type (ie AutoDetect for instance instead of the inferred one) */
  21276. get innerType(): NodeMaterialBlockConnectionPointTypes;
  21277. /**
  21278. * Gets or sets the connection point type (default is float)
  21279. */
  21280. get type(): NodeMaterialBlockConnectionPointTypes;
  21281. set type(value: NodeMaterialBlockConnectionPointTypes);
  21282. /**
  21283. * Gets or sets the connection point name
  21284. */
  21285. name: string;
  21286. /**
  21287. * Gets or sets the connection point name
  21288. */
  21289. displayName: string;
  21290. /**
  21291. * Gets or sets a boolean indicating that this connection point can be omitted
  21292. */
  21293. isOptional: boolean;
  21294. /**
  21295. * Gets or sets a boolean indicating that this connection point is exposed on a frame
  21296. */
  21297. isExposedOnFrame: boolean;
  21298. /**
  21299. * Gets or sets a string indicating that this uniform must be defined under a #ifdef
  21300. */
  21301. define: string;
  21302. /** @hidden */
  21303. _prioritizeVertex: boolean;
  21304. private _target;
  21305. /** Gets or sets the target of that connection point */
  21306. get target(): NodeMaterialBlockTargets;
  21307. set target(value: NodeMaterialBlockTargets);
  21308. /**
  21309. * Gets a boolean indicating that the current point is connected to another NodeMaterialBlock
  21310. */
  21311. get isConnected(): boolean;
  21312. /**
  21313. * Gets a boolean indicating that the current point is connected to an input block
  21314. */
  21315. get isConnectedToInputBlock(): boolean;
  21316. /**
  21317. * Gets a the connected input block (if any)
  21318. */
  21319. get connectInputBlock(): Nullable<InputBlock>;
  21320. /** Get the other side of the connection (if any) */
  21321. get connectedPoint(): Nullable<NodeMaterialConnectionPoint>;
  21322. /** Get the block that owns this connection point */
  21323. get ownerBlock(): NodeMaterialBlock;
  21324. /** Get the block connected on the other side of this connection (if any) */
  21325. get sourceBlock(): Nullable<NodeMaterialBlock>;
  21326. /** Get the block connected on the endpoints of this connection (if any) */
  21327. get connectedBlocks(): Array<NodeMaterialBlock>;
  21328. /** Gets the list of connected endpoints */
  21329. get endpoints(): NodeMaterialConnectionPoint[];
  21330. /** Gets a boolean indicating if that output point is connected to at least one input */
  21331. get hasEndpoints(): boolean;
  21332. /** Gets a boolean indicating that this connection will be used in the vertex shader */
  21333. get isConnectedInVertexShader(): boolean;
  21334. /** Gets a boolean indicating that this connection will be used in the fragment shader */
  21335. get isConnectedInFragmentShader(): boolean;
  21336. /**
  21337. * Creates a block suitable to be used as an input for this input point.
  21338. * If null is returned, a block based on the point type will be created.
  21339. * @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
  21340. */
  21341. createCustomInputBlock(): Nullable<[NodeMaterialBlock, string]>;
  21342. /**
  21343. * Creates a new connection point
  21344. * @param name defines the connection point name
  21345. * @param ownerBlock defines the block hosting this connection point
  21346. * @param direction defines the direction of the connection point
  21347. */
  21348. constructor(name: string, ownerBlock: NodeMaterialBlock, direction: NodeMaterialConnectionPointDirection);
  21349. /**
  21350. * Gets the current class name e.g. "NodeMaterialConnectionPoint"
  21351. * @returns the class name
  21352. */
  21353. getClassName(): string;
  21354. /**
  21355. * Gets a boolean indicating if the current point can be connected to another point
  21356. * @param connectionPoint defines the other connection point
  21357. * @returns a boolean
  21358. */
  21359. canConnectTo(connectionPoint: NodeMaterialConnectionPoint): boolean;
  21360. /**
  21361. * Gets a number indicating if the current point can be connected to another point
  21362. * @param connectionPoint defines the other connection point
  21363. * @returns a number defining the compatibility state
  21364. */
  21365. checkCompatibilityState(connectionPoint: NodeMaterialConnectionPoint): NodeMaterialConnectionPointCompatibilityStates;
  21366. /**
  21367. * Connect this point to another connection point
  21368. * @param connectionPoint defines the other connection point
  21369. * @param ignoreConstraints defines if the system will ignore connection type constraints (default is false)
  21370. * @returns the current connection point
  21371. */
  21372. connectTo(connectionPoint: NodeMaterialConnectionPoint, ignoreConstraints?: boolean): NodeMaterialConnectionPoint;
  21373. /**
  21374. * Disconnect this point from one of his endpoint
  21375. * @param endpoint defines the other connection point
  21376. * @returns the current connection point
  21377. */
  21378. disconnectFrom(endpoint: NodeMaterialConnectionPoint): NodeMaterialConnectionPoint;
  21379. /**
  21380. * Serializes this point in a JSON representation
  21381. * @param isInput defines if the connection point is an input (default is true)
  21382. * @returns the serialized point object
  21383. */
  21384. serialize(isInput?: boolean): any;
  21385. /**
  21386. * Release resources
  21387. */
  21388. dispose(): void;
  21389. }
  21390. }
  21391. declare module "babylonjs/Materials/Node/Enums/nodeMaterialModes" {
  21392. /**
  21393. * Enum used to define the material modes
  21394. */
  21395. export enum NodeMaterialModes {
  21396. /** Regular material */
  21397. Material = 0,
  21398. /** For post process */
  21399. PostProcess = 1,
  21400. /** For particle system */
  21401. Particle = 2
  21402. }
  21403. }
  21404. declare module "babylonjs/Materials/Node/Blocks/Dual/textureBlock" {
  21405. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  21406. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  21407. import { NodeMaterialBlockTargets } from "babylonjs/Materials/Node/Enums/nodeMaterialBlockTargets";
  21408. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  21409. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  21410. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  21411. import { Effect } from "babylonjs/Materials/effect";
  21412. import { Mesh } from "babylonjs/Meshes/mesh";
  21413. import { Nullable } from "babylonjs/types";
  21414. import { Texture } from "babylonjs/Materials/Textures/texture";
  21415. import { Scene } from "babylonjs/scene";
  21416. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  21417. /**
  21418. * Block used to read a texture from a sampler
  21419. */
  21420. export class TextureBlock extends NodeMaterialBlock {
  21421. private _defineName;
  21422. private _linearDefineName;
  21423. private _gammaDefineName;
  21424. private _tempTextureRead;
  21425. private _samplerName;
  21426. private _transformedUVName;
  21427. private _textureTransformName;
  21428. private _textureInfoName;
  21429. private _mainUVName;
  21430. private _mainUVDefineName;
  21431. private _fragmentOnly;
  21432. /**
  21433. * Gets or sets the texture associated with the node
  21434. */
  21435. texture: Nullable<Texture>;
  21436. /**
  21437. * Gets or sets a boolean indicating if content needs to be converted to gamma space
  21438. */
  21439. convertToGammaSpace: boolean;
  21440. /**
  21441. * Gets or sets a boolean indicating if content needs to be converted to linear space
  21442. */
  21443. convertToLinearSpace: boolean;
  21444. /**
  21445. * Create a new TextureBlock
  21446. * @param name defines the block name
  21447. */
  21448. constructor(name: string, fragmentOnly?: boolean);
  21449. /**
  21450. * Gets the current class name
  21451. * @returns the class name
  21452. */
  21453. getClassName(): string;
  21454. /**
  21455. * Gets the uv input component
  21456. */
  21457. get uv(): NodeMaterialConnectionPoint;
  21458. /**
  21459. * Gets the rgba output component
  21460. */
  21461. get rgba(): NodeMaterialConnectionPoint;
  21462. /**
  21463. * Gets the rgb output component
  21464. */
  21465. get rgb(): NodeMaterialConnectionPoint;
  21466. /**
  21467. * Gets the r output component
  21468. */
  21469. get r(): NodeMaterialConnectionPoint;
  21470. /**
  21471. * Gets the g output component
  21472. */
  21473. get g(): NodeMaterialConnectionPoint;
  21474. /**
  21475. * Gets the b output component
  21476. */
  21477. get b(): NodeMaterialConnectionPoint;
  21478. /**
  21479. * Gets the a output component
  21480. */
  21481. get a(): NodeMaterialConnectionPoint;
  21482. get target(): NodeMaterialBlockTargets;
  21483. autoConfigure(material: NodeMaterial): void;
  21484. initializeDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  21485. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  21486. isReady(): boolean;
  21487. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  21488. private get _isMixed();
  21489. private _injectVertexCode;
  21490. private _writeTextureRead;
  21491. private _writeOutput;
  21492. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  21493. protected _dumpPropertiesCode(): string;
  21494. serialize(): any;
  21495. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  21496. }
  21497. }
  21498. declare module "babylonjs/Shaders/ShadersInclude/reflectionFunction" {
  21499. /** @hidden */
  21500. export var reflectionFunction: {
  21501. name: string;
  21502. shader: string;
  21503. };
  21504. }
  21505. declare module "babylonjs/Materials/Node/Blocks/Dual/reflectionTextureBaseBlock" {
  21506. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  21507. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  21508. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  21509. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  21510. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  21511. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  21512. import { Effect } from "babylonjs/Materials/effect";
  21513. import { Mesh } from "babylonjs/Meshes/mesh";
  21514. import { Nullable } from "babylonjs/types";
  21515. import { Scene } from "babylonjs/scene";
  21516. import "babylonjs/Shaders/ShadersInclude/reflectionFunction";
  21517. /**
  21518. * Base block used to read a reflection texture from a sampler
  21519. */
  21520. export abstract class ReflectionTextureBaseBlock extends NodeMaterialBlock {
  21521. /** @hidden */
  21522. _define3DName: string;
  21523. /** @hidden */
  21524. _defineCubicName: string;
  21525. /** @hidden */
  21526. _defineExplicitName: string;
  21527. /** @hidden */
  21528. _defineProjectionName: string;
  21529. /** @hidden */
  21530. _defineLocalCubicName: string;
  21531. /** @hidden */
  21532. _defineSphericalName: string;
  21533. /** @hidden */
  21534. _definePlanarName: string;
  21535. /** @hidden */
  21536. _defineEquirectangularName: string;
  21537. /** @hidden */
  21538. _defineMirroredEquirectangularFixedName: string;
  21539. /** @hidden */
  21540. _defineEquirectangularFixedName: string;
  21541. /** @hidden */
  21542. _defineSkyboxName: string;
  21543. /** @hidden */
  21544. _defineOppositeZ: string;
  21545. /** @hidden */
  21546. _cubeSamplerName: string;
  21547. /** @hidden */
  21548. _2DSamplerName: string;
  21549. protected _positionUVWName: string;
  21550. protected _directionWName: string;
  21551. protected _reflectionVectorName: string;
  21552. /** @hidden */
  21553. _reflectionCoordsName: string;
  21554. /** @hidden */
  21555. _reflectionMatrixName: string;
  21556. protected _reflectionColorName: string;
  21557. /**
  21558. * Gets or sets the texture associated with the node
  21559. */
  21560. texture: Nullable<BaseTexture>;
  21561. /**
  21562. * Create a new ReflectionTextureBaseBlock
  21563. * @param name defines the block name
  21564. */
  21565. constructor(name: string);
  21566. /**
  21567. * Gets the current class name
  21568. * @returns the class name
  21569. */
  21570. getClassName(): string;
  21571. /**
  21572. * Gets the world position input component
  21573. */
  21574. abstract get position(): NodeMaterialConnectionPoint;
  21575. /**
  21576. * Gets the world position input component
  21577. */
  21578. abstract get worldPosition(): NodeMaterialConnectionPoint;
  21579. /**
  21580. * Gets the world normal input component
  21581. */
  21582. abstract get worldNormal(): NodeMaterialConnectionPoint;
  21583. /**
  21584. * Gets the world input component
  21585. */
  21586. abstract get world(): NodeMaterialConnectionPoint;
  21587. /**
  21588. * Gets the camera (or eye) position component
  21589. */
  21590. abstract get cameraPosition(): NodeMaterialConnectionPoint;
  21591. /**
  21592. * Gets the view input component
  21593. */
  21594. abstract get view(): NodeMaterialConnectionPoint;
  21595. protected _getTexture(): Nullable<BaseTexture>;
  21596. autoConfigure(material: NodeMaterial): void;
  21597. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  21598. isReady(): boolean;
  21599. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  21600. /**
  21601. * Gets the code to inject in the vertex shader
  21602. * @param state current state of the node material building
  21603. * @returns the shader code
  21604. */
  21605. handleVertexSide(state: NodeMaterialBuildState): string;
  21606. /**
  21607. * Handles the inits for the fragment code path
  21608. * @param state node material build state
  21609. */
  21610. handleFragmentSideInits(state: NodeMaterialBuildState): void;
  21611. /**
  21612. * Generates the reflection coords code for the fragment code path
  21613. * @param worldNormalVarName name of the world normal variable
  21614. * @param worldPos name of the world position variable. If not provided, will use the world position connected to this block
  21615. * @param onlyReflectionVector if true, generates code only for the reflection vector computation, not for the reflection coordinates
  21616. * @returns the shader code
  21617. */
  21618. handleFragmentSideCodeReflectionCoords(worldNormalVarName: string, worldPos?: string, onlyReflectionVector?: boolean): string;
  21619. /**
  21620. * Generates the reflection color code for the fragment code path
  21621. * @param lodVarName name of the lod variable
  21622. * @param swizzleLookupTexture swizzle to use for the final color variable
  21623. * @returns the shader code
  21624. */
  21625. handleFragmentSideCodeReflectionColor(lodVarName?: string, swizzleLookupTexture?: string): string;
  21626. /**
  21627. * Generates the code corresponding to the connected output points
  21628. * @param state node material build state
  21629. * @param varName name of the variable to output
  21630. * @returns the shader code
  21631. */
  21632. writeOutputs(state: NodeMaterialBuildState, varName: string): string;
  21633. protected _buildBlock(state: NodeMaterialBuildState): this;
  21634. protected _dumpPropertiesCode(): string;
  21635. serialize(): any;
  21636. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  21637. }
  21638. }
  21639. declare module "babylonjs/Materials/Node/nodeMaterialConnectionPointCustomObject" {
  21640. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  21641. import { NodeMaterialConnectionPoint, NodeMaterialConnectionPointDirection, NodeMaterialConnectionPointCompatibilityStates } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  21642. import { Nullable } from "babylonjs/types";
  21643. /**
  21644. * Defines a connection point to be used for points with a custom object type
  21645. */
  21646. export class NodeMaterialConnectionPointCustomObject<T extends NodeMaterialBlock> extends NodeMaterialConnectionPoint {
  21647. private _blockType;
  21648. private _blockName;
  21649. private _nameForCheking?;
  21650. /**
  21651. * Creates a new connection point
  21652. * @param name defines the connection point name
  21653. * @param ownerBlock defines the block hosting this connection point
  21654. * @param direction defines the direction of the connection point
  21655. */
  21656. constructor(name: string, ownerBlock: NodeMaterialBlock, direction: NodeMaterialConnectionPointDirection, _blockType: new (...args: any[]) => T, _blockName: string, _nameForCheking?: string | undefined);
  21657. /**
  21658. * Gets a number indicating if the current point can be connected to another point
  21659. * @param connectionPoint defines the other connection point
  21660. * @returns a number defining the compatibility state
  21661. */
  21662. checkCompatibilityState(connectionPoint: NodeMaterialConnectionPoint): NodeMaterialConnectionPointCompatibilityStates;
  21663. /**
  21664. * Creates a block suitable to be used as an input for this input point.
  21665. * If null is returned, a block based on the point type will be created.
  21666. * @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
  21667. */
  21668. createCustomInputBlock(): Nullable<[NodeMaterialBlock, string]>;
  21669. }
  21670. }
  21671. declare module "babylonjs/Materials/Node/nodeMaterialDecorator" {
  21672. /**
  21673. * Enum defining the type of properties that can be edited in the property pages in the NME
  21674. */
  21675. export enum PropertyTypeForEdition {
  21676. /** property is a boolean */
  21677. Boolean = 0,
  21678. /** property is a float */
  21679. Float = 1,
  21680. /** property is a Vector2 */
  21681. Vector2 = 2,
  21682. /** property is a list of values */
  21683. List = 3
  21684. }
  21685. /**
  21686. * Interface that defines an option in a variable of type list
  21687. */
  21688. export interface IEditablePropertyListOption {
  21689. /** label of the option */
  21690. "label": string;
  21691. /** value of the option */
  21692. "value": number;
  21693. }
  21694. /**
  21695. * Interface that defines the options available for an editable property
  21696. */
  21697. export interface IEditablePropertyOption {
  21698. /** min value */
  21699. "min"?: number;
  21700. /** max value */
  21701. "max"?: number;
  21702. /** notifiers: indicates which actions to take when the property is changed */
  21703. "notifiers"?: {
  21704. /** the material should be rebuilt */
  21705. "rebuild"?: boolean;
  21706. /** the preview should be updated */
  21707. "update"?: boolean;
  21708. };
  21709. /** list of the options for a variable of type list */
  21710. "options"?: IEditablePropertyListOption[];
  21711. }
  21712. /**
  21713. * Interface that describes an editable property
  21714. */
  21715. export interface IPropertyDescriptionForEdition {
  21716. /** name of the property */
  21717. "propertyName": string;
  21718. /** display name of the property */
  21719. "displayName": string;
  21720. /** type of the property */
  21721. "type": PropertyTypeForEdition;
  21722. /** group of the property - all properties with the same group value will be displayed in a specific section */
  21723. "groupName": string;
  21724. /** options for the property */
  21725. "options": IEditablePropertyOption;
  21726. }
  21727. /**
  21728. * Decorator that flags a property in a node material block as being editable
  21729. */
  21730. export function editableInPropertyPage(displayName: string, propertyType?: PropertyTypeForEdition, groupName?: string, options?: IEditablePropertyOption): (target: any, propertyKey: string) => void;
  21731. }
  21732. declare module "babylonjs/Materials/Node/Blocks/PBR/refractionBlock" {
  21733. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  21734. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  21735. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  21736. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  21737. import { Nullable } from "babylonjs/types";
  21738. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  21739. import { Mesh } from "babylonjs/Meshes/mesh";
  21740. import { SubMesh } from "babylonjs/Meshes/subMesh";
  21741. import { Effect } from "babylonjs/Materials/effect";
  21742. import { Scene } from "babylonjs/scene";
  21743. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  21744. /**
  21745. * Block used to implement the refraction part of the sub surface module of the PBR material
  21746. */
  21747. export class RefractionBlock extends NodeMaterialBlock {
  21748. /** @hidden */
  21749. _define3DName: string;
  21750. /** @hidden */
  21751. _refractionMatrixName: string;
  21752. /** @hidden */
  21753. _defineLODRefractionAlpha: string;
  21754. /** @hidden */
  21755. _defineLinearSpecularRefraction: string;
  21756. /** @hidden */
  21757. _defineOppositeZ: string;
  21758. /** @hidden */
  21759. _cubeSamplerName: string;
  21760. /** @hidden */
  21761. _2DSamplerName: string;
  21762. /** @hidden */
  21763. _vRefractionMicrosurfaceInfosName: string;
  21764. /** @hidden */
  21765. _vRefractionInfosName: string;
  21766. private _scene;
  21767. /**
  21768. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  21769. * Materials half opaque for instance using refraction could benefit from this control.
  21770. */
  21771. linkRefractionWithTransparency: boolean;
  21772. /**
  21773. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  21774. */
  21775. invertRefractionY: boolean;
  21776. /**
  21777. * Gets or sets the texture associated with the node
  21778. */
  21779. texture: Nullable<BaseTexture>;
  21780. /**
  21781. * Create a new RefractionBlock
  21782. * @param name defines the block name
  21783. */
  21784. constructor(name: string);
  21785. /**
  21786. * Gets the current class name
  21787. * @returns the class name
  21788. */
  21789. getClassName(): string;
  21790. /**
  21791. * Gets the intensity input component
  21792. */
  21793. get intensity(): NodeMaterialConnectionPoint;
  21794. /**
  21795. * Gets the index of refraction input component
  21796. */
  21797. get indexOfRefraction(): NodeMaterialConnectionPoint;
  21798. /**
  21799. * Gets the tint at distance input component
  21800. */
  21801. get tintAtDistance(): NodeMaterialConnectionPoint;
  21802. /**
  21803. * Gets the view input component
  21804. */
  21805. get view(): NodeMaterialConnectionPoint;
  21806. /**
  21807. * Gets the refraction object output component
  21808. */
  21809. get refraction(): NodeMaterialConnectionPoint;
  21810. /**
  21811. * Returns true if the block has a texture
  21812. */
  21813. get hasTexture(): boolean;
  21814. protected _getTexture(): Nullable<BaseTexture>;
  21815. autoConfigure(material: NodeMaterial): void;
  21816. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  21817. isReady(): boolean;
  21818. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh, subMesh?: SubMesh): void;
  21819. /**
  21820. * Gets the main code of the block (fragment side)
  21821. * @param state current state of the node material building
  21822. * @returns the shader code
  21823. */
  21824. getCode(state: NodeMaterialBuildState): string;
  21825. protected _buildBlock(state: NodeMaterialBuildState): this;
  21826. protected _dumpPropertiesCode(): string;
  21827. serialize(): any;
  21828. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  21829. }
  21830. }
  21831. declare module "babylonjs/Materials/Node/Blocks/Dual/currentScreenBlock" {
  21832. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  21833. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  21834. import { NodeMaterialBlockTargets } from "babylonjs/Materials/Node/Enums/nodeMaterialBlockTargets";
  21835. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  21836. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  21837. import { NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  21838. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  21839. import { Nullable } from "babylonjs/types";
  21840. import { Scene } from "babylonjs/scene";
  21841. import { NodeMaterial } from "babylonjs/Materials/Node/nodeMaterial";
  21842. /**
  21843. * Base block used as input for post process
  21844. */
  21845. export class CurrentScreenBlock extends NodeMaterialBlock {
  21846. private _samplerName;
  21847. private _linearDefineName;
  21848. private _gammaDefineName;
  21849. private _mainUVName;
  21850. private _tempTextureRead;
  21851. /**
  21852. * Gets or sets the texture associated with the node
  21853. */
  21854. texture: Nullable<BaseTexture>;
  21855. /**
  21856. * Gets or sets a boolean indicating if content needs to be converted to gamma space
  21857. */
  21858. convertToGammaSpace: boolean;
  21859. /**
  21860. * Gets or sets a boolean indicating if content needs to be converted to linear space
  21861. */
  21862. convertToLinearSpace: boolean;
  21863. /**
  21864. * Create a new CurrentScreenBlock
  21865. * @param name defines the block name
  21866. */
  21867. constructor(name: string);
  21868. /**
  21869. * Gets the current class name
  21870. * @returns the class name
  21871. */
  21872. getClassName(): string;
  21873. /**
  21874. * Gets the uv input component
  21875. */
  21876. get uv(): NodeMaterialConnectionPoint;
  21877. /**
  21878. * Gets the rgba output component
  21879. */
  21880. get rgba(): NodeMaterialConnectionPoint;
  21881. /**
  21882. * Gets the rgb output component
  21883. */
  21884. get rgb(): NodeMaterialConnectionPoint;
  21885. /**
  21886. * Gets the r output component
  21887. */
  21888. get r(): NodeMaterialConnectionPoint;
  21889. /**
  21890. * Gets the g output component
  21891. */
  21892. get g(): NodeMaterialConnectionPoint;
  21893. /**
  21894. * Gets the b output component
  21895. */
  21896. get b(): NodeMaterialConnectionPoint;
  21897. /**
  21898. * Gets the a output component
  21899. */
  21900. get a(): NodeMaterialConnectionPoint;
  21901. /**
  21902. * Initialize the block and prepare the context for build
  21903. * @param state defines the state that will be used for the build
  21904. */
  21905. initialize(state: NodeMaterialBuildState): void;
  21906. get target(): NodeMaterialBlockTargets;
  21907. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  21908. isReady(): boolean;
  21909. private _injectVertexCode;
  21910. private _writeTextureRead;
  21911. private _writeOutput;
  21912. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  21913. serialize(): any;
  21914. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  21915. }
  21916. }
  21917. declare module "babylonjs/Materials/Node/Blocks/Particle/particleTextureBlock" {
  21918. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  21919. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  21920. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  21921. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  21922. import { NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  21923. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  21924. import { Nullable } from "babylonjs/types";
  21925. import { Scene } from "babylonjs/scene";
  21926. import { NodeMaterial } from "babylonjs/Materials/Node/nodeMaterial";
  21927. /**
  21928. * Base block used for the particle texture
  21929. */
  21930. export class ParticleTextureBlock extends NodeMaterialBlock {
  21931. private _samplerName;
  21932. private _linearDefineName;
  21933. private _gammaDefineName;
  21934. private _tempTextureRead;
  21935. /**
  21936. * Gets or sets the texture associated with the node
  21937. */
  21938. texture: Nullable<BaseTexture>;
  21939. /**
  21940. * Gets or sets a boolean indicating if content needs to be converted to gamma space
  21941. */
  21942. convertToGammaSpace: boolean;
  21943. /**
  21944. * Gets or sets a boolean indicating if content needs to be converted to linear space
  21945. */
  21946. convertToLinearSpace: boolean;
  21947. /**
  21948. * Create a new ParticleTextureBlock
  21949. * @param name defines the block name
  21950. */
  21951. constructor(name: string);
  21952. /**
  21953. * Gets the current class name
  21954. * @returns the class name
  21955. */
  21956. getClassName(): string;
  21957. /**
  21958. * Gets the uv input component
  21959. */
  21960. get uv(): NodeMaterialConnectionPoint;
  21961. /**
  21962. * Gets the rgba output component
  21963. */
  21964. get rgba(): NodeMaterialConnectionPoint;
  21965. /**
  21966. * Gets the rgb output component
  21967. */
  21968. get rgb(): NodeMaterialConnectionPoint;
  21969. /**
  21970. * Gets the r output component
  21971. */
  21972. get r(): NodeMaterialConnectionPoint;
  21973. /**
  21974. * Gets the g output component
  21975. */
  21976. get g(): NodeMaterialConnectionPoint;
  21977. /**
  21978. * Gets the b output component
  21979. */
  21980. get b(): NodeMaterialConnectionPoint;
  21981. /**
  21982. * Gets the a output component
  21983. */
  21984. get a(): NodeMaterialConnectionPoint;
  21985. /**
  21986. * Initialize the block and prepare the context for build
  21987. * @param state defines the state that will be used for the build
  21988. */
  21989. initialize(state: NodeMaterialBuildState): void;
  21990. autoConfigure(material: NodeMaterial): void;
  21991. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  21992. isReady(): boolean;
  21993. private _writeOutput;
  21994. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  21995. serialize(): any;
  21996. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  21997. }
  21998. }
  21999. declare module "babylonjs/Materials/Node/nodeMaterialBuildStateSharedData" {
  22000. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  22001. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  22002. import { InputBlock } from "babylonjs/Materials/Node/Blocks/Input/inputBlock";
  22003. import { TextureBlock } from "babylonjs/Materials/Node/Blocks/Dual/textureBlock";
  22004. import { ReflectionTextureBaseBlock } from "babylonjs/Materials/Node/Blocks/Dual/reflectionTextureBaseBlock";
  22005. import { RefractionBlock } from "babylonjs/Materials/Node/Blocks/PBR/refractionBlock";
  22006. import { CurrentScreenBlock } from "babylonjs/Materials/Node/Blocks/Dual/currentScreenBlock";
  22007. import { ParticleTextureBlock } from "babylonjs/Materials/Node/Blocks/Particle/particleTextureBlock";
  22008. import { Scene } from "babylonjs/scene";
  22009. /**
  22010. * Class used to store shared data between 2 NodeMaterialBuildState
  22011. */
  22012. export class NodeMaterialBuildStateSharedData {
  22013. /**
  22014. * Gets the list of emitted varyings
  22015. */
  22016. temps: string[];
  22017. /**
  22018. * Gets the list of emitted varyings
  22019. */
  22020. varyings: string[];
  22021. /**
  22022. * Gets the varying declaration string
  22023. */
  22024. varyingDeclaration: string;
  22025. /**
  22026. * Input blocks
  22027. */
  22028. inputBlocks: InputBlock[];
  22029. /**
  22030. * Input blocks
  22031. */
  22032. textureBlocks: (TextureBlock | ReflectionTextureBaseBlock | RefractionBlock | CurrentScreenBlock | ParticleTextureBlock)[];
  22033. /**
  22034. * Bindable blocks (Blocks that need to set data to the effect)
  22035. */
  22036. bindableBlocks: NodeMaterialBlock[];
  22037. /**
  22038. * List of blocks that can provide a compilation fallback
  22039. */
  22040. blocksWithFallbacks: NodeMaterialBlock[];
  22041. /**
  22042. * List of blocks that can provide a define update
  22043. */
  22044. blocksWithDefines: NodeMaterialBlock[];
  22045. /**
  22046. * List of blocks that can provide a repeatable content
  22047. */
  22048. repeatableContentBlocks: NodeMaterialBlock[];
  22049. /**
  22050. * List of blocks that can provide a dynamic list of uniforms
  22051. */
  22052. dynamicUniformBlocks: NodeMaterialBlock[];
  22053. /**
  22054. * List of blocks that can block the isReady function for the material
  22055. */
  22056. blockingBlocks: NodeMaterialBlock[];
  22057. /**
  22058. * Gets the list of animated inputs
  22059. */
  22060. animatedInputs: InputBlock[];
  22061. /**
  22062. * Build Id used to avoid multiple recompilations
  22063. */
  22064. buildId: number;
  22065. /** List of emitted variables */
  22066. variableNames: {
  22067. [key: string]: number;
  22068. };
  22069. /** List of emitted defines */
  22070. defineNames: {
  22071. [key: string]: number;
  22072. };
  22073. /** Should emit comments? */
  22074. emitComments: boolean;
  22075. /** Emit build activity */
  22076. verbose: boolean;
  22077. /** Gets or sets the hosting scene */
  22078. scene: Scene;
  22079. /**
  22080. * Gets the compilation hints emitted at compilation time
  22081. */
  22082. hints: {
  22083. needWorldViewMatrix: boolean;
  22084. needWorldViewProjectionMatrix: boolean;
  22085. needAlphaBlending: boolean;
  22086. needAlphaTesting: boolean;
  22087. };
  22088. /**
  22089. * List of compilation checks
  22090. */
  22091. checks: {
  22092. emitVertex: boolean;
  22093. emitFragment: boolean;
  22094. notConnectedNonOptionalInputs: NodeMaterialConnectionPoint[];
  22095. };
  22096. /**
  22097. * Is vertex program allowed to be empty?
  22098. */
  22099. allowEmptyVertexProgram: boolean;
  22100. /** Creates a new shared data */
  22101. constructor();
  22102. /**
  22103. * Emits console errors and exceptions if there is a failing check
  22104. */
  22105. emitErrors(): void;
  22106. }
  22107. }
  22108. declare module "babylonjs/Materials/Node/nodeMaterialBuildState" {
  22109. import { NodeMaterialBlockConnectionPointTypes } from "babylonjs/Materials/Node/Enums/nodeMaterialBlockConnectionPointTypes";
  22110. import { NodeMaterialBlockTargets } from "babylonjs/Materials/Node/Enums/nodeMaterialBlockTargets";
  22111. import { NodeMaterialBuildStateSharedData } from "babylonjs/Materials/Node/nodeMaterialBuildStateSharedData";
  22112. /**
  22113. * Class used to store node based material build state
  22114. */
  22115. export class NodeMaterialBuildState {
  22116. /** Gets or sets a boolean indicating if the current state can emit uniform buffers */
  22117. supportUniformBuffers: boolean;
  22118. /**
  22119. * Gets the list of emitted attributes
  22120. */
  22121. attributes: string[];
  22122. /**
  22123. * Gets the list of emitted uniforms
  22124. */
  22125. uniforms: string[];
  22126. /**
  22127. * Gets the list of emitted constants
  22128. */
  22129. constants: string[];
  22130. /**
  22131. * Gets the list of emitted samplers
  22132. */
  22133. samplers: string[];
  22134. /**
  22135. * Gets the list of emitted functions
  22136. */
  22137. functions: {
  22138. [key: string]: string;
  22139. };
  22140. /**
  22141. * Gets the list of emitted extensions
  22142. */
  22143. extensions: {
  22144. [key: string]: string;
  22145. };
  22146. /**
  22147. * Gets the target of the compilation state
  22148. */
  22149. target: NodeMaterialBlockTargets;
  22150. /**
  22151. * Gets the list of emitted counters
  22152. */
  22153. counters: {
  22154. [key: string]: number;
  22155. };
  22156. /**
  22157. * Shared data between multiple NodeMaterialBuildState instances
  22158. */
  22159. sharedData: NodeMaterialBuildStateSharedData;
  22160. /** @hidden */
  22161. _vertexState: NodeMaterialBuildState;
  22162. /** @hidden */
  22163. _attributeDeclaration: string;
  22164. /** @hidden */
  22165. _uniformDeclaration: string;
  22166. /** @hidden */
  22167. _constantDeclaration: string;
  22168. /** @hidden */
  22169. _samplerDeclaration: string;
  22170. /** @hidden */
  22171. _varyingTransfer: string;
  22172. /** @hidden */
  22173. _injectAtEnd: string;
  22174. private _repeatableContentAnchorIndex;
  22175. /** @hidden */
  22176. _builtCompilationString: string;
  22177. /**
  22178. * Gets the emitted compilation strings
  22179. */
  22180. compilationString: string;
  22181. /**
  22182. * Finalize the compilation strings
  22183. * @param state defines the current compilation state
  22184. */
  22185. finalize(state: NodeMaterialBuildState): void;
  22186. /** @hidden */
  22187. get _repeatableContentAnchor(): string;
  22188. /** @hidden */
  22189. _getFreeVariableName(prefix: string): string;
  22190. /** @hidden */
  22191. _getFreeDefineName(prefix: string): string;
  22192. /** @hidden */
  22193. _excludeVariableName(name: string): void;
  22194. /** @hidden */
  22195. _emit2DSampler(name: string): void;
  22196. /** @hidden */
  22197. _getGLType(type: NodeMaterialBlockConnectionPointTypes): string;
  22198. /** @hidden */
  22199. _emitExtension(name: string, extension: string, define?: string): void;
  22200. /** @hidden */
  22201. _emitFunction(name: string, code: string, comments: string): void;
  22202. /** @hidden */
  22203. _emitCodeFromInclude(includeName: string, comments: string, options?: {
  22204. replaceStrings?: {
  22205. search: RegExp;
  22206. replace: string;
  22207. }[];
  22208. repeatKey?: string;
  22209. }): string;
  22210. /** @hidden */
  22211. _emitFunctionFromInclude(includeName: string, comments: string, options?: {
  22212. repeatKey?: string;
  22213. removeAttributes?: boolean;
  22214. removeUniforms?: boolean;
  22215. removeVaryings?: boolean;
  22216. removeIfDef?: boolean;
  22217. replaceStrings?: {
  22218. search: RegExp;
  22219. replace: string;
  22220. }[];
  22221. }, storeKey?: string): void;
  22222. /** @hidden */
  22223. _registerTempVariable(name: string): boolean;
  22224. /** @hidden */
  22225. _emitVaryingFromString(name: string, type: string, define?: string, notDefine?: boolean): boolean;
  22226. /** @hidden */
  22227. _emitUniformFromString(name: string, type: string, define?: string, notDefine?: boolean): void;
  22228. /** @hidden */
  22229. _emitFloat(value: number): string;
  22230. }
  22231. }
  22232. declare module "babylonjs/Misc/uniqueIdGenerator" {
  22233. /**
  22234. * Helper class used to generate session unique ID
  22235. */
  22236. export class UniqueIdGenerator {
  22237. private static _UniqueIdCounter;
  22238. /**
  22239. * Gets an unique (relatively to the current scene) Id
  22240. */
  22241. static get UniqueId(): number;
  22242. }
  22243. }
  22244. declare module "babylonjs/Materials/Node/nodeMaterialBlock" {
  22245. import { NodeMaterialBlockConnectionPointTypes } from "babylonjs/Materials/Node/Enums/nodeMaterialBlockConnectionPointTypes";
  22246. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  22247. import { Nullable } from "babylonjs/types";
  22248. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  22249. import { NodeMaterialBlockTargets } from "babylonjs/Materials/Node/Enums/nodeMaterialBlockTargets";
  22250. import { Effect } from "babylonjs/Materials/effect";
  22251. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  22252. import { Mesh } from "babylonjs/Meshes/mesh";
  22253. import { SubMesh } from "babylonjs/Meshes/subMesh";
  22254. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  22255. import { Scene } from "babylonjs/scene";
  22256. import { EffectFallbacks } from "babylonjs/Materials/effectFallbacks";
  22257. /**
  22258. * Defines a block that can be used inside a node based material
  22259. */
  22260. export class NodeMaterialBlock {
  22261. private _buildId;
  22262. private _buildTarget;
  22263. private _target;
  22264. private _isFinalMerger;
  22265. private _isInput;
  22266. private _name;
  22267. protected _isUnique: boolean;
  22268. /** Gets or sets a boolean indicating that only one input can be connected at a time */
  22269. inputsAreExclusive: boolean;
  22270. /** @hidden */
  22271. _codeVariableName: string;
  22272. /** @hidden */
  22273. _inputs: NodeMaterialConnectionPoint[];
  22274. /** @hidden */
  22275. _outputs: NodeMaterialConnectionPoint[];
  22276. /** @hidden */
  22277. _preparationId: number;
  22278. /**
  22279. * Gets the name of the block
  22280. */
  22281. get name(): string;
  22282. /**
  22283. * Sets the name of the block. Will check if the name is valid.
  22284. */
  22285. set name(newName: string);
  22286. /**
  22287. * Gets or sets the unique id of the node
  22288. */
  22289. uniqueId: number;
  22290. /**
  22291. * Gets or sets the comments associated with this block
  22292. */
  22293. comments: string;
  22294. /**
  22295. * Gets a boolean indicating that this block can only be used once per NodeMaterial
  22296. */
  22297. get isUnique(): boolean;
  22298. /**
  22299. * Gets a boolean indicating that this block is an end block (e.g. it is generating a system value)
  22300. */
  22301. get isFinalMerger(): boolean;
  22302. /**
  22303. * Gets a boolean indicating that this block is an input (e.g. it sends data to the shader)
  22304. */
  22305. get isInput(): boolean;
  22306. /**
  22307. * Gets or sets the build Id
  22308. */
  22309. get buildId(): number;
  22310. set buildId(value: number);
  22311. /**
  22312. * Gets or sets the target of the block
  22313. */
  22314. get target(): NodeMaterialBlockTargets;
  22315. set target(value: NodeMaterialBlockTargets);
  22316. /**
  22317. * Gets the list of input points
  22318. */
  22319. get inputs(): NodeMaterialConnectionPoint[];
  22320. /** Gets the list of output points */
  22321. get outputs(): NodeMaterialConnectionPoint[];
  22322. /**
  22323. * Find an input by its name
  22324. * @param name defines the name of the input to look for
  22325. * @returns the input or null if not found
  22326. */
  22327. getInputByName(name: string): Nullable<NodeMaterialConnectionPoint>;
  22328. /**
  22329. * Find an output by its name
  22330. * @param name defines the name of the outputto look for
  22331. * @returns the output or null if not found
  22332. */
  22333. getOutputByName(name: string): Nullable<NodeMaterialConnectionPoint>;
  22334. /**
  22335. * Creates a new NodeMaterialBlock
  22336. * @param name defines the block name
  22337. * @param target defines the target of that block (Vertex by default)
  22338. * @param isFinalMerger defines a boolean indicating that this block is an end block (e.g. it is generating a system value). Default is false
  22339. * @param isInput defines a boolean indicating that this block is an input (e.g. it sends data to the shader). Default is false
  22340. */
  22341. constructor(name: string, target?: NodeMaterialBlockTargets, isFinalMerger?: boolean, isInput?: boolean);
  22342. /**
  22343. * Initialize the block and prepare the context for build
  22344. * @param state defines the state that will be used for the build
  22345. */
  22346. initialize(state: NodeMaterialBuildState): void;
  22347. /**
  22348. * Bind data to effect. Will only be called for blocks with isBindable === true
  22349. * @param effect defines the effect to bind data to
  22350. * @param nodeMaterial defines the hosting NodeMaterial
  22351. * @param mesh defines the mesh that will be rendered
  22352. * @param subMesh defines the submesh that will be rendered
  22353. */
  22354. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh, subMesh?: SubMesh): void;
  22355. protected _declareOutput(output: NodeMaterialConnectionPoint, state: NodeMaterialBuildState): string;
  22356. protected _writeVariable(currentPoint: NodeMaterialConnectionPoint): string;
  22357. protected _writeFloat(value: number): string;
  22358. /**
  22359. * Gets the current class name e.g. "NodeMaterialBlock"
  22360. * @returns the class name
  22361. */
  22362. getClassName(): string;
  22363. /**
  22364. * Register a new input. Must be called inside a block constructor
  22365. * @param name defines the connection point name
  22366. * @param type defines the connection point type
  22367. * @param isOptional defines a boolean indicating that this input can be omitted
  22368. * @param target defines the target to use to limit the connection point (will be VertexAndFragment by default)
  22369. * @param point an already created connection point. If not provided, create a new one
  22370. * @returns the current block
  22371. */
  22372. registerInput(name: string, type: NodeMaterialBlockConnectionPointTypes, isOptional?: boolean, target?: NodeMaterialBlockTargets, point?: NodeMaterialConnectionPoint): this;
  22373. /**
  22374. * Register a new output. Must be called inside a block constructor
  22375. * @param name defines the connection point name
  22376. * @param type defines the connection point type
  22377. * @param target defines the target to use to limit the connection point (will be VertexAndFragment by default)
  22378. * @param point an already created connection point. If not provided, create a new one
  22379. * @returns the current block
  22380. */
  22381. registerOutput(name: string, type: NodeMaterialBlockConnectionPointTypes, target?: NodeMaterialBlockTargets, point?: NodeMaterialConnectionPoint): this;
  22382. /**
  22383. * Will return the first available input e.g. the first one which is not an uniform or an attribute
  22384. * @param forOutput defines an optional connection point to check compatibility with
  22385. * @returns the first available input or null
  22386. */
  22387. getFirstAvailableInput(forOutput?: Nullable<NodeMaterialConnectionPoint>): Nullable<NodeMaterialConnectionPoint>;
  22388. /**
  22389. * Will return the first available output e.g. the first one which is not yet connected and not a varying
  22390. * @param forBlock defines an optional block to check compatibility with
  22391. * @returns the first available input or null
  22392. */
  22393. getFirstAvailableOutput(forBlock?: Nullable<NodeMaterialBlock>): Nullable<NodeMaterialConnectionPoint>;
  22394. /**
  22395. * Gets the sibling of the given output
  22396. * @param current defines the current output
  22397. * @returns the next output in the list or null
  22398. */
  22399. getSiblingOutput(current: NodeMaterialConnectionPoint): Nullable<NodeMaterialConnectionPoint>;
  22400. /**
  22401. * Connect current block with another block
  22402. * @param other defines the block to connect with
  22403. * @param options define the various options to help pick the right connections
  22404. * @returns the current block
  22405. */
  22406. connectTo(other: NodeMaterialBlock, options?: {
  22407. input?: string;
  22408. output?: string;
  22409. outputSwizzle?: string;
  22410. }): this | undefined;
  22411. protected _buildBlock(state: NodeMaterialBuildState): void;
  22412. /**
  22413. * Add uniforms, samplers and uniform buffers at compilation time
  22414. * @param state defines the state to update
  22415. * @param nodeMaterial defines the node material requesting the update
  22416. * @param defines defines the material defines to update
  22417. * @param uniformBuffers defines the list of uniform buffer names
  22418. */
  22419. updateUniformsAndSamples(state: NodeMaterialBuildState, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, uniformBuffers: string[]): void;
  22420. /**
  22421. * Add potential fallbacks if shader compilation fails
  22422. * @param mesh defines the mesh to be rendered
  22423. * @param fallbacks defines the current prioritized list of fallbacks
  22424. */
  22425. provideFallbacks(mesh: AbstractMesh, fallbacks: EffectFallbacks): void;
  22426. /**
  22427. * Initialize defines for shader compilation
  22428. * @param mesh defines the mesh to be rendered
  22429. * @param nodeMaterial defines the node material requesting the update
  22430. * @param defines defines the material defines to update
  22431. * @param useInstances specifies that instances should be used
  22432. */
  22433. initializeDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  22434. /**
  22435. * Update defines for shader compilation
  22436. * @param mesh defines the mesh to be rendered
  22437. * @param nodeMaterial defines the node material requesting the update
  22438. * @param defines defines the material defines to update
  22439. * @param useInstances specifies that instances should be used
  22440. * @param subMesh defines which submesh to render
  22441. */
  22442. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean, subMesh?: SubMesh): void;
  22443. /**
  22444. * Lets the block try to connect some inputs automatically
  22445. * @param material defines the hosting NodeMaterial
  22446. */
  22447. autoConfigure(material: NodeMaterial): void;
  22448. /**
  22449. * Function called when a block is declared as repeatable content generator
  22450. * @param vertexShaderState defines the current compilation state for the vertex shader
  22451. * @param fragmentShaderState defines the current compilation state for the fragment shader
  22452. * @param mesh defines the mesh to be rendered
  22453. * @param defines defines the material defines to update
  22454. */
  22455. replaceRepeatableContent(vertexShaderState: NodeMaterialBuildState, fragmentShaderState: NodeMaterialBuildState, mesh: AbstractMesh, defines: NodeMaterialDefines): void;
  22456. /**
  22457. * Checks if the block is ready
  22458. * @param mesh defines the mesh to be rendered
  22459. * @param nodeMaterial defines the node material requesting the update
  22460. * @param defines defines the material defines to update
  22461. * @param useInstances specifies that instances should be used
  22462. * @returns true if the block is ready
  22463. */
  22464. isReady(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): boolean;
  22465. protected _linkConnectionTypes(inputIndex0: number, inputIndex1: number): void;
  22466. private _processBuild;
  22467. /**
  22468. * Validates the new name for the block node.
  22469. * @param newName the new name to be given to the node.
  22470. * @returns false if the name is a reserve word, else true.
  22471. */
  22472. validateBlockName(newName: string): boolean;
  22473. /**
  22474. * Compile the current node and generate the shader code
  22475. * @param state defines the current compilation state (uniforms, samplers, current string)
  22476. * @param activeBlocks defines the list of active blocks (i.e. blocks to compile)
  22477. * @returns true if already built
  22478. */
  22479. build(state: NodeMaterialBuildState, activeBlocks: NodeMaterialBlock[]): boolean;
  22480. protected _inputRename(name: string): string;
  22481. protected _outputRename(name: string): string;
  22482. protected _dumpPropertiesCode(): string;
  22483. /** @hidden */
  22484. _dumpCode(uniqueNames: string[], alreadyDumped: NodeMaterialBlock[]): string;
  22485. /** @hidden */
  22486. _dumpCodeForOutputConnections(alreadyDumped: NodeMaterialBlock[]): string;
  22487. /**
  22488. * Clone the current block to a new identical block
  22489. * @param scene defines the hosting scene
  22490. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  22491. * @returns a copy of the current block
  22492. */
  22493. clone(scene: Scene, rootUrl?: string): Nullable<NodeMaterialBlock>;
  22494. /**
  22495. * Serializes this block in a JSON representation
  22496. * @returns the serialized block object
  22497. */
  22498. serialize(): any;
  22499. /** @hidden */
  22500. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  22501. private _deserializePortDisplayNamesAndExposedOnFrame;
  22502. /**
  22503. * Release resources
  22504. */
  22505. dispose(): void;
  22506. }
  22507. }
  22508. declare module "babylonjs/Materials/pushMaterial" {
  22509. import { Nullable } from "babylonjs/types";
  22510. import { Scene } from "babylonjs/scene";
  22511. import { Matrix } from "babylonjs/Maths/math.vector";
  22512. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  22513. import { Mesh } from "babylonjs/Meshes/mesh";
  22514. import { Material } from "babylonjs/Materials/material";
  22515. import { Effect } from "babylonjs/Materials/effect";
  22516. import { SubMesh } from "babylonjs/Meshes/subMesh";
  22517. /**
  22518. * Base class of materials working in push mode in babylon JS
  22519. * @hidden
  22520. */
  22521. export class PushMaterial extends Material {
  22522. protected _activeEffect: Effect;
  22523. protected _normalMatrix: Matrix;
  22524. constructor(name: string, scene: Scene);
  22525. getEffect(): Effect;
  22526. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  22527. protected _isReadyForSubMesh(subMesh: SubMesh): boolean;
  22528. /**
  22529. * Binds the given world matrix to the active effect
  22530. *
  22531. * @param world the matrix to bind
  22532. */
  22533. bindOnlyWorldMatrix(world: Matrix): void;
  22534. /**
  22535. * Binds the given normal matrix to the active effect
  22536. *
  22537. * @param normalMatrix the matrix to bind
  22538. */
  22539. bindOnlyNormalMatrix(normalMatrix: Matrix): void;
  22540. bind(world: Matrix, mesh?: Mesh): void;
  22541. protected _afterBind(mesh: Mesh, effect?: Nullable<Effect>): void;
  22542. protected _mustRebind(scene: Scene, effect: Effect, visibility?: number): boolean;
  22543. }
  22544. }
  22545. declare module "babylonjs/Materials/Node/Optimizers/nodeMaterialOptimizer" {
  22546. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  22547. /**
  22548. * Root class for all node material optimizers
  22549. */
  22550. export class NodeMaterialOptimizer {
  22551. /**
  22552. * Function used to optimize a NodeMaterial graph
  22553. * @param vertexOutputNodes defines the list of output nodes for the vertex shader
  22554. * @param fragmentOutputNodes defines the list of output nodes for the fragment shader
  22555. */
  22556. optimize(vertexOutputNodes: NodeMaterialBlock[], fragmentOutputNodes: NodeMaterialBlock[]): void;
  22557. }
  22558. }
  22559. declare module "babylonjs/Materials/Node/Blocks/transformBlock" {
  22560. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  22561. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  22562. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  22563. import { Scene } from "babylonjs/scene";
  22564. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  22565. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  22566. import { SubMesh } from "babylonjs/Meshes/subMesh";
  22567. /**
  22568. * Block used to transform a vector (2, 3 or 4) with a matrix. It will generate a Vector4
  22569. */
  22570. export class TransformBlock extends NodeMaterialBlock {
  22571. /**
  22572. * Defines the value to use to complement W value to transform it to a Vector4
  22573. */
  22574. complementW: number;
  22575. /**
  22576. * Defines the value to use to complement z value to transform it to a Vector4
  22577. */
  22578. complementZ: number;
  22579. /**
  22580. * Creates a new TransformBlock
  22581. * @param name defines the block name
  22582. */
  22583. constructor(name: string);
  22584. /**
  22585. * Gets the current class name
  22586. * @returns the class name
  22587. */
  22588. getClassName(): string;
  22589. /**
  22590. * Gets the vector input
  22591. */
  22592. get vector(): NodeMaterialConnectionPoint;
  22593. /**
  22594. * Gets the output component
  22595. */
  22596. get output(): NodeMaterialConnectionPoint;
  22597. /**
  22598. * Gets the xyz output component
  22599. */
  22600. get xyz(): NodeMaterialConnectionPoint;
  22601. /**
  22602. * Gets the matrix transform input
  22603. */
  22604. get transform(): NodeMaterialConnectionPoint;
  22605. protected _buildBlock(state: NodeMaterialBuildState): this;
  22606. /**
  22607. * Update defines for shader compilation
  22608. * @param mesh defines the mesh to be rendered
  22609. * @param nodeMaterial defines the node material requesting the update
  22610. * @param defines defines the material defines to update
  22611. * @param useInstances specifies that instances should be used
  22612. * @param subMesh defines which submesh to render
  22613. */
  22614. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean, subMesh?: SubMesh): void;
  22615. serialize(): any;
  22616. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  22617. protected _dumpPropertiesCode(): string;
  22618. }
  22619. }
  22620. declare module "babylonjs/Materials/Node/Blocks/Vertex/vertexOutputBlock" {
  22621. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  22622. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  22623. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  22624. /**
  22625. * Block used to output the vertex position
  22626. */
  22627. export class VertexOutputBlock extends NodeMaterialBlock {
  22628. /**
  22629. * Creates a new VertexOutputBlock
  22630. * @param name defines the block name
  22631. */
  22632. constructor(name: string);
  22633. /**
  22634. * Gets the current class name
  22635. * @returns the class name
  22636. */
  22637. getClassName(): string;
  22638. /**
  22639. * Gets the vector input component
  22640. */
  22641. get vector(): NodeMaterialConnectionPoint;
  22642. protected _buildBlock(state: NodeMaterialBuildState): this;
  22643. }
  22644. }
  22645. declare module "babylonjs/Materials/Node/Blocks/Fragment/fragmentOutputBlock" {
  22646. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  22647. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  22648. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  22649. /**
  22650. * Block used to output the final color
  22651. */
  22652. export class FragmentOutputBlock extends NodeMaterialBlock {
  22653. /**
  22654. * Create a new FragmentOutputBlock
  22655. * @param name defines the block name
  22656. */
  22657. constructor(name: string);
  22658. /**
  22659. * Gets the current class name
  22660. * @returns the class name
  22661. */
  22662. getClassName(): string;
  22663. /**
  22664. * Gets the rgba input component
  22665. */
  22666. get rgba(): NodeMaterialConnectionPoint;
  22667. /**
  22668. * Gets the rgb input component
  22669. */
  22670. get rgb(): NodeMaterialConnectionPoint;
  22671. /**
  22672. * Gets the a input component
  22673. */
  22674. get a(): NodeMaterialConnectionPoint;
  22675. protected _buildBlock(state: NodeMaterialBuildState): this;
  22676. }
  22677. }
  22678. declare module "babylonjs/Materials/Node/Blocks/Particle/particleRampGradientBlock" {
  22679. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  22680. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  22681. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  22682. /**
  22683. * Block used for the particle ramp gradient section
  22684. */
  22685. export class ParticleRampGradientBlock extends NodeMaterialBlock {
  22686. /**
  22687. * Create a new ParticleRampGradientBlock
  22688. * @param name defines the block name
  22689. */
  22690. constructor(name: string);
  22691. /**
  22692. * Gets the current class name
  22693. * @returns the class name
  22694. */
  22695. getClassName(): string;
  22696. /**
  22697. * Gets the color input component
  22698. */
  22699. get color(): NodeMaterialConnectionPoint;
  22700. /**
  22701. * Gets the rampColor output component
  22702. */
  22703. get rampColor(): NodeMaterialConnectionPoint;
  22704. /**
  22705. * Initialize the block and prepare the context for build
  22706. * @param state defines the state that will be used for the build
  22707. */
  22708. initialize(state: NodeMaterialBuildState): void;
  22709. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  22710. }
  22711. }
  22712. declare module "babylonjs/Materials/Node/Blocks/Particle/particleBlendMultiplyBlock" {
  22713. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  22714. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  22715. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  22716. /**
  22717. * Block used for the particle blend multiply section
  22718. */
  22719. export class ParticleBlendMultiplyBlock extends NodeMaterialBlock {
  22720. /**
  22721. * Create a new ParticleBlendMultiplyBlock
  22722. * @param name defines the block name
  22723. */
  22724. constructor(name: string);
  22725. /**
  22726. * Gets the current class name
  22727. * @returns the class name
  22728. */
  22729. getClassName(): string;
  22730. /**
  22731. * Gets the color input component
  22732. */
  22733. get color(): NodeMaterialConnectionPoint;
  22734. /**
  22735. * Gets the alphaTexture input component
  22736. */
  22737. get alphaTexture(): NodeMaterialConnectionPoint;
  22738. /**
  22739. * Gets the alphaColor input component
  22740. */
  22741. get alphaColor(): NodeMaterialConnectionPoint;
  22742. /**
  22743. * Gets the blendColor output component
  22744. */
  22745. get blendColor(): NodeMaterialConnectionPoint;
  22746. /**
  22747. * Initialize the block and prepare the context for build
  22748. * @param state defines the state that will be used for the build
  22749. */
  22750. initialize(state: NodeMaterialBuildState): void;
  22751. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  22752. }
  22753. }
  22754. declare module "babylonjs/Materials/Node/Blocks/vectorMergerBlock" {
  22755. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  22756. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  22757. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  22758. /**
  22759. * Block used to create a Vector2/3/4 out of individual inputs (one for each component)
  22760. */
  22761. export class VectorMergerBlock extends NodeMaterialBlock {
  22762. /**
  22763. * Create a new VectorMergerBlock
  22764. * @param name defines the block name
  22765. */
  22766. constructor(name: string);
  22767. /**
  22768. * Gets the current class name
  22769. * @returns the class name
  22770. */
  22771. getClassName(): string;
  22772. /**
  22773. * Gets the xyz component (input)
  22774. */
  22775. get xyzIn(): NodeMaterialConnectionPoint;
  22776. /**
  22777. * Gets the xy component (input)
  22778. */
  22779. get xyIn(): NodeMaterialConnectionPoint;
  22780. /**
  22781. * Gets the x component (input)
  22782. */
  22783. get x(): NodeMaterialConnectionPoint;
  22784. /**
  22785. * Gets the y component (input)
  22786. */
  22787. get y(): NodeMaterialConnectionPoint;
  22788. /**
  22789. * Gets the z component (input)
  22790. */
  22791. get z(): NodeMaterialConnectionPoint;
  22792. /**
  22793. * Gets the w component (input)
  22794. */
  22795. get w(): NodeMaterialConnectionPoint;
  22796. /**
  22797. * Gets the xyzw component (output)
  22798. */
  22799. get xyzw(): NodeMaterialConnectionPoint;
  22800. /**
  22801. * Gets the xyz component (output)
  22802. */
  22803. get xyzOut(): NodeMaterialConnectionPoint;
  22804. /**
  22805. * Gets the xy component (output)
  22806. */
  22807. get xyOut(): NodeMaterialConnectionPoint;
  22808. /**
  22809. * Gets the xy component (output)
  22810. * @deprecated Please use xyOut instead.
  22811. */
  22812. get xy(): NodeMaterialConnectionPoint;
  22813. /**
  22814. * Gets the xyz component (output)
  22815. * @deprecated Please use xyzOut instead.
  22816. */
  22817. get xyz(): NodeMaterialConnectionPoint;
  22818. protected _buildBlock(state: NodeMaterialBuildState): this;
  22819. }
  22820. }
  22821. declare module "babylonjs/Materials/Node/Blocks/remapBlock" {
  22822. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  22823. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  22824. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  22825. import { Vector2 } from "babylonjs/Maths/math.vector";
  22826. import { Scene } from "babylonjs/scene";
  22827. /**
  22828. * Block used to remap a float from a range to a new one
  22829. */
  22830. export class RemapBlock extends NodeMaterialBlock {
  22831. /**
  22832. * Gets or sets the source range
  22833. */
  22834. sourceRange: Vector2;
  22835. /**
  22836. * Gets or sets the target range
  22837. */
  22838. targetRange: Vector2;
  22839. /**
  22840. * Creates a new RemapBlock
  22841. * @param name defines the block name
  22842. */
  22843. constructor(name: string);
  22844. /**
  22845. * Gets the current class name
  22846. * @returns the class name
  22847. */
  22848. getClassName(): string;
  22849. /**
  22850. * Gets the input component
  22851. */
  22852. get input(): NodeMaterialConnectionPoint;
  22853. /**
  22854. * Gets the source min input component
  22855. */
  22856. get sourceMin(): NodeMaterialConnectionPoint;
  22857. /**
  22858. * Gets the source max input component
  22859. */
  22860. get sourceMax(): NodeMaterialConnectionPoint;
  22861. /**
  22862. * Gets the target min input component
  22863. */
  22864. get targetMin(): NodeMaterialConnectionPoint;
  22865. /**
  22866. * Gets the target max input component
  22867. */
  22868. get targetMax(): NodeMaterialConnectionPoint;
  22869. /**
  22870. * Gets the output component
  22871. */
  22872. get output(): NodeMaterialConnectionPoint;
  22873. protected _buildBlock(state: NodeMaterialBuildState): this;
  22874. protected _dumpPropertiesCode(): string;
  22875. serialize(): any;
  22876. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  22877. }
  22878. }
  22879. declare module "babylonjs/Materials/Node/Blocks/multiplyBlock" {
  22880. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  22881. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  22882. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  22883. /**
  22884. * Block used to multiply 2 values
  22885. */
  22886. export class MultiplyBlock extends NodeMaterialBlock {
  22887. /**
  22888. * Creates a new MultiplyBlock
  22889. * @param name defines the block name
  22890. */
  22891. constructor(name: string);
  22892. /**
  22893. * Gets the current class name
  22894. * @returns the class name
  22895. */
  22896. getClassName(): string;
  22897. /**
  22898. * Gets the left operand input component
  22899. */
  22900. get left(): NodeMaterialConnectionPoint;
  22901. /**
  22902. * Gets the right operand input component
  22903. */
  22904. get right(): NodeMaterialConnectionPoint;
  22905. /**
  22906. * Gets the output component
  22907. */
  22908. get output(): NodeMaterialConnectionPoint;
  22909. protected _buildBlock(state: NodeMaterialBuildState): this;
  22910. }
  22911. }
  22912. declare module "babylonjs/Materials/Node/Blocks/colorSplitterBlock" {
  22913. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  22914. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  22915. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  22916. /**
  22917. * Block used to expand a Color3/4 into 4 outputs (one for each component)
  22918. */
  22919. export class ColorSplitterBlock extends NodeMaterialBlock {
  22920. /**
  22921. * Create a new ColorSplitterBlock
  22922. * @param name defines the block name
  22923. */
  22924. constructor(name: string);
  22925. /**
  22926. * Gets the current class name
  22927. * @returns the class name
  22928. */
  22929. getClassName(): string;
  22930. /**
  22931. * Gets the rgba component (input)
  22932. */
  22933. get rgba(): NodeMaterialConnectionPoint;
  22934. /**
  22935. * Gets the rgb component (input)
  22936. */
  22937. get rgbIn(): NodeMaterialConnectionPoint;
  22938. /**
  22939. * Gets the rgb component (output)
  22940. */
  22941. get rgbOut(): NodeMaterialConnectionPoint;
  22942. /**
  22943. * Gets the r component (output)
  22944. */
  22945. get r(): NodeMaterialConnectionPoint;
  22946. /**
  22947. * Gets the g component (output)
  22948. */
  22949. get g(): NodeMaterialConnectionPoint;
  22950. /**
  22951. * Gets the b component (output)
  22952. */
  22953. get b(): NodeMaterialConnectionPoint;
  22954. /**
  22955. * Gets the a component (output)
  22956. */
  22957. get a(): NodeMaterialConnectionPoint;
  22958. protected _inputRename(name: string): string;
  22959. protected _outputRename(name: string): string;
  22960. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  22961. }
  22962. }
  22963. declare module "babylonjs/Materials/Node/nodeMaterial" {
  22964. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  22965. import { PushMaterial } from "babylonjs/Materials/pushMaterial";
  22966. import { Scene } from "babylonjs/scene";
  22967. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  22968. import { Matrix } from "babylonjs/Maths/math.vector";
  22969. import { Mesh } from "babylonjs/Meshes/mesh";
  22970. import { Engine } from "babylonjs/Engines/engine";
  22971. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  22972. import { Observable } from "babylonjs/Misc/observable";
  22973. import { SubMesh } from "babylonjs/Meshes/subMesh";
  22974. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  22975. import { NodeMaterialOptimizer } from "babylonjs/Materials/Node/Optimizers/nodeMaterialOptimizer";
  22976. import { ImageProcessingConfiguration, IImageProcessingConfigurationDefines } from "babylonjs/Materials/imageProcessingConfiguration";
  22977. import { Nullable } from "babylonjs/types";
  22978. import { InputBlock } from "babylonjs/Materials/Node/Blocks/Input/inputBlock";
  22979. import { TextureBlock } from "babylonjs/Materials/Node/Blocks/Dual/textureBlock";
  22980. import { ReflectionTextureBaseBlock } from "babylonjs/Materials/Node/Blocks/Dual/reflectionTextureBaseBlock";
  22981. import { RefractionBlock } from "babylonjs/Materials/Node/Blocks/PBR/refractionBlock";
  22982. import { CurrentScreenBlock } from "babylonjs/Materials/Node/Blocks/Dual/currentScreenBlock";
  22983. import { ParticleTextureBlock } from "babylonjs/Materials/Node/Blocks/Particle/particleTextureBlock";
  22984. import { Effect } from "babylonjs/Materials/effect";
  22985. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  22986. import { Camera } from "babylonjs/Cameras/camera";
  22987. import { NodeMaterialModes } from "babylonjs/Materials/Node/Enums/nodeMaterialModes";
  22988. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  22989. /**
  22990. * Interface used to configure the node material editor
  22991. */
  22992. export interface INodeMaterialEditorOptions {
  22993. /** Define the URl to load node editor script */
  22994. editorURL?: string;
  22995. }
  22996. /** @hidden */
  22997. export class NodeMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  22998. NORMAL: boolean;
  22999. TANGENT: boolean;
  23000. UV1: boolean;
  23001. /** BONES */
  23002. NUM_BONE_INFLUENCERS: number;
  23003. BonesPerMesh: number;
  23004. BONETEXTURE: boolean;
  23005. /** MORPH TARGETS */
  23006. MORPHTARGETS: boolean;
  23007. MORPHTARGETS_NORMAL: boolean;
  23008. MORPHTARGETS_TANGENT: boolean;
  23009. MORPHTARGETS_UV: boolean;
  23010. NUM_MORPH_INFLUENCERS: number;
  23011. /** IMAGE PROCESSING */
  23012. IMAGEPROCESSING: boolean;
  23013. VIGNETTE: boolean;
  23014. VIGNETTEBLENDMODEMULTIPLY: boolean;
  23015. VIGNETTEBLENDMODEOPAQUE: boolean;
  23016. TONEMAPPING: boolean;
  23017. TONEMAPPING_ACES: boolean;
  23018. CONTRAST: boolean;
  23019. EXPOSURE: boolean;
  23020. COLORCURVES: boolean;
  23021. COLORGRADING: boolean;
  23022. COLORGRADING3D: boolean;
  23023. SAMPLER3DGREENDEPTH: boolean;
  23024. SAMPLER3DBGRMAP: boolean;
  23025. IMAGEPROCESSINGPOSTPROCESS: boolean;
  23026. /** MISC. */
  23027. BUMPDIRECTUV: number;
  23028. constructor();
  23029. setValue(name: string, value: any, markAsUnprocessedIfDirty?: boolean): void;
  23030. }
  23031. /**
  23032. * Class used to configure NodeMaterial
  23033. */
  23034. export interface INodeMaterialOptions {
  23035. /**
  23036. * Defines if blocks should emit comments
  23037. */
  23038. emitComments: boolean;
  23039. }
  23040. /**
  23041. * Class used to create a node based material built by assembling shader blocks
  23042. */
  23043. export class NodeMaterial extends PushMaterial {
  23044. private static _BuildIdGenerator;
  23045. private _options;
  23046. private _vertexCompilationState;
  23047. private _fragmentCompilationState;
  23048. private _sharedData;
  23049. private _buildId;
  23050. private _buildWasSuccessful;
  23051. private _cachedWorldViewMatrix;
  23052. private _cachedWorldViewProjectionMatrix;
  23053. private _optimizers;
  23054. private _animationFrame;
  23055. /** Define the Url to load node editor script */
  23056. static EditorURL: string;
  23057. /** Define the Url to load snippets */
  23058. static SnippetUrl: string;
  23059. /** Gets or sets a boolean indicating that node materials should not deserialize textures from json / snippet content */
  23060. static IgnoreTexturesAtLoadTime: boolean;
  23061. private BJSNODEMATERIALEDITOR;
  23062. /** Get the inspector from bundle or global */
  23063. private _getGlobalNodeMaterialEditor;
  23064. /**
  23065. * Snippet ID if the material was created from the snippet server
  23066. */
  23067. snippetId: string;
  23068. /**
  23069. * Gets or sets data used by visual editor
  23070. * @see https://nme.babylonjs.com
  23071. */
  23072. editorData: any;
  23073. /**
  23074. * 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)
  23075. */
  23076. ignoreAlpha: boolean;
  23077. /**
  23078. * Defines the maximum number of lights that can be used in the material
  23079. */
  23080. maxSimultaneousLights: number;
  23081. /**
  23082. * Observable raised when the material is built
  23083. */
  23084. onBuildObservable: Observable<NodeMaterial>;
  23085. /**
  23086. * Gets or sets the root nodes of the material vertex shader
  23087. */
  23088. _vertexOutputNodes: NodeMaterialBlock[];
  23089. /**
  23090. * Gets or sets the root nodes of the material fragment (pixel) shader
  23091. */
  23092. _fragmentOutputNodes: NodeMaterialBlock[];
  23093. /** Gets or sets options to control the node material overall behavior */
  23094. get options(): INodeMaterialOptions;
  23095. set options(options: INodeMaterialOptions);
  23096. /**
  23097. * Default configuration related to image processing available in the standard Material.
  23098. */
  23099. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  23100. /**
  23101. * Gets the image processing configuration used either in this material.
  23102. */
  23103. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  23104. /**
  23105. * Sets the Default image processing configuration used either in the this material.
  23106. *
  23107. * If sets to null, the scene one is in use.
  23108. */
  23109. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  23110. /**
  23111. * Gets an array of blocks that needs to be serialized even if they are not yet connected
  23112. */
  23113. attachedBlocks: NodeMaterialBlock[];
  23114. /**
  23115. * Specifies the mode of the node material
  23116. * @hidden
  23117. */
  23118. _mode: NodeMaterialModes;
  23119. /**
  23120. * Gets the mode property
  23121. */
  23122. get mode(): NodeMaterialModes;
  23123. /**
  23124. * Create a new node based material
  23125. * @param name defines the material name
  23126. * @param scene defines the hosting scene
  23127. * @param options defines creation option
  23128. */
  23129. constructor(name: string, scene?: Scene, options?: Partial<INodeMaterialOptions>);
  23130. /**
  23131. * Gets the current class name of the material e.g. "NodeMaterial"
  23132. * @returns the class name
  23133. */
  23134. getClassName(): string;
  23135. /**
  23136. * Keep track of the image processing observer to allow dispose and replace.
  23137. */
  23138. private _imageProcessingObserver;
  23139. /**
  23140. * Attaches a new image processing configuration to the Standard Material.
  23141. * @param configuration
  23142. */
  23143. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  23144. /**
  23145. * Get a block by its name
  23146. * @param name defines the name of the block to retrieve
  23147. * @returns the required block or null if not found
  23148. */
  23149. getBlockByName(name: string): Nullable<NodeMaterialBlock>;
  23150. /**
  23151. * Get a block by its name
  23152. * @param predicate defines the predicate used to find the good candidate
  23153. * @returns the required block or null if not found
  23154. */
  23155. getBlockByPredicate(predicate: (block: NodeMaterialBlock) => boolean): Nullable<NodeMaterialBlock>;
  23156. /**
  23157. * Get an input block by its name
  23158. * @param predicate defines the predicate used to find the good candidate
  23159. * @returns the required input block or null if not found
  23160. */
  23161. getInputBlockByPredicate(predicate: (block: InputBlock) => boolean): Nullable<InputBlock>;
  23162. /**
  23163. * Gets the list of input blocks attached to this material
  23164. * @returns an array of InputBlocks
  23165. */
  23166. getInputBlocks(): InputBlock[];
  23167. /**
  23168. * Adds a new optimizer to the list of optimizers
  23169. * @param optimizer defines the optimizers to add
  23170. * @returns the current material
  23171. */
  23172. registerOptimizer(optimizer: NodeMaterialOptimizer): this | undefined;
  23173. /**
  23174. * Remove an optimizer from the list of optimizers
  23175. * @param optimizer defines the optimizers to remove
  23176. * @returns the current material
  23177. */
  23178. unregisterOptimizer(optimizer: NodeMaterialOptimizer): this | undefined;
  23179. /**
  23180. * Add a new block to the list of output nodes
  23181. * @param node defines the node to add
  23182. * @returns the current material
  23183. */
  23184. addOutputNode(node: NodeMaterialBlock): this;
  23185. /**
  23186. * Remove a block from the list of root nodes
  23187. * @param node defines the node to remove
  23188. * @returns the current material
  23189. */
  23190. removeOutputNode(node: NodeMaterialBlock): this;
  23191. private _addVertexOutputNode;
  23192. private _removeVertexOutputNode;
  23193. private _addFragmentOutputNode;
  23194. private _removeFragmentOutputNode;
  23195. /**
  23196. * Specifies if the material will require alpha blending
  23197. * @returns a boolean specifying if alpha blending is needed
  23198. */
  23199. needAlphaBlending(): boolean;
  23200. /**
  23201. * Specifies if this material should be rendered in alpha test mode
  23202. * @returns a boolean specifying if an alpha test is needed.
  23203. */
  23204. needAlphaTesting(): boolean;
  23205. private _initializeBlock;
  23206. private _resetDualBlocks;
  23207. /**
  23208. * Remove a block from the current node material
  23209. * @param block defines the block to remove
  23210. */
  23211. removeBlock(block: NodeMaterialBlock): void;
  23212. /**
  23213. * Build the material and generates the inner effect
  23214. * @param verbose defines if the build should log activity
  23215. */
  23216. build(verbose?: boolean): void;
  23217. /**
  23218. * Runs an otpimization phase to try to improve the shader code
  23219. */
  23220. optimize(): void;
  23221. private _prepareDefinesForAttributes;
  23222. /**
  23223. * Create a post process from the material
  23224. * @param camera The camera to apply the render pass to.
  23225. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  23226. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  23227. * @param engine The engine which the post process will be applied. (default: current engine)
  23228. * @param reusable If the post process can be reused on the same frame. (default: false)
  23229. * @param textureType Type of textures used when performing the post process. (default: 0)
  23230. * @param textureFormat Format of textures used when performing the post process. (default: TEXTUREFORMAT_RGBA)
  23231. * @returns the post process created
  23232. */
  23233. createPostProcess(camera: Nullable<Camera>, options?: number | PostProcessOptions, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, textureFormat?: number): PostProcess;
  23234. /**
  23235. * Create the post process effect from the material
  23236. * @param postProcess The post process to create the effect for
  23237. */
  23238. createEffectForPostProcess(postProcess: PostProcess): void;
  23239. private _createEffectOrPostProcess;
  23240. private _createEffectForParticles;
  23241. /**
  23242. * Create the effect to be used as the custom effect for a particle system
  23243. * @param particleSystem Particle system to create the effect for
  23244. * @param onCompiled defines a function to call when the effect creation is successful
  23245. * @param onError defines a function to call when the effect creation has failed
  23246. */
  23247. createEffectForParticles(particleSystem: IParticleSystem, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  23248. private _processDefines;
  23249. /**
  23250. * Get if the submesh is ready to be used and all its information available.
  23251. * Child classes can use it to update shaders
  23252. * @param mesh defines the mesh to check
  23253. * @param subMesh defines which submesh to check
  23254. * @param useInstances specifies that instances should be used
  23255. * @returns a boolean indicating that the submesh is ready or not
  23256. */
  23257. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  23258. /**
  23259. * Get a string representing the shaders built by the current node graph
  23260. */
  23261. get compiledShaders(): string;
  23262. /**
  23263. * Binds the world matrix to the material
  23264. * @param world defines the world transformation matrix
  23265. */
  23266. bindOnlyWorldMatrix(world: Matrix): void;
  23267. /**
  23268. * Binds the submesh to this material by preparing the effect and shader to draw
  23269. * @param world defines the world transformation matrix
  23270. * @param mesh defines the mesh containing the submesh
  23271. * @param subMesh defines the submesh to bind the material to
  23272. */
  23273. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  23274. /**
  23275. * Gets the active textures from the material
  23276. * @returns an array of textures
  23277. */
  23278. getActiveTextures(): BaseTexture[];
  23279. /**
  23280. * Gets the list of texture blocks
  23281. * @returns an array of texture blocks
  23282. */
  23283. getTextureBlocks(): (TextureBlock | ReflectionTextureBaseBlock | RefractionBlock | CurrentScreenBlock | ParticleTextureBlock)[];
  23284. /**
  23285. * Specifies if the material uses a texture
  23286. * @param texture defines the texture to check against the material
  23287. * @returns a boolean specifying if the material uses the texture
  23288. */
  23289. hasTexture(texture: BaseTexture): boolean;
  23290. /**
  23291. * Disposes the material
  23292. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  23293. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  23294. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  23295. */
  23296. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  23297. /** Creates the node editor window. */
  23298. private _createNodeEditor;
  23299. /**
  23300. * Launch the node material editor
  23301. * @param config Define the configuration of the editor
  23302. * @return a promise fulfilled when the node editor is visible
  23303. */
  23304. edit(config?: INodeMaterialEditorOptions): Promise<void>;
  23305. /**
  23306. * Clear the current material
  23307. */
  23308. clear(): void;
  23309. /**
  23310. * Clear the current material and set it to a default state
  23311. */
  23312. setToDefault(): void;
  23313. /**
  23314. * Clear the current material and set it to a default state for post process
  23315. */
  23316. setToDefaultPostProcess(): void;
  23317. /**
  23318. * Clear the current material and set it to a default state for particle
  23319. */
  23320. setToDefaultParticle(): void;
  23321. /**
  23322. * Loads the current Node Material from a url pointing to a file save by the Node Material Editor
  23323. * @param url defines the url to load from
  23324. * @returns a promise that will fullfil when the material is fully loaded
  23325. */
  23326. loadAsync(url: string): Promise<void>;
  23327. private _gatherBlocks;
  23328. /**
  23329. * Generate a string containing the code declaration required to create an equivalent of this material
  23330. * @returns a string
  23331. */
  23332. generateCode(): string;
  23333. /**
  23334. * Serializes this material in a JSON representation
  23335. * @returns the serialized material object
  23336. */
  23337. serialize(selectedBlocks?: NodeMaterialBlock[]): any;
  23338. private _restoreConnections;
  23339. /**
  23340. * Clear the current graph and load a new one from a serialization object
  23341. * @param source defines the JSON representation of the material
  23342. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  23343. * @param merge defines whether or not the source must be merged or replace the current content
  23344. */
  23345. loadFromSerialization(source: any, rootUrl?: string, merge?: boolean): void;
  23346. /**
  23347. * Makes a duplicate of the current material.
  23348. * @param name - name to use for the new material.
  23349. */
  23350. clone(name: string): NodeMaterial;
  23351. /**
  23352. * Creates a node material from parsed material data
  23353. * @param source defines the JSON representation of the material
  23354. * @param scene defines the hosting scene
  23355. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  23356. * @returns a new node material
  23357. */
  23358. static Parse(source: any, scene: Scene, rootUrl?: string): NodeMaterial;
  23359. /**
  23360. * Creates a node material from a snippet saved in a remote file
  23361. * @param name defines the name of the material to create
  23362. * @param url defines the url to load from
  23363. * @param scene defines the hosting scene
  23364. * @returns a promise that will resolve to the new node material
  23365. */
  23366. static ParseFromFileAsync(name: string, url: string, scene: Scene): Promise<NodeMaterial>;
  23367. /**
  23368. * Creates a node material from a snippet saved by the node material editor
  23369. * @param snippetId defines the snippet to load
  23370. * @param scene defines the hosting scene
  23371. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  23372. * @param nodeMaterial defines a node material to update (instead of creating a new one)
  23373. * @returns a promise that will resolve to the new node material
  23374. */
  23375. static ParseFromSnippetAsync(snippetId: string, scene: Scene, rootUrl?: string, nodeMaterial?: NodeMaterial): Promise<NodeMaterial>;
  23376. /**
  23377. * Creates a new node material set to default basic configuration
  23378. * @param name defines the name of the material
  23379. * @param scene defines the hosting scene
  23380. * @returns a new NodeMaterial
  23381. */
  23382. static CreateDefault(name: string, scene?: Scene): NodeMaterial;
  23383. }
  23384. }
  23385. declare module "babylonjs/PostProcesses/postProcess" {
  23386. import { Nullable } from "babylonjs/types";
  23387. import { SmartArray } from "babylonjs/Misc/smartArray";
  23388. import { Observable } from "babylonjs/Misc/observable";
  23389. import { Vector2 } from "babylonjs/Maths/math.vector";
  23390. import { Camera } from "babylonjs/Cameras/camera";
  23391. import { Effect } from "babylonjs/Materials/effect";
  23392. import "babylonjs/Shaders/postprocess.vertex";
  23393. import { IInspectable } from "babylonjs/Misc/iInspectable";
  23394. import { Engine } from "babylonjs/Engines/engine";
  23395. import { Color4 } from "babylonjs/Maths/math.color";
  23396. import "babylonjs/Engines/Extensions/engine.renderTarget";
  23397. import { NodeMaterial } from "babylonjs/Materials/Node/nodeMaterial";
  23398. import { Scene } from "babylonjs/scene";
  23399. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  23400. /**
  23401. * Size options for a post process
  23402. */
  23403. export type PostProcessOptions = {
  23404. width: number;
  23405. height: number;
  23406. };
  23407. /**
  23408. * PostProcess can be used to apply a shader to a texture after it has been rendered
  23409. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  23410. */
  23411. export class PostProcess {
  23412. /**
  23413. * Gets or sets the unique id of the post process
  23414. */
  23415. uniqueId: number;
  23416. /** Name of the PostProcess. */
  23417. name: string;
  23418. /**
  23419. * Width of the texture to apply the post process on
  23420. */
  23421. width: number;
  23422. /**
  23423. * Height of the texture to apply the post process on
  23424. */
  23425. height: number;
  23426. /**
  23427. * Gets the node material used to create this postprocess (null if the postprocess was manually created)
  23428. */
  23429. nodeMaterialSource: Nullable<NodeMaterial>;
  23430. /**
  23431. * Internal, reference to the location where this postprocess was output to. (Typically the texture on the next postprocess in the chain)
  23432. * @hidden
  23433. */
  23434. _outputTexture: Nullable<InternalTexture>;
  23435. /**
  23436. * Sampling mode used by the shader
  23437. * See https://doc.babylonjs.com/classes/3.1/texture
  23438. */
  23439. renderTargetSamplingMode: number;
  23440. /**
  23441. * Clear color to use when screen clearing
  23442. */
  23443. clearColor: Color4;
  23444. /**
  23445. * If the buffer needs to be cleared before applying the post process. (default: true)
  23446. * Should be set to false if shader will overwrite all previous pixels.
  23447. */
  23448. autoClear: boolean;
  23449. /**
  23450. * Type of alpha mode to use when performing the post process (default: Engine.ALPHA_DISABLE)
  23451. */
  23452. alphaMode: number;
  23453. /**
  23454. * Sets the setAlphaBlendConstants of the babylon engine
  23455. */
  23456. alphaConstants: Color4;
  23457. /**
  23458. * Animations to be used for the post processing
  23459. */
  23460. animations: import("babylonjs/Animations/animation").Animation[];
  23461. /**
  23462. * Enable Pixel Perfect mode where texture is not scaled to be power of 2.
  23463. * Can only be used on a single postprocess or on the last one of a chain. (default: false)
  23464. */
  23465. enablePixelPerfectMode: boolean;
  23466. /**
  23467. * Force the postprocess to be applied without taking in account viewport
  23468. */
  23469. forceFullscreenViewport: boolean;
  23470. /**
  23471. * List of inspectable custom properties (used by the Inspector)
  23472. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  23473. */
  23474. inspectableCustomProperties: IInspectable[];
  23475. /**
  23476. * Scale mode for the post process (default: Engine.SCALEMODE_FLOOR)
  23477. *
  23478. * | Value | Type | Description |
  23479. * | ----- | ----------------------------------- | ----------- |
  23480. * | 1 | SCALEMODE_FLOOR | [engine.scalemode_floor](https://doc.babylonjs.com/api/classes/babylon.engine#scalemode_floor) |
  23481. * | 2 | SCALEMODE_NEAREST | [engine.scalemode_nearest](https://doc.babylonjs.com/api/classes/babylon.engine#scalemode_nearest) |
  23482. * | 3 | SCALEMODE_CEILING | [engine.scalemode_ceiling](https://doc.babylonjs.com/api/classes/babylon.engine#scalemode_ceiling) |
  23483. *
  23484. */
  23485. scaleMode: number;
  23486. /**
  23487. * Force textures to be a power of two (default: false)
  23488. */
  23489. alwaysForcePOT: boolean;
  23490. private _samples;
  23491. /**
  23492. * Number of sample textures (default: 1)
  23493. */
  23494. get samples(): number;
  23495. set samples(n: number);
  23496. /**
  23497. * Modify the scale of the post process to be the same as the viewport (default: false)
  23498. */
  23499. adaptScaleToCurrentViewport: boolean;
  23500. private _camera;
  23501. protected _scene: Scene;
  23502. private _engine;
  23503. private _options;
  23504. private _reusable;
  23505. private _textureType;
  23506. private _textureFormat;
  23507. /**
  23508. * Smart array of input and output textures for the post process.
  23509. * @hidden
  23510. */
  23511. _textures: SmartArray<import("babylonjs/Materials/Textures/internalTexture").InternalTexture>;
  23512. /**
  23513. * The index in _textures that corresponds to the output texture.
  23514. * @hidden
  23515. */
  23516. _currentRenderTextureInd: number;
  23517. private _effect;
  23518. private _samplers;
  23519. private _fragmentUrl;
  23520. private _vertexUrl;
  23521. private _parameters;
  23522. private _scaleRatio;
  23523. protected _indexParameters: any;
  23524. private _shareOutputWithPostProcess;
  23525. private _texelSize;
  23526. private _forcedOutputTexture;
  23527. /**
  23528. * Returns the fragment url or shader name used in the post process.
  23529. * @returns the fragment url or name in the shader store.
  23530. */
  23531. getEffectName(): string;
  23532. /**
  23533. * An event triggered when the postprocess is activated.
  23534. */
  23535. onActivateObservable: Observable<Camera>;
  23536. private _onActivateObserver;
  23537. /**
  23538. * A function that is added to the onActivateObservable
  23539. */
  23540. set onActivate(callback: Nullable<(camera: Camera) => void>);
  23541. /**
  23542. * An event triggered when the postprocess changes its size.
  23543. */
  23544. onSizeChangedObservable: Observable<PostProcess>;
  23545. private _onSizeChangedObserver;
  23546. /**
  23547. * A function that is added to the onSizeChangedObservable
  23548. */
  23549. set onSizeChanged(callback: (postProcess: PostProcess) => void);
  23550. /**
  23551. * An event triggered when the postprocess applies its effect.
  23552. */
  23553. onApplyObservable: Observable<Effect>;
  23554. private _onApplyObserver;
  23555. /**
  23556. * A function that is added to the onApplyObservable
  23557. */
  23558. set onApply(callback: (effect: Effect) => void);
  23559. /**
  23560. * An event triggered before rendering the postprocess
  23561. */
  23562. onBeforeRenderObservable: Observable<Effect>;
  23563. private _onBeforeRenderObserver;
  23564. /**
  23565. * A function that is added to the onBeforeRenderObservable
  23566. */
  23567. set onBeforeRender(callback: (effect: Effect) => void);
  23568. /**
  23569. * An event triggered after rendering the postprocess
  23570. */
  23571. onAfterRenderObservable: Observable<Effect>;
  23572. private _onAfterRenderObserver;
  23573. /**
  23574. * A function that is added to the onAfterRenderObservable
  23575. */
  23576. set onAfterRender(callback: (efect: Effect) => void);
  23577. /**
  23578. * 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
  23579. * render it's output into this texture and this texture will be used as textureSampler in the fragment shader of this post process.
  23580. */
  23581. get inputTexture(): InternalTexture;
  23582. set inputTexture(value: InternalTexture);
  23583. /**
  23584. * Since inputTexture should always be defined, if we previously manually set `inputTexture`,
  23585. * the only way to unset it is to use this function to restore its internal state
  23586. */
  23587. restoreDefaultInputTexture(): void;
  23588. /**
  23589. * Gets the camera which post process is applied to.
  23590. * @returns The camera the post process is applied to.
  23591. */
  23592. getCamera(): Camera;
  23593. /**
  23594. * Gets the texel size of the postprocess.
  23595. * See https://en.wikipedia.org/wiki/Texel_(graphics)
  23596. */
  23597. get texelSize(): Vector2;
  23598. /**
  23599. * Creates a new instance PostProcess
  23600. * @param name The name of the PostProcess.
  23601. * @param fragmentUrl The url of the fragment shader to be used.
  23602. * @param parameters Array of the names of uniform non-sampler2D variables that will be passed to the shader.
  23603. * @param samplers Array of the names of uniform sampler2D variables that will be passed to the shader.
  23604. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  23605. * @param camera The camera to apply the render pass to.
  23606. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  23607. * @param engine The engine which the post process will be applied. (default: current engine)
  23608. * @param reusable If the post process can be reused on the same frame. (default: false)
  23609. * @param defines String of defines that will be set when running the fragment shader. (default: null)
  23610. * @param textureType Type of textures used when performing the post process. (default: 0)
  23611. * @param vertexUrl The url of the vertex shader to be used. (default: "postprocess")
  23612. * @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
  23613. * @param blockCompilation If the shader should not be compiled imediatly. (default: false)
  23614. * @param textureFormat Format of textures used when performing the post process. (default: TEXTUREFORMAT_RGBA)
  23615. */
  23616. 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);
  23617. /**
  23618. * Gets a string identifying the name of the class
  23619. * @returns "PostProcess" string
  23620. */
  23621. getClassName(): string;
  23622. /**
  23623. * Gets the engine which this post process belongs to.
  23624. * @returns The engine the post process was enabled with.
  23625. */
  23626. getEngine(): Engine;
  23627. /**
  23628. * The effect that is created when initializing the post process.
  23629. * @returns The created effect corresponding the the postprocess.
  23630. */
  23631. getEffect(): Effect;
  23632. /**
  23633. * To avoid multiple redundant textures for multiple post process, the output the output texture for this post process can be shared with another.
  23634. * @param postProcess The post process to share the output with.
  23635. * @returns This post process.
  23636. */
  23637. shareOutputWith(postProcess: PostProcess): PostProcess;
  23638. /**
  23639. * Reverses the effect of calling shareOutputWith and returns the post process back to its original state.
  23640. * This should be called if the post process that shares output with this post process is disabled/disposed.
  23641. */
  23642. useOwnOutput(): void;
  23643. /**
  23644. * Updates the effect with the current post process compile time values and recompiles the shader.
  23645. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  23646. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  23647. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  23648. * @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
  23649. * @param onCompiled Called when the shader has been compiled.
  23650. * @param onError Called if there is an error when compiling a shader.
  23651. * @param vertexUrl The url of the vertex shader to be used (default: the one given at construction time)
  23652. * @param fragmentUrl The url of the fragment shader to be used (default: the one given at construction time)
  23653. */
  23654. 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;
  23655. /**
  23656. * The post process is reusable if it can be used multiple times within one frame.
  23657. * @returns If the post process is reusable
  23658. */
  23659. isReusable(): boolean;
  23660. /** invalidate frameBuffer to hint the postprocess to create a depth buffer */
  23661. markTextureDirty(): void;
  23662. /**
  23663. * Activates the post process by intializing the textures to be used when executed. Notifies onActivateObservable.
  23664. * 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.
  23665. * @param camera The camera that will be used in the post process. This camera will be used when calling onActivateObservable.
  23666. * @param sourceTexture The source texture to be inspected to get the width and height if not specified in the post process constructor. (default: null)
  23667. * @param forceDepthStencil If true, a depth and stencil buffer will be generated. (default: false)
  23668. * @returns The target texture that was bound to be written to.
  23669. */
  23670. activate(camera: Nullable<Camera>, sourceTexture?: Nullable<InternalTexture>, forceDepthStencil?: boolean): InternalTexture;
  23671. /**
  23672. * If the post process is supported.
  23673. */
  23674. get isSupported(): boolean;
  23675. /**
  23676. * The aspect ratio of the output texture.
  23677. */
  23678. get aspectRatio(): number;
  23679. /**
  23680. * Get a value indicating if the post-process is ready to be used
  23681. * @returns true if the post-process is ready (shader is compiled)
  23682. */
  23683. isReady(): boolean;
  23684. /**
  23685. * Binds all textures and uniforms to the shader, this will be run on every pass.
  23686. * @returns the effect corresponding to this post process. Null if not compiled or not ready.
  23687. */
  23688. apply(): Nullable<Effect>;
  23689. private _disposeTextures;
  23690. /**
  23691. * Disposes the post process.
  23692. * @param camera The camera to dispose the post process on.
  23693. */
  23694. dispose(camera?: Camera): void;
  23695. /**
  23696. * Serializes the particle system to a JSON object
  23697. * @returns the JSON object
  23698. */
  23699. serialize(): any;
  23700. /**
  23701. * Creates a material from parsed material data
  23702. * @param parsedPostProcess defines parsed post process data
  23703. * @param scene defines the hosting scene
  23704. * @param rootUrl defines the root URL to use to load textures
  23705. * @returns a new post process
  23706. */
  23707. static Parse(parsedPostProcess: any, scene: Scene, rootUrl: string): Nullable<PostProcess>;
  23708. }
  23709. }
  23710. declare module "babylonjs/Shaders/ShadersInclude/kernelBlurVaryingDeclaration" {
  23711. /** @hidden */
  23712. export var kernelBlurVaryingDeclaration: {
  23713. name: string;
  23714. shader: string;
  23715. };
  23716. }
  23717. declare module "babylonjs/Shaders/ShadersInclude/kernelBlurFragment" {
  23718. /** @hidden */
  23719. export var kernelBlurFragment: {
  23720. name: string;
  23721. shader: string;
  23722. };
  23723. }
  23724. declare module "babylonjs/Shaders/ShadersInclude/kernelBlurFragment2" {
  23725. /** @hidden */
  23726. export var kernelBlurFragment2: {
  23727. name: string;
  23728. shader: string;
  23729. };
  23730. }
  23731. declare module "babylonjs/Shaders/kernelBlur.fragment" {
  23732. import "babylonjs/Shaders/ShadersInclude/kernelBlurVaryingDeclaration";
  23733. import "babylonjs/Shaders/ShadersInclude/packingFunctions";
  23734. import "babylonjs/Shaders/ShadersInclude/kernelBlurFragment";
  23735. import "babylonjs/Shaders/ShadersInclude/kernelBlurFragment2";
  23736. /** @hidden */
  23737. export var kernelBlurPixelShader: {
  23738. name: string;
  23739. shader: string;
  23740. };
  23741. }
  23742. declare module "babylonjs/Shaders/ShadersInclude/kernelBlurVertex" {
  23743. /** @hidden */
  23744. export var kernelBlurVertex: {
  23745. name: string;
  23746. shader: string;
  23747. };
  23748. }
  23749. declare module "babylonjs/Shaders/kernelBlur.vertex" {
  23750. import "babylonjs/Shaders/ShadersInclude/kernelBlurVaryingDeclaration";
  23751. import "babylonjs/Shaders/ShadersInclude/kernelBlurVertex";
  23752. /** @hidden */
  23753. export var kernelBlurVertexShader: {
  23754. name: string;
  23755. shader: string;
  23756. };
  23757. }
  23758. declare module "babylonjs/PostProcesses/blurPostProcess" {
  23759. import { Vector2 } from "babylonjs/Maths/math.vector";
  23760. import { Nullable } from "babylonjs/types";
  23761. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  23762. import { Camera } from "babylonjs/Cameras/camera";
  23763. import { Effect } from "babylonjs/Materials/effect";
  23764. import { Engine } from "babylonjs/Engines/engine";
  23765. import "babylonjs/Shaders/kernelBlur.fragment";
  23766. import "babylonjs/Shaders/kernelBlur.vertex";
  23767. import { Scene } from "babylonjs/scene";
  23768. /**
  23769. * The Blur Post Process which blurs an image based on a kernel and direction.
  23770. * Can be used twice in x and y directions to perform a guassian blur in two passes.
  23771. */
  23772. export class BlurPostProcess extends PostProcess {
  23773. private blockCompilation;
  23774. protected _kernel: number;
  23775. protected _idealKernel: number;
  23776. protected _packedFloat: boolean;
  23777. private _staticDefines;
  23778. /** The direction in which to blur the image. */
  23779. direction: Vector2;
  23780. /**
  23781. * Sets the length in pixels of the blur sample region
  23782. */
  23783. set kernel(v: number);
  23784. /**
  23785. * Gets the length in pixels of the blur sample region
  23786. */
  23787. get kernel(): number;
  23788. /**
  23789. * Sets wether or not the blur needs to unpack/repack floats
  23790. */
  23791. set packedFloat(v: boolean);
  23792. /**
  23793. * Gets wether or not the blur is unpacking/repacking floats
  23794. */
  23795. get packedFloat(): boolean;
  23796. /**
  23797. * Gets a string identifying the name of the class
  23798. * @returns "BlurPostProcess" string
  23799. */
  23800. getClassName(): string;
  23801. /**
  23802. * Creates a new instance BlurPostProcess
  23803. * @param name The name of the effect.
  23804. * @param direction The direction in which to blur the image.
  23805. * @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.
  23806. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  23807. * @param camera The camera to apply the render pass to.
  23808. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  23809. * @param engine The engine which the post process will be applied. (default: current engine)
  23810. * @param reusable If the post process can be reused on the same frame. (default: false)
  23811. * @param textureType Type of textures used when performing the post process. (default: 0)
  23812. * @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)
  23813. */
  23814. 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);
  23815. /**
  23816. * Updates the effect with the current post process compile time values and recompiles the shader.
  23817. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  23818. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  23819. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  23820. * @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
  23821. * @param onCompiled Called when the shader has been compiled.
  23822. * @param onError Called if there is an error when compiling a shader.
  23823. */
  23824. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  23825. protected _updateParameters(onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  23826. /**
  23827. * Best kernels are odd numbers that when divided by 2, their integer part is even, so 5, 9 or 13.
  23828. * Other odd kernels optimize correctly but require proportionally more samples, even kernels are
  23829. * possible but will produce minor visual artifacts. Since each new kernel requires a new shader we
  23830. * want to minimize kernel changes, having gaps between physical kernels is helpful in that regard.
  23831. * The gaps between physical kernels are compensated for in the weighting of the samples
  23832. * @param idealKernel Ideal blur kernel.
  23833. * @return Nearest best kernel.
  23834. */
  23835. protected _nearestBestKernel(idealKernel: number): number;
  23836. /**
  23837. * Calculates the value of a Gaussian distribution with sigma 3 at a given point.
  23838. * @param x The point on the Gaussian distribution to sample.
  23839. * @return the value of the Gaussian function at x.
  23840. */
  23841. protected _gaussianWeight(x: number): number;
  23842. /**
  23843. * Generates a string that can be used as a floating point number in GLSL.
  23844. * @param x Value to print.
  23845. * @param decimalFigures Number of decimal places to print the number to (excluding trailing 0s).
  23846. * @return GLSL float string.
  23847. */
  23848. protected _glslFloat(x: number, decimalFigures?: number): string;
  23849. /** @hidden */
  23850. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): Nullable<BlurPostProcess>;
  23851. }
  23852. }
  23853. declare module "babylonjs/Materials/Textures/mirrorTexture" {
  23854. import { Scene } from "babylonjs/scene";
  23855. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  23856. import { Plane } from "babylonjs/Maths/math.plane";
  23857. /**
  23858. * Mirror texture can be used to simulate the view from a mirror in a scene.
  23859. * It will dynamically be rendered every frame to adapt to the camera point of view.
  23860. * You can then easily use it as a reflectionTexture on a flat surface.
  23861. * In case the surface is not a plane, please consider relying on reflection probes.
  23862. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  23863. */
  23864. export class MirrorTexture extends RenderTargetTexture {
  23865. private scene;
  23866. /**
  23867. * Define the reflection plane we want to use. The mirrorPlane is usually set to the constructed reflector.
  23868. * 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.
  23869. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  23870. */
  23871. mirrorPlane: Plane;
  23872. /**
  23873. * Define the blur ratio used to blur the reflection if needed.
  23874. */
  23875. set blurRatio(value: number);
  23876. get blurRatio(): number;
  23877. /**
  23878. * Define the adaptive blur kernel used to blur the reflection if needed.
  23879. * This will autocompute the closest best match for the `blurKernel`
  23880. */
  23881. set adaptiveBlurKernel(value: number);
  23882. /**
  23883. * Define the blur kernel used to blur the reflection if needed.
  23884. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  23885. */
  23886. set blurKernel(value: number);
  23887. /**
  23888. * Define the blur kernel on the X Axis used to blur the reflection if needed.
  23889. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  23890. */
  23891. set blurKernelX(value: number);
  23892. get blurKernelX(): number;
  23893. /**
  23894. * Define the blur kernel on the Y Axis used to blur the reflection if needed.
  23895. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  23896. */
  23897. set blurKernelY(value: number);
  23898. get blurKernelY(): number;
  23899. private _autoComputeBlurKernel;
  23900. protected _onRatioRescale(): void;
  23901. private _updateGammaSpace;
  23902. private _imageProcessingConfigChangeObserver;
  23903. private _transformMatrix;
  23904. private _mirrorMatrix;
  23905. private _savedViewMatrix;
  23906. private _blurX;
  23907. private _blurY;
  23908. private _adaptiveBlurKernel;
  23909. private _blurKernelX;
  23910. private _blurKernelY;
  23911. private _blurRatio;
  23912. /**
  23913. * Instantiates a Mirror Texture.
  23914. * Mirror texture can be used to simulate the view from a mirror in a scene.
  23915. * It will dynamically be rendered every frame to adapt to the camera point of view.
  23916. * You can then easily use it as a reflectionTexture on a flat surface.
  23917. * In case the surface is not a plane, please consider relying on reflection probes.
  23918. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  23919. * @param name
  23920. * @param size
  23921. * @param scene
  23922. * @param generateMipMaps
  23923. * @param type
  23924. * @param samplingMode
  23925. * @param generateDepthBuffer
  23926. */
  23927. constructor(name: string, size: number | {
  23928. width: number;
  23929. height: number;
  23930. } | {
  23931. ratio: number;
  23932. }, scene: Scene, generateMipMaps?: boolean, type?: number, samplingMode?: number, generateDepthBuffer?: boolean);
  23933. private _preparePostProcesses;
  23934. /**
  23935. * Clone the mirror texture.
  23936. * @returns the cloned texture
  23937. */
  23938. clone(): MirrorTexture;
  23939. /**
  23940. * Serialize the texture to a JSON representation you could use in Parse later on
  23941. * @returns the serialized JSON representation
  23942. */
  23943. serialize(): any;
  23944. /**
  23945. * Dispose the texture and release its associated resources.
  23946. */
  23947. dispose(): void;
  23948. }
  23949. }
  23950. declare module "babylonjs/Materials/Textures/texture" {
  23951. import { Observable } from "babylonjs/Misc/observable";
  23952. import { Nullable } from "babylonjs/types";
  23953. import { Matrix } from "babylonjs/Maths/math.vector";
  23954. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  23955. import { IInspectable } from "babylonjs/Misc/iInspectable";
  23956. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  23957. import { CubeTexture } from "babylonjs/Materials/Textures/cubeTexture";
  23958. import { MirrorTexture } from "babylonjs/Materials/Textures/mirrorTexture";
  23959. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  23960. import { Scene } from "babylonjs/scene";
  23961. /**
  23962. * This represents a texture in babylon. It can be easily loaded from a network, base64 or html input.
  23963. * @see https://doc.babylonjs.com/babylon101/materials#texture
  23964. */
  23965. export class Texture extends BaseTexture {
  23966. /**
  23967. * Gets or sets a general boolean used to indicate that textures containing direct data (buffers) must be saved as part of the serialization process
  23968. */
  23969. static SerializeBuffers: boolean;
  23970. /** @hidden */
  23971. static _CubeTextureParser: (jsonTexture: any, scene: Scene, rootUrl: string) => CubeTexture;
  23972. /** @hidden */
  23973. static _CreateMirror: (name: string, renderTargetSize: number, scene: Scene, generateMipMaps: boolean) => MirrorTexture;
  23974. /** @hidden */
  23975. static _CreateRenderTargetTexture: (name: string, renderTargetSize: number, scene: Scene, generateMipMaps: boolean) => RenderTargetTexture;
  23976. /** nearest is mag = nearest and min = nearest and mip = linear */
  23977. static readonly NEAREST_SAMPLINGMODE: number;
  23978. /** nearest is mag = nearest and min = nearest and mip = linear */
  23979. static readonly NEAREST_NEAREST_MIPLINEAR: number;
  23980. /** Bilinear is mag = linear and min = linear and mip = nearest */
  23981. static readonly BILINEAR_SAMPLINGMODE: number;
  23982. /** Bilinear is mag = linear and min = linear and mip = nearest */
  23983. static readonly LINEAR_LINEAR_MIPNEAREST: number;
  23984. /** Trilinear is mag = linear and min = linear and mip = linear */
  23985. static readonly TRILINEAR_SAMPLINGMODE: number;
  23986. /** Trilinear is mag = linear and min = linear and mip = linear */
  23987. static readonly LINEAR_LINEAR_MIPLINEAR: number;
  23988. /** mag = nearest and min = nearest and mip = nearest */
  23989. static readonly NEAREST_NEAREST_MIPNEAREST: number;
  23990. /** mag = nearest and min = linear and mip = nearest */
  23991. static readonly NEAREST_LINEAR_MIPNEAREST: number;
  23992. /** mag = nearest and min = linear and mip = linear */
  23993. static readonly NEAREST_LINEAR_MIPLINEAR: number;
  23994. /** mag = nearest and min = linear and mip = none */
  23995. static readonly NEAREST_LINEAR: number;
  23996. /** mag = nearest and min = nearest and mip = none */
  23997. static readonly NEAREST_NEAREST: number;
  23998. /** mag = linear and min = nearest and mip = nearest */
  23999. static readonly LINEAR_NEAREST_MIPNEAREST: number;
  24000. /** mag = linear and min = nearest and mip = linear */
  24001. static readonly LINEAR_NEAREST_MIPLINEAR: number;
  24002. /** mag = linear and min = linear and mip = none */
  24003. static readonly LINEAR_LINEAR: number;
  24004. /** mag = linear and min = nearest and mip = none */
  24005. static readonly LINEAR_NEAREST: number;
  24006. /** Explicit coordinates mode */
  24007. static readonly EXPLICIT_MODE: number;
  24008. /** Spherical coordinates mode */
  24009. static readonly SPHERICAL_MODE: number;
  24010. /** Planar coordinates mode */
  24011. static readonly PLANAR_MODE: number;
  24012. /** Cubic coordinates mode */
  24013. static readonly CUBIC_MODE: number;
  24014. /** Projection coordinates mode */
  24015. static readonly PROJECTION_MODE: number;
  24016. /** Inverse Cubic coordinates mode */
  24017. static readonly SKYBOX_MODE: number;
  24018. /** Inverse Cubic coordinates mode */
  24019. static readonly INVCUBIC_MODE: number;
  24020. /** Equirectangular coordinates mode */
  24021. static readonly EQUIRECTANGULAR_MODE: number;
  24022. /** Equirectangular Fixed coordinates mode */
  24023. static readonly FIXED_EQUIRECTANGULAR_MODE: number;
  24024. /** Equirectangular Fixed Mirrored coordinates mode */
  24025. static readonly FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  24026. /** Texture is not repeating outside of 0..1 UVs */
  24027. static readonly CLAMP_ADDRESSMODE: number;
  24028. /** Texture is repeating outside of 0..1 UVs */
  24029. static readonly WRAP_ADDRESSMODE: number;
  24030. /** Texture is repeating and mirrored */
  24031. static readonly MIRROR_ADDRESSMODE: number;
  24032. /**
  24033. * 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
  24034. */
  24035. static UseSerializedUrlIfAny: boolean;
  24036. /**
  24037. * Define the url of the texture.
  24038. */
  24039. url: Nullable<string>;
  24040. /**
  24041. * Define an offset on the texture to offset the u coordinates of the UVs
  24042. * @see https://doc.babylonjs.com/how_to/more_materials#offsetting
  24043. */
  24044. uOffset: number;
  24045. /**
  24046. * Define an offset on the texture to offset the v coordinates of the UVs
  24047. * @see https://doc.babylonjs.com/how_to/more_materials#offsetting
  24048. */
  24049. vOffset: number;
  24050. /**
  24051. * Define an offset on the texture to scale the u coordinates of the UVs
  24052. * @see https://doc.babylonjs.com/how_to/more_materials#tiling
  24053. */
  24054. uScale: number;
  24055. /**
  24056. * Define an offset on the texture to scale the v coordinates of the UVs
  24057. * @see https://doc.babylonjs.com/how_to/more_materials#tiling
  24058. */
  24059. vScale: number;
  24060. /**
  24061. * Define an offset on the texture to rotate around the u coordinates of the UVs
  24062. * @see https://doc.babylonjs.com/how_to/more_materials
  24063. */
  24064. uAng: number;
  24065. /**
  24066. * Define an offset on the texture to rotate around the v coordinates of the UVs
  24067. * @see https://doc.babylonjs.com/how_to/more_materials
  24068. */
  24069. vAng: number;
  24070. /**
  24071. * Define an offset on the texture to rotate around the w coordinates of the UVs (in case of 3d texture)
  24072. * @see https://doc.babylonjs.com/how_to/more_materials
  24073. */
  24074. wAng: number;
  24075. /**
  24076. * Defines the center of rotation (U)
  24077. */
  24078. uRotationCenter: number;
  24079. /**
  24080. * Defines the center of rotation (V)
  24081. */
  24082. vRotationCenter: number;
  24083. /**
  24084. * Defines the center of rotation (W)
  24085. */
  24086. wRotationCenter: number;
  24087. /**
  24088. * Are mip maps generated for this texture or not.
  24089. */
  24090. get noMipmap(): boolean;
  24091. /**
  24092. * List of inspectable custom properties (used by the Inspector)
  24093. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  24094. */
  24095. inspectableCustomProperties: Nullable<IInspectable[]>;
  24096. private _noMipmap;
  24097. /** @hidden */
  24098. _invertY: boolean;
  24099. private _rowGenerationMatrix;
  24100. private _cachedTextureMatrix;
  24101. private _projectionModeMatrix;
  24102. private _t0;
  24103. private _t1;
  24104. private _t2;
  24105. private _cachedUOffset;
  24106. private _cachedVOffset;
  24107. private _cachedUScale;
  24108. private _cachedVScale;
  24109. private _cachedUAng;
  24110. private _cachedVAng;
  24111. private _cachedWAng;
  24112. private _cachedProjectionMatrixId;
  24113. private _cachedCoordinatesMode;
  24114. /** @hidden */
  24115. protected _initialSamplingMode: number;
  24116. /** @hidden */
  24117. _buffer: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob | ImageBitmap>;
  24118. private _deleteBuffer;
  24119. protected _format: Nullable<number>;
  24120. private _delayedOnLoad;
  24121. private _delayedOnError;
  24122. private _mimeType?;
  24123. /** Returns the texture mime type if it was defined by a loader (undefined else) */
  24124. get mimeType(): string | undefined;
  24125. /**
  24126. * Observable triggered once the texture has been loaded.
  24127. */
  24128. onLoadObservable: Observable<Texture>;
  24129. protected _isBlocking: boolean;
  24130. /**
  24131. * Is the texture preventing material to render while loading.
  24132. * If false, a default texture will be used instead of the loading one during the preparation step.
  24133. */
  24134. set isBlocking(value: boolean);
  24135. get isBlocking(): boolean;
  24136. /**
  24137. * Get the current sampling mode associated with the texture.
  24138. */
  24139. get samplingMode(): number;
  24140. /**
  24141. * Gets a boolean indicating if the texture needs to be inverted on the y axis during loading
  24142. */
  24143. get invertY(): boolean;
  24144. /**
  24145. * Instantiates a new texture.
  24146. * This represents a texture in babylon. It can be easily loaded from a network, base64 or html input.
  24147. * @see https://doc.babylonjs.com/babylon101/materials#texture
  24148. * @param url defines the url of the picture to load as a texture
  24149. * @param sceneOrEngine defines the scene or engine the texture will belong to
  24150. * @param noMipmap defines if the texture will require mip maps or not
  24151. * @param invertY defines if the texture needs to be inverted on the y axis during loading
  24152. * @param samplingMode defines the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  24153. * @param onLoad defines a callback triggered when the texture has been loaded
  24154. * @param onError defines a callback triggered when an error occurred during the loading session
  24155. * @param buffer defines the buffer to load the texture from in case the texture is loaded from a buffer representation
  24156. * @param deleteBuffer defines if the buffer we are loading the texture from should be deleted after load
  24157. * @param format defines the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  24158. * @param mimeType defines an optional mime type information
  24159. */
  24160. 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);
  24161. /**
  24162. * Update the url (and optional buffer) of this texture if url was null during construction.
  24163. * @param url the url of the texture
  24164. * @param buffer the buffer of the texture (defaults to null)
  24165. * @param onLoad callback called when the texture is loaded (defaults to null)
  24166. */
  24167. updateURL(url: string, buffer?: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob>, onLoad?: () => void): void;
  24168. /**
  24169. * Finish the loading sequence of a texture flagged as delayed load.
  24170. * @hidden
  24171. */
  24172. delayLoad(): void;
  24173. private _prepareRowForTextureGeneration;
  24174. /**
  24175. * Get the current texture matrix which includes the requested offsetting, tiling and rotation components.
  24176. * @returns the transform matrix of the texture.
  24177. */
  24178. getTextureMatrix(uBase?: number): Matrix;
  24179. /**
  24180. * Get the current matrix used to apply reflection. This is useful to rotate an environment texture for instance.
  24181. * @returns The reflection texture transform
  24182. */
  24183. getReflectionTextureMatrix(): Matrix;
  24184. /**
  24185. * Clones the texture.
  24186. * @returns the cloned texture
  24187. */
  24188. clone(): Texture;
  24189. /**
  24190. * Serialize the texture to a JSON representation we can easily use in the resepective Parse function.
  24191. * @returns The JSON representation of the texture
  24192. */
  24193. serialize(): any;
  24194. /**
  24195. * Get the current class name of the texture useful for serialization or dynamic coding.
  24196. * @returns "Texture"
  24197. */
  24198. getClassName(): string;
  24199. /**
  24200. * Dispose the texture and release its associated resources.
  24201. */
  24202. dispose(): void;
  24203. /**
  24204. * Parse the JSON representation of a texture in order to recreate the texture in the given scene.
  24205. * @param parsedTexture Define the JSON representation of the texture
  24206. * @param scene Define the scene the parsed texture should be instantiated in
  24207. * @param rootUrl Define the root url of the parsing sequence in the case of relative dependencies
  24208. * @returns The parsed texture if successful
  24209. */
  24210. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<BaseTexture>;
  24211. /**
  24212. * Creates a texture from its base 64 representation.
  24213. * @param data Define the base64 payload without the data: prefix
  24214. * @param name Define the name of the texture in the scene useful fo caching purpose for instance
  24215. * @param scene Define the scene the texture should belong to
  24216. * @param noMipmap Forces the texture to not create mip map information if true
  24217. * @param invertY define if the texture needs to be inverted on the y axis during loading
  24218. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  24219. * @param onLoad define a callback triggered when the texture has been loaded
  24220. * @param onError define a callback triggered when an error occurred during the loading session
  24221. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  24222. * @returns the created texture
  24223. */
  24224. static CreateFromBase64String(data: string, name: string, scene: Scene, noMipmap?: boolean, invertY?: boolean, samplingMode?: number, onLoad?: Nullable<() => void>, onError?: Nullable<() => void>, format?: number): Texture;
  24225. /**
  24226. * Creates a texture from its data: representation. (data: will be added in case only the payload has been passed in)
  24227. * @param data Define the base64 payload without the data: prefix
  24228. * @param name Define the name of the texture in the scene useful fo caching purpose for instance
  24229. * @param buffer define the buffer to load the texture from in case the texture is loaded from a buffer representation
  24230. * @param scene Define the scene the texture should belong to
  24231. * @param deleteBuffer define if the buffer we are loading the texture from should be deleted after load
  24232. * @param noMipmap Forces the texture to not create mip map information if true
  24233. * @param invertY define if the texture needs to be inverted on the y axis during loading
  24234. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  24235. * @param onLoad define a callback triggered when the texture has been loaded
  24236. * @param onError define a callback triggered when an error occurred during the loading session
  24237. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  24238. * @returns the created texture
  24239. */
  24240. 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;
  24241. }
  24242. }
  24243. declare module "babylonjs/PostProcesses/postProcessManager" {
  24244. import { Nullable } from "babylonjs/types";
  24245. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  24246. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  24247. import { Scene } from "babylonjs/scene";
  24248. /**
  24249. * PostProcessManager is used to manage one or more post processes or post process pipelines
  24250. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  24251. */
  24252. export class PostProcessManager {
  24253. private _scene;
  24254. private _indexBuffer;
  24255. private _vertexBuffers;
  24256. /**
  24257. * Creates a new instance PostProcess
  24258. * @param scene The scene that the post process is associated with.
  24259. */
  24260. constructor(scene: Scene);
  24261. private _prepareBuffers;
  24262. private _buildIndexBuffer;
  24263. /**
  24264. * Rebuilds the vertex buffers of the manager.
  24265. * @hidden
  24266. */
  24267. _rebuild(): void;
  24268. /**
  24269. * Prepares a frame to be run through a post process.
  24270. * @param sourceTexture The input texture to the post procesess. (default: null)
  24271. * @param postProcesses An array of post processes to be run. (default: null)
  24272. * @returns True if the post processes were able to be run.
  24273. * @hidden
  24274. */
  24275. _prepareFrame(sourceTexture?: Nullable<InternalTexture>, postProcesses?: Nullable<PostProcess[]>): boolean;
  24276. /**
  24277. * Manually render a set of post processes to a texture.
  24278. * Please note, the frame buffer won't be unbound after the call in case you have more render to do.
  24279. * @param postProcesses An array of post processes to be run.
  24280. * @param targetTexture The target texture to render to.
  24281. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight
  24282. * @param faceIndex defines the face to render to if a cubemap is defined as the target
  24283. * @param lodLevel defines which lod of the texture to render to
  24284. * @param doNotBindFrambuffer If set to true, assumes that the framebuffer has been bound previously
  24285. */
  24286. directRender(postProcesses: PostProcess[], targetTexture?: Nullable<InternalTexture>, forceFullscreenViewport?: boolean, faceIndex?: number, lodLevel?: number, doNotBindFrambuffer?: boolean): void;
  24287. /**
  24288. * Finalize the result of the output of the postprocesses.
  24289. * @param doNotPresent If true the result will not be displayed to the screen.
  24290. * @param targetTexture The target texture to render to.
  24291. * @param faceIndex The index of the face to bind the target texture to.
  24292. * @param postProcesses The array of post processes to render.
  24293. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight (default: false)
  24294. * @hidden
  24295. */
  24296. _finalizeFrame(doNotPresent?: boolean, targetTexture?: InternalTexture, faceIndex?: number, postProcesses?: Array<PostProcess>, forceFullscreenViewport?: boolean): void;
  24297. /**
  24298. * Disposes of the post process manager.
  24299. */
  24300. dispose(): void;
  24301. }
  24302. }
  24303. declare module "babylonjs/Materials/Textures/renderTargetTexture" {
  24304. import { Observable } from "babylonjs/Misc/observable";
  24305. import { SmartArray } from "babylonjs/Misc/smartArray";
  24306. import { Nullable, Immutable } from "babylonjs/types";
  24307. import { Camera } from "babylonjs/Cameras/camera";
  24308. import { Scene } from "babylonjs/scene";
  24309. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  24310. import { Color4 } from "babylonjs/Maths/math.color";
  24311. import { RenderTargetCreationOptions } from "babylonjs/Materials/Textures/renderTargetCreationOptions";
  24312. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  24313. import { SubMesh } from "babylonjs/Meshes/subMesh";
  24314. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  24315. import { Texture } from "babylonjs/Materials/Textures/texture";
  24316. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  24317. import { RenderingManager } from "babylonjs/Rendering/renderingManager";
  24318. import "babylonjs/Engines/Extensions/engine.renderTarget";
  24319. import "babylonjs/Engines/Extensions/engine.renderTargetCube";
  24320. import { Engine } from "babylonjs/Engines/engine";
  24321. /**
  24322. * This Helps creating a texture that will be created from a camera in your scene.
  24323. * It is basically a dynamic texture that could be used to create special effects for instance.
  24324. * Actually, It is the base of lot of effects in the framework like post process, shadows, effect layers and rendering pipelines...
  24325. */
  24326. export class RenderTargetTexture extends Texture {
  24327. /**
  24328. * The texture will only be rendered once which can be useful to improve performance if everything in your render is static for instance.
  24329. */
  24330. static readonly REFRESHRATE_RENDER_ONCE: number;
  24331. /**
  24332. * The texture will only be rendered rendered every frame and is recomended for dynamic contents.
  24333. */
  24334. static readonly REFRESHRATE_RENDER_ONEVERYFRAME: number;
  24335. /**
  24336. * The texture will be rendered every 2 frames which could be enough if your dynamic objects are not
  24337. * the central point of your effect and can save a lot of performances.
  24338. */
  24339. static readonly REFRESHRATE_RENDER_ONEVERYTWOFRAMES: number;
  24340. /**
  24341. * Use this predicate to dynamically define the list of mesh you want to render.
  24342. * If set, the renderList property will be overwritten.
  24343. */
  24344. renderListPredicate: (AbstractMesh: AbstractMesh) => boolean;
  24345. private _renderList;
  24346. /**
  24347. * Use this list to define the list of mesh you want to render.
  24348. */
  24349. get renderList(): Nullable<Array<AbstractMesh>>;
  24350. set renderList(value: Nullable<Array<AbstractMesh>>);
  24351. /**
  24352. * Use this function to overload the renderList array at rendering time.
  24353. * Return null to render with the curent renderList, else return the list of meshes to use for rendering.
  24354. * For 2DArray RTT, layerOrFace is the index of the layer that is going to be rendered, else it is the faceIndex of
  24355. * the cube (if the RTT is a cube, else layerOrFace=0).
  24356. * The renderList passed to the function is the current render list (the one that will be used if the function returns null).
  24357. * The length of this list is passed through renderListLength: don't use renderList.length directly because the array can
  24358. * hold dummy elements!
  24359. */
  24360. getCustomRenderList: (layerOrFace: number, renderList: Nullable<Immutable<Array<AbstractMesh>>>, renderListLength: number) => Nullable<Array<AbstractMesh>>;
  24361. private _hookArray;
  24362. /**
  24363. * Define if particles should be rendered in your texture.
  24364. */
  24365. renderParticles: boolean;
  24366. /**
  24367. * Define if sprites should be rendered in your texture.
  24368. */
  24369. renderSprites: boolean;
  24370. /**
  24371. * Define the camera used to render the texture.
  24372. */
  24373. activeCamera: Nullable<Camera>;
  24374. /**
  24375. * Override the mesh isReady function with your own one.
  24376. */
  24377. customIsReadyFunction: (mesh: AbstractMesh, refreshRate: number) => boolean;
  24378. /**
  24379. * Override the render function of the texture with your own one.
  24380. */
  24381. customRenderFunction: (opaqueSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>, beforeTransparents?: () => void) => void;
  24382. /**
  24383. * Define if camera post processes should be use while rendering the texture.
  24384. */
  24385. useCameraPostProcesses: boolean;
  24386. /**
  24387. * Define if the camera viewport should be respected while rendering the texture or if the render should be done to the entire texture.
  24388. */
  24389. ignoreCameraViewport: boolean;
  24390. private _postProcessManager;
  24391. private _postProcesses;
  24392. private _resizeObserver;
  24393. /**
  24394. * An event triggered when the texture is unbind.
  24395. */
  24396. onBeforeBindObservable: Observable<RenderTargetTexture>;
  24397. /**
  24398. * An event triggered when the texture is unbind.
  24399. */
  24400. onAfterUnbindObservable: Observable<RenderTargetTexture>;
  24401. private _onAfterUnbindObserver;
  24402. /**
  24403. * Set a after unbind callback in the texture.
  24404. * This has been kept for backward compatibility and use of onAfterUnbindObservable is recommended.
  24405. */
  24406. set onAfterUnbind(callback: () => void);
  24407. /**
  24408. * An event triggered before rendering the texture
  24409. */
  24410. onBeforeRenderObservable: Observable<number>;
  24411. private _onBeforeRenderObserver;
  24412. /**
  24413. * Set a before render callback in the texture.
  24414. * This has been kept for backward compatibility and use of onBeforeRenderObservable is recommended.
  24415. */
  24416. set onBeforeRender(callback: (faceIndex: number) => void);
  24417. /**
  24418. * An event triggered after rendering the texture
  24419. */
  24420. onAfterRenderObservable: Observable<number>;
  24421. private _onAfterRenderObserver;
  24422. /**
  24423. * Set a after render callback in the texture.
  24424. * This has been kept for backward compatibility and use of onAfterRenderObservable is recommended.
  24425. */
  24426. set onAfterRender(callback: (faceIndex: number) => void);
  24427. /**
  24428. * An event triggered after the texture clear
  24429. */
  24430. onClearObservable: Observable<Engine>;
  24431. private _onClearObserver;
  24432. /**
  24433. * Set a clear callback in the texture.
  24434. * This has been kept for backward compatibility and use of onClearObservable is recommended.
  24435. */
  24436. set onClear(callback: (Engine: Engine) => void);
  24437. /**
  24438. * An event triggered when the texture is resized.
  24439. */
  24440. onResizeObservable: Observable<RenderTargetTexture>;
  24441. /**
  24442. * Define the clear color of the Render Target if it should be different from the scene.
  24443. */
  24444. clearColor: Color4;
  24445. protected _size: number | {
  24446. width: number;
  24447. height: number;
  24448. layers?: number;
  24449. };
  24450. protected _initialSizeParameter: number | {
  24451. width: number;
  24452. height: number;
  24453. } | {
  24454. ratio: number;
  24455. };
  24456. protected _sizeRatio: Nullable<number>;
  24457. /** @hidden */
  24458. _generateMipMaps: boolean;
  24459. protected _renderingManager: RenderingManager;
  24460. /** @hidden */
  24461. _waitingRenderList?: string[];
  24462. protected _doNotChangeAspectRatio: boolean;
  24463. protected _currentRefreshId: number;
  24464. protected _refreshRate: number;
  24465. protected _textureMatrix: Matrix;
  24466. protected _samples: number;
  24467. protected _renderTargetOptions: RenderTargetCreationOptions;
  24468. /**
  24469. * Gets render target creation options that were used.
  24470. */
  24471. get renderTargetOptions(): RenderTargetCreationOptions;
  24472. protected _onRatioRescale(): void;
  24473. /**
  24474. * Gets or sets the center of the bounding box associated with the texture (when in cube mode)
  24475. * It must define where the camera used to render the texture is set
  24476. */
  24477. boundingBoxPosition: Vector3;
  24478. private _boundingBoxSize;
  24479. /**
  24480. * Gets or sets the size of the bounding box associated with the texture (when in cube mode)
  24481. * When defined, the cubemap will switch to local mode
  24482. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  24483. * @example https://www.babylonjs-playground.com/#RNASML
  24484. */
  24485. set boundingBoxSize(value: Vector3);
  24486. get boundingBoxSize(): Vector3;
  24487. /**
  24488. * In case the RTT has been created with a depth texture, get the associated
  24489. * depth texture.
  24490. * Otherwise, return null.
  24491. */
  24492. get depthStencilTexture(): Nullable<InternalTexture>;
  24493. /**
  24494. * Instantiate a render target texture. This is mainly used to render of screen the scene to for instance apply post processse
  24495. * or used a shadow, depth texture...
  24496. * @param name The friendly name of the texture
  24497. * @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)
  24498. * @param scene The scene the RTT belongs to. The latest created scene will be used if not precised.
  24499. * @param generateMipMaps True if mip maps need to be generated after render.
  24500. * @param doNotChangeAspectRatio True to not change the aspect ratio of the scene in the RTT
  24501. * @param type The type of the buffer in the RTT (int, half float, float...)
  24502. * @param isCube True if a cube texture needs to be created
  24503. * @param samplingMode The sampling mode to be usedwith the render target (Linear, Nearest...)
  24504. * @param generateDepthBuffer True to generate a depth buffer
  24505. * @param generateStencilBuffer True to generate a stencil buffer
  24506. * @param isMulti True if multiple textures need to be created (Draw Buffers)
  24507. * @param format The internal format of the buffer in the RTT (RED, RG, RGB, RGBA, ALPHA...)
  24508. * @param delayAllocation if the texture allocation should be delayed (default: false)
  24509. */
  24510. constructor(name: string, size: number | {
  24511. width: number;
  24512. height: number;
  24513. layers?: number;
  24514. } | {
  24515. ratio: number;
  24516. }, scene: Nullable<Scene>, generateMipMaps?: boolean, doNotChangeAspectRatio?: boolean, type?: number, isCube?: boolean, samplingMode?: number, generateDepthBuffer?: boolean, generateStencilBuffer?: boolean, isMulti?: boolean, format?: number, delayAllocation?: boolean);
  24517. /**
  24518. * Creates a depth stencil texture.
  24519. * This is only available in WebGL 2 or with the depth texture extension available.
  24520. * @param comparisonFunction Specifies the comparison function to set on the texture. If 0 or undefined, the texture is not in comparison mode
  24521. * @param bilinearFiltering Specifies whether or not bilinear filtering is enable on the texture
  24522. * @param generateStencil Specifies whether or not a stencil should be allocated in the texture
  24523. */
  24524. createDepthStencilTexture(comparisonFunction?: number, bilinearFiltering?: boolean, generateStencil?: boolean): void;
  24525. private _processSizeParameter;
  24526. /**
  24527. * Define the number of samples to use in case of MSAA.
  24528. * It defaults to one meaning no MSAA has been enabled.
  24529. */
  24530. get samples(): number;
  24531. set samples(value: number);
  24532. /**
  24533. * Resets the refresh counter of the texture and start bak from scratch.
  24534. * Could be useful to regenerate the texture if it is setup to render only once.
  24535. */
  24536. resetRefreshCounter(): void;
  24537. /**
  24538. * Define the refresh rate of the texture or the rendering frequency.
  24539. * Use 0 to render just once, 1 to render on every frame, 2 to render every two frames and so on...
  24540. */
  24541. get refreshRate(): number;
  24542. set refreshRate(value: number);
  24543. /**
  24544. * Adds a post process to the render target rendering passes.
  24545. * @param postProcess define the post process to add
  24546. */
  24547. addPostProcess(postProcess: PostProcess): void;
  24548. /**
  24549. * Clear all the post processes attached to the render target
  24550. * @param dispose define if the cleared post processesshould also be disposed (false by default)
  24551. */
  24552. clearPostProcesses(dispose?: boolean): void;
  24553. /**
  24554. * Remove one of the post process from the list of attached post processes to the texture
  24555. * @param postProcess define the post process to remove from the list
  24556. */
  24557. removePostProcess(postProcess: PostProcess): void;
  24558. /** @hidden */
  24559. _shouldRender(): boolean;
  24560. /**
  24561. * Gets the actual render size of the texture.
  24562. * @returns the width of the render size
  24563. */
  24564. getRenderSize(): number;
  24565. /**
  24566. * Gets the actual render width of the texture.
  24567. * @returns the width of the render size
  24568. */
  24569. getRenderWidth(): number;
  24570. /**
  24571. * Gets the actual render height of the texture.
  24572. * @returns the height of the render size
  24573. */
  24574. getRenderHeight(): number;
  24575. /**
  24576. * Gets the actual number of layers of the texture.
  24577. * @returns the number of layers
  24578. */
  24579. getRenderLayers(): number;
  24580. /**
  24581. * Get if the texture can be rescaled or not.
  24582. */
  24583. get canRescale(): boolean;
  24584. /**
  24585. * Resize the texture using a ratio.
  24586. * @param ratio the ratio to apply to the texture size in order to compute the new target size
  24587. */
  24588. scale(ratio: number): void;
  24589. /**
  24590. * Get the texture reflection matrix used to rotate/transform the reflection.
  24591. * @returns the reflection matrix
  24592. */
  24593. getReflectionTextureMatrix(): Matrix;
  24594. /**
  24595. * Resize the texture to a new desired size.
  24596. * Be carrefull as it will recreate all the data in the new texture.
  24597. * @param size Define the new size. It can be:
  24598. * - a number for squared texture,
  24599. * - an object containing { width: number, height: number }
  24600. * - or an object containing a ratio { ratio: number }
  24601. */
  24602. resize(size: number | {
  24603. width: number;
  24604. height: number;
  24605. } | {
  24606. ratio: number;
  24607. }): void;
  24608. private _defaultRenderListPrepared;
  24609. /**
  24610. * Renders all the objects from the render list into the texture.
  24611. * @param useCameraPostProcess Define if camera post processes should be used during the rendering
  24612. * @param dumpForDebug Define if the rendering result should be dumped (copied) for debugging purpose
  24613. */
  24614. render(useCameraPostProcess?: boolean, dumpForDebug?: boolean): void;
  24615. private _bestReflectionRenderTargetDimension;
  24616. private _prepareRenderingManager;
  24617. /**
  24618. * @hidden
  24619. * @param faceIndex face index to bind to if this is a cubetexture
  24620. * @param layer defines the index of the texture to bind in the array
  24621. */
  24622. _bindFrameBuffer(faceIndex?: number, layer?: number): void;
  24623. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  24624. private renderToTarget;
  24625. /**
  24626. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  24627. * This allowed control for front to back rendering or reversly depending of the special needs.
  24628. *
  24629. * @param renderingGroupId The rendering group id corresponding to its index
  24630. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  24631. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  24632. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  24633. */
  24634. 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;
  24635. /**
  24636. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  24637. *
  24638. * @param renderingGroupId The rendering group id corresponding to its index
  24639. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  24640. */
  24641. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  24642. /**
  24643. * Clones the texture.
  24644. * @returns the cloned texture
  24645. */
  24646. clone(): RenderTargetTexture;
  24647. /**
  24648. * Serialize the texture to a JSON representation we can easily use in the resepective Parse function.
  24649. * @returns The JSON representation of the texture
  24650. */
  24651. serialize(): any;
  24652. /**
  24653. * This will remove the attached framebuffer objects. The texture will not be able to be used as render target anymore
  24654. */
  24655. disposeFramebufferObjects(): void;
  24656. /**
  24657. * Dispose the texture and release its associated resources.
  24658. */
  24659. dispose(): void;
  24660. /** @hidden */
  24661. _rebuild(): void;
  24662. /**
  24663. * Clear the info related to rendering groups preventing retention point in material dispose.
  24664. */
  24665. freeRenderingGroups(): void;
  24666. /**
  24667. * Gets the number of views the corresponding to the texture (eg. a MultiviewRenderTarget will have > 1)
  24668. * @returns the view count
  24669. */
  24670. getViewCount(): number;
  24671. }
  24672. }
  24673. declare module "babylonjs/Misc/guid" {
  24674. /**
  24675. * Class used to manipulate GUIDs
  24676. */
  24677. export class GUID {
  24678. /**
  24679. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  24680. * Be aware Math.random() could cause collisions, but:
  24681. * "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"
  24682. * @returns a pseudo random id
  24683. */
  24684. static RandomId(): string;
  24685. }
  24686. }
  24687. declare module "babylonjs/Materials/shadowDepthWrapper" {
  24688. import { Nullable } from "babylonjs/types";
  24689. import { Scene } from "babylonjs/scene";
  24690. import { SubMesh } from "babylonjs/Meshes/subMesh";
  24691. import { Material } from "babylonjs/Materials/material";
  24692. import { Effect } from "babylonjs/Materials/effect";
  24693. import { ShadowGenerator } from "babylonjs/Lights/Shadows/shadowGenerator";
  24694. /**
  24695. * Options to be used when creating a shadow depth material
  24696. */
  24697. export interface IIOptionShadowDepthMaterial {
  24698. /** Variables in the vertex shader code that need to have their names remapped.
  24699. * The format is: ["var_name", "var_remapped_name", "var_name", "var_remapped_name", ...]
  24700. * "var_name" should be either: worldPos or vNormalW
  24701. * So, if the variable holding the world position in your vertex shader is not named worldPos, you must tell the system
  24702. * the name to use instead by using: ["worldPos", "myWorldPosVar"] assuming the variable is named myWorldPosVar in your code.
  24703. * If the normal must also be remapped: ["worldPos", "myWorldPosVar", "vNormalW", "myWorldNormal"]
  24704. */
  24705. remappedVariables?: string[];
  24706. /** Set standalone to true if the base material wrapped by ShadowDepthMaterial is not used for a regular object but for depth shadow generation only */
  24707. standalone?: boolean;
  24708. }
  24709. /**
  24710. * Class that can be used to wrap a base material to generate accurate shadows when using custom vertex/fragment code in the base material
  24711. */
  24712. export class ShadowDepthWrapper {
  24713. private _scene;
  24714. private _options?;
  24715. private _baseMaterial;
  24716. private _onEffectCreatedObserver;
  24717. private _subMeshToEffect;
  24718. private _subMeshToDepthEffect;
  24719. private _meshes;
  24720. /** @hidden */
  24721. _matriceNames: any;
  24722. /** Gets the standalone status of the wrapper */
  24723. get standalone(): boolean;
  24724. /** Gets the base material the wrapper is built upon */
  24725. get baseMaterial(): Material;
  24726. /**
  24727. * Instantiate a new shadow depth wrapper.
  24728. * It works by injecting some specific code in the vertex/fragment shaders of the base material and is used by a shadow generator to
  24729. * generate the shadow depth map. For more information, please refer to the documentation:
  24730. * https://doc.babylonjs.com/babylon101/shadows
  24731. * @param baseMaterial Material to wrap
  24732. * @param scene Define the scene the material belongs to
  24733. * @param options Options used to create the wrapper
  24734. */
  24735. constructor(baseMaterial: Material, scene: Scene, options?: IIOptionShadowDepthMaterial);
  24736. /**
  24737. * Gets the effect to use to generate the depth map
  24738. * @param subMesh subMesh to get the effect for
  24739. * @param shadowGenerator shadow generator to get the effect for
  24740. * @returns the effect to use to generate the depth map for the subMesh + shadow generator specified
  24741. */
  24742. getEffect(subMesh: Nullable<SubMesh>, shadowGenerator: ShadowGenerator): Nullable<Effect>;
  24743. /**
  24744. * Specifies that the submesh is ready to be used for depth rendering
  24745. * @param subMesh submesh to check
  24746. * @param defines the list of defines to take into account when checking the effect
  24747. * @param shadowGenerator combined with subMesh, it defines the effect to check
  24748. * @param useInstances specifies that instances should be used
  24749. * @returns a boolean indicating that the submesh is ready or not
  24750. */
  24751. isReadyForSubMesh(subMesh: SubMesh, defines: string[], shadowGenerator: ShadowGenerator, useInstances: boolean): boolean;
  24752. /**
  24753. * Disposes the resources
  24754. */
  24755. dispose(): void;
  24756. private _makeEffect;
  24757. }
  24758. }
  24759. declare module "babylonjs/Engines/Extensions/engine.multiRender" {
  24760. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  24761. import { IMultiRenderTargetOptions } from "babylonjs/Materials/Textures/multiRenderTarget";
  24762. import { Nullable } from "babylonjs/types";
  24763. module "babylonjs/Engines/thinEngine" {
  24764. interface ThinEngine {
  24765. /**
  24766. * Unbind a list of render target textures from the webGL context
  24767. * This is used only when drawBuffer extension or webGL2 are active
  24768. * @param textures defines the render target textures to unbind
  24769. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  24770. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  24771. */
  24772. unBindMultiColorAttachmentFramebuffer(textures: InternalTexture[], disableGenerateMipMaps: boolean, onBeforeUnbind?: () => void): void;
  24773. /**
  24774. * Create a multi render target texture
  24775. * @see https://doc.babylonjs.com/features/webgl2#multiple-render-target
  24776. * @param size defines the size of the texture
  24777. * @param options defines the creation options
  24778. * @returns the cube texture as an InternalTexture
  24779. */
  24780. createMultipleRenderTarget(size: any, options: IMultiRenderTargetOptions): InternalTexture[];
  24781. /**
  24782. * Update the sample count for a given multiple render target texture
  24783. * @see https://doc.babylonjs.com/features/webgl2#multisample-render-targets
  24784. * @param textures defines the textures to update
  24785. * @param samples defines the sample count to set
  24786. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  24787. */
  24788. updateMultipleRenderTargetTextureSampleCount(textures: Nullable<InternalTexture[]>, samples: number): number;
  24789. /**
  24790. * Select a subsets of attachments to draw to.
  24791. * @param attachments gl attachments
  24792. */
  24793. bindAttachments(attachments: number[]): void;
  24794. }
  24795. }
  24796. }
  24797. declare module "babylonjs/Materials/Textures/multiRenderTarget" {
  24798. import { Scene } from "babylonjs/scene";
  24799. import { Engine } from "babylonjs/Engines/engine";
  24800. import { Texture } from "babylonjs/Materials/Textures/texture";
  24801. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  24802. import "babylonjs/Engines/Extensions/engine.multiRender";
  24803. /**
  24804. * Creation options of the multi render target texture.
  24805. */
  24806. export interface IMultiRenderTargetOptions {
  24807. /**
  24808. * Define if the texture needs to create mip maps after render.
  24809. */
  24810. generateMipMaps?: boolean;
  24811. /**
  24812. * Define the types of all the draw buffers we want to create
  24813. */
  24814. types?: number[];
  24815. /**
  24816. * Define the sampling modes of all the draw buffers we want to create
  24817. */
  24818. samplingModes?: number[];
  24819. /**
  24820. * Define if a depth buffer is required
  24821. */
  24822. generateDepthBuffer?: boolean;
  24823. /**
  24824. * Define if a stencil buffer is required
  24825. */
  24826. generateStencilBuffer?: boolean;
  24827. /**
  24828. * Define if a depth texture is required instead of a depth buffer
  24829. */
  24830. generateDepthTexture?: boolean;
  24831. /**
  24832. * Define the number of desired draw buffers
  24833. */
  24834. textureCount?: number;
  24835. /**
  24836. * Define if aspect ratio should be adapted to the texture or stay the scene one
  24837. */
  24838. doNotChangeAspectRatio?: boolean;
  24839. /**
  24840. * Define the default type of the buffers we are creating
  24841. */
  24842. defaultType?: number;
  24843. }
  24844. /**
  24845. * A multi render target, like a render target provides the ability to render to a texture.
  24846. * Unlike the render target, it can render to several draw buffers in one draw.
  24847. * This is specially interesting in deferred rendering or for any effects requiring more than
  24848. * just one color from a single pass.
  24849. */
  24850. export class MultiRenderTarget extends RenderTargetTexture {
  24851. private _internalTextures;
  24852. private _textures;
  24853. private _multiRenderTargetOptions;
  24854. private _count;
  24855. /**
  24856. * Get if draw buffers are currently supported by the used hardware and browser.
  24857. */
  24858. get isSupported(): boolean;
  24859. /**
  24860. * Get the list of textures generated by the multi render target.
  24861. */
  24862. get textures(): Texture[];
  24863. /**
  24864. * Gets the number of textures in this MRT. This number can be different from `_textures.length` in case a depth texture is generated.
  24865. */
  24866. get count(): number;
  24867. /**
  24868. * Get the depth texture generated by the multi render target if options.generateDepthTexture has been set
  24869. */
  24870. get depthTexture(): Texture;
  24871. /**
  24872. * Set the wrapping mode on U of all the textures we are rendering to.
  24873. * Can be any of the Texture. (CLAMP_ADDRESSMODE, MIRROR_ADDRESSMODE or WRAP_ADDRESSMODE)
  24874. */
  24875. set wrapU(wrap: number);
  24876. /**
  24877. * Set the wrapping mode on V of all the textures we are rendering to.
  24878. * Can be any of the Texture. (CLAMP_ADDRESSMODE, MIRROR_ADDRESSMODE or WRAP_ADDRESSMODE)
  24879. */
  24880. set wrapV(wrap: number);
  24881. /**
  24882. * Instantiate a new multi render target texture.
  24883. * A multi render target, like a render target provides the ability to render to a texture.
  24884. * Unlike the render target, it can render to several draw buffers in one draw.
  24885. * This is specially interesting in deferred rendering or for any effects requiring more than
  24886. * just one color from a single pass.
  24887. * @param name Define the name of the texture
  24888. * @param size Define the size of the buffers to render to
  24889. * @param count Define the number of target we are rendering into
  24890. * @param scene Define the scene the texture belongs to
  24891. * @param options Define the options used to create the multi render target
  24892. */
  24893. constructor(name: string, size: any, count: number, scene: Scene, options?: IMultiRenderTargetOptions);
  24894. /** @hidden */
  24895. _rebuild(): void;
  24896. private _createInternalTextures;
  24897. private _createTextures;
  24898. /**
  24899. * Define the number of samples used if MSAA is enabled.
  24900. */
  24901. get samples(): number;
  24902. set samples(value: number);
  24903. /**
  24904. * Resize all the textures in the multi render target.
  24905. * Be carrefull as it will recreate all the data in the new texture.
  24906. * @param size Define the new size
  24907. */
  24908. resize(size: any): void;
  24909. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  24910. /**
  24911. * Dispose the render targets and their associated resources
  24912. */
  24913. dispose(): void;
  24914. /**
  24915. * Release all the underlying texture used as draw buffers.
  24916. */
  24917. releaseInternalTextures(): void;
  24918. }
  24919. }
  24920. declare module "babylonjs/Shaders/imageProcessing.fragment" {
  24921. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  24922. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  24923. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  24924. /** @hidden */
  24925. export var imageProcessingPixelShader: {
  24926. name: string;
  24927. shader: string;
  24928. };
  24929. }
  24930. declare module "babylonjs/PostProcesses/imageProcessingPostProcess" {
  24931. import { Nullable } from "babylonjs/types";
  24932. import { Color4 } from "babylonjs/Maths/math.color";
  24933. import { Camera } from "babylonjs/Cameras/camera";
  24934. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  24935. import { ColorCurves } from "babylonjs/Materials/colorCurves";
  24936. import { ImageProcessingConfiguration } from "babylonjs/Materials/imageProcessingConfiguration";
  24937. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  24938. import { Engine } from "babylonjs/Engines/engine";
  24939. import "babylonjs/Shaders/imageProcessing.fragment";
  24940. import "babylonjs/Shaders/postprocess.vertex";
  24941. /**
  24942. * ImageProcessingPostProcess
  24943. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#imageprocessing
  24944. */
  24945. export class ImageProcessingPostProcess extends PostProcess {
  24946. /**
  24947. * Default configuration related to image processing available in the PBR Material.
  24948. */
  24949. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  24950. /**
  24951. * Gets the image processing configuration used either in this material.
  24952. */
  24953. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  24954. /**
  24955. * Sets the Default image processing configuration used either in the this material.
  24956. *
  24957. * If sets to null, the scene one is in use.
  24958. */
  24959. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  24960. /**
  24961. * Keep track of the image processing observer to allow dispose and replace.
  24962. */
  24963. private _imageProcessingObserver;
  24964. /**
  24965. * Attaches a new image processing configuration to the PBR Material.
  24966. * @param configuration
  24967. */
  24968. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>, doNotBuild?: boolean): void;
  24969. /**
  24970. * If the post process is supported.
  24971. */
  24972. get isSupported(): boolean;
  24973. /**
  24974. * Gets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  24975. */
  24976. get colorCurves(): Nullable<ColorCurves>;
  24977. /**
  24978. * Sets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  24979. */
  24980. set colorCurves(value: Nullable<ColorCurves>);
  24981. /**
  24982. * Gets wether the color curves effect is enabled.
  24983. */
  24984. get colorCurvesEnabled(): boolean;
  24985. /**
  24986. * Sets wether the color curves effect is enabled.
  24987. */
  24988. set colorCurvesEnabled(value: boolean);
  24989. /**
  24990. * Gets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  24991. */
  24992. get colorGradingTexture(): Nullable<BaseTexture>;
  24993. /**
  24994. * Sets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  24995. */
  24996. set colorGradingTexture(value: Nullable<BaseTexture>);
  24997. /**
  24998. * Gets wether the color grading effect is enabled.
  24999. */
  25000. get colorGradingEnabled(): boolean;
  25001. /**
  25002. * Gets wether the color grading effect is enabled.
  25003. */
  25004. set colorGradingEnabled(value: boolean);
  25005. /**
  25006. * Gets exposure used in the effect.
  25007. */
  25008. get exposure(): number;
  25009. /**
  25010. * Sets exposure used in the effect.
  25011. */
  25012. set exposure(value: number);
  25013. /**
  25014. * Gets wether tonemapping is enabled or not.
  25015. */
  25016. get toneMappingEnabled(): boolean;
  25017. /**
  25018. * Sets wether tonemapping is enabled or not
  25019. */
  25020. set toneMappingEnabled(value: boolean);
  25021. /**
  25022. * Gets the type of tone mapping effect.
  25023. */
  25024. get toneMappingType(): number;
  25025. /**
  25026. * Sets the type of tone mapping effect.
  25027. */
  25028. set toneMappingType(value: number);
  25029. /**
  25030. * Gets contrast used in the effect.
  25031. */
  25032. get contrast(): number;
  25033. /**
  25034. * Sets contrast used in the effect.
  25035. */
  25036. set contrast(value: number);
  25037. /**
  25038. * Gets Vignette stretch size.
  25039. */
  25040. get vignetteStretch(): number;
  25041. /**
  25042. * Sets Vignette stretch size.
  25043. */
  25044. set vignetteStretch(value: number);
  25045. /**
  25046. * Gets Vignette centre X Offset.
  25047. */
  25048. get vignetteCentreX(): number;
  25049. /**
  25050. * Sets Vignette centre X Offset.
  25051. */
  25052. set vignetteCentreX(value: number);
  25053. /**
  25054. * Gets Vignette centre Y Offset.
  25055. */
  25056. get vignetteCentreY(): number;
  25057. /**
  25058. * Sets Vignette centre Y Offset.
  25059. */
  25060. set vignetteCentreY(value: number);
  25061. /**
  25062. * Gets Vignette weight or intensity of the vignette effect.
  25063. */
  25064. get vignetteWeight(): number;
  25065. /**
  25066. * Sets Vignette weight or intensity of the vignette effect.
  25067. */
  25068. set vignetteWeight(value: number);
  25069. /**
  25070. * Gets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  25071. * if vignetteEnabled is set to true.
  25072. */
  25073. get vignetteColor(): Color4;
  25074. /**
  25075. * Sets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  25076. * if vignetteEnabled is set to true.
  25077. */
  25078. set vignetteColor(value: Color4);
  25079. /**
  25080. * Gets Camera field of view used by the Vignette effect.
  25081. */
  25082. get vignetteCameraFov(): number;
  25083. /**
  25084. * Sets Camera field of view used by the Vignette effect.
  25085. */
  25086. set vignetteCameraFov(value: number);
  25087. /**
  25088. * Gets the vignette blend mode allowing different kind of effect.
  25089. */
  25090. get vignetteBlendMode(): number;
  25091. /**
  25092. * Sets the vignette blend mode allowing different kind of effect.
  25093. */
  25094. set vignetteBlendMode(value: number);
  25095. /**
  25096. * Gets wether the vignette effect is enabled.
  25097. */
  25098. get vignetteEnabled(): boolean;
  25099. /**
  25100. * Sets wether the vignette effect is enabled.
  25101. */
  25102. set vignetteEnabled(value: boolean);
  25103. private _fromLinearSpace;
  25104. /**
  25105. * Gets wether the input of the processing is in Gamma or Linear Space.
  25106. */
  25107. get fromLinearSpace(): boolean;
  25108. /**
  25109. * Sets wether the input of the processing is in Gamma or Linear Space.
  25110. */
  25111. set fromLinearSpace(value: boolean);
  25112. /**
  25113. * Defines cache preventing GC.
  25114. */
  25115. private _defines;
  25116. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, imageProcessingConfiguration?: ImageProcessingConfiguration);
  25117. /**
  25118. * "ImageProcessingPostProcess"
  25119. * @returns "ImageProcessingPostProcess"
  25120. */
  25121. getClassName(): string;
  25122. /**
  25123. * @hidden
  25124. */
  25125. _updateParameters(): void;
  25126. dispose(camera?: Camera): void;
  25127. }
  25128. }
  25129. declare module "babylonjs/Shaders/ShadersInclude/fibonacci" {
  25130. /** @hidden */
  25131. export var fibonacci: {
  25132. name: string;
  25133. shader: string;
  25134. };
  25135. }
  25136. declare module "babylonjs/Shaders/ShadersInclude/subSurfaceScatteringFunctions" {
  25137. /** @hidden */
  25138. export var subSurfaceScatteringFunctions: {
  25139. name: string;
  25140. shader: string;
  25141. };
  25142. }
  25143. declare module "babylonjs/Shaders/ShadersInclude/diffusionProfile" {
  25144. /** @hidden */
  25145. export var diffusionProfile: {
  25146. name: string;
  25147. shader: string;
  25148. };
  25149. }
  25150. declare module "babylonjs/Shaders/subSurfaceScattering.fragment" {
  25151. import "babylonjs/Shaders/ShadersInclude/fibonacci";
  25152. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  25153. import "babylonjs/Shaders/ShadersInclude/subSurfaceScatteringFunctions";
  25154. import "babylonjs/Shaders/ShadersInclude/diffusionProfile";
  25155. /** @hidden */
  25156. export var subSurfaceScatteringPixelShader: {
  25157. name: string;
  25158. shader: string;
  25159. };
  25160. }
  25161. declare module "babylonjs/PostProcesses/subSurfaceScatteringPostProcess" {
  25162. import { Nullable } from "babylonjs/types";
  25163. import { Camera } from "babylonjs/Cameras/camera";
  25164. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  25165. import { Engine } from "babylonjs/Engines/engine";
  25166. import { Scene } from "babylonjs/scene";
  25167. import "babylonjs/Shaders/imageProcessing.fragment";
  25168. import "babylonjs/Shaders/subSurfaceScattering.fragment";
  25169. import "babylonjs/Shaders/postprocess.vertex";
  25170. /**
  25171. * Sub surface scattering post process
  25172. */
  25173. export class SubSurfaceScatteringPostProcess extends PostProcess {
  25174. /**
  25175. * Gets a string identifying the name of the class
  25176. * @returns "SubSurfaceScatteringPostProcess" string
  25177. */
  25178. getClassName(): string;
  25179. constructor(name: string, scene: Scene, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  25180. }
  25181. }
  25182. declare module "babylonjs/Rendering/prePassEffectConfiguration" {
  25183. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  25184. /**
  25185. * Interface for defining prepass effects in the prepass post-process pipeline
  25186. */
  25187. export interface PrePassEffectConfiguration {
  25188. /**
  25189. * Post process to attach for this effect
  25190. */
  25191. postProcess: PostProcess;
  25192. /**
  25193. * Is the effect enabled
  25194. */
  25195. enabled: boolean;
  25196. /**
  25197. * Disposes the effect configuration
  25198. */
  25199. dispose(): void;
  25200. /**
  25201. * Disposes the effect configuration
  25202. */
  25203. createPostProcess: () => PostProcess;
  25204. }
  25205. }
  25206. declare module "babylonjs/Rendering/subSurfaceConfiguration" {
  25207. import { Scene } from "babylonjs/scene";
  25208. import { Color3 } from "babylonjs/Maths/math.color";
  25209. import { SubSurfaceScatteringPostProcess } from "babylonjs/PostProcesses/subSurfaceScatteringPostProcess";
  25210. import { PrePassEffectConfiguration } from "babylonjs/Rendering/prePassEffectConfiguration";
  25211. /**
  25212. * Contains all parameters needed for the prepass to perform
  25213. * screen space subsurface scattering
  25214. */
  25215. export class SubSurfaceConfiguration implements PrePassEffectConfiguration {
  25216. private _ssDiffusionS;
  25217. private _ssFilterRadii;
  25218. private _ssDiffusionD;
  25219. /**
  25220. * Post process to attach for screen space subsurface scattering
  25221. */
  25222. postProcess: SubSurfaceScatteringPostProcess;
  25223. /**
  25224. * Diffusion profile color for subsurface scattering
  25225. */
  25226. get ssDiffusionS(): number[];
  25227. /**
  25228. * Diffusion profile max color channel value for subsurface scattering
  25229. */
  25230. get ssDiffusionD(): number[];
  25231. /**
  25232. * Diffusion profile filter radius for subsurface scattering
  25233. */
  25234. get ssFilterRadii(): number[];
  25235. /**
  25236. * Is subsurface enabled
  25237. */
  25238. enabled: boolean;
  25239. /**
  25240. * Diffusion profile colors for subsurface scattering
  25241. * You can add one diffusion color using `addDiffusionProfile` on `scene.prePassRenderer`
  25242. * See ...
  25243. * Note that you can only store up to 5 of them
  25244. */
  25245. ssDiffusionProfileColors: Color3[];
  25246. /**
  25247. * Defines the ratio real world => scene units.
  25248. * Used for subsurface scattering
  25249. */
  25250. metersPerUnit: number;
  25251. private _scene;
  25252. /**
  25253. * Builds a subsurface configuration object
  25254. * @param scene The scene
  25255. */
  25256. constructor(scene: Scene);
  25257. /**
  25258. * Adds a new diffusion profile.
  25259. * Useful for more realistic subsurface scattering on diverse materials.
  25260. * @param color The color of the diffusion profile. Should be the average color of the material.
  25261. * @return The index of the diffusion profile for the material subsurface configuration
  25262. */
  25263. addDiffusionProfile(color: Color3): number;
  25264. /**
  25265. * Creates the sss post process
  25266. * @return The created post process
  25267. */
  25268. createPostProcess(): SubSurfaceScatteringPostProcess;
  25269. /**
  25270. * Deletes all diffusion profiles.
  25271. * Note that in order to render subsurface scattering, you should have at least 1 diffusion profile.
  25272. */
  25273. clearAllDiffusionProfiles(): void;
  25274. /**
  25275. * Disposes this object
  25276. */
  25277. dispose(): void;
  25278. /**
  25279. * @hidden
  25280. * https://zero-radiance.github.io/post/sampling-diffusion/
  25281. *
  25282. * Importance sample the normalized diffuse reflectance profile for the computed value of 's'.
  25283. * ------------------------------------------------------------------------------------
  25284. * R[r, phi, s] = s * (Exp[-r * s] + Exp[-r * s / 3]) / (8 * Pi * r)
  25285. * PDF[r, phi, s] = r * R[r, phi, s]
  25286. * CDF[r, s] = 1 - 1/4 * Exp[-r * s] - 3/4 * Exp[-r * s / 3]
  25287. * ------------------------------------------------------------------------------------
  25288. * We importance sample the color channel with the widest scattering distance.
  25289. */
  25290. getDiffusionProfileParameters(color: Color3): number;
  25291. /**
  25292. * Performs sampling of a Normalized Burley diffusion profile in polar coordinates.
  25293. * 'u' is the random number (the value of the CDF): [0, 1).
  25294. * rcp(s) = 1 / ShapeParam = ScatteringDistance.
  25295. * Returns the sampled radial distance, s.t. (u = 0 -> r = 0) and (u = 1 -> r = Inf).
  25296. */
  25297. private _sampleBurleyDiffusionProfile;
  25298. }
  25299. }
  25300. declare module "babylonjs/Rendering/prePassRenderer" {
  25301. import { MultiRenderTarget } from "babylonjs/Materials/Textures/multiRenderTarget";
  25302. import { Scene } from "babylonjs/scene";
  25303. import { ImageProcessingPostProcess } from "babylonjs/PostProcesses/imageProcessingPostProcess";
  25304. import { Effect } from "babylonjs/Materials/effect";
  25305. import { SubSurfaceConfiguration } from "babylonjs/Rendering/subSurfaceConfiguration";
  25306. /**
  25307. * Renders a pre pass of the scene
  25308. * This means every mesh in the scene will be rendered to a render target texture
  25309. * And then this texture will be composited to the rendering canvas with post processes
  25310. * It is necessary for effects like subsurface scattering or deferred shading
  25311. */
  25312. export class PrePassRenderer {
  25313. /** @hidden */
  25314. static _SceneComponentInitialization: (scene: Scene) => void;
  25315. private _scene;
  25316. private _engine;
  25317. private _isDirty;
  25318. /**
  25319. * Number of textures in the multi render target texture where the scene is directly rendered
  25320. */
  25321. readonly mrtCount: number;
  25322. /**
  25323. * The render target where the scene is directly rendered
  25324. */
  25325. prePassRT: MultiRenderTarget;
  25326. private _mrtTypes;
  25327. private _multiRenderAttachments;
  25328. private _defaultAttachments;
  25329. private _clearAttachments;
  25330. private _postProcesses;
  25331. private readonly _clearColor;
  25332. /**
  25333. * Image processing post process for composition
  25334. */
  25335. imageProcessingPostProcess: ImageProcessingPostProcess;
  25336. /**
  25337. * Configuration for sub surface scattering post process
  25338. */
  25339. subSurfaceConfiguration: SubSurfaceConfiguration;
  25340. /**
  25341. * Should materials render their geometry on the MRT
  25342. */
  25343. materialsShouldRenderGeometry: boolean;
  25344. /**
  25345. * Should materials render the irradiance information on the MRT
  25346. */
  25347. materialsShouldRenderIrradiance: boolean;
  25348. private _enabled;
  25349. /**
  25350. * Indicates if the prepass is enabled
  25351. */
  25352. get enabled(): boolean;
  25353. /**
  25354. * How many samples are used for MSAA of the scene render target
  25355. */
  25356. get samples(): number;
  25357. set samples(n: number);
  25358. /**
  25359. * Instanciates a prepass renderer
  25360. * @param scene The scene
  25361. */
  25362. constructor(scene: Scene);
  25363. private _initializeAttachments;
  25364. private _createCompositionEffect;
  25365. /**
  25366. * Indicates if rendering a prepass is supported
  25367. */
  25368. get isSupported(): boolean;
  25369. /**
  25370. * Sets the proper output textures to draw in the engine.
  25371. * @param effect The effect that is drawn. It can be or not be compatible with drawing to several output textures.
  25372. */
  25373. bindAttachmentsForEffect(effect: Effect): void;
  25374. /**
  25375. * @hidden
  25376. */
  25377. _beforeCameraDraw(): void;
  25378. /**
  25379. * @hidden
  25380. */
  25381. _afterCameraDraw(): void;
  25382. private _checkRTSize;
  25383. private _bindFrameBuffer;
  25384. /**
  25385. * Clears the scene render target (in the sense of settings pixels to the scene clear color value)
  25386. */
  25387. clear(): void;
  25388. private _setState;
  25389. private _enable;
  25390. private _disable;
  25391. private _resetPostProcessChain;
  25392. private _bindPostProcessChain;
  25393. /**
  25394. * Marks the prepass renderer as dirty, triggering a check if the prepass is necessary for the next rendering.
  25395. */
  25396. markAsDirty(): void;
  25397. private _update;
  25398. /**
  25399. * Disposes the prepass renderer.
  25400. */
  25401. dispose(): void;
  25402. }
  25403. }
  25404. declare module "babylonjs/Materials/material" {
  25405. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  25406. import { SmartArray } from "babylonjs/Misc/smartArray";
  25407. import { Observable } from "babylonjs/Misc/observable";
  25408. import { Nullable } from "babylonjs/types";
  25409. import { Scene } from "babylonjs/scene";
  25410. import { Matrix } from "babylonjs/Maths/math.vector";
  25411. import { SubMesh } from "babylonjs/Meshes/subMesh";
  25412. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  25413. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  25414. import { Effect } from "babylonjs/Materials/effect";
  25415. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  25416. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  25417. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  25418. import { IInspectable } from "babylonjs/Misc/iInspectable";
  25419. import { ShadowDepthWrapper } from "babylonjs/Materials/shadowDepthWrapper";
  25420. import { PrePassRenderer } from "babylonjs/Rendering/prePassRenderer";
  25421. import { Mesh } from "babylonjs/Meshes/mesh";
  25422. import { Animation } from "babylonjs/Animations/animation";
  25423. /**
  25424. * Options for compiling materials.
  25425. */
  25426. export interface IMaterialCompilationOptions {
  25427. /**
  25428. * Defines whether clip planes are enabled.
  25429. */
  25430. clipPlane: boolean;
  25431. /**
  25432. * Defines whether instances are enabled.
  25433. */
  25434. useInstances: boolean;
  25435. }
  25436. /**
  25437. * Options passed when calling customShaderNameResolve
  25438. */
  25439. export interface ICustomShaderNameResolveOptions {
  25440. /**
  25441. * 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
  25442. */
  25443. processFinalCode?: Nullable<(shaderType: string, code: string) => string>;
  25444. }
  25445. /**
  25446. * Base class for the main features of a material in Babylon.js
  25447. */
  25448. export class Material implements IAnimatable {
  25449. /**
  25450. * Returns the triangle fill mode
  25451. */
  25452. static readonly TriangleFillMode: number;
  25453. /**
  25454. * Returns the wireframe mode
  25455. */
  25456. static readonly WireFrameFillMode: number;
  25457. /**
  25458. * Returns the point fill mode
  25459. */
  25460. static readonly PointFillMode: number;
  25461. /**
  25462. * Returns the point list draw mode
  25463. */
  25464. static readonly PointListDrawMode: number;
  25465. /**
  25466. * Returns the line list draw mode
  25467. */
  25468. static readonly LineListDrawMode: number;
  25469. /**
  25470. * Returns the line loop draw mode
  25471. */
  25472. static readonly LineLoopDrawMode: number;
  25473. /**
  25474. * Returns the line strip draw mode
  25475. */
  25476. static readonly LineStripDrawMode: number;
  25477. /**
  25478. * Returns the triangle strip draw mode
  25479. */
  25480. static readonly TriangleStripDrawMode: number;
  25481. /**
  25482. * Returns the triangle fan draw mode
  25483. */
  25484. static readonly TriangleFanDrawMode: number;
  25485. /**
  25486. * Stores the clock-wise side orientation
  25487. */
  25488. static readonly ClockWiseSideOrientation: number;
  25489. /**
  25490. * Stores the counter clock-wise side orientation
  25491. */
  25492. static readonly CounterClockWiseSideOrientation: number;
  25493. /**
  25494. * The dirty texture flag value
  25495. */
  25496. static readonly TextureDirtyFlag: number;
  25497. /**
  25498. * The dirty light flag value
  25499. */
  25500. static readonly LightDirtyFlag: number;
  25501. /**
  25502. * The dirty fresnel flag value
  25503. */
  25504. static readonly FresnelDirtyFlag: number;
  25505. /**
  25506. * The dirty attribute flag value
  25507. */
  25508. static readonly AttributesDirtyFlag: number;
  25509. /**
  25510. * The dirty misc flag value
  25511. */
  25512. static readonly MiscDirtyFlag: number;
  25513. /**
  25514. * The all dirty flag value
  25515. */
  25516. static readonly AllDirtyFlag: number;
  25517. /**
  25518. * MaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  25519. */
  25520. static readonly MATERIAL_OPAQUE: number;
  25521. /**
  25522. * MaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  25523. */
  25524. static readonly MATERIAL_ALPHATEST: number;
  25525. /**
  25526. * MaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  25527. */
  25528. static readonly MATERIAL_ALPHABLEND: number;
  25529. /**
  25530. * MaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  25531. * They are also discarded below the alpha cutoff threshold to improve performances.
  25532. */
  25533. static readonly MATERIAL_ALPHATESTANDBLEND: number;
  25534. /**
  25535. * The Whiteout method is used to blend normals.
  25536. * Details of the algorithm can be found here: https://blog.selfshadow.com/publications/blending-in-detail/
  25537. */
  25538. static readonly MATERIAL_NORMALBLENDMETHOD_WHITEOUT: number;
  25539. /**
  25540. * The Reoriented Normal Mapping method is used to blend normals.
  25541. * Details of the algorithm can be found here: https://blog.selfshadow.com/publications/blending-in-detail/
  25542. */
  25543. static readonly MATERIAL_NORMALBLENDMETHOD_RNM: number;
  25544. /**
  25545. * Custom callback helping to override the default shader used in the material.
  25546. */
  25547. customShaderNameResolve: (shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: MaterialDefines | string[], attributes?: string[], options?: ICustomShaderNameResolveOptions) => string;
  25548. /**
  25549. * Custom shadow depth material to use for shadow rendering instead of the in-built one
  25550. */
  25551. shadowDepthWrapper: Nullable<ShadowDepthWrapper>;
  25552. /**
  25553. * Gets or sets a boolean indicating that the material is allowed (if supported) to do shader hot swapping.
  25554. * This means that the material can keep using a previous shader while a new one is being compiled.
  25555. * This is mostly used when shader parallel compilation is supported (true by default)
  25556. */
  25557. allowShaderHotSwapping: boolean;
  25558. /**
  25559. * The ID of the material
  25560. */
  25561. id: string;
  25562. /**
  25563. * Gets or sets the unique id of the material
  25564. */
  25565. uniqueId: number;
  25566. /**
  25567. * The name of the material
  25568. */
  25569. name: string;
  25570. /**
  25571. * Gets or sets user defined metadata
  25572. */
  25573. metadata: any;
  25574. /**
  25575. * For internal use only. Please do not use.
  25576. */
  25577. reservedDataStore: any;
  25578. /**
  25579. * Specifies if the ready state should be checked on each call
  25580. */
  25581. checkReadyOnEveryCall: boolean;
  25582. /**
  25583. * Specifies if the ready state should be checked once
  25584. */
  25585. checkReadyOnlyOnce: boolean;
  25586. /**
  25587. * The state of the material
  25588. */
  25589. state: string;
  25590. /**
  25591. * If the material can be rendered to several textures with MRT extension
  25592. */
  25593. get canRenderToMRT(): boolean;
  25594. /**
  25595. * The alpha value of the material
  25596. */
  25597. protected _alpha: number;
  25598. /**
  25599. * List of inspectable custom properties (used by the Inspector)
  25600. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  25601. */
  25602. inspectableCustomProperties: IInspectable[];
  25603. /**
  25604. * Sets the alpha value of the material
  25605. */
  25606. set alpha(value: number);
  25607. /**
  25608. * Gets the alpha value of the material
  25609. */
  25610. get alpha(): number;
  25611. /**
  25612. * Specifies if back face culling is enabled
  25613. */
  25614. protected _backFaceCulling: boolean;
  25615. /**
  25616. * Sets the back-face culling state
  25617. */
  25618. set backFaceCulling(value: boolean);
  25619. /**
  25620. * Gets the back-face culling state
  25621. */
  25622. get backFaceCulling(): boolean;
  25623. /**
  25624. * Stores the value for side orientation
  25625. */
  25626. sideOrientation: number;
  25627. /**
  25628. * Callback triggered when the material is compiled
  25629. */
  25630. onCompiled: Nullable<(effect: Effect) => void>;
  25631. /**
  25632. * Callback triggered when an error occurs
  25633. */
  25634. onError: Nullable<(effect: Effect, errors: string) => void>;
  25635. /**
  25636. * Callback triggered to get the render target textures
  25637. */
  25638. getRenderTargetTextures: Nullable<() => SmartArray<RenderTargetTexture>>;
  25639. /**
  25640. * Gets a boolean indicating that current material needs to register RTT
  25641. */
  25642. get hasRenderTargetTextures(): boolean;
  25643. /**
  25644. * Specifies if the material should be serialized
  25645. */
  25646. doNotSerialize: boolean;
  25647. /**
  25648. * @hidden
  25649. */
  25650. _storeEffectOnSubMeshes: boolean;
  25651. /**
  25652. * Stores the animations for the material
  25653. */
  25654. animations: Nullable<Array<Animation>>;
  25655. /**
  25656. * An event triggered when the material is disposed
  25657. */
  25658. onDisposeObservable: Observable<Material>;
  25659. /**
  25660. * An observer which watches for dispose events
  25661. */
  25662. private _onDisposeObserver;
  25663. private _onUnBindObservable;
  25664. /**
  25665. * Called during a dispose event
  25666. */
  25667. set onDispose(callback: () => void);
  25668. private _onBindObservable;
  25669. /**
  25670. * An event triggered when the material is bound
  25671. */
  25672. get onBindObservable(): Observable<AbstractMesh>;
  25673. /**
  25674. * An observer which watches for bind events
  25675. */
  25676. private _onBindObserver;
  25677. /**
  25678. * Called during a bind event
  25679. */
  25680. set onBind(callback: (Mesh: AbstractMesh) => void);
  25681. /**
  25682. * An event triggered when the material is unbound
  25683. */
  25684. get onUnBindObservable(): Observable<Material>;
  25685. protected _onEffectCreatedObservable: Nullable<Observable<{
  25686. effect: Effect;
  25687. subMesh: Nullable<SubMesh>;
  25688. }>>;
  25689. /**
  25690. * An event triggered when the effect is (re)created
  25691. */
  25692. get onEffectCreatedObservable(): Observable<{
  25693. effect: Effect;
  25694. subMesh: Nullable<SubMesh>;
  25695. }>;
  25696. /**
  25697. * Stores the value of the alpha mode
  25698. */
  25699. private _alphaMode;
  25700. /**
  25701. * Sets the value of the alpha mode.
  25702. *
  25703. * | Value | Type | Description |
  25704. * | --- | --- | --- |
  25705. * | 0 | ALPHA_DISABLE | |
  25706. * | 1 | ALPHA_ADD | |
  25707. * | 2 | ALPHA_COMBINE | |
  25708. * | 3 | ALPHA_SUBTRACT | |
  25709. * | 4 | ALPHA_MULTIPLY | |
  25710. * | 5 | ALPHA_MAXIMIZED | |
  25711. * | 6 | ALPHA_ONEONE | |
  25712. * | 7 | ALPHA_PREMULTIPLIED | |
  25713. * | 8 | ALPHA_PREMULTIPLIED_PORTERDUFF | |
  25714. * | 9 | ALPHA_INTERPOLATE | |
  25715. * | 10 | ALPHA_SCREENMODE | |
  25716. *
  25717. */
  25718. set alphaMode(value: number);
  25719. /**
  25720. * Gets the value of the alpha mode
  25721. */
  25722. get alphaMode(): number;
  25723. /**
  25724. * Stores the state of the need depth pre-pass value
  25725. */
  25726. private _needDepthPrePass;
  25727. /**
  25728. * Sets the need depth pre-pass value
  25729. */
  25730. set needDepthPrePass(value: boolean);
  25731. /**
  25732. * Gets the depth pre-pass value
  25733. */
  25734. get needDepthPrePass(): boolean;
  25735. /**
  25736. * Specifies if depth writing should be disabled
  25737. */
  25738. disableDepthWrite: boolean;
  25739. /**
  25740. * Specifies if color writing should be disabled
  25741. */
  25742. disableColorWrite: boolean;
  25743. /**
  25744. * Specifies if depth writing should be forced
  25745. */
  25746. forceDepthWrite: boolean;
  25747. /**
  25748. * Specifies the depth function that should be used. 0 means the default engine function
  25749. */
  25750. depthFunction: number;
  25751. /**
  25752. * Specifies if there should be a separate pass for culling
  25753. */
  25754. separateCullingPass: boolean;
  25755. /**
  25756. * Stores the state specifing if fog should be enabled
  25757. */
  25758. private _fogEnabled;
  25759. /**
  25760. * Sets the state for enabling fog
  25761. */
  25762. set fogEnabled(value: boolean);
  25763. /**
  25764. * Gets the value of the fog enabled state
  25765. */
  25766. get fogEnabled(): boolean;
  25767. /**
  25768. * Stores the size of points
  25769. */
  25770. pointSize: number;
  25771. /**
  25772. * Stores the z offset value
  25773. */
  25774. zOffset: number;
  25775. get wireframe(): boolean;
  25776. /**
  25777. * Sets the state of wireframe mode
  25778. */
  25779. set wireframe(value: boolean);
  25780. /**
  25781. * Gets the value specifying if point clouds are enabled
  25782. */
  25783. get pointsCloud(): boolean;
  25784. /**
  25785. * Sets the state of point cloud mode
  25786. */
  25787. set pointsCloud(value: boolean);
  25788. /**
  25789. * Gets the material fill mode
  25790. */
  25791. get fillMode(): number;
  25792. /**
  25793. * Sets the material fill mode
  25794. */
  25795. set fillMode(value: number);
  25796. /**
  25797. * @hidden
  25798. * Stores the effects for the material
  25799. */
  25800. _effect: Nullable<Effect>;
  25801. /**
  25802. * Specifies if uniform buffers should be used
  25803. */
  25804. private _useUBO;
  25805. /**
  25806. * Stores a reference to the scene
  25807. */
  25808. private _scene;
  25809. /**
  25810. * Stores the fill mode state
  25811. */
  25812. private _fillMode;
  25813. /**
  25814. * Specifies if the depth write state should be cached
  25815. */
  25816. private _cachedDepthWriteState;
  25817. /**
  25818. * Specifies if the color write state should be cached
  25819. */
  25820. private _cachedColorWriteState;
  25821. /**
  25822. * Specifies if the depth function state should be cached
  25823. */
  25824. private _cachedDepthFunctionState;
  25825. /**
  25826. * Stores the uniform buffer
  25827. */
  25828. protected _uniformBuffer: UniformBuffer;
  25829. /** @hidden */
  25830. _indexInSceneMaterialArray: number;
  25831. /** @hidden */
  25832. meshMap: Nullable<{
  25833. [id: string]: AbstractMesh | undefined;
  25834. }>;
  25835. /**
  25836. * Creates a material instance
  25837. * @param name defines the name of the material
  25838. * @param scene defines the scene to reference
  25839. * @param doNotAdd specifies if the material should be added to the scene
  25840. */
  25841. constructor(name: string, scene: Scene, doNotAdd?: boolean);
  25842. /**
  25843. * Returns a string representation of the current material
  25844. * @param fullDetails defines a boolean indicating which levels of logging is desired
  25845. * @returns a string with material information
  25846. */
  25847. toString(fullDetails?: boolean): string;
  25848. /**
  25849. * Gets the class name of the material
  25850. * @returns a string with the class name of the material
  25851. */
  25852. getClassName(): string;
  25853. /**
  25854. * Specifies if updates for the material been locked
  25855. */
  25856. get isFrozen(): boolean;
  25857. /**
  25858. * Locks updates for the material
  25859. */
  25860. freeze(): void;
  25861. /**
  25862. * Unlocks updates for the material
  25863. */
  25864. unfreeze(): void;
  25865. /**
  25866. * Specifies if the material is ready to be used
  25867. * @param mesh defines the mesh to check
  25868. * @param useInstances specifies if instances should be used
  25869. * @returns a boolean indicating if the material is ready to be used
  25870. */
  25871. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  25872. /**
  25873. * Specifies that the submesh is ready to be used
  25874. * @param mesh defines the mesh to check
  25875. * @param subMesh defines which submesh to check
  25876. * @param useInstances specifies that instances should be used
  25877. * @returns a boolean indicating that the submesh is ready or not
  25878. */
  25879. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  25880. /**
  25881. * Returns the material effect
  25882. * @returns the effect associated with the material
  25883. */
  25884. getEffect(): Nullable<Effect>;
  25885. /**
  25886. * Returns the current scene
  25887. * @returns a Scene
  25888. */
  25889. getScene(): Scene;
  25890. /**
  25891. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  25892. */
  25893. protected _forceAlphaTest: boolean;
  25894. /**
  25895. * The transparency mode of the material.
  25896. */
  25897. protected _transparencyMode: Nullable<number>;
  25898. /**
  25899. * Gets the current transparency mode.
  25900. */
  25901. get transparencyMode(): Nullable<number>;
  25902. /**
  25903. * Sets the transparency mode of the material.
  25904. *
  25905. * | Value | Type | Description |
  25906. * | ----- | ----------------------------------- | ----------- |
  25907. * | 0 | OPAQUE | |
  25908. * | 1 | ALPHATEST | |
  25909. * | 2 | ALPHABLEND | |
  25910. * | 3 | ALPHATESTANDBLEND | |
  25911. *
  25912. */
  25913. set transparencyMode(value: Nullable<number>);
  25914. /**
  25915. * Returns true if alpha blending should be disabled.
  25916. */
  25917. protected get _disableAlphaBlending(): boolean;
  25918. /**
  25919. * Specifies whether or not this material should be rendered in alpha blend mode.
  25920. * @returns a boolean specifying if alpha blending is needed
  25921. */
  25922. needAlphaBlending(): boolean;
  25923. /**
  25924. * Specifies if the mesh will require alpha blending
  25925. * @param mesh defines the mesh to check
  25926. * @returns a boolean specifying if alpha blending is needed for the mesh
  25927. */
  25928. needAlphaBlendingForMesh(mesh: AbstractMesh): boolean;
  25929. /**
  25930. * Specifies whether or not this material should be rendered in alpha test mode.
  25931. * @returns a boolean specifying if an alpha test is needed.
  25932. */
  25933. needAlphaTesting(): boolean;
  25934. /**
  25935. * Specifies if material alpha testing should be turned on for the mesh
  25936. * @param mesh defines the mesh to check
  25937. */
  25938. protected _shouldTurnAlphaTestOn(mesh: AbstractMesh): boolean;
  25939. /**
  25940. * Gets the texture used for the alpha test
  25941. * @returns the texture to use for alpha testing
  25942. */
  25943. getAlphaTestTexture(): Nullable<BaseTexture>;
  25944. /**
  25945. * Marks the material to indicate that it needs to be re-calculated
  25946. */
  25947. markDirty(): void;
  25948. /** @hidden */
  25949. _preBind(effect?: Effect, overrideOrientation?: Nullable<number>): boolean;
  25950. /**
  25951. * Binds the material to the mesh
  25952. * @param world defines the world transformation matrix
  25953. * @param mesh defines the mesh to bind the material to
  25954. */
  25955. bind(world: Matrix, mesh?: Mesh): void;
  25956. /**
  25957. * Binds the submesh to the material
  25958. * @param world defines the world transformation matrix
  25959. * @param mesh defines the mesh containing the submesh
  25960. * @param subMesh defines the submesh to bind the material to
  25961. */
  25962. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  25963. /**
  25964. * Binds the world matrix to the material
  25965. * @param world defines the world transformation matrix
  25966. */
  25967. bindOnlyWorldMatrix(world: Matrix): void;
  25968. /**
  25969. * Binds the scene's uniform buffer to the effect.
  25970. * @param effect defines the effect to bind to the scene uniform buffer
  25971. * @param sceneUbo defines the uniform buffer storing scene data
  25972. */
  25973. bindSceneUniformBuffer(effect: Effect, sceneUbo: UniformBuffer): void;
  25974. /**
  25975. * Binds the view matrix to the effect
  25976. * @param effect defines the effect to bind the view matrix to
  25977. */
  25978. bindView(effect: Effect): void;
  25979. /**
  25980. * Binds the view projection matrix to the effect
  25981. * @param effect defines the effect to bind the view projection matrix to
  25982. */
  25983. bindViewProjection(effect: Effect): void;
  25984. /**
  25985. * Processes to execute after binding the material to a mesh
  25986. * @param mesh defines the rendered mesh
  25987. */
  25988. protected _afterBind(mesh?: Mesh): void;
  25989. /**
  25990. * Unbinds the material from the mesh
  25991. */
  25992. unbind(): void;
  25993. /**
  25994. * Gets the active textures from the material
  25995. * @returns an array of textures
  25996. */
  25997. getActiveTextures(): BaseTexture[];
  25998. /**
  25999. * Specifies if the material uses a texture
  26000. * @param texture defines the texture to check against the material
  26001. * @returns a boolean specifying if the material uses the texture
  26002. */
  26003. hasTexture(texture: BaseTexture): boolean;
  26004. /**
  26005. * Makes a duplicate of the material, and gives it a new name
  26006. * @param name defines the new name for the duplicated material
  26007. * @returns the cloned material
  26008. */
  26009. clone(name: string): Nullable<Material>;
  26010. /**
  26011. * Gets the meshes bound to the material
  26012. * @returns an array of meshes bound to the material
  26013. */
  26014. getBindedMeshes(): AbstractMesh[];
  26015. /**
  26016. * Force shader compilation
  26017. * @param mesh defines the mesh associated with this material
  26018. * @param onCompiled defines a function to execute once the material is compiled
  26019. * @param options defines the options to configure the compilation
  26020. * @param onError defines a function to execute if the material fails compiling
  26021. */
  26022. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<IMaterialCompilationOptions>, onError?: (reason: string) => void): void;
  26023. /**
  26024. * Force shader compilation
  26025. * @param mesh defines the mesh that will use this material
  26026. * @param options defines additional options for compiling the shaders
  26027. * @returns a promise that resolves when the compilation completes
  26028. */
  26029. forceCompilationAsync(mesh: AbstractMesh, options?: Partial<IMaterialCompilationOptions>): Promise<void>;
  26030. private static readonly _AllDirtyCallBack;
  26031. private static readonly _ImageProcessingDirtyCallBack;
  26032. private static readonly _TextureDirtyCallBack;
  26033. private static readonly _FresnelDirtyCallBack;
  26034. private static readonly _MiscDirtyCallBack;
  26035. private static readonly _LightsDirtyCallBack;
  26036. private static readonly _AttributeDirtyCallBack;
  26037. private static _FresnelAndMiscDirtyCallBack;
  26038. private static _TextureAndMiscDirtyCallBack;
  26039. private static readonly _DirtyCallbackArray;
  26040. private static readonly _RunDirtyCallBacks;
  26041. /**
  26042. * Marks a define in the material to indicate that it needs to be re-computed
  26043. * @param flag defines a flag used to determine which parts of the material have to be marked as dirty
  26044. */
  26045. markAsDirty(flag: number): void;
  26046. /**
  26047. * Marks all submeshes of a material to indicate that their material defines need to be re-calculated
  26048. * @param func defines a function which checks material defines against the submeshes
  26049. */
  26050. protected _markAllSubMeshesAsDirty(func: (defines: MaterialDefines) => void): void;
  26051. /**
  26052. * Indicates that the scene should check if the rendering now needs a prepass
  26053. */
  26054. protected _markScenePrePassDirty(): void;
  26055. /**
  26056. * Indicates that we need to re-calculated for all submeshes
  26057. */
  26058. protected _markAllSubMeshesAsAllDirty(): void;
  26059. /**
  26060. * Indicates that image processing needs to be re-calculated for all submeshes
  26061. */
  26062. protected _markAllSubMeshesAsImageProcessingDirty(): void;
  26063. /**
  26064. * Indicates that textures need to be re-calculated for all submeshes
  26065. */
  26066. protected _markAllSubMeshesAsTexturesDirty(): void;
  26067. /**
  26068. * Indicates that fresnel needs to be re-calculated for all submeshes
  26069. */
  26070. protected _markAllSubMeshesAsFresnelDirty(): void;
  26071. /**
  26072. * Indicates that fresnel and misc need to be re-calculated for all submeshes
  26073. */
  26074. protected _markAllSubMeshesAsFresnelAndMiscDirty(): void;
  26075. /**
  26076. * Indicates that lights need to be re-calculated for all submeshes
  26077. */
  26078. protected _markAllSubMeshesAsLightsDirty(): void;
  26079. /**
  26080. * Indicates that attributes need to be re-calculated for all submeshes
  26081. */
  26082. protected _markAllSubMeshesAsAttributesDirty(): void;
  26083. /**
  26084. * Indicates that misc needs to be re-calculated for all submeshes
  26085. */
  26086. protected _markAllSubMeshesAsMiscDirty(): void;
  26087. /**
  26088. * Indicates that textures and misc need to be re-calculated for all submeshes
  26089. */
  26090. protected _markAllSubMeshesAsTexturesAndMiscDirty(): void;
  26091. /**
  26092. * Sets the required values to the prepass renderer.
  26093. * @param prePassRenderer defines the prepass renderer to setup.
  26094. * @returns true if the pre pass is needed.
  26095. */
  26096. setPrePassRenderer(prePassRenderer: PrePassRenderer): boolean;
  26097. /**
  26098. * Disposes the material
  26099. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  26100. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  26101. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  26102. */
  26103. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  26104. /** @hidden */
  26105. private releaseVertexArrayObject;
  26106. /**
  26107. * Serializes this material
  26108. * @returns the serialized material object
  26109. */
  26110. serialize(): any;
  26111. /**
  26112. * Creates a material from parsed material data
  26113. * @param parsedMaterial defines parsed material data
  26114. * @param scene defines the hosting scene
  26115. * @param rootUrl defines the root URL to use to load textures
  26116. * @returns a new material
  26117. */
  26118. static Parse(parsedMaterial: any, scene: Scene, rootUrl: string): Nullable<Material>;
  26119. }
  26120. }
  26121. declare module "babylonjs/Materials/multiMaterial" {
  26122. import { Nullable } from "babylonjs/types";
  26123. import { Scene } from "babylonjs/scene";
  26124. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  26125. import { SubMesh } from "babylonjs/Meshes/subMesh";
  26126. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  26127. import { Material } from "babylonjs/Materials/material";
  26128. /**
  26129. * A multi-material is used to apply different materials to different parts of the same object without the need of
  26130. * separate meshes. This can be use to improve performances.
  26131. * @see https://doc.babylonjs.com/how_to/multi_materials
  26132. */
  26133. export class MultiMaterial extends Material {
  26134. private _subMaterials;
  26135. /**
  26136. * Gets or Sets the list of Materials used within the multi material.
  26137. * They need to be ordered according to the submeshes order in the associated mesh
  26138. */
  26139. get subMaterials(): Nullable<Material>[];
  26140. set subMaterials(value: Nullable<Material>[]);
  26141. /**
  26142. * Function used to align with Node.getChildren()
  26143. * @returns the list of Materials used within the multi material
  26144. */
  26145. getChildren(): Nullable<Material>[];
  26146. /**
  26147. * Instantiates a new Multi Material
  26148. * A multi-material is used to apply different materials to different parts of the same object without the need of
  26149. * separate meshes. This can be use to improve performances.
  26150. * @see https://doc.babylonjs.com/how_to/multi_materials
  26151. * @param name Define the name in the scene
  26152. * @param scene Define the scene the material belongs to
  26153. */
  26154. constructor(name: string, scene: Scene);
  26155. private _hookArray;
  26156. /**
  26157. * Get one of the submaterial by its index in the submaterials array
  26158. * @param index The index to look the sub material at
  26159. * @returns The Material if the index has been defined
  26160. */
  26161. getSubMaterial(index: number): Nullable<Material>;
  26162. /**
  26163. * Get the list of active textures for the whole sub materials list.
  26164. * @returns All the textures that will be used during the rendering
  26165. */
  26166. getActiveTextures(): BaseTexture[];
  26167. /**
  26168. * Gets the current class name of the material e.g. "MultiMaterial"
  26169. * Mainly use in serialization.
  26170. * @returns the class name
  26171. */
  26172. getClassName(): string;
  26173. /**
  26174. * Checks if the material is ready to render the requested sub mesh
  26175. * @param mesh Define the mesh the submesh belongs to
  26176. * @param subMesh Define the sub mesh to look readyness for
  26177. * @param useInstances Define whether or not the material is used with instances
  26178. * @returns true if ready, otherwise false
  26179. */
  26180. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  26181. /**
  26182. * Clones the current material and its related sub materials
  26183. * @param name Define the name of the newly cloned material
  26184. * @param cloneChildren Define if submaterial will be cloned or shared with the parent instance
  26185. * @returns the cloned material
  26186. */
  26187. clone(name: string, cloneChildren?: boolean): MultiMaterial;
  26188. /**
  26189. * Serializes the materials into a JSON representation.
  26190. * @returns the JSON representation
  26191. */
  26192. serialize(): any;
  26193. /**
  26194. * Dispose the material and release its associated resources
  26195. * @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)
  26196. * @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)
  26197. * @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)
  26198. */
  26199. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, forceDisposeChildren?: boolean): void;
  26200. /**
  26201. * Creates a MultiMaterial from parsed MultiMaterial data.
  26202. * @param parsedMultiMaterial defines parsed MultiMaterial data.
  26203. * @param scene defines the hosting scene
  26204. * @returns a new MultiMaterial
  26205. */
  26206. static ParseMultiMaterial(parsedMultiMaterial: any, scene: Scene): MultiMaterial;
  26207. }
  26208. }
  26209. declare module "babylonjs/Meshes/subMesh" {
  26210. import { Nullable, IndicesArray, DeepImmutable, FloatArray } from "babylonjs/types";
  26211. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  26212. import { Engine } from "babylonjs/Engines/engine";
  26213. import { IntersectionInfo } from "babylonjs/Collisions/intersectionInfo";
  26214. import { ICullable, BoundingInfo } from "babylonjs/Culling/boundingInfo";
  26215. import { Effect } from "babylonjs/Materials/effect";
  26216. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  26217. import { Plane } from "babylonjs/Maths/math.plane";
  26218. import { Collider } from "babylonjs/Collisions/collider";
  26219. import { Material } from "babylonjs/Materials/material";
  26220. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  26221. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  26222. import { Mesh } from "babylonjs/Meshes/mesh";
  26223. import { Ray } from "babylonjs/Culling/ray";
  26224. import { TrianglePickingPredicate } from "babylonjs/Culling/ray";
  26225. /**
  26226. * Defines a subdivision inside a mesh
  26227. */
  26228. export class SubMesh implements ICullable {
  26229. /** the material index to use */
  26230. materialIndex: number;
  26231. /** vertex index start */
  26232. verticesStart: number;
  26233. /** vertices count */
  26234. verticesCount: number;
  26235. /** index start */
  26236. indexStart: number;
  26237. /** indices count */
  26238. indexCount: number;
  26239. /** @hidden */
  26240. _materialDefines: Nullable<MaterialDefines>;
  26241. /** @hidden */
  26242. _materialEffect: Nullable<Effect>;
  26243. /** @hidden */
  26244. _effectOverride: Nullable<Effect>;
  26245. /**
  26246. * Gets material defines used by the effect associated to the sub mesh
  26247. */
  26248. get materialDefines(): Nullable<MaterialDefines>;
  26249. /**
  26250. * Sets material defines used by the effect associated to the sub mesh
  26251. */
  26252. set materialDefines(defines: Nullable<MaterialDefines>);
  26253. /**
  26254. * Gets associated effect
  26255. */
  26256. get effect(): Nullable<Effect>;
  26257. /**
  26258. * Sets associated effect (effect used to render this submesh)
  26259. * @param effect defines the effect to associate with
  26260. * @param defines defines the set of defines used to compile this effect
  26261. */
  26262. setEffect(effect: Nullable<Effect>, defines?: Nullable<MaterialDefines>): void;
  26263. /** @hidden */
  26264. _linesIndexCount: number;
  26265. private _mesh;
  26266. private _renderingMesh;
  26267. private _boundingInfo;
  26268. private _linesIndexBuffer;
  26269. /** @hidden */
  26270. _lastColliderWorldVertices: Nullable<Vector3[]>;
  26271. /** @hidden */
  26272. _trianglePlanes: Plane[];
  26273. /** @hidden */
  26274. _lastColliderTransformMatrix: Nullable<Matrix>;
  26275. /** @hidden */
  26276. _renderId: number;
  26277. /** @hidden */
  26278. _alphaIndex: number;
  26279. /** @hidden */
  26280. _distanceToCamera: number;
  26281. /** @hidden */
  26282. _id: number;
  26283. private _currentMaterial;
  26284. /**
  26285. * Add a new submesh to a mesh
  26286. * @param materialIndex defines the material index to use
  26287. * @param verticesStart defines vertex index start
  26288. * @param verticesCount defines vertices count
  26289. * @param indexStart defines index start
  26290. * @param indexCount defines indices count
  26291. * @param mesh defines the parent mesh
  26292. * @param renderingMesh defines an optional rendering mesh
  26293. * @param createBoundingBox defines if bounding box should be created for this submesh
  26294. * @returns the new submesh
  26295. */
  26296. static AddToMesh(materialIndex: number, verticesStart: number, verticesCount: number, indexStart: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox?: boolean): SubMesh;
  26297. /**
  26298. * Creates a new submesh
  26299. * @param materialIndex defines the material index to use
  26300. * @param verticesStart defines vertex index start
  26301. * @param verticesCount defines vertices count
  26302. * @param indexStart defines index start
  26303. * @param indexCount defines indices count
  26304. * @param mesh defines the parent mesh
  26305. * @param renderingMesh defines an optional rendering mesh
  26306. * @param createBoundingBox defines if bounding box should be created for this submesh
  26307. * @param addToMesh defines a boolean indicating that the submesh must be added to the mesh.subMeshes array (true by default)
  26308. */
  26309. constructor(
  26310. /** the material index to use */
  26311. materialIndex: number,
  26312. /** vertex index start */
  26313. verticesStart: number,
  26314. /** vertices count */
  26315. verticesCount: number,
  26316. /** index start */
  26317. indexStart: number,
  26318. /** indices count */
  26319. indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox?: boolean, addToMesh?: boolean);
  26320. /**
  26321. * Returns true if this submesh covers the entire parent mesh
  26322. * @ignorenaming
  26323. */
  26324. get IsGlobal(): boolean;
  26325. /**
  26326. * Returns the submesh BoudingInfo object
  26327. * @returns current bounding info (or mesh's one if the submesh is global)
  26328. */
  26329. getBoundingInfo(): BoundingInfo;
  26330. /**
  26331. * Sets the submesh BoundingInfo
  26332. * @param boundingInfo defines the new bounding info to use
  26333. * @returns the SubMesh
  26334. */
  26335. setBoundingInfo(boundingInfo: BoundingInfo): SubMesh;
  26336. /**
  26337. * Returns the mesh of the current submesh
  26338. * @return the parent mesh
  26339. */
  26340. getMesh(): AbstractMesh;
  26341. /**
  26342. * Returns the rendering mesh of the submesh
  26343. * @returns the rendering mesh (could be different from parent mesh)
  26344. */
  26345. getRenderingMesh(): Mesh;
  26346. /**
  26347. * Returns the replacement mesh of the submesh
  26348. * @returns the replacement mesh (could be different from parent mesh)
  26349. */
  26350. getReplacementMesh(): Nullable<AbstractMesh>;
  26351. /**
  26352. * Returns the effective mesh of the submesh
  26353. * @returns the effective mesh (could be different from parent mesh)
  26354. */
  26355. getEffectiveMesh(): AbstractMesh;
  26356. /**
  26357. * Returns the submesh material
  26358. * @returns null or the current material
  26359. */
  26360. getMaterial(): Nullable<Material>;
  26361. private _IsMultiMaterial;
  26362. /**
  26363. * Sets a new updated BoundingInfo object to the submesh
  26364. * @param data defines an optional position array to use to determine the bounding info
  26365. * @returns the SubMesh
  26366. */
  26367. refreshBoundingInfo(data?: Nullable<FloatArray>): SubMesh;
  26368. /** @hidden */
  26369. _checkCollision(collider: Collider): boolean;
  26370. /**
  26371. * Updates the submesh BoundingInfo
  26372. * @param world defines the world matrix to use to update the bounding info
  26373. * @returns the submesh
  26374. */
  26375. updateBoundingInfo(world: DeepImmutable<Matrix>): SubMesh;
  26376. /**
  26377. * True is the submesh bounding box intersects the frustum defined by the passed array of planes.
  26378. * @param frustumPlanes defines the frustum planes
  26379. * @returns true if the submesh is intersecting with the frustum
  26380. */
  26381. isInFrustum(frustumPlanes: Plane[]): boolean;
  26382. /**
  26383. * True is the submesh bounding box is completely inside the frustum defined by the passed array of planes
  26384. * @param frustumPlanes defines the frustum planes
  26385. * @returns true if the submesh is inside the frustum
  26386. */
  26387. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  26388. /**
  26389. * Renders the submesh
  26390. * @param enableAlphaMode defines if alpha needs to be used
  26391. * @returns the submesh
  26392. */
  26393. render(enableAlphaMode: boolean): SubMesh;
  26394. /**
  26395. * @hidden
  26396. */
  26397. _getLinesIndexBuffer(indices: IndicesArray, engine: Engine): DataBuffer;
  26398. /**
  26399. * Checks if the submesh intersects with a ray
  26400. * @param ray defines the ray to test
  26401. * @returns true is the passed ray intersects the submesh bounding box
  26402. */
  26403. canIntersects(ray: Ray): boolean;
  26404. /**
  26405. * Intersects current submesh with a ray
  26406. * @param ray defines the ray to test
  26407. * @param positions defines mesh's positions array
  26408. * @param indices defines mesh's indices array
  26409. * @param fastCheck defines if the first intersection will be used (and not the closest)
  26410. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  26411. * @returns intersection info or null if no intersection
  26412. */
  26413. intersects(ray: Ray, positions: Vector3[], indices: IndicesArray, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<IntersectionInfo>;
  26414. /** @hidden */
  26415. private _intersectLines;
  26416. /** @hidden */
  26417. private _intersectUnIndexedLines;
  26418. /** @hidden */
  26419. private _intersectTriangles;
  26420. /** @hidden */
  26421. private _intersectUnIndexedTriangles;
  26422. /** @hidden */
  26423. _rebuild(): void;
  26424. /**
  26425. * Creates a new submesh from the passed mesh
  26426. * @param newMesh defines the new hosting mesh
  26427. * @param newRenderingMesh defines an optional rendering mesh
  26428. * @returns the new submesh
  26429. */
  26430. clone(newMesh: AbstractMesh, newRenderingMesh?: Mesh): SubMesh;
  26431. /**
  26432. * Release associated resources
  26433. */
  26434. dispose(): void;
  26435. /**
  26436. * Gets the class name
  26437. * @returns the string "SubMesh".
  26438. */
  26439. getClassName(): string;
  26440. /**
  26441. * Creates a new submesh from indices data
  26442. * @param materialIndex the index of the main mesh material
  26443. * @param startIndex the index where to start the copy in the mesh indices array
  26444. * @param indexCount the number of indices to copy then from the startIndex
  26445. * @param mesh the main mesh to create the submesh from
  26446. * @param renderingMesh the optional rendering mesh
  26447. * @returns a new submesh
  26448. */
  26449. static CreateFromIndices(materialIndex: number, startIndex: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh): SubMesh;
  26450. }
  26451. }
  26452. declare module "babylonjs/Loading/sceneLoaderFlags" {
  26453. /**
  26454. * Class used to represent data loading progression
  26455. */
  26456. export class SceneLoaderFlags {
  26457. private static _ForceFullSceneLoadingForIncremental;
  26458. private static _ShowLoadingScreen;
  26459. private static _CleanBoneMatrixWeights;
  26460. private static _loggingLevel;
  26461. /**
  26462. * Gets or sets a boolean indicating if entire scene must be loaded even if scene contains incremental data
  26463. */
  26464. static get ForceFullSceneLoadingForIncremental(): boolean;
  26465. static set ForceFullSceneLoadingForIncremental(value: boolean);
  26466. /**
  26467. * Gets or sets a boolean indicating if loading screen must be displayed while loading a scene
  26468. */
  26469. static get ShowLoadingScreen(): boolean;
  26470. static set ShowLoadingScreen(value: boolean);
  26471. /**
  26472. * Defines the current logging level (while loading the scene)
  26473. * @ignorenaming
  26474. */
  26475. static get loggingLevel(): number;
  26476. static set loggingLevel(value: number);
  26477. /**
  26478. * Gets or set a boolean indicating if matrix weights must be cleaned upon loading
  26479. */
  26480. static get CleanBoneMatrixWeights(): boolean;
  26481. static set CleanBoneMatrixWeights(value: boolean);
  26482. }
  26483. }
  26484. declare module "babylonjs/Meshes/geometry" {
  26485. import { Nullable, FloatArray, DataArray, IndicesArray } from "babylonjs/types";
  26486. import { Scene } from "babylonjs/scene";
  26487. import { Vector3, Vector2 } from "babylonjs/Maths/math.vector";
  26488. import { Engine } from "babylonjs/Engines/engine";
  26489. import { IGetSetVerticesData, VertexData } from "babylonjs/Meshes/mesh.vertexData";
  26490. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  26491. import { Effect } from "babylonjs/Materials/effect";
  26492. import { BoundingInfo } from "babylonjs/Culling/boundingInfo";
  26493. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  26494. import { Mesh } from "babylonjs/Meshes/mesh";
  26495. /**
  26496. * Class used to store geometry data (vertex buffers + index buffer)
  26497. */
  26498. export class Geometry implements IGetSetVerticesData {
  26499. /**
  26500. * Gets or sets the ID of the geometry
  26501. */
  26502. id: string;
  26503. /**
  26504. * Gets or sets the unique ID of the geometry
  26505. */
  26506. uniqueId: number;
  26507. /**
  26508. * Gets the delay loading state of the geometry (none by default which means not delayed)
  26509. */
  26510. delayLoadState: number;
  26511. /**
  26512. * Gets the file containing the data to load when running in delay load state
  26513. */
  26514. delayLoadingFile: Nullable<string>;
  26515. /**
  26516. * Callback called when the geometry is updated
  26517. */
  26518. onGeometryUpdated: (geometry: Geometry, kind?: string) => void;
  26519. private _scene;
  26520. private _engine;
  26521. private _meshes;
  26522. private _totalVertices;
  26523. /** @hidden */
  26524. _indices: IndicesArray;
  26525. /** @hidden */
  26526. _vertexBuffers: {
  26527. [key: string]: VertexBuffer;
  26528. };
  26529. private _isDisposed;
  26530. private _extend;
  26531. private _boundingBias;
  26532. /** @hidden */
  26533. _delayInfo: Array<string>;
  26534. private _indexBuffer;
  26535. private _indexBufferIsUpdatable;
  26536. /** @hidden */
  26537. _boundingInfo: Nullable<BoundingInfo>;
  26538. /** @hidden */
  26539. _delayLoadingFunction: Nullable<(any: any, geometry: Geometry) => void>;
  26540. /** @hidden */
  26541. _softwareSkinningFrameId: number;
  26542. private _vertexArrayObjects;
  26543. private _updatable;
  26544. /** @hidden */
  26545. _positions: Nullable<Vector3[]>;
  26546. /**
  26547. * 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
  26548. */
  26549. get boundingBias(): Vector2;
  26550. /**
  26551. * 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
  26552. */
  26553. set boundingBias(value: Vector2);
  26554. /**
  26555. * Static function used to attach a new empty geometry to a mesh
  26556. * @param mesh defines the mesh to attach the geometry to
  26557. * @returns the new Geometry
  26558. */
  26559. static CreateGeometryForMesh(mesh: Mesh): Geometry;
  26560. /** Get the list of meshes using this geometry */
  26561. get meshes(): Mesh[];
  26562. /**
  26563. * 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
  26564. * and won't be computed based on the vertex positions (which is what we get when useBoundingInfoFromGeometry = false)
  26565. */
  26566. useBoundingInfoFromGeometry: boolean;
  26567. /**
  26568. * Creates a new geometry
  26569. * @param id defines the unique ID
  26570. * @param scene defines the hosting scene
  26571. * @param vertexData defines the VertexData used to get geometry data
  26572. * @param updatable defines if geometry must be updatable (false by default)
  26573. * @param mesh defines the mesh that will be associated with the geometry
  26574. */
  26575. constructor(id: string, scene: Scene, vertexData?: VertexData, updatable?: boolean, mesh?: Nullable<Mesh>);
  26576. /**
  26577. * Gets the current extend of the geometry
  26578. */
  26579. get extend(): {
  26580. minimum: Vector3;
  26581. maximum: Vector3;
  26582. };
  26583. /**
  26584. * Gets the hosting scene
  26585. * @returns the hosting Scene
  26586. */
  26587. getScene(): Scene;
  26588. /**
  26589. * Gets the hosting engine
  26590. * @returns the hosting Engine
  26591. */
  26592. getEngine(): Engine;
  26593. /**
  26594. * Defines if the geometry is ready to use
  26595. * @returns true if the geometry is ready to be used
  26596. */
  26597. isReady(): boolean;
  26598. /**
  26599. * Gets a value indicating that the geometry should not be serialized
  26600. */
  26601. get doNotSerialize(): boolean;
  26602. /** @hidden */
  26603. _rebuild(): void;
  26604. /**
  26605. * Affects all geometry data in one call
  26606. * @param vertexData defines the geometry data
  26607. * @param updatable defines if the geometry must be flagged as updatable (false as default)
  26608. */
  26609. setAllVerticesData(vertexData: VertexData, updatable?: boolean): void;
  26610. /**
  26611. * Set specific vertex data
  26612. * @param kind defines the data kind (Position, normal, etc...)
  26613. * @param data defines the vertex data to use
  26614. * @param updatable defines if the vertex must be flagged as updatable (false as default)
  26615. * @param stride defines the stride to use (0 by default). This value is deduced from the kind value if not specified
  26616. */
  26617. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): void;
  26618. /**
  26619. * Removes a specific vertex data
  26620. * @param kind defines the data kind (Position, normal, etc...)
  26621. */
  26622. removeVerticesData(kind: string): void;
  26623. /**
  26624. * Affect a vertex buffer to the geometry. the vertexBuffer.getKind() function is used to determine where to store the data
  26625. * @param buffer defines the vertex buffer to use
  26626. * @param totalVertices defines the total number of vertices for position kind (could be null)
  26627. */
  26628. setVerticesBuffer(buffer: VertexBuffer, totalVertices?: Nullable<number>): void;
  26629. /**
  26630. * Update a specific vertex buffer
  26631. * This function will directly update the underlying DataBuffer according to the passed numeric array or Float32Array
  26632. * It will do nothing if the buffer is not updatable
  26633. * @param kind defines the data kind (Position, normal, etc...)
  26634. * @param data defines the data to use
  26635. * @param offset defines the offset in the target buffer where to store the data
  26636. * @param useBytes set to true if the offset is in bytes
  26637. */
  26638. updateVerticesDataDirectly(kind: string, data: DataArray, offset: number, useBytes?: boolean): void;
  26639. /**
  26640. * Update a specific vertex buffer
  26641. * This function will create a new buffer if the current one is not updatable
  26642. * @param kind defines the data kind (Position, normal, etc...)
  26643. * @param data defines the data to use
  26644. * @param updateExtends defines if the geometry extends must be recomputed (false by default)
  26645. */
  26646. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean): void;
  26647. private _updateBoundingInfo;
  26648. /** @hidden */
  26649. _bind(effect: Nullable<Effect>, indexToBind?: Nullable<DataBuffer>): void;
  26650. /**
  26651. * Gets total number of vertices
  26652. * @returns the total number of vertices
  26653. */
  26654. getTotalVertices(): number;
  26655. /**
  26656. * Gets a specific vertex data attached to this geometry. Float data is constructed if the vertex buffer data cannot be returned directly.
  26657. * @param kind defines the data kind (Position, normal, etc...)
  26658. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  26659. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  26660. * @returns a float array containing vertex data
  26661. */
  26662. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  26663. /**
  26664. * Returns a boolean defining if the vertex data for the requested `kind` is updatable
  26665. * @param kind defines the data kind (Position, normal, etc...)
  26666. * @returns true if the vertex buffer with the specified kind is updatable
  26667. */
  26668. isVertexBufferUpdatable(kind: string): boolean;
  26669. /**
  26670. * Gets a specific vertex buffer
  26671. * @param kind defines the data kind (Position, normal, etc...)
  26672. * @returns a VertexBuffer
  26673. */
  26674. getVertexBuffer(kind: string): Nullable<VertexBuffer>;
  26675. /**
  26676. * Returns all vertex buffers
  26677. * @return an object holding all vertex buffers indexed by kind
  26678. */
  26679. getVertexBuffers(): Nullable<{
  26680. [key: string]: VertexBuffer;
  26681. }>;
  26682. /**
  26683. * Gets a boolean indicating if specific vertex buffer is present
  26684. * @param kind defines the data kind (Position, normal, etc...)
  26685. * @returns true if data is present
  26686. */
  26687. isVerticesDataPresent(kind: string): boolean;
  26688. /**
  26689. * Gets a list of all attached data kinds (Position, normal, etc...)
  26690. * @returns a list of string containing all kinds
  26691. */
  26692. getVerticesDataKinds(): string[];
  26693. /**
  26694. * Update index buffer
  26695. * @param indices defines the indices to store in the index buffer
  26696. * @param offset defines the offset in the target buffer where to store the data
  26697. * @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)
  26698. */
  26699. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): void;
  26700. /**
  26701. * Creates a new index buffer
  26702. * @param indices defines the indices to store in the index buffer
  26703. * @param totalVertices defines the total number of vertices (could be null)
  26704. * @param updatable defines if the index buffer must be flagged as updatable (false by default)
  26705. */
  26706. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>, updatable?: boolean): void;
  26707. /**
  26708. * Return the total number of indices
  26709. * @returns the total number of indices
  26710. */
  26711. getTotalIndices(): number;
  26712. /**
  26713. * Gets the index buffer array
  26714. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  26715. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  26716. * @returns the index buffer array
  26717. */
  26718. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  26719. /**
  26720. * Gets the index buffer
  26721. * @return the index buffer
  26722. */
  26723. getIndexBuffer(): Nullable<DataBuffer>;
  26724. /** @hidden */
  26725. _releaseVertexArrayObject(effect?: Nullable<Effect>): void;
  26726. /**
  26727. * Release the associated resources for a specific mesh
  26728. * @param mesh defines the source mesh
  26729. * @param shouldDispose defines if the geometry must be disposed if there is no more mesh pointing to it
  26730. */
  26731. releaseForMesh(mesh: Mesh, shouldDispose?: boolean): void;
  26732. /**
  26733. * Apply current geometry to a given mesh
  26734. * @param mesh defines the mesh to apply geometry to
  26735. */
  26736. applyToMesh(mesh: Mesh): void;
  26737. private _updateExtend;
  26738. private _applyToMesh;
  26739. private notifyUpdate;
  26740. /**
  26741. * Load the geometry if it was flagged as delay loaded
  26742. * @param scene defines the hosting scene
  26743. * @param onLoaded defines a callback called when the geometry is loaded
  26744. */
  26745. load(scene: Scene, onLoaded?: () => void): void;
  26746. private _queueLoad;
  26747. /**
  26748. * Invert the geometry to move from a right handed system to a left handed one.
  26749. */
  26750. toLeftHanded(): void;
  26751. /** @hidden */
  26752. _resetPointsArrayCache(): void;
  26753. /** @hidden */
  26754. _generatePointsArray(): boolean;
  26755. /**
  26756. * Gets a value indicating if the geometry is disposed
  26757. * @returns true if the geometry was disposed
  26758. */
  26759. isDisposed(): boolean;
  26760. private _disposeVertexArrayObjects;
  26761. /**
  26762. * Free all associated resources
  26763. */
  26764. dispose(): void;
  26765. /**
  26766. * Clone the current geometry into a new geometry
  26767. * @param id defines the unique ID of the new geometry
  26768. * @returns a new geometry object
  26769. */
  26770. copy(id: string): Geometry;
  26771. /**
  26772. * Serialize the current geometry info (and not the vertices data) into a JSON object
  26773. * @return a JSON representation of the current geometry data (without the vertices data)
  26774. */
  26775. serialize(): any;
  26776. private toNumberArray;
  26777. /**
  26778. * Serialize all vertices data into a JSON oject
  26779. * @returns a JSON representation of the current geometry data
  26780. */
  26781. serializeVerticeData(): any;
  26782. /**
  26783. * Extracts a clone of a mesh geometry
  26784. * @param mesh defines the source mesh
  26785. * @param id defines the unique ID of the new geometry object
  26786. * @returns the new geometry object
  26787. */
  26788. static ExtractFromMesh(mesh: Mesh, id: string): Nullable<Geometry>;
  26789. /**
  26790. * You should now use Tools.RandomId(), this method is still here for legacy reasons.
  26791. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  26792. * Be aware Math.random() could cause collisions, but:
  26793. * "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"
  26794. * @returns a string containing a new GUID
  26795. */
  26796. static RandomId(): string;
  26797. /** @hidden */
  26798. static _ImportGeometry(parsedGeometry: any, mesh: Mesh): void;
  26799. private static _CleanMatricesWeights;
  26800. /**
  26801. * Create a new geometry from persisted data (Using .babylon file format)
  26802. * @param parsedVertexData defines the persisted data
  26803. * @param scene defines the hosting scene
  26804. * @param rootUrl defines the root url to use to load assets (like delayed data)
  26805. * @returns the new geometry object
  26806. */
  26807. static Parse(parsedVertexData: any, scene: Scene, rootUrl: string): Nullable<Geometry>;
  26808. }
  26809. }
  26810. declare module "babylonjs/Meshes/mesh.vertexData" {
  26811. import { Nullable, FloatArray, IndicesArray } from "babylonjs/types";
  26812. import { Matrix, Vector3, Vector2, Vector4 } from "babylonjs/Maths/math.vector";
  26813. import { Color4, Color3 } from "babylonjs/Maths/math.color";
  26814. import { Geometry } from "babylonjs/Meshes/geometry";
  26815. import { Mesh } from "babylonjs/Meshes/mesh";
  26816. /**
  26817. * Define an interface for all classes that will get and set the data on vertices
  26818. */
  26819. export interface IGetSetVerticesData {
  26820. /**
  26821. * Gets a boolean indicating if specific vertex data is present
  26822. * @param kind defines the vertex data kind to use
  26823. * @returns true is data kind is present
  26824. */
  26825. isVerticesDataPresent(kind: string): boolean;
  26826. /**
  26827. * Gets a specific vertex data attached to this geometry. Float data is constructed if the vertex buffer data cannot be returned directly.
  26828. * @param kind defines the data kind (Position, normal, etc...)
  26829. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  26830. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  26831. * @returns a float array containing vertex data
  26832. */
  26833. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  26834. /**
  26835. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  26836. * @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.
  26837. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  26838. * @returns the indices array or an empty array if the mesh has no geometry
  26839. */
  26840. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  26841. /**
  26842. * Set specific vertex data
  26843. * @param kind defines the data kind (Position, normal, etc...)
  26844. * @param data defines the vertex data to use
  26845. * @param updatable defines if the vertex must be flagged as updatable (false as default)
  26846. * @param stride defines the stride to use (0 by default). This value is deduced from the kind value if not specified
  26847. */
  26848. setVerticesData(kind: string, data: FloatArray, updatable: boolean): void;
  26849. /**
  26850. * Update a specific associated vertex buffer
  26851. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  26852. * - VertexBuffer.PositionKind
  26853. * - VertexBuffer.UVKind
  26854. * - VertexBuffer.UV2Kind
  26855. * - VertexBuffer.UV3Kind
  26856. * - VertexBuffer.UV4Kind
  26857. * - VertexBuffer.UV5Kind
  26858. * - VertexBuffer.UV6Kind
  26859. * - VertexBuffer.ColorKind
  26860. * - VertexBuffer.MatricesIndicesKind
  26861. * - VertexBuffer.MatricesIndicesExtraKind
  26862. * - VertexBuffer.MatricesWeightsKind
  26863. * - VertexBuffer.MatricesWeightsExtraKind
  26864. * @param data defines the data source
  26865. * @param updateExtends defines if extends info of the mesh must be updated (can be null). This is mostly useful for "position" kind
  26866. * @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)
  26867. */
  26868. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): void;
  26869. /**
  26870. * Creates a new index buffer
  26871. * @param indices defines the indices to store in the index buffer
  26872. * @param totalVertices defines the total number of vertices (could be null)
  26873. * @param updatable defines if the index buffer must be flagged as updatable (false by default)
  26874. */
  26875. setIndices(indices: IndicesArray, totalVertices: Nullable<number>, updatable?: boolean): void;
  26876. }
  26877. /**
  26878. * This class contains the various kinds of data on every vertex of a mesh used in determining its shape and appearance
  26879. */
  26880. export class VertexData {
  26881. /**
  26882. * Mesh side orientation : usually the external or front surface
  26883. */
  26884. static readonly FRONTSIDE: number;
  26885. /**
  26886. * Mesh side orientation : usually the internal or back surface
  26887. */
  26888. static readonly BACKSIDE: number;
  26889. /**
  26890. * Mesh side orientation : both internal and external or front and back surfaces
  26891. */
  26892. static readonly DOUBLESIDE: number;
  26893. /**
  26894. * Mesh side orientation : by default, `FRONTSIDE`
  26895. */
  26896. static readonly DEFAULTSIDE: number;
  26897. /**
  26898. * An array of the x, y, z position of each vertex [...., x, y, z, .....]
  26899. */
  26900. positions: Nullable<FloatArray>;
  26901. /**
  26902. * An array of the x, y, z normal vector of each vertex [...., x, y, z, .....]
  26903. */
  26904. normals: Nullable<FloatArray>;
  26905. /**
  26906. * An array of the x, y, z tangent vector of each vertex [...., x, y, z, .....]
  26907. */
  26908. tangents: Nullable<FloatArray>;
  26909. /**
  26910. * An array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  26911. */
  26912. uvs: Nullable<FloatArray>;
  26913. /**
  26914. * A second array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  26915. */
  26916. uvs2: Nullable<FloatArray>;
  26917. /**
  26918. * A third array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  26919. */
  26920. uvs3: Nullable<FloatArray>;
  26921. /**
  26922. * A fourth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  26923. */
  26924. uvs4: Nullable<FloatArray>;
  26925. /**
  26926. * A fifth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  26927. */
  26928. uvs5: Nullable<FloatArray>;
  26929. /**
  26930. * A sixth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  26931. */
  26932. uvs6: Nullable<FloatArray>;
  26933. /**
  26934. * An array of the r, g, b, a, color of each vertex [...., r, g, b, a, .....]
  26935. */
  26936. colors: Nullable<FloatArray>;
  26937. /**
  26938. * 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).
  26939. */
  26940. matricesIndices: Nullable<FloatArray>;
  26941. /**
  26942. * An array containing the list of weights defining the weight of each indexed matrix in the final computation
  26943. */
  26944. matricesWeights: Nullable<FloatArray>;
  26945. /**
  26946. * An array extending the number of possible indices
  26947. */
  26948. matricesIndicesExtra: Nullable<FloatArray>;
  26949. /**
  26950. * An array extending the number of possible weights when the number of indices is extended
  26951. */
  26952. matricesWeightsExtra: Nullable<FloatArray>;
  26953. /**
  26954. * An array of i, j, k the three vertex indices required for each triangular facet [...., i, j, k .....]
  26955. */
  26956. indices: Nullable<IndicesArray>;
  26957. /**
  26958. * Uses the passed data array to set the set the values for the specified kind of data
  26959. * @param data a linear array of floating numbers
  26960. * @param kind the type of data that is being set, eg positions, colors etc
  26961. */
  26962. set(data: FloatArray, kind: string): void;
  26963. /**
  26964. * Associates the vertexData to the passed Mesh.
  26965. * Sets it as updatable or not (default `false`)
  26966. * @param mesh the mesh the vertexData is applied to
  26967. * @param updatable when used and having the value true allows new data to update the vertexData
  26968. * @returns the VertexData
  26969. */
  26970. applyToMesh(mesh: Mesh, updatable?: boolean): VertexData;
  26971. /**
  26972. * Associates the vertexData to the passed Geometry.
  26973. * Sets it as updatable or not (default `false`)
  26974. * @param geometry the geometry the vertexData is applied to
  26975. * @param updatable when used and having the value true allows new data to update the vertexData
  26976. * @returns VertexData
  26977. */
  26978. applyToGeometry(geometry: Geometry, updatable?: boolean): VertexData;
  26979. /**
  26980. * Updates the associated mesh
  26981. * @param mesh the mesh to be updated
  26982. * @param updateExtends when true the mesh BoundingInfo will be renewed when and if position kind is updated, optional with default false
  26983. * @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
  26984. * @returns VertexData
  26985. */
  26986. updateMesh(mesh: Mesh): VertexData;
  26987. /**
  26988. * Updates the associated geometry
  26989. * @param geometry the geometry to be updated
  26990. * @param updateExtends when true BoundingInfo will be renewed when and if position kind is updated, optional with default false
  26991. * @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
  26992. * @returns VertexData.
  26993. */
  26994. updateGeometry(geometry: Geometry): VertexData;
  26995. private _applyTo;
  26996. private _update;
  26997. /**
  26998. * Transforms each position and each normal of the vertexData according to the passed Matrix
  26999. * @param matrix the transforming matrix
  27000. * @returns the VertexData
  27001. */
  27002. transform(matrix: Matrix): VertexData;
  27003. /**
  27004. * Merges the passed VertexData into the current one
  27005. * @param other the VertexData to be merged into the current one
  27006. * @param use32BitsIndices defines a boolean indicating if indices must be store in a 32 bits array
  27007. * @returns the modified VertexData
  27008. */
  27009. merge(other: VertexData, use32BitsIndices?: boolean): VertexData;
  27010. private _mergeElement;
  27011. private _validate;
  27012. /**
  27013. * Serializes the VertexData
  27014. * @returns a serialized object
  27015. */
  27016. serialize(): any;
  27017. /**
  27018. * Extracts the vertexData from a mesh
  27019. * @param mesh the mesh from which to extract the VertexData
  27020. * @param copyWhenShared defines if the VertexData must be cloned when shared between multiple meshes, optional, default false
  27021. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  27022. * @returns the object VertexData associated to the passed mesh
  27023. */
  27024. static ExtractFromMesh(mesh: Mesh, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  27025. /**
  27026. * Extracts the vertexData from the geometry
  27027. * @param geometry the geometry from which to extract the VertexData
  27028. * @param copyWhenShared defines if the VertexData must be cloned when the geometrty is shared between multiple meshes, optional, default false
  27029. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  27030. * @returns the object VertexData associated to the passed mesh
  27031. */
  27032. static ExtractFromGeometry(geometry: Geometry, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  27033. private static _ExtractFrom;
  27034. /**
  27035. * Creates the VertexData for a Ribbon
  27036. * @param options an object used to set the following optional parameters for the ribbon, required but can be empty
  27037. * * pathArray array of paths, each of which an array of successive Vector3
  27038. * * closeArray creates a seam between the first and the last paths of the pathArray, optional, default false
  27039. * * closePath creates a seam between the first and the last points of each path of the path array, optional, default false
  27040. * * 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
  27041. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  27042. * * 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)
  27043. * * 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)
  27044. * * invertUV swaps in the U and V coordinates when applying a texture, optional, default false
  27045. * * uvs a linear array, of length 2 * number of vertices, of custom UV values, optional
  27046. * * colors a linear array, of length 4 * number of vertices, of custom color values, optional
  27047. * @returns the VertexData of the ribbon
  27048. */
  27049. static CreateRibbon(options: {
  27050. pathArray: Vector3[][];
  27051. closeArray?: boolean;
  27052. closePath?: boolean;
  27053. offset?: number;
  27054. sideOrientation?: number;
  27055. frontUVs?: Vector4;
  27056. backUVs?: Vector4;
  27057. invertUV?: boolean;
  27058. uvs?: Vector2[];
  27059. colors?: Color4[];
  27060. }): VertexData;
  27061. /**
  27062. * Creates the VertexData for a box
  27063. * @param options an object used to set the following optional parameters for the box, required but can be empty
  27064. * * size sets the width, height and depth of the box to the value of size, optional default 1
  27065. * * width sets the width (x direction) of the box, overwrites the width set by size, optional, default size
  27066. * * height sets the height (y direction) of the box, overwrites the height set by size, optional, default size
  27067. * * depth sets the depth (z direction) of the box, overwrites the depth set by size, optional, default size
  27068. * * faceUV an array of 6 Vector4 elements used to set different images to each box side
  27069. * * faceColors an array of 6 Color3 elements used to set different colors to each box side
  27070. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  27071. * * 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)
  27072. * * 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)
  27073. * @returns the VertexData of the box
  27074. */
  27075. static CreateBox(options: {
  27076. size?: number;
  27077. width?: number;
  27078. height?: number;
  27079. depth?: number;
  27080. faceUV?: Vector4[];
  27081. faceColors?: Color4[];
  27082. sideOrientation?: number;
  27083. frontUVs?: Vector4;
  27084. backUVs?: Vector4;
  27085. }): VertexData;
  27086. /**
  27087. * Creates the VertexData for a tiled box
  27088. * @param options an object used to set the following optional parameters for the box, required but can be empty
  27089. * * faceTiles sets the pattern, tile size and number of tiles for a face
  27090. * * faceUV an array of 6 Vector4 elements used to set different images to each box side
  27091. * * faceColors an array of 6 Color3 elements used to set different colors to each box side
  27092. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  27093. * @returns the VertexData of the box
  27094. */
  27095. static CreateTiledBox(options: {
  27096. pattern?: number;
  27097. width?: number;
  27098. height?: number;
  27099. depth?: number;
  27100. tileSize?: number;
  27101. tileWidth?: number;
  27102. tileHeight?: number;
  27103. alignHorizontal?: number;
  27104. alignVertical?: number;
  27105. faceUV?: Vector4[];
  27106. faceColors?: Color4[];
  27107. sideOrientation?: number;
  27108. }): VertexData;
  27109. /**
  27110. * Creates the VertexData for a tiled plane
  27111. * @param options an object used to set the following optional parameters for the box, required but can be empty
  27112. * * pattern a limited pattern arrangement depending on the number
  27113. * * tileSize sets the width, height and depth of the tile to the value of size, optional default 1
  27114. * * tileWidth sets the width (x direction) of the tile, overwrites the width set by size, optional, default size
  27115. * * tileHeight sets the height (y direction) of the tile, overwrites the height set by size, optional, default size
  27116. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  27117. * * 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)
  27118. * * 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)
  27119. * @returns the VertexData of the tiled plane
  27120. */
  27121. static CreateTiledPlane(options: {
  27122. pattern?: number;
  27123. tileSize?: number;
  27124. tileWidth?: number;
  27125. tileHeight?: number;
  27126. size?: number;
  27127. width?: number;
  27128. height?: number;
  27129. alignHorizontal?: number;
  27130. alignVertical?: number;
  27131. sideOrientation?: number;
  27132. frontUVs?: Vector4;
  27133. backUVs?: Vector4;
  27134. }): VertexData;
  27135. /**
  27136. * Creates the VertexData for an ellipsoid, defaults to a sphere
  27137. * @param options an object used to set the following optional parameters for the box, required but can be empty
  27138. * * segments sets the number of horizontal strips optional, default 32
  27139. * * diameter sets the axes dimensions, diameterX, diameterY and diameterZ to the value of diameter, optional default 1
  27140. * * diameterX sets the diameterX (x direction) of the ellipsoid, overwrites the diameterX set by diameter, optional, default diameter
  27141. * * diameterY sets the diameterY (y direction) of the ellipsoid, overwrites the diameterY set by diameter, optional, default diameter
  27142. * * diameterZ sets the diameterZ (z direction) of the ellipsoid, overwrites the diameterZ set by diameter, optional, default diameter
  27143. * * 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
  27144. * * 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
  27145. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  27146. * * 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)
  27147. * * 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)
  27148. * @returns the VertexData of the ellipsoid
  27149. */
  27150. static CreateSphere(options: {
  27151. segments?: number;
  27152. diameter?: number;
  27153. diameterX?: number;
  27154. diameterY?: number;
  27155. diameterZ?: number;
  27156. arc?: number;
  27157. slice?: number;
  27158. sideOrientation?: number;
  27159. frontUVs?: Vector4;
  27160. backUVs?: Vector4;
  27161. }): VertexData;
  27162. /**
  27163. * Creates the VertexData for a cylinder, cone or prism
  27164. * @param options an object used to set the following optional parameters for the box, required but can be empty
  27165. * * height sets the height (y direction) of the cylinder, optional, default 2
  27166. * * diameterTop sets the diameter of the top of the cone, overwrites diameter, optional, default diameter
  27167. * * diameterBottom sets the diameter of the bottom of the cone, overwrites diameter, optional, default diameter
  27168. * * diameter sets the diameter of the top and bottom of the cone, optional default 1
  27169. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  27170. * * subdivisions` the number of rings along the cylinder height, optional, default 1
  27171. * * 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
  27172. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  27173. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  27174. * * hasRings when true makes each subdivision independantly treated as a face for faceUV and faceColors, optional, default false
  27175. * * enclose when true closes an open cylinder by adding extra flat faces between the height axis and vertical edges, think cut cake
  27176. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  27177. * * 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)
  27178. * * 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)
  27179. * @returns the VertexData of the cylinder, cone or prism
  27180. */
  27181. static CreateCylinder(options: {
  27182. height?: number;
  27183. diameterTop?: number;
  27184. diameterBottom?: number;
  27185. diameter?: number;
  27186. tessellation?: number;
  27187. subdivisions?: number;
  27188. arc?: number;
  27189. faceColors?: Color4[];
  27190. faceUV?: Vector4[];
  27191. hasRings?: boolean;
  27192. enclose?: boolean;
  27193. sideOrientation?: number;
  27194. frontUVs?: Vector4;
  27195. backUVs?: Vector4;
  27196. }): VertexData;
  27197. /**
  27198. * Creates the VertexData for a torus
  27199. * @param options an object used to set the following optional parameters for the box, required but can be empty
  27200. * * diameter the diameter of the torus, optional default 1
  27201. * * thickness the diameter of the tube forming the torus, optional default 0.5
  27202. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  27203. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  27204. * * 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)
  27205. * * 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)
  27206. * @returns the VertexData of the torus
  27207. */
  27208. static CreateTorus(options: {
  27209. diameter?: number;
  27210. thickness?: number;
  27211. tessellation?: number;
  27212. sideOrientation?: number;
  27213. frontUVs?: Vector4;
  27214. backUVs?: Vector4;
  27215. }): VertexData;
  27216. /**
  27217. * Creates the VertexData of the LineSystem
  27218. * @param options an object used to set the following optional parameters for the LineSystem, required but can be empty
  27219. * - lines an array of lines, each line being an array of successive Vector3
  27220. * - colors an array of line colors, each of the line colors being an array of successive Color4, one per line point
  27221. * @returns the VertexData of the LineSystem
  27222. */
  27223. static CreateLineSystem(options: {
  27224. lines: Vector3[][];
  27225. colors?: Nullable<Color4[][]>;
  27226. }): VertexData;
  27227. /**
  27228. * Create the VertexData for a DashedLines
  27229. * @param options an object used to set the following optional parameters for the DashedLines, required but can be empty
  27230. * - points an array successive Vector3
  27231. * - dashSize the size of the dashes relative to the dash number, optional, default 3
  27232. * - gapSize the size of the gap between two successive dashes relative to the dash number, optional, default 1
  27233. * - dashNb the intended total number of dashes, optional, default 200
  27234. * @returns the VertexData for the DashedLines
  27235. */
  27236. static CreateDashedLines(options: {
  27237. points: Vector3[];
  27238. dashSize?: number;
  27239. gapSize?: number;
  27240. dashNb?: number;
  27241. }): VertexData;
  27242. /**
  27243. * Creates the VertexData for a Ground
  27244. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  27245. * - width the width (x direction) of the ground, optional, default 1
  27246. * - height the height (z direction) of the ground, optional, default 1
  27247. * - subdivisions the number of subdivisions per side, optional, default 1
  27248. * @returns the VertexData of the Ground
  27249. */
  27250. static CreateGround(options: {
  27251. width?: number;
  27252. height?: number;
  27253. subdivisions?: number;
  27254. subdivisionsX?: number;
  27255. subdivisionsY?: number;
  27256. }): VertexData;
  27257. /**
  27258. * Creates the VertexData for a TiledGround by subdividing the ground into tiles
  27259. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  27260. * * xmin the ground minimum X coordinate, optional, default -1
  27261. * * zmin the ground minimum Z coordinate, optional, default -1
  27262. * * xmax the ground maximum X coordinate, optional, default 1
  27263. * * zmax the ground maximum Z coordinate, optional, default 1
  27264. * * 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}
  27265. * * 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}
  27266. * @returns the VertexData of the TiledGround
  27267. */
  27268. static CreateTiledGround(options: {
  27269. xmin: number;
  27270. zmin: number;
  27271. xmax: number;
  27272. zmax: number;
  27273. subdivisions?: {
  27274. w: number;
  27275. h: number;
  27276. };
  27277. precision?: {
  27278. w: number;
  27279. h: number;
  27280. };
  27281. }): VertexData;
  27282. /**
  27283. * Creates the VertexData of the Ground designed from a heightmap
  27284. * @param options an object used to set the following parameters for the Ground, required and provided by MeshBuilder.CreateGroundFromHeightMap
  27285. * * width the width (x direction) of the ground
  27286. * * height the height (z direction) of the ground
  27287. * * subdivisions the number of subdivisions per side
  27288. * * minHeight the minimum altitude on the ground, optional, default 0
  27289. * * maxHeight the maximum altitude on the ground, optional default 1
  27290. * * colorFilter the filter to apply to the image pixel colors to compute the height, optional Color3, default (0.3, 0.59, 0.11)
  27291. * * buffer the array holding the image color data
  27292. * * bufferWidth the width of image
  27293. * * bufferHeight the height of image
  27294. * * alphaFilter Remove any data where the alpha channel is below this value, defaults 0 (all data visible)
  27295. * @returns the VertexData of the Ground designed from a heightmap
  27296. */
  27297. static CreateGroundFromHeightMap(options: {
  27298. width: number;
  27299. height: number;
  27300. subdivisions: number;
  27301. minHeight: number;
  27302. maxHeight: number;
  27303. colorFilter: Color3;
  27304. buffer: Uint8Array;
  27305. bufferWidth: number;
  27306. bufferHeight: number;
  27307. alphaFilter: number;
  27308. }): VertexData;
  27309. /**
  27310. * Creates the VertexData for a Plane
  27311. * @param options an object used to set the following optional parameters for the plane, required but can be empty
  27312. * * size sets the width and height of the plane to the value of size, optional default 1
  27313. * * width sets the width (x direction) of the plane, overwrites the width set by size, optional, default size
  27314. * * height sets the height (y direction) of the plane, overwrites the height set by size, optional, default size
  27315. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  27316. * * 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)
  27317. * * 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)
  27318. * @returns the VertexData of the box
  27319. */
  27320. static CreatePlane(options: {
  27321. size?: number;
  27322. width?: number;
  27323. height?: number;
  27324. sideOrientation?: number;
  27325. frontUVs?: Vector4;
  27326. backUVs?: Vector4;
  27327. }): VertexData;
  27328. /**
  27329. * Creates the VertexData of the Disc or regular Polygon
  27330. * @param options an object used to set the following optional parameters for the disc, required but can be empty
  27331. * * radius the radius of the disc, optional default 0.5
  27332. * * tessellation the number of polygon sides, optional, default 64
  27333. * * 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
  27334. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  27335. * * 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)
  27336. * * 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)
  27337. * @returns the VertexData of the box
  27338. */
  27339. static CreateDisc(options: {
  27340. radius?: number;
  27341. tessellation?: number;
  27342. arc?: number;
  27343. sideOrientation?: number;
  27344. frontUVs?: Vector4;
  27345. backUVs?: Vector4;
  27346. }): VertexData;
  27347. /**
  27348. * Creates the VertexData for an irregular Polygon in the XoZ plane using a mesh built by polygonTriangulation.build()
  27349. * All parameters are provided by MeshBuilder.CreatePolygon as needed
  27350. * @param polygon a mesh built from polygonTriangulation.build()
  27351. * @param sideOrientation takes the values Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  27352. * @param fUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  27353. * @param fColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  27354. * @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)
  27355. * @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)
  27356. * @param wrap a boolean, default false, when true and fUVs used texture is wrapped around all sides, when false texture is applied side
  27357. * @returns the VertexData of the Polygon
  27358. */
  27359. static CreatePolygon(polygon: Mesh, sideOrientation: number, fUV?: Vector4[], fColors?: Color4[], frontUVs?: Vector4, backUVs?: Vector4, wrap?: boolean): VertexData;
  27360. /**
  27361. * Creates the VertexData of the IcoSphere
  27362. * @param options an object used to set the following optional parameters for the IcoSphere, required but can be empty
  27363. * * radius the radius of the IcoSphere, optional default 1
  27364. * * radiusX allows stretching in the x direction, optional, default radius
  27365. * * radiusY allows stretching in the y direction, optional, default radius
  27366. * * radiusZ allows stretching in the z direction, optional, default radius
  27367. * * flat when true creates a flat shaded mesh, optional, default true
  27368. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  27369. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  27370. * * 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)
  27371. * * 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)
  27372. * @returns the VertexData of the IcoSphere
  27373. */
  27374. static CreateIcoSphere(options: {
  27375. radius?: number;
  27376. radiusX?: number;
  27377. radiusY?: number;
  27378. radiusZ?: number;
  27379. flat?: boolean;
  27380. subdivisions?: number;
  27381. sideOrientation?: number;
  27382. frontUVs?: Vector4;
  27383. backUVs?: Vector4;
  27384. }): VertexData;
  27385. /**
  27386. * Creates the VertexData for a Polyhedron
  27387. * @param options an object used to set the following optional parameters for the polyhedron, required but can be empty
  27388. * * type provided types are:
  27389. * * 0 : Tetrahedron, 1 : Octahedron, 2 : Dodecahedron, 3 : Icosahedron, 4 : Rhombicuboctahedron, 5 : Triangular Prism, 6 : Pentagonal Prism, 7 : Hexagonal Prism, 8 : Square Pyramid (J1)
  27390. * * 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)
  27391. * * size the size of the IcoSphere, optional default 1
  27392. * * sizeX allows stretching in the x direction, optional, default size
  27393. * * sizeY allows stretching in the y direction, optional, default size
  27394. * * sizeZ allows stretching in the z direction, optional, default size
  27395. * * 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
  27396. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  27397. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  27398. * * flat when true creates a flat shaded mesh, optional, default true
  27399. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  27400. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  27401. * * frontUvs only usable when you create a double-sided mesh, used to choose what parts of the texture image to crop and apply on the front side, optional, default vector4 (0, 0, 1, 1)
  27402. * * backUVs only usable when you create a double-sided mesh, used to choose what parts of the texture image to crop and apply on the back side, optional, default vector4 (0, 0, 1, 1)
  27403. * @returns the VertexData of the Polyhedron
  27404. */
  27405. static CreatePolyhedron(options: {
  27406. type?: number;
  27407. size?: number;
  27408. sizeX?: number;
  27409. sizeY?: number;
  27410. sizeZ?: number;
  27411. custom?: any;
  27412. faceUV?: Vector4[];
  27413. faceColors?: Color4[];
  27414. flat?: boolean;
  27415. sideOrientation?: number;
  27416. frontUVs?: Vector4;
  27417. backUVs?: Vector4;
  27418. }): VertexData;
  27419. /**
  27420. * Creates the VertexData for a TorusKnot
  27421. * @param options an object used to set the following optional parameters for the TorusKnot, required but can be empty
  27422. * * radius the radius of the torus knot, optional, default 2
  27423. * * tube the thickness of the tube, optional, default 0.5
  27424. * * radialSegments the number of sides on each tube segments, optional, default 32
  27425. * * tubularSegments the number of tubes to decompose the knot into, optional, default 32
  27426. * * p the number of windings around the z axis, optional, default 2
  27427. * * q the number of windings around the x axis, optional, default 3
  27428. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  27429. * * 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)
  27430. * * 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)
  27431. * @returns the VertexData of the Torus Knot
  27432. */
  27433. static CreateTorusKnot(options: {
  27434. radius?: number;
  27435. tube?: number;
  27436. radialSegments?: number;
  27437. tubularSegments?: number;
  27438. p?: number;
  27439. q?: number;
  27440. sideOrientation?: number;
  27441. frontUVs?: Vector4;
  27442. backUVs?: Vector4;
  27443. }): VertexData;
  27444. /**
  27445. * Compute normals for given positions and indices
  27446. * @param positions an array of vertex positions, [...., x, y, z, ......]
  27447. * @param indices an array of indices in groups of three for each triangular facet, [...., i, j, k, ......]
  27448. * @param normals an array of vertex normals, [...., x, y, z, ......]
  27449. * @param options an object used to set the following optional parameters for the TorusKnot, optional
  27450. * * facetNormals : optional array of facet normals (vector3)
  27451. * * facetPositions : optional array of facet positions (vector3)
  27452. * * facetPartitioning : optional partitioning array. facetPositions is required for facetPartitioning computation
  27453. * * ratio : optional partitioning ratio / bounding box, required for facetPartitioning computation
  27454. * * bInfo : optional bounding info, required for facetPartitioning computation
  27455. * * bbSize : optional bounding box size data, required for facetPartitioning computation
  27456. * * subDiv : optional partitioning data about subdivsions on each axis (int), required for facetPartitioning computation
  27457. * * useRightHandedSystem: optional boolean to for right handed system computation
  27458. * * depthSort : optional boolean to enable the facet depth sort computation
  27459. * * distanceTo : optional Vector3 to compute the facet depth from this location
  27460. * * depthSortedFacets : optional array of depthSortedFacets to store the facet distances from the reference location
  27461. */
  27462. static ComputeNormals(positions: any, indices: any, normals: any, options?: {
  27463. facetNormals?: any;
  27464. facetPositions?: any;
  27465. facetPartitioning?: any;
  27466. ratio?: number;
  27467. bInfo?: any;
  27468. bbSize?: Vector3;
  27469. subDiv?: any;
  27470. useRightHandedSystem?: boolean;
  27471. depthSort?: boolean;
  27472. distanceTo?: Vector3;
  27473. depthSortedFacets?: any;
  27474. }): void;
  27475. /** @hidden */
  27476. static _ComputeSides(sideOrientation: number, positions: FloatArray, indices: FloatArray, normals: FloatArray, uvs: FloatArray, frontUVs?: Vector4, backUVs?: Vector4): void;
  27477. /**
  27478. * Applies VertexData created from the imported parameters to the geometry
  27479. * @param parsedVertexData the parsed data from an imported file
  27480. * @param geometry the geometry to apply the VertexData to
  27481. */
  27482. static ImportVertexData(parsedVertexData: any, geometry: Geometry): void;
  27483. }
  27484. }
  27485. declare module "babylonjs/Morph/morphTarget" {
  27486. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  27487. import { Observable } from "babylonjs/Misc/observable";
  27488. import { Nullable, FloatArray } from "babylonjs/types";
  27489. import { Scene } from "babylonjs/scene";
  27490. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  27491. import { AnimationPropertiesOverride } from "babylonjs/Animations/animationPropertiesOverride";
  27492. /**
  27493. * Defines a target to use with MorphTargetManager
  27494. * @see https://doc.babylonjs.com/how_to/how_to_use_morphtargets
  27495. */
  27496. export class MorphTarget implements IAnimatable {
  27497. /** defines the name of the target */
  27498. name: string;
  27499. /**
  27500. * Gets or sets the list of animations
  27501. */
  27502. animations: import("babylonjs/Animations/animation").Animation[];
  27503. private _scene;
  27504. private _positions;
  27505. private _normals;
  27506. private _tangents;
  27507. private _uvs;
  27508. private _influence;
  27509. private _uniqueId;
  27510. /**
  27511. * Observable raised when the influence changes
  27512. */
  27513. onInfluenceChanged: Observable<boolean>;
  27514. /** @hidden */
  27515. _onDataLayoutChanged: Observable<void>;
  27516. /**
  27517. * Gets or sets the influence of this target (ie. its weight in the overall morphing)
  27518. */
  27519. get influence(): number;
  27520. set influence(influence: number);
  27521. /**
  27522. * Gets or sets the id of the morph Target
  27523. */
  27524. id: string;
  27525. private _animationPropertiesOverride;
  27526. /**
  27527. * Gets or sets the animation properties override
  27528. */
  27529. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  27530. set animationPropertiesOverride(value: Nullable<AnimationPropertiesOverride>);
  27531. /**
  27532. * Creates a new MorphTarget
  27533. * @param name defines the name of the target
  27534. * @param influence defines the influence to use
  27535. * @param scene defines the scene the morphtarget belongs to
  27536. */
  27537. constructor(
  27538. /** defines the name of the target */
  27539. name: string, influence?: number, scene?: Nullable<Scene>);
  27540. /**
  27541. * Gets the unique ID of this manager
  27542. */
  27543. get uniqueId(): number;
  27544. /**
  27545. * Gets a boolean defining if the target contains position data
  27546. */
  27547. get hasPositions(): boolean;
  27548. /**
  27549. * Gets a boolean defining if the target contains normal data
  27550. */
  27551. get hasNormals(): boolean;
  27552. /**
  27553. * Gets a boolean defining if the target contains tangent data
  27554. */
  27555. get hasTangents(): boolean;
  27556. /**
  27557. * Gets a boolean defining if the target contains texture coordinates data
  27558. */
  27559. get hasUVs(): boolean;
  27560. /**
  27561. * Affects position data to this target
  27562. * @param data defines the position data to use
  27563. */
  27564. setPositions(data: Nullable<FloatArray>): void;
  27565. /**
  27566. * Gets the position data stored in this target
  27567. * @returns a FloatArray containing the position data (or null if not present)
  27568. */
  27569. getPositions(): Nullable<FloatArray>;
  27570. /**
  27571. * Affects normal data to this target
  27572. * @param data defines the normal data to use
  27573. */
  27574. setNormals(data: Nullable<FloatArray>): void;
  27575. /**
  27576. * Gets the normal data stored in this target
  27577. * @returns a FloatArray containing the normal data (or null if not present)
  27578. */
  27579. getNormals(): Nullable<FloatArray>;
  27580. /**
  27581. * Affects tangent data to this target
  27582. * @param data defines the tangent data to use
  27583. */
  27584. setTangents(data: Nullable<FloatArray>): void;
  27585. /**
  27586. * Gets the tangent data stored in this target
  27587. * @returns a FloatArray containing the tangent data (or null if not present)
  27588. */
  27589. getTangents(): Nullable<FloatArray>;
  27590. /**
  27591. * Affects texture coordinates data to this target
  27592. * @param data defines the texture coordinates data to use
  27593. */
  27594. setUVs(data: Nullable<FloatArray>): void;
  27595. /**
  27596. * Gets the texture coordinates data stored in this target
  27597. * @returns a FloatArray containing the texture coordinates data (or null if not present)
  27598. */
  27599. getUVs(): Nullable<FloatArray>;
  27600. /**
  27601. * Clone the current target
  27602. * @returns a new MorphTarget
  27603. */
  27604. clone(): MorphTarget;
  27605. /**
  27606. * Serializes the current target into a Serialization object
  27607. * @returns the serialized object
  27608. */
  27609. serialize(): any;
  27610. /**
  27611. * Returns the string "MorphTarget"
  27612. * @returns "MorphTarget"
  27613. */
  27614. getClassName(): string;
  27615. /**
  27616. * Creates a new target from serialized data
  27617. * @param serializationObject defines the serialized data to use
  27618. * @returns a new MorphTarget
  27619. */
  27620. static Parse(serializationObject: any): MorphTarget;
  27621. /**
  27622. * Creates a MorphTarget from mesh data
  27623. * @param mesh defines the source mesh
  27624. * @param name defines the name to use for the new target
  27625. * @param influence defines the influence to attach to the target
  27626. * @returns a new MorphTarget
  27627. */
  27628. static FromMesh(mesh: AbstractMesh, name?: string, influence?: number): MorphTarget;
  27629. }
  27630. }
  27631. declare module "babylonjs/Morph/morphTargetManager" {
  27632. import { Nullable } from "babylonjs/types";
  27633. import { Scene } from "babylonjs/scene";
  27634. import { MorphTarget } from "babylonjs/Morph/morphTarget";
  27635. /**
  27636. * This class is used to deform meshes using morphing between different targets
  27637. * @see https://doc.babylonjs.com/how_to/how_to_use_morphtargets
  27638. */
  27639. export class MorphTargetManager {
  27640. private _targets;
  27641. private _targetInfluenceChangedObservers;
  27642. private _targetDataLayoutChangedObservers;
  27643. private _activeTargets;
  27644. private _scene;
  27645. private _influences;
  27646. private _supportsNormals;
  27647. private _supportsTangents;
  27648. private _supportsUVs;
  27649. private _vertexCount;
  27650. private _uniqueId;
  27651. private _tempInfluences;
  27652. /**
  27653. * Gets or sets a boolean indicating if normals must be morphed
  27654. */
  27655. enableNormalMorphing: boolean;
  27656. /**
  27657. * Gets or sets a boolean indicating if tangents must be morphed
  27658. */
  27659. enableTangentMorphing: boolean;
  27660. /**
  27661. * Gets or sets a boolean indicating if UV must be morphed
  27662. */
  27663. enableUVMorphing: boolean;
  27664. /**
  27665. * Creates a new MorphTargetManager
  27666. * @param scene defines the current scene
  27667. */
  27668. constructor(scene?: Nullable<Scene>);
  27669. /**
  27670. * Gets the unique ID of this manager
  27671. */
  27672. get uniqueId(): number;
  27673. /**
  27674. * Gets the number of vertices handled by this manager
  27675. */
  27676. get vertexCount(): number;
  27677. /**
  27678. * Gets a boolean indicating if this manager supports morphing of normals
  27679. */
  27680. get supportsNormals(): boolean;
  27681. /**
  27682. * Gets a boolean indicating if this manager supports morphing of tangents
  27683. */
  27684. get supportsTangents(): boolean;
  27685. /**
  27686. * Gets a boolean indicating if this manager supports morphing of texture coordinates
  27687. */
  27688. get supportsUVs(): boolean;
  27689. /**
  27690. * Gets the number of targets stored in this manager
  27691. */
  27692. get numTargets(): number;
  27693. /**
  27694. * Gets the number of influencers (ie. the number of targets with influences > 0)
  27695. */
  27696. get numInfluencers(): number;
  27697. /**
  27698. * Gets the list of influences (one per target)
  27699. */
  27700. get influences(): Float32Array;
  27701. /**
  27702. * Gets the active target at specified index. An active target is a target with an influence > 0
  27703. * @param index defines the index to check
  27704. * @returns the requested target
  27705. */
  27706. getActiveTarget(index: number): MorphTarget;
  27707. /**
  27708. * Gets the target at specified index
  27709. * @param index defines the index to check
  27710. * @returns the requested target
  27711. */
  27712. getTarget(index: number): MorphTarget;
  27713. /**
  27714. * Add a new target to this manager
  27715. * @param target defines the target to add
  27716. */
  27717. addTarget(target: MorphTarget): void;
  27718. /**
  27719. * Removes a target from the manager
  27720. * @param target defines the target to remove
  27721. */
  27722. removeTarget(target: MorphTarget): void;
  27723. /**
  27724. * Clone the current manager
  27725. * @returns a new MorphTargetManager
  27726. */
  27727. clone(): MorphTargetManager;
  27728. /**
  27729. * Serializes the current manager into a Serialization object
  27730. * @returns the serialized object
  27731. */
  27732. serialize(): any;
  27733. private _syncActiveTargets;
  27734. /**
  27735. * Syncrhonize the targets with all the meshes using this morph target manager
  27736. */
  27737. synchronize(): void;
  27738. /**
  27739. * Creates a new MorphTargetManager from serialized data
  27740. * @param serializationObject defines the serialized data
  27741. * @param scene defines the hosting scene
  27742. * @returns the new MorphTargetManager
  27743. */
  27744. static Parse(serializationObject: any, scene: Scene): MorphTargetManager;
  27745. }
  27746. }
  27747. declare module "babylonjs/Meshes/meshLODLevel" {
  27748. import { Mesh } from "babylonjs/Meshes/mesh";
  27749. import { Nullable } from "babylonjs/types";
  27750. /**
  27751. * Class used to represent a specific level of detail of a mesh
  27752. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  27753. */
  27754. export class MeshLODLevel {
  27755. /** Defines the distance where this level should start being displayed */
  27756. distance: number;
  27757. /** Defines the mesh to use to render this level */
  27758. mesh: Nullable<Mesh>;
  27759. /**
  27760. * Creates a new LOD level
  27761. * @param distance defines the distance where this level should star being displayed
  27762. * @param mesh defines the mesh to use to render this level
  27763. */
  27764. constructor(
  27765. /** Defines the distance where this level should start being displayed */
  27766. distance: number,
  27767. /** Defines the mesh to use to render this level */
  27768. mesh: Nullable<Mesh>);
  27769. }
  27770. }
  27771. declare module "babylonjs/Misc/canvasGenerator" {
  27772. /**
  27773. * Helper class used to generate a canvas to manipulate images
  27774. */
  27775. export class CanvasGenerator {
  27776. /**
  27777. * Create a new canvas (or offscreen canvas depending on the context)
  27778. * @param width defines the expected width
  27779. * @param height defines the expected height
  27780. * @return a new canvas or offscreen canvas
  27781. */
  27782. static CreateCanvas(width: number, height: number): HTMLCanvasElement | OffscreenCanvas;
  27783. }
  27784. }
  27785. declare module "babylonjs/Meshes/groundMesh" {
  27786. import { Scene } from "babylonjs/scene";
  27787. import { Vector3 } from "babylonjs/Maths/math.vector";
  27788. import { Mesh } from "babylonjs/Meshes/mesh";
  27789. /**
  27790. * Mesh representing the gorund
  27791. */
  27792. export class GroundMesh extends Mesh {
  27793. /** If octree should be generated */
  27794. generateOctree: boolean;
  27795. private _heightQuads;
  27796. /** @hidden */
  27797. _subdivisionsX: number;
  27798. /** @hidden */
  27799. _subdivisionsY: number;
  27800. /** @hidden */
  27801. _width: number;
  27802. /** @hidden */
  27803. _height: number;
  27804. /** @hidden */
  27805. _minX: number;
  27806. /** @hidden */
  27807. _maxX: number;
  27808. /** @hidden */
  27809. _minZ: number;
  27810. /** @hidden */
  27811. _maxZ: number;
  27812. constructor(name: string, scene: Scene);
  27813. /**
  27814. * "GroundMesh"
  27815. * @returns "GroundMesh"
  27816. */
  27817. getClassName(): string;
  27818. /**
  27819. * The minimum of x and y subdivisions
  27820. */
  27821. get subdivisions(): number;
  27822. /**
  27823. * X subdivisions
  27824. */
  27825. get subdivisionsX(): number;
  27826. /**
  27827. * Y subdivisions
  27828. */
  27829. get subdivisionsY(): number;
  27830. /**
  27831. * This function will update an octree to help to select the right submeshes for rendering, picking and collision computations.
  27832. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  27833. * @param chunksCount the number of subdivisions for x and y
  27834. * @param octreeBlocksSize (Default: 32)
  27835. */
  27836. optimize(chunksCount: number, octreeBlocksSize?: number): void;
  27837. /**
  27838. * Returns a height (y) value in the Worl system :
  27839. * the ground altitude at the coordinates (x, z) expressed in the World system.
  27840. * @param x x coordinate
  27841. * @param z z coordinate
  27842. * @returns the ground y position if (x, z) are outside the ground surface.
  27843. */
  27844. getHeightAtCoordinates(x: number, z: number): number;
  27845. /**
  27846. * Returns a normalized vector (Vector3) orthogonal to the ground
  27847. * at the ground coordinates (x, z) expressed in the World system.
  27848. * @param x x coordinate
  27849. * @param z z coordinate
  27850. * @returns Vector3(0.0, 1.0, 0.0) if (x, z) are outside the ground surface.
  27851. */
  27852. getNormalAtCoordinates(x: number, z: number): Vector3;
  27853. /**
  27854. * Updates the Vector3 passed a reference with a normalized vector orthogonal to the ground
  27855. * at the ground coordinates (x, z) expressed in the World system.
  27856. * Doesn't uptade the reference Vector3 if (x, z) are outside the ground surface.
  27857. * @param x x coordinate
  27858. * @param z z coordinate
  27859. * @param ref vector to store the result
  27860. * @returns the GroundMesh.
  27861. */
  27862. getNormalAtCoordinatesToRef(x: number, z: number, ref: Vector3): GroundMesh;
  27863. /**
  27864. * Force the heights to be recomputed for getHeightAtCoordinates() or getNormalAtCoordinates()
  27865. * if the ground has been updated.
  27866. * This can be used in the render loop.
  27867. * @returns the GroundMesh.
  27868. */
  27869. updateCoordinateHeights(): GroundMesh;
  27870. private _getFacetAt;
  27871. private _initHeightQuads;
  27872. private _computeHeightQuads;
  27873. /**
  27874. * Serializes this ground mesh
  27875. * @param serializationObject object to write serialization to
  27876. */
  27877. serialize(serializationObject: any): void;
  27878. /**
  27879. * Parses a serialized ground mesh
  27880. * @param parsedMesh the serialized mesh
  27881. * @param scene the scene to create the ground mesh in
  27882. * @returns the created ground mesh
  27883. */
  27884. static Parse(parsedMesh: any, scene: Scene): GroundMesh;
  27885. }
  27886. }
  27887. declare module "babylonjs/Physics/physicsJoint" {
  27888. import { Vector3 } from "babylonjs/Maths/math.vector";
  27889. import { IPhysicsEnginePlugin } from "babylonjs/Physics/IPhysicsEngine";
  27890. /**
  27891. * Interface for Physics-Joint data
  27892. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  27893. */
  27894. export interface PhysicsJointData {
  27895. /**
  27896. * The main pivot of the joint
  27897. */
  27898. mainPivot?: Vector3;
  27899. /**
  27900. * The connected pivot of the joint
  27901. */
  27902. connectedPivot?: Vector3;
  27903. /**
  27904. * The main axis of the joint
  27905. */
  27906. mainAxis?: Vector3;
  27907. /**
  27908. * The connected axis of the joint
  27909. */
  27910. connectedAxis?: Vector3;
  27911. /**
  27912. * The collision of the joint
  27913. */
  27914. collision?: boolean;
  27915. /**
  27916. * Native Oimo/Cannon/Energy data
  27917. */
  27918. nativeParams?: any;
  27919. }
  27920. /**
  27921. * This is a holder class for the physics joint created by the physics plugin
  27922. * It holds a set of functions to control the underlying joint
  27923. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  27924. */
  27925. export class PhysicsJoint {
  27926. /**
  27927. * The type of the physics joint
  27928. */
  27929. type: number;
  27930. /**
  27931. * The data for the physics joint
  27932. */
  27933. jointData: PhysicsJointData;
  27934. private _physicsJoint;
  27935. protected _physicsPlugin: IPhysicsEnginePlugin;
  27936. /**
  27937. * Initializes the physics joint
  27938. * @param type The type of the physics joint
  27939. * @param jointData The data for the physics joint
  27940. */
  27941. constructor(
  27942. /**
  27943. * The type of the physics joint
  27944. */
  27945. type: number,
  27946. /**
  27947. * The data for the physics joint
  27948. */
  27949. jointData: PhysicsJointData);
  27950. /**
  27951. * Gets the physics joint
  27952. */
  27953. get physicsJoint(): any;
  27954. /**
  27955. * Sets the physics joint
  27956. */
  27957. set physicsJoint(newJoint: any);
  27958. /**
  27959. * Sets the physics plugin
  27960. */
  27961. set physicsPlugin(physicsPlugin: IPhysicsEnginePlugin);
  27962. /**
  27963. * Execute a function that is physics-plugin specific.
  27964. * @param {Function} func the function that will be executed.
  27965. * It accepts two parameters: the physics world and the physics joint
  27966. */
  27967. executeNativeFunction(func: (world: any, physicsJoint: any) => void): void;
  27968. /**
  27969. * Distance-Joint type
  27970. */
  27971. static DistanceJoint: number;
  27972. /**
  27973. * Hinge-Joint type
  27974. */
  27975. static HingeJoint: number;
  27976. /**
  27977. * Ball-and-Socket joint type
  27978. */
  27979. static BallAndSocketJoint: number;
  27980. /**
  27981. * Wheel-Joint type
  27982. */
  27983. static WheelJoint: number;
  27984. /**
  27985. * Slider-Joint type
  27986. */
  27987. static SliderJoint: number;
  27988. /**
  27989. * Prismatic-Joint type
  27990. */
  27991. static PrismaticJoint: number;
  27992. /**
  27993. * Universal-Joint type
  27994. * ENERGY FTW! (compare with this - @see http://ode-wiki.org/wiki/index.php?title=Manual:_Joint_Types_and_Functions)
  27995. */
  27996. static UniversalJoint: number;
  27997. /**
  27998. * Hinge-Joint 2 type
  27999. */
  28000. static Hinge2Joint: number;
  28001. /**
  28002. * Point to Point Joint type. Similar to a Ball-Joint. Different in parameters
  28003. */
  28004. static PointToPointJoint: number;
  28005. /**
  28006. * Spring-Joint type
  28007. */
  28008. static SpringJoint: number;
  28009. /**
  28010. * Lock-Joint type
  28011. */
  28012. static LockJoint: number;
  28013. }
  28014. /**
  28015. * A class representing a physics distance joint
  28016. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  28017. */
  28018. export class DistanceJoint extends PhysicsJoint {
  28019. /**
  28020. *
  28021. * @param jointData The data for the Distance-Joint
  28022. */
  28023. constructor(jointData: DistanceJointData);
  28024. /**
  28025. * Update the predefined distance.
  28026. * @param maxDistance The maximum preferred distance
  28027. * @param minDistance The minimum preferred distance
  28028. */
  28029. updateDistance(maxDistance: number, minDistance?: number): void;
  28030. }
  28031. /**
  28032. * Represents a Motor-Enabled Joint
  28033. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  28034. */
  28035. export class MotorEnabledJoint extends PhysicsJoint implements IMotorEnabledJoint {
  28036. /**
  28037. * Initializes the Motor-Enabled Joint
  28038. * @param type The type of the joint
  28039. * @param jointData The physica joint data for the joint
  28040. */
  28041. constructor(type: number, jointData: PhysicsJointData);
  28042. /**
  28043. * Set the motor values.
  28044. * Attention, this function is plugin specific. Engines won't react 100% the same.
  28045. * @param force the force to apply
  28046. * @param maxForce max force for this motor.
  28047. */
  28048. setMotor(force?: number, maxForce?: number): void;
  28049. /**
  28050. * Set the motor's limits.
  28051. * Attention, this function is plugin specific. Engines won't react 100% the same.
  28052. * @param upperLimit The upper limit of the motor
  28053. * @param lowerLimit The lower limit of the motor
  28054. */
  28055. setLimit(upperLimit: number, lowerLimit?: number): void;
  28056. }
  28057. /**
  28058. * This class represents a single physics Hinge-Joint
  28059. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  28060. */
  28061. export class HingeJoint extends MotorEnabledJoint {
  28062. /**
  28063. * Initializes the Hinge-Joint
  28064. * @param jointData The joint data for the Hinge-Joint
  28065. */
  28066. constructor(jointData: PhysicsJointData);
  28067. /**
  28068. * Set the motor values.
  28069. * Attention, this function is plugin specific. Engines won't react 100% the same.
  28070. * @param {number} force the force to apply
  28071. * @param {number} maxForce max force for this motor.
  28072. */
  28073. setMotor(force?: number, maxForce?: number): void;
  28074. /**
  28075. * Set the motor's limits.
  28076. * Attention, this function is plugin specific. Engines won't react 100% the same.
  28077. * @param upperLimit The upper limit of the motor
  28078. * @param lowerLimit The lower limit of the motor
  28079. */
  28080. setLimit(upperLimit: number, lowerLimit?: number): void;
  28081. }
  28082. /**
  28083. * This class represents a dual hinge physics joint (same as wheel joint)
  28084. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  28085. */
  28086. export class Hinge2Joint extends MotorEnabledJoint {
  28087. /**
  28088. * Initializes the Hinge2-Joint
  28089. * @param jointData The joint data for the Hinge2-Joint
  28090. */
  28091. constructor(jointData: PhysicsJointData);
  28092. /**
  28093. * Set the motor values.
  28094. * Attention, this function is plugin specific. Engines won't react 100% the same.
  28095. * @param {number} targetSpeed the speed the motor is to reach
  28096. * @param {number} maxForce max force for this motor.
  28097. * @param {motorIndex} the motor's index, 0 or 1.
  28098. */
  28099. setMotor(targetSpeed?: number, maxForce?: number, motorIndex?: number): void;
  28100. /**
  28101. * Set the motor limits.
  28102. * Attention, this function is plugin specific. Engines won't react 100% the same.
  28103. * @param {number} upperLimit the upper limit
  28104. * @param {number} lowerLimit lower limit
  28105. * @param {motorIndex} the motor's index, 0 or 1.
  28106. */
  28107. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  28108. }
  28109. /**
  28110. * Interface for a motor enabled joint
  28111. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  28112. */
  28113. export interface IMotorEnabledJoint {
  28114. /**
  28115. * Physics joint
  28116. */
  28117. physicsJoint: any;
  28118. /**
  28119. * Sets the motor of the motor-enabled joint
  28120. * @param force The force of the motor
  28121. * @param maxForce The maximum force of the motor
  28122. * @param motorIndex The index of the motor
  28123. */
  28124. setMotor(force?: number, maxForce?: number, motorIndex?: number): void;
  28125. /**
  28126. * Sets the limit of the motor
  28127. * @param upperLimit The upper limit of the motor
  28128. * @param lowerLimit The lower limit of the motor
  28129. * @param motorIndex The index of the motor
  28130. */
  28131. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  28132. }
  28133. /**
  28134. * Joint data for a Distance-Joint
  28135. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  28136. */
  28137. export interface DistanceJointData extends PhysicsJointData {
  28138. /**
  28139. * Max distance the 2 joint objects can be apart
  28140. */
  28141. maxDistance: number;
  28142. }
  28143. /**
  28144. * Joint data from a spring joint
  28145. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  28146. */
  28147. export interface SpringJointData extends PhysicsJointData {
  28148. /**
  28149. * Length of the spring
  28150. */
  28151. length: number;
  28152. /**
  28153. * Stiffness of the spring
  28154. */
  28155. stiffness: number;
  28156. /**
  28157. * Damping of the spring
  28158. */
  28159. damping: number;
  28160. /** this callback will be called when applying the force to the impostors. */
  28161. forceApplicationCallback: () => void;
  28162. }
  28163. }
  28164. declare module "babylonjs/Physics/physicsRaycastResult" {
  28165. import { Vector3 } from "babylonjs/Maths/math.vector";
  28166. /**
  28167. * Holds the data for the raycast result
  28168. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  28169. */
  28170. export class PhysicsRaycastResult {
  28171. private _hasHit;
  28172. private _hitDistance;
  28173. private _hitNormalWorld;
  28174. private _hitPointWorld;
  28175. private _rayFromWorld;
  28176. private _rayToWorld;
  28177. /**
  28178. * Gets if there was a hit
  28179. */
  28180. get hasHit(): boolean;
  28181. /**
  28182. * Gets the distance from the hit
  28183. */
  28184. get hitDistance(): number;
  28185. /**
  28186. * Gets the hit normal/direction in the world
  28187. */
  28188. get hitNormalWorld(): Vector3;
  28189. /**
  28190. * Gets the hit point in the world
  28191. */
  28192. get hitPointWorld(): Vector3;
  28193. /**
  28194. * Gets the ray "start point" of the ray in the world
  28195. */
  28196. get rayFromWorld(): Vector3;
  28197. /**
  28198. * Gets the ray "end point" of the ray in the world
  28199. */
  28200. get rayToWorld(): Vector3;
  28201. /**
  28202. * Sets the hit data (normal & point in world space)
  28203. * @param hitNormalWorld defines the normal in world space
  28204. * @param hitPointWorld defines the point in world space
  28205. */
  28206. setHitData(hitNormalWorld: IXYZ, hitPointWorld: IXYZ): void;
  28207. /**
  28208. * Sets the distance from the start point to the hit point
  28209. * @param distance
  28210. */
  28211. setHitDistance(distance: number): void;
  28212. /**
  28213. * Calculates the distance manually
  28214. */
  28215. calculateHitDistance(): void;
  28216. /**
  28217. * Resets all the values to default
  28218. * @param from The from point on world space
  28219. * @param to The to point on world space
  28220. */
  28221. reset(from?: Vector3, to?: Vector3): void;
  28222. }
  28223. /**
  28224. * Interface for the size containing width and height
  28225. */
  28226. interface IXYZ {
  28227. /**
  28228. * X
  28229. */
  28230. x: number;
  28231. /**
  28232. * Y
  28233. */
  28234. y: number;
  28235. /**
  28236. * Z
  28237. */
  28238. z: number;
  28239. }
  28240. }
  28241. declare module "babylonjs/Physics/IPhysicsEngine" {
  28242. import { Nullable } from "babylonjs/types";
  28243. import { Vector3, Quaternion } from "babylonjs/Maths/math.vector";
  28244. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  28245. import { PhysicsImpostor, IPhysicsEnabledObject } from "babylonjs/Physics/physicsImpostor";
  28246. import { PhysicsJoint, IMotorEnabledJoint } from "babylonjs/Physics/physicsJoint";
  28247. import { PhysicsRaycastResult } from "babylonjs/Physics/physicsRaycastResult";
  28248. /**
  28249. * Interface used to describe a physics joint
  28250. */
  28251. export interface PhysicsImpostorJoint {
  28252. /** Defines the main impostor to which the joint is linked */
  28253. mainImpostor: PhysicsImpostor;
  28254. /** Defines the impostor that is connected to the main impostor using this joint */
  28255. connectedImpostor: PhysicsImpostor;
  28256. /** Defines the joint itself */
  28257. joint: PhysicsJoint;
  28258. }
  28259. /** @hidden */
  28260. export interface IPhysicsEnginePlugin {
  28261. world: any;
  28262. name: string;
  28263. setGravity(gravity: Vector3): void;
  28264. setTimeStep(timeStep: number): void;
  28265. getTimeStep(): number;
  28266. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  28267. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  28268. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  28269. generatePhysicsBody(impostor: PhysicsImpostor): void;
  28270. removePhysicsBody(impostor: PhysicsImpostor): void;
  28271. generateJoint(joint: PhysicsImpostorJoint): void;
  28272. removeJoint(joint: PhysicsImpostorJoint): void;
  28273. isSupported(): boolean;
  28274. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  28275. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  28276. setLinearVelocity(impostor: PhysicsImpostor, velocity: Nullable<Vector3>): void;
  28277. setAngularVelocity(impostor: PhysicsImpostor, velocity: Nullable<Vector3>): void;
  28278. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  28279. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  28280. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  28281. getBodyMass(impostor: PhysicsImpostor): number;
  28282. getBodyFriction(impostor: PhysicsImpostor): number;
  28283. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  28284. getBodyRestitution(impostor: PhysicsImpostor): number;
  28285. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  28286. getBodyPressure?(impostor: PhysicsImpostor): number;
  28287. setBodyPressure?(impostor: PhysicsImpostor, pressure: number): void;
  28288. getBodyStiffness?(impostor: PhysicsImpostor): number;
  28289. setBodyStiffness?(impostor: PhysicsImpostor, stiffness: number): void;
  28290. getBodyVelocityIterations?(impostor: PhysicsImpostor): number;
  28291. setBodyVelocityIterations?(impostor: PhysicsImpostor, velocityIterations: number): void;
  28292. getBodyPositionIterations?(impostor: PhysicsImpostor): number;
  28293. setBodyPositionIterations?(impostor: PhysicsImpostor, positionIterations: number): void;
  28294. appendAnchor?(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, width: number, height: number, influence: number, noCollisionBetweenLinkedBodies: boolean): void;
  28295. appendHook?(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, length: number, influence: number, noCollisionBetweenLinkedBodies: boolean): void;
  28296. sleepBody(impostor: PhysicsImpostor): void;
  28297. wakeUpBody(impostor: PhysicsImpostor): void;
  28298. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  28299. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  28300. setMotor(joint: IMotorEnabledJoint, speed: number, maxForce?: number, motorIndex?: number): void;
  28301. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  28302. getRadius(impostor: PhysicsImpostor): number;
  28303. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  28304. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  28305. dispose(): void;
  28306. }
  28307. /**
  28308. * Interface used to define a physics engine
  28309. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  28310. */
  28311. export interface IPhysicsEngine {
  28312. /**
  28313. * Gets the gravity vector used by the simulation
  28314. */
  28315. gravity: Vector3;
  28316. /**
  28317. * Sets the gravity vector used by the simulation
  28318. * @param gravity defines the gravity vector to use
  28319. */
  28320. setGravity(gravity: Vector3): void;
  28321. /**
  28322. * Set the time step of the physics engine.
  28323. * Default is 1/60.
  28324. * To slow it down, enter 1/600 for example.
  28325. * To speed it up, 1/30
  28326. * @param newTimeStep the new timestep to apply to this world.
  28327. */
  28328. setTimeStep(newTimeStep: number): void;
  28329. /**
  28330. * Get the time step of the physics engine.
  28331. * @returns the current time step
  28332. */
  28333. getTimeStep(): number;
  28334. /**
  28335. * Set the sub time step of the physics engine.
  28336. * Default is 0 meaning there is no sub steps
  28337. * To increase physics resolution precision, set a small value (like 1 ms)
  28338. * @param subTimeStep defines the new sub timestep used for physics resolution.
  28339. */
  28340. setSubTimeStep(subTimeStep: number): void;
  28341. /**
  28342. * Get the sub time step of the physics engine.
  28343. * @returns the current sub time step
  28344. */
  28345. getSubTimeStep(): number;
  28346. /**
  28347. * Release all resources
  28348. */
  28349. dispose(): void;
  28350. /**
  28351. * Gets the name of the current physics plugin
  28352. * @returns the name of the plugin
  28353. */
  28354. getPhysicsPluginName(): string;
  28355. /**
  28356. * Adding a new impostor for the impostor tracking.
  28357. * This will be done by the impostor itself.
  28358. * @param impostor the impostor to add
  28359. */
  28360. addImpostor(impostor: PhysicsImpostor): void;
  28361. /**
  28362. * Remove an impostor from the engine.
  28363. * This impostor and its mesh will not longer be updated by the physics engine.
  28364. * @param impostor the impostor to remove
  28365. */
  28366. removeImpostor(impostor: PhysicsImpostor): void;
  28367. /**
  28368. * Add a joint to the physics engine
  28369. * @param mainImpostor defines the main impostor to which the joint is added.
  28370. * @param connectedImpostor defines the impostor that is connected to the main impostor using this joint
  28371. * @param joint defines the joint that will connect both impostors.
  28372. */
  28373. addJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  28374. /**
  28375. * Removes a joint from the simulation
  28376. * @param mainImpostor defines the impostor used with the joint
  28377. * @param connectedImpostor defines the other impostor connected to the main one by the joint
  28378. * @param joint defines the joint to remove
  28379. */
  28380. removeJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  28381. /**
  28382. * Gets the current plugin used to run the simulation
  28383. * @returns current plugin
  28384. */
  28385. getPhysicsPlugin(): IPhysicsEnginePlugin;
  28386. /**
  28387. * Gets the list of physic impostors
  28388. * @returns an array of PhysicsImpostor
  28389. */
  28390. getImpostors(): Array<PhysicsImpostor>;
  28391. /**
  28392. * Gets the impostor for a physics enabled object
  28393. * @param object defines the object impersonated by the impostor
  28394. * @returns the PhysicsImpostor or null if not found
  28395. */
  28396. getImpostorForPhysicsObject(object: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  28397. /**
  28398. * Gets the impostor for a physics body object
  28399. * @param body defines physics body used by the impostor
  28400. * @returns the PhysicsImpostor or null if not found
  28401. */
  28402. getImpostorWithPhysicsBody(body: any): Nullable<PhysicsImpostor>;
  28403. /**
  28404. * Does a raycast in the physics world
  28405. * @param from when should the ray start?
  28406. * @param to when should the ray end?
  28407. * @returns PhysicsRaycastResult
  28408. */
  28409. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  28410. /**
  28411. * Called by the scene. No need to call it.
  28412. * @param delta defines the timespam between frames
  28413. */
  28414. _step(delta: number): void;
  28415. }
  28416. }
  28417. declare module "babylonjs/Physics/physicsImpostor" {
  28418. import { Nullable, IndicesArray } from "babylonjs/types";
  28419. import { Vector3, Matrix, Quaternion } from "babylonjs/Maths/math.vector";
  28420. import { TransformNode } from "babylonjs/Meshes/transformNode";
  28421. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  28422. import { Scene } from "babylonjs/scene";
  28423. import { Bone } from "babylonjs/Bones/bone";
  28424. import { BoundingInfo } from "babylonjs/Culling/boundingInfo";
  28425. import { PhysicsJoint, PhysicsJointData } from "babylonjs/Physics/physicsJoint";
  28426. import { Space } from "babylonjs/Maths/math.axis";
  28427. /**
  28428. * The interface for the physics imposter parameters
  28429. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  28430. */
  28431. export interface PhysicsImpostorParameters {
  28432. /**
  28433. * The mass of the physics imposter
  28434. */
  28435. mass: number;
  28436. /**
  28437. * The friction of the physics imposter
  28438. */
  28439. friction?: number;
  28440. /**
  28441. * The coefficient of restitution of the physics imposter
  28442. */
  28443. restitution?: number;
  28444. /**
  28445. * The native options of the physics imposter
  28446. */
  28447. nativeOptions?: any;
  28448. /**
  28449. * Specifies if the parent should be ignored
  28450. */
  28451. ignoreParent?: boolean;
  28452. /**
  28453. * Specifies if bi-directional transformations should be disabled
  28454. */
  28455. disableBidirectionalTransformation?: boolean;
  28456. /**
  28457. * The pressure inside the physics imposter, soft object only
  28458. */
  28459. pressure?: number;
  28460. /**
  28461. * The stiffness the physics imposter, soft object only
  28462. */
  28463. stiffness?: number;
  28464. /**
  28465. * The number of iterations used in maintaining consistent vertex velocities, soft object only
  28466. */
  28467. velocityIterations?: number;
  28468. /**
  28469. * The number of iterations used in maintaining consistent vertex positions, soft object only
  28470. */
  28471. positionIterations?: number;
  28472. /**
  28473. * The number used to fix points on a cloth (0, 1, 2, 4, 8) or rope (0, 1, 2) only
  28474. * 0 None, 1, back left or top, 2, back right or bottom, 4, front left, 8, front right
  28475. * Add to fix multiple points
  28476. */
  28477. fixedPoints?: number;
  28478. /**
  28479. * The collision margin around a soft object
  28480. */
  28481. margin?: number;
  28482. /**
  28483. * The collision margin around a soft object
  28484. */
  28485. damping?: number;
  28486. /**
  28487. * The path for a rope based on an extrusion
  28488. */
  28489. path?: any;
  28490. /**
  28491. * The shape of an extrusion used for a rope based on an extrusion
  28492. */
  28493. shape?: any;
  28494. }
  28495. /**
  28496. * Interface for a physics-enabled object
  28497. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  28498. */
  28499. export interface IPhysicsEnabledObject {
  28500. /**
  28501. * The position of the physics-enabled object
  28502. */
  28503. position: Vector3;
  28504. /**
  28505. * The rotation of the physics-enabled object
  28506. */
  28507. rotationQuaternion: Nullable<Quaternion>;
  28508. /**
  28509. * The scale of the physics-enabled object
  28510. */
  28511. scaling: Vector3;
  28512. /**
  28513. * The rotation of the physics-enabled object
  28514. */
  28515. rotation?: Vector3;
  28516. /**
  28517. * The parent of the physics-enabled object
  28518. */
  28519. parent?: any;
  28520. /**
  28521. * The bounding info of the physics-enabled object
  28522. * @returns The bounding info of the physics-enabled object
  28523. */
  28524. getBoundingInfo(): BoundingInfo;
  28525. /**
  28526. * Computes the world matrix
  28527. * @param force Specifies if the world matrix should be computed by force
  28528. * @returns A world matrix
  28529. */
  28530. computeWorldMatrix(force: boolean): Matrix;
  28531. /**
  28532. * Gets the world matrix
  28533. * @returns A world matrix
  28534. */
  28535. getWorldMatrix?(): Matrix;
  28536. /**
  28537. * Gets the child meshes
  28538. * @param directDescendantsOnly Specifies if only direct-descendants should be obtained
  28539. * @returns An array of abstract meshes
  28540. */
  28541. getChildMeshes?(directDescendantsOnly?: boolean): Array<AbstractMesh>;
  28542. /**
  28543. * Gets the vertex data
  28544. * @param kind The type of vertex data
  28545. * @returns A nullable array of numbers, or a float32 array
  28546. */
  28547. getVerticesData(kind: string): Nullable<Array<number> | Float32Array>;
  28548. /**
  28549. * Gets the indices from the mesh
  28550. * @returns A nullable array of index arrays
  28551. */
  28552. getIndices?(): Nullable<IndicesArray>;
  28553. /**
  28554. * Gets the scene from the mesh
  28555. * @returns the indices array or null
  28556. */
  28557. getScene?(): Scene;
  28558. /**
  28559. * Gets the absolute position from the mesh
  28560. * @returns the absolute position
  28561. */
  28562. getAbsolutePosition(): Vector3;
  28563. /**
  28564. * Gets the absolute pivot point from the mesh
  28565. * @returns the absolute pivot point
  28566. */
  28567. getAbsolutePivotPoint(): Vector3;
  28568. /**
  28569. * Rotates the mesh
  28570. * @param axis The axis of rotation
  28571. * @param amount The amount of rotation
  28572. * @param space The space of the rotation
  28573. * @returns The rotation transform node
  28574. */
  28575. rotate(axis: Vector3, amount: number, space?: Space): TransformNode;
  28576. /**
  28577. * Translates the mesh
  28578. * @param axis The axis of translation
  28579. * @param distance The distance of translation
  28580. * @param space The space of the translation
  28581. * @returns The transform node
  28582. */
  28583. translate(axis: Vector3, distance: number, space?: Space): TransformNode;
  28584. /**
  28585. * Sets the absolute position of the mesh
  28586. * @param absolutePosition The absolute position of the mesh
  28587. * @returns The transform node
  28588. */
  28589. setAbsolutePosition(absolutePosition: Vector3): TransformNode;
  28590. /**
  28591. * Gets the class name of the mesh
  28592. * @returns The class name
  28593. */
  28594. getClassName(): string;
  28595. }
  28596. /**
  28597. * Represents a physics imposter
  28598. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  28599. */
  28600. export class PhysicsImpostor {
  28601. /**
  28602. * The physics-enabled object used as the physics imposter
  28603. */
  28604. object: IPhysicsEnabledObject;
  28605. /**
  28606. * The type of the physics imposter
  28607. */
  28608. type: number;
  28609. private _options;
  28610. private _scene?;
  28611. /**
  28612. * The default object size of the imposter
  28613. */
  28614. static DEFAULT_OBJECT_SIZE: Vector3;
  28615. /**
  28616. * The identity quaternion of the imposter
  28617. */
  28618. static IDENTITY_QUATERNION: Quaternion;
  28619. /** @hidden */
  28620. _pluginData: any;
  28621. private _physicsEngine;
  28622. private _physicsBody;
  28623. private _bodyUpdateRequired;
  28624. private _onBeforePhysicsStepCallbacks;
  28625. private _onAfterPhysicsStepCallbacks;
  28626. /** @hidden */
  28627. _onPhysicsCollideCallbacks: Array<{
  28628. callback: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor) => void;
  28629. otherImpostors: Array<PhysicsImpostor>;
  28630. }>;
  28631. private _deltaPosition;
  28632. private _deltaRotation;
  28633. private _deltaRotationConjugated;
  28634. /** @hidden */
  28635. _isFromLine: boolean;
  28636. private _parent;
  28637. private _isDisposed;
  28638. private static _tmpVecs;
  28639. private static _tmpQuat;
  28640. /**
  28641. * Specifies if the physics imposter is disposed
  28642. */
  28643. get isDisposed(): boolean;
  28644. /**
  28645. * Gets the mass of the physics imposter
  28646. */
  28647. get mass(): number;
  28648. set mass(value: number);
  28649. /**
  28650. * Gets the coefficient of friction
  28651. */
  28652. get friction(): number;
  28653. /**
  28654. * Sets the coefficient of friction
  28655. */
  28656. set friction(value: number);
  28657. /**
  28658. * Gets the coefficient of restitution
  28659. */
  28660. get restitution(): number;
  28661. /**
  28662. * Sets the coefficient of restitution
  28663. */
  28664. set restitution(value: number);
  28665. /**
  28666. * Gets the pressure of a soft body; only supported by the AmmoJSPlugin
  28667. */
  28668. get pressure(): number;
  28669. /**
  28670. * Sets the pressure of a soft body; only supported by the AmmoJSPlugin
  28671. */
  28672. set pressure(value: number);
  28673. /**
  28674. * Gets the stiffness of a soft body; only supported by the AmmoJSPlugin
  28675. */
  28676. get stiffness(): number;
  28677. /**
  28678. * Sets the stiffness of a soft body; only supported by the AmmoJSPlugin
  28679. */
  28680. set stiffness(value: number);
  28681. /**
  28682. * Gets the velocityIterations of a soft body; only supported by the AmmoJSPlugin
  28683. */
  28684. get velocityIterations(): number;
  28685. /**
  28686. * Sets the velocityIterations of a soft body; only supported by the AmmoJSPlugin
  28687. */
  28688. set velocityIterations(value: number);
  28689. /**
  28690. * Gets the positionIterations of a soft body; only supported by the AmmoJSPlugin
  28691. */
  28692. get positionIterations(): number;
  28693. /**
  28694. * Sets the positionIterations of a soft body; only supported by the AmmoJSPlugin
  28695. */
  28696. set positionIterations(value: number);
  28697. /**
  28698. * The unique id of the physics imposter
  28699. * set by the physics engine when adding this impostor to the array
  28700. */
  28701. uniqueId: number;
  28702. /**
  28703. * @hidden
  28704. */
  28705. soft: boolean;
  28706. /**
  28707. * @hidden
  28708. */
  28709. segments: number;
  28710. private _joints;
  28711. /**
  28712. * Initializes the physics imposter
  28713. * @param object The physics-enabled object used as the physics imposter
  28714. * @param type The type of the physics imposter
  28715. * @param _options The options for the physics imposter
  28716. * @param _scene The Babylon scene
  28717. */
  28718. constructor(
  28719. /**
  28720. * The physics-enabled object used as the physics imposter
  28721. */
  28722. object: IPhysicsEnabledObject,
  28723. /**
  28724. * The type of the physics imposter
  28725. */
  28726. type: number, _options?: PhysicsImpostorParameters, _scene?: Scene | undefined);
  28727. /**
  28728. * This function will completly initialize this impostor.
  28729. * It will create a new body - but only if this mesh has no parent.
  28730. * If it has, this impostor will not be used other than to define the impostor
  28731. * of the child mesh.
  28732. * @hidden
  28733. */
  28734. _init(): void;
  28735. private _getPhysicsParent;
  28736. /**
  28737. * Should a new body be generated.
  28738. * @returns boolean specifying if body initialization is required
  28739. */
  28740. isBodyInitRequired(): boolean;
  28741. /**
  28742. * Sets the updated scaling
  28743. * @param updated Specifies if the scaling is updated
  28744. */
  28745. setScalingUpdated(): void;
  28746. /**
  28747. * Force a regeneration of this or the parent's impostor's body.
  28748. * Use under cautious - This will remove all joints already implemented.
  28749. */
  28750. forceUpdate(): void;
  28751. /**
  28752. * Gets the body that holds this impostor. Either its own, or its parent.
  28753. */
  28754. get physicsBody(): any;
  28755. /**
  28756. * Get the parent of the physics imposter
  28757. * @returns Physics imposter or null
  28758. */
  28759. get parent(): Nullable<PhysicsImpostor>;
  28760. /**
  28761. * Sets the parent of the physics imposter
  28762. */
  28763. set parent(value: Nullable<PhysicsImpostor>);
  28764. /**
  28765. * Set the physics body. Used mainly by the physics engine/plugin
  28766. */
  28767. set physicsBody(physicsBody: any);
  28768. /**
  28769. * Resets the update flags
  28770. */
  28771. resetUpdateFlags(): void;
  28772. /**
  28773. * Gets the object extend size
  28774. * @returns the object extend size
  28775. */
  28776. getObjectExtendSize(): Vector3;
  28777. /**
  28778. * Gets the object center
  28779. * @returns The object center
  28780. */
  28781. getObjectCenter(): Vector3;
  28782. /**
  28783. * Get a specific parameter from the options parameters
  28784. * @param paramName The object parameter name
  28785. * @returns The object parameter
  28786. */
  28787. getParam(paramName: string): any;
  28788. /**
  28789. * Sets a specific parameter in the options given to the physics plugin
  28790. * @param paramName The parameter name
  28791. * @param value The value of the parameter
  28792. */
  28793. setParam(paramName: string, value: number): void;
  28794. /**
  28795. * Specifically change the body's mass option. Won't recreate the physics body object
  28796. * @param mass The mass of the physics imposter
  28797. */
  28798. setMass(mass: number): void;
  28799. /**
  28800. * Gets the linear velocity
  28801. * @returns linear velocity or null
  28802. */
  28803. getLinearVelocity(): Nullable<Vector3>;
  28804. /**
  28805. * Sets the linear velocity
  28806. * @param velocity linear velocity or null
  28807. */
  28808. setLinearVelocity(velocity: Nullable<Vector3>): void;
  28809. /**
  28810. * Gets the angular velocity
  28811. * @returns angular velocity or null
  28812. */
  28813. getAngularVelocity(): Nullable<Vector3>;
  28814. /**
  28815. * Sets the angular velocity
  28816. * @param velocity The velocity or null
  28817. */
  28818. setAngularVelocity(velocity: Nullable<Vector3>): void;
  28819. /**
  28820. * Execute a function with the physics plugin native code
  28821. * Provide a function the will have two variables - the world object and the physics body object
  28822. * @param func The function to execute with the physics plugin native code
  28823. */
  28824. executeNativeFunction(func: (world: any, physicsBody: any) => void): void;
  28825. /**
  28826. * Register a function that will be executed before the physics world is stepping forward
  28827. * @param func The function to execute before the physics world is stepped forward
  28828. */
  28829. registerBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  28830. /**
  28831. * Unregister a function that will be executed before the physics world is stepping forward
  28832. * @param func The function to execute before the physics world is stepped forward
  28833. */
  28834. unregisterBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  28835. /**
  28836. * Register a function that will be executed after the physics step
  28837. * @param func The function to execute after physics step
  28838. */
  28839. registerAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  28840. /**
  28841. * Unregisters a function that will be executed after the physics step
  28842. * @param func The function to execute after physics step
  28843. */
  28844. unregisterAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  28845. /**
  28846. * register a function that will be executed when this impostor collides against a different body
  28847. * @param collideAgainst Physics imposter, or array of physics imposters to collide against
  28848. * @param func Callback that is executed on collision
  28849. */
  28850. registerOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor) => void): void;
  28851. /**
  28852. * Unregisters the physics imposter on contact
  28853. * @param collideAgainst The physics object to collide against
  28854. * @param func Callback to execute on collision
  28855. */
  28856. unregisterOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor | Array<PhysicsImpostor>) => void): void;
  28857. private _tmpQuat;
  28858. private _tmpQuat2;
  28859. /**
  28860. * Get the parent rotation
  28861. * @returns The parent rotation
  28862. */
  28863. getParentsRotation(): Quaternion;
  28864. /**
  28865. * this function is executed by the physics engine.
  28866. */
  28867. beforeStep: () => void;
  28868. /**
  28869. * this function is executed by the physics engine
  28870. */
  28871. afterStep: () => void;
  28872. /**
  28873. * Legacy collision detection event support
  28874. */
  28875. onCollideEvent: Nullable<(collider: PhysicsImpostor, collidedWith: PhysicsImpostor) => void>;
  28876. /**
  28877. * event and body object due to cannon's event-based architecture.
  28878. */
  28879. onCollide: (e: {
  28880. body: any;
  28881. }) => void;
  28882. /**
  28883. * Apply a force
  28884. * @param force The force to apply
  28885. * @param contactPoint The contact point for the force
  28886. * @returns The physics imposter
  28887. */
  28888. applyForce(force: Vector3, contactPoint: Vector3): PhysicsImpostor;
  28889. /**
  28890. * Apply an impulse
  28891. * @param force The impulse force
  28892. * @param contactPoint The contact point for the impulse force
  28893. * @returns The physics imposter
  28894. */
  28895. applyImpulse(force: Vector3, contactPoint: Vector3): PhysicsImpostor;
  28896. /**
  28897. * A help function to create a joint
  28898. * @param otherImpostor A physics imposter used to create a joint
  28899. * @param jointType The type of joint
  28900. * @param jointData The data for the joint
  28901. * @returns The physics imposter
  28902. */
  28903. createJoint(otherImpostor: PhysicsImpostor, jointType: number, jointData: PhysicsJointData): PhysicsImpostor;
  28904. /**
  28905. * Add a joint to this impostor with a different impostor
  28906. * @param otherImpostor A physics imposter used to add a joint
  28907. * @param joint The joint to add
  28908. * @returns The physics imposter
  28909. */
  28910. addJoint(otherImpostor: PhysicsImpostor, joint: PhysicsJoint): PhysicsImpostor;
  28911. /**
  28912. * Add an anchor to a cloth impostor
  28913. * @param otherImpostor rigid impostor to anchor to
  28914. * @param width ratio across width from 0 to 1
  28915. * @param height ratio up height from 0 to 1
  28916. * @param influence the elasticity between cloth impostor and anchor from 0, very stretchy to 1, little strech
  28917. * @param noCollisionBetweenLinkedBodies when true collisions between cloth impostor and anchor are ignored; default false
  28918. * @returns impostor the soft imposter
  28919. */
  28920. addAnchor(otherImpostor: PhysicsImpostor, width: number, height: number, influence: number, noCollisionBetweenLinkedBodies: boolean): PhysicsImpostor;
  28921. /**
  28922. * Add a hook to a rope impostor
  28923. * @param otherImpostor rigid impostor to anchor to
  28924. * @param length ratio across rope from 0 to 1
  28925. * @param influence the elasticity between rope impostor and anchor from 0, very stretchy to 1, little strech
  28926. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  28927. * @returns impostor the rope imposter
  28928. */
  28929. addHook(otherImpostor: PhysicsImpostor, length: number, influence: number, noCollisionBetweenLinkedBodies: boolean): PhysicsImpostor;
  28930. /**
  28931. * Will keep this body still, in a sleep mode.
  28932. * @returns the physics imposter
  28933. */
  28934. sleep(): PhysicsImpostor;
  28935. /**
  28936. * Wake the body up.
  28937. * @returns The physics imposter
  28938. */
  28939. wakeUp(): PhysicsImpostor;
  28940. /**
  28941. * Clones the physics imposter
  28942. * @param newObject The physics imposter clones to this physics-enabled object
  28943. * @returns A nullable physics imposter
  28944. */
  28945. clone(newObject: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  28946. /**
  28947. * Disposes the physics imposter
  28948. */
  28949. dispose(): void;
  28950. /**
  28951. * Sets the delta position
  28952. * @param position The delta position amount
  28953. */
  28954. setDeltaPosition(position: Vector3): void;
  28955. /**
  28956. * Sets the delta rotation
  28957. * @param rotation The delta rotation amount
  28958. */
  28959. setDeltaRotation(rotation: Quaternion): void;
  28960. /**
  28961. * Gets the box size of the physics imposter and stores the result in the input parameter
  28962. * @param result Stores the box size
  28963. * @returns The physics imposter
  28964. */
  28965. getBoxSizeToRef(result: Vector3): PhysicsImpostor;
  28966. /**
  28967. * Gets the radius of the physics imposter
  28968. * @returns Radius of the physics imposter
  28969. */
  28970. getRadius(): number;
  28971. /**
  28972. * Sync a bone with this impostor
  28973. * @param bone The bone to sync to the impostor.
  28974. * @param boneMesh The mesh that the bone is influencing.
  28975. * @param jointPivot The pivot of the joint / bone in local space.
  28976. * @param distToJoint Optional distance from the impostor to the joint.
  28977. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  28978. */
  28979. syncBoneWithImpostor(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion): void;
  28980. /**
  28981. * Sync impostor to a bone
  28982. * @param bone The bone that the impostor will be synced to.
  28983. * @param boneMesh The mesh that the bone is influencing.
  28984. * @param jointPivot The pivot of the joint / bone in local space.
  28985. * @param distToJoint Optional distance from the impostor to the joint.
  28986. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  28987. * @param boneAxis Optional vector3 axis the bone is aligned with
  28988. */
  28989. syncImpostorWithBone(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion, boneAxis?: Vector3): void;
  28990. /**
  28991. * No-Imposter type
  28992. */
  28993. static NoImpostor: number;
  28994. /**
  28995. * Sphere-Imposter type
  28996. */
  28997. static SphereImpostor: number;
  28998. /**
  28999. * Box-Imposter type
  29000. */
  29001. static BoxImpostor: number;
  29002. /**
  29003. * Plane-Imposter type
  29004. */
  29005. static PlaneImpostor: number;
  29006. /**
  29007. * Mesh-imposter type
  29008. */
  29009. static MeshImpostor: number;
  29010. /**
  29011. * Capsule-Impostor type (Ammo.js plugin only)
  29012. */
  29013. static CapsuleImpostor: number;
  29014. /**
  29015. * Cylinder-Imposter type
  29016. */
  29017. static CylinderImpostor: number;
  29018. /**
  29019. * Particle-Imposter type
  29020. */
  29021. static ParticleImpostor: number;
  29022. /**
  29023. * Heightmap-Imposter type
  29024. */
  29025. static HeightmapImpostor: number;
  29026. /**
  29027. * ConvexHull-Impostor type (Ammo.js plugin only)
  29028. */
  29029. static ConvexHullImpostor: number;
  29030. /**
  29031. * Custom-Imposter type (Ammo.js plugin only)
  29032. */
  29033. static CustomImpostor: number;
  29034. /**
  29035. * Rope-Imposter type
  29036. */
  29037. static RopeImpostor: number;
  29038. /**
  29039. * Cloth-Imposter type
  29040. */
  29041. static ClothImpostor: number;
  29042. /**
  29043. * Softbody-Imposter type
  29044. */
  29045. static SoftbodyImpostor: number;
  29046. }
  29047. }
  29048. declare module "babylonjs/Meshes/mesh" {
  29049. import { Observable } from "babylonjs/Misc/observable";
  29050. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  29051. import { Nullable, FloatArray, IndicesArray } from "babylonjs/types";
  29052. import { Camera } from "babylonjs/Cameras/camera";
  29053. import { Scene } from "babylonjs/scene";
  29054. import { Matrix, Vector3, Vector2, Vector4 } from "babylonjs/Maths/math.vector";
  29055. import { Color4 } from "babylonjs/Maths/math.color";
  29056. import { Engine } from "babylonjs/Engines/engine";
  29057. import { Node } from "babylonjs/node";
  29058. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  29059. import { IGetSetVerticesData } from "babylonjs/Meshes/mesh.vertexData";
  29060. import { Buffer } from "babylonjs/Meshes/buffer";
  29061. import { Geometry } from "babylonjs/Meshes/geometry";
  29062. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  29063. import { SubMesh } from "babylonjs/Meshes/subMesh";
  29064. import { BoundingSphere } from "babylonjs/Culling/boundingSphere";
  29065. import { Effect } from "babylonjs/Materials/effect";
  29066. import { Material } from "babylonjs/Materials/material";
  29067. import { Skeleton } from "babylonjs/Bones/skeleton";
  29068. import { MorphTargetManager } from "babylonjs/Morph/morphTargetManager";
  29069. import { MeshLODLevel } from "babylonjs/Meshes/meshLODLevel";
  29070. import { Path3D } from "babylonjs/Maths/math.path";
  29071. import { Plane } from "babylonjs/Maths/math.plane";
  29072. import { TransformNode } from "babylonjs/Meshes/transformNode";
  29073. import { LinesMesh } from "babylonjs/Meshes/linesMesh";
  29074. import { InstancedMesh } from "babylonjs/Meshes/instancedMesh";
  29075. import { GroundMesh } from "babylonjs/Meshes/groundMesh";
  29076. import { IPhysicsEnabledObject } from "babylonjs/Physics/physicsImpostor";
  29077. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  29078. /**
  29079. * @hidden
  29080. **/
  29081. export class _CreationDataStorage {
  29082. closePath?: boolean;
  29083. closeArray?: boolean;
  29084. idx: number[];
  29085. dashSize: number;
  29086. gapSize: number;
  29087. path3D: Path3D;
  29088. pathArray: Vector3[][];
  29089. arc: number;
  29090. radius: number;
  29091. cap: number;
  29092. tessellation: number;
  29093. }
  29094. /**
  29095. * @hidden
  29096. **/
  29097. class _InstanceDataStorage {
  29098. visibleInstances: any;
  29099. batchCache: _InstancesBatch;
  29100. instancesBufferSize: number;
  29101. instancesBuffer: Nullable<Buffer>;
  29102. instancesData: Float32Array;
  29103. overridenInstanceCount: number;
  29104. isFrozen: boolean;
  29105. previousBatch: Nullable<_InstancesBatch>;
  29106. hardwareInstancedRendering: boolean;
  29107. sideOrientation: number;
  29108. manualUpdate: boolean;
  29109. }
  29110. /**
  29111. * @hidden
  29112. **/
  29113. export class _InstancesBatch {
  29114. mustReturn: boolean;
  29115. visibleInstances: Nullable<import("babylonjs/Meshes/instancedMesh").InstancedMesh[]>[];
  29116. renderSelf: boolean[];
  29117. hardwareInstancedRendering: boolean[];
  29118. }
  29119. /**
  29120. * @hidden
  29121. **/
  29122. class _ThinInstanceDataStorage {
  29123. instancesCount: number;
  29124. matrixBuffer: Nullable<Buffer>;
  29125. matrixBufferSize: number;
  29126. matrixData: Nullable<Float32Array>;
  29127. boundingVectors: Array<Vector3>;
  29128. worldMatrices: Nullable<Matrix[]>;
  29129. }
  29130. /**
  29131. * Class used to represent renderable models
  29132. */
  29133. export class Mesh extends AbstractMesh implements IGetSetVerticesData {
  29134. /**
  29135. * Mesh side orientation : usually the external or front surface
  29136. */
  29137. static readonly FRONTSIDE: number;
  29138. /**
  29139. * Mesh side orientation : usually the internal or back surface
  29140. */
  29141. static readonly BACKSIDE: number;
  29142. /**
  29143. * Mesh side orientation : both internal and external or front and back surfaces
  29144. */
  29145. static readonly DOUBLESIDE: number;
  29146. /**
  29147. * Mesh side orientation : by default, `FRONTSIDE`
  29148. */
  29149. static readonly DEFAULTSIDE: number;
  29150. /**
  29151. * Mesh cap setting : no cap
  29152. */
  29153. static readonly NO_CAP: number;
  29154. /**
  29155. * Mesh cap setting : one cap at the beginning of the mesh
  29156. */
  29157. static readonly CAP_START: number;
  29158. /**
  29159. * Mesh cap setting : one cap at the end of the mesh
  29160. */
  29161. static readonly CAP_END: number;
  29162. /**
  29163. * Mesh cap setting : two caps, one at the beginning and one at the end of the mesh
  29164. */
  29165. static readonly CAP_ALL: number;
  29166. /**
  29167. * Mesh pattern setting : no flip or rotate
  29168. */
  29169. static readonly NO_FLIP: number;
  29170. /**
  29171. * Mesh pattern setting : flip (reflect in y axis) alternate tiles on each row or column
  29172. */
  29173. static readonly FLIP_TILE: number;
  29174. /**
  29175. * Mesh pattern setting : rotate (180degs) alternate tiles on each row or column
  29176. */
  29177. static readonly ROTATE_TILE: number;
  29178. /**
  29179. * Mesh pattern setting : flip (reflect in y axis) all tiles on alternate rows
  29180. */
  29181. static readonly FLIP_ROW: number;
  29182. /**
  29183. * Mesh pattern setting : rotate (180degs) all tiles on alternate rows
  29184. */
  29185. static readonly ROTATE_ROW: number;
  29186. /**
  29187. * Mesh pattern setting : flip and rotate alternate tiles on each row or column
  29188. */
  29189. static readonly FLIP_N_ROTATE_TILE: number;
  29190. /**
  29191. * Mesh pattern setting : rotate pattern and rotate
  29192. */
  29193. static readonly FLIP_N_ROTATE_ROW: number;
  29194. /**
  29195. * Mesh tile positioning : part tiles same on left/right or top/bottom
  29196. */
  29197. static readonly CENTER: number;
  29198. /**
  29199. * Mesh tile positioning : part tiles on left
  29200. */
  29201. static readonly LEFT: number;
  29202. /**
  29203. * Mesh tile positioning : part tiles on right
  29204. */
  29205. static readonly RIGHT: number;
  29206. /**
  29207. * Mesh tile positioning : part tiles on top
  29208. */
  29209. static readonly TOP: number;
  29210. /**
  29211. * Mesh tile positioning : part tiles on bottom
  29212. */
  29213. static readonly BOTTOM: number;
  29214. /**
  29215. * Gets the default side orientation.
  29216. * @param orientation the orientation to value to attempt to get
  29217. * @returns the default orientation
  29218. * @hidden
  29219. */
  29220. static _GetDefaultSideOrientation(orientation?: number): number;
  29221. private _internalMeshDataInfo;
  29222. get computeBonesUsingShaders(): boolean;
  29223. set computeBonesUsingShaders(value: boolean);
  29224. /**
  29225. * An event triggered before rendering the mesh
  29226. */
  29227. get onBeforeRenderObservable(): Observable<Mesh>;
  29228. /**
  29229. * An event triggered before binding the mesh
  29230. */
  29231. get onBeforeBindObservable(): Observable<Mesh>;
  29232. /**
  29233. * An event triggered after rendering the mesh
  29234. */
  29235. get onAfterRenderObservable(): Observable<Mesh>;
  29236. /**
  29237. * An event triggered before drawing the mesh
  29238. */
  29239. get onBeforeDrawObservable(): Observable<Mesh>;
  29240. private _onBeforeDrawObserver;
  29241. /**
  29242. * Sets a callback to call before drawing the mesh. It is recommended to use onBeforeDrawObservable instead
  29243. */
  29244. set onBeforeDraw(callback: () => void);
  29245. get hasInstances(): boolean;
  29246. get hasThinInstances(): boolean;
  29247. /**
  29248. * Gets the delay loading state of the mesh (when delay loading is turned on)
  29249. * @see https://doc.babylonjs.com/how_to/using_the_incremental_loading_system
  29250. */
  29251. delayLoadState: number;
  29252. /**
  29253. * Gets the list of instances created from this mesh
  29254. * it is not supposed to be modified manually.
  29255. * Note also that the order of the InstancedMesh wihin the array is not significant and might change.
  29256. * @see https://doc.babylonjs.com/how_to/how_to_use_instances
  29257. */
  29258. instances: import("babylonjs/Meshes/instancedMesh").InstancedMesh[];
  29259. /**
  29260. * Gets the file containing delay loading data for this mesh
  29261. */
  29262. delayLoadingFile: string;
  29263. /** @hidden */
  29264. _binaryInfo: any;
  29265. /**
  29266. * User defined function used to change how LOD level selection is done
  29267. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  29268. */
  29269. onLODLevelSelection: (distance: number, mesh: Mesh, selectedLevel: Nullable<Mesh>) => void;
  29270. /**
  29271. * Gets or sets the morph target manager
  29272. * @see https://doc.babylonjs.com/how_to/how_to_use_morphtargets
  29273. */
  29274. get morphTargetManager(): Nullable<MorphTargetManager>;
  29275. set morphTargetManager(value: Nullable<MorphTargetManager>);
  29276. /** @hidden */
  29277. _creationDataStorage: Nullable<_CreationDataStorage>;
  29278. /** @hidden */
  29279. _geometry: Nullable<Geometry>;
  29280. /** @hidden */
  29281. _delayInfo: Array<string>;
  29282. /** @hidden */
  29283. _delayLoadingFunction: (any: any, mesh: Mesh) => void;
  29284. /** @hidden */
  29285. _instanceDataStorage: _InstanceDataStorage;
  29286. /** @hidden */
  29287. _thinInstanceDataStorage: _ThinInstanceDataStorage;
  29288. private _effectiveMaterial;
  29289. /** @hidden */
  29290. _shouldGenerateFlatShading: boolean;
  29291. /** @hidden */
  29292. _originalBuilderSideOrientation: number;
  29293. /**
  29294. * Use this property to change the original side orientation defined at construction time
  29295. */
  29296. overrideMaterialSideOrientation: Nullable<number>;
  29297. /**
  29298. * Gets the source mesh (the one used to clone this one from)
  29299. */
  29300. get source(): Nullable<Mesh>;
  29301. /**
  29302. * Gets the list of clones of this mesh
  29303. * The scene must have been constructed with useClonedMeshMap=true for this to work!
  29304. * Note that useClonedMeshMap=true is the default setting
  29305. */
  29306. get cloneMeshMap(): Nullable<{
  29307. [id: string]: Mesh | undefined;
  29308. }>;
  29309. /**
  29310. * Gets or sets a boolean indicating that this mesh does not use index buffer
  29311. */
  29312. get isUnIndexed(): boolean;
  29313. set isUnIndexed(value: boolean);
  29314. /** Gets the array buffer used to store the instanced buffer used for instances' world matrices */
  29315. get worldMatrixInstancedBuffer(): Float32Array;
  29316. /** Gets or sets a boolean indicating that the update of the instance buffer of the world matrices is manual */
  29317. get manualUpdateOfWorldMatrixInstancedBuffer(): boolean;
  29318. set manualUpdateOfWorldMatrixInstancedBuffer(value: boolean);
  29319. /**
  29320. * @constructor
  29321. * @param name The value used by scene.getMeshByName() to do a lookup.
  29322. * @param scene The scene to add this mesh to.
  29323. * @param parent The parent of this mesh, if it has one
  29324. * @param source An optional Mesh from which geometry is shared, cloned.
  29325. * @param doNotCloneChildren When cloning, skip cloning child meshes of source, default False.
  29326. * When false, achieved by calling a clone(), also passing False.
  29327. * This will make creation of children, recursive.
  29328. * @param clonePhysicsImpostor When cloning, include cloning mesh physics impostor, default True.
  29329. */
  29330. constructor(name: string, scene?: Nullable<Scene>, parent?: Nullable<Node>, source?: Nullable<Mesh>, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean);
  29331. instantiateHierarchy(newParent?: Nullable<TransformNode>, options?: {
  29332. doNotInstantiate: boolean;
  29333. }, onNewNodeCreated?: (source: TransformNode, clone: TransformNode) => void): Nullable<TransformNode>;
  29334. /**
  29335. * Gets the class name
  29336. * @returns the string "Mesh".
  29337. */
  29338. getClassName(): string;
  29339. /** @hidden */
  29340. get _isMesh(): boolean;
  29341. /**
  29342. * Returns a description of this mesh
  29343. * @param fullDetails define if full details about this mesh must be used
  29344. * @returns a descriptive string representing this mesh
  29345. */
  29346. toString(fullDetails?: boolean): string;
  29347. /** @hidden */
  29348. _unBindEffect(): void;
  29349. /**
  29350. * Gets a boolean indicating if this mesh has LOD
  29351. */
  29352. get hasLODLevels(): boolean;
  29353. /**
  29354. * Gets the list of MeshLODLevel associated with the current mesh
  29355. * @returns an array of MeshLODLevel
  29356. */
  29357. getLODLevels(): MeshLODLevel[];
  29358. private _sortLODLevels;
  29359. /**
  29360. * Add a mesh as LOD level triggered at the given distance.
  29361. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  29362. * @param distance The distance from the center of the object to show this level
  29363. * @param mesh The mesh to be added as LOD level (can be null)
  29364. * @return This mesh (for chaining)
  29365. */
  29366. addLODLevel(distance: number, mesh: Nullable<Mesh>): Mesh;
  29367. /**
  29368. * Returns the LOD level mesh at the passed distance or null if not found.
  29369. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  29370. * @param distance The distance from the center of the object to show this level
  29371. * @returns a Mesh or `null`
  29372. */
  29373. getLODLevelAtDistance(distance: number): Nullable<Mesh>;
  29374. /**
  29375. * Remove a mesh from the LOD array
  29376. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  29377. * @param mesh defines the mesh to be removed
  29378. * @return This mesh (for chaining)
  29379. */
  29380. removeLODLevel(mesh: Mesh): Mesh;
  29381. /**
  29382. * Returns the registered LOD mesh distant from the parameter `camera` position if any, else returns the current mesh.
  29383. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  29384. * @param camera defines the camera to use to compute distance
  29385. * @param boundingSphere defines a custom bounding sphere to use instead of the one from this mesh
  29386. * @return This mesh (for chaining)
  29387. */
  29388. getLOD(camera: Camera, boundingSphere?: BoundingSphere): Nullable<AbstractMesh>;
  29389. /**
  29390. * Gets the mesh internal Geometry object
  29391. */
  29392. get geometry(): Nullable<Geometry>;
  29393. /**
  29394. * Returns the total number of vertices within the mesh geometry or zero if the mesh has no geometry.
  29395. * @returns the total number of vertices
  29396. */
  29397. getTotalVertices(): number;
  29398. /**
  29399. * Returns the content of an associated vertex buffer
  29400. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  29401. * - VertexBuffer.PositionKind
  29402. * - VertexBuffer.UVKind
  29403. * - VertexBuffer.UV2Kind
  29404. * - VertexBuffer.UV3Kind
  29405. * - VertexBuffer.UV4Kind
  29406. * - VertexBuffer.UV5Kind
  29407. * - VertexBuffer.UV6Kind
  29408. * - VertexBuffer.ColorKind
  29409. * - VertexBuffer.MatricesIndicesKind
  29410. * - VertexBuffer.MatricesIndicesExtraKind
  29411. * - VertexBuffer.MatricesWeightsKind
  29412. * - VertexBuffer.MatricesWeightsExtraKind
  29413. * @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
  29414. * @param forceCopy defines a boolean forcing the copy of the buffer no matter what the value of copyWhenShared is
  29415. * @returns a FloatArray or null if the mesh has no geometry or no vertex buffer for this kind.
  29416. */
  29417. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  29418. /**
  29419. * Returns the mesh VertexBuffer object from the requested `kind`
  29420. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  29421. * - VertexBuffer.PositionKind
  29422. * - VertexBuffer.NormalKind
  29423. * - VertexBuffer.UVKind
  29424. * - VertexBuffer.UV2Kind
  29425. * - VertexBuffer.UV3Kind
  29426. * - VertexBuffer.UV4Kind
  29427. * - VertexBuffer.UV5Kind
  29428. * - VertexBuffer.UV6Kind
  29429. * - VertexBuffer.ColorKind
  29430. * - VertexBuffer.MatricesIndicesKind
  29431. * - VertexBuffer.MatricesIndicesExtraKind
  29432. * - VertexBuffer.MatricesWeightsKind
  29433. * - VertexBuffer.MatricesWeightsExtraKind
  29434. * @returns a FloatArray or null if the mesh has no vertex buffer for this kind.
  29435. */
  29436. getVertexBuffer(kind: string): Nullable<VertexBuffer>;
  29437. /**
  29438. * Tests if a specific vertex buffer is associated with this mesh
  29439. * @param kind defines which buffer to check (positions, indices, normals, etc). Possible `kind` values :
  29440. * - VertexBuffer.PositionKind
  29441. * - VertexBuffer.NormalKind
  29442. * - VertexBuffer.UVKind
  29443. * - VertexBuffer.UV2Kind
  29444. * - VertexBuffer.UV3Kind
  29445. * - VertexBuffer.UV4Kind
  29446. * - VertexBuffer.UV5Kind
  29447. * - VertexBuffer.UV6Kind
  29448. * - VertexBuffer.ColorKind
  29449. * - VertexBuffer.MatricesIndicesKind
  29450. * - VertexBuffer.MatricesIndicesExtraKind
  29451. * - VertexBuffer.MatricesWeightsKind
  29452. * - VertexBuffer.MatricesWeightsExtraKind
  29453. * @returns a boolean
  29454. */
  29455. isVerticesDataPresent(kind: string): boolean;
  29456. /**
  29457. * Returns a boolean defining if the vertex data for the requested `kind` is updatable.
  29458. * @param kind defines which buffer to check (positions, indices, normals, etc). Possible `kind` values :
  29459. * - VertexBuffer.PositionKind
  29460. * - VertexBuffer.UVKind
  29461. * - VertexBuffer.UV2Kind
  29462. * - VertexBuffer.UV3Kind
  29463. * - VertexBuffer.UV4Kind
  29464. * - VertexBuffer.UV5Kind
  29465. * - VertexBuffer.UV6Kind
  29466. * - VertexBuffer.ColorKind
  29467. * - VertexBuffer.MatricesIndicesKind
  29468. * - VertexBuffer.MatricesIndicesExtraKind
  29469. * - VertexBuffer.MatricesWeightsKind
  29470. * - VertexBuffer.MatricesWeightsExtraKind
  29471. * @returns a boolean
  29472. */
  29473. isVertexBufferUpdatable(kind: string): boolean;
  29474. /**
  29475. * Returns a string which contains the list of existing `kinds` of Vertex Data associated with this mesh.
  29476. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  29477. * - VertexBuffer.PositionKind
  29478. * - VertexBuffer.NormalKind
  29479. * - VertexBuffer.UVKind
  29480. * - VertexBuffer.UV2Kind
  29481. * - VertexBuffer.UV3Kind
  29482. * - VertexBuffer.UV4Kind
  29483. * - VertexBuffer.UV5Kind
  29484. * - VertexBuffer.UV6Kind
  29485. * - VertexBuffer.ColorKind
  29486. * - VertexBuffer.MatricesIndicesKind
  29487. * - VertexBuffer.MatricesIndicesExtraKind
  29488. * - VertexBuffer.MatricesWeightsKind
  29489. * - VertexBuffer.MatricesWeightsExtraKind
  29490. * @returns an array of strings
  29491. */
  29492. getVerticesDataKinds(): string[];
  29493. /**
  29494. * Returns a positive integer : the total number of indices in this mesh geometry.
  29495. * @returns the numner of indices or zero if the mesh has no geometry.
  29496. */
  29497. getTotalIndices(): number;
  29498. /**
  29499. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  29500. * @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.
  29501. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  29502. * @returns the indices array or an empty array if the mesh has no geometry
  29503. */
  29504. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  29505. get isBlocked(): boolean;
  29506. /**
  29507. * Determine if the current mesh is ready to be rendered
  29508. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  29509. * @param forceInstanceSupport will check if the mesh will be ready when used with instances (false by default)
  29510. * @returns true if all associated assets are ready (material, textures, shaders)
  29511. */
  29512. isReady(completeCheck?: boolean, forceInstanceSupport?: boolean): boolean;
  29513. /**
  29514. * 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.
  29515. */
  29516. get areNormalsFrozen(): boolean;
  29517. /**
  29518. * 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.
  29519. * @returns the current mesh
  29520. */
  29521. freezeNormals(): Mesh;
  29522. /**
  29523. * 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
  29524. * @returns the current mesh
  29525. */
  29526. unfreezeNormals(): Mesh;
  29527. /**
  29528. * Sets a value overriding the instance count. Only applicable when custom instanced InterleavedVertexBuffer are used rather than InstancedMeshs
  29529. */
  29530. set overridenInstanceCount(count: number);
  29531. /** @hidden */
  29532. _preActivate(): Mesh;
  29533. /** @hidden */
  29534. _preActivateForIntermediateRendering(renderId: number): Mesh;
  29535. /** @hidden */
  29536. _registerInstanceForRenderId(instance: InstancedMesh, renderId: number): Mesh;
  29537. protected _afterComputeWorldMatrix(): void;
  29538. /** @hidden */
  29539. _postActivate(): void;
  29540. /**
  29541. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  29542. * This means the mesh underlying bounding box and sphere are recomputed.
  29543. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  29544. * @returns the current mesh
  29545. */
  29546. refreshBoundingInfo(applySkeleton?: boolean): Mesh;
  29547. /** @hidden */
  29548. _createGlobalSubMesh(force: boolean): Nullable<SubMesh>;
  29549. /**
  29550. * This function will subdivide the mesh into multiple submeshes
  29551. * @param count defines the expected number of submeshes
  29552. */
  29553. subdivide(count: number): void;
  29554. /**
  29555. * Copy a FloatArray into a specific associated vertex buffer
  29556. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  29557. * - VertexBuffer.PositionKind
  29558. * - VertexBuffer.UVKind
  29559. * - VertexBuffer.UV2Kind
  29560. * - VertexBuffer.UV3Kind
  29561. * - VertexBuffer.UV4Kind
  29562. * - VertexBuffer.UV5Kind
  29563. * - VertexBuffer.UV6Kind
  29564. * - VertexBuffer.ColorKind
  29565. * - VertexBuffer.MatricesIndicesKind
  29566. * - VertexBuffer.MatricesIndicesExtraKind
  29567. * - VertexBuffer.MatricesWeightsKind
  29568. * - VertexBuffer.MatricesWeightsExtraKind
  29569. * @param data defines the data source
  29570. * @param updatable defines if the updated vertex buffer must be flagged as updatable
  29571. * @param stride defines the data stride size (can be null)
  29572. * @returns the current mesh
  29573. */
  29574. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  29575. /**
  29576. * Delete a vertex buffer associated with this mesh
  29577. * @param kind defines which buffer to delete (positions, indices, normals, etc). Possible `kind` values :
  29578. * - VertexBuffer.PositionKind
  29579. * - VertexBuffer.UVKind
  29580. * - VertexBuffer.UV2Kind
  29581. * - VertexBuffer.UV3Kind
  29582. * - VertexBuffer.UV4Kind
  29583. * - VertexBuffer.UV5Kind
  29584. * - VertexBuffer.UV6Kind
  29585. * - VertexBuffer.ColorKind
  29586. * - VertexBuffer.MatricesIndicesKind
  29587. * - VertexBuffer.MatricesIndicesExtraKind
  29588. * - VertexBuffer.MatricesWeightsKind
  29589. * - VertexBuffer.MatricesWeightsExtraKind
  29590. */
  29591. removeVerticesData(kind: string): void;
  29592. /**
  29593. * Flags an associated vertex buffer as updatable
  29594. * @param kind defines which buffer to use (positions, indices, normals, etc). Possible `kind` values :
  29595. * - VertexBuffer.PositionKind
  29596. * - VertexBuffer.UVKind
  29597. * - VertexBuffer.UV2Kind
  29598. * - VertexBuffer.UV3Kind
  29599. * - VertexBuffer.UV4Kind
  29600. * - VertexBuffer.UV5Kind
  29601. * - VertexBuffer.UV6Kind
  29602. * - VertexBuffer.ColorKind
  29603. * - VertexBuffer.MatricesIndicesKind
  29604. * - VertexBuffer.MatricesIndicesExtraKind
  29605. * - VertexBuffer.MatricesWeightsKind
  29606. * - VertexBuffer.MatricesWeightsExtraKind
  29607. * @param updatable defines if the updated vertex buffer must be flagged as updatable
  29608. */
  29609. markVerticesDataAsUpdatable(kind: string, updatable?: boolean): void;
  29610. /**
  29611. * Sets the mesh global Vertex Buffer
  29612. * @param buffer defines the buffer to use
  29613. * @returns the current mesh
  29614. */
  29615. setVerticesBuffer(buffer: VertexBuffer): Mesh;
  29616. /**
  29617. * Update a specific associated vertex buffer
  29618. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  29619. * - VertexBuffer.PositionKind
  29620. * - VertexBuffer.UVKind
  29621. * - VertexBuffer.UV2Kind
  29622. * - VertexBuffer.UV3Kind
  29623. * - VertexBuffer.UV4Kind
  29624. * - VertexBuffer.UV5Kind
  29625. * - VertexBuffer.UV6Kind
  29626. * - VertexBuffer.ColorKind
  29627. * - VertexBuffer.MatricesIndicesKind
  29628. * - VertexBuffer.MatricesIndicesExtraKind
  29629. * - VertexBuffer.MatricesWeightsKind
  29630. * - VertexBuffer.MatricesWeightsExtraKind
  29631. * @param data defines the data source
  29632. * @param updateExtends defines if extends info of the mesh must be updated (can be null). This is mostly useful for "position" kind
  29633. * @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)
  29634. * @returns the current mesh
  29635. */
  29636. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): AbstractMesh;
  29637. /**
  29638. * This method updates the vertex positions of an updatable mesh according to the `positionFunction` returned values.
  29639. * @see https://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh#other-shapes-updatemeshpositions
  29640. * @param positionFunction is a simple JS function what is passed the mesh `positions` array. It doesn't need to return anything
  29641. * @param computeNormals is a boolean (default true) to enable/disable the mesh normal recomputation after the vertex position update
  29642. * @returns the current mesh
  29643. */
  29644. updateMeshPositions(positionFunction: (data: FloatArray) => void, computeNormals?: boolean): Mesh;
  29645. /**
  29646. * Creates a un-shared specific occurence of the geometry for the mesh.
  29647. * @returns the current mesh
  29648. */
  29649. makeGeometryUnique(): Mesh;
  29650. /**
  29651. * Set the index buffer of this mesh
  29652. * @param indices defines the source data
  29653. * @param totalVertices defines the total number of vertices referenced by this index data (can be null)
  29654. * @param updatable defines if the updated index buffer must be flagged as updatable (default is false)
  29655. * @returns the current mesh
  29656. */
  29657. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>, updatable?: boolean): AbstractMesh;
  29658. /**
  29659. * Update the current index buffer
  29660. * @param indices defines the source data
  29661. * @param offset defines the offset in the index buffer where to store the new data (can be null)
  29662. * @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)
  29663. * @returns the current mesh
  29664. */
  29665. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): AbstractMesh;
  29666. /**
  29667. * Invert the geometry to move from a right handed system to a left handed one.
  29668. * @returns the current mesh
  29669. */
  29670. toLeftHanded(): Mesh;
  29671. /** @hidden */
  29672. _bind(subMesh: SubMesh, effect: Effect, fillMode: number): Mesh;
  29673. /** @hidden */
  29674. _draw(subMesh: SubMesh, fillMode: number, instancesCount?: number): Mesh;
  29675. /**
  29676. * Registers for this mesh a javascript function called just before the rendering process
  29677. * @param func defines the function to call before rendering this mesh
  29678. * @returns the current mesh
  29679. */
  29680. registerBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  29681. /**
  29682. * Disposes a previously registered javascript function called before the rendering
  29683. * @param func defines the function to remove
  29684. * @returns the current mesh
  29685. */
  29686. unregisterBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  29687. /**
  29688. * Registers for this mesh a javascript function called just after the rendering is complete
  29689. * @param func defines the function to call after rendering this mesh
  29690. * @returns the current mesh
  29691. */
  29692. registerAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  29693. /**
  29694. * Disposes a previously registered javascript function called after the rendering.
  29695. * @param func defines the function to remove
  29696. * @returns the current mesh
  29697. */
  29698. unregisterAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  29699. /** @hidden */
  29700. _getInstancesRenderList(subMeshId: number, isReplacementMode?: boolean): _InstancesBatch;
  29701. /** @hidden */
  29702. _renderWithInstances(subMesh: SubMesh, fillMode: number, batch: _InstancesBatch, effect: Effect, engine: Engine): Mesh;
  29703. /** @hidden */
  29704. _renderWithThinInstances(subMesh: SubMesh, fillMode: number, effect: Effect, engine: Engine): void;
  29705. /** @hidden */
  29706. _processInstancedBuffers(visibleInstances: InstancedMesh[], renderSelf: boolean): void;
  29707. /** @hidden */
  29708. _processRendering(renderingMesh: AbstractMesh, subMesh: SubMesh, effect: Effect, fillMode: number, batch: _InstancesBatch, hardwareInstancedRendering: boolean, onBeforeDraw: (isInstance: boolean, world: Matrix, effectiveMaterial?: Material) => void, effectiveMaterial?: Material): Mesh;
  29709. /** @hidden */
  29710. _rebuild(): void;
  29711. /** @hidden */
  29712. _freeze(): void;
  29713. /** @hidden */
  29714. _unFreeze(): void;
  29715. /**
  29716. * 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
  29717. * @param subMesh defines the subMesh to render
  29718. * @param enableAlphaMode defines if alpha mode can be changed
  29719. * @param effectiveMeshReplacement defines an optional mesh used to provide info for the rendering
  29720. * @returns the current mesh
  29721. */
  29722. render(subMesh: SubMesh, enableAlphaMode: boolean, effectiveMeshReplacement?: AbstractMesh): Mesh;
  29723. private _onBeforeDraw;
  29724. /**
  29725. * Renormalize the mesh and patch it up if there are no weights
  29726. * Similar to normalization by adding the weights compute the reciprocal and multiply all elements, this wil ensure that everything adds to 1.
  29727. * However in the case of zero weights then we set just a single influence to 1.
  29728. * We check in the function for extra's present and if so we use the normalizeSkinWeightsWithExtras rather than the FourWeights version.
  29729. */
  29730. cleanMatrixWeights(): void;
  29731. private normalizeSkinFourWeights;
  29732. private normalizeSkinWeightsAndExtra;
  29733. /**
  29734. * ValidateSkinning is used to determine that a mesh has valid skinning data along with skin metrics, if missing weights,
  29735. * or not normalized it is returned as invalid mesh the string can be used for console logs, or on screen messages to let
  29736. * the user know there was an issue with importing the mesh
  29737. * @returns a validation object with skinned, valid and report string
  29738. */
  29739. validateSkinning(): {
  29740. skinned: boolean;
  29741. valid: boolean;
  29742. report: string;
  29743. };
  29744. /** @hidden */
  29745. _checkDelayState(): Mesh;
  29746. private _queueLoad;
  29747. /**
  29748. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  29749. * A mesh is in the frustum if its bounding box intersects the frustum
  29750. * @param frustumPlanes defines the frustum to test
  29751. * @returns true if the mesh is in the frustum planes
  29752. */
  29753. isInFrustum(frustumPlanes: Plane[]): boolean;
  29754. /**
  29755. * Sets the mesh material by the material or multiMaterial `id` property
  29756. * @param id is a string identifying the material or the multiMaterial
  29757. * @returns the current mesh
  29758. */
  29759. setMaterialByID(id: string): Mesh;
  29760. /**
  29761. * Returns as a new array populated with the mesh material and/or skeleton, if any.
  29762. * @returns an array of IAnimatable
  29763. */
  29764. getAnimatables(): IAnimatable[];
  29765. /**
  29766. * Modifies the mesh geometry according to the passed transformation matrix.
  29767. * This method returns nothing but it really modifies the mesh even if it's originally not set as updatable.
  29768. * The mesh normals are modified using the same transformation.
  29769. * Note that, under the hood, this method sets a new VertexBuffer each call.
  29770. * @param transform defines the transform matrix to use
  29771. * @see https://doc.babylonjs.com/resources/baking_transformations
  29772. * @returns the current mesh
  29773. */
  29774. bakeTransformIntoVertices(transform: Matrix): Mesh;
  29775. /**
  29776. * Modifies the mesh geometry according to its own current World Matrix.
  29777. * The mesh World Matrix is then reset.
  29778. * This method returns nothing but really modifies the mesh even if it's originally not set as updatable.
  29779. * Note that, under the hood, this method sets a new VertexBuffer each call.
  29780. * @see https://doc.babylonjs.com/resources/baking_transformations
  29781. * @param bakeIndependenlyOfChildren indicates whether to preserve all child nodes' World Matrix during baking
  29782. * @returns the current mesh
  29783. */
  29784. bakeCurrentTransformIntoVertices(bakeIndependenlyOfChildren?: boolean): Mesh;
  29785. /** @hidden */
  29786. get _positions(): Nullable<Vector3[]>;
  29787. /** @hidden */
  29788. _resetPointsArrayCache(): Mesh;
  29789. /** @hidden */
  29790. _generatePointsArray(): boolean;
  29791. /**
  29792. * Returns a new Mesh object generated from the current mesh properties.
  29793. * This method must not get confused with createInstance()
  29794. * @param name is a string, the name given to the new mesh
  29795. * @param newParent can be any Node object (default `null`)
  29796. * @param doNotCloneChildren allows/denies the recursive cloning of the original mesh children if any (default `false`)
  29797. * @param clonePhysicsImpostor allows/denies the cloning in the same time of the original mesh `body` used by the physics engine, if any (default `true`)
  29798. * @returns a new mesh
  29799. */
  29800. clone(name?: string, newParent?: Nullable<Node>, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean): Mesh;
  29801. /**
  29802. * Releases resources associated with this mesh.
  29803. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  29804. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  29805. */
  29806. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  29807. /** @hidden */
  29808. _disposeInstanceSpecificData(): void;
  29809. /** @hidden */
  29810. _disposeThinInstanceSpecificData(): void;
  29811. /**
  29812. * Modifies the mesh geometry according to a displacement map.
  29813. * 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.
  29814. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  29815. * @param url is a string, the URL from the image file is to be downloaded.
  29816. * @param minHeight is the lower limit of the displacement.
  29817. * @param maxHeight is the upper limit of the displacement.
  29818. * @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.
  29819. * @param uvOffset is an optional vector2 used to offset UV.
  29820. * @param uvScale is an optional vector2 used to scale UV.
  29821. * @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.
  29822. * @returns the Mesh.
  29823. */
  29824. applyDisplacementMap(url: string, minHeight: number, maxHeight: number, onSuccess?: (mesh: Mesh) => void, uvOffset?: Vector2, uvScale?: Vector2, forceUpdate?: boolean): Mesh;
  29825. /**
  29826. * Modifies the mesh geometry according to a displacementMap buffer.
  29827. * 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.
  29828. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  29829. * @param buffer is a `Uint8Array` buffer containing series of `Uint8` lower than 255, the red, green, blue and alpha values of each successive pixel.
  29830. * @param heightMapWidth is the width of the buffer image.
  29831. * @param heightMapHeight is the height of the buffer image.
  29832. * @param minHeight is the lower limit of the displacement.
  29833. * @param maxHeight is the upper limit of the displacement.
  29834. * @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.
  29835. * @param uvOffset is an optional vector2 used to offset UV.
  29836. * @param uvScale is an optional vector2 used to scale UV.
  29837. * @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.
  29838. * @returns the Mesh.
  29839. */
  29840. applyDisplacementMapFromBuffer(buffer: Uint8Array, heightMapWidth: number, heightMapHeight: number, minHeight: number, maxHeight: number, uvOffset?: Vector2, uvScale?: Vector2, forceUpdate?: boolean): Mesh;
  29841. /**
  29842. * Modify the mesh to get a flat shading rendering.
  29843. * This means each mesh facet will then have its own normals. Usually new vertices are added in the mesh geometry to get this result.
  29844. * Warning : the mesh is really modified even if not set originally as updatable and, under the hood, a new VertexBuffer is allocated.
  29845. * @returns current mesh
  29846. */
  29847. convertToFlatShadedMesh(): Mesh;
  29848. /**
  29849. * This method removes all the mesh indices and add new vertices (duplication) in order to unfold facets into buffers.
  29850. * In other words, more vertices, no more indices and a single bigger VBO.
  29851. * The mesh is really modified even if not set originally as updatable. Under the hood, a new VertexBuffer is allocated.
  29852. * @returns current mesh
  29853. */
  29854. convertToUnIndexedMesh(): Mesh;
  29855. /**
  29856. * Inverses facet orientations.
  29857. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  29858. * @param flipNormals will also inverts the normals
  29859. * @returns current mesh
  29860. */
  29861. flipFaces(flipNormals?: boolean): Mesh;
  29862. /**
  29863. * Increase the number of facets and hence vertices in a mesh
  29864. * Vertex normals are interpolated from existing vertex normals
  29865. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  29866. * @param numberPerEdge the number of new vertices to add to each edge of a facet, optional default 1
  29867. */
  29868. increaseVertices(numberPerEdge: number): void;
  29869. /**
  29870. * Force adjacent facets to share vertices and remove any facets that have all vertices in a line
  29871. * This will undo any application of covertToFlatShadedMesh
  29872. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  29873. */
  29874. forceSharedVertices(): void;
  29875. /** @hidden */
  29876. static _instancedMeshFactory(name: string, mesh: Mesh): InstancedMesh;
  29877. /** @hidden */
  29878. static _PhysicsImpostorParser(scene: Scene, physicObject: IPhysicsEnabledObject, jsonObject: any): PhysicsImpostor;
  29879. /**
  29880. * Creates a new InstancedMesh object from the mesh model.
  29881. * @see https://doc.babylonjs.com/how_to/how_to_use_instances
  29882. * @param name defines the name of the new instance
  29883. * @returns a new InstancedMesh
  29884. */
  29885. createInstance(name: string): InstancedMesh;
  29886. /**
  29887. * Synchronises all the mesh instance submeshes to the current mesh submeshes, if any.
  29888. * After this call, all the mesh instances have the same submeshes than the current mesh.
  29889. * @returns the current mesh
  29890. */
  29891. synchronizeInstances(): Mesh;
  29892. /**
  29893. * Optimization of the mesh's indices, in case a mesh has duplicated vertices.
  29894. * The function will only reorder the indices and will not remove unused vertices to avoid problems with submeshes.
  29895. * This should be used together with the simplification to avoid disappearing triangles.
  29896. * @param successCallback an optional success callback to be called after the optimization finished.
  29897. * @returns the current mesh
  29898. */
  29899. optimizeIndices(successCallback?: (mesh?: Mesh) => void): Mesh;
  29900. /**
  29901. * Serialize current mesh
  29902. * @param serializationObject defines the object which will receive the serialization data
  29903. */
  29904. serialize(serializationObject: any): void;
  29905. /** @hidden */
  29906. _syncGeometryWithMorphTargetManager(): void;
  29907. /** @hidden */
  29908. static _GroundMeshParser: (parsedMesh: any, scene: Scene) => Mesh;
  29909. /**
  29910. * Returns a new Mesh object parsed from the source provided.
  29911. * @param parsedMesh is the source
  29912. * @param scene defines the hosting scene
  29913. * @param rootUrl is the root URL to prefix the `delayLoadingFile` property with
  29914. * @returns a new Mesh
  29915. */
  29916. static Parse(parsedMesh: any, scene: Scene, rootUrl: string): Mesh;
  29917. /**
  29918. * Creates a ribbon mesh. Please consider using the same method from the MeshBuilder class instead
  29919. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  29920. * @param name defines the name of the mesh to create
  29921. * @param pathArray is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry.
  29922. * @param closeArray creates a seam between the first and the last paths of the path array (default is false)
  29923. * @param closePath creates a seam between the first and the last points of each path of the path array
  29924. * @param offset is taken in account only if the `pathArray` is containing a single path
  29925. * @param scene defines the hosting scene
  29926. * @param updatable defines if the mesh must be flagged as updatable
  29927. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  29928. * @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)
  29929. * @returns a new Mesh
  29930. */
  29931. static CreateRibbon(name: string, pathArray: Vector3[][], closeArray: boolean, closePath: boolean, offset: number, scene?: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  29932. /**
  29933. * Creates a plane polygonal mesh. By default, this is a disc. Please consider using the same method from the MeshBuilder class instead
  29934. * @param name defines the name of the mesh to create
  29935. * @param radius sets the radius size (float) of the polygon (default 0.5)
  29936. * @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
  29937. * @param scene defines the hosting scene
  29938. * @param updatable defines if the mesh must be flagged as updatable
  29939. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  29940. * @returns a new Mesh
  29941. */
  29942. static CreateDisc(name: string, radius: number, tessellation: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  29943. /**
  29944. * Creates a box mesh. Please consider using the same method from the MeshBuilder class instead
  29945. * @param name defines the name of the mesh to create
  29946. * @param size sets the size (float) of each box side (default 1)
  29947. * @param scene defines the hosting scene
  29948. * @param updatable defines if the mesh must be flagged as updatable
  29949. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  29950. * @returns a new Mesh
  29951. */
  29952. static CreateBox(name: string, size: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  29953. /**
  29954. * Creates a sphere mesh. Please consider using the same method from the MeshBuilder class instead
  29955. * @param name defines the name of the mesh to create
  29956. * @param segments sets the sphere number of horizontal stripes (positive integer, default 32)
  29957. * @param diameter sets the diameter size (float) of the sphere (default 1)
  29958. * @param scene defines the hosting scene
  29959. * @param updatable defines if the mesh must be flagged as updatable
  29960. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  29961. * @returns a new Mesh
  29962. */
  29963. static CreateSphere(name: string, segments: number, diameter: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  29964. /**
  29965. * Creates a hemisphere mesh. Please consider using the same method from the MeshBuilder class instead
  29966. * @param name defines the name of the mesh to create
  29967. * @param segments sets the sphere number of horizontal stripes (positive integer, default 32)
  29968. * @param diameter sets the diameter size (float) of the sphere (default 1)
  29969. * @param scene defines the hosting scene
  29970. * @returns a new Mesh
  29971. */
  29972. static CreateHemisphere(name: string, segments: number, diameter: number, scene?: Scene): Mesh;
  29973. /**
  29974. * Creates a cylinder or a cone mesh. Please consider using the same method from the MeshBuilder class instead
  29975. * @param name defines the name of the mesh to create
  29976. * @param height sets the height size (float) of the cylinder/cone (float, default 2)
  29977. * @param diameterTop set the top cap diameter (floats, default 1)
  29978. * @param diameterBottom set the bottom cap diameter (floats, default 1). This value can't be zero
  29979. * @param tessellation sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance
  29980. * @param subdivisions sets the number of rings along the cylinder height (positive integer, default 1)
  29981. * @param scene defines the hosting scene
  29982. * @param updatable defines if the mesh must be flagged as updatable
  29983. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  29984. * @returns a new Mesh
  29985. */
  29986. static CreateCylinder(name: string, height: number, diameterTop: number, diameterBottom: number, tessellation: number, subdivisions: any, scene?: Scene, updatable?: any, sideOrientation?: number): Mesh;
  29987. /**
  29988. * Creates a torus mesh. Please consider using the same method from the MeshBuilder class instead
  29989. * @param name defines the name of the mesh to create
  29990. * @param diameter sets the diameter size (float) of the torus (default 1)
  29991. * @param thickness sets the diameter size of the tube of the torus (float, default 0.5)
  29992. * @param tessellation sets the number of torus sides (postive integer, default 16)
  29993. * @param scene defines the hosting scene
  29994. * @param updatable defines if the mesh must be flagged as updatable
  29995. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  29996. * @returns a new Mesh
  29997. */
  29998. static CreateTorus(name: string, diameter: number, thickness: number, tessellation: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  29999. /**
  30000. * Creates a torus knot mesh. Please consider using the same method from the MeshBuilder class instead
  30001. * @param name defines the name of the mesh to create
  30002. * @param radius sets the global radius size (float) of the torus knot (default 2)
  30003. * @param tube sets the diameter size of the tube of the torus (float, default 0.5)
  30004. * @param radialSegments sets the number of sides on each tube segments (positive integer, default 32)
  30005. * @param tubularSegments sets the number of tubes to decompose the knot into (positive integer, default 32)
  30006. * @param p the number of windings on X axis (positive integers, default 2)
  30007. * @param q the number of windings on Y axis (positive integers, default 3)
  30008. * @param scene defines the hosting scene
  30009. * @param updatable defines if the mesh must be flagged as updatable
  30010. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  30011. * @returns a new Mesh
  30012. */
  30013. static CreateTorusKnot(name: string, radius: number, tube: number, radialSegments: number, tubularSegments: number, p: number, q: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  30014. /**
  30015. * Creates a line mesh. Please consider using the same method from the MeshBuilder class instead.
  30016. * @param name defines the name of the mesh to create
  30017. * @param points is an array successive Vector3
  30018. * @param scene defines the hosting scene
  30019. * @param updatable defines if the mesh must be flagged as updatable
  30020. * @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).
  30021. * @returns a new Mesh
  30022. */
  30023. static CreateLines(name: string, points: Vector3[], scene?: Nullable<Scene>, updatable?: boolean, instance?: Nullable<LinesMesh>): LinesMesh;
  30024. /**
  30025. * Creates a dashed line mesh. Please consider using the same method from the MeshBuilder class instead
  30026. * @param name defines the name of the mesh to create
  30027. * @param points is an array successive Vector3
  30028. * @param dashSize is the size of the dashes relatively the dash number (positive float, default 3)
  30029. * @param gapSize is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  30030. * @param dashNb is the intended total number of dashes (positive integer, default 200)
  30031. * @param scene defines the hosting scene
  30032. * @param updatable defines if the mesh must be flagged as updatable
  30033. * @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)
  30034. * @returns a new Mesh
  30035. */
  30036. static CreateDashedLines(name: string, points: Vector3[], dashSize: number, gapSize: number, dashNb: number, scene?: Nullable<Scene>, updatable?: boolean, instance?: LinesMesh): LinesMesh;
  30037. /**
  30038. * Creates a polygon mesh.Please consider using the same method from the MeshBuilder class instead
  30039. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh.
  30040. * 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.
  30041. * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  30042. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  30043. * Remember you can only change the shape positions, not their number when updating a polygon.
  30044. * @see https://doc.babylonjs.com/how_to/parametric_shapes#non-regular-polygon
  30045. * @param name defines the name of the mesh to create
  30046. * @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
  30047. * @param scene defines the hosting scene
  30048. * @param holes is a required array of arrays of successive Vector3 used to defines holes in the polygon
  30049. * @param updatable defines if the mesh must be flagged as updatable
  30050. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  30051. * @param earcutInjection can be used to inject your own earcut reference
  30052. * @returns a new Mesh
  30053. */
  30054. static CreatePolygon(name: string, shape: Vector3[], scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number, earcutInjection?: any): Mesh;
  30055. /**
  30056. * Creates an extruded polygon mesh, with depth in the Y direction. Please consider using the same method from the MeshBuilder class instead.
  30057. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-non-regular-polygon
  30058. * @param name defines the name of the mesh to create
  30059. * @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
  30060. * @param depth defines the height of extrusion
  30061. * @param scene defines the hosting scene
  30062. * @param holes is a required array of arrays of successive Vector3 used to defines holes in the polygon
  30063. * @param updatable defines if the mesh must be flagged as updatable
  30064. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  30065. * @param earcutInjection can be used to inject your own earcut reference
  30066. * @returns a new Mesh
  30067. */
  30068. static ExtrudePolygon(name: string, shape: Vector3[], depth: number, scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number, earcutInjection?: any): Mesh;
  30069. /**
  30070. * Creates an extruded shape mesh.
  30071. * 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
  30072. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  30073. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  30074. * @param name defines the name of the mesh to create
  30075. * @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
  30076. * @param path is a required array of successive Vector3. This is the axis curve the shape is extruded along
  30077. * @param scale is the value to scale the shape
  30078. * @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
  30079. * @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
  30080. * @param scene defines the hosting scene
  30081. * @param updatable defines if the mesh must be flagged as updatable
  30082. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  30083. * @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)
  30084. * @returns a new Mesh
  30085. */
  30086. static ExtrudeShape(name: string, shape: Vector3[], path: Vector3[], scale: number, rotation: number, cap: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  30087. /**
  30088. * Creates an custom extruded shape mesh.
  30089. * The custom extrusion is a parametric shape.
  30090. * It has no predefined shape. Its final shape will depend on the input parameters.
  30091. * Please consider using the same method from the MeshBuilder class instead
  30092. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  30093. * @param name defines the name of the mesh to create
  30094. * @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
  30095. * @param path is a required array of successive Vector3. This is the axis curve the shape is extruded along
  30096. * @param scaleFunction is a custom Javascript function called on each path point
  30097. * @param rotationFunction is a custom Javascript function called on each path point
  30098. * @param ribbonCloseArray forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  30099. * @param ribbonClosePath forces the extrusion underlying ribbon to close its `pathArray`
  30100. * @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
  30101. * @param scene defines the hosting scene
  30102. * @param updatable defines if the mesh must be flagged as updatable
  30103. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  30104. * @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)
  30105. * @returns a new Mesh
  30106. */
  30107. 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;
  30108. /**
  30109. * Creates lathe mesh.
  30110. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe.
  30111. * Please consider using the same method from the MeshBuilder class instead
  30112. * @param name defines the name of the mesh to create
  30113. * @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
  30114. * @param radius is the radius value of the lathe
  30115. * @param tessellation is the side number of the lathe.
  30116. * @param scene defines the hosting scene
  30117. * @param updatable defines if the mesh must be flagged as updatable
  30118. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  30119. * @returns a new Mesh
  30120. */
  30121. static CreateLathe(name: string, shape: Vector3[], radius: number, tessellation: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  30122. /**
  30123. * Creates a plane mesh. Please consider using the same method from the MeshBuilder class instead
  30124. * @param name defines the name of the mesh to create
  30125. * @param size sets the size (float) of both sides of the plane at once (default 1)
  30126. * @param scene defines the hosting scene
  30127. * @param updatable defines if the mesh must be flagged as updatable
  30128. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  30129. * @returns a new Mesh
  30130. */
  30131. static CreatePlane(name: string, size: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  30132. /**
  30133. * Creates a ground mesh.
  30134. * Please consider using the same method from the MeshBuilder class instead
  30135. * @param name defines the name of the mesh to create
  30136. * @param width set the width of the ground
  30137. * @param height set the height of the ground
  30138. * @param subdivisions sets the number of subdivisions per side
  30139. * @param scene defines the hosting scene
  30140. * @param updatable defines if the mesh must be flagged as updatable
  30141. * @returns a new Mesh
  30142. */
  30143. static CreateGround(name: string, width: number, height: number, subdivisions: number, scene?: Scene, updatable?: boolean): Mesh;
  30144. /**
  30145. * Creates a tiled ground mesh.
  30146. * Please consider using the same method from the MeshBuilder class instead
  30147. * @param name defines the name of the mesh to create
  30148. * @param xmin set the ground minimum X coordinate
  30149. * @param zmin set the ground minimum Y coordinate
  30150. * @param xmax set the ground maximum X coordinate
  30151. * @param zmax set the ground maximum Z coordinate
  30152. * @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
  30153. * @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
  30154. * @param scene defines the hosting scene
  30155. * @param updatable defines if the mesh must be flagged as updatable
  30156. * @returns a new Mesh
  30157. */
  30158. static CreateTiledGround(name: string, xmin: number, zmin: number, xmax: number, zmax: number, subdivisions: {
  30159. w: number;
  30160. h: number;
  30161. }, precision: {
  30162. w: number;
  30163. h: number;
  30164. }, scene: Scene, updatable?: boolean): Mesh;
  30165. /**
  30166. * Creates a ground mesh from a height map.
  30167. * Please consider using the same method from the MeshBuilder class instead
  30168. * @see https://doc.babylonjs.com/babylon101/height_map
  30169. * @param name defines the name of the mesh to create
  30170. * @param url sets the URL of the height map image resource
  30171. * @param width set the ground width size
  30172. * @param height set the ground height size
  30173. * @param subdivisions sets the number of subdivision per side
  30174. * @param minHeight is the minimum altitude on the ground
  30175. * @param maxHeight is the maximum altitude on the ground
  30176. * @param scene defines the hosting scene
  30177. * @param updatable defines if the mesh must be flagged as updatable
  30178. * @param onReady is a callback function that will be called once the mesh is built (the height map download can last some time)
  30179. * @param alphaFilter will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  30180. * @returns a new Mesh
  30181. */
  30182. 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;
  30183. /**
  30184. * Creates a tube mesh.
  30185. * The tube is a parametric shape.
  30186. * It has no predefined shape. Its final shape will depend on the input parameters.
  30187. * Please consider using the same method from the MeshBuilder class instead
  30188. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  30189. * @param name defines the name of the mesh to create
  30190. * @param path is a required array of successive Vector3. It is the curve used as the axis of the tube
  30191. * @param radius sets the tube radius size
  30192. * @param tessellation is the number of sides on the tubular surface
  30193. * @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
  30194. * @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
  30195. * @param scene defines the hosting scene
  30196. * @param updatable defines if the mesh must be flagged as updatable
  30197. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  30198. * @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)
  30199. * @returns a new Mesh
  30200. */
  30201. static CreateTube(name: string, path: Vector3[], radius: number, tessellation: number, radiusFunction: {
  30202. (i: number, distance: number): number;
  30203. }, cap: number, scene: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  30204. /**
  30205. * Creates a polyhedron mesh.
  30206. * Please consider using the same method from the MeshBuilder class instead.
  30207. * * 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
  30208. * * The parameter `size` (positive float, default 1) sets the polygon size
  30209. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  30210. * * 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`
  30211. * * 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
  30212. * * 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)`)
  30213. * * 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
  30214. * * 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
  30215. * * You can also set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  30216. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  30217. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  30218. * @param name defines the name of the mesh to create
  30219. * @param options defines the options used to create the mesh
  30220. * @param scene defines the hosting scene
  30221. * @returns a new Mesh
  30222. */
  30223. static CreatePolyhedron(name: string, options: {
  30224. type?: number;
  30225. size?: number;
  30226. sizeX?: number;
  30227. sizeY?: number;
  30228. sizeZ?: number;
  30229. custom?: any;
  30230. faceUV?: Vector4[];
  30231. faceColors?: Color4[];
  30232. updatable?: boolean;
  30233. sideOrientation?: number;
  30234. }, scene: Scene): Mesh;
  30235. /**
  30236. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  30237. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  30238. * * 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`)
  30239. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  30240. * * 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
  30241. * * You can also set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  30242. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  30243. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  30244. * @param name defines the name of the mesh
  30245. * @param options defines the options used to create the mesh
  30246. * @param scene defines the hosting scene
  30247. * @returns a new Mesh
  30248. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  30249. */
  30250. static CreateIcoSphere(name: string, options: {
  30251. radius?: number;
  30252. flat?: boolean;
  30253. subdivisions?: number;
  30254. sideOrientation?: number;
  30255. updatable?: boolean;
  30256. }, scene: Scene): Mesh;
  30257. /**
  30258. * Creates a decal mesh.
  30259. * Please consider using the same method from the MeshBuilder class instead.
  30260. * A decal is a mesh usually applied as a model onto the surface of another mesh
  30261. * @param name defines the name of the mesh
  30262. * @param sourceMesh defines the mesh receiving the decal
  30263. * @param position sets the position of the decal in world coordinates
  30264. * @param normal sets the normal of the mesh where the decal is applied onto in world coordinates
  30265. * @param size sets the decal scaling
  30266. * @param angle sets the angle to rotate the decal
  30267. * @returns a new Mesh
  30268. */
  30269. static CreateDecal(name: string, sourceMesh: AbstractMesh, position: Vector3, normal: Vector3, size: Vector3, angle: number): Mesh;
  30270. /**
  30271. * Prepare internal position array for software CPU skinning
  30272. * @returns original positions used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh
  30273. */
  30274. setPositionsForCPUSkinning(): Float32Array;
  30275. /**
  30276. * Prepare internal normal array for software CPU skinning
  30277. * @returns original normals used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh.
  30278. */
  30279. setNormalsForCPUSkinning(): Float32Array;
  30280. /**
  30281. * Updates the vertex buffer by applying transformation from the bones
  30282. * @param skeleton defines the skeleton to apply to current mesh
  30283. * @returns the current mesh
  30284. */
  30285. applySkeleton(skeleton: Skeleton): Mesh;
  30286. /**
  30287. * 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
  30288. * @param meshes defines the list of meshes to scan
  30289. * @returns an object `{min:` Vector3`, max:` Vector3`}`
  30290. */
  30291. static MinMax(meshes: AbstractMesh[]): {
  30292. min: Vector3;
  30293. max: Vector3;
  30294. };
  30295. /**
  30296. * Returns the center of the `{min:` Vector3`, max:` Vector3`}` or the center of MinMax vector3 computed from a mesh array
  30297. * @param meshesOrMinMaxVector could be an array of meshes or a `{min:` Vector3`, max:` Vector3`}` object
  30298. * @returns a vector3
  30299. */
  30300. static Center(meshesOrMinMaxVector: {
  30301. min: Vector3;
  30302. max: Vector3;
  30303. } | AbstractMesh[]): Vector3;
  30304. /**
  30305. * Merge the array of meshes into a single mesh for performance reasons.
  30306. * @param meshes defines he vertices source. They should all be of the same material. Entries can empty
  30307. * @param disposeSource when true (default), dispose of the vertices from the source meshes
  30308. * @param allow32BitsIndices when the sum of the vertices > 64k, this must be set to true
  30309. * @param meshSubclass when set, vertices inserted into this Mesh. Meshes can then be merged into a Mesh sub-class.
  30310. * @param subdivideWithSubMeshes when true (false default), subdivide mesh to his subMesh array with meshes source.
  30311. * @param multiMultiMaterials when true (false default), subdivide mesh and accept multiple multi materials, ignores subdivideWithSubMeshes.
  30312. * @returns a new mesh
  30313. */
  30314. static MergeMeshes(meshes: Array<Mesh>, disposeSource?: boolean, allow32BitsIndices?: boolean, meshSubclass?: Mesh, subdivideWithSubMeshes?: boolean, multiMultiMaterials?: boolean): Nullable<Mesh>;
  30315. /** @hidden */
  30316. addInstance(instance: InstancedMesh): void;
  30317. /** @hidden */
  30318. removeInstance(instance: InstancedMesh): void;
  30319. }
  30320. }
  30321. declare module "babylonjs/Cameras/camera" {
  30322. import { SmartArray } from "babylonjs/Misc/smartArray";
  30323. import { Observable } from "babylonjs/Misc/observable";
  30324. import { Nullable } from "babylonjs/types";
  30325. import { CameraInputsManager } from "babylonjs/Cameras/cameraInputsManager";
  30326. import { Scene } from "babylonjs/scene";
  30327. import { Matrix, Vector3, Quaternion } from "babylonjs/Maths/math.vector";
  30328. import { Node } from "babylonjs/node";
  30329. import { Mesh } from "babylonjs/Meshes/mesh";
  30330. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  30331. import { ICullable } from "babylonjs/Culling/boundingInfo";
  30332. import { Viewport } from "babylonjs/Maths/math.viewport";
  30333. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  30334. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  30335. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  30336. import { Ray } from "babylonjs/Culling/ray";
  30337. /**
  30338. * This is the base class of all the camera used in the application.
  30339. * @see https://doc.babylonjs.com/features/cameras
  30340. */
  30341. export class Camera extends Node {
  30342. /** @hidden */
  30343. static _createDefaultParsedCamera: (name: string, scene: Scene) => Camera;
  30344. /**
  30345. * This is the default projection mode used by the cameras.
  30346. * It helps recreating a feeling of perspective and better appreciate depth.
  30347. * This is the best way to simulate real life cameras.
  30348. */
  30349. static readonly PERSPECTIVE_CAMERA: number;
  30350. /**
  30351. * This helps creating camera with an orthographic mode.
  30352. * 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.
  30353. */
  30354. static readonly ORTHOGRAPHIC_CAMERA: number;
  30355. /**
  30356. * This is the default FOV mode for perspective cameras.
  30357. * This setting aligns the upper and lower bounds of the viewport to the upper and lower bounds of the camera frustum.
  30358. */
  30359. static readonly FOVMODE_VERTICAL_FIXED: number;
  30360. /**
  30361. * This setting aligns the left and right bounds of the viewport to the left and right bounds of the camera frustum.
  30362. */
  30363. static readonly FOVMODE_HORIZONTAL_FIXED: number;
  30364. /**
  30365. * This specifies ther is no need for a camera rig.
  30366. * Basically only one eye is rendered corresponding to the camera.
  30367. */
  30368. static readonly RIG_MODE_NONE: number;
  30369. /**
  30370. * Simulates a camera Rig with one blue eye and one red eye.
  30371. * This can be use with 3d blue and red glasses.
  30372. */
  30373. static readonly RIG_MODE_STEREOSCOPIC_ANAGLYPH: number;
  30374. /**
  30375. * Defines that both eyes of the camera will be rendered side by side with a parallel target.
  30376. */
  30377. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_PARALLEL: number;
  30378. /**
  30379. * Defines that both eyes of the camera will be rendered side by side with a none parallel target.
  30380. */
  30381. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_CROSSEYED: number;
  30382. /**
  30383. * Defines that both eyes of the camera will be rendered over under each other.
  30384. */
  30385. static readonly RIG_MODE_STEREOSCOPIC_OVERUNDER: number;
  30386. /**
  30387. * Defines that both eyes of the camera will be rendered on successive lines interlaced for passive 3d monitors.
  30388. */
  30389. static readonly RIG_MODE_STEREOSCOPIC_INTERLACED: number;
  30390. /**
  30391. * Defines that both eyes of the camera should be renderered in a VR mode (carbox).
  30392. */
  30393. static readonly RIG_MODE_VR: number;
  30394. /**
  30395. * Defines that both eyes of the camera should be renderered in a VR mode (webVR).
  30396. */
  30397. static readonly RIG_MODE_WEBVR: number;
  30398. /**
  30399. * Custom rig mode allowing rig cameras to be populated manually with any number of cameras
  30400. */
  30401. static readonly RIG_MODE_CUSTOM: number;
  30402. /**
  30403. * Defines if by default attaching controls should prevent the default javascript event to continue.
  30404. */
  30405. static ForceAttachControlToAlwaysPreventDefault: boolean;
  30406. /**
  30407. * Define the input manager associated with the camera.
  30408. */
  30409. inputs: CameraInputsManager<Camera>;
  30410. /** @hidden */
  30411. _position: Vector3;
  30412. /**
  30413. * Define the current local position of the camera in the scene
  30414. */
  30415. get position(): Vector3;
  30416. set position(newPosition: Vector3);
  30417. protected _upVector: Vector3;
  30418. /**
  30419. * The vector the camera should consider as up.
  30420. * (default is Vector3(0, 1, 0) aka Vector3.Up())
  30421. */
  30422. set upVector(vec: Vector3);
  30423. get upVector(): Vector3;
  30424. /**
  30425. * Define the current limit on the left side for an orthographic camera
  30426. * In scene unit
  30427. */
  30428. orthoLeft: Nullable<number>;
  30429. /**
  30430. * Define the current limit on the right side for an orthographic camera
  30431. * In scene unit
  30432. */
  30433. orthoRight: Nullable<number>;
  30434. /**
  30435. * Define the current limit on the bottom side for an orthographic camera
  30436. * In scene unit
  30437. */
  30438. orthoBottom: Nullable<number>;
  30439. /**
  30440. * Define the current limit on the top side for an orthographic camera
  30441. * In scene unit
  30442. */
  30443. orthoTop: Nullable<number>;
  30444. /**
  30445. * Field Of View is set in Radians. (default is 0.8)
  30446. */
  30447. fov: number;
  30448. /**
  30449. * Define the minimum distance the camera can see from.
  30450. * This is important to note that the depth buffer are not infinite and the closer it starts
  30451. * the more your scene might encounter depth fighting issue.
  30452. */
  30453. minZ: number;
  30454. /**
  30455. * Define the maximum distance the camera can see to.
  30456. * This is important to note that the depth buffer are not infinite and the further it end
  30457. * the more your scene might encounter depth fighting issue.
  30458. */
  30459. maxZ: number;
  30460. /**
  30461. * Define the default inertia of the camera.
  30462. * This helps giving a smooth feeling to the camera movement.
  30463. */
  30464. inertia: number;
  30465. /**
  30466. * Define the mode of the camera (Camera.PERSPECTIVE_CAMERA or Camera.ORTHOGRAPHIC_CAMERA)
  30467. */
  30468. mode: number;
  30469. /**
  30470. * Define whether the camera is intermediate.
  30471. * This is useful to not present the output directly to the screen in case of rig without post process for instance
  30472. */
  30473. isIntermediate: boolean;
  30474. /**
  30475. * Define the viewport of the camera.
  30476. * This correspond to the portion of the screen the camera will render to in normalized 0 to 1 unit.
  30477. */
  30478. viewport: Viewport;
  30479. /**
  30480. * Restricts the camera to viewing objects with the same layerMask.
  30481. * A camera with a layerMask of 1 will render mesh.layerMask & camera.layerMask!== 0
  30482. */
  30483. layerMask: number;
  30484. /**
  30485. * fovMode sets the camera frustum bounds to the viewport bounds. (default is FOVMODE_VERTICAL_FIXED)
  30486. */
  30487. fovMode: number;
  30488. /**
  30489. * Rig mode of the camera.
  30490. * This is useful to create the camera with two "eyes" instead of one to create VR or stereoscopic scenes.
  30491. * This is normally controlled byt the camera themselves as internal use.
  30492. */
  30493. cameraRigMode: number;
  30494. /**
  30495. * Defines the distance between both "eyes" in case of a RIG
  30496. */
  30497. interaxialDistance: number;
  30498. /**
  30499. * Defines if stereoscopic rendering is done side by side or over under.
  30500. */
  30501. isStereoscopicSideBySide: boolean;
  30502. /**
  30503. * 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
  30504. * This is pretty helpfull if you wish to make a camera render to a texture you could reuse somewhere
  30505. * else in the scene. (Eg. security camera)
  30506. *
  30507. * 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)
  30508. */
  30509. customRenderTargets: import("babylonjs/Materials/Textures/renderTargetTexture").RenderTargetTexture[];
  30510. /**
  30511. * When set, the camera will render to this render target instead of the default canvas
  30512. *
  30513. * If the desire is to use the output of a camera as a texture in the scene consider using camera.customRenderTargets instead
  30514. */
  30515. outputRenderTarget: Nullable<RenderTargetTexture>;
  30516. /**
  30517. * Observable triggered when the camera view matrix has changed.
  30518. */
  30519. onViewMatrixChangedObservable: Observable<Camera>;
  30520. /**
  30521. * Observable triggered when the camera Projection matrix has changed.
  30522. */
  30523. onProjectionMatrixChangedObservable: Observable<Camera>;
  30524. /**
  30525. * Observable triggered when the inputs have been processed.
  30526. */
  30527. onAfterCheckInputsObservable: Observable<Camera>;
  30528. /**
  30529. * Observable triggered when reset has been called and applied to the camera.
  30530. */
  30531. onRestoreStateObservable: Observable<Camera>;
  30532. /**
  30533. * Is this camera a part of a rig system?
  30534. */
  30535. isRigCamera: boolean;
  30536. /**
  30537. * If isRigCamera set to true this will be set with the parent camera.
  30538. * The parent camera is not (!) necessarily the .parent of this camera (like in the case of XR)
  30539. */
  30540. rigParent?: Camera;
  30541. /** @hidden */
  30542. _cameraRigParams: any;
  30543. /** @hidden */
  30544. _rigCameras: Camera[];
  30545. /** @hidden */
  30546. _rigPostProcess: Nullable<PostProcess>;
  30547. protected _webvrViewMatrix: Matrix;
  30548. /** @hidden */
  30549. _skipRendering: boolean;
  30550. /** @hidden */
  30551. _projectionMatrix: Matrix;
  30552. /** @hidden */
  30553. _postProcesses: Nullable<import("babylonjs/PostProcesses/postProcess").PostProcess>[];
  30554. /** @hidden */
  30555. _activeMeshes: SmartArray<AbstractMesh>;
  30556. protected _globalPosition: Vector3;
  30557. /** @hidden */
  30558. _computedViewMatrix: Matrix;
  30559. private _doNotComputeProjectionMatrix;
  30560. private _transformMatrix;
  30561. private _frustumPlanes;
  30562. private _refreshFrustumPlanes;
  30563. private _storedFov;
  30564. private _stateStored;
  30565. /**
  30566. * Instantiates a new camera object.
  30567. * This should not be used directly but through the inherited cameras: ArcRotate, Free...
  30568. * @see https://doc.babylonjs.com/features/cameras
  30569. * @param name Defines the name of the camera in the scene
  30570. * @param position Defines the position of the camera
  30571. * @param scene Defines the scene the camera belongs too
  30572. * @param setActiveOnSceneIfNoneActive Defines if the camera should be set as active after creation if no other camera have been defined in the scene
  30573. */
  30574. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  30575. /**
  30576. * Store current camera state (fov, position, etc..)
  30577. * @returns the camera
  30578. */
  30579. storeState(): Camera;
  30580. /**
  30581. * Restores the camera state values if it has been stored. You must call storeState() first
  30582. */
  30583. protected _restoreStateValues(): boolean;
  30584. /**
  30585. * Restored camera state. You must call storeState() first.
  30586. * @returns true if restored and false otherwise
  30587. */
  30588. restoreState(): boolean;
  30589. /**
  30590. * Gets the class name of the camera.
  30591. * @returns the class name
  30592. */
  30593. getClassName(): string;
  30594. /** @hidden */
  30595. readonly _isCamera: boolean;
  30596. /**
  30597. * Gets a string representation of the camera useful for debug purpose.
  30598. * @param fullDetails Defines that a more verboe level of logging is required
  30599. * @returns the string representation
  30600. */
  30601. toString(fullDetails?: boolean): string;
  30602. /**
  30603. * Gets the current world space position of the camera.
  30604. */
  30605. get globalPosition(): Vector3;
  30606. /**
  30607. * Gets the list of active meshes this frame (meshes no culled or excluded by lod s in the frame)
  30608. * @returns the active meshe list
  30609. */
  30610. getActiveMeshes(): SmartArray<AbstractMesh>;
  30611. /**
  30612. * Check whether a mesh is part of the current active mesh list of the camera
  30613. * @param mesh Defines the mesh to check
  30614. * @returns true if active, false otherwise
  30615. */
  30616. isActiveMesh(mesh: Mesh): boolean;
  30617. /**
  30618. * Is this camera ready to be used/rendered
  30619. * @param completeCheck defines if a complete check (including post processes) has to be done (false by default)
  30620. * @return true if the camera is ready
  30621. */
  30622. isReady(completeCheck?: boolean): boolean;
  30623. /** @hidden */
  30624. _initCache(): void;
  30625. /** @hidden */
  30626. _updateCache(ignoreParentClass?: boolean): void;
  30627. /** @hidden */
  30628. _isSynchronized(): boolean;
  30629. /** @hidden */
  30630. _isSynchronizedViewMatrix(): boolean;
  30631. /** @hidden */
  30632. _isSynchronizedProjectionMatrix(): boolean;
  30633. /**
  30634. * Attach the input controls to a specific dom element to get the input from.
  30635. * @param element Defines the element the controls should be listened from
  30636. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  30637. */
  30638. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  30639. /**
  30640. * Detach the current controls from the specified dom element.
  30641. * @param element Defines the element to stop listening the inputs from
  30642. */
  30643. detachControl(element: HTMLElement): void;
  30644. /**
  30645. * Update the camera state according to the different inputs gathered during the frame.
  30646. */
  30647. update(): void;
  30648. /** @hidden */
  30649. _checkInputs(): void;
  30650. /** @hidden */
  30651. get rigCameras(): Camera[];
  30652. /**
  30653. * Gets the post process used by the rig cameras
  30654. */
  30655. get rigPostProcess(): Nullable<PostProcess>;
  30656. /**
  30657. * Internal, gets the first post proces.
  30658. * @returns the first post process to be run on this camera.
  30659. */
  30660. _getFirstPostProcess(): Nullable<PostProcess>;
  30661. private _cascadePostProcessesToRigCams;
  30662. /**
  30663. * Attach a post process to the camera.
  30664. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#attach-postprocess
  30665. * @param postProcess The post process to attach to the camera
  30666. * @param insertAt The position of the post process in case several of them are in use in the scene
  30667. * @returns the position the post process has been inserted at
  30668. */
  30669. attachPostProcess(postProcess: PostProcess, insertAt?: Nullable<number>): number;
  30670. /**
  30671. * Detach a post process to the camera.
  30672. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#attach-postprocess
  30673. * @param postProcess The post process to detach from the camera
  30674. */
  30675. detachPostProcess(postProcess: PostProcess): void;
  30676. /**
  30677. * Gets the current world matrix of the camera
  30678. */
  30679. getWorldMatrix(): Matrix;
  30680. /** @hidden */
  30681. _getViewMatrix(): Matrix;
  30682. /**
  30683. * Gets the current view matrix of the camera.
  30684. * @param force forces the camera to recompute the matrix without looking at the cached state
  30685. * @returns the view matrix
  30686. */
  30687. getViewMatrix(force?: boolean): Matrix;
  30688. /**
  30689. * Freeze the projection matrix.
  30690. * It will prevent the cache check of the camera projection compute and can speed up perf
  30691. * if no parameter of the camera are meant to change
  30692. * @param projection Defines manually a projection if necessary
  30693. */
  30694. freezeProjectionMatrix(projection?: Matrix): void;
  30695. /**
  30696. * Unfreeze the projection matrix if it has previously been freezed by freezeProjectionMatrix.
  30697. */
  30698. unfreezeProjectionMatrix(): void;
  30699. /**
  30700. * Gets the current projection matrix of the camera.
  30701. * @param force forces the camera to recompute the matrix without looking at the cached state
  30702. * @returns the projection matrix
  30703. */
  30704. getProjectionMatrix(force?: boolean): Matrix;
  30705. /**
  30706. * Gets the transformation matrix (ie. the multiplication of view by projection matrices)
  30707. * @returns a Matrix
  30708. */
  30709. getTransformationMatrix(): Matrix;
  30710. private _updateFrustumPlanes;
  30711. /**
  30712. * Checks if a cullable object (mesh...) is in the camera frustum
  30713. * This checks the bounding box center. See isCompletelyInFrustum for a full bounding check
  30714. * @param target The object to check
  30715. * @param checkRigCameras If the rig cameras should be checked (eg. with webVR camera both eyes should be checked) (Default: false)
  30716. * @returns true if the object is in frustum otherwise false
  30717. */
  30718. isInFrustum(target: ICullable, checkRigCameras?: boolean): boolean;
  30719. /**
  30720. * Checks if a cullable object (mesh...) is in the camera frustum
  30721. * Unlike isInFrustum this cheks the full bounding box
  30722. * @param target The object to check
  30723. * @returns true if the object is in frustum otherwise false
  30724. */
  30725. isCompletelyInFrustum(target: ICullable): boolean;
  30726. /**
  30727. * Gets a ray in the forward direction from the camera.
  30728. * @param length Defines the length of the ray to create
  30729. * @param transform Defines the transform to apply to the ray, by default the world matrx is used to create a workd space ray
  30730. * @param origin Defines the start point of the ray which defaults to the camera position
  30731. * @returns the forward ray
  30732. */
  30733. getForwardRay(length?: number, transform?: Matrix, origin?: Vector3): Ray;
  30734. /**
  30735. * Gets a ray in the forward direction from the camera.
  30736. * @param refRay the ray to (re)use when setting the values
  30737. * @param length Defines the length of the ray to create
  30738. * @param transform Defines the transform to apply to the ray, by default the world matrx is used to create a workd space ray
  30739. * @param origin Defines the start point of the ray which defaults to the camera position
  30740. * @returns the forward ray
  30741. */
  30742. getForwardRayToRef(refRay: Ray, length?: number, transform?: Matrix, origin?: Vector3): Ray;
  30743. /**
  30744. * Releases resources associated with this node.
  30745. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  30746. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  30747. */
  30748. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  30749. /** @hidden */
  30750. _isLeftCamera: boolean;
  30751. /**
  30752. * Gets the left camera of a rig setup in case of Rigged Camera
  30753. */
  30754. get isLeftCamera(): boolean;
  30755. /** @hidden */
  30756. _isRightCamera: boolean;
  30757. /**
  30758. * Gets the right camera of a rig setup in case of Rigged Camera
  30759. */
  30760. get isRightCamera(): boolean;
  30761. /**
  30762. * Gets the left camera of a rig setup in case of Rigged Camera
  30763. */
  30764. get leftCamera(): Nullable<FreeCamera>;
  30765. /**
  30766. * Gets the right camera of a rig setup in case of Rigged Camera
  30767. */
  30768. get rightCamera(): Nullable<FreeCamera>;
  30769. /**
  30770. * Gets the left camera target of a rig setup in case of Rigged Camera
  30771. * @returns the target position
  30772. */
  30773. getLeftTarget(): Nullable<Vector3>;
  30774. /**
  30775. * Gets the right camera target of a rig setup in case of Rigged Camera
  30776. * @returns the target position
  30777. */
  30778. getRightTarget(): Nullable<Vector3>;
  30779. /**
  30780. * @hidden
  30781. */
  30782. setCameraRigMode(mode: number, rigParams: any): void;
  30783. /** @hidden */
  30784. static _setStereoscopicRigMode(camera: Camera): void;
  30785. /** @hidden */
  30786. static _setStereoscopicAnaglyphRigMode(camera: Camera): void;
  30787. /** @hidden */
  30788. static _setVRRigMode(camera: Camera, rigParams: any): void;
  30789. /** @hidden */
  30790. static _setWebVRRigMode(camera: Camera, rigParams: any): void;
  30791. /** @hidden */
  30792. _getVRProjectionMatrix(): Matrix;
  30793. protected _updateCameraRotationMatrix(): void;
  30794. protected _updateWebVRCameraRotationMatrix(): void;
  30795. /**
  30796. * This function MUST be overwritten by the different WebVR cameras available.
  30797. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  30798. * @hidden
  30799. */
  30800. _getWebVRProjectionMatrix(): Matrix;
  30801. /**
  30802. * This function MUST be overwritten by the different WebVR cameras available.
  30803. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  30804. * @hidden
  30805. */
  30806. _getWebVRViewMatrix(): Matrix;
  30807. /** @hidden */
  30808. setCameraRigParameter(name: string, value: any): void;
  30809. /**
  30810. * needs to be overridden by children so sub has required properties to be copied
  30811. * @hidden
  30812. */
  30813. createRigCamera(name: string, cameraIndex: number): Nullable<Camera>;
  30814. /**
  30815. * May need to be overridden by children
  30816. * @hidden
  30817. */
  30818. _updateRigCameras(): void;
  30819. /** @hidden */
  30820. _setupInputs(): void;
  30821. /**
  30822. * Serialiaze the camera setup to a json represention
  30823. * @returns the JSON representation
  30824. */
  30825. serialize(): any;
  30826. /**
  30827. * Clones the current camera.
  30828. * @param name The cloned camera name
  30829. * @returns the cloned camera
  30830. */
  30831. clone(name: string): Camera;
  30832. /**
  30833. * Gets the direction of the camera relative to a given local axis.
  30834. * @param localAxis Defines the reference axis to provide a relative direction.
  30835. * @return the direction
  30836. */
  30837. getDirection(localAxis: Vector3): Vector3;
  30838. /**
  30839. * Returns the current camera absolute rotation
  30840. */
  30841. get absoluteRotation(): Quaternion;
  30842. /**
  30843. * Gets the direction of the camera relative to a given local axis into a passed vector.
  30844. * @param localAxis Defines the reference axis to provide a relative direction.
  30845. * @param result Defines the vector to store the result in
  30846. */
  30847. getDirectionToRef(localAxis: Vector3, result: Vector3): void;
  30848. /**
  30849. * Gets a camera constructor for a given camera type
  30850. * @param type The type of the camera to construct (should be equal to one of the camera class name)
  30851. * @param name The name of the camera the result will be able to instantiate
  30852. * @param scene The scene the result will construct the camera in
  30853. * @param interaxial_distance In case of stereoscopic setup, the distance between both eyes
  30854. * @param isStereoscopicSideBySide In case of stereoscopic setup, should the sereo be side b side
  30855. * @returns a factory method to construc the camera
  30856. */
  30857. static GetConstructorFromName(type: string, name: string, scene: Scene, interaxial_distance?: number, isStereoscopicSideBySide?: boolean): () => Camera;
  30858. /**
  30859. * Compute the world matrix of the camera.
  30860. * @returns the camera world matrix
  30861. */
  30862. computeWorldMatrix(): Matrix;
  30863. /**
  30864. * Parse a JSON and creates the camera from the parsed information
  30865. * @param parsedCamera The JSON to parse
  30866. * @param scene The scene to instantiate the camera in
  30867. * @returns the newly constructed camera
  30868. */
  30869. static Parse(parsedCamera: any, scene: Scene): Camera;
  30870. }
  30871. }
  30872. declare module "babylonjs/Meshes/Builders/discBuilder" {
  30873. import { Nullable } from "babylonjs/types";
  30874. import { Scene } from "babylonjs/scene";
  30875. import { Vector4 } from "babylonjs/Maths/math.vector";
  30876. import { Mesh } from "babylonjs/Meshes/mesh";
  30877. /**
  30878. * Class containing static functions to help procedurally build meshes
  30879. */
  30880. export class DiscBuilder {
  30881. /**
  30882. * Creates a plane polygonal mesh. By default, this is a disc
  30883. * * The parameter `radius` sets the radius size (float) of the polygon (default 0.5)
  30884. * * 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
  30885. * * 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
  30886. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  30887. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  30888. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  30889. * @param name defines the name of the mesh
  30890. * @param options defines the options used to create the mesh
  30891. * @param scene defines the hosting scene
  30892. * @returns the plane polygonal mesh
  30893. * @see https://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  30894. */
  30895. static CreateDisc(name: string, options: {
  30896. radius?: number;
  30897. tessellation?: number;
  30898. arc?: number;
  30899. updatable?: boolean;
  30900. sideOrientation?: number;
  30901. frontUVs?: Vector4;
  30902. backUVs?: Vector4;
  30903. }, scene?: Nullable<Scene>): Mesh;
  30904. }
  30905. }
  30906. declare module "babylonjs/Materials/fresnelParameters" {
  30907. import { DeepImmutable } from "babylonjs/types";
  30908. import { Color3 } from "babylonjs/Maths/math.color";
  30909. /**
  30910. * Options to be used when creating a FresnelParameters.
  30911. */
  30912. export type IFresnelParametersCreationOptions = {
  30913. /**
  30914. * Define the color used on edges (grazing angle)
  30915. */
  30916. leftColor?: Color3;
  30917. /**
  30918. * Define the color used on center
  30919. */
  30920. rightColor?: Color3;
  30921. /**
  30922. * Define bias applied to computed fresnel term
  30923. */
  30924. bias?: number;
  30925. /**
  30926. * Defined the power exponent applied to fresnel term
  30927. */
  30928. power?: number;
  30929. /**
  30930. * Define if the fresnel effect is enable or not.
  30931. */
  30932. isEnabled?: boolean;
  30933. };
  30934. /**
  30935. * Serialized format for FresnelParameters.
  30936. */
  30937. export type IFresnelParametersSerialized = {
  30938. /**
  30939. * Define the color used on edges (grazing angle) [as an array]
  30940. */
  30941. leftColor: number[];
  30942. /**
  30943. * Define the color used on center [as an array]
  30944. */
  30945. rightColor: number[];
  30946. /**
  30947. * Define bias applied to computed fresnel term
  30948. */
  30949. bias: number;
  30950. /**
  30951. * Defined the power exponent applied to fresnel term
  30952. */
  30953. power?: number;
  30954. /**
  30955. * Define if the fresnel effect is enable or not.
  30956. */
  30957. isEnabled: boolean;
  30958. };
  30959. /**
  30960. * This represents all the required information to add a fresnel effect on a material:
  30961. * @see https://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  30962. */
  30963. export class FresnelParameters {
  30964. private _isEnabled;
  30965. /**
  30966. * Define if the fresnel effect is enable or not.
  30967. */
  30968. get isEnabled(): boolean;
  30969. set isEnabled(value: boolean);
  30970. /**
  30971. * Define the color used on edges (grazing angle)
  30972. */
  30973. leftColor: Color3;
  30974. /**
  30975. * Define the color used on center
  30976. */
  30977. rightColor: Color3;
  30978. /**
  30979. * Define bias applied to computed fresnel term
  30980. */
  30981. bias: number;
  30982. /**
  30983. * Defined the power exponent applied to fresnel term
  30984. */
  30985. power: number;
  30986. /**
  30987. * Creates a new FresnelParameters object.
  30988. *
  30989. * @param options provide your own settings to optionally to override defaults
  30990. */
  30991. constructor(options?: IFresnelParametersCreationOptions);
  30992. /**
  30993. * Clones the current fresnel and its valuues
  30994. * @returns a clone fresnel configuration
  30995. */
  30996. clone(): FresnelParameters;
  30997. /**
  30998. * Determines equality between FresnelParameters objects
  30999. * @param otherFresnelParameters defines the second operand
  31000. * @returns true if the power, bias, leftColor, rightColor and isEnabled values are equal to the given ones
  31001. */
  31002. equals(otherFresnelParameters: DeepImmutable<FresnelParameters>): boolean;
  31003. /**
  31004. * Serializes the current fresnel parameters to a JSON representation.
  31005. * @return the JSON serialization
  31006. */
  31007. serialize(): IFresnelParametersSerialized;
  31008. /**
  31009. * Parse a JSON object and deserialize it to a new Fresnel parameter object.
  31010. * @param parsedFresnelParameters Define the JSON representation
  31011. * @returns the parsed parameters
  31012. */
  31013. static Parse(parsedFresnelParameters: IFresnelParametersSerialized): FresnelParameters;
  31014. }
  31015. }
  31016. declare module "babylonjs/Materials/materialFlags" {
  31017. /**
  31018. * This groups all the flags used to control the materials channel.
  31019. */
  31020. export class MaterialFlags {
  31021. private static _DiffuseTextureEnabled;
  31022. /**
  31023. * Are diffuse textures enabled in the application.
  31024. */
  31025. static get DiffuseTextureEnabled(): boolean;
  31026. static set DiffuseTextureEnabled(value: boolean);
  31027. private static _DetailTextureEnabled;
  31028. /**
  31029. * Are detail textures enabled in the application.
  31030. */
  31031. static get DetailTextureEnabled(): boolean;
  31032. static set DetailTextureEnabled(value: boolean);
  31033. private static _AmbientTextureEnabled;
  31034. /**
  31035. * Are ambient textures enabled in the application.
  31036. */
  31037. static get AmbientTextureEnabled(): boolean;
  31038. static set AmbientTextureEnabled(value: boolean);
  31039. private static _OpacityTextureEnabled;
  31040. /**
  31041. * Are opacity textures enabled in the application.
  31042. */
  31043. static get OpacityTextureEnabled(): boolean;
  31044. static set OpacityTextureEnabled(value: boolean);
  31045. private static _ReflectionTextureEnabled;
  31046. /**
  31047. * Are reflection textures enabled in the application.
  31048. */
  31049. static get ReflectionTextureEnabled(): boolean;
  31050. static set ReflectionTextureEnabled(value: boolean);
  31051. private static _EmissiveTextureEnabled;
  31052. /**
  31053. * Are emissive textures enabled in the application.
  31054. */
  31055. static get EmissiveTextureEnabled(): boolean;
  31056. static set EmissiveTextureEnabled(value: boolean);
  31057. private static _SpecularTextureEnabled;
  31058. /**
  31059. * Are specular textures enabled in the application.
  31060. */
  31061. static get SpecularTextureEnabled(): boolean;
  31062. static set SpecularTextureEnabled(value: boolean);
  31063. private static _BumpTextureEnabled;
  31064. /**
  31065. * Are bump textures enabled in the application.
  31066. */
  31067. static get BumpTextureEnabled(): boolean;
  31068. static set BumpTextureEnabled(value: boolean);
  31069. private static _LightmapTextureEnabled;
  31070. /**
  31071. * Are lightmap textures enabled in the application.
  31072. */
  31073. static get LightmapTextureEnabled(): boolean;
  31074. static set LightmapTextureEnabled(value: boolean);
  31075. private static _RefractionTextureEnabled;
  31076. /**
  31077. * Are refraction textures enabled in the application.
  31078. */
  31079. static get RefractionTextureEnabled(): boolean;
  31080. static set RefractionTextureEnabled(value: boolean);
  31081. private static _ColorGradingTextureEnabled;
  31082. /**
  31083. * Are color grading textures enabled in the application.
  31084. */
  31085. static get ColorGradingTextureEnabled(): boolean;
  31086. static set ColorGradingTextureEnabled(value: boolean);
  31087. private static _FresnelEnabled;
  31088. /**
  31089. * Are fresnels enabled in the application.
  31090. */
  31091. static get FresnelEnabled(): boolean;
  31092. static set FresnelEnabled(value: boolean);
  31093. private static _ClearCoatTextureEnabled;
  31094. /**
  31095. * Are clear coat textures enabled in the application.
  31096. */
  31097. static get ClearCoatTextureEnabled(): boolean;
  31098. static set ClearCoatTextureEnabled(value: boolean);
  31099. private static _ClearCoatBumpTextureEnabled;
  31100. /**
  31101. * Are clear coat bump textures enabled in the application.
  31102. */
  31103. static get ClearCoatBumpTextureEnabled(): boolean;
  31104. static set ClearCoatBumpTextureEnabled(value: boolean);
  31105. private static _ClearCoatTintTextureEnabled;
  31106. /**
  31107. * Are clear coat tint textures enabled in the application.
  31108. */
  31109. static get ClearCoatTintTextureEnabled(): boolean;
  31110. static set ClearCoatTintTextureEnabled(value: boolean);
  31111. private static _SheenTextureEnabled;
  31112. /**
  31113. * Are sheen textures enabled in the application.
  31114. */
  31115. static get SheenTextureEnabled(): boolean;
  31116. static set SheenTextureEnabled(value: boolean);
  31117. private static _AnisotropicTextureEnabled;
  31118. /**
  31119. * Are anisotropic textures enabled in the application.
  31120. */
  31121. static get AnisotropicTextureEnabled(): boolean;
  31122. static set AnisotropicTextureEnabled(value: boolean);
  31123. private static _ThicknessTextureEnabled;
  31124. /**
  31125. * Are thickness textures enabled in the application.
  31126. */
  31127. static get ThicknessTextureEnabled(): boolean;
  31128. static set ThicknessTextureEnabled(value: boolean);
  31129. }
  31130. }
  31131. declare module "babylonjs/Shaders/ShadersInclude/defaultFragmentDeclaration" {
  31132. /** @hidden */
  31133. export var defaultFragmentDeclaration: {
  31134. name: string;
  31135. shader: string;
  31136. };
  31137. }
  31138. declare module "babylonjs/Shaders/ShadersInclude/defaultUboDeclaration" {
  31139. /** @hidden */
  31140. export var defaultUboDeclaration: {
  31141. name: string;
  31142. shader: string;
  31143. };
  31144. }
  31145. declare module "babylonjs/Shaders/ShadersInclude/prePassDeclaration" {
  31146. /** @hidden */
  31147. export var prePassDeclaration: {
  31148. name: string;
  31149. shader: string;
  31150. };
  31151. }
  31152. declare module "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration" {
  31153. /** @hidden */
  31154. export var lightFragmentDeclaration: {
  31155. name: string;
  31156. shader: string;
  31157. };
  31158. }
  31159. declare module "babylonjs/Shaders/ShadersInclude/lightUboDeclaration" {
  31160. /** @hidden */
  31161. export var lightUboDeclaration: {
  31162. name: string;
  31163. shader: string;
  31164. };
  31165. }
  31166. declare module "babylonjs/Shaders/ShadersInclude/lightsFragmentFunctions" {
  31167. /** @hidden */
  31168. export var lightsFragmentFunctions: {
  31169. name: string;
  31170. shader: string;
  31171. };
  31172. }
  31173. declare module "babylonjs/Shaders/ShadersInclude/shadowsFragmentFunctions" {
  31174. /** @hidden */
  31175. export var shadowsFragmentFunctions: {
  31176. name: string;
  31177. shader: string;
  31178. };
  31179. }
  31180. declare module "babylonjs/Shaders/ShadersInclude/fresnelFunction" {
  31181. /** @hidden */
  31182. export var fresnelFunction: {
  31183. name: string;
  31184. shader: string;
  31185. };
  31186. }
  31187. declare module "babylonjs/Shaders/ShadersInclude/bumpFragmentMainFunctions" {
  31188. /** @hidden */
  31189. export var bumpFragmentMainFunctions: {
  31190. name: string;
  31191. shader: string;
  31192. };
  31193. }
  31194. declare module "babylonjs/Shaders/ShadersInclude/bumpFragmentFunctions" {
  31195. /** @hidden */
  31196. export var bumpFragmentFunctions: {
  31197. name: string;
  31198. shader: string;
  31199. };
  31200. }
  31201. declare module "babylonjs/Shaders/ShadersInclude/logDepthDeclaration" {
  31202. /** @hidden */
  31203. export var logDepthDeclaration: {
  31204. name: string;
  31205. shader: string;
  31206. };
  31207. }
  31208. declare module "babylonjs/Shaders/ShadersInclude/bumpFragment" {
  31209. /** @hidden */
  31210. export var bumpFragment: {
  31211. name: string;
  31212. shader: string;
  31213. };
  31214. }
  31215. declare module "babylonjs/Shaders/ShadersInclude/depthPrePass" {
  31216. /** @hidden */
  31217. export var depthPrePass: {
  31218. name: string;
  31219. shader: string;
  31220. };
  31221. }
  31222. declare module "babylonjs/Shaders/ShadersInclude/lightFragment" {
  31223. /** @hidden */
  31224. export var lightFragment: {
  31225. name: string;
  31226. shader: string;
  31227. };
  31228. }
  31229. declare module "babylonjs/Shaders/ShadersInclude/logDepthFragment" {
  31230. /** @hidden */
  31231. export var logDepthFragment: {
  31232. name: string;
  31233. shader: string;
  31234. };
  31235. }
  31236. declare module "babylonjs/Shaders/default.fragment" {
  31237. import "babylonjs/Shaders/ShadersInclude/defaultFragmentDeclaration";
  31238. import "babylonjs/Shaders/ShadersInclude/defaultUboDeclaration";
  31239. import "babylonjs/Shaders/ShadersInclude/prePassDeclaration";
  31240. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  31241. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  31242. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  31243. import "babylonjs/Shaders/ShadersInclude/lightsFragmentFunctions";
  31244. import "babylonjs/Shaders/ShadersInclude/shadowsFragmentFunctions";
  31245. import "babylonjs/Shaders/ShadersInclude/fresnelFunction";
  31246. import "babylonjs/Shaders/ShadersInclude/reflectionFunction";
  31247. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  31248. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  31249. import "babylonjs/Shaders/ShadersInclude/bumpFragmentMainFunctions";
  31250. import "babylonjs/Shaders/ShadersInclude/bumpFragmentFunctions";
  31251. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration";
  31252. import "babylonjs/Shaders/ShadersInclude/logDepthDeclaration";
  31253. import "babylonjs/Shaders/ShadersInclude/fogFragmentDeclaration";
  31254. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragment";
  31255. import "babylonjs/Shaders/ShadersInclude/bumpFragment";
  31256. import "babylonjs/Shaders/ShadersInclude/depthPrePass";
  31257. import "babylonjs/Shaders/ShadersInclude/lightFragment";
  31258. import "babylonjs/Shaders/ShadersInclude/logDepthFragment";
  31259. import "babylonjs/Shaders/ShadersInclude/fogFragment";
  31260. /** @hidden */
  31261. export var defaultPixelShader: {
  31262. name: string;
  31263. shader: string;
  31264. };
  31265. }
  31266. declare module "babylonjs/Shaders/ShadersInclude/defaultVertexDeclaration" {
  31267. /** @hidden */
  31268. export var defaultVertexDeclaration: {
  31269. name: string;
  31270. shader: string;
  31271. };
  31272. }
  31273. declare module "babylonjs/Shaders/ShadersInclude/bumpVertexDeclaration" {
  31274. /** @hidden */
  31275. export var bumpVertexDeclaration: {
  31276. name: string;
  31277. shader: string;
  31278. };
  31279. }
  31280. declare module "babylonjs/Shaders/ShadersInclude/bumpVertex" {
  31281. /** @hidden */
  31282. export var bumpVertex: {
  31283. name: string;
  31284. shader: string;
  31285. };
  31286. }
  31287. declare module "babylonjs/Shaders/ShadersInclude/fogVertex" {
  31288. /** @hidden */
  31289. export var fogVertex: {
  31290. name: string;
  31291. shader: string;
  31292. };
  31293. }
  31294. declare module "babylonjs/Shaders/ShadersInclude/shadowsVertex" {
  31295. /** @hidden */
  31296. export var shadowsVertex: {
  31297. name: string;
  31298. shader: string;
  31299. };
  31300. }
  31301. declare module "babylonjs/Shaders/ShadersInclude/pointCloudVertex" {
  31302. /** @hidden */
  31303. export var pointCloudVertex: {
  31304. name: string;
  31305. shader: string;
  31306. };
  31307. }
  31308. declare module "babylonjs/Shaders/ShadersInclude/logDepthVertex" {
  31309. /** @hidden */
  31310. export var logDepthVertex: {
  31311. name: string;
  31312. shader: string;
  31313. };
  31314. }
  31315. declare module "babylonjs/Shaders/default.vertex" {
  31316. import "babylonjs/Shaders/ShadersInclude/defaultVertexDeclaration";
  31317. import "babylonjs/Shaders/ShadersInclude/defaultUboDeclaration";
  31318. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  31319. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  31320. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  31321. import "babylonjs/Shaders/ShadersInclude/bumpVertexDeclaration";
  31322. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration";
  31323. import "babylonjs/Shaders/ShadersInclude/fogVertexDeclaration";
  31324. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  31325. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  31326. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  31327. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  31328. import "babylonjs/Shaders/ShadersInclude/logDepthDeclaration";
  31329. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  31330. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  31331. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  31332. import "babylonjs/Shaders/ShadersInclude/bumpVertex";
  31333. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertex";
  31334. import "babylonjs/Shaders/ShadersInclude/fogVertex";
  31335. import "babylonjs/Shaders/ShadersInclude/shadowsVertex";
  31336. import "babylonjs/Shaders/ShadersInclude/pointCloudVertex";
  31337. import "babylonjs/Shaders/ShadersInclude/logDepthVertex";
  31338. /** @hidden */
  31339. export var defaultVertexShader: {
  31340. name: string;
  31341. shader: string;
  31342. };
  31343. }
  31344. declare module "babylonjs/Materials/material.detailMapConfiguration" {
  31345. import { Nullable } from "babylonjs/types";
  31346. import { Scene } from "babylonjs/scene";
  31347. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  31348. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  31349. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  31350. /**
  31351. * @hidden
  31352. */
  31353. export interface IMaterialDetailMapDefines {
  31354. DETAIL: boolean;
  31355. DETAILDIRECTUV: number;
  31356. DETAIL_NORMALBLENDMETHOD: number;
  31357. /** @hidden */
  31358. _areTexturesDirty: boolean;
  31359. }
  31360. /**
  31361. * Define the code related to the detail map parameters of a material
  31362. *
  31363. * Inspired from:
  31364. * 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
  31365. * Unreal: https://docs.unrealengine.com/en-US/Engine/Rendering/Materials/HowTo/DetailTexturing/index.html
  31366. * Cryengine: https://docs.cryengine.com/display/SDKDOC2/Detail+Maps
  31367. */
  31368. export class DetailMapConfiguration {
  31369. private _texture;
  31370. /**
  31371. * The detail texture of the material.
  31372. */
  31373. texture: Nullable<BaseTexture>;
  31374. /**
  31375. * Defines how strongly the detail diffuse/albedo channel is blended with the regular diffuse/albedo texture
  31376. * Bigger values mean stronger blending
  31377. */
  31378. diffuseBlendLevel: number;
  31379. /**
  31380. * Defines how strongly the detail roughness channel is blended with the regular roughness value
  31381. * Bigger values mean stronger blending. Only used with PBR materials
  31382. */
  31383. roughnessBlendLevel: number;
  31384. /**
  31385. * Defines how strong the bump effect from the detail map is
  31386. * Bigger values mean stronger effect
  31387. */
  31388. bumpLevel: number;
  31389. private _normalBlendMethod;
  31390. /**
  31391. * The method used to blend the bump and detail normals together
  31392. */
  31393. normalBlendMethod: number;
  31394. private _isEnabled;
  31395. /**
  31396. * Enable or disable the detail map on this material
  31397. */
  31398. isEnabled: boolean;
  31399. /** @hidden */
  31400. private _internalMarkAllSubMeshesAsTexturesDirty;
  31401. /** @hidden */
  31402. _markAllSubMeshesAsTexturesDirty(): void;
  31403. /**
  31404. * Instantiate a new detail map
  31405. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  31406. */
  31407. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  31408. /**
  31409. * Gets whether the submesh is ready to be used or not.
  31410. * @param defines the list of "defines" to update.
  31411. * @param scene defines the scene the material belongs to.
  31412. * @returns - boolean indicating that the submesh is ready or not.
  31413. */
  31414. isReadyForSubMesh(defines: IMaterialDetailMapDefines, scene: Scene): boolean;
  31415. /**
  31416. * Update the defines for detail map usage
  31417. * @param defines the list of "defines" to update.
  31418. * @param scene defines the scene the material belongs to.
  31419. */
  31420. prepareDefines(defines: IMaterialDetailMapDefines, scene: Scene): void;
  31421. /**
  31422. * Binds the material data.
  31423. * @param uniformBuffer defines the Uniform buffer to fill in.
  31424. * @param scene defines the scene the material belongs to.
  31425. * @param isFrozen defines whether the material is frozen or not.
  31426. */
  31427. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean): void;
  31428. /**
  31429. * Checks to see if a texture is used in the material.
  31430. * @param texture - Base texture to use.
  31431. * @returns - Boolean specifying if a texture is used in the material.
  31432. */
  31433. hasTexture(texture: BaseTexture): boolean;
  31434. /**
  31435. * Returns an array of the actively used textures.
  31436. * @param activeTextures Array of BaseTextures
  31437. */
  31438. getActiveTextures(activeTextures: BaseTexture[]): void;
  31439. /**
  31440. * Returns the animatable textures.
  31441. * @param animatables Array of animatable textures.
  31442. */
  31443. getAnimatables(animatables: IAnimatable[]): void;
  31444. /**
  31445. * Disposes the resources of the material.
  31446. * @param forceDisposeTextures - Forces the disposal of all textures.
  31447. */
  31448. dispose(forceDisposeTextures?: boolean): void;
  31449. /**
  31450. * Get the current class name useful for serialization or dynamic coding.
  31451. * @returns "DetailMap"
  31452. */
  31453. getClassName(): string;
  31454. /**
  31455. * Add the required uniforms to the current list.
  31456. * @param uniforms defines the current uniform list.
  31457. */
  31458. static AddUniforms(uniforms: string[]): void;
  31459. /**
  31460. * Add the required samplers to the current list.
  31461. * @param samplers defines the current sampler list.
  31462. */
  31463. static AddSamplers(samplers: string[]): void;
  31464. /**
  31465. * Add the required uniforms to the current buffer.
  31466. * @param uniformBuffer defines the current uniform buffer.
  31467. */
  31468. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  31469. /**
  31470. * Makes a duplicate of the current instance into another one.
  31471. * @param detailMap define the instance where to copy the info
  31472. */
  31473. copyTo(detailMap: DetailMapConfiguration): void;
  31474. /**
  31475. * Serializes this detail map instance
  31476. * @returns - An object with the serialized instance.
  31477. */
  31478. serialize(): any;
  31479. /**
  31480. * Parses a detail map setting from a serialized object.
  31481. * @param source - Serialized object.
  31482. * @param scene Defines the scene we are parsing for
  31483. * @param rootUrl Defines the rootUrl to load from
  31484. */
  31485. parse(source: any, scene: Scene, rootUrl: string): void;
  31486. }
  31487. }
  31488. declare module "babylonjs/Materials/standardMaterial" {
  31489. import { SmartArray } from "babylonjs/Misc/smartArray";
  31490. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  31491. import { Nullable } from "babylonjs/types";
  31492. import { Scene } from "babylonjs/scene";
  31493. import { Matrix } from "babylonjs/Maths/math.vector";
  31494. import { Color3 } from "babylonjs/Maths/math.color";
  31495. import { SubMesh } from "babylonjs/Meshes/subMesh";
  31496. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  31497. import { Mesh } from "babylonjs/Meshes/mesh";
  31498. import { ImageProcessingConfiguration, IImageProcessingConfigurationDefines } from "babylonjs/Materials/imageProcessingConfiguration";
  31499. import { ColorCurves } from "babylonjs/Materials/colorCurves";
  31500. import { FresnelParameters } from "babylonjs/Materials/fresnelParameters";
  31501. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  31502. import { PushMaterial } from "babylonjs/Materials/pushMaterial";
  31503. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  31504. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  31505. import "babylonjs/Shaders/default.fragment";
  31506. import "babylonjs/Shaders/default.vertex";
  31507. import { IMaterialDetailMapDefines, DetailMapConfiguration } from "babylonjs/Materials/material.detailMapConfiguration";
  31508. /** @hidden */
  31509. export class StandardMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines, IMaterialDetailMapDefines {
  31510. MAINUV1: boolean;
  31511. MAINUV2: boolean;
  31512. DIFFUSE: boolean;
  31513. DIFFUSEDIRECTUV: number;
  31514. DETAIL: boolean;
  31515. DETAILDIRECTUV: number;
  31516. DETAIL_NORMALBLENDMETHOD: number;
  31517. AMBIENT: boolean;
  31518. AMBIENTDIRECTUV: number;
  31519. OPACITY: boolean;
  31520. OPACITYDIRECTUV: number;
  31521. OPACITYRGB: boolean;
  31522. REFLECTION: boolean;
  31523. EMISSIVE: boolean;
  31524. EMISSIVEDIRECTUV: number;
  31525. SPECULAR: boolean;
  31526. SPECULARDIRECTUV: number;
  31527. BUMP: boolean;
  31528. BUMPDIRECTUV: number;
  31529. PARALLAX: boolean;
  31530. PARALLAXOCCLUSION: boolean;
  31531. SPECULAROVERALPHA: boolean;
  31532. CLIPPLANE: boolean;
  31533. CLIPPLANE2: boolean;
  31534. CLIPPLANE3: boolean;
  31535. CLIPPLANE4: boolean;
  31536. CLIPPLANE5: boolean;
  31537. CLIPPLANE6: boolean;
  31538. ALPHATEST: boolean;
  31539. DEPTHPREPASS: boolean;
  31540. ALPHAFROMDIFFUSE: boolean;
  31541. POINTSIZE: boolean;
  31542. FOG: boolean;
  31543. SPECULARTERM: boolean;
  31544. DIFFUSEFRESNEL: boolean;
  31545. OPACITYFRESNEL: boolean;
  31546. REFLECTIONFRESNEL: boolean;
  31547. REFRACTIONFRESNEL: boolean;
  31548. EMISSIVEFRESNEL: boolean;
  31549. FRESNEL: boolean;
  31550. NORMAL: boolean;
  31551. UV1: boolean;
  31552. UV2: boolean;
  31553. VERTEXCOLOR: boolean;
  31554. VERTEXALPHA: boolean;
  31555. NUM_BONE_INFLUENCERS: number;
  31556. BonesPerMesh: number;
  31557. BONETEXTURE: boolean;
  31558. INSTANCES: boolean;
  31559. THIN_INSTANCES: boolean;
  31560. GLOSSINESS: boolean;
  31561. ROUGHNESS: boolean;
  31562. EMISSIVEASILLUMINATION: boolean;
  31563. LINKEMISSIVEWITHDIFFUSE: boolean;
  31564. REFLECTIONFRESNELFROMSPECULAR: boolean;
  31565. LIGHTMAP: boolean;
  31566. LIGHTMAPDIRECTUV: number;
  31567. OBJECTSPACE_NORMALMAP: boolean;
  31568. USELIGHTMAPASSHADOWMAP: boolean;
  31569. REFLECTIONMAP_3D: boolean;
  31570. REFLECTIONMAP_SPHERICAL: boolean;
  31571. REFLECTIONMAP_PLANAR: boolean;
  31572. REFLECTIONMAP_CUBIC: boolean;
  31573. USE_LOCAL_REFLECTIONMAP_CUBIC: boolean;
  31574. REFLECTIONMAP_PROJECTION: boolean;
  31575. REFLECTIONMAP_SKYBOX: boolean;
  31576. REFLECTIONMAP_EXPLICIT: boolean;
  31577. REFLECTIONMAP_EQUIRECTANGULAR: boolean;
  31578. REFLECTIONMAP_EQUIRECTANGULAR_FIXED: boolean;
  31579. REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED: boolean;
  31580. INVERTCUBICMAP: boolean;
  31581. LOGARITHMICDEPTH: boolean;
  31582. REFRACTION: boolean;
  31583. REFRACTIONMAP_3D: boolean;
  31584. REFLECTIONOVERALPHA: boolean;
  31585. TWOSIDEDLIGHTING: boolean;
  31586. SHADOWFLOAT: boolean;
  31587. MORPHTARGETS: boolean;
  31588. MORPHTARGETS_NORMAL: boolean;
  31589. MORPHTARGETS_TANGENT: boolean;
  31590. MORPHTARGETS_UV: boolean;
  31591. NUM_MORPH_INFLUENCERS: number;
  31592. NONUNIFORMSCALING: boolean;
  31593. PREMULTIPLYALPHA: boolean;
  31594. ALPHATEST_AFTERALLALPHACOMPUTATIONS: boolean;
  31595. ALPHABLEND: boolean;
  31596. PREPASS: boolean;
  31597. SCENE_MRT_COUNT: number;
  31598. RGBDLIGHTMAP: boolean;
  31599. RGBDREFLECTION: boolean;
  31600. RGBDREFRACTION: boolean;
  31601. IMAGEPROCESSING: boolean;
  31602. VIGNETTE: boolean;
  31603. VIGNETTEBLENDMODEMULTIPLY: boolean;
  31604. VIGNETTEBLENDMODEOPAQUE: boolean;
  31605. TONEMAPPING: boolean;
  31606. TONEMAPPING_ACES: boolean;
  31607. CONTRAST: boolean;
  31608. COLORCURVES: boolean;
  31609. COLORGRADING: boolean;
  31610. COLORGRADING3D: boolean;
  31611. SAMPLER3DGREENDEPTH: boolean;
  31612. SAMPLER3DBGRMAP: boolean;
  31613. IMAGEPROCESSINGPOSTPROCESS: boolean;
  31614. MULTIVIEW: boolean;
  31615. /**
  31616. * If the reflection texture on this material is in linear color space
  31617. * @hidden
  31618. */
  31619. IS_REFLECTION_LINEAR: boolean;
  31620. /**
  31621. * If the refraction texture on this material is in linear color space
  31622. * @hidden
  31623. */
  31624. IS_REFRACTION_LINEAR: boolean;
  31625. EXPOSURE: boolean;
  31626. constructor();
  31627. setReflectionMode(modeToEnable: string): void;
  31628. }
  31629. /**
  31630. * This is the default material used in Babylon. It is the best trade off between quality
  31631. * and performances.
  31632. * @see https://doc.babylonjs.com/babylon101/materials
  31633. */
  31634. export class StandardMaterial extends PushMaterial {
  31635. private _diffuseTexture;
  31636. /**
  31637. * The basic texture of the material as viewed under a light.
  31638. */
  31639. diffuseTexture: Nullable<BaseTexture>;
  31640. private _ambientTexture;
  31641. /**
  31642. * AKA Occlusion Texture in other nomenclature, it helps adding baked shadows into your material.
  31643. */
  31644. ambientTexture: Nullable<BaseTexture>;
  31645. private _opacityTexture;
  31646. /**
  31647. * Define the transparency of the material from a texture.
  31648. * The final alpha value can be read either from the red channel (if texture.getAlphaFromRGB is false)
  31649. * or from the luminance or the current texel (if texture.getAlphaFromRGB is true)
  31650. */
  31651. opacityTexture: Nullable<BaseTexture>;
  31652. private _reflectionTexture;
  31653. /**
  31654. * Define the texture used to display the reflection.
  31655. * @see https://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  31656. */
  31657. reflectionTexture: Nullable<BaseTexture>;
  31658. private _emissiveTexture;
  31659. /**
  31660. * Define texture of the material as if self lit.
  31661. * This will be mixed in the final result even in the absence of light.
  31662. */
  31663. emissiveTexture: Nullable<BaseTexture>;
  31664. private _specularTexture;
  31665. /**
  31666. * Define how the color and intensity of the highlight given by the light in the material.
  31667. */
  31668. specularTexture: Nullable<BaseTexture>;
  31669. private _bumpTexture;
  31670. /**
  31671. * Bump mapping is a technique to simulate bump and dents on a rendered surface.
  31672. * 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.
  31673. * @see https://doc.babylonjs.com/how_to/more_materials#bump-map
  31674. */
  31675. bumpTexture: Nullable<BaseTexture>;
  31676. private _lightmapTexture;
  31677. /**
  31678. * Complex lighting can be computationally expensive to compute at runtime.
  31679. * To save on computation, lightmaps may be used to store calculated lighting in a texture which will be applied to a given mesh.
  31680. * @see https://doc.babylonjs.com/babylon101/lights#lightmaps
  31681. */
  31682. lightmapTexture: Nullable<BaseTexture>;
  31683. private _refractionTexture;
  31684. /**
  31685. * Define the texture used to display the refraction.
  31686. * @see https://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  31687. */
  31688. refractionTexture: Nullable<BaseTexture>;
  31689. /**
  31690. * The color of the material lit by the environmental background lighting.
  31691. * @see https://doc.babylonjs.com/babylon101/materials#ambient-color-example
  31692. */
  31693. ambientColor: Color3;
  31694. /**
  31695. * The basic color of the material as viewed under a light.
  31696. */
  31697. diffuseColor: Color3;
  31698. /**
  31699. * Define how the color and intensity of the highlight given by the light in the material.
  31700. */
  31701. specularColor: Color3;
  31702. /**
  31703. * Define the color of the material as if self lit.
  31704. * This will be mixed in the final result even in the absence of light.
  31705. */
  31706. emissiveColor: Color3;
  31707. /**
  31708. * Defines how sharp are the highlights in the material.
  31709. * The bigger the value the sharper giving a more glossy feeling to the result.
  31710. * Reversely, the smaller the value the blurrier giving a more rough feeling to the result.
  31711. */
  31712. specularPower: number;
  31713. private _useAlphaFromDiffuseTexture;
  31714. /**
  31715. * Does the transparency come from the diffuse texture alpha channel.
  31716. */
  31717. useAlphaFromDiffuseTexture: boolean;
  31718. private _useEmissiveAsIllumination;
  31719. /**
  31720. * If true, the emissive value is added into the end result, otherwise it is multiplied in.
  31721. */
  31722. useEmissiveAsIllumination: boolean;
  31723. private _linkEmissiveWithDiffuse;
  31724. /**
  31725. * If true, some kind of energy conservation will prevent the end result to be more than 1 by reducing
  31726. * the emissive level when the final color is close to one.
  31727. */
  31728. linkEmissiveWithDiffuse: boolean;
  31729. private _useSpecularOverAlpha;
  31730. /**
  31731. * Specifies that the material will keep the specular highlights over a transparent surface (only the most limunous ones).
  31732. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  31733. */
  31734. useSpecularOverAlpha: boolean;
  31735. private _useReflectionOverAlpha;
  31736. /**
  31737. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  31738. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  31739. */
  31740. useReflectionOverAlpha: boolean;
  31741. private _disableLighting;
  31742. /**
  31743. * Does lights from the scene impacts this material.
  31744. * It can be a nice trick for performance to disable lighting on a fully emissive material.
  31745. */
  31746. disableLighting: boolean;
  31747. private _useObjectSpaceNormalMap;
  31748. /**
  31749. * Allows using an object space normal map (instead of tangent space).
  31750. */
  31751. useObjectSpaceNormalMap: boolean;
  31752. private _useParallax;
  31753. /**
  31754. * Is parallax enabled or not.
  31755. * @see https://doc.babylonjs.com/how_to/using_parallax_mapping
  31756. */
  31757. useParallax: boolean;
  31758. private _useParallaxOcclusion;
  31759. /**
  31760. * Is parallax occlusion enabled or not.
  31761. * If true, the outcome is way more realistic than traditional Parallax but you can expect a performance hit that worthes consideration.
  31762. * @see https://doc.babylonjs.com/how_to/using_parallax_mapping
  31763. */
  31764. useParallaxOcclusion: boolean;
  31765. /**
  31766. * 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.
  31767. */
  31768. parallaxScaleBias: number;
  31769. private _roughness;
  31770. /**
  31771. * Helps to define how blurry the reflections should appears in the material.
  31772. */
  31773. roughness: number;
  31774. /**
  31775. * In case of refraction, define the value of the index of refraction.
  31776. * @see https://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  31777. */
  31778. indexOfRefraction: number;
  31779. /**
  31780. * Invert the refraction texture alongside the y axis.
  31781. * It can be useful with procedural textures or probe for instance.
  31782. * @see https://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  31783. */
  31784. invertRefractionY: boolean;
  31785. /**
  31786. * Defines the alpha limits in alpha test mode.
  31787. */
  31788. alphaCutOff: number;
  31789. private _useLightmapAsShadowmap;
  31790. /**
  31791. * In case of light mapping, define whether the map contains light or shadow informations.
  31792. */
  31793. useLightmapAsShadowmap: boolean;
  31794. private _diffuseFresnelParameters;
  31795. /**
  31796. * Define the diffuse fresnel parameters of the material.
  31797. * @see https://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  31798. */
  31799. diffuseFresnelParameters: FresnelParameters;
  31800. private _opacityFresnelParameters;
  31801. /**
  31802. * Define the opacity fresnel parameters of the material.
  31803. * @see https://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  31804. */
  31805. opacityFresnelParameters: FresnelParameters;
  31806. private _reflectionFresnelParameters;
  31807. /**
  31808. * Define the reflection fresnel parameters of the material.
  31809. * @see https://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  31810. */
  31811. reflectionFresnelParameters: FresnelParameters;
  31812. private _refractionFresnelParameters;
  31813. /**
  31814. * Define the refraction fresnel parameters of the material.
  31815. * @see https://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  31816. */
  31817. refractionFresnelParameters: FresnelParameters;
  31818. private _emissiveFresnelParameters;
  31819. /**
  31820. * Define the emissive fresnel parameters of the material.
  31821. * @see https://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  31822. */
  31823. emissiveFresnelParameters: FresnelParameters;
  31824. private _useReflectionFresnelFromSpecular;
  31825. /**
  31826. * If true automatically deducts the fresnels values from the material specularity.
  31827. * @see https://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  31828. */
  31829. useReflectionFresnelFromSpecular: boolean;
  31830. private _useGlossinessFromSpecularMapAlpha;
  31831. /**
  31832. * Defines if the glossiness/roughness of the material should be read from the specular map alpha channel
  31833. */
  31834. useGlossinessFromSpecularMapAlpha: boolean;
  31835. private _maxSimultaneousLights;
  31836. /**
  31837. * Defines the maximum number of lights that can be used in the material
  31838. */
  31839. maxSimultaneousLights: number;
  31840. private _invertNormalMapX;
  31841. /**
  31842. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  31843. */
  31844. invertNormalMapX: boolean;
  31845. private _invertNormalMapY;
  31846. /**
  31847. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  31848. */
  31849. invertNormalMapY: boolean;
  31850. private _twoSidedLighting;
  31851. /**
  31852. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  31853. */
  31854. twoSidedLighting: boolean;
  31855. /**
  31856. * Default configuration related to image processing available in the standard Material.
  31857. */
  31858. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  31859. /**
  31860. * Gets the image processing configuration used either in this material.
  31861. */
  31862. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  31863. /**
  31864. * Sets the Default image processing configuration used either in the this material.
  31865. *
  31866. * If sets to null, the scene one is in use.
  31867. */
  31868. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  31869. /**
  31870. * Keep track of the image processing observer to allow dispose and replace.
  31871. */
  31872. private _imageProcessingObserver;
  31873. /**
  31874. * Attaches a new image processing configuration to the Standard Material.
  31875. * @param configuration
  31876. */
  31877. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  31878. /**
  31879. * Gets wether the color curves effect is enabled.
  31880. */
  31881. get cameraColorCurvesEnabled(): boolean;
  31882. /**
  31883. * Sets wether the color curves effect is enabled.
  31884. */
  31885. set cameraColorCurvesEnabled(value: boolean);
  31886. /**
  31887. * Gets wether the color grading effect is enabled.
  31888. */
  31889. get cameraColorGradingEnabled(): boolean;
  31890. /**
  31891. * Gets wether the color grading effect is enabled.
  31892. */
  31893. set cameraColorGradingEnabled(value: boolean);
  31894. /**
  31895. * Gets wether tonemapping is enabled or not.
  31896. */
  31897. get cameraToneMappingEnabled(): boolean;
  31898. /**
  31899. * Sets wether tonemapping is enabled or not
  31900. */
  31901. set cameraToneMappingEnabled(value: boolean);
  31902. /**
  31903. * The camera exposure used on this material.
  31904. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  31905. * This corresponds to a photographic exposure.
  31906. */
  31907. get cameraExposure(): number;
  31908. /**
  31909. * The camera exposure used on this material.
  31910. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  31911. * This corresponds to a photographic exposure.
  31912. */
  31913. set cameraExposure(value: number);
  31914. /**
  31915. * Gets The camera contrast used on this material.
  31916. */
  31917. get cameraContrast(): number;
  31918. /**
  31919. * Sets The camera contrast used on this material.
  31920. */
  31921. set cameraContrast(value: number);
  31922. /**
  31923. * Gets the Color Grading 2D Lookup Texture.
  31924. */
  31925. get cameraColorGradingTexture(): Nullable<BaseTexture>;
  31926. /**
  31927. * Sets the Color Grading 2D Lookup Texture.
  31928. */
  31929. set cameraColorGradingTexture(value: Nullable<BaseTexture>);
  31930. /**
  31931. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  31932. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  31933. * 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;
  31934. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  31935. */
  31936. get cameraColorCurves(): Nullable<ColorCurves>;
  31937. /**
  31938. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  31939. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  31940. * 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;
  31941. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  31942. */
  31943. set cameraColorCurves(value: Nullable<ColorCurves>);
  31944. /**
  31945. * Can this material render to several textures at once
  31946. */
  31947. get canRenderToMRT(): boolean;
  31948. /**
  31949. * Defines the detail map parameters for the material.
  31950. */
  31951. readonly detailMap: DetailMapConfiguration;
  31952. protected _renderTargets: SmartArray<RenderTargetTexture>;
  31953. protected _worldViewProjectionMatrix: Matrix;
  31954. protected _globalAmbientColor: Color3;
  31955. protected _useLogarithmicDepth: boolean;
  31956. protected _rebuildInParallel: boolean;
  31957. /**
  31958. * Instantiates a new standard material.
  31959. * This is the default material used in Babylon. It is the best trade off between quality
  31960. * and performances.
  31961. * @see https://doc.babylonjs.com/babylon101/materials
  31962. * @param name Define the name of the material in the scene
  31963. * @param scene Define the scene the material belong to
  31964. */
  31965. constructor(name: string, scene: Scene);
  31966. /**
  31967. * Gets a boolean indicating that current material needs to register RTT
  31968. */
  31969. get hasRenderTargetTextures(): boolean;
  31970. /**
  31971. * Gets the current class name of the material e.g. "StandardMaterial"
  31972. * Mainly use in serialization.
  31973. * @returns the class name
  31974. */
  31975. getClassName(): string;
  31976. /**
  31977. * In case the depth buffer does not allow enough depth precision for your scene (might be the case in large scenes)
  31978. * You can try switching to logarithmic depth.
  31979. * @see https://doc.babylonjs.com/how_to/using_logarithmic_depth_buffer
  31980. */
  31981. get useLogarithmicDepth(): boolean;
  31982. set useLogarithmicDepth(value: boolean);
  31983. /**
  31984. * Specifies if the material will require alpha blending
  31985. * @returns a boolean specifying if alpha blending is needed
  31986. */
  31987. needAlphaBlending(): boolean;
  31988. /**
  31989. * Specifies if this material should be rendered in alpha test mode
  31990. * @returns a boolean specifying if an alpha test is needed.
  31991. */
  31992. needAlphaTesting(): boolean;
  31993. protected _shouldUseAlphaFromDiffuseTexture(): boolean;
  31994. /**
  31995. * Get the texture used for alpha test purpose.
  31996. * @returns the diffuse texture in case of the standard material.
  31997. */
  31998. getAlphaTestTexture(): Nullable<BaseTexture>;
  31999. /**
  32000. * Get if the submesh is ready to be used and all its information available.
  32001. * Child classes can use it to update shaders
  32002. * @param mesh defines the mesh to check
  32003. * @param subMesh defines which submesh to check
  32004. * @param useInstances specifies that instances should be used
  32005. * @returns a boolean indicating that the submesh is ready or not
  32006. */
  32007. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  32008. /**
  32009. * Builds the material UBO layouts.
  32010. * Used internally during the effect preparation.
  32011. */
  32012. buildUniformLayout(): void;
  32013. /**
  32014. * Unbinds the material from the mesh
  32015. */
  32016. unbind(): void;
  32017. /**
  32018. * Binds the submesh to this material by preparing the effect and shader to draw
  32019. * @param world defines the world transformation matrix
  32020. * @param mesh defines the mesh containing the submesh
  32021. * @param subMesh defines the submesh to bind the material to
  32022. */
  32023. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  32024. /**
  32025. * Get the list of animatables in the material.
  32026. * @returns the list of animatables object used in the material
  32027. */
  32028. getAnimatables(): IAnimatable[];
  32029. /**
  32030. * Gets the active textures from the material
  32031. * @returns an array of textures
  32032. */
  32033. getActiveTextures(): BaseTexture[];
  32034. /**
  32035. * Specifies if the material uses a texture
  32036. * @param texture defines the texture to check against the material
  32037. * @returns a boolean specifying if the material uses the texture
  32038. */
  32039. hasTexture(texture: BaseTexture): boolean;
  32040. /**
  32041. * Disposes the material
  32042. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  32043. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  32044. */
  32045. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  32046. /**
  32047. * Makes a duplicate of the material, and gives it a new name
  32048. * @param name defines the new name for the duplicated material
  32049. * @returns the cloned material
  32050. */
  32051. clone(name: string): StandardMaterial;
  32052. /**
  32053. * Serializes this material in a JSON representation
  32054. * @returns the serialized material object
  32055. */
  32056. serialize(): any;
  32057. /**
  32058. * Creates a standard material from parsed material data
  32059. * @param source defines the JSON representation of the material
  32060. * @param scene defines the hosting scene
  32061. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  32062. * @returns a new standard material
  32063. */
  32064. static Parse(source: any, scene: Scene, rootUrl: string): StandardMaterial;
  32065. /**
  32066. * Are diffuse textures enabled in the application.
  32067. */
  32068. static get DiffuseTextureEnabled(): boolean;
  32069. static set DiffuseTextureEnabled(value: boolean);
  32070. /**
  32071. * Are detail textures enabled in the application.
  32072. */
  32073. static get DetailTextureEnabled(): boolean;
  32074. static set DetailTextureEnabled(value: boolean);
  32075. /**
  32076. * Are ambient textures enabled in the application.
  32077. */
  32078. static get AmbientTextureEnabled(): boolean;
  32079. static set AmbientTextureEnabled(value: boolean);
  32080. /**
  32081. * Are opacity textures enabled in the application.
  32082. */
  32083. static get OpacityTextureEnabled(): boolean;
  32084. static set OpacityTextureEnabled(value: boolean);
  32085. /**
  32086. * Are reflection textures enabled in the application.
  32087. */
  32088. static get ReflectionTextureEnabled(): boolean;
  32089. static set ReflectionTextureEnabled(value: boolean);
  32090. /**
  32091. * Are emissive textures enabled in the application.
  32092. */
  32093. static get EmissiveTextureEnabled(): boolean;
  32094. static set EmissiveTextureEnabled(value: boolean);
  32095. /**
  32096. * Are specular textures enabled in the application.
  32097. */
  32098. static get SpecularTextureEnabled(): boolean;
  32099. static set SpecularTextureEnabled(value: boolean);
  32100. /**
  32101. * Are bump textures enabled in the application.
  32102. */
  32103. static get BumpTextureEnabled(): boolean;
  32104. static set BumpTextureEnabled(value: boolean);
  32105. /**
  32106. * Are lightmap textures enabled in the application.
  32107. */
  32108. static get LightmapTextureEnabled(): boolean;
  32109. static set LightmapTextureEnabled(value: boolean);
  32110. /**
  32111. * Are refraction textures enabled in the application.
  32112. */
  32113. static get RefractionTextureEnabled(): boolean;
  32114. static set RefractionTextureEnabled(value: boolean);
  32115. /**
  32116. * Are color grading textures enabled in the application.
  32117. */
  32118. static get ColorGradingTextureEnabled(): boolean;
  32119. static set ColorGradingTextureEnabled(value: boolean);
  32120. /**
  32121. * Are fresnels enabled in the application.
  32122. */
  32123. static get FresnelEnabled(): boolean;
  32124. static set FresnelEnabled(value: boolean);
  32125. }
  32126. }
  32127. declare module "babylonjs/Particles/solidParticleSystem" {
  32128. import { Nullable } from "babylonjs/types";
  32129. import { Mesh } from "babylonjs/Meshes/mesh";
  32130. import { Scene, IDisposable } from "babylonjs/scene";
  32131. import { DepthSortedParticle, SolidParticle, SolidParticleVertex } from "babylonjs/Particles/solidParticle";
  32132. import { Material } from "babylonjs/Materials/material";
  32133. import { MultiMaterial } from "babylonjs/Materials/multiMaterial";
  32134. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  32135. /**
  32136. * The SPS is a single updatable mesh. The solid particles are simply separate parts or faces fo this big mesh.
  32137. *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.
  32138. * The SPS is also a particle system. It provides some methods to manage the particles.
  32139. * However it is behavior agnostic. This means it has no emitter, no particle physics, no particle recycler. You have to implement your own behavior.
  32140. *
  32141. * Full documentation here : https://doc.babylonjs.com/how_to/Solid_Particle_System
  32142. */
  32143. export class SolidParticleSystem implements IDisposable {
  32144. /**
  32145. * The SPS array of Solid Particle objects. Just access each particle as with any classic array.
  32146. * Example : var p = SPS.particles[i];
  32147. */
  32148. particles: SolidParticle[];
  32149. /**
  32150. * The SPS total number of particles. Read only. Use SPS.counter instead if you need to set your own value.
  32151. */
  32152. nbParticles: number;
  32153. /**
  32154. * If the particles must ever face the camera (default false). Useful for planar particles.
  32155. */
  32156. billboard: boolean;
  32157. /**
  32158. * Recompute normals when adding a shape
  32159. */
  32160. recomputeNormals: boolean;
  32161. /**
  32162. * This a counter ofr your own usage. It's not set by any SPS functions.
  32163. */
  32164. counter: number;
  32165. /**
  32166. * The SPS name. This name is also given to the underlying mesh.
  32167. */
  32168. name: string;
  32169. /**
  32170. * The SPS mesh. It's a standard BJS Mesh, so all the methods from the Mesh class are avalaible.
  32171. */
  32172. mesh: Mesh;
  32173. /**
  32174. * This empty object is intended to store some SPS specific or temporary values in order to lower the Garbage Collector activity.
  32175. * Please read : https://doc.babylonjs.com/how_to/Solid_Particle_System#garbage-collector-concerns
  32176. */
  32177. vars: any;
  32178. /**
  32179. * This array is populated when the SPS is set as 'pickable'.
  32180. * Each key of this array is a `faceId` value that you can get from a pickResult object.
  32181. * Each element of this array is an object `{idx: int, faceId: int}`.
  32182. * `idx` is the picked particle index in the `SPS.particles` array
  32183. * `faceId` is the picked face index counted within this particle.
  32184. * This array is the first element of the pickedBySubMesh array : sps.pickBySubMesh[0].
  32185. * It's not pertinent to use it when using a SPS with the support for MultiMaterial enabled.
  32186. * Use the method SPS.pickedParticle(pickingInfo) instead.
  32187. * Please read : https://doc.babylonjs.com/how_to/Solid_Particle_System#pickable-particles
  32188. */
  32189. pickedParticles: {
  32190. idx: number;
  32191. faceId: number;
  32192. }[];
  32193. /**
  32194. * This array is populated when the SPS is set as 'pickable'
  32195. * Each key of this array is a submesh index.
  32196. * Each element of this array is a second array defined like this :
  32197. * Each key of this second array is a `faceId` value that you can get from a pickResult object.
  32198. * Each element of this second array is an object `{idx: int, faceId: int}`.
  32199. * `idx` is the picked particle index in the `SPS.particles` array
  32200. * `faceId` is the picked face index counted within this particle.
  32201. * It's better to use the method SPS.pickedParticle(pickingInfo) rather than using directly this array.
  32202. * Please read : https://doc.babylonjs.com/how_to/Solid_Particle_System#pickable-particles
  32203. */
  32204. pickedBySubMesh: {
  32205. idx: number;
  32206. faceId: number;
  32207. }[][];
  32208. /**
  32209. * This array is populated when `enableDepthSort` is set to true.
  32210. * Each element of this array is an instance of the class DepthSortedParticle.
  32211. */
  32212. depthSortedParticles: DepthSortedParticle[];
  32213. /**
  32214. * If the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster). (Internal use only)
  32215. * @hidden
  32216. */
  32217. _bSphereOnly: boolean;
  32218. /**
  32219. * A number to multiply the boundind sphere radius by in order to reduce it for instance. (Internal use only)
  32220. * @hidden
  32221. */
  32222. _bSphereRadiusFactor: number;
  32223. private _scene;
  32224. private _positions;
  32225. private _indices;
  32226. private _normals;
  32227. private _colors;
  32228. private _uvs;
  32229. private _indices32;
  32230. private _positions32;
  32231. private _normals32;
  32232. private _fixedNormal32;
  32233. private _colors32;
  32234. private _uvs32;
  32235. private _index;
  32236. private _updatable;
  32237. private _pickable;
  32238. private _isVisibilityBoxLocked;
  32239. private _alwaysVisible;
  32240. private _depthSort;
  32241. private _expandable;
  32242. private _shapeCounter;
  32243. private _copy;
  32244. private _color;
  32245. private _computeParticleColor;
  32246. private _computeParticleTexture;
  32247. private _computeParticleRotation;
  32248. private _computeParticleVertex;
  32249. private _computeBoundingBox;
  32250. private _depthSortParticles;
  32251. private _camera;
  32252. private _mustUnrotateFixedNormals;
  32253. private _particlesIntersect;
  32254. private _needs32Bits;
  32255. private _isNotBuilt;
  32256. private _lastParticleId;
  32257. private _idxOfId;
  32258. private _multimaterialEnabled;
  32259. private _useModelMaterial;
  32260. private _indicesByMaterial;
  32261. private _materialIndexes;
  32262. private _depthSortFunction;
  32263. private _materialSortFunction;
  32264. private _materials;
  32265. private _multimaterial;
  32266. private _materialIndexesById;
  32267. private _defaultMaterial;
  32268. private _autoUpdateSubMeshes;
  32269. private _tmpVertex;
  32270. /**
  32271. * Creates a SPS (Solid Particle System) object.
  32272. * @param name (String) is the SPS name, this will be the underlying mesh name.
  32273. * @param scene (Scene) is the scene in which the SPS is added.
  32274. * @param options defines the options of the sps e.g.
  32275. * * updatable (optional boolean, default true) : if the SPS must be updatable or immutable.
  32276. * * isPickable (optional boolean, default false) : if the solid particles must be pickable.
  32277. * * enableDepthSort (optional boolean, default false) : if the solid particles must be sorted in the geometry according to their distance to the camera.
  32278. * * 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.
  32279. * * enableMultiMaterial (optional boolean, default false) : if the solid particles can be given different materials.
  32280. * * expandable (optional boolean, default false) : if particles can still be added after the initial SPS mesh creation.
  32281. * * particleIntersection (optional boolean, default false) : if the solid particle intersections must be computed.
  32282. * * boundingSphereOnly (optional boolean, default false) : if the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster).
  32283. * * bSphereRadiusFactor (optional float, default 1.0) : a number to multiply the boundind sphere radius by in order to reduce it for instance.
  32284. * @example bSphereRadiusFactor = 1.0 / Math.sqrt(3.0) => the bounding sphere exactly matches a spherical mesh.
  32285. */
  32286. constructor(name: string, scene: Scene, options?: {
  32287. updatable?: boolean;
  32288. isPickable?: boolean;
  32289. enableDepthSort?: boolean;
  32290. particleIntersection?: boolean;
  32291. boundingSphereOnly?: boolean;
  32292. bSphereRadiusFactor?: number;
  32293. expandable?: boolean;
  32294. useModelMaterial?: boolean;
  32295. enableMultiMaterial?: boolean;
  32296. });
  32297. /**
  32298. * Builds the SPS underlying mesh. Returns a standard Mesh.
  32299. * If no model shape was added to the SPS, the returned mesh is just a single triangular plane.
  32300. * @returns the created mesh
  32301. */
  32302. buildMesh(): Mesh;
  32303. /**
  32304. * Digests the mesh and generates as many solid particles in the system as wanted. Returns the SPS.
  32305. * These particles will have the same geometry than the mesh parts and will be positioned at the same localisation than the mesh original places.
  32306. * Thus the particles generated from `digest()` have their property `position` set yet.
  32307. * @param mesh ( Mesh ) is the mesh to be digested
  32308. * @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
  32309. * {delta} (optional integer, default 0) is the random extra number of facets per particle , each particle will have between `facetNb` and `facetNb + delta` facets
  32310. * {number} (optional positive integer) is the wanted number of particles : each particle is built with `mesh_total_facets / number` facets
  32311. * {storage} (optional existing array) is an array where the particles will be stored for a further use instead of being inserted in the SPS.
  32312. * @returns the current SPS
  32313. */
  32314. digest(mesh: Mesh, options?: {
  32315. facetNb?: number;
  32316. number?: number;
  32317. delta?: number;
  32318. storage?: [];
  32319. }): SolidParticleSystem;
  32320. /**
  32321. * Unrotate the fixed normals in case the mesh was built with pre-rotated particles, ex : use of positionFunction in addShape()
  32322. * @hidden
  32323. */
  32324. private _unrotateFixedNormals;
  32325. /**
  32326. * Resets the temporary working copy particle
  32327. * @hidden
  32328. */
  32329. private _resetCopy;
  32330. /**
  32331. * Inserts the shape model geometry in the global SPS mesh by updating the positions, indices, normals, colors, uvs arrays
  32332. * @param p the current index in the positions array to be updated
  32333. * @param ind the current index in the indices array
  32334. * @param shape a Vector3 array, the shape geometry
  32335. * @param positions the positions array to be updated
  32336. * @param meshInd the shape indices array
  32337. * @param indices the indices array to be updated
  32338. * @param meshUV the shape uv array
  32339. * @param uvs the uv array to be updated
  32340. * @param meshCol the shape color array
  32341. * @param colors the color array to be updated
  32342. * @param meshNor the shape normals array
  32343. * @param normals the normals array to be updated
  32344. * @param idx the particle index
  32345. * @param idxInShape the particle index in its shape
  32346. * @param options the addShape() method passed options
  32347. * @model the particle model
  32348. * @hidden
  32349. */
  32350. private _meshBuilder;
  32351. /**
  32352. * Returns a shape Vector3 array from positions float array
  32353. * @param positions float array
  32354. * @returns a vector3 array
  32355. * @hidden
  32356. */
  32357. private _posToShape;
  32358. /**
  32359. * Returns a shapeUV array from a float uvs (array deep copy)
  32360. * @param uvs as a float array
  32361. * @returns a shapeUV array
  32362. * @hidden
  32363. */
  32364. private _uvsToShapeUV;
  32365. /**
  32366. * Adds a new particle object in the particles array
  32367. * @param idx particle index in particles array
  32368. * @param id particle id
  32369. * @param idxpos positionIndex : the starting index of the particle vertices in the SPS "positions" array
  32370. * @param idxind indiceIndex : he starting index of the particle indices in the SPS "indices" array
  32371. * @param model particle ModelShape object
  32372. * @param shapeId model shape identifier
  32373. * @param idxInShape index of the particle in the current model
  32374. * @param bInfo model bounding info object
  32375. * @param storage target storage array, if any
  32376. * @hidden
  32377. */
  32378. private _addParticle;
  32379. /**
  32380. * Adds some particles to the SPS from the model shape. Returns the shape id.
  32381. * Please read the doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#create-an-immutable-sps
  32382. * @param mesh is any Mesh object that will be used as a model for the solid particles.
  32383. * @param nb (positive integer) the number of particles to be created from this model
  32384. * @param options {positionFunction} is an optional javascript function to called for each particle on SPS creation.
  32385. * {vertexFunction} is an optional javascript function to called for each vertex of each particle on SPS creation
  32386. * {storage} (optional existing array) is an array where the particles will be stored for a further use instead of being inserted in the SPS.
  32387. * @returns the number of shapes in the system
  32388. */
  32389. addShape(mesh: Mesh, nb: number, options?: {
  32390. positionFunction?: any;
  32391. vertexFunction?: any;
  32392. storage?: [];
  32393. }): number;
  32394. /**
  32395. * Rebuilds a particle back to its just built status : if needed, recomputes the custom positions and vertices
  32396. * @hidden
  32397. */
  32398. private _rebuildParticle;
  32399. /**
  32400. * Rebuilds the whole mesh and updates the VBO : custom positions and vertices are recomputed if needed.
  32401. * @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.
  32402. * @returns the SPS.
  32403. */
  32404. rebuildMesh(reset?: boolean): SolidParticleSystem;
  32405. /** Removes the particles from the start-th to the end-th included from an expandable SPS (required).
  32406. * Returns an array with the removed particles.
  32407. * 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.
  32408. * The SPS can't be empty so at least one particle needs to remain in place.
  32409. * Under the hood, the VertexData array, so the VBO buffer, is recreated each call.
  32410. * @param start index of the first particle to remove
  32411. * @param end index of the last particle to remove (included)
  32412. * @returns an array populated with the removed particles
  32413. */
  32414. removeParticles(start: number, end: number): SolidParticle[];
  32415. /**
  32416. * Inserts some pre-created particles in the solid particle system so that they can be managed by setParticles().
  32417. * @param solidParticleArray an array populated with Solid Particles objects
  32418. * @returns the SPS
  32419. */
  32420. insertParticlesFromArray(solidParticleArray: SolidParticle[]): SolidParticleSystem;
  32421. /**
  32422. * Creates a new particle and modifies the SPS mesh geometry :
  32423. * - calls _meshBuilder() to increase the SPS mesh geometry step by step
  32424. * - calls _addParticle() to populate the particle array
  32425. * factorized code from addShape() and insertParticlesFromArray()
  32426. * @param idx particle index in the particles array
  32427. * @param i particle index in its shape
  32428. * @param modelShape particle ModelShape object
  32429. * @param shape shape vertex array
  32430. * @param meshInd shape indices array
  32431. * @param meshUV shape uv array
  32432. * @param meshCol shape color array
  32433. * @param meshNor shape normals array
  32434. * @param bbInfo shape bounding info
  32435. * @param storage target particle storage
  32436. * @options addShape() passed options
  32437. * @hidden
  32438. */
  32439. private _insertNewParticle;
  32440. /**
  32441. * Sets all the particles : this method actually really updates the mesh according to the particle positions, rotations, colors, textures, etc.
  32442. * This method calls `updateParticle()` for each particle of the SPS.
  32443. * For an animated SPS, it is usually called within the render loop.
  32444. * 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.
  32445. * @param start The particle index in the particle array where to start to compute the particle property values _(default 0)_
  32446. * @param end The particle index in the particle array where to stop to compute the particle property values _(default nbParticle - 1)_
  32447. * @param update If the mesh must be finally updated on this call after all the particle computations _(default true)_
  32448. * @returns the SPS.
  32449. */
  32450. setParticles(start?: number, end?: number, update?: boolean): SolidParticleSystem;
  32451. /**
  32452. * Disposes the SPS.
  32453. */
  32454. dispose(): void;
  32455. /** Returns an object {idx: numbern faceId: number} for the picked particle from the passed pickingInfo object.
  32456. * idx is the particle index in the SPS
  32457. * faceId is the picked face index counted within this particle.
  32458. * Returns null if the pickInfo can't identify a picked particle.
  32459. * @param pickingInfo (PickingInfo object)
  32460. * @returns {idx: number, faceId: number} or null
  32461. */
  32462. pickedParticle(pickingInfo: PickingInfo): Nullable<{
  32463. idx: number;
  32464. faceId: number;
  32465. }>;
  32466. /**
  32467. * Returns a SolidParticle object from its identifier : particle.id
  32468. * @param id (integer) the particle Id
  32469. * @returns the searched particle or null if not found in the SPS.
  32470. */
  32471. getParticleById(id: number): Nullable<SolidParticle>;
  32472. /**
  32473. * Returns a new array populated with the particles having the passed shapeId.
  32474. * @param shapeId (integer) the shape identifier
  32475. * @returns a new solid particle array
  32476. */
  32477. getParticlesByShapeId(shapeId: number): SolidParticle[];
  32478. /**
  32479. * Populates the passed array "ref" with the particles having the passed shapeId.
  32480. * @param shapeId the shape identifier
  32481. * @returns the SPS
  32482. * @param ref
  32483. */
  32484. getParticlesByShapeIdToRef(shapeId: number, ref: SolidParticle[]): SolidParticleSystem;
  32485. /**
  32486. * Computes the required SubMeshes according the materials assigned to the particles.
  32487. * @returns the solid particle system.
  32488. * Does nothing if called before the SPS mesh is built.
  32489. */
  32490. computeSubMeshes(): SolidParticleSystem;
  32491. /**
  32492. * Sorts the solid particles by material when MultiMaterial is enabled.
  32493. * Updates the indices32 array.
  32494. * Updates the indicesByMaterial array.
  32495. * Updates the mesh indices array.
  32496. * @returns the SPS
  32497. * @hidden
  32498. */
  32499. private _sortParticlesByMaterial;
  32500. /**
  32501. * Sets the material indexes by id materialIndexesById[id] = materialIndex
  32502. * @hidden
  32503. */
  32504. private _setMaterialIndexesById;
  32505. /**
  32506. * Returns an array with unique values of Materials from the passed array
  32507. * @param array the material array to be checked and filtered
  32508. * @hidden
  32509. */
  32510. private _filterUniqueMaterialId;
  32511. /**
  32512. * Sets a new Standard Material as _defaultMaterial if not already set.
  32513. * @hidden
  32514. */
  32515. private _setDefaultMaterial;
  32516. /**
  32517. * Visibilty helper : Recomputes the visible size according to the mesh bounding box
  32518. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  32519. * @returns the SPS.
  32520. */
  32521. refreshVisibleSize(): SolidParticleSystem;
  32522. /**
  32523. * Visibility helper : Sets the size of a visibility box, this sets the underlying mesh bounding box.
  32524. * @param size the size (float) of the visibility box
  32525. * note : this doesn't lock the SPS mesh bounding box.
  32526. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  32527. */
  32528. setVisibilityBox(size: number): void;
  32529. /**
  32530. * Gets whether the SPS as always visible or not
  32531. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  32532. */
  32533. get isAlwaysVisible(): boolean;
  32534. /**
  32535. * Sets the SPS as always visible or not
  32536. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  32537. */
  32538. set isAlwaysVisible(val: boolean);
  32539. /**
  32540. * Sets the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  32541. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  32542. */
  32543. set isVisibilityBoxLocked(val: boolean);
  32544. /**
  32545. * Gets if the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  32546. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  32547. */
  32548. get isVisibilityBoxLocked(): boolean;
  32549. /**
  32550. * Tells to `setParticles()` to compute the particle rotations or not.
  32551. * Default value : true. The SPS is faster when it's set to false.
  32552. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  32553. */
  32554. set computeParticleRotation(val: boolean);
  32555. /**
  32556. * Tells to `setParticles()` to compute the particle colors or not.
  32557. * Default value : true. The SPS is faster when it's set to false.
  32558. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  32559. */
  32560. set computeParticleColor(val: boolean);
  32561. set computeParticleTexture(val: boolean);
  32562. /**
  32563. * Tells to `setParticles()` to call the vertex function for each vertex of each particle, or not.
  32564. * Default value : false. The SPS is faster when it's set to false.
  32565. * Note : the particle custom vertex positions aren't stored values.
  32566. */
  32567. set computeParticleVertex(val: boolean);
  32568. /**
  32569. * Tells to `setParticles()` to compute or not the mesh bounding box when computing the particle positions.
  32570. */
  32571. set computeBoundingBox(val: boolean);
  32572. /**
  32573. * Tells to `setParticles()` to sort or not the distance between each particle and the camera.
  32574. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  32575. * Default : `true`
  32576. */
  32577. set depthSortParticles(val: boolean);
  32578. /**
  32579. * Gets if `setParticles()` computes the particle rotations or not.
  32580. * Default value : true. The SPS is faster when it's set to false.
  32581. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  32582. */
  32583. get computeParticleRotation(): boolean;
  32584. /**
  32585. * Gets if `setParticles()` computes the particle colors or not.
  32586. * Default value : true. The SPS is faster when it's set to false.
  32587. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  32588. */
  32589. get computeParticleColor(): boolean;
  32590. /**
  32591. * Gets if `setParticles()` computes the particle textures or not.
  32592. * Default value : true. The SPS is faster when it's set to false.
  32593. * Note : the particle textures are stored values, so setting `computeParticleTexture` to false will keep yet the last colors set.
  32594. */
  32595. get computeParticleTexture(): boolean;
  32596. /**
  32597. * Gets if `setParticles()` calls the vertex function for each vertex of each particle, or not.
  32598. * Default value : false. The SPS is faster when it's set to false.
  32599. * Note : the particle custom vertex positions aren't stored values.
  32600. */
  32601. get computeParticleVertex(): boolean;
  32602. /**
  32603. * Gets if `setParticles()` computes or not the mesh bounding box when computing the particle positions.
  32604. */
  32605. get computeBoundingBox(): boolean;
  32606. /**
  32607. * Gets if `setParticles()` sorts or not the distance between each particle and the camera.
  32608. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  32609. * Default : `true`
  32610. */
  32611. get depthSortParticles(): boolean;
  32612. /**
  32613. * Gets if the SPS is created as expandable at construction time.
  32614. * Default : `false`
  32615. */
  32616. get expandable(): boolean;
  32617. /**
  32618. * Gets if the SPS supports the Multi Materials
  32619. */
  32620. get multimaterialEnabled(): boolean;
  32621. /**
  32622. * Gets if the SPS uses the model materials for its own multimaterial.
  32623. */
  32624. get useModelMaterial(): boolean;
  32625. /**
  32626. * The SPS used material array.
  32627. */
  32628. get materials(): Material[];
  32629. /**
  32630. * Sets the SPS MultiMaterial from the passed materials.
  32631. * Note : the passed array is internally copied and not used then by reference.
  32632. * @param materials an array of material objects. This array indexes are the materialIndex values of the particles.
  32633. */
  32634. setMultiMaterial(materials: Material[]): void;
  32635. /**
  32636. * The SPS computed multimaterial object
  32637. */
  32638. get multimaterial(): MultiMaterial;
  32639. set multimaterial(mm: MultiMaterial);
  32640. /**
  32641. * If the subMeshes must be updated on the next call to setParticles()
  32642. */
  32643. get autoUpdateSubMeshes(): boolean;
  32644. set autoUpdateSubMeshes(val: boolean);
  32645. /**
  32646. * This function does nothing. It may be overwritten to set all the particle first values.
  32647. * The SPS doesn't call this function, you may have to call it by your own.
  32648. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  32649. */
  32650. initParticles(): void;
  32651. /**
  32652. * This function does nothing. It may be overwritten to recycle a particle.
  32653. * The SPS doesn't call this function, you may have to call it by your own.
  32654. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  32655. * @param particle The particle to recycle
  32656. * @returns the recycled particle
  32657. */
  32658. recycleParticle(particle: SolidParticle): SolidParticle;
  32659. /**
  32660. * Updates a particle : this function should be overwritten by the user.
  32661. * It is called on each particle by `setParticles()`. This is the place to code each particle behavior.
  32662. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  32663. * @example : just set a particle position or velocity and recycle conditions
  32664. * @param particle The particle to update
  32665. * @returns the updated particle
  32666. */
  32667. updateParticle(particle: SolidParticle): SolidParticle;
  32668. /**
  32669. * Updates a vertex of a particle : it can be overwritten by the user.
  32670. * This will be called on each vertex particle by `setParticles()` if `computeParticleVertex` is set to true only.
  32671. * @param particle the current particle
  32672. * @param vertex the current vertex of the current particle : a SolidParticleVertex object
  32673. * @param pt the index of the current vertex in the particle shape
  32674. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#update-each-particle-shape
  32675. * @example : just set a vertex particle position or color
  32676. * @returns the sps
  32677. */
  32678. updateParticleVertex(particle: SolidParticle, vertex: SolidParticleVertex, pt: number): SolidParticleSystem;
  32679. /**
  32680. * This will be called before any other treatment by `setParticles()` and will be passed three parameters.
  32681. * This does nothing and may be overwritten by the user.
  32682. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  32683. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  32684. * @param update the boolean update value actually passed to setParticles()
  32685. */
  32686. beforeUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  32687. /**
  32688. * This will be called by `setParticles()` after all the other treatments and just before the actual mesh update.
  32689. * This will be passed three parameters.
  32690. * This does nothing and may be overwritten by the user.
  32691. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  32692. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  32693. * @param update the boolean update value actually passed to setParticles()
  32694. */
  32695. afterUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  32696. }
  32697. }
  32698. declare module "babylonjs/Particles/solidParticle" {
  32699. import { Nullable } from "babylonjs/types";
  32700. import { Vector3, Matrix, Quaternion, Vector4, Vector2 } from "babylonjs/Maths/math.vector";
  32701. import { Color4 } from "babylonjs/Maths/math.color";
  32702. import { Mesh } from "babylonjs/Meshes/mesh";
  32703. import { BoundingInfo } from "babylonjs/Culling/boundingInfo";
  32704. import { SolidParticleSystem } from "babylonjs/Particles/solidParticleSystem";
  32705. import { Plane } from "babylonjs/Maths/math.plane";
  32706. import { Material } from "babylonjs/Materials/material";
  32707. /**
  32708. * Represents one particle of a solid particle system.
  32709. */
  32710. export class SolidParticle {
  32711. /**
  32712. * particle global index
  32713. */
  32714. idx: number;
  32715. /**
  32716. * particle identifier
  32717. */
  32718. id: number;
  32719. /**
  32720. * The color of the particle
  32721. */
  32722. color: Nullable<Color4>;
  32723. /**
  32724. * The world space position of the particle.
  32725. */
  32726. position: Vector3;
  32727. /**
  32728. * The world space rotation of the particle. (Not use if rotationQuaternion is set)
  32729. */
  32730. rotation: Vector3;
  32731. /**
  32732. * The world space rotation quaternion of the particle.
  32733. */
  32734. rotationQuaternion: Nullable<Quaternion>;
  32735. /**
  32736. * The scaling of the particle.
  32737. */
  32738. scaling: Vector3;
  32739. /**
  32740. * The uvs of the particle.
  32741. */
  32742. uvs: Vector4;
  32743. /**
  32744. * The current speed of the particle.
  32745. */
  32746. velocity: Vector3;
  32747. /**
  32748. * The pivot point in the particle local space.
  32749. */
  32750. pivot: Vector3;
  32751. /**
  32752. * Must the particle be translated from its pivot point in its local space ?
  32753. * In this case, the pivot point is set at the origin of the particle local space and the particle is translated.
  32754. * Default : false
  32755. */
  32756. translateFromPivot: boolean;
  32757. /**
  32758. * Is the particle active or not ?
  32759. */
  32760. alive: boolean;
  32761. /**
  32762. * Is the particle visible or not ?
  32763. */
  32764. isVisible: boolean;
  32765. /**
  32766. * Index of this particle in the global "positions" array (Internal use)
  32767. * @hidden
  32768. */
  32769. _pos: number;
  32770. /**
  32771. * @hidden Index of this particle in the global "indices" array (Internal use)
  32772. */
  32773. _ind: number;
  32774. /**
  32775. * @hidden ModelShape of this particle (Internal use)
  32776. */
  32777. _model: ModelShape;
  32778. /**
  32779. * ModelShape id of this particle
  32780. */
  32781. shapeId: number;
  32782. /**
  32783. * Index of the particle in its shape id
  32784. */
  32785. idxInShape: number;
  32786. /**
  32787. * @hidden Reference to the shape model BoundingInfo object (Internal use)
  32788. */
  32789. _modelBoundingInfo: BoundingInfo;
  32790. /**
  32791. * @hidden Particle BoundingInfo object (Internal use)
  32792. */
  32793. _boundingInfo: BoundingInfo;
  32794. /**
  32795. * @hidden Reference to the SPS what the particle belongs to (Internal use)
  32796. */
  32797. _sps: SolidParticleSystem;
  32798. /**
  32799. * @hidden Still set as invisible in order to skip useless computations (Internal use)
  32800. */
  32801. _stillInvisible: boolean;
  32802. /**
  32803. * @hidden Last computed particle rotation matrix
  32804. */
  32805. _rotationMatrix: number[];
  32806. /**
  32807. * Parent particle Id, if any.
  32808. * Default null.
  32809. */
  32810. parentId: Nullable<number>;
  32811. /**
  32812. * The particle material identifier (integer) when MultiMaterials are enabled in the SPS.
  32813. */
  32814. materialIndex: Nullable<number>;
  32815. /**
  32816. * Custom object or properties.
  32817. */
  32818. props: Nullable<any>;
  32819. /**
  32820. * The culling strategy to use to check whether the solid particle must be culled or not when using isInFrustum().
  32821. * The possible values are :
  32822. * - AbstractMesh.CULLINGSTRATEGY_STANDARD
  32823. * - AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  32824. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION
  32825. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY
  32826. * The default value for solid particles is AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  32827. * Please read each static variable documentation in the class AbstractMesh to get details about the culling process.
  32828. * */
  32829. cullingStrategy: number;
  32830. /**
  32831. * @hidden Internal global position in the SPS.
  32832. */
  32833. _globalPosition: Vector3;
  32834. /**
  32835. * Creates a Solid Particle object.
  32836. * Don't create particles manually, use instead the Solid Particle System internal tools like _addParticle()
  32837. * @param particleIndex (integer) is the particle index in the Solid Particle System pool.
  32838. * @param particleId (integer) is the particle identifier. Unless some particles are removed from the SPS, it's the same value than the particle idx.
  32839. * @param positionIndex (integer) is the starting index of the particle vertices in the SPS "positions" array.
  32840. * @param indiceIndex (integer) is the starting index of the particle indices in the SPS "indices" array.
  32841. * @param model (ModelShape) is a reference to the model shape on what the particle is designed.
  32842. * @param shapeId (integer) is the model shape identifier in the SPS.
  32843. * @param idxInShape (integer) is the index of the particle in the current model (ex: the 10th box of addShape(box, 30))
  32844. * @param sps defines the sps it is associated to
  32845. * @param modelBoundingInfo is the reference to the model BoundingInfo used for intersection computations.
  32846. * @param materialIndex is the particle material identifier (integer) when the MultiMaterials are enabled in the SPS.
  32847. */
  32848. constructor(particleIndex: number, particleId: number, positionIndex: number, indiceIndex: number, model: Nullable<ModelShape>, shapeId: number, idxInShape: number, sps: SolidParticleSystem, modelBoundingInfo?: Nullable<BoundingInfo>, materialIndex?: Nullable<number>);
  32849. /**
  32850. * Copies the particle property values into the existing target : position, rotation, scaling, uvs, colors, pivot, parent, visibility, alive
  32851. * @param target the particle target
  32852. * @returns the current particle
  32853. */
  32854. copyToRef(target: SolidParticle): SolidParticle;
  32855. /**
  32856. * Legacy support, changed scale to scaling
  32857. */
  32858. get scale(): Vector3;
  32859. /**
  32860. * Legacy support, changed scale to scaling
  32861. */
  32862. set scale(scale: Vector3);
  32863. /**
  32864. * Legacy support, changed quaternion to rotationQuaternion
  32865. */
  32866. get quaternion(): Nullable<Quaternion>;
  32867. /**
  32868. * Legacy support, changed quaternion to rotationQuaternion
  32869. */
  32870. set quaternion(q: Nullable<Quaternion>);
  32871. /**
  32872. * Returns a boolean. True if the particle intersects another particle or another mesh, else false.
  32873. * The intersection is computed on the particle bounding sphere and Axis Aligned Bounding Box (AABB)
  32874. * @param target is the object (solid particle or mesh) what the intersection is computed against.
  32875. * @returns true if it intersects
  32876. */
  32877. intersectsMesh(target: Mesh | SolidParticle): boolean;
  32878. /**
  32879. * Returns `true` if the solid particle is within the frustum defined by the passed array of planes.
  32880. * A particle is in the frustum if its bounding box intersects the frustum
  32881. * @param frustumPlanes defines the frustum to test
  32882. * @returns true if the particle is in the frustum planes
  32883. */
  32884. isInFrustum(frustumPlanes: Plane[]): boolean;
  32885. /**
  32886. * get the rotation matrix of the particle
  32887. * @hidden
  32888. */
  32889. getRotationMatrix(m: Matrix): void;
  32890. }
  32891. /**
  32892. * Represents the shape of the model used by one particle of a solid particle system.
  32893. * SPS internal tool, don't use it manually.
  32894. */
  32895. export class ModelShape {
  32896. /**
  32897. * The shape id
  32898. * @hidden
  32899. */
  32900. shapeID: number;
  32901. /**
  32902. * flat array of model positions (internal use)
  32903. * @hidden
  32904. */
  32905. _shape: Vector3[];
  32906. /**
  32907. * flat array of model UVs (internal use)
  32908. * @hidden
  32909. */
  32910. _shapeUV: number[];
  32911. /**
  32912. * color array of the model
  32913. * @hidden
  32914. */
  32915. _shapeColors: number[];
  32916. /**
  32917. * indices array of the model
  32918. * @hidden
  32919. */
  32920. _indices: number[];
  32921. /**
  32922. * normals array of the model
  32923. * @hidden
  32924. */
  32925. _normals: number[];
  32926. /**
  32927. * length of the shape in the model indices array (internal use)
  32928. * @hidden
  32929. */
  32930. _indicesLength: number;
  32931. /**
  32932. * Custom position function (internal use)
  32933. * @hidden
  32934. */
  32935. _positionFunction: Nullable<(particle: SolidParticle, i: number, s: number) => void>;
  32936. /**
  32937. * Custom vertex function (internal use)
  32938. * @hidden
  32939. */
  32940. _vertexFunction: Nullable<(particle: SolidParticle, vertex: Vector3, i: number) => void>;
  32941. /**
  32942. * Model material (internal use)
  32943. * @hidden
  32944. */
  32945. _material: Nullable<Material>;
  32946. /**
  32947. * 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.
  32948. * SPS internal tool, don't use it manually.
  32949. * @hidden
  32950. */
  32951. 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>);
  32952. }
  32953. /**
  32954. * Represents a Depth Sorted Particle in the solid particle system.
  32955. * @hidden
  32956. */
  32957. export class DepthSortedParticle {
  32958. /**
  32959. * Particle index
  32960. */
  32961. idx: number;
  32962. /**
  32963. * Index of the particle in the "indices" array
  32964. */
  32965. ind: number;
  32966. /**
  32967. * Length of the particle shape in the "indices" array
  32968. */
  32969. indicesLength: number;
  32970. /**
  32971. * Squared distance from the particle to the camera
  32972. */
  32973. sqDistance: number;
  32974. /**
  32975. * Material index when used with MultiMaterials
  32976. */
  32977. materialIndex: number;
  32978. /**
  32979. * Creates a new sorted particle
  32980. * @param materialIndex
  32981. */
  32982. constructor(idx: number, ind: number, indLength: number, materialIndex: number);
  32983. }
  32984. /**
  32985. * Represents a solid particle vertex
  32986. */
  32987. export class SolidParticleVertex {
  32988. /**
  32989. * Vertex position
  32990. */
  32991. position: Vector3;
  32992. /**
  32993. * Vertex color
  32994. */
  32995. color: Color4;
  32996. /**
  32997. * Vertex UV
  32998. */
  32999. uv: Vector2;
  33000. /**
  33001. * Creates a new solid particle vertex
  33002. */
  33003. constructor();
  33004. /** Vertex x coordinate */
  33005. get x(): number;
  33006. set x(val: number);
  33007. /** Vertex y coordinate */
  33008. get y(): number;
  33009. set y(val: number);
  33010. /** Vertex z coordinate */
  33011. get z(): number;
  33012. set z(val: number);
  33013. }
  33014. }
  33015. declare module "babylonjs/Collisions/meshCollisionData" {
  33016. import { Collider } from "babylonjs/Collisions/collider";
  33017. import { Vector3 } from "babylonjs/Maths/math.vector";
  33018. import { Nullable } from "babylonjs/types";
  33019. import { Observer } from "babylonjs/Misc/observable";
  33020. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  33021. /**
  33022. * @hidden
  33023. */
  33024. export class _MeshCollisionData {
  33025. _checkCollisions: boolean;
  33026. _collisionMask: number;
  33027. _collisionGroup: number;
  33028. _surroundingMeshes: Nullable<AbstractMesh[]>;
  33029. _collider: Nullable<Collider>;
  33030. _oldPositionForCollisions: Vector3;
  33031. _diffPositionForCollisions: Vector3;
  33032. _onCollideObserver: Nullable<Observer<AbstractMesh>>;
  33033. _onCollisionPositionChangeObserver: Nullable<Observer<Vector3>>;
  33034. }
  33035. }
  33036. declare module "babylonjs/Meshes/abstractMesh" {
  33037. import { Observable } from "babylonjs/Misc/observable";
  33038. import { Nullable, FloatArray, IndicesArray, DeepImmutable } from "babylonjs/types";
  33039. import { Camera } from "babylonjs/Cameras/camera";
  33040. import { Scene, IDisposable } from "babylonjs/scene";
  33041. import { Matrix, Vector3, Vector2 } from "babylonjs/Maths/math.vector";
  33042. import { Node } from "babylonjs/node";
  33043. import { IGetSetVerticesData } from "babylonjs/Meshes/mesh.vertexData";
  33044. import { TransformNode } from "babylonjs/Meshes/transformNode";
  33045. import { SubMesh } from "babylonjs/Meshes/subMesh";
  33046. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  33047. import { ICullable, BoundingInfo } from "babylonjs/Culling/boundingInfo";
  33048. import { Material } from "babylonjs/Materials/material";
  33049. import { Light } from "babylonjs/Lights/light";
  33050. import { Skeleton } from "babylonjs/Bones/skeleton";
  33051. import { IEdgesRenderer } from "babylonjs/Rendering/edgesRenderer";
  33052. import { SolidParticle } from "babylonjs/Particles/solidParticle";
  33053. import { AbstractActionManager } from "babylonjs/Actions/abstractActionManager";
  33054. import { RawTexture } from "babylonjs/Materials/Textures/rawTexture";
  33055. import { Color3, Color4 } from "babylonjs/Maths/math.color";
  33056. import { Plane } from "babylonjs/Maths/math.plane";
  33057. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  33058. import { Ray } from "babylonjs/Culling/ray";
  33059. import { Collider } from "babylonjs/Collisions/collider";
  33060. import { TrianglePickingPredicate } from "babylonjs/Culling/ray";
  33061. import { RenderingGroup } from "babylonjs/Rendering/renderingGroup";
  33062. /** @hidden */
  33063. class _FacetDataStorage {
  33064. facetPositions: Vector3[];
  33065. facetNormals: Vector3[];
  33066. facetPartitioning: number[][];
  33067. facetNb: number;
  33068. partitioningSubdivisions: number;
  33069. partitioningBBoxRatio: number;
  33070. facetDataEnabled: boolean;
  33071. facetParameters: any;
  33072. bbSize: Vector3;
  33073. subDiv: {
  33074. max: number;
  33075. X: number;
  33076. Y: number;
  33077. Z: number;
  33078. };
  33079. facetDepthSort: boolean;
  33080. facetDepthSortEnabled: boolean;
  33081. depthSortedIndices: IndicesArray;
  33082. depthSortedFacets: {
  33083. ind: number;
  33084. sqDistance: number;
  33085. }[];
  33086. facetDepthSortFunction: (f1: {
  33087. ind: number;
  33088. sqDistance: number;
  33089. }, f2: {
  33090. ind: number;
  33091. sqDistance: number;
  33092. }) => number;
  33093. facetDepthSortFrom: Vector3;
  33094. facetDepthSortOrigin: Vector3;
  33095. invertedMatrix: Matrix;
  33096. }
  33097. /**
  33098. * @hidden
  33099. **/
  33100. class _InternalAbstractMeshDataInfo {
  33101. _hasVertexAlpha: boolean;
  33102. _useVertexColors: boolean;
  33103. _numBoneInfluencers: number;
  33104. _applyFog: boolean;
  33105. _receiveShadows: boolean;
  33106. _facetData: _FacetDataStorage;
  33107. _visibility: number;
  33108. _skeleton: Nullable<Skeleton>;
  33109. _layerMask: number;
  33110. _computeBonesUsingShaders: boolean;
  33111. _isActive: boolean;
  33112. _onlyForInstances: boolean;
  33113. _isActiveIntermediate: boolean;
  33114. _onlyForInstancesIntermediate: boolean;
  33115. _actAsRegularMesh: boolean;
  33116. }
  33117. /**
  33118. * Class used to store all common mesh properties
  33119. */
  33120. export class AbstractMesh extends TransformNode implements IDisposable, ICullable, IGetSetVerticesData {
  33121. /** No occlusion */
  33122. static OCCLUSION_TYPE_NONE: number;
  33123. /** Occlusion set to optimisitic */
  33124. static OCCLUSION_TYPE_OPTIMISTIC: number;
  33125. /** Occlusion set to strict */
  33126. static OCCLUSION_TYPE_STRICT: number;
  33127. /** Use an accurante occlusion algorithm */
  33128. static OCCLUSION_ALGORITHM_TYPE_ACCURATE: number;
  33129. /** Use a conservative occlusion algorithm */
  33130. static OCCLUSION_ALGORITHM_TYPE_CONSERVATIVE: number;
  33131. /** Default culling strategy : this is an exclusion test and it's the more accurate.
  33132. * Test order :
  33133. * Is the bounding sphere outside the frustum ?
  33134. * If not, are the bounding box vertices outside the frustum ?
  33135. * It not, then the cullable object is in the frustum.
  33136. */
  33137. static readonly CULLINGSTRATEGY_STANDARD: number;
  33138. /** Culling strategy : Bounding Sphere Only.
  33139. * This is an exclusion test. It's faster than the standard strategy because the bounding box is not tested.
  33140. * It's also less accurate than the standard because some not visible objects can still be selected.
  33141. * Test : is the bounding sphere outside the frustum ?
  33142. * If not, then the cullable object is in the frustum.
  33143. */
  33144. static readonly CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY: number;
  33145. /** Culling strategy : Optimistic Inclusion.
  33146. * This in an inclusion test first, then the standard exclusion test.
  33147. * This can be faster when a cullable object is expected to be almost always in the camera frustum.
  33148. * 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.
  33149. * Anyway, it's as accurate as the standard strategy.
  33150. * Test :
  33151. * Is the cullable object bounding sphere center in the frustum ?
  33152. * If not, apply the default culling strategy.
  33153. */
  33154. static readonly CULLINGSTRATEGY_OPTIMISTIC_INCLUSION: number;
  33155. /** Culling strategy : Optimistic Inclusion then Bounding Sphere Only.
  33156. * This in an inclusion test first, then the bounding sphere only exclusion test.
  33157. * This can be the fastest test when a cullable object is expected to be almost always in the camera frustum.
  33158. * 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.
  33159. * It's less accurate than the standard strategy and as accurate as the BoundingSphereOnly strategy.
  33160. * Test :
  33161. * Is the cullable object bounding sphere center in the frustum ?
  33162. * If not, apply the Bounding Sphere Only strategy. No Bounding Box is tested here.
  33163. */
  33164. static readonly CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY: number;
  33165. /**
  33166. * No billboard
  33167. */
  33168. static get BILLBOARDMODE_NONE(): number;
  33169. /** Billboard on X axis */
  33170. static get BILLBOARDMODE_X(): number;
  33171. /** Billboard on Y axis */
  33172. static get BILLBOARDMODE_Y(): number;
  33173. /** Billboard on Z axis */
  33174. static get BILLBOARDMODE_Z(): number;
  33175. /** Billboard on all axes */
  33176. static get BILLBOARDMODE_ALL(): number;
  33177. /** Billboard on using position instead of orientation */
  33178. static get BILLBOARDMODE_USE_POSITION(): number;
  33179. /** @hidden */
  33180. _internalAbstractMeshDataInfo: _InternalAbstractMeshDataInfo;
  33181. /**
  33182. * The culling strategy to use to check whether the mesh must be rendered or not.
  33183. * This value can be changed at any time and will be used on the next render mesh selection.
  33184. * The possible values are :
  33185. * - AbstractMesh.CULLINGSTRATEGY_STANDARD
  33186. * - AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  33187. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION
  33188. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY
  33189. * Please read each static variable documentation to get details about the culling process.
  33190. * */
  33191. cullingStrategy: number;
  33192. /**
  33193. * Gets the number of facets in the mesh
  33194. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  33195. */
  33196. get facetNb(): number;
  33197. /**
  33198. * Gets or set the number (integer) of subdivisions per axis in the partioning space
  33199. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  33200. */
  33201. get partitioningSubdivisions(): number;
  33202. set partitioningSubdivisions(nb: number);
  33203. /**
  33204. * The ratio (float) to apply to the bouding box size to set to the partioning space.
  33205. * Ex : 1.01 (default) the partioning space is 1% bigger than the bounding box
  33206. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  33207. */
  33208. get partitioningBBoxRatio(): number;
  33209. set partitioningBBoxRatio(ratio: number);
  33210. /**
  33211. * Gets or sets a boolean indicating that the facets must be depth sorted on next call to `updateFacetData()`.
  33212. * Works only for updatable meshes.
  33213. * Doesn't work with multi-materials
  33214. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  33215. */
  33216. get mustDepthSortFacets(): boolean;
  33217. set mustDepthSortFacets(sort: boolean);
  33218. /**
  33219. * The location (Vector3) where the facet depth sort must be computed from.
  33220. * By default, the active camera position.
  33221. * Used only when facet depth sort is enabled
  33222. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  33223. */
  33224. get facetDepthSortFrom(): Vector3;
  33225. set facetDepthSortFrom(location: Vector3);
  33226. /**
  33227. * gets a boolean indicating if facetData is enabled
  33228. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  33229. */
  33230. get isFacetDataEnabled(): boolean;
  33231. /** @hidden */
  33232. _updateNonUniformScalingState(value: boolean): boolean;
  33233. /**
  33234. * An event triggered when this mesh collides with another one
  33235. */
  33236. onCollideObservable: Observable<AbstractMesh>;
  33237. /** Set a function to call when this mesh collides with another one */
  33238. set onCollide(callback: () => void);
  33239. /**
  33240. * An event triggered when the collision's position changes
  33241. */
  33242. onCollisionPositionChangeObservable: Observable<Vector3>;
  33243. /** Set a function to call when the collision's position changes */
  33244. set onCollisionPositionChange(callback: () => void);
  33245. /**
  33246. * An event triggered when material is changed
  33247. */
  33248. onMaterialChangedObservable: Observable<AbstractMesh>;
  33249. /**
  33250. * Gets or sets the orientation for POV movement & rotation
  33251. */
  33252. definedFacingForward: boolean;
  33253. /** @hidden */
  33254. _occlusionQuery: Nullable<WebGLQuery>;
  33255. /** @hidden */
  33256. _renderingGroup: Nullable<RenderingGroup>;
  33257. /**
  33258. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  33259. */
  33260. get visibility(): number;
  33261. /**
  33262. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  33263. */
  33264. set visibility(value: number);
  33265. /** Gets or sets the alpha index used to sort transparent meshes
  33266. * @see https://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#alpha-index
  33267. */
  33268. alphaIndex: number;
  33269. /**
  33270. * Gets or sets a boolean indicating if the mesh is visible (renderable). Default is true
  33271. */
  33272. isVisible: boolean;
  33273. /**
  33274. * Gets or sets a boolean indicating if the mesh can be picked (by scene.pick for instance or through actions). Default is true
  33275. */
  33276. isPickable: boolean;
  33277. /** Gets or sets a boolean indicating that bounding boxes of subMeshes must be rendered as well (false by default) */
  33278. showSubMeshesBoundingBox: boolean;
  33279. /** Gets or sets a boolean indicating if the mesh must be considered as a ray blocker for lens flares (false by default)
  33280. * @see https://doc.babylonjs.com/how_to/how_to_use_lens_flares
  33281. */
  33282. isBlocker: boolean;
  33283. /**
  33284. * Gets or sets a boolean indicating that pointer move events must be supported on this mesh (false by default)
  33285. */
  33286. enablePointerMoveEvents: boolean;
  33287. private _renderingGroupId;
  33288. /**
  33289. * Specifies the rendering group id for this mesh (0 by default)
  33290. * @see https://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#rendering-groups
  33291. */
  33292. get renderingGroupId(): number;
  33293. set renderingGroupId(value: number);
  33294. private _material;
  33295. /** Gets or sets current material */
  33296. get material(): Nullable<Material>;
  33297. set material(value: Nullable<Material>);
  33298. /**
  33299. * Gets or sets a boolean indicating that this mesh can receive realtime shadows
  33300. * @see https://doc.babylonjs.com/babylon101/shadows
  33301. */
  33302. get receiveShadows(): boolean;
  33303. set receiveShadows(value: boolean);
  33304. /** Defines color to use when rendering outline */
  33305. outlineColor: Color3;
  33306. /** Define width to use when rendering outline */
  33307. outlineWidth: number;
  33308. /** Defines color to use when rendering overlay */
  33309. overlayColor: Color3;
  33310. /** Defines alpha to use when rendering overlay */
  33311. overlayAlpha: number;
  33312. /** Gets or sets a boolean indicating that this mesh contains vertex color data with alpha values */
  33313. get hasVertexAlpha(): boolean;
  33314. set hasVertexAlpha(value: boolean);
  33315. /** 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) */
  33316. get useVertexColors(): boolean;
  33317. set useVertexColors(value: boolean);
  33318. /**
  33319. * Gets or sets a boolean indicating that bone animations must be computed by the CPU (false by default)
  33320. */
  33321. get computeBonesUsingShaders(): boolean;
  33322. set computeBonesUsingShaders(value: boolean);
  33323. /** Gets or sets the number of allowed bone influences per vertex (4 by default) */
  33324. get numBoneInfluencers(): number;
  33325. set numBoneInfluencers(value: number);
  33326. /** Gets or sets a boolean indicating that this mesh will allow fog to be rendered on it (true by default) */
  33327. get applyFog(): boolean;
  33328. set applyFog(value: boolean);
  33329. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes selection (true by default) */
  33330. useOctreeForRenderingSelection: boolean;
  33331. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes picking (true by default) */
  33332. useOctreeForPicking: boolean;
  33333. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes collision (true by default) */
  33334. useOctreeForCollisions: boolean;
  33335. /**
  33336. * Gets or sets the current layer mask (default is 0x0FFFFFFF)
  33337. * @see https://doc.babylonjs.com/how_to/layermasks_and_multi-cam_textures
  33338. */
  33339. get layerMask(): number;
  33340. set layerMask(value: number);
  33341. /**
  33342. * True if the mesh must be rendered in any case (this will shortcut the frustum clipping phase)
  33343. */
  33344. alwaysSelectAsActiveMesh: boolean;
  33345. /**
  33346. * Gets or sets a boolean indicating that the bounding info does not need to be kept in sync (for performance reason)
  33347. */
  33348. doNotSyncBoundingInfo: boolean;
  33349. /**
  33350. * Gets or sets the current action manager
  33351. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  33352. */
  33353. actionManager: Nullable<AbstractActionManager>;
  33354. private _meshCollisionData;
  33355. /**
  33356. * Gets or sets the ellipsoid used to impersonate this mesh when using collision engine (default is (0.5, 1, 0.5))
  33357. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  33358. */
  33359. ellipsoid: Vector3;
  33360. /**
  33361. * Gets or sets the ellipsoid offset used to impersonate this mesh when using collision engine (default is (0, 0, 0))
  33362. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  33363. */
  33364. ellipsoidOffset: Vector3;
  33365. /**
  33366. * Gets or sets a collision mask used to mask collisions (default is -1).
  33367. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  33368. */
  33369. get collisionMask(): number;
  33370. set collisionMask(mask: number);
  33371. /**
  33372. * Gets or sets the current collision group mask (-1 by default).
  33373. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  33374. */
  33375. get collisionGroup(): number;
  33376. set collisionGroup(mask: number);
  33377. /**
  33378. * Gets or sets current surrounding meshes (null by default).
  33379. *
  33380. * By default collision detection is tested against every mesh in the scene.
  33381. * It is possible to set surroundingMeshes to a defined list of meshes and then only these specified
  33382. * meshes will be tested for the collision.
  33383. *
  33384. * Note: if set to an empty array no collision will happen when this mesh is moved.
  33385. */
  33386. get surroundingMeshes(): Nullable<AbstractMesh[]>;
  33387. set surroundingMeshes(meshes: Nullable<AbstractMesh[]>);
  33388. /**
  33389. * Defines edge width used when edgesRenderer is enabled
  33390. * @see https://www.babylonjs-playground.com/#10OJSG#13
  33391. */
  33392. edgesWidth: number;
  33393. /**
  33394. * Defines edge color used when edgesRenderer is enabled
  33395. * @see https://www.babylonjs-playground.com/#10OJSG#13
  33396. */
  33397. edgesColor: Color4;
  33398. /** @hidden */
  33399. _edgesRenderer: Nullable<IEdgesRenderer>;
  33400. /** @hidden */
  33401. _masterMesh: Nullable<AbstractMesh>;
  33402. /** @hidden */
  33403. _boundingInfo: Nullable<BoundingInfo>;
  33404. /** @hidden */
  33405. _renderId: number;
  33406. /**
  33407. * Gets or sets the list of subMeshes
  33408. * @see https://doc.babylonjs.com/how_to/multi_materials
  33409. */
  33410. subMeshes: SubMesh[];
  33411. /** @hidden */
  33412. _intersectionsInProgress: AbstractMesh[];
  33413. /** @hidden */
  33414. _unIndexed: boolean;
  33415. /** @hidden */
  33416. _lightSources: Light[];
  33417. /** Gets the list of lights affecting that mesh */
  33418. get lightSources(): Light[];
  33419. /** @hidden */
  33420. get _positions(): Nullable<Vector3[]>;
  33421. /** @hidden */
  33422. _waitingData: {
  33423. lods: Nullable<any>;
  33424. actions: Nullable<any>;
  33425. freezeWorldMatrix: Nullable<boolean>;
  33426. };
  33427. /** @hidden */
  33428. _bonesTransformMatrices: Nullable<Float32Array>;
  33429. /** @hidden */
  33430. _transformMatrixTexture: Nullable<RawTexture>;
  33431. /**
  33432. * Gets or sets a skeleton to apply skining transformations
  33433. * @see https://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  33434. */
  33435. set skeleton(value: Nullable<Skeleton>);
  33436. get skeleton(): Nullable<Skeleton>;
  33437. /**
  33438. * An event triggered when the mesh is rebuilt.
  33439. */
  33440. onRebuildObservable: Observable<AbstractMesh>;
  33441. /**
  33442. * Creates a new AbstractMesh
  33443. * @param name defines the name of the mesh
  33444. * @param scene defines the hosting scene
  33445. */
  33446. constructor(name: string, scene?: Nullable<Scene>);
  33447. /**
  33448. * Returns the string "AbstractMesh"
  33449. * @returns "AbstractMesh"
  33450. */
  33451. getClassName(): string;
  33452. /**
  33453. * Gets a string representation of the current mesh
  33454. * @param fullDetails defines a boolean indicating if full details must be included
  33455. * @returns a string representation of the current mesh
  33456. */
  33457. toString(fullDetails?: boolean): string;
  33458. /**
  33459. * @hidden
  33460. */
  33461. protected _getEffectiveParent(): Nullable<Node>;
  33462. /** @hidden */
  33463. _getActionManagerForTrigger(trigger?: number, initialCall?: boolean): Nullable<AbstractActionManager>;
  33464. /** @hidden */
  33465. _rebuild(): void;
  33466. /** @hidden */
  33467. _resyncLightSources(): void;
  33468. /** @hidden */
  33469. _resyncLightSource(light: Light): void;
  33470. /** @hidden */
  33471. _unBindEffect(): void;
  33472. /** @hidden */
  33473. _removeLightSource(light: Light, dispose: boolean): void;
  33474. private _markSubMeshesAsDirty;
  33475. /** @hidden */
  33476. _markSubMeshesAsLightDirty(dispose?: boolean): void;
  33477. /** @hidden */
  33478. _markSubMeshesAsAttributesDirty(): void;
  33479. /** @hidden */
  33480. _markSubMeshesAsMiscDirty(): void;
  33481. /**
  33482. * Gets or sets a Vector3 depicting the mesh scaling along each local axis X, Y, Z. Default is (1.0, 1.0, 1.0)
  33483. */
  33484. get scaling(): Vector3;
  33485. set scaling(newScaling: Vector3);
  33486. /**
  33487. * Returns true if the mesh is blocked. Implemented by child classes
  33488. */
  33489. get isBlocked(): boolean;
  33490. /**
  33491. * Returns the mesh itself by default. Implemented by child classes
  33492. * @param camera defines the camera to use to pick the right LOD level
  33493. * @returns the currentAbstractMesh
  33494. */
  33495. getLOD(camera: Camera): Nullable<AbstractMesh>;
  33496. /**
  33497. * Returns 0 by default. Implemented by child classes
  33498. * @returns an integer
  33499. */
  33500. getTotalVertices(): number;
  33501. /**
  33502. * Returns a positive integer : the total number of indices in this mesh geometry.
  33503. * @returns the numner of indices or zero if the mesh has no geometry.
  33504. */
  33505. getTotalIndices(): number;
  33506. /**
  33507. * Returns null by default. Implemented by child classes
  33508. * @returns null
  33509. */
  33510. getIndices(): Nullable<IndicesArray>;
  33511. /**
  33512. * Returns the array of the requested vertex data kind. Implemented by child classes
  33513. * @param kind defines the vertex data kind to use
  33514. * @returns null
  33515. */
  33516. getVerticesData(kind: string): Nullable<FloatArray>;
  33517. /**
  33518. * Sets the vertex data of the mesh geometry for the requested `kind`.
  33519. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  33520. * Note that a new underlying VertexBuffer object is created each call.
  33521. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  33522. * @param kind defines vertex data kind:
  33523. * * VertexBuffer.PositionKind
  33524. * * VertexBuffer.UVKind
  33525. * * VertexBuffer.UV2Kind
  33526. * * VertexBuffer.UV3Kind
  33527. * * VertexBuffer.UV4Kind
  33528. * * VertexBuffer.UV5Kind
  33529. * * VertexBuffer.UV6Kind
  33530. * * VertexBuffer.ColorKind
  33531. * * VertexBuffer.MatricesIndicesKind
  33532. * * VertexBuffer.MatricesIndicesExtraKind
  33533. * * VertexBuffer.MatricesWeightsKind
  33534. * * VertexBuffer.MatricesWeightsExtraKind
  33535. * @param data defines the data source
  33536. * @param updatable defines if the data must be flagged as updatable (or static)
  33537. * @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
  33538. * @returns the current mesh
  33539. */
  33540. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  33541. /**
  33542. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  33543. * If the mesh has no geometry, it is simply returned as it is.
  33544. * @param kind defines vertex data kind:
  33545. * * VertexBuffer.PositionKind
  33546. * * VertexBuffer.UVKind
  33547. * * VertexBuffer.UV2Kind
  33548. * * VertexBuffer.UV3Kind
  33549. * * VertexBuffer.UV4Kind
  33550. * * VertexBuffer.UV5Kind
  33551. * * VertexBuffer.UV6Kind
  33552. * * VertexBuffer.ColorKind
  33553. * * VertexBuffer.MatricesIndicesKind
  33554. * * VertexBuffer.MatricesIndicesExtraKind
  33555. * * VertexBuffer.MatricesWeightsKind
  33556. * * VertexBuffer.MatricesWeightsExtraKind
  33557. * @param data defines the data source
  33558. * @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
  33559. * @param makeItUnique If true, a new global geometry is created from this data and is set to the mesh
  33560. * @returns the current mesh
  33561. */
  33562. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): AbstractMesh;
  33563. /**
  33564. * Sets the mesh indices,
  33565. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  33566. * @param indices Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array)
  33567. * @param totalVertices Defines the total number of vertices
  33568. * @returns the current mesh
  33569. */
  33570. setIndices(indices: IndicesArray, totalVertices: Nullable<number>): AbstractMesh;
  33571. /**
  33572. * Gets a boolean indicating if specific vertex data is present
  33573. * @param kind defines the vertex data kind to use
  33574. * @returns true is data kind is present
  33575. */
  33576. isVerticesDataPresent(kind: string): boolean;
  33577. /**
  33578. * Returns the mesh BoundingInfo object or creates a new one and returns if it was undefined.
  33579. * Note that it returns a shallow bounding of the mesh (i.e. it does not include children).
  33580. * To get the full bounding of all children, call `getHierarchyBoundingVectors` instead.
  33581. * @returns a BoundingInfo
  33582. */
  33583. getBoundingInfo(): BoundingInfo;
  33584. /**
  33585. * Uniformly scales the mesh to fit inside of a unit cube (1 X 1 X 1 units)
  33586. * @param includeDescendants Use the hierarchy's bounding box instead of the mesh's bounding box. Default is false
  33587. * @param ignoreRotation ignore rotation when computing the scale (ie. object will be axis aligned). Default is false
  33588. * @param predicate predicate that is passed in to getHierarchyBoundingVectors when selecting which object should be included when scaling
  33589. * @returns the current mesh
  33590. */
  33591. normalizeToUnitCube(includeDescendants?: boolean, ignoreRotation?: boolean, predicate?: Nullable<(node: AbstractMesh) => boolean>): AbstractMesh;
  33592. /**
  33593. * Overwrite the current bounding info
  33594. * @param boundingInfo defines the new bounding info
  33595. * @returns the current mesh
  33596. */
  33597. setBoundingInfo(boundingInfo: BoundingInfo): AbstractMesh;
  33598. /** Gets a boolean indicating if this mesh has skinning data and an attached skeleton */
  33599. get useBones(): boolean;
  33600. /** @hidden */
  33601. _preActivate(): void;
  33602. /** @hidden */
  33603. _preActivateForIntermediateRendering(renderId: number): void;
  33604. /** @hidden */
  33605. _activate(renderId: number, intermediateRendering: boolean): boolean;
  33606. /** @hidden */
  33607. _postActivate(): void;
  33608. /** @hidden */
  33609. _freeze(): void;
  33610. /** @hidden */
  33611. _unFreeze(): void;
  33612. /**
  33613. * Gets the current world matrix
  33614. * @returns a Matrix
  33615. */
  33616. getWorldMatrix(): Matrix;
  33617. /** @hidden */
  33618. _getWorldMatrixDeterminant(): number;
  33619. /**
  33620. * Gets a boolean indicating if this mesh is an instance or a regular mesh
  33621. */
  33622. get isAnInstance(): boolean;
  33623. /**
  33624. * Gets a boolean indicating if this mesh has instances
  33625. */
  33626. get hasInstances(): boolean;
  33627. /**
  33628. * Gets a boolean indicating if this mesh has thin instances
  33629. */
  33630. get hasThinInstances(): boolean;
  33631. /**
  33632. * Perform relative position change from the point of view of behind the front of the mesh.
  33633. * This is performed taking into account the meshes current rotation, so you do not have to care.
  33634. * Supports definition of mesh facing forward or backward
  33635. * @param amountRight defines the distance on the right axis
  33636. * @param amountUp defines the distance on the up axis
  33637. * @param amountForward defines the distance on the forward axis
  33638. * @returns the current mesh
  33639. */
  33640. movePOV(amountRight: number, amountUp: number, amountForward: number): AbstractMesh;
  33641. /**
  33642. * Calculate relative position change from the point of view of behind the front of the mesh.
  33643. * This is performed taking into account the meshes current rotation, so you do not have to care.
  33644. * Supports definition of mesh facing forward or backward
  33645. * @param amountRight defines the distance on the right axis
  33646. * @param amountUp defines the distance on the up axis
  33647. * @param amountForward defines the distance on the forward axis
  33648. * @returns the new displacement vector
  33649. */
  33650. calcMovePOV(amountRight: number, amountUp: number, amountForward: number): Vector3;
  33651. /**
  33652. * Perform relative rotation change from the point of view of behind the front of the mesh.
  33653. * Supports definition of mesh facing forward or backward
  33654. * @param flipBack defines the flip
  33655. * @param twirlClockwise defines the twirl
  33656. * @param tiltRight defines the tilt
  33657. * @returns the current mesh
  33658. */
  33659. rotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): AbstractMesh;
  33660. /**
  33661. * Calculate relative rotation change from the point of view of behind the front of the mesh.
  33662. * Supports definition of mesh facing forward or backward.
  33663. * @param flipBack defines the flip
  33664. * @param twirlClockwise defines the twirl
  33665. * @param tiltRight defines the tilt
  33666. * @returns the new rotation vector
  33667. */
  33668. calcRotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): Vector3;
  33669. /**
  33670. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  33671. * This means the mesh underlying bounding box and sphere are recomputed.
  33672. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  33673. * @returns the current mesh
  33674. */
  33675. refreshBoundingInfo(applySkeleton?: boolean): AbstractMesh;
  33676. /** @hidden */
  33677. _refreshBoundingInfo(data: Nullable<FloatArray>, bias: Nullable<Vector2>): void;
  33678. /** @hidden */
  33679. _getPositionData(applySkeleton: boolean): Nullable<FloatArray>;
  33680. /** @hidden */
  33681. _updateBoundingInfo(): AbstractMesh;
  33682. /** @hidden */
  33683. _updateSubMeshesBoundingInfo(matrix: DeepImmutable<Matrix>): AbstractMesh;
  33684. /** @hidden */
  33685. protected _afterComputeWorldMatrix(): void;
  33686. /** @hidden */
  33687. get _effectiveMesh(): AbstractMesh;
  33688. /**
  33689. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  33690. * A mesh is in the frustum if its bounding box intersects the frustum
  33691. * @param frustumPlanes defines the frustum to test
  33692. * @returns true if the mesh is in the frustum planes
  33693. */
  33694. isInFrustum(frustumPlanes: Plane[]): boolean;
  33695. /**
  33696. * Returns `true` if the mesh is completely in the frustum defined be the passed array of planes.
  33697. * A mesh is completely in the frustum if its bounding box it completely inside the frustum.
  33698. * @param frustumPlanes defines the frustum to test
  33699. * @returns true if the mesh is completely in the frustum planes
  33700. */
  33701. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  33702. /**
  33703. * True if the mesh intersects another mesh or a SolidParticle object
  33704. * @param mesh defines a target mesh or SolidParticle to test
  33705. * @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)
  33706. * @param includeDescendants Can be set to true to test if the mesh defined in parameters intersects with the current mesh or any child meshes
  33707. * @returns true if there is an intersection
  33708. */
  33709. intersectsMesh(mesh: AbstractMesh | SolidParticle, precise?: boolean, includeDescendants?: boolean): boolean;
  33710. /**
  33711. * Returns true if the passed point (Vector3) is inside the mesh bounding box
  33712. * @param point defines the point to test
  33713. * @returns true if there is an intersection
  33714. */
  33715. intersectsPoint(point: Vector3): boolean;
  33716. /**
  33717. * Gets or sets a boolean indicating that this mesh can be used in the collision engine
  33718. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  33719. */
  33720. get checkCollisions(): boolean;
  33721. set checkCollisions(collisionEnabled: boolean);
  33722. /**
  33723. * Gets Collider object used to compute collisions (not physics)
  33724. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  33725. */
  33726. get collider(): Nullable<Collider>;
  33727. /**
  33728. * Move the mesh using collision engine
  33729. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  33730. * @param displacement defines the requested displacement vector
  33731. * @returns the current mesh
  33732. */
  33733. moveWithCollisions(displacement: Vector3): AbstractMesh;
  33734. private _onCollisionPositionChange;
  33735. /** @hidden */
  33736. _collideForSubMesh(subMesh: SubMesh, transformMatrix: Matrix, collider: Collider): AbstractMesh;
  33737. /** @hidden */
  33738. _processCollisionsForSubMeshes(collider: Collider, transformMatrix: Matrix): AbstractMesh;
  33739. /** @hidden */
  33740. _checkCollision(collider: Collider): AbstractMesh;
  33741. /** @hidden */
  33742. _generatePointsArray(): boolean;
  33743. /**
  33744. * Checks if the passed Ray intersects with the mesh
  33745. * @param ray defines the ray to use
  33746. * @param fastCheck defines if fast mode (but less precise) must be used (false by default)
  33747. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  33748. * @param onlyBoundingInfo defines a boolean indicating if picking should only happen using bounding info (false by default)
  33749. * @param worldToUse defines the world matrix to use to get the world coordinate of the intersection point
  33750. * @returns the picking info
  33751. * @see https://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  33752. */
  33753. intersects(ray: Ray, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate, onlyBoundingInfo?: boolean, worldToUse?: Matrix): PickingInfo;
  33754. /**
  33755. * Clones the current mesh
  33756. * @param name defines the mesh name
  33757. * @param newParent defines the new mesh parent
  33758. * @param doNotCloneChildren defines a boolean indicating that children must not be cloned (false by default)
  33759. * @returns the new mesh
  33760. */
  33761. clone(name: string, newParent: Nullable<Node>, doNotCloneChildren?: boolean): Nullable<AbstractMesh>;
  33762. /**
  33763. * Disposes all the submeshes of the current meshnp
  33764. * @returns the current mesh
  33765. */
  33766. releaseSubMeshes(): AbstractMesh;
  33767. /**
  33768. * Releases resources associated with this abstract mesh.
  33769. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  33770. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  33771. */
  33772. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  33773. /**
  33774. * Adds the passed mesh as a child to the current mesh
  33775. * @param mesh defines the child mesh
  33776. * @returns the current mesh
  33777. */
  33778. addChild(mesh: AbstractMesh): AbstractMesh;
  33779. /**
  33780. * Removes the passed mesh from the current mesh children list
  33781. * @param mesh defines the child mesh
  33782. * @returns the current mesh
  33783. */
  33784. removeChild(mesh: AbstractMesh): AbstractMesh;
  33785. /** @hidden */
  33786. private _initFacetData;
  33787. /**
  33788. * Updates the mesh facetData arrays and the internal partitioning when the mesh is morphed or updated.
  33789. * This method can be called within the render loop.
  33790. * 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
  33791. * @returns the current mesh
  33792. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  33793. */
  33794. updateFacetData(): AbstractMesh;
  33795. /**
  33796. * Returns the facetLocalNormals array.
  33797. * The normals are expressed in the mesh local spac
  33798. * @returns an array of Vector3
  33799. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  33800. */
  33801. getFacetLocalNormals(): Vector3[];
  33802. /**
  33803. * Returns the facetLocalPositions array.
  33804. * The facet positions are expressed in the mesh local space
  33805. * @returns an array of Vector3
  33806. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  33807. */
  33808. getFacetLocalPositions(): Vector3[];
  33809. /**
  33810. * Returns the facetLocalPartioning array
  33811. * @returns an array of array of numbers
  33812. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  33813. */
  33814. getFacetLocalPartitioning(): number[][];
  33815. /**
  33816. * Returns the i-th facet position in the world system.
  33817. * This method allocates a new Vector3 per call
  33818. * @param i defines the facet index
  33819. * @returns a new Vector3
  33820. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  33821. */
  33822. getFacetPosition(i: number): Vector3;
  33823. /**
  33824. * Sets the reference Vector3 with the i-th facet position in the world system
  33825. * @param i defines the facet index
  33826. * @param ref defines the target vector
  33827. * @returns the current mesh
  33828. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  33829. */
  33830. getFacetPositionToRef(i: number, ref: Vector3): AbstractMesh;
  33831. /**
  33832. * Returns the i-th facet normal in the world system.
  33833. * This method allocates a new Vector3 per call
  33834. * @param i defines the facet index
  33835. * @returns a new Vector3
  33836. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  33837. */
  33838. getFacetNormal(i: number): Vector3;
  33839. /**
  33840. * Sets the reference Vector3 with the i-th facet normal in the world system
  33841. * @param i defines the facet index
  33842. * @param ref defines the target vector
  33843. * @returns the current mesh
  33844. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  33845. */
  33846. getFacetNormalToRef(i: number, ref: Vector3): this;
  33847. /**
  33848. * 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)
  33849. * @param x defines x coordinate
  33850. * @param y defines y coordinate
  33851. * @param z defines z coordinate
  33852. * @returns the array of facet indexes
  33853. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  33854. */
  33855. getFacetsAtLocalCoordinates(x: number, y: number, z: number): Nullable<number[]>;
  33856. /**
  33857. * Returns the closest mesh facet index at (x,y,z) World coordinates, null if not found
  33858. * @param projected sets as the (x,y,z) world projection on the facet
  33859. * @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
  33860. * @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
  33861. * @param x defines x coordinate
  33862. * @param y defines y coordinate
  33863. * @param z defines z coordinate
  33864. * @returns the face index if found (or null instead)
  33865. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  33866. */
  33867. getClosestFacetAtCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  33868. /**
  33869. * Returns the closest mesh facet index at (x,y,z) local coordinates, null if not found
  33870. * @param projected sets as the (x,y,z) local projection on the facet
  33871. * @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
  33872. * @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
  33873. * @param x defines x coordinate
  33874. * @param y defines y coordinate
  33875. * @param z defines z coordinate
  33876. * @returns the face index if found (or null instead)
  33877. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  33878. */
  33879. getClosestFacetAtLocalCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  33880. /**
  33881. * Returns the object "parameter" set with all the expected parameters for facetData computation by ComputeNormals()
  33882. * @returns the parameters
  33883. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  33884. */
  33885. getFacetDataParameters(): any;
  33886. /**
  33887. * Disables the feature FacetData and frees the related memory
  33888. * @returns the current mesh
  33889. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  33890. */
  33891. disableFacetData(): AbstractMesh;
  33892. /**
  33893. * Updates the AbstractMesh indices array
  33894. * @param indices defines the data source
  33895. * @param offset defines the offset in the index buffer where to store the new data (can be null)
  33896. * @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)
  33897. * @returns the current mesh
  33898. */
  33899. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): AbstractMesh;
  33900. /**
  33901. * Creates new normals data for the mesh
  33902. * @param updatable defines if the normal vertex buffer must be flagged as updatable
  33903. * @returns the current mesh
  33904. */
  33905. createNormals(updatable: boolean): AbstractMesh;
  33906. /**
  33907. * Align the mesh with a normal
  33908. * @param normal defines the normal to use
  33909. * @param upDirection can be used to redefined the up vector to use (will use the (0, 1, 0) by default)
  33910. * @returns the current mesh
  33911. */
  33912. alignWithNormal(normal: Vector3, upDirection?: Vector3): AbstractMesh;
  33913. /** @hidden */
  33914. _checkOcclusionQuery(): boolean;
  33915. /**
  33916. * Disables the mesh edge rendering mode
  33917. * @returns the currentAbstractMesh
  33918. */
  33919. disableEdgesRendering(): AbstractMesh;
  33920. /**
  33921. * Enables the edge rendering mode on the mesh.
  33922. * This mode makes the mesh edges visible
  33923. * @param epsilon defines the maximal distance between two angles to detect a face
  33924. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  33925. * @returns the currentAbstractMesh
  33926. * @see https://www.babylonjs-playground.com/#19O9TU#0
  33927. */
  33928. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): AbstractMesh;
  33929. /**
  33930. * This function returns all of the particle systems in the scene that use the mesh as an emitter.
  33931. * @returns an array of particle systems in the scene that use the mesh as an emitter
  33932. */
  33933. getConnectedParticleSystems(): IParticleSystem[];
  33934. }
  33935. }
  33936. declare module "babylonjs/Actions/actionEvent" {
  33937. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  33938. import { Nullable } from "babylonjs/types";
  33939. import { Sprite } from "babylonjs/Sprites/sprite";
  33940. import { Scene } from "babylonjs/scene";
  33941. import { Vector2 } from "babylonjs/Maths/math.vector";
  33942. /**
  33943. * Interface used to define ActionEvent
  33944. */
  33945. export interface IActionEvent {
  33946. /** The mesh or sprite that triggered the action */
  33947. source: any;
  33948. /** The X mouse cursor position at the time of the event */
  33949. pointerX: number;
  33950. /** The Y mouse cursor position at the time of the event */
  33951. pointerY: number;
  33952. /** The mesh that is currently pointed at (can be null) */
  33953. meshUnderPointer: Nullable<AbstractMesh>;
  33954. /** the original (browser) event that triggered the ActionEvent */
  33955. sourceEvent?: any;
  33956. /** additional data for the event */
  33957. additionalData?: any;
  33958. }
  33959. /**
  33960. * ActionEvent is the event being sent when an action is triggered.
  33961. */
  33962. export class ActionEvent implements IActionEvent {
  33963. /** The mesh or sprite that triggered the action */
  33964. source: any;
  33965. /** The X mouse cursor position at the time of the event */
  33966. pointerX: number;
  33967. /** The Y mouse cursor position at the time of the event */
  33968. pointerY: number;
  33969. /** The mesh that is currently pointed at (can be null) */
  33970. meshUnderPointer: Nullable<AbstractMesh>;
  33971. /** the original (browser) event that triggered the ActionEvent */
  33972. sourceEvent?: any;
  33973. /** additional data for the event */
  33974. additionalData?: any;
  33975. /**
  33976. * Creates a new ActionEvent
  33977. * @param source The mesh or sprite that triggered the action
  33978. * @param pointerX The X mouse cursor position at the time of the event
  33979. * @param pointerY The Y mouse cursor position at the time of the event
  33980. * @param meshUnderPointer The mesh that is currently pointed at (can be null)
  33981. * @param sourceEvent the original (browser) event that triggered the ActionEvent
  33982. * @param additionalData additional data for the event
  33983. */
  33984. constructor(
  33985. /** The mesh or sprite that triggered the action */
  33986. source: any,
  33987. /** The X mouse cursor position at the time of the event */
  33988. pointerX: number,
  33989. /** The Y mouse cursor position at the time of the event */
  33990. pointerY: number,
  33991. /** The mesh that is currently pointed at (can be null) */
  33992. meshUnderPointer: Nullable<AbstractMesh>,
  33993. /** the original (browser) event that triggered the ActionEvent */
  33994. sourceEvent?: any,
  33995. /** additional data for the event */
  33996. additionalData?: any);
  33997. /**
  33998. * Helper function to auto-create an ActionEvent from a source mesh.
  33999. * @param source The source mesh that triggered the event
  34000. * @param evt The original (browser) event
  34001. * @param additionalData additional data for the event
  34002. * @returns the new ActionEvent
  34003. */
  34004. static CreateNew(source: AbstractMesh, evt?: Event, additionalData?: any): ActionEvent;
  34005. /**
  34006. * Helper function to auto-create an ActionEvent from a source sprite
  34007. * @param source The source sprite that triggered the event
  34008. * @param scene Scene associated with the sprite
  34009. * @param evt The original (browser) event
  34010. * @param additionalData additional data for the event
  34011. * @returns the new ActionEvent
  34012. */
  34013. static CreateNewFromSprite(source: Sprite, scene: Scene, evt?: Event, additionalData?: any): ActionEvent;
  34014. /**
  34015. * Helper function to auto-create an ActionEvent from a scene. If triggered by a mesh use ActionEvent.CreateNew
  34016. * @param scene the scene where the event occurred
  34017. * @param evt The original (browser) event
  34018. * @returns the new ActionEvent
  34019. */
  34020. static CreateNewFromScene(scene: Scene, evt: Event): ActionEvent;
  34021. /**
  34022. * Helper function to auto-create an ActionEvent from a primitive
  34023. * @param prim defines the target primitive
  34024. * @param pointerPos defines the pointer position
  34025. * @param evt The original (browser) event
  34026. * @param additionalData additional data for the event
  34027. * @returns the new ActionEvent
  34028. */
  34029. static CreateNewFromPrimitive(prim: any, pointerPos: Vector2, evt?: Event, additionalData?: any): ActionEvent;
  34030. }
  34031. }
  34032. declare module "babylonjs/Actions/abstractActionManager" {
  34033. import { IDisposable } from "babylonjs/scene";
  34034. import { IActionEvent } from "babylonjs/Actions/actionEvent";
  34035. import { IAction } from "babylonjs/Actions/action";
  34036. import { Nullable } from "babylonjs/types";
  34037. /**
  34038. * Abstract class used to decouple action Manager from scene and meshes.
  34039. * Do not instantiate.
  34040. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  34041. */
  34042. export abstract class AbstractActionManager implements IDisposable {
  34043. /** Gets the list of active triggers */
  34044. static Triggers: {
  34045. [key: string]: number;
  34046. };
  34047. /** Gets the cursor to use when hovering items */
  34048. hoverCursor: string;
  34049. /** Gets the list of actions */
  34050. actions: IAction[];
  34051. /**
  34052. * Gets or sets a boolean indicating that the manager is recursive meaning that it can trigger action from children
  34053. */
  34054. isRecursive: boolean;
  34055. /**
  34056. * Releases all associated resources
  34057. */
  34058. abstract dispose(): void;
  34059. /**
  34060. * Does this action manager has pointer triggers
  34061. */
  34062. abstract get hasPointerTriggers(): boolean;
  34063. /**
  34064. * Does this action manager has pick triggers
  34065. */
  34066. abstract get hasPickTriggers(): boolean;
  34067. /**
  34068. * Process a specific trigger
  34069. * @param trigger defines the trigger to process
  34070. * @param evt defines the event details to be processed
  34071. */
  34072. abstract processTrigger(trigger: number, evt?: IActionEvent): void;
  34073. /**
  34074. * Does this action manager handles actions of any of the given triggers
  34075. * @param triggers defines the triggers to be tested
  34076. * @return a boolean indicating whether one (or more) of the triggers is handled
  34077. */
  34078. abstract hasSpecificTriggers(triggers: number[]): boolean;
  34079. /**
  34080. * Does this action manager handles actions of any of the given triggers. This function takes two arguments for
  34081. * speed.
  34082. * @param triggerA defines the trigger to be tested
  34083. * @param triggerB defines the trigger to be tested
  34084. * @return a boolean indicating whether one (or more) of the triggers is handled
  34085. */
  34086. abstract hasSpecificTriggers2(triggerA: number, triggerB: number): boolean;
  34087. /**
  34088. * Does this action manager handles actions of a given trigger
  34089. * @param trigger defines the trigger to be tested
  34090. * @param parameterPredicate defines an optional predicate to filter triggers by parameter
  34091. * @return whether the trigger is handled
  34092. */
  34093. abstract hasSpecificTrigger(trigger: number, parameterPredicate?: (parameter: any) => boolean): boolean;
  34094. /**
  34095. * Serialize this manager to a JSON object
  34096. * @param name defines the property name to store this manager
  34097. * @returns a JSON representation of this manager
  34098. */
  34099. abstract serialize(name: string): any;
  34100. /**
  34101. * Registers an action to this action manager
  34102. * @param action defines the action to be registered
  34103. * @return the action amended (prepared) after registration
  34104. */
  34105. abstract registerAction(action: IAction): Nullable<IAction>;
  34106. /**
  34107. * Unregisters an action to this action manager
  34108. * @param action defines the action to be unregistered
  34109. * @return a boolean indicating whether the action has been unregistered
  34110. */
  34111. abstract unregisterAction(action: IAction): Boolean;
  34112. /**
  34113. * Does exist one action manager with at least one trigger
  34114. **/
  34115. static get HasTriggers(): boolean;
  34116. /**
  34117. * Does exist one action manager with at least one pick trigger
  34118. **/
  34119. static get HasPickTriggers(): boolean;
  34120. /**
  34121. * Does exist one action manager that handles actions of a given trigger
  34122. * @param trigger defines the trigger to be tested
  34123. * @return a boolean indicating whether the trigger is handeled by at least one action manager
  34124. **/
  34125. static HasSpecificTrigger(trigger: number): boolean;
  34126. }
  34127. }
  34128. declare module "babylonjs/node" {
  34129. import { Scene } from "babylonjs/scene";
  34130. import { Nullable } from "babylonjs/types";
  34131. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  34132. import { Engine } from "babylonjs/Engines/engine";
  34133. import { IBehaviorAware, Behavior } from "babylonjs/Behaviors/behavior";
  34134. import { Observable } from "babylonjs/Misc/observable";
  34135. import { AbstractActionManager } from "babylonjs/Actions/abstractActionManager";
  34136. import { IInspectable } from "babylonjs/Misc/iInspectable";
  34137. import { Animatable } from "babylonjs/Animations/animatable";
  34138. import { AnimationPropertiesOverride } from "babylonjs/Animations/animationPropertiesOverride";
  34139. import { Animation } from "babylonjs/Animations/animation";
  34140. import { AnimationRange } from "babylonjs/Animations/animationRange";
  34141. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  34142. /**
  34143. * Defines how a node can be built from a string name.
  34144. */
  34145. export type NodeConstructor = (name: string, scene: Scene, options?: any) => () => Node;
  34146. /**
  34147. * Node is the basic class for all scene objects (Mesh, Light, Camera.)
  34148. */
  34149. export class Node implements IBehaviorAware<Node> {
  34150. /** @hidden */
  34151. static _AnimationRangeFactory: (name: string, from: number, to: number) => AnimationRange;
  34152. private static _NodeConstructors;
  34153. /**
  34154. * Add a new node constructor
  34155. * @param type defines the type name of the node to construct
  34156. * @param constructorFunc defines the constructor function
  34157. */
  34158. static AddNodeConstructor(type: string, constructorFunc: NodeConstructor): void;
  34159. /**
  34160. * Returns a node constructor based on type name
  34161. * @param type defines the type name
  34162. * @param name defines the new node name
  34163. * @param scene defines the hosting scene
  34164. * @param options defines optional options to transmit to constructors
  34165. * @returns the new constructor or null
  34166. */
  34167. static Construct(type: string, name: string, scene: Scene, options?: any): Nullable<() => Node>;
  34168. /**
  34169. * Gets or sets the name of the node
  34170. */
  34171. name: string;
  34172. /**
  34173. * Gets or sets the id of the node
  34174. */
  34175. id: string;
  34176. /**
  34177. * Gets or sets the unique id of the node
  34178. */
  34179. uniqueId: number;
  34180. /**
  34181. * Gets or sets a string used to store user defined state for the node
  34182. */
  34183. state: string;
  34184. /**
  34185. * Gets or sets an object used to store user defined information for the node
  34186. */
  34187. metadata: any;
  34188. /**
  34189. * For internal use only. Please do not use.
  34190. */
  34191. reservedDataStore: any;
  34192. /**
  34193. * List of inspectable custom properties (used by the Inspector)
  34194. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  34195. */
  34196. inspectableCustomProperties: IInspectable[];
  34197. private _doNotSerialize;
  34198. /**
  34199. * Gets or sets a boolean used to define if the node must be serialized
  34200. */
  34201. get doNotSerialize(): boolean;
  34202. set doNotSerialize(value: boolean);
  34203. /** @hidden */
  34204. _isDisposed: boolean;
  34205. /**
  34206. * Gets a list of Animations associated with the node
  34207. */
  34208. animations: import("babylonjs/Animations/animation").Animation[];
  34209. protected _ranges: {
  34210. [name: string]: Nullable<AnimationRange>;
  34211. };
  34212. /**
  34213. * Callback raised when the node is ready to be used
  34214. */
  34215. onReady: Nullable<(node: Node) => void>;
  34216. private _isEnabled;
  34217. private _isParentEnabled;
  34218. private _isReady;
  34219. /** @hidden */
  34220. _currentRenderId: number;
  34221. private _parentUpdateId;
  34222. /** @hidden */
  34223. _childUpdateId: number;
  34224. /** @hidden */
  34225. _waitingParentId: Nullable<string>;
  34226. /** @hidden */
  34227. _scene: Scene;
  34228. /** @hidden */
  34229. _cache: any;
  34230. private _parentNode;
  34231. private _children;
  34232. /** @hidden */
  34233. _worldMatrix: Matrix;
  34234. /** @hidden */
  34235. _worldMatrixDeterminant: number;
  34236. /** @hidden */
  34237. _worldMatrixDeterminantIsDirty: boolean;
  34238. /** @hidden */
  34239. private _sceneRootNodesIndex;
  34240. /**
  34241. * Gets a boolean indicating if the node has been disposed
  34242. * @returns true if the node was disposed
  34243. */
  34244. isDisposed(): boolean;
  34245. /**
  34246. * Gets or sets the parent of the node (without keeping the current position in the scene)
  34247. * @see https://doc.babylonjs.com/how_to/parenting
  34248. */
  34249. set parent(parent: Nullable<Node>);
  34250. get parent(): Nullable<Node>;
  34251. /** @hidden */
  34252. _addToSceneRootNodes(): void;
  34253. /** @hidden */
  34254. _removeFromSceneRootNodes(): void;
  34255. private _animationPropertiesOverride;
  34256. /**
  34257. * Gets or sets the animation properties override
  34258. */
  34259. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  34260. set animationPropertiesOverride(value: Nullable<AnimationPropertiesOverride>);
  34261. /**
  34262. * Gets a string identifying the name of the class
  34263. * @returns "Node" string
  34264. */
  34265. getClassName(): string;
  34266. /** @hidden */
  34267. readonly _isNode: boolean;
  34268. /**
  34269. * An event triggered when the mesh is disposed
  34270. */
  34271. onDisposeObservable: Observable<Node>;
  34272. private _onDisposeObserver;
  34273. /**
  34274. * Sets a callback that will be raised when the node will be disposed
  34275. */
  34276. set onDispose(callback: () => void);
  34277. /**
  34278. * Creates a new Node
  34279. * @param name the name and id to be given to this node
  34280. * @param scene the scene this node will be added to
  34281. */
  34282. constructor(name: string, scene?: Nullable<Scene>);
  34283. /**
  34284. * Gets the scene of the node
  34285. * @returns a scene
  34286. */
  34287. getScene(): Scene;
  34288. /**
  34289. * Gets the engine of the node
  34290. * @returns a Engine
  34291. */
  34292. getEngine(): Engine;
  34293. private _behaviors;
  34294. /**
  34295. * Attach a behavior to the node
  34296. * @see https://doc.babylonjs.com/features/behaviour
  34297. * @param behavior defines the behavior to attach
  34298. * @param attachImmediately defines that the behavior must be attached even if the scene is still loading
  34299. * @returns the current Node
  34300. */
  34301. addBehavior(behavior: Behavior<Node>, attachImmediately?: boolean): Node;
  34302. /**
  34303. * Remove an attached behavior
  34304. * @see https://doc.babylonjs.com/features/behaviour
  34305. * @param behavior defines the behavior to attach
  34306. * @returns the current Node
  34307. */
  34308. removeBehavior(behavior: Behavior<Node>): Node;
  34309. /**
  34310. * Gets the list of attached behaviors
  34311. * @see https://doc.babylonjs.com/features/behaviour
  34312. */
  34313. get behaviors(): Behavior<Node>[];
  34314. /**
  34315. * Gets an attached behavior by name
  34316. * @param name defines the name of the behavior to look for
  34317. * @see https://doc.babylonjs.com/features/behaviour
  34318. * @returns null if behavior was not found else the requested behavior
  34319. */
  34320. getBehaviorByName(name: string): Nullable<Behavior<Node>>;
  34321. /**
  34322. * Returns the latest update of the World matrix
  34323. * @returns a Matrix
  34324. */
  34325. getWorldMatrix(): Matrix;
  34326. /** @hidden */
  34327. _getWorldMatrixDeterminant(): number;
  34328. /**
  34329. * Returns directly the latest state of the mesh World matrix.
  34330. * A Matrix is returned.
  34331. */
  34332. get worldMatrixFromCache(): Matrix;
  34333. /** @hidden */
  34334. _initCache(): void;
  34335. /** @hidden */
  34336. updateCache(force?: boolean): void;
  34337. /** @hidden */
  34338. _getActionManagerForTrigger(trigger?: number, initialCall?: boolean): Nullable<AbstractActionManager>;
  34339. /** @hidden */
  34340. _updateCache(ignoreParentClass?: boolean): void;
  34341. /** @hidden */
  34342. _isSynchronized(): boolean;
  34343. /** @hidden */
  34344. _markSyncedWithParent(): void;
  34345. /** @hidden */
  34346. isSynchronizedWithParent(): boolean;
  34347. /** @hidden */
  34348. isSynchronized(): boolean;
  34349. /**
  34350. * Is this node ready to be used/rendered
  34351. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  34352. * @return true if the node is ready
  34353. */
  34354. isReady(completeCheck?: boolean): boolean;
  34355. /**
  34356. * Is this node enabled?
  34357. * 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
  34358. * @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
  34359. * @return whether this node (and its parent) is enabled
  34360. */
  34361. isEnabled(checkAncestors?: boolean): boolean;
  34362. /** @hidden */
  34363. protected _syncParentEnabledState(): void;
  34364. /**
  34365. * Set the enabled state of this node
  34366. * @param value defines the new enabled state
  34367. */
  34368. setEnabled(value: boolean): void;
  34369. /**
  34370. * Is this node a descendant of the given node?
  34371. * The function will iterate up the hierarchy until the ancestor was found or no more parents defined
  34372. * @param ancestor defines the parent node to inspect
  34373. * @returns a boolean indicating if this node is a descendant of the given node
  34374. */
  34375. isDescendantOf(ancestor: Node): boolean;
  34376. /** @hidden */
  34377. _getDescendants(results: Node[], directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): void;
  34378. /**
  34379. * Will return all nodes that have this node as ascendant
  34380. * @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
  34381. * @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
  34382. * @return all children nodes of all types
  34383. */
  34384. getDescendants(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): Node[];
  34385. /**
  34386. * Get all child-meshes of this node
  34387. * @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)
  34388. * @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
  34389. * @returns an array of AbstractMesh
  34390. */
  34391. getChildMeshes(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): AbstractMesh[];
  34392. /**
  34393. * Get all direct children of this node
  34394. * @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
  34395. * @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)
  34396. * @returns an array of Node
  34397. */
  34398. getChildren(predicate?: (node: Node) => boolean, directDescendantsOnly?: boolean): Node[];
  34399. /** @hidden */
  34400. _setReady(state: boolean): void;
  34401. /**
  34402. * Get an animation by name
  34403. * @param name defines the name of the animation to look for
  34404. * @returns null if not found else the requested animation
  34405. */
  34406. getAnimationByName(name: string): Nullable<Animation>;
  34407. /**
  34408. * Creates an animation range for this node
  34409. * @param name defines the name of the range
  34410. * @param from defines the starting key
  34411. * @param to defines the end key
  34412. */
  34413. createAnimationRange(name: string, from: number, to: number): void;
  34414. /**
  34415. * Delete a specific animation range
  34416. * @param name defines the name of the range to delete
  34417. * @param deleteFrames defines if animation frames from the range must be deleted as well
  34418. */
  34419. deleteAnimationRange(name: string, deleteFrames?: boolean): void;
  34420. /**
  34421. * Get an animation range by name
  34422. * @param name defines the name of the animation range to look for
  34423. * @returns null if not found else the requested animation range
  34424. */
  34425. getAnimationRange(name: string): Nullable<AnimationRange>;
  34426. /**
  34427. * Gets the list of all animation ranges defined on this node
  34428. * @returns an array
  34429. */
  34430. getAnimationRanges(): Nullable<AnimationRange>[];
  34431. /**
  34432. * Will start the animation sequence
  34433. * @param name defines the range frames for animation sequence
  34434. * @param loop defines if the animation should loop (false by default)
  34435. * @param speedRatio defines the speed factor in which to run the animation (1 by default)
  34436. * @param onAnimationEnd defines a function to be executed when the animation ended (undefined by default)
  34437. * @returns the object created for this animation. If range does not exist, it will return null
  34438. */
  34439. beginAnimation(name: string, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Nullable<Animatable>;
  34440. /**
  34441. * Serialize animation ranges into a JSON compatible object
  34442. * @returns serialization object
  34443. */
  34444. serializeAnimationRanges(): any;
  34445. /**
  34446. * Computes the world matrix of the node
  34447. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  34448. * @returns the world matrix
  34449. */
  34450. computeWorldMatrix(force?: boolean): Matrix;
  34451. /**
  34452. * Releases resources associated with this node.
  34453. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  34454. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  34455. */
  34456. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  34457. /**
  34458. * Parse animation range data from a serialization object and store them into a given node
  34459. * @param node defines where to store the animation ranges
  34460. * @param parsedNode defines the serialization object to read data from
  34461. * @param scene defines the hosting scene
  34462. */
  34463. static ParseAnimationRanges(node: Node, parsedNode: any, scene: Scene): void;
  34464. /**
  34465. * Return the minimum and maximum world vectors of the entire hierarchy under current node
  34466. * @param includeDescendants Include bounding info from descendants as well (true by default)
  34467. * @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
  34468. * @returns the new bounding vectors
  34469. */
  34470. getHierarchyBoundingVectors(includeDescendants?: boolean, predicate?: Nullable<(abstractMesh: AbstractMesh) => boolean>): {
  34471. min: Vector3;
  34472. max: Vector3;
  34473. };
  34474. }
  34475. }
  34476. declare module "babylonjs/Animations/animation" {
  34477. import { IEasingFunction, EasingFunction } from "babylonjs/Animations/easing";
  34478. import { Vector3, Quaternion, Vector2, Matrix } from "babylonjs/Maths/math.vector";
  34479. import { Color3, Color4 } from "babylonjs/Maths/math.color";
  34480. import { Nullable } from "babylonjs/types";
  34481. import { Scene } from "babylonjs/scene";
  34482. import { IAnimationKey } from "babylonjs/Animations/animationKey";
  34483. import { AnimationRange } from "babylonjs/Animations/animationRange";
  34484. import { AnimationEvent } from "babylonjs/Animations/animationEvent";
  34485. import { Node } from "babylonjs/node";
  34486. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  34487. import { Size } from "babylonjs/Maths/math.size";
  34488. import { Animatable } from "babylonjs/Animations/animatable";
  34489. import { RuntimeAnimation } from "babylonjs/Animations/runtimeAnimation";
  34490. /**
  34491. * @hidden
  34492. */
  34493. export class _IAnimationState {
  34494. key: number;
  34495. repeatCount: number;
  34496. workValue?: any;
  34497. loopMode?: number;
  34498. offsetValue?: any;
  34499. highLimitValue?: any;
  34500. }
  34501. /**
  34502. * Class used to store any kind of animation
  34503. */
  34504. export class Animation {
  34505. /**Name of the animation */
  34506. name: string;
  34507. /**Property to animate */
  34508. targetProperty: string;
  34509. /**The frames per second of the animation */
  34510. framePerSecond: number;
  34511. /**The data type of the animation */
  34512. dataType: number;
  34513. /**The loop mode of the animation */
  34514. loopMode?: number | undefined;
  34515. /**Specifies if blending should be enabled */
  34516. enableBlending?: boolean | undefined;
  34517. /**
  34518. * Use matrix interpolation instead of using direct key value when animating matrices
  34519. */
  34520. static AllowMatricesInterpolation: boolean;
  34521. /**
  34522. * When matrix interpolation is enabled, this boolean forces the system to use Matrix.DecomposeLerp instead of Matrix.Lerp. Interpolation is more precise but slower
  34523. */
  34524. static AllowMatrixDecomposeForInterpolation: boolean;
  34525. /** Define the Url to load snippets */
  34526. static SnippetUrl: string;
  34527. /** Snippet ID if the animation was created from the snippet server */
  34528. snippetId: string;
  34529. /**
  34530. * Stores the key frames of the animation
  34531. */
  34532. private _keys;
  34533. /**
  34534. * Stores the easing function of the animation
  34535. */
  34536. private _easingFunction;
  34537. /**
  34538. * @hidden Internal use only
  34539. */
  34540. _runtimeAnimations: import("babylonjs/Animations/runtimeAnimation").RuntimeAnimation[];
  34541. /**
  34542. * The set of event that will be linked to this animation
  34543. */
  34544. private _events;
  34545. /**
  34546. * Stores an array of target property paths
  34547. */
  34548. targetPropertyPath: string[];
  34549. /**
  34550. * Stores the blending speed of the animation
  34551. */
  34552. blendingSpeed: number;
  34553. /**
  34554. * Stores the animation ranges for the animation
  34555. */
  34556. private _ranges;
  34557. /**
  34558. * @hidden Internal use
  34559. */
  34560. static _PrepareAnimation(name: string, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction): Nullable<Animation>;
  34561. /**
  34562. * Sets up an animation
  34563. * @param property The property to animate
  34564. * @param animationType The animation type to apply
  34565. * @param framePerSecond The frames per second of the animation
  34566. * @param easingFunction The easing function used in the animation
  34567. * @returns The created animation
  34568. */
  34569. static CreateAnimation(property: string, animationType: number, framePerSecond: number, easingFunction: EasingFunction): Animation;
  34570. /**
  34571. * Create and start an animation on a node
  34572. * @param name defines the name of the global animation that will be run on all nodes
  34573. * @param node defines the root node where the animation will take place
  34574. * @param targetProperty defines property to animate
  34575. * @param framePerSecond defines the number of frame per second yo use
  34576. * @param totalFrame defines the number of frames in total
  34577. * @param from defines the initial value
  34578. * @param to defines the final value
  34579. * @param loopMode defines which loop mode you want to use (off by default)
  34580. * @param easingFunction defines the easing function to use (linear by default)
  34581. * @param onAnimationEnd defines the callback to call when animation end
  34582. * @returns the animatable created for this animation
  34583. */
  34584. static CreateAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  34585. /**
  34586. * Create and start an animation on a node and its descendants
  34587. * @param name defines the name of the global animation that will be run on all nodes
  34588. * @param node defines the root node where the animation will take place
  34589. * @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
  34590. * @param targetProperty defines property to animate
  34591. * @param framePerSecond defines the number of frame per second to use
  34592. * @param totalFrame defines the number of frames in total
  34593. * @param from defines the initial value
  34594. * @param to defines the final value
  34595. * @param loopMode defines which loop mode you want to use (off by default)
  34596. * @param easingFunction defines the easing function to use (linear by default)
  34597. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  34598. * @returns the list of animatables created for all nodes
  34599. * @example https://www.babylonjs-playground.com/#MH0VLI
  34600. */
  34601. 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[]>;
  34602. /**
  34603. * Creates a new animation, merges it with the existing animations and starts it
  34604. * @param name Name of the animation
  34605. * @param node Node which contains the scene that begins the animations
  34606. * @param targetProperty Specifies which property to animate
  34607. * @param framePerSecond The frames per second of the animation
  34608. * @param totalFrame The total number of frames
  34609. * @param from The frame at the beginning of the animation
  34610. * @param to The frame at the end of the animation
  34611. * @param loopMode Specifies the loop mode of the animation
  34612. * @param easingFunction (Optional) The easing function of the animation, which allow custom mathematical formulas for animations
  34613. * @param onAnimationEnd Callback to run once the animation is complete
  34614. * @returns Nullable animation
  34615. */
  34616. static CreateMergeAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  34617. /**
  34618. * Convert the keyframes for all animations belonging to the group to be relative to a given reference frame.
  34619. * @param sourceAnimation defines the Animation containing keyframes to convert
  34620. * @param referenceFrame defines the frame that keyframes in the range will be relative to
  34621. * @param range defines the name of the AnimationRange belonging to the Animation to convert
  34622. * @param cloneOriginal defines whether or not to clone the animation and convert the clone or convert the original animation (default is false)
  34623. * @param clonedName defines the name of the resulting cloned Animation if cloneOriginal is true
  34624. * @returns a new Animation if cloneOriginal is true or the original Animation if cloneOriginal is false
  34625. */
  34626. static MakeAnimationAdditive(sourceAnimation: Animation, referenceFrame?: number, range?: string, cloneOriginal?: boolean, clonedName?: string): Animation;
  34627. /**
  34628. * Transition property of an host to the target Value
  34629. * @param property The property to transition
  34630. * @param targetValue The target Value of the property
  34631. * @param host The object where the property to animate belongs
  34632. * @param scene Scene used to run the animation
  34633. * @param frameRate Framerate (in frame/s) to use
  34634. * @param transition The transition type we want to use
  34635. * @param duration The duration of the animation, in milliseconds
  34636. * @param onAnimationEnd Callback trigger at the end of the animation
  34637. * @returns Nullable animation
  34638. */
  34639. static TransitionTo(property: string, targetValue: any, host: any, scene: Scene, frameRate: number, transition: Animation, duration: number, onAnimationEnd?: Nullable<() => void>): Nullable<Animatable>;
  34640. /**
  34641. * Return the array of runtime animations currently using this animation
  34642. */
  34643. get runtimeAnimations(): RuntimeAnimation[];
  34644. /**
  34645. * Specifies if any of the runtime animations are currently running
  34646. */
  34647. get hasRunningRuntimeAnimations(): boolean;
  34648. /**
  34649. * Initializes the animation
  34650. * @param name Name of the animation
  34651. * @param targetProperty Property to animate
  34652. * @param framePerSecond The frames per second of the animation
  34653. * @param dataType The data type of the animation
  34654. * @param loopMode The loop mode of the animation
  34655. * @param enableBlending Specifies if blending should be enabled
  34656. */
  34657. constructor(
  34658. /**Name of the animation */
  34659. name: string,
  34660. /**Property to animate */
  34661. targetProperty: string,
  34662. /**The frames per second of the animation */
  34663. framePerSecond: number,
  34664. /**The data type of the animation */
  34665. dataType: number,
  34666. /**The loop mode of the animation */
  34667. loopMode?: number | undefined,
  34668. /**Specifies if blending should be enabled */
  34669. enableBlending?: boolean | undefined);
  34670. /**
  34671. * Converts the animation to a string
  34672. * @param fullDetails support for multiple levels of logging within scene loading
  34673. * @returns String form of the animation
  34674. */
  34675. toString(fullDetails?: boolean): string;
  34676. /**
  34677. * Add an event to this animation
  34678. * @param event Event to add
  34679. */
  34680. addEvent(event: AnimationEvent): void;
  34681. /**
  34682. * Remove all events found at the given frame
  34683. * @param frame The frame to remove events from
  34684. */
  34685. removeEvents(frame: number): void;
  34686. /**
  34687. * Retrieves all the events from the animation
  34688. * @returns Events from the animation
  34689. */
  34690. getEvents(): AnimationEvent[];
  34691. /**
  34692. * Creates an animation range
  34693. * @param name Name of the animation range
  34694. * @param from Starting frame of the animation range
  34695. * @param to Ending frame of the animation
  34696. */
  34697. createRange(name: string, from: number, to: number): void;
  34698. /**
  34699. * Deletes an animation range by name
  34700. * @param name Name of the animation range to delete
  34701. * @param deleteFrames Specifies if the key frames for the range should also be deleted (true) or not (false)
  34702. */
  34703. deleteRange(name: string, deleteFrames?: boolean): void;
  34704. /**
  34705. * Gets the animation range by name, or null if not defined
  34706. * @param name Name of the animation range
  34707. * @returns Nullable animation range
  34708. */
  34709. getRange(name: string): Nullable<AnimationRange>;
  34710. /**
  34711. * Gets the key frames from the animation
  34712. * @returns The key frames of the animation
  34713. */
  34714. getKeys(): Array<IAnimationKey>;
  34715. /**
  34716. * Gets the highest frame rate of the animation
  34717. * @returns Highest frame rate of the animation
  34718. */
  34719. getHighestFrame(): number;
  34720. /**
  34721. * Gets the easing function of the animation
  34722. * @returns Easing function of the animation
  34723. */
  34724. getEasingFunction(): IEasingFunction;
  34725. /**
  34726. * Sets the easing function of the animation
  34727. * @param easingFunction A custom mathematical formula for animation
  34728. */
  34729. setEasingFunction(easingFunction: EasingFunction): void;
  34730. /**
  34731. * Interpolates a scalar linearly
  34732. * @param startValue Start value of the animation curve
  34733. * @param endValue End value of the animation curve
  34734. * @param gradient Scalar amount to interpolate
  34735. * @returns Interpolated scalar value
  34736. */
  34737. floatInterpolateFunction(startValue: number, endValue: number, gradient: number): number;
  34738. /**
  34739. * Interpolates a scalar cubically
  34740. * @param startValue Start value of the animation curve
  34741. * @param outTangent End tangent of the animation
  34742. * @param endValue End value of the animation curve
  34743. * @param inTangent Start tangent of the animation curve
  34744. * @param gradient Scalar amount to interpolate
  34745. * @returns Interpolated scalar value
  34746. */
  34747. floatInterpolateFunctionWithTangents(startValue: number, outTangent: number, endValue: number, inTangent: number, gradient: number): number;
  34748. /**
  34749. * Interpolates a quaternion using a spherical linear interpolation
  34750. * @param startValue Start value of the animation curve
  34751. * @param endValue End value of the animation curve
  34752. * @param gradient Scalar amount to interpolate
  34753. * @returns Interpolated quaternion value
  34754. */
  34755. quaternionInterpolateFunction(startValue: Quaternion, endValue: Quaternion, gradient: number): Quaternion;
  34756. /**
  34757. * Interpolates a quaternion cubically
  34758. * @param startValue Start value of the animation curve
  34759. * @param outTangent End tangent of the animation curve
  34760. * @param endValue End value of the animation curve
  34761. * @param inTangent Start tangent of the animation curve
  34762. * @param gradient Scalar amount to interpolate
  34763. * @returns Interpolated quaternion value
  34764. */
  34765. quaternionInterpolateFunctionWithTangents(startValue: Quaternion, outTangent: Quaternion, endValue: Quaternion, inTangent: Quaternion, gradient: number): Quaternion;
  34766. /**
  34767. * Interpolates a Vector3 linearl
  34768. * @param startValue Start value of the animation curve
  34769. * @param endValue End value of the animation curve
  34770. * @param gradient Scalar amount to interpolate
  34771. * @returns Interpolated scalar value
  34772. */
  34773. vector3InterpolateFunction(startValue: Vector3, endValue: Vector3, gradient: number): Vector3;
  34774. /**
  34775. * Interpolates a Vector3 cubically
  34776. * @param startValue Start value of the animation curve
  34777. * @param outTangent End tangent of the animation
  34778. * @param endValue End value of the animation curve
  34779. * @param inTangent Start tangent of the animation curve
  34780. * @param gradient Scalar amount to interpolate
  34781. * @returns InterpolatedVector3 value
  34782. */
  34783. vector3InterpolateFunctionWithTangents(startValue: Vector3, outTangent: Vector3, endValue: Vector3, inTangent: Vector3, gradient: number): Vector3;
  34784. /**
  34785. * Interpolates a Vector2 linearly
  34786. * @param startValue Start value of the animation curve
  34787. * @param endValue End value of the animation curve
  34788. * @param gradient Scalar amount to interpolate
  34789. * @returns Interpolated Vector2 value
  34790. */
  34791. vector2InterpolateFunction(startValue: Vector2, endValue: Vector2, gradient: number): Vector2;
  34792. /**
  34793. * Interpolates a Vector2 cubically
  34794. * @param startValue Start value of the animation curve
  34795. * @param outTangent End tangent of the animation
  34796. * @param endValue End value of the animation curve
  34797. * @param inTangent Start tangent of the animation curve
  34798. * @param gradient Scalar amount to interpolate
  34799. * @returns Interpolated Vector2 value
  34800. */
  34801. vector2InterpolateFunctionWithTangents(startValue: Vector2, outTangent: Vector2, endValue: Vector2, inTangent: Vector2, gradient: number): Vector2;
  34802. /**
  34803. * Interpolates a size linearly
  34804. * @param startValue Start value of the animation curve
  34805. * @param endValue End value of the animation curve
  34806. * @param gradient Scalar amount to interpolate
  34807. * @returns Interpolated Size value
  34808. */
  34809. sizeInterpolateFunction(startValue: Size, endValue: Size, gradient: number): Size;
  34810. /**
  34811. * Interpolates a Color3 linearly
  34812. * @param startValue Start value of the animation curve
  34813. * @param endValue End value of the animation curve
  34814. * @param gradient Scalar amount to interpolate
  34815. * @returns Interpolated Color3 value
  34816. */
  34817. color3InterpolateFunction(startValue: Color3, endValue: Color3, gradient: number): Color3;
  34818. /**
  34819. * Interpolates a Color4 linearly
  34820. * @param startValue Start value of the animation curve
  34821. * @param endValue End value of the animation curve
  34822. * @param gradient Scalar amount to interpolate
  34823. * @returns Interpolated Color3 value
  34824. */
  34825. color4InterpolateFunction(startValue: Color4, endValue: Color4, gradient: number): Color4;
  34826. /**
  34827. * @hidden Internal use only
  34828. */
  34829. _getKeyValue(value: any): any;
  34830. /**
  34831. * @hidden Internal use only
  34832. */
  34833. _interpolate(currentFrame: number, state: _IAnimationState): any;
  34834. /**
  34835. * Defines the function to use to interpolate matrices
  34836. * @param startValue defines the start matrix
  34837. * @param endValue defines the end matrix
  34838. * @param gradient defines the gradient between both matrices
  34839. * @param result defines an optional target matrix where to store the interpolation
  34840. * @returns the interpolated matrix
  34841. */
  34842. matrixInterpolateFunction(startValue: Matrix, endValue: Matrix, gradient: number, result?: Matrix): Matrix;
  34843. /**
  34844. * Makes a copy of the animation
  34845. * @returns Cloned animation
  34846. */
  34847. clone(): Animation;
  34848. /**
  34849. * Sets the key frames of the animation
  34850. * @param values The animation key frames to set
  34851. */
  34852. setKeys(values: Array<IAnimationKey>): void;
  34853. /**
  34854. * Serializes the animation to an object
  34855. * @returns Serialized object
  34856. */
  34857. serialize(): any;
  34858. /**
  34859. * Float animation type
  34860. */
  34861. static readonly ANIMATIONTYPE_FLOAT: number;
  34862. /**
  34863. * Vector3 animation type
  34864. */
  34865. static readonly ANIMATIONTYPE_VECTOR3: number;
  34866. /**
  34867. * Quaternion animation type
  34868. */
  34869. static readonly ANIMATIONTYPE_QUATERNION: number;
  34870. /**
  34871. * Matrix animation type
  34872. */
  34873. static readonly ANIMATIONTYPE_MATRIX: number;
  34874. /**
  34875. * Color3 animation type
  34876. */
  34877. static readonly ANIMATIONTYPE_COLOR3: number;
  34878. /**
  34879. * Color3 animation type
  34880. */
  34881. static readonly ANIMATIONTYPE_COLOR4: number;
  34882. /**
  34883. * Vector2 animation type
  34884. */
  34885. static readonly ANIMATIONTYPE_VECTOR2: number;
  34886. /**
  34887. * Size animation type
  34888. */
  34889. static readonly ANIMATIONTYPE_SIZE: number;
  34890. /**
  34891. * Relative Loop Mode
  34892. */
  34893. static readonly ANIMATIONLOOPMODE_RELATIVE: number;
  34894. /**
  34895. * Cycle Loop Mode
  34896. */
  34897. static readonly ANIMATIONLOOPMODE_CYCLE: number;
  34898. /**
  34899. * Constant Loop Mode
  34900. */
  34901. static readonly ANIMATIONLOOPMODE_CONSTANT: number;
  34902. /** @hidden */
  34903. static _UniversalLerp(left: any, right: any, amount: number): any;
  34904. /**
  34905. * Parses an animation object and creates an animation
  34906. * @param parsedAnimation Parsed animation object
  34907. * @returns Animation object
  34908. */
  34909. static Parse(parsedAnimation: any): Animation;
  34910. /**
  34911. * Appends the serialized animations from the source animations
  34912. * @param source Source containing the animations
  34913. * @param destination Target to store the animations
  34914. */
  34915. static AppendSerializedAnimations(source: IAnimatable, destination: any): void;
  34916. /**
  34917. * Creates a new animation or an array of animations from a snippet saved in a remote file
  34918. * @param name defines the name of the animation to create (can be null or empty to use the one from the json data)
  34919. * @param url defines the url to load from
  34920. * @returns a promise that will resolve to the new animation or an array of animations
  34921. */
  34922. static ParseFromFileAsync(name: Nullable<string>, url: string): Promise<Animation | Array<Animation>>;
  34923. /**
  34924. * Creates an animation or an array of animations from a snippet saved by the Inspector
  34925. * @param snippetId defines the snippet to load
  34926. * @returns a promise that will resolve to the new animation or a new array of animations
  34927. */
  34928. static CreateFromSnippetAsync(snippetId: string): Promise<Animation | Array<Animation>>;
  34929. }
  34930. }
  34931. declare module "babylonjs/Animations/animatable.interface" {
  34932. import { Nullable } from "babylonjs/types";
  34933. import { Animation } from "babylonjs/Animations/animation";
  34934. /**
  34935. * Interface containing an array of animations
  34936. */
  34937. export interface IAnimatable {
  34938. /**
  34939. * Array of animations
  34940. */
  34941. animations: Nullable<Array<Animation>>;
  34942. }
  34943. }
  34944. declare module "babylonjs/Misc/decorators" {
  34945. import { Nullable } from "babylonjs/types";
  34946. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  34947. import { Scene } from "babylonjs/scene";
  34948. import { ImageProcessingConfiguration } from "babylonjs/Materials/imageProcessingConfiguration";
  34949. import { FresnelParameters } from "babylonjs/Materials/fresnelParameters";
  34950. import { ColorCurves } from "babylonjs/Materials/colorCurves";
  34951. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  34952. export function expandToProperty(callback: string, targetKey?: Nullable<string>): (target: any, propertyKey: string) => void;
  34953. export function serialize(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  34954. export function serializeAsTexture(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  34955. export function serializeAsColor3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  34956. export function serializeAsFresnelParameters(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  34957. export function serializeAsVector2(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  34958. export function serializeAsVector3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  34959. export function serializeAsMeshReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  34960. export function serializeAsColorCurves(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  34961. export function serializeAsColor4(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  34962. export function serializeAsImageProcessingConfiguration(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  34963. export function serializeAsQuaternion(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  34964. export function serializeAsMatrix(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  34965. /**
  34966. * Decorator used to define property that can be serialized as reference to a camera
  34967. * @param sourceName defines the name of the property to decorate
  34968. */
  34969. export function serializeAsCameraReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  34970. /**
  34971. * Class used to help serialization objects
  34972. */
  34973. export class SerializationHelper {
  34974. /** @hidden */
  34975. static _ImageProcessingConfigurationParser: (sourceProperty: any) => ImageProcessingConfiguration;
  34976. /** @hidden */
  34977. static _FresnelParametersParser: (sourceProperty: any) => FresnelParameters;
  34978. /** @hidden */
  34979. static _ColorCurvesParser: (sourceProperty: any) => ColorCurves;
  34980. /** @hidden */
  34981. static _TextureParser: (sourceProperty: any, scene: Scene, rootUrl: string) => Nullable<BaseTexture>;
  34982. /**
  34983. * Appends the serialized animations from the source animations
  34984. * @param source Source containing the animations
  34985. * @param destination Target to store the animations
  34986. */
  34987. static AppendSerializedAnimations(source: IAnimatable, destination: any): void;
  34988. /**
  34989. * Static function used to serialized a specific entity
  34990. * @param entity defines the entity to serialize
  34991. * @param serializationObject defines the optional target obecjt where serialization data will be stored
  34992. * @returns a JSON compatible object representing the serialization of the entity
  34993. */
  34994. static Serialize<T>(entity: T, serializationObject?: any): any;
  34995. /**
  34996. * Creates a new entity from a serialization data object
  34997. * @param creationFunction defines a function used to instanciated the new entity
  34998. * @param source defines the source serialization data
  34999. * @param scene defines the hosting scene
  35000. * @param rootUrl defines the root url for resources
  35001. * @returns a new entity
  35002. */
  35003. static Parse<T>(creationFunction: () => T, source: any, scene: Nullable<Scene>, rootUrl?: Nullable<string>): T;
  35004. /**
  35005. * Clones an object
  35006. * @param creationFunction defines the function used to instanciate the new object
  35007. * @param source defines the source object
  35008. * @returns the cloned object
  35009. */
  35010. static Clone<T>(creationFunction: () => T, source: T): T;
  35011. /**
  35012. * Instanciates a new object based on a source one (some data will be shared between both object)
  35013. * @param creationFunction defines the function used to instanciate the new object
  35014. * @param source defines the source object
  35015. * @returns the new object
  35016. */
  35017. static Instanciate<T>(creationFunction: () => T, source: T): T;
  35018. }
  35019. }
  35020. declare module "babylonjs/Materials/Textures/baseTexture" {
  35021. import { Observable } from "babylonjs/Misc/observable";
  35022. import { Nullable } from "babylonjs/types";
  35023. import { Scene } from "babylonjs/scene";
  35024. import { Matrix } from "babylonjs/Maths/math.vector";
  35025. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  35026. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  35027. import { ISize } from "babylonjs/Maths/math.size";
  35028. import "babylonjs/Misc/fileTools";
  35029. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  35030. /**
  35031. * Base class of all the textures in babylon.
  35032. * It groups all the common properties the materials, post process, lights... might need
  35033. * in order to make a correct use of the texture.
  35034. */
  35035. export class BaseTexture implements IAnimatable {
  35036. /**
  35037. * Default anisotropic filtering level for the application.
  35038. * It is set to 4 as a good tradeoff between perf and quality.
  35039. */
  35040. static DEFAULT_ANISOTROPIC_FILTERING_LEVEL: number;
  35041. /**
  35042. * Gets or sets the unique id of the texture
  35043. */
  35044. uniqueId: number;
  35045. /**
  35046. * Define the name of the texture.
  35047. */
  35048. name: string;
  35049. /**
  35050. * Gets or sets an object used to store user defined information.
  35051. */
  35052. metadata: any;
  35053. /**
  35054. * For internal use only. Please do not use.
  35055. */
  35056. reservedDataStore: any;
  35057. private _hasAlpha;
  35058. /**
  35059. * Define if the texture is having a usable alpha value (can be use for transparency or glossiness for instance).
  35060. */
  35061. set hasAlpha(value: boolean);
  35062. get hasAlpha(): boolean;
  35063. /**
  35064. * Defines if the alpha value should be determined via the rgb values.
  35065. * If true the luminance of the pixel might be used to find the corresponding alpha value.
  35066. */
  35067. getAlphaFromRGB: boolean;
  35068. /**
  35069. * Intensity or strength of the texture.
  35070. * It is commonly used by materials to fine tune the intensity of the texture
  35071. */
  35072. level: number;
  35073. /**
  35074. * Define the UV chanel to use starting from 0 and defaulting to 0.
  35075. * This is part of the texture as textures usually maps to one uv set.
  35076. */
  35077. coordinatesIndex: number;
  35078. protected _coordinatesMode: number;
  35079. /**
  35080. * How a texture is mapped.
  35081. *
  35082. * | Value | Type | Description |
  35083. * | ----- | ----------------------------------- | ----------- |
  35084. * | 0 | EXPLICIT_MODE | |
  35085. * | 1 | SPHERICAL_MODE | |
  35086. * | 2 | PLANAR_MODE | |
  35087. * | 3 | CUBIC_MODE | |
  35088. * | 4 | PROJECTION_MODE | |
  35089. * | 5 | SKYBOX_MODE | |
  35090. * | 6 | INVCUBIC_MODE | |
  35091. * | 7 | EQUIRECTANGULAR_MODE | |
  35092. * | 8 | FIXED_EQUIRECTANGULAR_MODE | |
  35093. * | 9 | FIXED_EQUIRECTANGULAR_MIRRORED_MODE | |
  35094. */
  35095. set coordinatesMode(value: number);
  35096. get coordinatesMode(): number;
  35097. private _wrapU;
  35098. /**
  35099. * | Value | Type | Description |
  35100. * | ----- | ------------------ | ----------- |
  35101. * | 0 | CLAMP_ADDRESSMODE | |
  35102. * | 1 | WRAP_ADDRESSMODE | |
  35103. * | 2 | MIRROR_ADDRESSMODE | |
  35104. */
  35105. get wrapU(): number;
  35106. set wrapU(value: number);
  35107. private _wrapV;
  35108. /**
  35109. * | Value | Type | Description |
  35110. * | ----- | ------------------ | ----------- |
  35111. * | 0 | CLAMP_ADDRESSMODE | |
  35112. * | 1 | WRAP_ADDRESSMODE | |
  35113. * | 2 | MIRROR_ADDRESSMODE | |
  35114. */
  35115. get wrapV(): number;
  35116. set wrapV(value: number);
  35117. /**
  35118. * | Value | Type | Description |
  35119. * | ----- | ------------------ | ----------- |
  35120. * | 0 | CLAMP_ADDRESSMODE | |
  35121. * | 1 | WRAP_ADDRESSMODE | |
  35122. * | 2 | MIRROR_ADDRESSMODE | |
  35123. */
  35124. wrapR: number;
  35125. /**
  35126. * With compliant hardware and browser (supporting anisotropic filtering)
  35127. * this defines the level of anisotropic filtering in the texture.
  35128. * The higher the better but the slower. This defaults to 4 as it seems to be the best tradeoff.
  35129. */
  35130. anisotropicFilteringLevel: number;
  35131. /**
  35132. * Define if the texture is a cube texture or if false a 2d texture.
  35133. */
  35134. get isCube(): boolean;
  35135. set isCube(value: boolean);
  35136. /**
  35137. * Define if the texture is a 3d texture (webgl 2) or if false a 2d texture.
  35138. */
  35139. get is3D(): boolean;
  35140. set is3D(value: boolean);
  35141. /**
  35142. * Define if the texture is a 2d array texture (webgl 2) or if false a 2d texture.
  35143. */
  35144. get is2DArray(): boolean;
  35145. set is2DArray(value: boolean);
  35146. /**
  35147. * Define if the texture contains data in gamma space (most of the png/jpg aside bump).
  35148. * HDR texture are usually stored in linear space.
  35149. * This only impacts the PBR and Background materials
  35150. */
  35151. gammaSpace: boolean;
  35152. /**
  35153. * Gets or sets whether or not the texture contains RGBD data.
  35154. */
  35155. get isRGBD(): boolean;
  35156. set isRGBD(value: boolean);
  35157. /**
  35158. * Is Z inverted in the texture (useful in a cube texture).
  35159. */
  35160. invertZ: boolean;
  35161. /**
  35162. * Are mip maps generated for this texture or not.
  35163. */
  35164. get noMipmap(): boolean;
  35165. /**
  35166. * @hidden
  35167. */
  35168. lodLevelInAlpha: boolean;
  35169. /**
  35170. * With prefiltered texture, defined the offset used during the prefiltering steps.
  35171. */
  35172. get lodGenerationOffset(): number;
  35173. set lodGenerationOffset(value: number);
  35174. /**
  35175. * With prefiltered texture, defined the scale used during the prefiltering steps.
  35176. */
  35177. get lodGenerationScale(): number;
  35178. set lodGenerationScale(value: number);
  35179. /**
  35180. * With prefiltered texture, defined if the specular generation is based on a linear ramp.
  35181. * By default we are using a log2 of the linear roughness helping to keep a better resolution for
  35182. * average roughness values.
  35183. */
  35184. get linearSpecularLOD(): boolean;
  35185. set linearSpecularLOD(value: boolean);
  35186. /**
  35187. * In case a better definition than spherical harmonics is required for the diffuse part of the environment.
  35188. * You can set the irradiance texture to rely on a texture instead of the spherical approach.
  35189. * This texture need to have the same characteristics than its parent (Cube vs 2d, coordinates mode, Gamma/Linear, RGBD).
  35190. */
  35191. get irradianceTexture(): Nullable<BaseTexture>;
  35192. set irradianceTexture(value: Nullable<BaseTexture>);
  35193. /**
  35194. * Define if the texture is a render target.
  35195. */
  35196. isRenderTarget: boolean;
  35197. /**
  35198. * Define the unique id of the texture in the scene.
  35199. */
  35200. get uid(): string;
  35201. /** @hidden */
  35202. _prefiltered: boolean;
  35203. /**
  35204. * Return a string representation of the texture.
  35205. * @returns the texture as a string
  35206. */
  35207. toString(): string;
  35208. /**
  35209. * Get the class name of the texture.
  35210. * @returns "BaseTexture"
  35211. */
  35212. getClassName(): string;
  35213. /**
  35214. * Define the list of animation attached to the texture.
  35215. */
  35216. animations: import("babylonjs/Animations/animation").Animation[];
  35217. /**
  35218. * An event triggered when the texture is disposed.
  35219. */
  35220. onDisposeObservable: Observable<BaseTexture>;
  35221. private _onDisposeObserver;
  35222. /**
  35223. * Callback triggered when the texture has been disposed.
  35224. * Kept for back compatibility, you can use the onDisposeObservable instead.
  35225. */
  35226. set onDispose(callback: () => void);
  35227. /**
  35228. * Define the current state of the loading sequence when in delayed load mode.
  35229. */
  35230. delayLoadState: number;
  35231. protected _scene: Nullable<Scene>;
  35232. protected _engine: Nullable<ThinEngine>;
  35233. /** @hidden */
  35234. _texture: Nullable<InternalTexture>;
  35235. private _uid;
  35236. /**
  35237. * Define if the texture is preventinga material to render or not.
  35238. * If not and the texture is not ready, the engine will use a default black texture instead.
  35239. */
  35240. get isBlocking(): boolean;
  35241. /**
  35242. * Instantiates a new BaseTexture.
  35243. * Base class of all the textures in babylon.
  35244. * It groups all the common properties the materials, post process, lights... might need
  35245. * in order to make a correct use of the texture.
  35246. * @param sceneOrEngine Define the scene or engine the texture blongs to
  35247. */
  35248. constructor(sceneOrEngine: Nullable<Scene | ThinEngine>);
  35249. /**
  35250. * Get the scene the texture belongs to.
  35251. * @returns the scene or null if undefined
  35252. */
  35253. getScene(): Nullable<Scene>;
  35254. /** @hidden */
  35255. protected _getEngine(): Nullable<ThinEngine>;
  35256. /**
  35257. * Get the texture transform matrix used to offset tile the texture for istance.
  35258. * @returns the transformation matrix
  35259. */
  35260. getTextureMatrix(): Matrix;
  35261. /**
  35262. * Get the texture reflection matrix used to rotate/transform the reflection.
  35263. * @returns the reflection matrix
  35264. */
  35265. getReflectionTextureMatrix(): Matrix;
  35266. /**
  35267. * Get the underlying lower level texture from Babylon.
  35268. * @returns the insternal texture
  35269. */
  35270. getInternalTexture(): Nullable<InternalTexture>;
  35271. /**
  35272. * Get if the texture is ready to be consumed (either it is ready or it is not blocking)
  35273. * @returns true if ready or not blocking
  35274. */
  35275. isReadyOrNotBlocking(): boolean;
  35276. /**
  35277. * Get if the texture is ready to be used (downloaded, converted, mip mapped...).
  35278. * @returns true if fully ready
  35279. */
  35280. isReady(): boolean;
  35281. private _cachedSize;
  35282. /**
  35283. * Get the size of the texture.
  35284. * @returns the texture size.
  35285. */
  35286. getSize(): ISize;
  35287. /**
  35288. * Get the base size of the texture.
  35289. * It can be different from the size if the texture has been resized for POT for instance
  35290. * @returns the base size
  35291. */
  35292. getBaseSize(): ISize;
  35293. /**
  35294. * Update the sampling mode of the texture.
  35295. * Default is Trilinear mode.
  35296. *
  35297. * | Value | Type | Description |
  35298. * | ----- | ------------------ | ----------- |
  35299. * | 1 | NEAREST_SAMPLINGMODE or NEAREST_NEAREST_MIPLINEAR | Nearest is: mag = nearest, min = nearest, mip = linear |
  35300. * | 2 | BILINEAR_SAMPLINGMODE or LINEAR_LINEAR_MIPNEAREST | Bilinear is: mag = linear, min = linear, mip = nearest |
  35301. * | 3 | TRILINEAR_SAMPLINGMODE or LINEAR_LINEAR_MIPLINEAR | Trilinear is: mag = linear, min = linear, mip = linear |
  35302. * | 4 | NEAREST_NEAREST_MIPNEAREST | |
  35303. * | 5 | NEAREST_LINEAR_MIPNEAREST | |
  35304. * | 6 | NEAREST_LINEAR_MIPLINEAR | |
  35305. * | 7 | NEAREST_LINEAR | |
  35306. * | 8 | NEAREST_NEAREST | |
  35307. * | 9 | LINEAR_NEAREST_MIPNEAREST | |
  35308. * | 10 | LINEAR_NEAREST_MIPLINEAR | |
  35309. * | 11 | LINEAR_LINEAR | |
  35310. * | 12 | LINEAR_NEAREST | |
  35311. *
  35312. * > _mag_: magnification filter (close to the viewer)
  35313. * > _min_: minification filter (far from the viewer)
  35314. * > _mip_: filter used between mip map levels
  35315. *@param samplingMode Define the new sampling mode of the texture
  35316. */
  35317. updateSamplingMode(samplingMode: number): void;
  35318. /**
  35319. * Scales the texture if is `canRescale()`
  35320. * @param ratio the resize factor we want to use to rescale
  35321. */
  35322. scale(ratio: number): void;
  35323. /**
  35324. * Get if the texture can rescale.
  35325. */
  35326. get canRescale(): boolean;
  35327. /** @hidden */
  35328. _getFromCache(url: Nullable<string>, noMipmap: boolean, sampling?: number, invertY?: boolean): Nullable<InternalTexture>;
  35329. /** @hidden */
  35330. _rebuild(): void;
  35331. /**
  35332. * Triggers the load sequence in delayed load mode.
  35333. */
  35334. delayLoad(): void;
  35335. /**
  35336. * Clones the texture.
  35337. * @returns the cloned texture
  35338. */
  35339. clone(): Nullable<BaseTexture>;
  35340. /**
  35341. * Get the texture underlying type (INT, FLOAT...)
  35342. */
  35343. get textureType(): number;
  35344. /**
  35345. * Get the texture underlying format (RGB, RGBA...)
  35346. */
  35347. get textureFormat(): number;
  35348. /**
  35349. * Indicates that textures need to be re-calculated for all materials
  35350. */
  35351. protected _markAllSubMeshesAsTexturesDirty(): void;
  35352. /**
  35353. * Reads the pixels stored in the webgl texture and returns them as an ArrayBuffer.
  35354. * This will returns an RGBA array buffer containing either in values (0-255) or
  35355. * float values (0-1) depending of the underlying buffer type.
  35356. * @param faceIndex defines the face of the texture to read (in case of cube texture)
  35357. * @param level defines the LOD level of the texture to read (in case of Mip Maps)
  35358. * @param buffer defines a user defined buffer to fill with data (can be null)
  35359. * @returns The Array buffer containing the pixels data.
  35360. */
  35361. readPixels(faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>): Nullable<ArrayBufferView>;
  35362. /**
  35363. * Release and destroy the underlying lower level texture aka internalTexture.
  35364. */
  35365. releaseInternalTexture(): void;
  35366. /** @hidden */
  35367. get _lodTextureHigh(): Nullable<BaseTexture>;
  35368. /** @hidden */
  35369. get _lodTextureMid(): Nullable<BaseTexture>;
  35370. /** @hidden */
  35371. get _lodTextureLow(): Nullable<BaseTexture>;
  35372. /**
  35373. * Dispose the texture and release its associated resources.
  35374. */
  35375. dispose(): void;
  35376. /**
  35377. * Serialize the texture into a JSON representation that can be parsed later on.
  35378. * @returns the JSON representation of the texture
  35379. */
  35380. serialize(): any;
  35381. /**
  35382. * Helper function to be called back once a list of texture contains only ready textures.
  35383. * @param textures Define the list of textures to wait for
  35384. * @param callback Define the callback triggered once the entire list will be ready
  35385. */
  35386. static WhenAllReady(textures: BaseTexture[], callback: () => void): void;
  35387. private static _isScene;
  35388. }
  35389. }
  35390. declare module "babylonjs/Materials/effect" {
  35391. import { Observable } from "babylonjs/Misc/observable";
  35392. import { Nullable } from "babylonjs/types";
  35393. import { IDisposable } from "babylonjs/scene";
  35394. import { IPipelineContext } from "babylonjs/Engines/IPipelineContext";
  35395. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  35396. import { IMatrixLike, IVector2Like, IVector3Like, IVector4Like, IColor3Like, IColor4Like } from "babylonjs/Maths/math.like";
  35397. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  35398. import { IEffectFallbacks } from "babylonjs/Materials/iEffectFallbacks";
  35399. import { Engine } from "babylonjs/Engines/engine";
  35400. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  35401. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  35402. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  35403. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  35404. /**
  35405. * Options to be used when creating an effect.
  35406. */
  35407. export interface IEffectCreationOptions {
  35408. /**
  35409. * Atrributes that will be used in the shader.
  35410. */
  35411. attributes: string[];
  35412. /**
  35413. * Uniform varible names that will be set in the shader.
  35414. */
  35415. uniformsNames: string[];
  35416. /**
  35417. * Uniform buffer variable names that will be set in the shader.
  35418. */
  35419. uniformBuffersNames: string[];
  35420. /**
  35421. * Sampler texture variable names that will be set in the shader.
  35422. */
  35423. samplers: string[];
  35424. /**
  35425. * Define statements that will be set in the shader.
  35426. */
  35427. defines: any;
  35428. /**
  35429. * Possible fallbacks for this effect to improve performance when needed.
  35430. */
  35431. fallbacks: Nullable<IEffectFallbacks>;
  35432. /**
  35433. * Callback that will be called when the shader is compiled.
  35434. */
  35435. onCompiled: Nullable<(effect: Effect) => void>;
  35436. /**
  35437. * Callback that will be called if an error occurs during shader compilation.
  35438. */
  35439. onError: Nullable<(effect: Effect, errors: string) => void>;
  35440. /**
  35441. * Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  35442. */
  35443. indexParameters?: any;
  35444. /**
  35445. * Max number of lights that can be used in the shader.
  35446. */
  35447. maxSimultaneousLights?: number;
  35448. /**
  35449. * See https://developer.mozilla.org/en-US/docs/Web/API/WebGL2RenderingContext/transformFeedbackVaryings
  35450. */
  35451. transformFeedbackVaryings?: Nullable<string[]>;
  35452. /**
  35453. * 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
  35454. */
  35455. processFinalCode?: Nullable<(shaderType: string, code: string) => string>;
  35456. /**
  35457. * Is this effect rendering to several color attachments ?
  35458. */
  35459. multiTarget?: boolean;
  35460. }
  35461. /**
  35462. * Effect containing vertex and fragment shader that can be executed on an object.
  35463. */
  35464. export class Effect implements IDisposable {
  35465. /**
  35466. * Gets or sets the relative url used to load shaders if using the engine in non-minified mode
  35467. */
  35468. static ShadersRepository: string;
  35469. /**
  35470. * Enable logging of the shader code when a compilation error occurs
  35471. */
  35472. static LogShaderCodeOnCompilationError: boolean;
  35473. /**
  35474. * Name of the effect.
  35475. */
  35476. name: any;
  35477. /**
  35478. * String container all the define statements that should be set on the shader.
  35479. */
  35480. defines: string;
  35481. /**
  35482. * Callback that will be called when the shader is compiled.
  35483. */
  35484. onCompiled: Nullable<(effect: Effect) => void>;
  35485. /**
  35486. * Callback that will be called if an error occurs during shader compilation.
  35487. */
  35488. onError: Nullable<(effect: Effect, errors: string) => void>;
  35489. /**
  35490. * Callback that will be called when effect is bound.
  35491. */
  35492. onBind: Nullable<(effect: Effect) => void>;
  35493. /**
  35494. * Unique ID of the effect.
  35495. */
  35496. uniqueId: number;
  35497. /**
  35498. * Observable that will be called when the shader is compiled.
  35499. * It is recommended to use executeWhenCompile() or to make sure that scene.isReady() is called to get this observable raised.
  35500. */
  35501. onCompileObservable: Observable<Effect>;
  35502. /**
  35503. * Observable that will be called if an error occurs during shader compilation.
  35504. */
  35505. onErrorObservable: Observable<Effect>;
  35506. /** @hidden */
  35507. _onBindObservable: Nullable<Observable<Effect>>;
  35508. /**
  35509. * @hidden
  35510. * Specifies if the effect was previously ready
  35511. */
  35512. _wasPreviouslyReady: boolean;
  35513. /**
  35514. * Observable that will be called when effect is bound.
  35515. */
  35516. get onBindObservable(): Observable<Effect>;
  35517. /** @hidden */
  35518. _bonesComputationForcedToCPU: boolean;
  35519. /** @hidden */
  35520. _multiTarget: boolean;
  35521. private static _uniqueIdSeed;
  35522. private _engine;
  35523. private _uniformBuffersNames;
  35524. private _uniformBuffersNamesList;
  35525. private _uniformsNames;
  35526. private _samplerList;
  35527. private _samplers;
  35528. private _isReady;
  35529. private _compilationError;
  35530. private _allFallbacksProcessed;
  35531. private _attributesNames;
  35532. private _attributes;
  35533. private _attributeLocationByName;
  35534. private _uniforms;
  35535. /**
  35536. * Key for the effect.
  35537. * @hidden
  35538. */
  35539. _key: string;
  35540. private _indexParameters;
  35541. private _fallbacks;
  35542. private _vertexSourceCode;
  35543. private _fragmentSourceCode;
  35544. private _vertexSourceCodeOverride;
  35545. private _fragmentSourceCodeOverride;
  35546. private _transformFeedbackVaryings;
  35547. /**
  35548. * Compiled shader to webGL program.
  35549. * @hidden
  35550. */
  35551. _pipelineContext: Nullable<IPipelineContext>;
  35552. private _valueCache;
  35553. private static _baseCache;
  35554. /**
  35555. * Instantiates an effect.
  35556. * An effect can be used to create/manage/execute vertex and fragment shaders.
  35557. * @param baseName Name of the effect.
  35558. * @param attributesNamesOrOptions List of attribute names that will be passed to the shader or set of all options to create the effect.
  35559. * @param uniformsNamesOrEngine List of uniform variable names that will be passed to the shader or the engine that will be used to render effect.
  35560. * @param samplers List of sampler variables that will be passed to the shader.
  35561. * @param engine Engine to be used to render the effect
  35562. * @param defines Define statements to be added to the shader.
  35563. * @param fallbacks Possible fallbacks for this effect to improve performance when needed.
  35564. * @param onCompiled Callback that will be called when the shader is compiled.
  35565. * @param onError Callback that will be called if an error occurs during shader compilation.
  35566. * @param indexParameters Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  35567. */
  35568. 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);
  35569. private _useFinalCode;
  35570. /**
  35571. * Unique key for this effect
  35572. */
  35573. get key(): string;
  35574. /**
  35575. * If the effect has been compiled and prepared.
  35576. * @returns if the effect is compiled and prepared.
  35577. */
  35578. isReady(): boolean;
  35579. private _isReadyInternal;
  35580. /**
  35581. * The engine the effect was initialized with.
  35582. * @returns the engine.
  35583. */
  35584. getEngine(): Engine;
  35585. /**
  35586. * The pipeline context for this effect
  35587. * @returns the associated pipeline context
  35588. */
  35589. getPipelineContext(): Nullable<IPipelineContext>;
  35590. /**
  35591. * The set of names of attribute variables for the shader.
  35592. * @returns An array of attribute names.
  35593. */
  35594. getAttributesNames(): string[];
  35595. /**
  35596. * Returns the attribute at the given index.
  35597. * @param index The index of the attribute.
  35598. * @returns The location of the attribute.
  35599. */
  35600. getAttributeLocation(index: number): number;
  35601. /**
  35602. * Returns the attribute based on the name of the variable.
  35603. * @param name of the attribute to look up.
  35604. * @returns the attribute location.
  35605. */
  35606. getAttributeLocationByName(name: string): number;
  35607. /**
  35608. * The number of attributes.
  35609. * @returns the numnber of attributes.
  35610. */
  35611. getAttributesCount(): number;
  35612. /**
  35613. * Gets the index of a uniform variable.
  35614. * @param uniformName of the uniform to look up.
  35615. * @returns the index.
  35616. */
  35617. getUniformIndex(uniformName: string): number;
  35618. /**
  35619. * Returns the attribute based on the name of the variable.
  35620. * @param uniformName of the uniform to look up.
  35621. * @returns the location of the uniform.
  35622. */
  35623. getUniform(uniformName: string): Nullable<WebGLUniformLocation>;
  35624. /**
  35625. * Returns an array of sampler variable names
  35626. * @returns The array of sampler variable names.
  35627. */
  35628. getSamplers(): string[];
  35629. /**
  35630. * Returns an array of uniform variable names
  35631. * @returns The array of uniform variable names.
  35632. */
  35633. getUniformNames(): string[];
  35634. /**
  35635. * Returns an array of uniform buffer variable names
  35636. * @returns The array of uniform buffer variable names.
  35637. */
  35638. getUniformBuffersNames(): string[];
  35639. /**
  35640. * Returns the index parameters used to create the effect
  35641. * @returns The index parameters object
  35642. */
  35643. getIndexParameters(): any;
  35644. /**
  35645. * The error from the last compilation.
  35646. * @returns the error string.
  35647. */
  35648. getCompilationError(): string;
  35649. /**
  35650. * Gets a boolean indicating that all fallbacks were used during compilation
  35651. * @returns true if all fallbacks were used
  35652. */
  35653. allFallbacksProcessed(): boolean;
  35654. /**
  35655. * Adds a callback to the onCompiled observable and call the callback imediatly if already ready.
  35656. * @param func The callback to be used.
  35657. */
  35658. executeWhenCompiled(func: (effect: Effect) => void): void;
  35659. private _checkIsReady;
  35660. private _loadShader;
  35661. /**
  35662. * Gets the vertex shader source code of this effect
  35663. */
  35664. get vertexSourceCode(): string;
  35665. /**
  35666. * Gets the fragment shader source code of this effect
  35667. */
  35668. get fragmentSourceCode(): string;
  35669. /**
  35670. * Recompiles the webGL program
  35671. * @param vertexSourceCode The source code for the vertex shader.
  35672. * @param fragmentSourceCode The source code for the fragment shader.
  35673. * @param onCompiled Callback called when completed.
  35674. * @param onError Callback called on error.
  35675. * @hidden
  35676. */
  35677. _rebuildProgram(vertexSourceCode: string, fragmentSourceCode: string, onCompiled: (pipelineContext: IPipelineContext) => void, onError: (message: string) => void): void;
  35678. /**
  35679. * Prepares the effect
  35680. * @hidden
  35681. */
  35682. _prepareEffect(): void;
  35683. private _getShaderCodeAndErrorLine;
  35684. private _processCompilationErrors;
  35685. /**
  35686. * Checks if the effect is supported. (Must be called after compilation)
  35687. */
  35688. get isSupported(): boolean;
  35689. /**
  35690. * Binds a texture to the engine to be used as output of the shader.
  35691. * @param channel Name of the output variable.
  35692. * @param texture Texture to bind.
  35693. * @hidden
  35694. */
  35695. _bindTexture(channel: string, texture: Nullable<InternalTexture>): void;
  35696. /**
  35697. * Sets a texture on the engine to be used in the shader.
  35698. * @param channel Name of the sampler variable.
  35699. * @param texture Texture to set.
  35700. */
  35701. setTexture(channel: string, texture: Nullable<BaseTexture>): void;
  35702. /**
  35703. * Sets a depth stencil texture from a render target on the engine to be used in the shader.
  35704. * @param channel Name of the sampler variable.
  35705. * @param texture Texture to set.
  35706. */
  35707. setDepthStencilTexture(channel: string, texture: Nullable<RenderTargetTexture>): void;
  35708. /**
  35709. * Sets an array of textures on the engine to be used in the shader.
  35710. * @param channel Name of the variable.
  35711. * @param textures Textures to set.
  35712. */
  35713. setTextureArray(channel: string, textures: BaseTexture[]): void;
  35714. /**
  35715. * 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)
  35716. * @param channel Name of the sampler variable.
  35717. * @param postProcess Post process to get the input texture from.
  35718. */
  35719. setTextureFromPostProcess(channel: string, postProcess: Nullable<PostProcess>): void;
  35720. /**
  35721. * (Warning! setTextureFromPostProcessOutput may be desired instead)
  35722. * 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)
  35723. * @param channel Name of the sampler variable.
  35724. * @param postProcess Post process to get the output texture from.
  35725. */
  35726. setTextureFromPostProcessOutput(channel: string, postProcess: Nullable<PostProcess>): void;
  35727. /** @hidden */
  35728. _cacheMatrix(uniformName: string, matrix: IMatrixLike): boolean;
  35729. /** @hidden */
  35730. _cacheFloat2(uniformName: string, x: number, y: number): boolean;
  35731. /** @hidden */
  35732. _cacheFloat3(uniformName: string, x: number, y: number, z: number): boolean;
  35733. /** @hidden */
  35734. _cacheFloat4(uniformName: string, x: number, y: number, z: number, w: number): boolean;
  35735. /**
  35736. * Binds a buffer to a uniform.
  35737. * @param buffer Buffer to bind.
  35738. * @param name Name of the uniform variable to bind to.
  35739. */
  35740. bindUniformBuffer(buffer: DataBuffer, name: string): void;
  35741. /**
  35742. * Binds block to a uniform.
  35743. * @param blockName Name of the block to bind.
  35744. * @param index Index to bind.
  35745. */
  35746. bindUniformBlock(blockName: string, index: number): void;
  35747. /**
  35748. * Sets an interger value on a uniform variable.
  35749. * @param uniformName Name of the variable.
  35750. * @param value Value to be set.
  35751. * @returns this effect.
  35752. */
  35753. setInt(uniformName: string, value: number): Effect;
  35754. /**
  35755. * Sets an int array on a uniform variable.
  35756. * @param uniformName Name of the variable.
  35757. * @param array array to be set.
  35758. * @returns this effect.
  35759. */
  35760. setIntArray(uniformName: string, array: Int32Array): Effect;
  35761. /**
  35762. * 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)
  35763. * @param uniformName Name of the variable.
  35764. * @param array array to be set.
  35765. * @returns this effect.
  35766. */
  35767. setIntArray2(uniformName: string, array: Int32Array): Effect;
  35768. /**
  35769. * 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)
  35770. * @param uniformName Name of the variable.
  35771. * @param array array to be set.
  35772. * @returns this effect.
  35773. */
  35774. setIntArray3(uniformName: string, array: Int32Array): Effect;
  35775. /**
  35776. * 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)
  35777. * @param uniformName Name of the variable.
  35778. * @param array array to be set.
  35779. * @returns this effect.
  35780. */
  35781. setIntArray4(uniformName: string, array: Int32Array): Effect;
  35782. /**
  35783. * Sets an float array on a uniform variable.
  35784. * @param uniformName Name of the variable.
  35785. * @param array array to be set.
  35786. * @returns this effect.
  35787. */
  35788. setFloatArray(uniformName: string, array: Float32Array): Effect;
  35789. /**
  35790. * 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)
  35791. * @param uniformName Name of the variable.
  35792. * @param array array to be set.
  35793. * @returns this effect.
  35794. */
  35795. setFloatArray2(uniformName: string, array: Float32Array): Effect;
  35796. /**
  35797. * 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)
  35798. * @param uniformName Name of the variable.
  35799. * @param array array to be set.
  35800. * @returns this effect.
  35801. */
  35802. setFloatArray3(uniformName: string, array: Float32Array): Effect;
  35803. /**
  35804. * 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)
  35805. * @param uniformName Name of the variable.
  35806. * @param array array to be set.
  35807. * @returns this effect.
  35808. */
  35809. setFloatArray4(uniformName: string, array: Float32Array): Effect;
  35810. /**
  35811. * Sets an array on a uniform variable.
  35812. * @param uniformName Name of the variable.
  35813. * @param array array to be set.
  35814. * @returns this effect.
  35815. */
  35816. setArray(uniformName: string, array: number[]): Effect;
  35817. /**
  35818. * 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)
  35819. * @param uniformName Name of the variable.
  35820. * @param array array to be set.
  35821. * @returns this effect.
  35822. */
  35823. setArray2(uniformName: string, array: number[]): Effect;
  35824. /**
  35825. * 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)
  35826. * @param uniformName Name of the variable.
  35827. * @param array array to be set.
  35828. * @returns this effect.
  35829. */
  35830. setArray3(uniformName: string, array: number[]): Effect;
  35831. /**
  35832. * 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)
  35833. * @param uniformName Name of the variable.
  35834. * @param array array to be set.
  35835. * @returns this effect.
  35836. */
  35837. setArray4(uniformName: string, array: number[]): Effect;
  35838. /**
  35839. * Sets matrices on a uniform variable.
  35840. * @param uniformName Name of the variable.
  35841. * @param matrices matrices to be set.
  35842. * @returns this effect.
  35843. */
  35844. setMatrices(uniformName: string, matrices: Float32Array | Array<number>): Effect;
  35845. /**
  35846. * Sets matrix on a uniform variable.
  35847. * @param uniformName Name of the variable.
  35848. * @param matrix matrix to be set.
  35849. * @returns this effect.
  35850. */
  35851. setMatrix(uniformName: string, matrix: IMatrixLike): Effect;
  35852. /**
  35853. * 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)
  35854. * @param uniformName Name of the variable.
  35855. * @param matrix matrix to be set.
  35856. * @returns this effect.
  35857. */
  35858. setMatrix3x3(uniformName: string, matrix: Float32Array | Array<number>): Effect;
  35859. /**
  35860. * Sets a 2x2 matrix on a uniform variable. (Speicified as [1,2,3,4] will result in [1,2][3,4] matrix)
  35861. * @param uniformName Name of the variable.
  35862. * @param matrix matrix to be set.
  35863. * @returns this effect.
  35864. */
  35865. setMatrix2x2(uniformName: string, matrix: Float32Array | Array<number>): Effect;
  35866. /**
  35867. * Sets a float on a uniform variable.
  35868. * @param uniformName Name of the variable.
  35869. * @param value value to be set.
  35870. * @returns this effect.
  35871. */
  35872. setFloat(uniformName: string, value: number): Effect;
  35873. /**
  35874. * Sets a boolean on a uniform variable.
  35875. * @param uniformName Name of the variable.
  35876. * @param bool value to be set.
  35877. * @returns this effect.
  35878. */
  35879. setBool(uniformName: string, bool: boolean): Effect;
  35880. /**
  35881. * Sets a Vector2 on a uniform variable.
  35882. * @param uniformName Name of the variable.
  35883. * @param vector2 vector2 to be set.
  35884. * @returns this effect.
  35885. */
  35886. setVector2(uniformName: string, vector2: IVector2Like): Effect;
  35887. /**
  35888. * Sets a float2 on a uniform variable.
  35889. * @param uniformName Name of the variable.
  35890. * @param x First float in float2.
  35891. * @param y Second float in float2.
  35892. * @returns this effect.
  35893. */
  35894. setFloat2(uniformName: string, x: number, y: number): Effect;
  35895. /**
  35896. * Sets a Vector3 on a uniform variable.
  35897. * @param uniformName Name of the variable.
  35898. * @param vector3 Value to be set.
  35899. * @returns this effect.
  35900. */
  35901. setVector3(uniformName: string, vector3: IVector3Like): Effect;
  35902. /**
  35903. * Sets a float3 on a uniform variable.
  35904. * @param uniformName Name of the variable.
  35905. * @param x First float in float3.
  35906. * @param y Second float in float3.
  35907. * @param z Third float in float3.
  35908. * @returns this effect.
  35909. */
  35910. setFloat3(uniformName: string, x: number, y: number, z: number): Effect;
  35911. /**
  35912. * Sets a Vector4 on a uniform variable.
  35913. * @param uniformName Name of the variable.
  35914. * @param vector4 Value to be set.
  35915. * @returns this effect.
  35916. */
  35917. setVector4(uniformName: string, vector4: IVector4Like): Effect;
  35918. /**
  35919. * Sets a float4 on a uniform variable.
  35920. * @param uniformName Name of the variable.
  35921. * @param x First float in float4.
  35922. * @param y Second float in float4.
  35923. * @param z Third float in float4.
  35924. * @param w Fourth float in float4.
  35925. * @returns this effect.
  35926. */
  35927. setFloat4(uniformName: string, x: number, y: number, z: number, w: number): Effect;
  35928. /**
  35929. * Sets a Color3 on a uniform variable.
  35930. * @param uniformName Name of the variable.
  35931. * @param color3 Value to be set.
  35932. * @returns this effect.
  35933. */
  35934. setColor3(uniformName: string, color3: IColor3Like): Effect;
  35935. /**
  35936. * Sets a Color4 on a uniform variable.
  35937. * @param uniformName Name of the variable.
  35938. * @param color3 Value to be set.
  35939. * @param alpha Alpha value to be set.
  35940. * @returns this effect.
  35941. */
  35942. setColor4(uniformName: string, color3: IColor3Like, alpha: number): Effect;
  35943. /**
  35944. * Sets a Color4 on a uniform variable
  35945. * @param uniformName defines the name of the variable
  35946. * @param color4 defines the value to be set
  35947. * @returns this effect.
  35948. */
  35949. setDirectColor4(uniformName: string, color4: IColor4Like): Effect;
  35950. /** Release all associated resources */
  35951. dispose(): void;
  35952. /**
  35953. * This function will add a new shader to the shader store
  35954. * @param name the name of the shader
  35955. * @param pixelShader optional pixel shader content
  35956. * @param vertexShader optional vertex shader content
  35957. */
  35958. static RegisterShader(name: string, pixelShader?: string, vertexShader?: string): void;
  35959. /**
  35960. * Store of each shader (The can be looked up using effect.key)
  35961. */
  35962. static ShadersStore: {
  35963. [key: string]: string;
  35964. };
  35965. /**
  35966. * Store of each included file for a shader (The can be looked up using effect.key)
  35967. */
  35968. static IncludesShadersStore: {
  35969. [key: string]: string;
  35970. };
  35971. /**
  35972. * Resets the cache of effects.
  35973. */
  35974. static ResetCache(): void;
  35975. }
  35976. }
  35977. declare module "babylonjs/Engines/engineCapabilities" {
  35978. /**
  35979. * Interface used to describe the capabilities of the engine relatively to the current browser
  35980. */
  35981. export interface EngineCapabilities {
  35982. /** Maximum textures units per fragment shader */
  35983. maxTexturesImageUnits: number;
  35984. /** Maximum texture units per vertex shader */
  35985. maxVertexTextureImageUnits: number;
  35986. /** Maximum textures units in the entire pipeline */
  35987. maxCombinedTexturesImageUnits: number;
  35988. /** Maximum texture size */
  35989. maxTextureSize: number;
  35990. /** Maximum texture samples */
  35991. maxSamples?: number;
  35992. /** Maximum cube texture size */
  35993. maxCubemapTextureSize: number;
  35994. /** Maximum render texture size */
  35995. maxRenderTextureSize: number;
  35996. /** Maximum number of vertex attributes */
  35997. maxVertexAttribs: number;
  35998. /** Maximum number of varyings */
  35999. maxVaryingVectors: number;
  36000. /** Maximum number of uniforms per vertex shader */
  36001. maxVertexUniformVectors: number;
  36002. /** Maximum number of uniforms per fragment shader */
  36003. maxFragmentUniformVectors: number;
  36004. /** Defines if standard derivates (dx/dy) are supported */
  36005. standardDerivatives: boolean;
  36006. /** Defines if s3tc texture compression is supported */
  36007. s3tc?: WEBGL_compressed_texture_s3tc;
  36008. /** Defines if pvrtc texture compression is supported */
  36009. pvrtc: any;
  36010. /** Defines if etc1 texture compression is supported */
  36011. etc1: any;
  36012. /** Defines if etc2 texture compression is supported */
  36013. etc2: any;
  36014. /** Defines if astc texture compression is supported */
  36015. astc: any;
  36016. /** Defines if float textures are supported */
  36017. textureFloat: boolean;
  36018. /** Defines if vertex array objects are supported */
  36019. vertexArrayObject: boolean;
  36020. /** Gets the webgl extension for anisotropic filtering (null if not supported) */
  36021. textureAnisotropicFilterExtension?: EXT_texture_filter_anisotropic;
  36022. /** Gets the maximum level of anisotropy supported */
  36023. maxAnisotropy: number;
  36024. /** Defines if instancing is supported */
  36025. instancedArrays: boolean;
  36026. /** Defines if 32 bits indices are supported */
  36027. uintIndices: boolean;
  36028. /** Defines if high precision shaders are supported */
  36029. highPrecisionShaderSupported: boolean;
  36030. /** Defines if depth reading in the fragment shader is supported */
  36031. fragmentDepthSupported: boolean;
  36032. /** Defines if float texture linear filtering is supported*/
  36033. textureFloatLinearFiltering: boolean;
  36034. /** Defines if rendering to float textures is supported */
  36035. textureFloatRender: boolean;
  36036. /** Defines if half float textures are supported*/
  36037. textureHalfFloat: boolean;
  36038. /** Defines if half float texture linear filtering is supported*/
  36039. textureHalfFloatLinearFiltering: boolean;
  36040. /** Defines if rendering to half float textures is supported */
  36041. textureHalfFloatRender: boolean;
  36042. /** Defines if textureLOD shader command is supported */
  36043. textureLOD: boolean;
  36044. /** Defines if draw buffers extension is supported */
  36045. drawBuffersExtension: boolean;
  36046. /** Defines if depth textures are supported */
  36047. depthTextureExtension: boolean;
  36048. /** Defines if float color buffer are supported */
  36049. colorBufferFloat: boolean;
  36050. /** Gets disjoint timer query extension (null if not supported) */
  36051. timerQuery?: EXT_disjoint_timer_query;
  36052. /** Defines if timestamp can be used with timer query */
  36053. canUseTimestampForTimerQuery: boolean;
  36054. /** Defines if multiview is supported (https://www.khronos.org/registry/webgl/extensions/WEBGL_multiview/) */
  36055. multiview?: any;
  36056. /** Defines if oculus multiview is supported (https://developer.oculus.com/documentation/oculus-browser/latest/concepts/browser-multiview/) */
  36057. oculusMultiview?: any;
  36058. /** Function used to let the system compiles shaders in background */
  36059. parallelShaderCompile?: {
  36060. COMPLETION_STATUS_KHR: number;
  36061. };
  36062. /** Max number of texture samples for MSAA */
  36063. maxMSAASamples: number;
  36064. /** Defines if the blend min max extension is supported */
  36065. blendMinMax: boolean;
  36066. }
  36067. }
  36068. declare module "babylonjs/States/depthCullingState" {
  36069. import { Nullable } from "babylonjs/types";
  36070. /**
  36071. * @hidden
  36072. **/
  36073. export class DepthCullingState {
  36074. private _isDepthTestDirty;
  36075. private _isDepthMaskDirty;
  36076. private _isDepthFuncDirty;
  36077. private _isCullFaceDirty;
  36078. private _isCullDirty;
  36079. private _isZOffsetDirty;
  36080. private _isFrontFaceDirty;
  36081. private _depthTest;
  36082. private _depthMask;
  36083. private _depthFunc;
  36084. private _cull;
  36085. private _cullFace;
  36086. private _zOffset;
  36087. private _frontFace;
  36088. /**
  36089. * Initializes the state.
  36090. */
  36091. constructor();
  36092. get isDirty(): boolean;
  36093. get zOffset(): number;
  36094. set zOffset(value: number);
  36095. get cullFace(): Nullable<number>;
  36096. set cullFace(value: Nullable<number>);
  36097. get cull(): Nullable<boolean>;
  36098. set cull(value: Nullable<boolean>);
  36099. get depthFunc(): Nullable<number>;
  36100. set depthFunc(value: Nullable<number>);
  36101. get depthMask(): boolean;
  36102. set depthMask(value: boolean);
  36103. get depthTest(): boolean;
  36104. set depthTest(value: boolean);
  36105. get frontFace(): Nullable<number>;
  36106. set frontFace(value: Nullable<number>);
  36107. reset(): void;
  36108. apply(gl: WebGLRenderingContext): void;
  36109. }
  36110. }
  36111. declare module "babylonjs/States/stencilState" {
  36112. /**
  36113. * @hidden
  36114. **/
  36115. export class StencilState {
  36116. /** 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 */
  36117. static readonly ALWAYS: number;
  36118. /** Passed to stencilOperation to specify that stencil value must be kept */
  36119. static readonly KEEP: number;
  36120. /** Passed to stencilOperation to specify that stencil value must be replaced */
  36121. static readonly REPLACE: number;
  36122. private _isStencilTestDirty;
  36123. private _isStencilMaskDirty;
  36124. private _isStencilFuncDirty;
  36125. private _isStencilOpDirty;
  36126. private _stencilTest;
  36127. private _stencilMask;
  36128. private _stencilFunc;
  36129. private _stencilFuncRef;
  36130. private _stencilFuncMask;
  36131. private _stencilOpStencilFail;
  36132. private _stencilOpDepthFail;
  36133. private _stencilOpStencilDepthPass;
  36134. get isDirty(): boolean;
  36135. get stencilFunc(): number;
  36136. set stencilFunc(value: number);
  36137. get stencilFuncRef(): number;
  36138. set stencilFuncRef(value: number);
  36139. get stencilFuncMask(): number;
  36140. set stencilFuncMask(value: number);
  36141. get stencilOpStencilFail(): number;
  36142. set stencilOpStencilFail(value: number);
  36143. get stencilOpDepthFail(): number;
  36144. set stencilOpDepthFail(value: number);
  36145. get stencilOpStencilDepthPass(): number;
  36146. set stencilOpStencilDepthPass(value: number);
  36147. get stencilMask(): number;
  36148. set stencilMask(value: number);
  36149. get stencilTest(): boolean;
  36150. set stencilTest(value: boolean);
  36151. constructor();
  36152. reset(): void;
  36153. apply(gl: WebGLRenderingContext): void;
  36154. }
  36155. }
  36156. declare module "babylonjs/States/alphaCullingState" {
  36157. /**
  36158. * @hidden
  36159. **/
  36160. export class AlphaState {
  36161. private _isAlphaBlendDirty;
  36162. private _isBlendFunctionParametersDirty;
  36163. private _isBlendEquationParametersDirty;
  36164. private _isBlendConstantsDirty;
  36165. private _alphaBlend;
  36166. private _blendFunctionParameters;
  36167. private _blendEquationParameters;
  36168. private _blendConstants;
  36169. /**
  36170. * Initializes the state.
  36171. */
  36172. constructor();
  36173. get isDirty(): boolean;
  36174. get alphaBlend(): boolean;
  36175. set alphaBlend(value: boolean);
  36176. setAlphaBlendConstants(r: number, g: number, b: number, a: number): void;
  36177. setAlphaBlendFunctionParameters(value0: number, value1: number, value2: number, value3: number): void;
  36178. setAlphaEquationParameters(rgb: number, alpha: number): void;
  36179. reset(): void;
  36180. apply(gl: WebGLRenderingContext): void;
  36181. }
  36182. }
  36183. declare module "babylonjs/Engines/WebGL/webGL2ShaderProcessors" {
  36184. import { IShaderProcessor } from "babylonjs/Engines/Processors/iShaderProcessor";
  36185. /** @hidden */
  36186. export class WebGL2ShaderProcessor implements IShaderProcessor {
  36187. attributeProcessor(attribute: string): string;
  36188. varyingProcessor(varying: string, isFragment: boolean): string;
  36189. postProcessor(code: string, defines: string[], isFragment: boolean): string;
  36190. }
  36191. }
  36192. declare module "babylonjs/Engines/instancingAttributeInfo" {
  36193. /**
  36194. * Interface for attribute information associated with buffer instanciation
  36195. */
  36196. export interface InstancingAttributeInfo {
  36197. /**
  36198. * Name of the GLSL attribute
  36199. * if attribute index is not specified, this is used to retrieve the index from the effect
  36200. */
  36201. attributeName: string;
  36202. /**
  36203. * Index/offset of the attribute in the vertex shader
  36204. * if not specified, this will be computes from the name.
  36205. */
  36206. index?: number;
  36207. /**
  36208. * size of the attribute, 1, 2, 3 or 4
  36209. */
  36210. attributeSize: number;
  36211. /**
  36212. * Offset of the data in the Vertex Buffer acting as the instancing buffer
  36213. */
  36214. offset: number;
  36215. /**
  36216. * Modifies the rate at which generic vertex attributes advance when rendering multiple instances
  36217. * default to 1
  36218. */
  36219. divisor?: number;
  36220. /**
  36221. * type of the attribute, gl.BYTE, gl.UNSIGNED_BYTE, gl.SHORT, gl.UNSIGNED_SHORT, gl.FIXED, gl.FLOAT.
  36222. * default is FLOAT
  36223. */
  36224. attributeType?: number;
  36225. /**
  36226. * normalization of fixed-point data. behavior unclear, use FALSE, default is FALSE
  36227. */
  36228. normalized?: boolean;
  36229. }
  36230. }
  36231. declare module "babylonjs/Engines/Extensions/engine.videoTexture" {
  36232. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  36233. import { Nullable } from "babylonjs/types";
  36234. module "babylonjs/Engines/thinEngine" {
  36235. interface ThinEngine {
  36236. /**
  36237. * Update a video texture
  36238. * @param texture defines the texture to update
  36239. * @param video defines the video element to use
  36240. * @param invertY defines if data must be stored with Y axis inverted
  36241. */
  36242. updateVideoTexture(texture: Nullable<InternalTexture>, video: HTMLVideoElement, invertY: boolean): void;
  36243. }
  36244. }
  36245. }
  36246. declare module "babylonjs/Engines/Extensions/engine.dynamicTexture" {
  36247. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  36248. import { Nullable } from "babylonjs/types";
  36249. module "babylonjs/Engines/thinEngine" {
  36250. interface ThinEngine {
  36251. /**
  36252. * Creates a dynamic texture
  36253. * @param width defines the width of the texture
  36254. * @param height defines the height of the texture
  36255. * @param generateMipMaps defines if the engine should generate the mip levels
  36256. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  36257. * @returns the dynamic texture inside an InternalTexture
  36258. */
  36259. createDynamicTexture(width: number, height: number, generateMipMaps: boolean, samplingMode: number): InternalTexture;
  36260. /**
  36261. * Update the content of a dynamic texture
  36262. * @param texture defines the texture to update
  36263. * @param canvas defines the canvas containing the source
  36264. * @param invertY defines if data must be stored with Y axis inverted
  36265. * @param premulAlpha defines if alpha is stored as premultiplied
  36266. * @param format defines the format of the data
  36267. * @param forceBindTexture if the texture should be forced to be bound eg. after a graphics context loss (Default: false)
  36268. */
  36269. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement | OffscreenCanvas, invertY: boolean, premulAlpha?: boolean, format?: number, forceBindTexture?: boolean): void;
  36270. }
  36271. }
  36272. }
  36273. declare module "babylonjs/Materials/Textures/videoTexture" {
  36274. import { Observable } from "babylonjs/Misc/observable";
  36275. import { Nullable } from "babylonjs/types";
  36276. import { Scene } from "babylonjs/scene";
  36277. import { Texture } from "babylonjs/Materials/Textures/texture";
  36278. import "babylonjs/Engines/Extensions/engine.videoTexture";
  36279. import "babylonjs/Engines/Extensions/engine.dynamicTexture";
  36280. /**
  36281. * Settings for finer control over video usage
  36282. */
  36283. export interface VideoTextureSettings {
  36284. /**
  36285. * Applies `autoplay` to video, if specified
  36286. */
  36287. autoPlay?: boolean;
  36288. /**
  36289. * Applies `loop` to video, if specified
  36290. */
  36291. loop?: boolean;
  36292. /**
  36293. * Automatically updates internal texture from video at every frame in the render loop
  36294. */
  36295. autoUpdateTexture: boolean;
  36296. /**
  36297. * Image src displayed during the video loading or until the user interacts with the video.
  36298. */
  36299. poster?: string;
  36300. }
  36301. /**
  36302. * If you want to display a video in your scene, this is the special texture for that.
  36303. * This special texture works similar to other textures, with the exception of a few parameters.
  36304. * @see https://doc.babylonjs.com/how_to/video_texture
  36305. */
  36306. export class VideoTexture extends Texture {
  36307. /**
  36308. * Tells whether textures will be updated automatically or user is required to call `updateTexture` manually
  36309. */
  36310. readonly autoUpdateTexture: boolean;
  36311. /**
  36312. * The video instance used by the texture internally
  36313. */
  36314. readonly video: HTMLVideoElement;
  36315. private _onUserActionRequestedObservable;
  36316. /**
  36317. * Event triggerd when a dom action is required by the user to play the video.
  36318. * This happens due to recent changes in browser policies preventing video to auto start.
  36319. */
  36320. get onUserActionRequestedObservable(): Observable<Texture>;
  36321. private _generateMipMaps;
  36322. private _stillImageCaptured;
  36323. private _displayingPosterTexture;
  36324. private _settings;
  36325. private _createInternalTextureOnEvent;
  36326. private _frameId;
  36327. private _currentSrc;
  36328. /**
  36329. * Creates a video texture.
  36330. * If you want to display a video in your scene, this is the special texture for that.
  36331. * This special texture works similar to other textures, with the exception of a few parameters.
  36332. * @see https://doc.babylonjs.com/how_to/video_texture
  36333. * @param name optional name, will detect from video source, if not defined
  36334. * @param src can be used to provide an url, array of urls or an already setup HTML video element.
  36335. * @param scene is obviously the current scene.
  36336. * @param generateMipMaps can be used to turn on mipmaps (Can be expensive for videoTextures because they are often updated).
  36337. * @param invertY is false by default but can be used to invert video on Y axis
  36338. * @param samplingMode controls the sampling method and is set to TRILINEAR_SAMPLINGMODE by default
  36339. * @param settings allows finer control over video usage
  36340. */
  36341. constructor(name: Nullable<string>, src: string | string[] | HTMLVideoElement, scene: Nullable<Scene>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, settings?: VideoTextureSettings);
  36342. private _getName;
  36343. private _getVideo;
  36344. private _createInternalTexture;
  36345. private reset;
  36346. /**
  36347. * @hidden Internal method to initiate `update`.
  36348. */
  36349. _rebuild(): void;
  36350. /**
  36351. * Update Texture in the `auto` mode. Does not do anything if `settings.autoUpdateTexture` is false.
  36352. */
  36353. update(): void;
  36354. /**
  36355. * Update Texture in `manual` mode. Does not do anything if not visible or paused.
  36356. * @param isVisible Visibility state, detected by user using `scene.getActiveMeshes()` or othervise.
  36357. */
  36358. updateTexture(isVisible: boolean): void;
  36359. protected _updateInternalTexture: () => void;
  36360. /**
  36361. * Change video content. Changing video instance or setting multiple urls (as in constructor) is not supported.
  36362. * @param url New url.
  36363. */
  36364. updateURL(url: string): void;
  36365. /**
  36366. * Clones the texture.
  36367. * @returns the cloned texture
  36368. */
  36369. clone(): VideoTexture;
  36370. /**
  36371. * Dispose the texture and release its associated resources.
  36372. */
  36373. dispose(): void;
  36374. /**
  36375. * Creates a video texture straight from a stream.
  36376. * @param scene Define the scene the texture should be created in
  36377. * @param stream Define the stream the texture should be created from
  36378. * @returns The created video texture as a promise
  36379. */
  36380. static CreateFromStreamAsync(scene: Scene, stream: MediaStream): Promise<VideoTexture>;
  36381. /**
  36382. * Creates a video texture straight from your WebCam video feed.
  36383. * @param scene Define the scene the texture should be created in
  36384. * @param constraints Define the constraints to use to create the web cam feed from WebRTC
  36385. * @param audioConstaints Define the audio constraints to use to create the web cam feed from WebRTC
  36386. * @returns The created video texture as a promise
  36387. */
  36388. static CreateFromWebCamAsync(scene: Scene, constraints: {
  36389. minWidth: number;
  36390. maxWidth: number;
  36391. minHeight: number;
  36392. maxHeight: number;
  36393. deviceId: string;
  36394. } & MediaTrackConstraints, audioConstaints?: boolean | MediaTrackConstraints): Promise<VideoTexture>;
  36395. /**
  36396. * Creates a video texture straight from your WebCam video feed.
  36397. * @param scene Define the scene the texture should be created in
  36398. * @param onReady Define a callback to triggered once the texture will be ready
  36399. * @param constraints Define the constraints to use to create the web cam feed from WebRTC
  36400. * @param audioConstaints Define the audio constraints to use to create the web cam feed from WebRTC
  36401. */
  36402. static CreateFromWebCam(scene: Scene, onReady: (videoTexture: VideoTexture) => void, constraints: {
  36403. minWidth: number;
  36404. maxWidth: number;
  36405. minHeight: number;
  36406. maxHeight: number;
  36407. deviceId: string;
  36408. } & MediaTrackConstraints, audioConstaints?: boolean | MediaTrackConstraints): void;
  36409. }
  36410. }
  36411. declare module "babylonjs/Engines/thinEngine" {
  36412. import { IInternalTextureLoader } from "babylonjs/Materials/Textures/internalTextureLoader";
  36413. import { Effect, IEffectCreationOptions } from "babylonjs/Materials/effect";
  36414. import { IShaderProcessor } from "babylonjs/Engines/Processors/iShaderProcessor";
  36415. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  36416. import { Nullable, DataArray, IndicesArray } from "babylonjs/types";
  36417. import { EngineCapabilities } from "babylonjs/Engines/engineCapabilities";
  36418. import { Observable } from "babylonjs/Misc/observable";
  36419. import { DepthCullingState } from "babylonjs/States/depthCullingState";
  36420. import { StencilState } from "babylonjs/States/stencilState";
  36421. import { AlphaState } from "babylonjs/States/alphaCullingState";
  36422. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  36423. import { IViewportLike, IColor4Like } from "babylonjs/Maths/math.like";
  36424. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  36425. import { IFileRequest } from "babylonjs/Misc/fileRequest";
  36426. import { IPipelineContext } from "babylonjs/Engines/IPipelineContext";
  36427. import { WebGLPipelineContext } from "babylonjs/Engines/WebGL/webGLPipelineContext";
  36428. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  36429. import { InstancingAttributeInfo } from "babylonjs/Engines/instancingAttributeInfo";
  36430. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  36431. import { IOfflineProvider } from "babylonjs/Offline/IOfflineProvider";
  36432. import { IEffectFallbacks } from "babylonjs/Materials/iEffectFallbacks";
  36433. import { IWebRequest } from "babylonjs/Misc/interfaces/iWebRequest";
  36434. import { WebRequest } from "babylonjs/Misc/webRequest";
  36435. import { LoadFileError } from "babylonjs/Misc/fileTools";
  36436. /**
  36437. * Defines the interface used by objects working like Scene
  36438. * @hidden
  36439. */
  36440. export interface ISceneLike {
  36441. _addPendingData(data: any): void;
  36442. _removePendingData(data: any): void;
  36443. offlineProvider: IOfflineProvider;
  36444. }
  36445. /**
  36446. * Information about the current host
  36447. */
  36448. export interface HostInformation {
  36449. /**
  36450. * Defines if the current host is a mobile
  36451. */
  36452. isMobile: boolean;
  36453. }
  36454. /** Interface defining initialization parameters for Engine class */
  36455. export interface EngineOptions extends WebGLContextAttributes {
  36456. /**
  36457. * Defines if the engine should no exceed a specified device ratio
  36458. * @see https://developer.mozilla.org/en-US/docs/Web/API/Window/devicePixelRatio
  36459. */
  36460. limitDeviceRatio?: number;
  36461. /**
  36462. * Defines if webvr should be enabled automatically
  36463. * @see https://doc.babylonjs.com/how_to/webvr_camera
  36464. */
  36465. autoEnableWebVR?: boolean;
  36466. /**
  36467. * Defines if webgl2 should be turned off even if supported
  36468. * @see https://doc.babylonjs.com/features/webgl2
  36469. */
  36470. disableWebGL2Support?: boolean;
  36471. /**
  36472. * Defines if webaudio should be initialized as well
  36473. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  36474. */
  36475. audioEngine?: boolean;
  36476. /**
  36477. * Defines if animations should run using a deterministic lock step
  36478. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  36479. */
  36480. deterministicLockstep?: boolean;
  36481. /** Defines the maximum steps to use with deterministic lock step mode */
  36482. lockstepMaxSteps?: number;
  36483. /** Defines the seconds between each deterministic lock step */
  36484. timeStep?: number;
  36485. /**
  36486. * Defines that engine should ignore context lost events
  36487. * If this event happens when this parameter is true, you will have to reload the page to restore rendering
  36488. */
  36489. doNotHandleContextLost?: boolean;
  36490. /**
  36491. * Defines that engine should ignore modifying touch action attribute and style
  36492. * If not handle, you might need to set it up on your side for expected touch devices behavior.
  36493. */
  36494. doNotHandleTouchAction?: boolean;
  36495. /**
  36496. * Defines that engine should compile shaders with high precision floats (if supported). True by default
  36497. */
  36498. useHighPrecisionFloats?: boolean;
  36499. /**
  36500. * Make the canvas XR Compatible for XR sessions
  36501. */
  36502. xrCompatible?: boolean;
  36503. /**
  36504. * Make the matrix computations to be performed in 64 bits instead of 32 bits. False by default
  36505. */
  36506. useHighPrecisionMatrix?: boolean;
  36507. }
  36508. /**
  36509. * The base engine class (root of all engines)
  36510. */
  36511. export class ThinEngine {
  36512. /** Use this array to turn off some WebGL2 features on known buggy browsers version */
  36513. static ExceptionList: ({
  36514. key: string;
  36515. capture: string;
  36516. captureConstraint: number;
  36517. targets: string[];
  36518. } | {
  36519. key: string;
  36520. capture: null;
  36521. captureConstraint: null;
  36522. targets: string[];
  36523. })[];
  36524. /** @hidden */
  36525. static _TextureLoaders: IInternalTextureLoader[];
  36526. /**
  36527. * Returns the current npm package of the sdk
  36528. */
  36529. static get NpmPackage(): string;
  36530. /**
  36531. * Returns the current version of the framework
  36532. */
  36533. static get Version(): string;
  36534. /**
  36535. * Returns a string describing the current engine
  36536. */
  36537. get description(): string;
  36538. /**
  36539. * Gets or sets the epsilon value used by collision engine
  36540. */
  36541. static CollisionsEpsilon: number;
  36542. /**
  36543. * Gets or sets the relative url used to load shaders if using the engine in non-minified mode
  36544. */
  36545. static get ShadersRepository(): string;
  36546. static set ShadersRepository(value: string);
  36547. /** @hidden */
  36548. _shaderProcessor: IShaderProcessor;
  36549. /**
  36550. * Gets or sets a boolean that indicates if textures must be forced to power of 2 size even if not required
  36551. */
  36552. forcePOTTextures: boolean;
  36553. /**
  36554. * Gets a boolean indicating if the engine is currently rendering in fullscreen mode
  36555. */
  36556. isFullscreen: boolean;
  36557. /**
  36558. * Gets or sets a boolean indicating if back faces must be culled (true by default)
  36559. */
  36560. cullBackFaces: boolean;
  36561. /**
  36562. * Gets or sets a boolean indicating if the engine must keep rendering even if the window is not in foregroun
  36563. */
  36564. renderEvenInBackground: boolean;
  36565. /**
  36566. * Gets or sets a boolean indicating that cache can be kept between frames
  36567. */
  36568. preventCacheWipeBetweenFrames: boolean;
  36569. /** Gets or sets a boolean indicating if the engine should validate programs after compilation */
  36570. validateShaderPrograms: boolean;
  36571. /**
  36572. * Gets or sets a boolean indicating if depth buffer should be reverse, going from far to near.
  36573. * This can provide greater z depth for distant objects.
  36574. */
  36575. useReverseDepthBuffer: boolean;
  36576. /**
  36577. * Gets or sets a boolean indicating that uniform buffers must be disabled even if they are supported
  36578. */
  36579. disableUniformBuffers: boolean;
  36580. /** @hidden */
  36581. _uniformBuffers: UniformBuffer[];
  36582. /**
  36583. * Gets a boolean indicating that the engine supports uniform buffers
  36584. * @see https://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  36585. */
  36586. get supportsUniformBuffers(): boolean;
  36587. /** @hidden */
  36588. _gl: WebGLRenderingContext;
  36589. /** @hidden */
  36590. _webGLVersion: number;
  36591. protected _renderingCanvas: Nullable<HTMLCanvasElement>;
  36592. protected _windowIsBackground: boolean;
  36593. protected _creationOptions: EngineOptions;
  36594. protected _highPrecisionShadersAllowed: boolean;
  36595. /** @hidden */
  36596. get _shouldUseHighPrecisionShader(): boolean;
  36597. /**
  36598. * Gets a boolean indicating that only power of 2 textures are supported
  36599. * Please note that you can still use non power of 2 textures but in this case the engine will forcefully convert them
  36600. */
  36601. get needPOTTextures(): boolean;
  36602. /** @hidden */
  36603. _badOS: boolean;
  36604. /** @hidden */
  36605. _badDesktopOS: boolean;
  36606. private _hardwareScalingLevel;
  36607. /** @hidden */
  36608. _caps: EngineCapabilities;
  36609. private _isStencilEnable;
  36610. private _glVersion;
  36611. private _glRenderer;
  36612. private _glVendor;
  36613. /** @hidden */
  36614. _videoTextureSupported: boolean;
  36615. protected _renderingQueueLaunched: boolean;
  36616. protected _activeRenderLoops: (() => void)[];
  36617. /**
  36618. * Observable signaled when a context lost event is raised
  36619. */
  36620. onContextLostObservable: Observable<ThinEngine>;
  36621. /**
  36622. * Observable signaled when a context restored event is raised
  36623. */
  36624. onContextRestoredObservable: Observable<ThinEngine>;
  36625. private _onContextLost;
  36626. private _onContextRestored;
  36627. protected _contextWasLost: boolean;
  36628. /** @hidden */
  36629. _doNotHandleContextLost: boolean;
  36630. /**
  36631. * Gets or sets a boolean indicating if resources should be retained to be able to handle context lost events
  36632. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#handling-webgl-context-lost
  36633. */
  36634. get doNotHandleContextLost(): boolean;
  36635. set doNotHandleContextLost(value: boolean);
  36636. /**
  36637. * Gets or sets a boolean indicating that vertex array object must be disabled even if they are supported
  36638. */
  36639. disableVertexArrayObjects: boolean;
  36640. /** @hidden */
  36641. protected _colorWrite: boolean;
  36642. /** @hidden */
  36643. protected _colorWriteChanged: boolean;
  36644. /** @hidden */
  36645. protected _depthCullingState: DepthCullingState;
  36646. /** @hidden */
  36647. protected _stencilState: StencilState;
  36648. /** @hidden */
  36649. _alphaState: AlphaState;
  36650. /** @hidden */
  36651. _alphaMode: number;
  36652. /** @hidden */
  36653. _alphaEquation: number;
  36654. /** @hidden */
  36655. _internalTexturesCache: InternalTexture[];
  36656. /** @hidden */
  36657. protected _activeChannel: number;
  36658. private _currentTextureChannel;
  36659. /** @hidden */
  36660. protected _boundTexturesCache: {
  36661. [key: string]: Nullable<InternalTexture>;
  36662. };
  36663. /** @hidden */
  36664. protected _currentEffect: Nullable<Effect>;
  36665. /** @hidden */
  36666. protected _currentProgram: Nullable<WebGLProgram>;
  36667. private _compiledEffects;
  36668. private _vertexAttribArraysEnabled;
  36669. /** @hidden */
  36670. protected _cachedViewport: Nullable<IViewportLike>;
  36671. private _cachedVertexArrayObject;
  36672. /** @hidden */
  36673. protected _cachedVertexBuffers: any;
  36674. /** @hidden */
  36675. protected _cachedIndexBuffer: Nullable<DataBuffer>;
  36676. /** @hidden */
  36677. protected _cachedEffectForVertexBuffers: Nullable<Effect>;
  36678. /** @hidden */
  36679. _currentRenderTarget: Nullable<InternalTexture>;
  36680. private _uintIndicesCurrentlySet;
  36681. protected _currentBoundBuffer: Nullable<WebGLBuffer>[];
  36682. /** @hidden */
  36683. _currentFramebuffer: Nullable<WebGLFramebuffer>;
  36684. /** @hidden */
  36685. _dummyFramebuffer: Nullable<WebGLFramebuffer>;
  36686. private _currentBufferPointers;
  36687. private _currentInstanceLocations;
  36688. private _currentInstanceBuffers;
  36689. private _textureUnits;
  36690. /** @hidden */
  36691. _workingCanvas: Nullable<HTMLCanvasElement | OffscreenCanvas>;
  36692. /** @hidden */
  36693. _workingContext: Nullable<CanvasRenderingContext2D | OffscreenCanvasRenderingContext2D>;
  36694. /** @hidden */
  36695. _boundRenderFunction: any;
  36696. private _vaoRecordInProgress;
  36697. private _mustWipeVertexAttributes;
  36698. private _emptyTexture;
  36699. private _emptyCubeTexture;
  36700. private _emptyTexture3D;
  36701. private _emptyTexture2DArray;
  36702. /** @hidden */
  36703. _frameHandler: number;
  36704. private _nextFreeTextureSlots;
  36705. private _maxSimultaneousTextures;
  36706. private _activeRequests;
  36707. /** @hidden */
  36708. _transformTextureUrl: Nullable<(url: string) => string>;
  36709. /**
  36710. * Gets information about the current host
  36711. */
  36712. hostInformation: HostInformation;
  36713. protected get _supportsHardwareTextureRescaling(): boolean;
  36714. private _framebufferDimensionsObject;
  36715. /**
  36716. * sets the object from which width and height will be taken from when getting render width and height
  36717. * Will fallback to the gl object
  36718. * @param dimensions the framebuffer width and height that will be used.
  36719. */
  36720. set framebufferDimensionsObject(dimensions: Nullable<{
  36721. framebufferWidth: number;
  36722. framebufferHeight: number;
  36723. }>);
  36724. /**
  36725. * Gets the current viewport
  36726. */
  36727. get currentViewport(): Nullable<IViewportLike>;
  36728. /**
  36729. * Gets the default empty texture
  36730. */
  36731. get emptyTexture(): InternalTexture;
  36732. /**
  36733. * Gets the default empty 3D texture
  36734. */
  36735. get emptyTexture3D(): InternalTexture;
  36736. /**
  36737. * Gets the default empty 2D array texture
  36738. */
  36739. get emptyTexture2DArray(): InternalTexture;
  36740. /**
  36741. * Gets the default empty cube texture
  36742. */
  36743. get emptyCubeTexture(): InternalTexture;
  36744. /**
  36745. * Defines whether the engine has been created with the premultipliedAlpha option on or not.
  36746. */
  36747. readonly premultipliedAlpha: boolean;
  36748. /**
  36749. * Observable event triggered before each texture is initialized
  36750. */
  36751. onBeforeTextureInitObservable: Observable<import("babylonjs/Materials/Textures/texture").Texture>;
  36752. /**
  36753. * Creates a new engine
  36754. * @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
  36755. * @param antialias defines enable antialiasing (default: false)
  36756. * @param options defines further options to be sent to the getContext() function
  36757. * @param adaptToDeviceRatio defines whether to adapt to the device's viewport characteristics (default: false)
  36758. */
  36759. constructor(canvasOrContext: Nullable<HTMLCanvasElement | WebGLRenderingContext | WebGL2RenderingContext>, antialias?: boolean, options?: EngineOptions, adaptToDeviceRatio?: boolean);
  36760. private _rebuildInternalTextures;
  36761. private _rebuildEffects;
  36762. /**
  36763. * Gets a boolean indicating if all created effects are ready
  36764. * @returns true if all effects are ready
  36765. */
  36766. areAllEffectsReady(): boolean;
  36767. protected _rebuildBuffers(): void;
  36768. protected _initGLContext(): void;
  36769. /**
  36770. * Gets version of the current webGL context
  36771. */
  36772. get webGLVersion(): number;
  36773. /**
  36774. * Gets a string identifying the name of the class
  36775. * @returns "Engine" string
  36776. */
  36777. getClassName(): string;
  36778. /**
  36779. * Returns true if the stencil buffer has been enabled through the creation option of the context.
  36780. */
  36781. get isStencilEnable(): boolean;
  36782. /** @hidden */
  36783. _prepareWorkingCanvas(): void;
  36784. /**
  36785. * Reset the texture cache to empty state
  36786. */
  36787. resetTextureCache(): void;
  36788. /**
  36789. * Gets an object containing information about the current webGL context
  36790. * @returns an object containing the vender, the renderer and the version of the current webGL context
  36791. */
  36792. getGlInfo(): {
  36793. vendor: string;
  36794. renderer: string;
  36795. version: string;
  36796. };
  36797. /**
  36798. * Defines the hardware scaling level.
  36799. * By default the hardware scaling level is computed from the window device ratio.
  36800. * 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.
  36801. * @param level defines the level to use
  36802. */
  36803. setHardwareScalingLevel(level: number): void;
  36804. /**
  36805. * Gets the current hardware scaling level.
  36806. * By default the hardware scaling level is computed from the window device ratio.
  36807. * 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.
  36808. * @returns a number indicating the current hardware scaling level
  36809. */
  36810. getHardwareScalingLevel(): number;
  36811. /**
  36812. * Gets the list of loaded textures
  36813. * @returns an array containing all loaded textures
  36814. */
  36815. getLoadedTexturesCache(): InternalTexture[];
  36816. /**
  36817. * Gets the object containing all engine capabilities
  36818. * @returns the EngineCapabilities object
  36819. */
  36820. getCaps(): EngineCapabilities;
  36821. /**
  36822. * stop executing a render loop function and remove it from the execution array
  36823. * @param renderFunction defines the function to be removed. If not provided all functions will be removed.
  36824. */
  36825. stopRenderLoop(renderFunction?: () => void): void;
  36826. /** @hidden */
  36827. _renderLoop(): void;
  36828. /**
  36829. * Gets the HTML canvas attached with the current webGL context
  36830. * @returns a HTML canvas
  36831. */
  36832. getRenderingCanvas(): Nullable<HTMLCanvasElement>;
  36833. /**
  36834. * Gets host window
  36835. * @returns the host window object
  36836. */
  36837. getHostWindow(): Nullable<Window>;
  36838. /**
  36839. * Gets the current render width
  36840. * @param useScreen defines if screen size must be used (or the current render target if any)
  36841. * @returns a number defining the current render width
  36842. */
  36843. getRenderWidth(useScreen?: boolean): number;
  36844. /**
  36845. * Gets the current render height
  36846. * @param useScreen defines if screen size must be used (or the current render target if any)
  36847. * @returns a number defining the current render height
  36848. */
  36849. getRenderHeight(useScreen?: boolean): number;
  36850. /**
  36851. * Can be used to override the current requestAnimationFrame requester.
  36852. * @hidden
  36853. */
  36854. protected _queueNewFrame(bindedRenderFunction: any, requester?: any): number;
  36855. /**
  36856. * Register and execute a render loop. The engine can have more than one render function
  36857. * @param renderFunction defines the function to continuously execute
  36858. */
  36859. runRenderLoop(renderFunction: () => void): void;
  36860. /**
  36861. * Clear the current render buffer or the current render target (if any is set up)
  36862. * @param color defines the color to use
  36863. * @param backBuffer defines if the back buffer must be cleared
  36864. * @param depth defines if the depth buffer must be cleared
  36865. * @param stencil defines if the stencil buffer must be cleared
  36866. */
  36867. clear(color: Nullable<IColor4Like>, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  36868. private _viewportCached;
  36869. /** @hidden */
  36870. _viewport(x: number, y: number, width: number, height: number): void;
  36871. /**
  36872. * Set the WebGL's viewport
  36873. * @param viewport defines the viewport element to be used
  36874. * @param requiredWidth defines the width required for rendering. If not provided the rendering canvas' width is used
  36875. * @param requiredHeight defines the height required for rendering. If not provided the rendering canvas' height is used
  36876. */
  36877. setViewport(viewport: IViewportLike, requiredWidth?: number, requiredHeight?: number): void;
  36878. /**
  36879. * Begin a new frame
  36880. */
  36881. beginFrame(): void;
  36882. /**
  36883. * Enf the current frame
  36884. */
  36885. endFrame(): void;
  36886. /**
  36887. * Resize the view according to the canvas' size
  36888. */
  36889. resize(): void;
  36890. /**
  36891. * Force a specific size of the canvas
  36892. * @param width defines the new canvas' width
  36893. * @param height defines the new canvas' height
  36894. * @returns true if the size was changed
  36895. */
  36896. setSize(width: number, height: number): boolean;
  36897. /**
  36898. * Binds the frame buffer to the specified texture.
  36899. * @param texture The texture to render to or null for the default canvas
  36900. * @param faceIndex The face of the texture to render to in case of cube texture
  36901. * @param requiredWidth The width of the target to render to
  36902. * @param requiredHeight The height of the target to render to
  36903. * @param forceFullscreenViewport Forces the viewport to be the entire texture/screen if true
  36904. * @param lodLevel defines the lod level to bind to the frame buffer
  36905. * @param layer defines the 2d array index to bind to frame buffer to
  36906. */
  36907. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean, lodLevel?: number, layer?: number): void;
  36908. /** @hidden */
  36909. _bindUnboundFramebuffer(framebuffer: Nullable<WebGLFramebuffer>): void;
  36910. /**
  36911. * Unbind the current render target texture from the webGL context
  36912. * @param texture defines the render target texture to unbind
  36913. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  36914. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  36915. */
  36916. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  36917. /**
  36918. * Force a webGL flush (ie. a flush of all waiting webGL commands)
  36919. */
  36920. flushFramebuffer(): void;
  36921. /**
  36922. * Unbind the current render target and bind the default framebuffer
  36923. */
  36924. restoreDefaultFramebuffer(): void;
  36925. /** @hidden */
  36926. protected _resetVertexBufferBinding(): void;
  36927. /**
  36928. * Creates a vertex buffer
  36929. * @param data the data for the vertex buffer
  36930. * @returns the new WebGL static buffer
  36931. */
  36932. createVertexBuffer(data: DataArray): DataBuffer;
  36933. private _createVertexBuffer;
  36934. /**
  36935. * Creates a dynamic vertex buffer
  36936. * @param data the data for the dynamic vertex buffer
  36937. * @returns the new WebGL dynamic buffer
  36938. */
  36939. createDynamicVertexBuffer(data: DataArray): DataBuffer;
  36940. protected _resetIndexBufferBinding(): void;
  36941. /**
  36942. * Creates a new index buffer
  36943. * @param indices defines the content of the index buffer
  36944. * @param updatable defines if the index buffer must be updatable
  36945. * @returns a new webGL buffer
  36946. */
  36947. createIndexBuffer(indices: IndicesArray, updatable?: boolean): DataBuffer;
  36948. protected _normalizeIndexData(indices: IndicesArray): Uint16Array | Uint32Array;
  36949. /**
  36950. * Bind a webGL buffer to the webGL context
  36951. * @param buffer defines the buffer to bind
  36952. */
  36953. bindArrayBuffer(buffer: Nullable<DataBuffer>): void;
  36954. protected bindIndexBuffer(buffer: Nullable<DataBuffer>): void;
  36955. private bindBuffer;
  36956. /**
  36957. * update the bound buffer with the given data
  36958. * @param data defines the data to update
  36959. */
  36960. updateArrayBuffer(data: Float32Array): void;
  36961. private _vertexAttribPointer;
  36962. /** @hidden */
  36963. _bindIndexBufferWithCache(indexBuffer: Nullable<DataBuffer>): void;
  36964. private _bindVertexBuffersAttributes;
  36965. /**
  36966. * Records a vertex array object
  36967. * @see https://doc.babylonjs.com/features/webgl2#vertex-array-objects
  36968. * @param vertexBuffers defines the list of vertex buffers to store
  36969. * @param indexBuffer defines the index buffer to store
  36970. * @param effect defines the effect to store
  36971. * @returns the new vertex array object
  36972. */
  36973. recordVertexArrayObject(vertexBuffers: {
  36974. [key: string]: VertexBuffer;
  36975. }, indexBuffer: Nullable<DataBuffer>, effect: Effect): WebGLVertexArrayObject;
  36976. /**
  36977. * Bind a specific vertex array object
  36978. * @see https://doc.babylonjs.com/features/webgl2#vertex-array-objects
  36979. * @param vertexArrayObject defines the vertex array object to bind
  36980. * @param indexBuffer defines the index buffer to bind
  36981. */
  36982. bindVertexArrayObject(vertexArrayObject: WebGLVertexArrayObject, indexBuffer: Nullable<DataBuffer>): void;
  36983. /**
  36984. * Bind webGl buffers directly to the webGL context
  36985. * @param vertexBuffer defines the vertex buffer to bind
  36986. * @param indexBuffer defines the index buffer to bind
  36987. * @param vertexDeclaration defines the vertex declaration to use with the vertex buffer
  36988. * @param vertexStrideSize defines the vertex stride of the vertex buffer
  36989. * @param effect defines the effect associated with the vertex buffer
  36990. */
  36991. bindBuffersDirectly(vertexBuffer: DataBuffer, indexBuffer: DataBuffer, vertexDeclaration: number[], vertexStrideSize: number, effect: Effect): void;
  36992. private _unbindVertexArrayObject;
  36993. /**
  36994. * Bind a list of vertex buffers to the webGL context
  36995. * @param vertexBuffers defines the list of vertex buffers to bind
  36996. * @param indexBuffer defines the index buffer to bind
  36997. * @param effect defines the effect associated with the vertex buffers
  36998. */
  36999. bindBuffers(vertexBuffers: {
  37000. [key: string]: Nullable<VertexBuffer>;
  37001. }, indexBuffer: Nullable<DataBuffer>, effect: Effect): void;
  37002. /**
  37003. * Unbind all instance attributes
  37004. */
  37005. unbindInstanceAttributes(): void;
  37006. /**
  37007. * Release and free the memory of a vertex array object
  37008. * @param vao defines the vertex array object to delete
  37009. */
  37010. releaseVertexArrayObject(vao: WebGLVertexArrayObject): void;
  37011. /** @hidden */
  37012. _releaseBuffer(buffer: DataBuffer): boolean;
  37013. protected _deleteBuffer(buffer: DataBuffer): void;
  37014. /**
  37015. * Update the content of a webGL buffer used with instanciation and bind it to the webGL context
  37016. * @param instancesBuffer defines the webGL buffer to update and bind
  37017. * @param data defines the data to store in the buffer
  37018. * @param offsetLocations defines the offsets or attributes information used to determine where data must be stored in the buffer
  37019. */
  37020. updateAndBindInstancesBuffer(instancesBuffer: DataBuffer, data: Float32Array, offsetLocations: number[] | InstancingAttributeInfo[]): void;
  37021. /**
  37022. * Bind the content of a webGL buffer used with instantiation
  37023. * @param instancesBuffer defines the webGL buffer to bind
  37024. * @param attributesInfo defines the offsets or attributes information used to determine where data must be stored in the buffer
  37025. * @param computeStride defines Whether to compute the strides from the info or use the default 0
  37026. */
  37027. bindInstancesBuffer(instancesBuffer: DataBuffer, attributesInfo: InstancingAttributeInfo[], computeStride?: boolean): void;
  37028. /**
  37029. * Disable the instance attribute corresponding to the name in parameter
  37030. * @param name defines the name of the attribute to disable
  37031. */
  37032. disableInstanceAttributeByName(name: string): void;
  37033. /**
  37034. * Disable the instance attribute corresponding to the location in parameter
  37035. * @param attributeLocation defines the attribute location of the attribute to disable
  37036. */
  37037. disableInstanceAttribute(attributeLocation: number): void;
  37038. /**
  37039. * Disable the attribute corresponding to the location in parameter
  37040. * @param attributeLocation defines the attribute location of the attribute to disable
  37041. */
  37042. disableAttributeByIndex(attributeLocation: number): void;
  37043. /**
  37044. * Send a draw order
  37045. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  37046. * @param indexStart defines the starting index
  37047. * @param indexCount defines the number of index to draw
  37048. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  37049. */
  37050. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  37051. /**
  37052. * Draw a list of points
  37053. * @param verticesStart defines the index of first vertex to draw
  37054. * @param verticesCount defines the count of vertices to draw
  37055. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  37056. */
  37057. drawPointClouds(verticesStart: number, verticesCount: number, instancesCount?: number): void;
  37058. /**
  37059. * Draw a list of unindexed primitives
  37060. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  37061. * @param verticesStart defines the index of first vertex to draw
  37062. * @param verticesCount defines the count of vertices to draw
  37063. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  37064. */
  37065. drawUnIndexed(useTriangles: boolean, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  37066. /**
  37067. * Draw a list of indexed primitives
  37068. * @param fillMode defines the primitive to use
  37069. * @param indexStart defines the starting index
  37070. * @param indexCount defines the number of index to draw
  37071. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  37072. */
  37073. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  37074. /**
  37075. * Draw a list of unindexed primitives
  37076. * @param fillMode defines the primitive to use
  37077. * @param verticesStart defines the index of first vertex to draw
  37078. * @param verticesCount defines the count of vertices to draw
  37079. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  37080. */
  37081. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  37082. private _drawMode;
  37083. /** @hidden */
  37084. protected _reportDrawCall(): void;
  37085. /** @hidden */
  37086. _releaseEffect(effect: Effect): void;
  37087. /** @hidden */
  37088. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  37089. /**
  37090. * Create a new effect (used to store vertex/fragment shaders)
  37091. * @param baseName defines the base name of the effect (The name of file without .fragment.fx or .vertex.fx)
  37092. * @param attributesNamesOrOptions defines either a list of attribute names or an IEffectCreationOptions object
  37093. * @param uniformsNamesOrEngine defines either a list of uniform names or the engine to use
  37094. * @param samplers defines an array of string used to represent textures
  37095. * @param defines defines the string containing the defines to use to compile the shaders
  37096. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  37097. * @param onCompiled defines a function to call when the effect creation is successful
  37098. * @param onError defines a function to call when the effect creation has failed
  37099. * @param indexParameters defines an object containing the index values to use to compile shaders (like the maximum number of simultaneous lights)
  37100. * @returns the new Effect
  37101. */
  37102. 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;
  37103. protected static _ConcatenateShader(source: string, defines: Nullable<string>, shaderVersion?: string): string;
  37104. private _compileShader;
  37105. private _compileRawShader;
  37106. /** @hidden */
  37107. _getShaderSource(shader: WebGLShader): Nullable<string>;
  37108. /**
  37109. * Directly creates a webGL program
  37110. * @param pipelineContext defines the pipeline context to attach to
  37111. * @param vertexCode defines the vertex shader code to use
  37112. * @param fragmentCode defines the fragment shader code to use
  37113. * @param context defines the webGL context to use (if not set, the current one will be used)
  37114. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  37115. * @returns the new webGL program
  37116. */
  37117. createRawShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  37118. /**
  37119. * Creates a webGL program
  37120. * @param pipelineContext defines the pipeline context to attach to
  37121. * @param vertexCode defines the vertex shader code to use
  37122. * @param fragmentCode defines the fragment shader code to use
  37123. * @param defines defines the string containing the defines to use to compile the shaders
  37124. * @param context defines the webGL context to use (if not set, the current one will be used)
  37125. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  37126. * @returns the new webGL program
  37127. */
  37128. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  37129. /**
  37130. * Creates a new pipeline context
  37131. * @returns the new pipeline
  37132. */
  37133. createPipelineContext(): IPipelineContext;
  37134. protected _createShaderProgram(pipelineContext: WebGLPipelineContext, vertexShader: WebGLShader, fragmentShader: WebGLShader, context: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  37135. protected _finalizePipelineContext(pipelineContext: WebGLPipelineContext): void;
  37136. /** @hidden */
  37137. _preparePipelineContext(pipelineContext: IPipelineContext, vertexSourceCode: string, fragmentSourceCode: string, createAsRaw: boolean, rebuildRebind: any, defines: Nullable<string>, transformFeedbackVaryings: Nullable<string[]>): void;
  37138. /** @hidden */
  37139. _isRenderingStateCompiled(pipelineContext: IPipelineContext): boolean;
  37140. /** @hidden */
  37141. _executeWhenRenderingStateIsCompiled(pipelineContext: IPipelineContext, action: () => void): void;
  37142. /**
  37143. * Gets the list of webGL uniform locations associated with a specific program based on a list of uniform names
  37144. * @param pipelineContext defines the pipeline context to use
  37145. * @param uniformsNames defines the list of uniform names
  37146. * @returns an array of webGL uniform locations
  37147. */
  37148. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): Nullable<WebGLUniformLocation>[];
  37149. /**
  37150. * Gets the lsit of active attributes for a given webGL program
  37151. * @param pipelineContext defines the pipeline context to use
  37152. * @param attributesNames defines the list of attribute names to get
  37153. * @returns an array of indices indicating the offset of each attribute
  37154. */
  37155. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  37156. /**
  37157. * Activates an effect, mkaing it the current one (ie. the one used for rendering)
  37158. * @param effect defines the effect to activate
  37159. */
  37160. enableEffect(effect: Nullable<Effect>): void;
  37161. /**
  37162. * Set the value of an uniform to a number (int)
  37163. * @param uniform defines the webGL uniform location where to store the value
  37164. * @param value defines the int number to store
  37165. */
  37166. setInt(uniform: Nullable<WebGLUniformLocation>, value: number): void;
  37167. /**
  37168. * Set the value of an uniform to an array of int32
  37169. * @param uniform defines the webGL uniform location where to store the value
  37170. * @param array defines the array of int32 to store
  37171. */
  37172. setIntArray(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  37173. /**
  37174. * Set the value of an uniform to an array of int32 (stored as vec2)
  37175. * @param uniform defines the webGL uniform location where to store the value
  37176. * @param array defines the array of int32 to store
  37177. */
  37178. setIntArray2(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  37179. /**
  37180. * Set the value of an uniform to an array of int32 (stored as vec3)
  37181. * @param uniform defines the webGL uniform location where to store the value
  37182. * @param array defines the array of int32 to store
  37183. */
  37184. setIntArray3(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  37185. /**
  37186. * Set the value of an uniform to an array of int32 (stored as vec4)
  37187. * @param uniform defines the webGL uniform location where to store the value
  37188. * @param array defines the array of int32 to store
  37189. */
  37190. setIntArray4(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  37191. /**
  37192. * Set the value of an uniform to an array of number
  37193. * @param uniform defines the webGL uniform location where to store the value
  37194. * @param array defines the array of number to store
  37195. */
  37196. setArray(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): void;
  37197. /**
  37198. * Set the value of an uniform to an array of number (stored as vec2)
  37199. * @param uniform defines the webGL uniform location where to store the value
  37200. * @param array defines the array of number to store
  37201. */
  37202. setArray2(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): void;
  37203. /**
  37204. * Set the value of an uniform to an array of number (stored as vec3)
  37205. * @param uniform defines the webGL uniform location where to store the value
  37206. * @param array defines the array of number to store
  37207. */
  37208. setArray3(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): void;
  37209. /**
  37210. * Set the value of an uniform to an array of number (stored as vec4)
  37211. * @param uniform defines the webGL uniform location where to store the value
  37212. * @param array defines the array of number to store
  37213. */
  37214. setArray4(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): void;
  37215. /**
  37216. * Set the value of an uniform to an array of float32 (stored as matrices)
  37217. * @param uniform defines the webGL uniform location where to store the value
  37218. * @param matrices defines the array of float32 to store
  37219. */
  37220. setMatrices(uniform: Nullable<WebGLUniformLocation>, matrices: Float32Array): void;
  37221. /**
  37222. * Set the value of an uniform to a matrix (3x3)
  37223. * @param uniform defines the webGL uniform location where to store the value
  37224. * @param matrix defines the Float32Array representing the 3x3 matrix to store
  37225. */
  37226. setMatrix3x3(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): void;
  37227. /**
  37228. * Set the value of an uniform to a matrix (2x2)
  37229. * @param uniform defines the webGL uniform location where to store the value
  37230. * @param matrix defines the Float32Array representing the 2x2 matrix to store
  37231. */
  37232. setMatrix2x2(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): void;
  37233. /**
  37234. * Set the value of an uniform to a number (float)
  37235. * @param uniform defines the webGL uniform location where to store the value
  37236. * @param value defines the float number to store
  37237. */
  37238. setFloat(uniform: Nullable<WebGLUniformLocation>, value: number): void;
  37239. /**
  37240. * Set the value of an uniform to a vec2
  37241. * @param uniform defines the webGL uniform location where to store the value
  37242. * @param x defines the 1st component of the value
  37243. * @param y defines the 2nd component of the value
  37244. */
  37245. setFloat2(uniform: Nullable<WebGLUniformLocation>, x: number, y: number): void;
  37246. /**
  37247. * Set the value of an uniform to a vec3
  37248. * @param uniform defines the webGL uniform location where to store the value
  37249. * @param x defines the 1st component of the value
  37250. * @param y defines the 2nd component of the value
  37251. * @param z defines the 3rd component of the value
  37252. */
  37253. setFloat3(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number): void;
  37254. /**
  37255. * Set the value of an uniform to a vec4
  37256. * @param uniform defines the webGL uniform location where to store the value
  37257. * @param x defines the 1st component of the value
  37258. * @param y defines the 2nd component of the value
  37259. * @param z defines the 3rd component of the value
  37260. * @param w defines the 4th component of the value
  37261. */
  37262. setFloat4(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number, w: number): void;
  37263. /**
  37264. * Apply all cached states (depth, culling, stencil and alpha)
  37265. */
  37266. applyStates(): void;
  37267. /**
  37268. * Enable or disable color writing
  37269. * @param enable defines the state to set
  37270. */
  37271. setColorWrite(enable: boolean): void;
  37272. /**
  37273. * Gets a boolean indicating if color writing is enabled
  37274. * @returns the current color writing state
  37275. */
  37276. getColorWrite(): boolean;
  37277. /**
  37278. * Gets the depth culling state manager
  37279. */
  37280. get depthCullingState(): DepthCullingState;
  37281. /**
  37282. * Gets the alpha state manager
  37283. */
  37284. get alphaState(): AlphaState;
  37285. /**
  37286. * Gets the stencil state manager
  37287. */
  37288. get stencilState(): StencilState;
  37289. /**
  37290. * Clears the list of texture accessible through engine.
  37291. * This can help preventing texture load conflict due to name collision.
  37292. */
  37293. clearInternalTexturesCache(): void;
  37294. /**
  37295. * Force the entire cache to be cleared
  37296. * You should not have to use this function unless your engine needs to share the webGL context with another engine
  37297. * @param bruteForce defines a boolean to force clearing ALL caches (including stencil, detoh and alpha states)
  37298. */
  37299. wipeCaches(bruteForce?: boolean): void;
  37300. /** @hidden */
  37301. _getSamplingParameters(samplingMode: number, generateMipMaps: boolean): {
  37302. min: number;
  37303. mag: number;
  37304. };
  37305. /** @hidden */
  37306. _createTexture(): WebGLTexture;
  37307. /**
  37308. * Usually called from Texture.ts.
  37309. * Passed information to create a WebGLTexture
  37310. * @param url defines a value which contains one of the following:
  37311. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  37312. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  37313. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  37314. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  37315. * @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)
  37316. * @param scene needed for loading to the correct scene
  37317. * @param samplingMode mode with should be used sample / access the texture (Default: Texture.TRILINEAR_SAMPLINGMODE)
  37318. * @param onLoad optional callback to be called upon successful completion
  37319. * @param onError optional callback to be called upon failure
  37320. * @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
  37321. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  37322. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  37323. * @param forcedExtension defines the extension to use to pick the right loader
  37324. * @param mimeType defines an optional mime type
  37325. * @returns a InternalTexture for assignment back into BABYLON.Texture
  37326. */
  37327. 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;
  37328. /**
  37329. * Loads an image as an HTMLImageElement.
  37330. * @param input url string, ArrayBuffer, or Blob to load
  37331. * @param onLoad callback called when the image successfully loads
  37332. * @param onError callback called when the image fails to load
  37333. * @param offlineProvider offline provider for caching
  37334. * @param mimeType optional mime type
  37335. * @returns the HTMLImageElement of the loaded image
  37336. * @hidden
  37337. */
  37338. 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>;
  37339. /**
  37340. * @hidden
  37341. */
  37342. _rescaleTexture(source: InternalTexture, destination: InternalTexture, scene: Nullable<any>, internalFormat: number, onComplete: () => void): void;
  37343. private _unpackFlipYCached;
  37344. /**
  37345. * In case you are sharing the context with other applications, it might
  37346. * be interested to not cache the unpack flip y state to ensure a consistent
  37347. * value would be set.
  37348. */
  37349. enableUnpackFlipYCached: boolean;
  37350. /** @hidden */
  37351. _unpackFlipY(value: boolean): void;
  37352. /** @hidden */
  37353. _getUnpackAlignement(): number;
  37354. private _getTextureTarget;
  37355. /**
  37356. * Update the sampling mode of a given texture
  37357. * @param samplingMode defines the required sampling mode
  37358. * @param texture defines the texture to update
  37359. * @param generateMipMaps defines whether to generate mipmaps for the texture
  37360. */
  37361. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture, generateMipMaps?: boolean): void;
  37362. /**
  37363. * Update the sampling mode of a given texture
  37364. * @param texture defines the texture to update
  37365. * @param wrapU defines the texture wrap mode of the u coordinates
  37366. * @param wrapV defines the texture wrap mode of the v coordinates
  37367. * @param wrapR defines the texture wrap mode of the r coordinates
  37368. */
  37369. updateTextureWrappingMode(texture: InternalTexture, wrapU: Nullable<number>, wrapV?: Nullable<number>, wrapR?: Nullable<number>): void;
  37370. /** @hidden */
  37371. _setupDepthStencilTexture(internalTexture: InternalTexture, size: number | {
  37372. width: number;
  37373. height: number;
  37374. layers?: number;
  37375. }, generateStencil: boolean, bilinearFiltering: boolean, comparisonFunction: number): void;
  37376. /** @hidden */
  37377. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  37378. /** @hidden */
  37379. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number, babylonInternalFormat?: number, useTextureWidthAndHeight?: boolean): void;
  37380. /**
  37381. * Update a portion of an internal texture
  37382. * @param texture defines the texture to update
  37383. * @param imageData defines the data to store into the texture
  37384. * @param xOffset defines the x coordinates of the update rectangle
  37385. * @param yOffset defines the y coordinates of the update rectangle
  37386. * @param width defines the width of the update rectangle
  37387. * @param height defines the height of the update rectangle
  37388. * @param faceIndex defines the face index if texture is a cube (0 by default)
  37389. * @param lod defines the lod level to update (0 by default)
  37390. */
  37391. updateTextureData(texture: InternalTexture, imageData: ArrayBufferView, xOffset: number, yOffset: number, width: number, height: number, faceIndex?: number, lod?: number): void;
  37392. /** @hidden */
  37393. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  37394. protected _prepareWebGLTextureContinuation(texture: InternalTexture, scene: Nullable<ISceneLike>, noMipmap: boolean, isCompressed: boolean, samplingMode: number): void;
  37395. private _prepareWebGLTexture;
  37396. /** @hidden */
  37397. _setupFramebufferDepthAttachments(generateStencilBuffer: boolean, generateDepthBuffer: boolean, width: number, height: number, samples?: number): Nullable<WebGLRenderbuffer>;
  37398. private _getDepthStencilBuffer;
  37399. /** @hidden */
  37400. _releaseFramebufferObjects(texture: InternalTexture): void;
  37401. /** @hidden */
  37402. _releaseTexture(texture: InternalTexture): void;
  37403. protected _deleteTexture(texture: Nullable<WebGLTexture>): void;
  37404. protected _setProgram(program: WebGLProgram): void;
  37405. protected _boundUniforms: {
  37406. [key: number]: WebGLUniformLocation;
  37407. };
  37408. /**
  37409. * Binds an effect to the webGL context
  37410. * @param effect defines the effect to bind
  37411. */
  37412. bindSamplers(effect: Effect): void;
  37413. private _activateCurrentTexture;
  37414. /** @hidden */
  37415. _bindTextureDirectly(target: number, texture: Nullable<InternalTexture>, forTextureDataUpdate?: boolean, force?: boolean): boolean;
  37416. /** @hidden */
  37417. _bindTexture(channel: number, texture: Nullable<InternalTexture>): void;
  37418. /**
  37419. * Unbind all textures from the webGL context
  37420. */
  37421. unbindAllTextures(): void;
  37422. /**
  37423. * Sets a texture to the according uniform.
  37424. * @param channel The texture channel
  37425. * @param uniform The uniform to set
  37426. * @param texture The texture to apply
  37427. */
  37428. setTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<BaseTexture>): void;
  37429. private _bindSamplerUniformToChannel;
  37430. private _getTextureWrapMode;
  37431. protected _setTexture(channel: number, texture: Nullable<BaseTexture>, isPartOfTextureArray?: boolean, depthStencilTexture?: boolean): boolean;
  37432. /**
  37433. * Sets an array of texture to the webGL context
  37434. * @param channel defines the channel where the texture array must be set
  37435. * @param uniform defines the associated uniform location
  37436. * @param textures defines the array of textures to bind
  37437. */
  37438. setTextureArray(channel: number, uniform: Nullable<WebGLUniformLocation>, textures: BaseTexture[]): void;
  37439. /** @hidden */
  37440. _setAnisotropicLevel(target: number, internalTexture: InternalTexture, anisotropicFilteringLevel: number): void;
  37441. private _setTextureParameterFloat;
  37442. private _setTextureParameterInteger;
  37443. /**
  37444. * Unbind all vertex attributes from the webGL context
  37445. */
  37446. unbindAllAttributes(): void;
  37447. /**
  37448. * 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
  37449. */
  37450. releaseEffects(): void;
  37451. /**
  37452. * Dispose and release all associated resources
  37453. */
  37454. dispose(): void;
  37455. /**
  37456. * Attach a new callback raised when context lost event is fired
  37457. * @param callback defines the callback to call
  37458. */
  37459. attachContextLostEvent(callback: ((event: WebGLContextEvent) => void)): void;
  37460. /**
  37461. * Attach a new callback raised when context restored event is fired
  37462. * @param callback defines the callback to call
  37463. */
  37464. attachContextRestoredEvent(callback: ((event: WebGLContextEvent) => void)): void;
  37465. /**
  37466. * Get the current error code of the webGL context
  37467. * @returns the error code
  37468. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  37469. */
  37470. getError(): number;
  37471. private _canRenderToFloatFramebuffer;
  37472. private _canRenderToHalfFloatFramebuffer;
  37473. private _canRenderToFramebuffer;
  37474. /** @hidden */
  37475. _getWebGLTextureType(type: number): number;
  37476. /** @hidden */
  37477. _getInternalFormat(format: number): number;
  37478. /** @hidden */
  37479. _getRGBABufferInternalSizedFormat(type: number, format?: number): number;
  37480. /** @hidden */
  37481. _getRGBAMultiSampleBufferFormat(type: number): number;
  37482. /** @hidden */
  37483. _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;
  37484. /**
  37485. * Loads a file from a url
  37486. * @param url url to load
  37487. * @param onSuccess callback called when the file successfully loads
  37488. * @param onProgress callback called while file is loading (if the server supports this mode)
  37489. * @param offlineProvider defines the offline provider for caching
  37490. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  37491. * @param onError callback called when the file fails to load
  37492. * @returns a file request object
  37493. * @hidden
  37494. */
  37495. 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;
  37496. /**
  37497. * Reads pixels from the current frame buffer. Please note that this function can be slow
  37498. * @param x defines the x coordinate of the rectangle where pixels must be read
  37499. * @param y defines the y coordinate of the rectangle where pixels must be read
  37500. * @param width defines the width of the rectangle where pixels must be read
  37501. * @param height defines the height of the rectangle where pixels must be read
  37502. * @param hasAlpha defines whether the output should have alpha or not (defaults to true)
  37503. * @returns a Uint8Array containing RGBA colors
  37504. */
  37505. readPixels(x: number, y: number, width: number, height: number, hasAlpha?: boolean): Uint8Array;
  37506. private static _isSupported;
  37507. /**
  37508. * Gets a boolean indicating if the engine can be instanciated (ie. if a webGL context can be found)
  37509. * @returns true if the engine can be created
  37510. * @ignorenaming
  37511. */
  37512. static isSupported(): boolean;
  37513. /**
  37514. * Find the next highest power of two.
  37515. * @param x Number to start search from.
  37516. * @return Next highest power of two.
  37517. */
  37518. static CeilingPOT(x: number): number;
  37519. /**
  37520. * Find the next lowest power of two.
  37521. * @param x Number to start search from.
  37522. * @return Next lowest power of two.
  37523. */
  37524. static FloorPOT(x: number): number;
  37525. /**
  37526. * Find the nearest power of two.
  37527. * @param x Number to start search from.
  37528. * @return Next nearest power of two.
  37529. */
  37530. static NearestPOT(x: number): number;
  37531. /**
  37532. * Get the closest exponent of two
  37533. * @param value defines the value to approximate
  37534. * @param max defines the maximum value to return
  37535. * @param mode defines how to define the closest value
  37536. * @returns closest exponent of two of the given value
  37537. */
  37538. static GetExponentOfTwo(value: number, max: number, mode?: number): number;
  37539. /**
  37540. * Queue a new function into the requested animation frame pool (ie. this function will be executed byt the browser for the next frame)
  37541. * @param func - the function to be called
  37542. * @param requester - the object that will request the next frame. Falls back to window.
  37543. * @returns frame number
  37544. */
  37545. static QueueNewFrame(func: () => void, requester?: any): number;
  37546. /**
  37547. * Gets host document
  37548. * @returns the host document object
  37549. */
  37550. getHostDocument(): Nullable<Document>;
  37551. }
  37552. }
  37553. declare module "babylonjs/Maths/sphericalPolynomial" {
  37554. import { Vector3 } from "babylonjs/Maths/math.vector";
  37555. import { Color3 } from "babylonjs/Maths/math.color";
  37556. /**
  37557. * Class representing spherical harmonics coefficients to the 3rd degree
  37558. */
  37559. export class SphericalHarmonics {
  37560. /**
  37561. * Defines whether or not the harmonics have been prescaled for rendering.
  37562. */
  37563. preScaled: boolean;
  37564. /**
  37565. * The l0,0 coefficients of the spherical harmonics
  37566. */
  37567. l00: Vector3;
  37568. /**
  37569. * The l1,-1 coefficients of the spherical harmonics
  37570. */
  37571. l1_1: Vector3;
  37572. /**
  37573. * The l1,0 coefficients of the spherical harmonics
  37574. */
  37575. l10: Vector3;
  37576. /**
  37577. * The l1,1 coefficients of the spherical harmonics
  37578. */
  37579. l11: Vector3;
  37580. /**
  37581. * The l2,-2 coefficients of the spherical harmonics
  37582. */
  37583. l2_2: Vector3;
  37584. /**
  37585. * The l2,-1 coefficients of the spherical harmonics
  37586. */
  37587. l2_1: Vector3;
  37588. /**
  37589. * The l2,0 coefficients of the spherical harmonics
  37590. */
  37591. l20: Vector3;
  37592. /**
  37593. * The l2,1 coefficients of the spherical harmonics
  37594. */
  37595. l21: Vector3;
  37596. /**
  37597. * The l2,2 coefficients of the spherical harmonics
  37598. */
  37599. l22: Vector3;
  37600. /**
  37601. * Adds a light to the spherical harmonics
  37602. * @param direction the direction of the light
  37603. * @param color the color of the light
  37604. * @param deltaSolidAngle the delta solid angle of the light
  37605. */
  37606. addLight(direction: Vector3, color: Color3, deltaSolidAngle: number): void;
  37607. /**
  37608. * Scales the spherical harmonics by the given amount
  37609. * @param scale the amount to scale
  37610. */
  37611. scaleInPlace(scale: number): void;
  37612. /**
  37613. * Convert from incident radiance (Li) to irradiance (E) by applying convolution with the cosine-weighted hemisphere.
  37614. *
  37615. * ```
  37616. * E_lm = A_l * L_lm
  37617. * ```
  37618. *
  37619. * In spherical harmonics this convolution amounts to scaling factors for each frequency band.
  37620. * This corresponds to equation 5 in "An Efficient Representation for Irradiance Environment Maps", where
  37621. * the scaling factors are given in equation 9.
  37622. */
  37623. convertIncidentRadianceToIrradiance(): void;
  37624. /**
  37625. * Convert from irradiance to outgoing radiance for Lambertian BDRF, suitable for efficient shader evaluation.
  37626. *
  37627. * ```
  37628. * L = (1/pi) * E * rho
  37629. * ```
  37630. *
  37631. * This is done by an additional scale by 1/pi, so is a fairly trivial operation but important conceptually.
  37632. */
  37633. convertIrradianceToLambertianRadiance(): void;
  37634. /**
  37635. * Integrates the reconstruction coefficients directly in to the SH preventing further
  37636. * required operations at run time.
  37637. *
  37638. * This is simply done by scaling back the SH with Ylm constants parameter.
  37639. * The trigonometric part being applied by the shader at run time.
  37640. */
  37641. preScaleForRendering(): void;
  37642. /**
  37643. * Constructs a spherical harmonics from an array.
  37644. * @param data defines the 9x3 coefficients (l00, l1-1, l10, l11, l2-2, l2-1, l20, l21, l22)
  37645. * @returns the spherical harmonics
  37646. */
  37647. static FromArray(data: ArrayLike<ArrayLike<number>>): SphericalHarmonics;
  37648. /**
  37649. * Gets the spherical harmonics from polynomial
  37650. * @param polynomial the spherical polynomial
  37651. * @returns the spherical harmonics
  37652. */
  37653. static FromPolynomial(polynomial: SphericalPolynomial): SphericalHarmonics;
  37654. }
  37655. /**
  37656. * Class representing spherical polynomial coefficients to the 3rd degree
  37657. */
  37658. export class SphericalPolynomial {
  37659. private _harmonics;
  37660. /**
  37661. * The spherical harmonics used to create the polynomials.
  37662. */
  37663. get preScaledHarmonics(): SphericalHarmonics;
  37664. /**
  37665. * The x coefficients of the spherical polynomial
  37666. */
  37667. x: Vector3;
  37668. /**
  37669. * The y coefficients of the spherical polynomial
  37670. */
  37671. y: Vector3;
  37672. /**
  37673. * The z coefficients of the spherical polynomial
  37674. */
  37675. z: Vector3;
  37676. /**
  37677. * The xx coefficients of the spherical polynomial
  37678. */
  37679. xx: Vector3;
  37680. /**
  37681. * The yy coefficients of the spherical polynomial
  37682. */
  37683. yy: Vector3;
  37684. /**
  37685. * The zz coefficients of the spherical polynomial
  37686. */
  37687. zz: Vector3;
  37688. /**
  37689. * The xy coefficients of the spherical polynomial
  37690. */
  37691. xy: Vector3;
  37692. /**
  37693. * The yz coefficients of the spherical polynomial
  37694. */
  37695. yz: Vector3;
  37696. /**
  37697. * The zx coefficients of the spherical polynomial
  37698. */
  37699. zx: Vector3;
  37700. /**
  37701. * Adds an ambient color to the spherical polynomial
  37702. * @param color the color to add
  37703. */
  37704. addAmbient(color: Color3): void;
  37705. /**
  37706. * Scales the spherical polynomial by the given amount
  37707. * @param scale the amount to scale
  37708. */
  37709. scaleInPlace(scale: number): void;
  37710. /**
  37711. * Gets the spherical polynomial from harmonics
  37712. * @param harmonics the spherical harmonics
  37713. * @returns the spherical polynomial
  37714. */
  37715. static FromHarmonics(harmonics: SphericalHarmonics): SphericalPolynomial;
  37716. /**
  37717. * Constructs a spherical polynomial from an array.
  37718. * @param data defines the 9x3 coefficients (x, y, z, xx, yy, zz, yz, zx, xy)
  37719. * @returns the spherical polynomial
  37720. */
  37721. static FromArray(data: ArrayLike<ArrayLike<number>>): SphericalPolynomial;
  37722. }
  37723. }
  37724. declare module "babylonjs/Materials/Textures/internalTexture" {
  37725. import { Observable } from "babylonjs/Misc/observable";
  37726. import { Nullable, int } from "babylonjs/types";
  37727. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  37728. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  37729. import { SphericalPolynomial } from "babylonjs/Maths/sphericalPolynomial";
  37730. /**
  37731. * Defines the source of the internal texture
  37732. */
  37733. export enum InternalTextureSource {
  37734. /**
  37735. * The source of the texture data is unknown
  37736. */
  37737. Unknown = 0,
  37738. /**
  37739. * Texture data comes from an URL
  37740. */
  37741. Url = 1,
  37742. /**
  37743. * Texture data is only used for temporary storage
  37744. */
  37745. Temp = 2,
  37746. /**
  37747. * Texture data comes from raw data (ArrayBuffer)
  37748. */
  37749. Raw = 3,
  37750. /**
  37751. * Texture content is dynamic (video or dynamic texture)
  37752. */
  37753. Dynamic = 4,
  37754. /**
  37755. * Texture content is generated by rendering to it
  37756. */
  37757. RenderTarget = 5,
  37758. /**
  37759. * Texture content is part of a multi render target process
  37760. */
  37761. MultiRenderTarget = 6,
  37762. /**
  37763. * Texture data comes from a cube data file
  37764. */
  37765. Cube = 7,
  37766. /**
  37767. * Texture data comes from a raw cube data
  37768. */
  37769. CubeRaw = 8,
  37770. /**
  37771. * Texture data come from a prefiltered cube data file
  37772. */
  37773. CubePrefiltered = 9,
  37774. /**
  37775. * Texture content is raw 3D data
  37776. */
  37777. Raw3D = 10,
  37778. /**
  37779. * Texture content is raw 2D array data
  37780. */
  37781. Raw2DArray = 11,
  37782. /**
  37783. * Texture content is a depth texture
  37784. */
  37785. Depth = 12,
  37786. /**
  37787. * Texture data comes from a raw cube data encoded with RGBD
  37788. */
  37789. CubeRawRGBD = 13
  37790. }
  37791. /**
  37792. * Class used to store data associated with WebGL texture data for the engine
  37793. * This class should not be used directly
  37794. */
  37795. export class InternalTexture {
  37796. /** @hidden */
  37797. static _UpdateRGBDAsync: (internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number) => Promise<void>;
  37798. /**
  37799. * Defines if the texture is ready
  37800. */
  37801. isReady: boolean;
  37802. /**
  37803. * Defines if the texture is a cube texture
  37804. */
  37805. isCube: boolean;
  37806. /**
  37807. * Defines if the texture contains 3D data
  37808. */
  37809. is3D: boolean;
  37810. /**
  37811. * Defines if the texture contains 2D array data
  37812. */
  37813. is2DArray: boolean;
  37814. /**
  37815. * Defines if the texture contains multiview data
  37816. */
  37817. isMultiview: boolean;
  37818. /**
  37819. * Gets the URL used to load this texture
  37820. */
  37821. url: string;
  37822. /**
  37823. * Gets the sampling mode of the texture
  37824. */
  37825. samplingMode: number;
  37826. /**
  37827. * Gets a boolean indicating if the texture needs mipmaps generation
  37828. */
  37829. generateMipMaps: boolean;
  37830. /**
  37831. * Gets the number of samples used by the texture (WebGL2+ only)
  37832. */
  37833. samples: number;
  37834. /**
  37835. * Gets the type of the texture (int, float...)
  37836. */
  37837. type: number;
  37838. /**
  37839. * Gets the format of the texture (RGB, RGBA...)
  37840. */
  37841. format: number;
  37842. /**
  37843. * Observable called when the texture is loaded
  37844. */
  37845. onLoadedObservable: Observable<InternalTexture>;
  37846. /**
  37847. * Gets the width of the texture
  37848. */
  37849. width: number;
  37850. /**
  37851. * Gets the height of the texture
  37852. */
  37853. height: number;
  37854. /**
  37855. * Gets the depth of the texture
  37856. */
  37857. depth: number;
  37858. /**
  37859. * Gets the initial width of the texture (It could be rescaled if the current system does not support non power of two textures)
  37860. */
  37861. baseWidth: number;
  37862. /**
  37863. * Gets the initial height of the texture (It could be rescaled if the current system does not support non power of two textures)
  37864. */
  37865. baseHeight: number;
  37866. /**
  37867. * Gets the initial depth of the texture (It could be rescaled if the current system does not support non power of two textures)
  37868. */
  37869. baseDepth: number;
  37870. /**
  37871. * Gets a boolean indicating if the texture is inverted on Y axis
  37872. */
  37873. invertY: boolean;
  37874. /** @hidden */
  37875. _invertVScale: boolean;
  37876. /** @hidden */
  37877. _associatedChannel: number;
  37878. /** @hidden */
  37879. _source: InternalTextureSource;
  37880. /** @hidden */
  37881. _buffer: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob | ImageBitmap>;
  37882. /** @hidden */
  37883. _bufferView: Nullable<ArrayBufferView>;
  37884. /** @hidden */
  37885. _bufferViewArray: Nullable<ArrayBufferView[]>;
  37886. /** @hidden */
  37887. _bufferViewArrayArray: Nullable<ArrayBufferView[][]>;
  37888. /** @hidden */
  37889. _size: number;
  37890. /** @hidden */
  37891. _extension: string;
  37892. /** @hidden */
  37893. _files: Nullable<string[]>;
  37894. /** @hidden */
  37895. _workingCanvas: Nullable<HTMLCanvasElement | OffscreenCanvas>;
  37896. /** @hidden */
  37897. _workingContext: Nullable<CanvasRenderingContext2D | OffscreenCanvasRenderingContext2D>;
  37898. /** @hidden */
  37899. _framebuffer: Nullable<WebGLFramebuffer>;
  37900. /** @hidden */
  37901. _depthStencilBuffer: Nullable<WebGLRenderbuffer>;
  37902. /** @hidden */
  37903. _MSAAFramebuffer: Nullable<WebGLFramebuffer>;
  37904. /** @hidden */
  37905. _MSAARenderBuffer: Nullable<WebGLRenderbuffer>;
  37906. /** @hidden */
  37907. _attachments: Nullable<number[]>;
  37908. /** @hidden */
  37909. _textureArray: Nullable<InternalTexture[]>;
  37910. /** @hidden */
  37911. _cachedCoordinatesMode: Nullable<number>;
  37912. /** @hidden */
  37913. _cachedWrapU: Nullable<number>;
  37914. /** @hidden */
  37915. _cachedWrapV: Nullable<number>;
  37916. /** @hidden */
  37917. _cachedWrapR: Nullable<number>;
  37918. /** @hidden */
  37919. _cachedAnisotropicFilteringLevel: Nullable<number>;
  37920. /** @hidden */
  37921. _isDisabled: boolean;
  37922. /** @hidden */
  37923. _compression: Nullable<string>;
  37924. /** @hidden */
  37925. _generateStencilBuffer: boolean;
  37926. /** @hidden */
  37927. _generateDepthBuffer: boolean;
  37928. /** @hidden */
  37929. _comparisonFunction: number;
  37930. /** @hidden */
  37931. _sphericalPolynomial: Nullable<SphericalPolynomial>;
  37932. /** @hidden */
  37933. _lodGenerationScale: number;
  37934. /** @hidden */
  37935. _lodGenerationOffset: number;
  37936. /** @hidden */
  37937. _depthStencilTexture: Nullable<InternalTexture>;
  37938. /** @hidden */
  37939. _colorTextureArray: Nullable<WebGLTexture>;
  37940. /** @hidden */
  37941. _depthStencilTextureArray: Nullable<WebGLTexture>;
  37942. /** @hidden */
  37943. _lodTextureHigh: Nullable<BaseTexture>;
  37944. /** @hidden */
  37945. _lodTextureMid: Nullable<BaseTexture>;
  37946. /** @hidden */
  37947. _lodTextureLow: Nullable<BaseTexture>;
  37948. /** @hidden */
  37949. _isRGBD: boolean;
  37950. /** @hidden */
  37951. _linearSpecularLOD: boolean;
  37952. /** @hidden */
  37953. _irradianceTexture: Nullable<BaseTexture>;
  37954. /** @hidden */
  37955. _webGLTexture: Nullable<WebGLTexture>;
  37956. /** @hidden */
  37957. _references: number;
  37958. private _engine;
  37959. /**
  37960. * Gets the Engine the texture belongs to.
  37961. * @returns The babylon engine
  37962. */
  37963. getEngine(): ThinEngine;
  37964. /**
  37965. * Gets the data source type of the texture
  37966. */
  37967. get source(): InternalTextureSource;
  37968. /**
  37969. * Creates a new InternalTexture
  37970. * @param engine defines the engine to use
  37971. * @param source defines the type of data that will be used
  37972. * @param delayAllocation if the texture allocation should be delayed (default: false)
  37973. */
  37974. constructor(engine: ThinEngine, source: InternalTextureSource, delayAllocation?: boolean);
  37975. /**
  37976. * Increments the number of references (ie. the number of Texture that point to it)
  37977. */
  37978. incrementReferences(): void;
  37979. /**
  37980. * Change the size of the texture (not the size of the content)
  37981. * @param width defines the new width
  37982. * @param height defines the new height
  37983. * @param depth defines the new depth (1 by default)
  37984. */
  37985. updateSize(width: int, height: int, depth?: int): void;
  37986. /** @hidden */
  37987. _rebuild(): void;
  37988. /** @hidden */
  37989. _swapAndDie(target: InternalTexture): void;
  37990. /**
  37991. * Dispose the current allocated resources
  37992. */
  37993. dispose(): void;
  37994. }
  37995. }
  37996. declare module "babylonjs/Audio/analyser" {
  37997. import { Scene } from "babylonjs/scene";
  37998. /**
  37999. * Class used to work with sound analyzer using fast fourier transform (FFT)
  38000. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  38001. */
  38002. export class Analyser {
  38003. /**
  38004. * Gets or sets the smoothing
  38005. * @ignorenaming
  38006. */
  38007. SMOOTHING: number;
  38008. /**
  38009. * Gets or sets the FFT table size
  38010. * @ignorenaming
  38011. */
  38012. FFT_SIZE: number;
  38013. /**
  38014. * Gets or sets the bar graph amplitude
  38015. * @ignorenaming
  38016. */
  38017. BARGRAPHAMPLITUDE: number;
  38018. /**
  38019. * Gets or sets the position of the debug canvas
  38020. * @ignorenaming
  38021. */
  38022. DEBUGCANVASPOS: {
  38023. x: number;
  38024. y: number;
  38025. };
  38026. /**
  38027. * Gets or sets the debug canvas size
  38028. * @ignorenaming
  38029. */
  38030. DEBUGCANVASSIZE: {
  38031. width: number;
  38032. height: number;
  38033. };
  38034. private _byteFreqs;
  38035. private _byteTime;
  38036. private _floatFreqs;
  38037. private _webAudioAnalyser;
  38038. private _debugCanvas;
  38039. private _debugCanvasContext;
  38040. private _scene;
  38041. private _registerFunc;
  38042. private _audioEngine;
  38043. /**
  38044. * Creates a new analyser
  38045. * @param scene defines hosting scene
  38046. */
  38047. constructor(scene: Scene);
  38048. /**
  38049. * Get the number of data values you will have to play with for the visualization
  38050. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/frequencyBinCount
  38051. * @returns a number
  38052. */
  38053. getFrequencyBinCount(): number;
  38054. /**
  38055. * Gets the current frequency data as a byte array
  38056. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  38057. * @returns a Uint8Array
  38058. */
  38059. getByteFrequencyData(): Uint8Array;
  38060. /**
  38061. * Gets the current waveform as a byte array
  38062. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteTimeDomainData
  38063. * @returns a Uint8Array
  38064. */
  38065. getByteTimeDomainData(): Uint8Array;
  38066. /**
  38067. * Gets the current frequency data as a float array
  38068. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  38069. * @returns a Float32Array
  38070. */
  38071. getFloatFrequencyData(): Float32Array;
  38072. /**
  38073. * Renders the debug canvas
  38074. */
  38075. drawDebugCanvas(): void;
  38076. /**
  38077. * Stops rendering the debug canvas and removes it
  38078. */
  38079. stopDebugCanvas(): void;
  38080. /**
  38081. * Connects two audio nodes
  38082. * @param inputAudioNode defines first node to connect
  38083. * @param outputAudioNode defines second node to connect
  38084. */
  38085. connectAudioNodes(inputAudioNode: AudioNode, outputAudioNode: AudioNode): void;
  38086. /**
  38087. * Releases all associated resources
  38088. */
  38089. dispose(): void;
  38090. }
  38091. }
  38092. declare module "babylonjs/Audio/audioEngine" {
  38093. import { IDisposable } from "babylonjs/scene";
  38094. import { Analyser } from "babylonjs/Audio/analyser";
  38095. import { Nullable } from "babylonjs/types";
  38096. import { Observable } from "babylonjs/Misc/observable";
  38097. /**
  38098. * This represents an audio engine and it is responsible
  38099. * to play, synchronize and analyse sounds throughout the application.
  38100. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  38101. */
  38102. export interface IAudioEngine extends IDisposable {
  38103. /**
  38104. * Gets whether the current host supports Web Audio and thus could create AudioContexts.
  38105. */
  38106. readonly canUseWebAudio: boolean;
  38107. /**
  38108. * Gets the current AudioContext if available.
  38109. */
  38110. readonly audioContext: Nullable<AudioContext>;
  38111. /**
  38112. * The master gain node defines the global audio volume of your audio engine.
  38113. */
  38114. readonly masterGain: GainNode;
  38115. /**
  38116. * Gets whether or not mp3 are supported by your browser.
  38117. */
  38118. readonly isMP3supported: boolean;
  38119. /**
  38120. * Gets whether or not ogg are supported by your browser.
  38121. */
  38122. readonly isOGGsupported: boolean;
  38123. /**
  38124. * Defines if Babylon should emit a warning if WebAudio is not supported.
  38125. * @ignoreNaming
  38126. */
  38127. WarnedWebAudioUnsupported: boolean;
  38128. /**
  38129. * Defines if the audio engine relies on a custom unlocked button.
  38130. * In this case, the embedded button will not be displayed.
  38131. */
  38132. useCustomUnlockedButton: boolean;
  38133. /**
  38134. * Gets whether or not the audio engine is unlocked (require first a user gesture on some browser).
  38135. */
  38136. readonly unlocked: boolean;
  38137. /**
  38138. * Event raised when audio has been unlocked on the browser.
  38139. */
  38140. onAudioUnlockedObservable: Observable<AudioEngine>;
  38141. /**
  38142. * Event raised when audio has been locked on the browser.
  38143. */
  38144. onAudioLockedObservable: Observable<AudioEngine>;
  38145. /**
  38146. * Flags the audio engine in Locked state.
  38147. * This happens due to new browser policies preventing audio to autoplay.
  38148. */
  38149. lock(): void;
  38150. /**
  38151. * Unlocks the audio engine once a user action has been done on the dom.
  38152. * This is helpful to resume play once browser policies have been satisfied.
  38153. */
  38154. unlock(): void;
  38155. /**
  38156. * Gets the global volume sets on the master gain.
  38157. * @returns the global volume if set or -1 otherwise
  38158. */
  38159. getGlobalVolume(): number;
  38160. /**
  38161. * Sets the global volume of your experience (sets on the master gain).
  38162. * @param newVolume Defines the new global volume of the application
  38163. */
  38164. setGlobalVolume(newVolume: number): void;
  38165. /**
  38166. * Connect the audio engine to an audio analyser allowing some amazing
  38167. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  38168. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  38169. * @param analyser The analyser to connect to the engine
  38170. */
  38171. connectToAnalyser(analyser: Analyser): void;
  38172. }
  38173. /**
  38174. * This represents the default audio engine used in babylon.
  38175. * It is responsible to play, synchronize and analyse sounds throughout the application.
  38176. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  38177. */
  38178. export class AudioEngine implements IAudioEngine {
  38179. private _audioContext;
  38180. private _audioContextInitialized;
  38181. private _muteButton;
  38182. private _hostElement;
  38183. /**
  38184. * Gets whether the current host supports Web Audio and thus could create AudioContexts.
  38185. */
  38186. canUseWebAudio: boolean;
  38187. /**
  38188. * The master gain node defines the global audio volume of your audio engine.
  38189. */
  38190. masterGain: GainNode;
  38191. /**
  38192. * Defines if Babylon should emit a warning if WebAudio is not supported.
  38193. * @ignoreNaming
  38194. */
  38195. WarnedWebAudioUnsupported: boolean;
  38196. /**
  38197. * Gets whether or not mp3 are supported by your browser.
  38198. */
  38199. isMP3supported: boolean;
  38200. /**
  38201. * Gets whether or not ogg are supported by your browser.
  38202. */
  38203. isOGGsupported: boolean;
  38204. /**
  38205. * Gets whether audio has been unlocked on the device.
  38206. * Some Browsers have strong restrictions about Audio and won t autoplay unless
  38207. * a user interaction has happened.
  38208. */
  38209. unlocked: boolean;
  38210. /**
  38211. * Defines if the audio engine relies on a custom unlocked button.
  38212. * In this case, the embedded button will not be displayed.
  38213. */
  38214. useCustomUnlockedButton: boolean;
  38215. /**
  38216. * Event raised when audio has been unlocked on the browser.
  38217. */
  38218. onAudioUnlockedObservable: Observable<AudioEngine>;
  38219. /**
  38220. * Event raised when audio has been locked on the browser.
  38221. */
  38222. onAudioLockedObservable: Observable<AudioEngine>;
  38223. /**
  38224. * Gets the current AudioContext if available.
  38225. */
  38226. get audioContext(): Nullable<AudioContext>;
  38227. private _connectedAnalyser;
  38228. /**
  38229. * Instantiates a new audio engine.
  38230. *
  38231. * There should be only one per page as some browsers restrict the number
  38232. * of audio contexts you can create.
  38233. * @param hostElement defines the host element where to display the mute icon if necessary
  38234. */
  38235. constructor(hostElement?: Nullable<HTMLElement>);
  38236. /**
  38237. * Flags the audio engine in Locked state.
  38238. * This happens due to new browser policies preventing audio to autoplay.
  38239. */
  38240. lock(): void;
  38241. /**
  38242. * Unlocks the audio engine once a user action has been done on the dom.
  38243. * This is helpful to resume play once browser policies have been satisfied.
  38244. */
  38245. unlock(): void;
  38246. private _resumeAudioContext;
  38247. private _initializeAudioContext;
  38248. private _tryToRun;
  38249. private _triggerRunningState;
  38250. private _triggerSuspendedState;
  38251. private _displayMuteButton;
  38252. private _moveButtonToTopLeft;
  38253. private _onResize;
  38254. private _hideMuteButton;
  38255. /**
  38256. * Destroy and release the resources associated with the audio ccontext.
  38257. */
  38258. dispose(): void;
  38259. /**
  38260. * Gets the global volume sets on the master gain.
  38261. * @returns the global volume if set or -1 otherwise
  38262. */
  38263. getGlobalVolume(): number;
  38264. /**
  38265. * Sets the global volume of your experience (sets on the master gain).
  38266. * @param newVolume Defines the new global volume of the application
  38267. */
  38268. setGlobalVolume(newVolume: number): void;
  38269. /**
  38270. * Connect the audio engine to an audio analyser allowing some amazing
  38271. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  38272. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  38273. * @param analyser The analyser to connect to the engine
  38274. */
  38275. connectToAnalyser(analyser: Analyser): void;
  38276. }
  38277. }
  38278. declare module "babylonjs/Loading/loadingScreen" {
  38279. /**
  38280. * Interface used to present a loading screen while loading a scene
  38281. * @see https://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  38282. */
  38283. export interface ILoadingScreen {
  38284. /**
  38285. * Function called to display the loading screen
  38286. */
  38287. displayLoadingUI: () => void;
  38288. /**
  38289. * Function called to hide the loading screen
  38290. */
  38291. hideLoadingUI: () => void;
  38292. /**
  38293. * Gets or sets the color to use for the background
  38294. */
  38295. loadingUIBackgroundColor: string;
  38296. /**
  38297. * Gets or sets the text to display while loading
  38298. */
  38299. loadingUIText: string;
  38300. }
  38301. /**
  38302. * Class used for the default loading screen
  38303. * @see https://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  38304. */
  38305. export class DefaultLoadingScreen implements ILoadingScreen {
  38306. private _renderingCanvas;
  38307. private _loadingText;
  38308. private _loadingDivBackgroundColor;
  38309. private _loadingDiv;
  38310. private _loadingTextDiv;
  38311. /** Gets or sets the logo url to use for the default loading screen */
  38312. static DefaultLogoUrl: string;
  38313. /** Gets or sets the spinner url to use for the default loading screen */
  38314. static DefaultSpinnerUrl: string;
  38315. /**
  38316. * Creates a new default loading screen
  38317. * @param _renderingCanvas defines the canvas used to render the scene
  38318. * @param _loadingText defines the default text to display
  38319. * @param _loadingDivBackgroundColor defines the default background color
  38320. */
  38321. constructor(_renderingCanvas: HTMLCanvasElement, _loadingText?: string, _loadingDivBackgroundColor?: string);
  38322. /**
  38323. * Function called to display the loading screen
  38324. */
  38325. displayLoadingUI(): void;
  38326. /**
  38327. * Function called to hide the loading screen
  38328. */
  38329. hideLoadingUI(): void;
  38330. /**
  38331. * Gets or sets the text to display while loading
  38332. */
  38333. set loadingUIText(text: string);
  38334. get loadingUIText(): string;
  38335. /**
  38336. * Gets or sets the color to use for the background
  38337. */
  38338. get loadingUIBackgroundColor(): string;
  38339. set loadingUIBackgroundColor(color: string);
  38340. private _resizeLoadingUI;
  38341. }
  38342. }
  38343. declare module "babylonjs/Misc/customAnimationFrameRequester" {
  38344. /**
  38345. * Interface for any object that can request an animation frame
  38346. */
  38347. export interface ICustomAnimationFrameRequester {
  38348. /**
  38349. * This function will be called when the render loop is ready. If this is not populated, the engine's renderloop function will be called
  38350. */
  38351. renderFunction?: Function;
  38352. /**
  38353. * Called to request the next frame to render to
  38354. * @see https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame
  38355. */
  38356. requestAnimationFrame: Function;
  38357. /**
  38358. * You can pass this value to cancelAnimationFrame() to cancel the refresh callback request
  38359. * @see https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame#Return_value
  38360. */
  38361. requestID?: number;
  38362. }
  38363. }
  38364. declare module "babylonjs/Misc/performanceMonitor" {
  38365. /**
  38366. * Performance monitor tracks rolling average frame-time and frame-time variance over a user defined sliding-window
  38367. */
  38368. export class PerformanceMonitor {
  38369. private _enabled;
  38370. private _rollingFrameTime;
  38371. private _lastFrameTimeMs;
  38372. /**
  38373. * constructor
  38374. * @param frameSampleSize The number of samples required to saturate the sliding window
  38375. */
  38376. constructor(frameSampleSize?: number);
  38377. /**
  38378. * Samples current frame
  38379. * @param timeMs A timestamp in milliseconds of the current frame to compare with other frames
  38380. */
  38381. sampleFrame(timeMs?: number): void;
  38382. /**
  38383. * Returns the average frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  38384. */
  38385. get averageFrameTime(): number;
  38386. /**
  38387. * Returns the variance frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  38388. */
  38389. get averageFrameTimeVariance(): number;
  38390. /**
  38391. * Returns the frame time of the most recent frame
  38392. */
  38393. get instantaneousFrameTime(): number;
  38394. /**
  38395. * Returns the average framerate in frames per second over the sliding window (or the subset of frames sampled so far)
  38396. */
  38397. get averageFPS(): number;
  38398. /**
  38399. * Returns the average framerate in frames per second using the most recent frame time
  38400. */
  38401. get instantaneousFPS(): number;
  38402. /**
  38403. * Returns true if enough samples have been taken to completely fill the sliding window
  38404. */
  38405. get isSaturated(): boolean;
  38406. /**
  38407. * Enables contributions to the sliding window sample set
  38408. */
  38409. enable(): void;
  38410. /**
  38411. * Disables contributions to the sliding window sample set
  38412. * Samples will not be interpolated over the disabled period
  38413. */
  38414. disable(): void;
  38415. /**
  38416. * Returns true if sampling is enabled
  38417. */
  38418. get isEnabled(): boolean;
  38419. /**
  38420. * Resets performance monitor
  38421. */
  38422. reset(): void;
  38423. }
  38424. /**
  38425. * RollingAverage
  38426. *
  38427. * Utility to efficiently compute the rolling average and variance over a sliding window of samples
  38428. */
  38429. export class RollingAverage {
  38430. /**
  38431. * Current average
  38432. */
  38433. average: number;
  38434. /**
  38435. * Current variance
  38436. */
  38437. variance: number;
  38438. protected _samples: Array<number>;
  38439. protected _sampleCount: number;
  38440. protected _pos: number;
  38441. protected _m2: number;
  38442. /**
  38443. * constructor
  38444. * @param length The number of samples required to saturate the sliding window
  38445. */
  38446. constructor(length: number);
  38447. /**
  38448. * Adds a sample to the sample set
  38449. * @param v The sample value
  38450. */
  38451. add(v: number): void;
  38452. /**
  38453. * Returns previously added values or null if outside of history or outside the sliding window domain
  38454. * @param i Index in history. For example, pass 0 for the most recent value and 1 for the value before that
  38455. * @return Value previously recorded with add() or null if outside of range
  38456. */
  38457. history(i: number): number;
  38458. /**
  38459. * Returns true if enough samples have been taken to completely fill the sliding window
  38460. * @return true if sample-set saturated
  38461. */
  38462. isSaturated(): boolean;
  38463. /**
  38464. * Resets the rolling average (equivalent to 0 samples taken so far)
  38465. */
  38466. reset(): void;
  38467. /**
  38468. * Wraps a value around the sample range boundaries
  38469. * @param i Position in sample range, for example if the sample length is 5, and i is -3, then 2 will be returned.
  38470. * @return Wrapped position in sample range
  38471. */
  38472. protected _wrapPosition(i: number): number;
  38473. }
  38474. }
  38475. declare module "babylonjs/Misc/perfCounter" {
  38476. /**
  38477. * This class is used to track a performance counter which is number based.
  38478. * The user has access to many properties which give statistics of different nature.
  38479. *
  38480. * The implementer can track two kinds of Performance Counter: time and count.
  38481. * 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.
  38482. * 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.
  38483. */
  38484. export class PerfCounter {
  38485. /**
  38486. * Gets or sets a global boolean to turn on and off all the counters
  38487. */
  38488. static Enabled: boolean;
  38489. /**
  38490. * Returns the smallest value ever
  38491. */
  38492. get min(): number;
  38493. /**
  38494. * Returns the biggest value ever
  38495. */
  38496. get max(): number;
  38497. /**
  38498. * Returns the average value since the performance counter is running
  38499. */
  38500. get average(): number;
  38501. /**
  38502. * Returns the average value of the last second the counter was monitored
  38503. */
  38504. get lastSecAverage(): number;
  38505. /**
  38506. * Returns the current value
  38507. */
  38508. get current(): number;
  38509. /**
  38510. * Gets the accumulated total
  38511. */
  38512. get total(): number;
  38513. /**
  38514. * Gets the total value count
  38515. */
  38516. get count(): number;
  38517. /**
  38518. * Creates a new counter
  38519. */
  38520. constructor();
  38521. /**
  38522. * Call this method to start monitoring a new frame.
  38523. * 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.
  38524. */
  38525. fetchNewFrame(): void;
  38526. /**
  38527. * Call this method to monitor a count of something (e.g. mesh drawn in viewport count)
  38528. * @param newCount the count value to add to the monitored count
  38529. * @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.
  38530. */
  38531. addCount(newCount: number, fetchResult: boolean): void;
  38532. /**
  38533. * Start monitoring this performance counter
  38534. */
  38535. beginMonitoring(): void;
  38536. /**
  38537. * Compute the time lapsed since the previous beginMonitoring() call.
  38538. * @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
  38539. */
  38540. endMonitoring(newFrame?: boolean): void;
  38541. private _fetchResult;
  38542. private _startMonitoringTime;
  38543. private _min;
  38544. private _max;
  38545. private _average;
  38546. private _current;
  38547. private _totalValueCount;
  38548. private _totalAccumulated;
  38549. private _lastSecAverage;
  38550. private _lastSecAccumulated;
  38551. private _lastSecTime;
  38552. private _lastSecValueCount;
  38553. }
  38554. }
  38555. declare module "babylonjs/Engines/Extensions/engine.readTexture" {
  38556. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  38557. import { Nullable } from "babylonjs/types";
  38558. module "babylonjs/Engines/thinEngine" {
  38559. interface ThinEngine {
  38560. /** @hidden */
  38561. _readTexturePixels(texture: InternalTexture, width: number, height: number, faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>): ArrayBufferView;
  38562. }
  38563. }
  38564. }
  38565. declare module "babylonjs/Engines/engine" {
  38566. import { Observable } from "babylonjs/Misc/observable";
  38567. import { Nullable } from "babylonjs/types";
  38568. import { Scene } from "babylonjs/scene";
  38569. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  38570. import { IAudioEngine } from "babylonjs/Audio/audioEngine";
  38571. import { IOfflineProvider } from "babylonjs/Offline/IOfflineProvider";
  38572. import { ILoadingScreen } from "babylonjs/Loading/loadingScreen";
  38573. import { WebGLPipelineContext } from "babylonjs/Engines/WebGL/webGLPipelineContext";
  38574. import { IPipelineContext } from "babylonjs/Engines/IPipelineContext";
  38575. import { ICustomAnimationFrameRequester } from "babylonjs/Misc/customAnimationFrameRequester";
  38576. import { ThinEngine, EngineOptions } from "babylonjs/Engines/thinEngine";
  38577. import { IViewportLike, IColor4Like } from "babylonjs/Maths/math.like";
  38578. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  38579. import { PerformanceMonitor } from "babylonjs/Misc/performanceMonitor";
  38580. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  38581. import { PerfCounter } from "babylonjs/Misc/perfCounter";
  38582. import "babylonjs/Engines/Extensions/engine.alpha";
  38583. import "babylonjs/Engines/Extensions/engine.readTexture";
  38584. import "babylonjs/Engines/Extensions/engine.dynamicBuffer";
  38585. import { Material } from "babylonjs/Materials/material";
  38586. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  38587. /**
  38588. * Defines the interface used by display changed events
  38589. */
  38590. export interface IDisplayChangedEventArgs {
  38591. /** Gets the vrDisplay object (if any) */
  38592. vrDisplay: Nullable<any>;
  38593. /** Gets a boolean indicating if webVR is supported */
  38594. vrSupported: boolean;
  38595. }
  38596. /**
  38597. * Defines the interface used by objects containing a viewport (like a camera)
  38598. */
  38599. interface IViewportOwnerLike {
  38600. /**
  38601. * Gets or sets the viewport
  38602. */
  38603. viewport: IViewportLike;
  38604. }
  38605. /**
  38606. * The engine class is responsible for interfacing with all lower-level APIs such as WebGL and Audio
  38607. */
  38608. export class Engine extends ThinEngine {
  38609. /** Defines that alpha blending is disabled */
  38610. static readonly ALPHA_DISABLE: number;
  38611. /** Defines that alpha blending to SRC ALPHA * SRC + DEST */
  38612. static readonly ALPHA_ADD: number;
  38613. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC ALPHA) * DEST */
  38614. static readonly ALPHA_COMBINE: number;
  38615. /** Defines that alpha blending to DEST - SRC * DEST */
  38616. static readonly ALPHA_SUBTRACT: number;
  38617. /** Defines that alpha blending to SRC * DEST */
  38618. static readonly ALPHA_MULTIPLY: number;
  38619. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC) * DEST */
  38620. static readonly ALPHA_MAXIMIZED: number;
  38621. /** Defines that alpha blending to SRC + DEST */
  38622. static readonly ALPHA_ONEONE: number;
  38623. /** Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST */
  38624. static readonly ALPHA_PREMULTIPLIED: number;
  38625. /**
  38626. * Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST
  38627. * Alpha will be set to (1 - SRC ALPHA) * DEST ALPHA
  38628. */
  38629. static readonly ALPHA_PREMULTIPLIED_PORTERDUFF: number;
  38630. /** Defines that alpha blending to CST * SRC + (1 - CST) * DEST */
  38631. static readonly ALPHA_INTERPOLATE: number;
  38632. /**
  38633. * Defines that alpha blending to SRC + (1 - SRC) * DEST
  38634. * Alpha will be set to SRC ALPHA + (1 - SRC ALPHA) * DEST ALPHA
  38635. */
  38636. static readonly ALPHA_SCREENMODE: number;
  38637. /** Defines that the ressource is not delayed*/
  38638. static readonly DELAYLOADSTATE_NONE: number;
  38639. /** Defines that the ressource was successfully delay loaded */
  38640. static readonly DELAYLOADSTATE_LOADED: number;
  38641. /** Defines that the ressource is currently delay loading */
  38642. static readonly DELAYLOADSTATE_LOADING: number;
  38643. /** Defines that the ressource is delayed and has not started loading */
  38644. static readonly DELAYLOADSTATE_NOTLOADED: number;
  38645. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will never pass. i.e. Nothing will be drawn */
  38646. static readonly NEVER: number;
  38647. /** 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 */
  38648. static readonly ALWAYS: number;
  38649. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is less than the stored value */
  38650. static readonly LESS: number;
  38651. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is equals to the stored value */
  38652. static readonly EQUAL: number;
  38653. /** 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 */
  38654. static readonly LEQUAL: number;
  38655. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is greater than the stored value */
  38656. static readonly GREATER: number;
  38657. /** 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 */
  38658. static readonly GEQUAL: number;
  38659. /** 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 */
  38660. static readonly NOTEQUAL: number;
  38661. /** Passed to stencilOperation to specify that stencil value must be kept */
  38662. static readonly KEEP: number;
  38663. /** Passed to stencilOperation to specify that stencil value must be replaced */
  38664. static readonly REPLACE: number;
  38665. /** Passed to stencilOperation to specify that stencil value must be incremented */
  38666. static readonly INCR: number;
  38667. /** Passed to stencilOperation to specify that stencil value must be decremented */
  38668. static readonly DECR: number;
  38669. /** Passed to stencilOperation to specify that stencil value must be inverted */
  38670. static readonly INVERT: number;
  38671. /** Passed to stencilOperation to specify that stencil value must be incremented with wrapping */
  38672. static readonly INCR_WRAP: number;
  38673. /** Passed to stencilOperation to specify that stencil value must be decremented with wrapping */
  38674. static readonly DECR_WRAP: number;
  38675. /** Texture is not repeating outside of 0..1 UVs */
  38676. static readonly TEXTURE_CLAMP_ADDRESSMODE: number;
  38677. /** Texture is repeating outside of 0..1 UVs */
  38678. static readonly TEXTURE_WRAP_ADDRESSMODE: number;
  38679. /** Texture is repeating and mirrored */
  38680. static readonly TEXTURE_MIRROR_ADDRESSMODE: number;
  38681. /** ALPHA */
  38682. static readonly TEXTUREFORMAT_ALPHA: number;
  38683. /** LUMINANCE */
  38684. static readonly TEXTUREFORMAT_LUMINANCE: number;
  38685. /** LUMINANCE_ALPHA */
  38686. static readonly TEXTUREFORMAT_LUMINANCE_ALPHA: number;
  38687. /** RGB */
  38688. static readonly TEXTUREFORMAT_RGB: number;
  38689. /** RGBA */
  38690. static readonly TEXTUREFORMAT_RGBA: number;
  38691. /** RED */
  38692. static readonly TEXTUREFORMAT_RED: number;
  38693. /** RED (2nd reference) */
  38694. static readonly TEXTUREFORMAT_R: number;
  38695. /** RG */
  38696. static readonly TEXTUREFORMAT_RG: number;
  38697. /** RED_INTEGER */
  38698. static readonly TEXTUREFORMAT_RED_INTEGER: number;
  38699. /** RED_INTEGER (2nd reference) */
  38700. static readonly TEXTUREFORMAT_R_INTEGER: number;
  38701. /** RG_INTEGER */
  38702. static readonly TEXTUREFORMAT_RG_INTEGER: number;
  38703. /** RGB_INTEGER */
  38704. static readonly TEXTUREFORMAT_RGB_INTEGER: number;
  38705. /** RGBA_INTEGER */
  38706. static readonly TEXTUREFORMAT_RGBA_INTEGER: number;
  38707. /** UNSIGNED_BYTE */
  38708. static readonly TEXTURETYPE_UNSIGNED_BYTE: number;
  38709. /** UNSIGNED_BYTE (2nd reference) */
  38710. static readonly TEXTURETYPE_UNSIGNED_INT: number;
  38711. /** FLOAT */
  38712. static readonly TEXTURETYPE_FLOAT: number;
  38713. /** HALF_FLOAT */
  38714. static readonly TEXTURETYPE_HALF_FLOAT: number;
  38715. /** BYTE */
  38716. static readonly TEXTURETYPE_BYTE: number;
  38717. /** SHORT */
  38718. static readonly TEXTURETYPE_SHORT: number;
  38719. /** UNSIGNED_SHORT */
  38720. static readonly TEXTURETYPE_UNSIGNED_SHORT: number;
  38721. /** INT */
  38722. static readonly TEXTURETYPE_INT: number;
  38723. /** UNSIGNED_INT */
  38724. static readonly TEXTURETYPE_UNSIGNED_INTEGER: number;
  38725. /** UNSIGNED_SHORT_4_4_4_4 */
  38726. static readonly TEXTURETYPE_UNSIGNED_SHORT_4_4_4_4: number;
  38727. /** UNSIGNED_SHORT_5_5_5_1 */
  38728. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_5_5_1: number;
  38729. /** UNSIGNED_SHORT_5_6_5 */
  38730. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_6_5: number;
  38731. /** UNSIGNED_INT_2_10_10_10_REV */
  38732. static readonly TEXTURETYPE_UNSIGNED_INT_2_10_10_10_REV: number;
  38733. /** UNSIGNED_INT_24_8 */
  38734. static readonly TEXTURETYPE_UNSIGNED_INT_24_8: number;
  38735. /** UNSIGNED_INT_10F_11F_11F_REV */
  38736. static readonly TEXTURETYPE_UNSIGNED_INT_10F_11F_11F_REV: number;
  38737. /** UNSIGNED_INT_5_9_9_9_REV */
  38738. static readonly TEXTURETYPE_UNSIGNED_INT_5_9_9_9_REV: number;
  38739. /** FLOAT_32_UNSIGNED_INT_24_8_REV */
  38740. static readonly TEXTURETYPE_FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  38741. /** nearest is mag = nearest and min = nearest and mip = linear */
  38742. static readonly TEXTURE_NEAREST_SAMPLINGMODE: number;
  38743. /** Bilinear is mag = linear and min = linear and mip = nearest */
  38744. static readonly TEXTURE_BILINEAR_SAMPLINGMODE: number;
  38745. /** Trilinear is mag = linear and min = linear and mip = linear */
  38746. static readonly TEXTURE_TRILINEAR_SAMPLINGMODE: number;
  38747. /** nearest is mag = nearest and min = nearest and mip = linear */
  38748. static readonly TEXTURE_NEAREST_NEAREST_MIPLINEAR: number;
  38749. /** Bilinear is mag = linear and min = linear and mip = nearest */
  38750. static readonly TEXTURE_LINEAR_LINEAR_MIPNEAREST: number;
  38751. /** Trilinear is mag = linear and min = linear and mip = linear */
  38752. static readonly TEXTURE_LINEAR_LINEAR_MIPLINEAR: number;
  38753. /** mag = nearest and min = nearest and mip = nearest */
  38754. static readonly TEXTURE_NEAREST_NEAREST_MIPNEAREST: number;
  38755. /** mag = nearest and min = linear and mip = nearest */
  38756. static readonly TEXTURE_NEAREST_LINEAR_MIPNEAREST: number;
  38757. /** mag = nearest and min = linear and mip = linear */
  38758. static readonly TEXTURE_NEAREST_LINEAR_MIPLINEAR: number;
  38759. /** mag = nearest and min = linear and mip = none */
  38760. static readonly TEXTURE_NEAREST_LINEAR: number;
  38761. /** mag = nearest and min = nearest and mip = none */
  38762. static readonly TEXTURE_NEAREST_NEAREST: number;
  38763. /** mag = linear and min = nearest and mip = nearest */
  38764. static readonly TEXTURE_LINEAR_NEAREST_MIPNEAREST: number;
  38765. /** mag = linear and min = nearest and mip = linear */
  38766. static readonly TEXTURE_LINEAR_NEAREST_MIPLINEAR: number;
  38767. /** mag = linear and min = linear and mip = none */
  38768. static readonly TEXTURE_LINEAR_LINEAR: number;
  38769. /** mag = linear and min = nearest and mip = none */
  38770. static readonly TEXTURE_LINEAR_NEAREST: number;
  38771. /** Explicit coordinates mode */
  38772. static readonly TEXTURE_EXPLICIT_MODE: number;
  38773. /** Spherical coordinates mode */
  38774. static readonly TEXTURE_SPHERICAL_MODE: number;
  38775. /** Planar coordinates mode */
  38776. static readonly TEXTURE_PLANAR_MODE: number;
  38777. /** Cubic coordinates mode */
  38778. static readonly TEXTURE_CUBIC_MODE: number;
  38779. /** Projection coordinates mode */
  38780. static readonly TEXTURE_PROJECTION_MODE: number;
  38781. /** Skybox coordinates mode */
  38782. static readonly TEXTURE_SKYBOX_MODE: number;
  38783. /** Inverse Cubic coordinates mode */
  38784. static readonly TEXTURE_INVCUBIC_MODE: number;
  38785. /** Equirectangular coordinates mode */
  38786. static readonly TEXTURE_EQUIRECTANGULAR_MODE: number;
  38787. /** Equirectangular Fixed coordinates mode */
  38788. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MODE: number;
  38789. /** Equirectangular Fixed Mirrored coordinates mode */
  38790. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  38791. /** Defines that texture rescaling will use a floor to find the closer power of 2 size */
  38792. static readonly SCALEMODE_FLOOR: number;
  38793. /** Defines that texture rescaling will look for the nearest power of 2 size */
  38794. static readonly SCALEMODE_NEAREST: number;
  38795. /** Defines that texture rescaling will use a ceil to find the closer power of 2 size */
  38796. static readonly SCALEMODE_CEILING: number;
  38797. /**
  38798. * Returns the current npm package of the sdk
  38799. */
  38800. static get NpmPackage(): string;
  38801. /**
  38802. * Returns the current version of the framework
  38803. */
  38804. static get Version(): string;
  38805. /** Gets the list of created engines */
  38806. static get Instances(): Engine[];
  38807. /**
  38808. * Gets the latest created engine
  38809. */
  38810. static get LastCreatedEngine(): Nullable<Engine>;
  38811. /**
  38812. * Gets the latest created scene
  38813. */
  38814. static get LastCreatedScene(): Nullable<Scene>;
  38815. /**
  38816. * Will flag all materials in all scenes in all engines as dirty to trigger new shader compilation
  38817. * @param flag defines which part of the materials must be marked as dirty
  38818. * @param predicate defines a predicate used to filter which materials should be affected
  38819. */
  38820. static MarkAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  38821. /**
  38822. * Method called to create the default loading screen.
  38823. * This can be overriden in your own app.
  38824. * @param canvas The rendering canvas element
  38825. * @returns The loading screen
  38826. */
  38827. static DefaultLoadingScreenFactory(canvas: HTMLCanvasElement): ILoadingScreen;
  38828. /**
  38829. * Method called to create the default rescale post process on each engine.
  38830. */
  38831. static _RescalePostProcessFactory: Nullable<(engine: Engine) => PostProcess>;
  38832. /**
  38833. * Gets or sets a boolean to enable/disable IndexedDB support and avoid XHR on .manifest
  38834. **/
  38835. enableOfflineSupport: boolean;
  38836. /**
  38837. * 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)
  38838. **/
  38839. disableManifestCheck: boolean;
  38840. /**
  38841. * Gets the list of created scenes
  38842. */
  38843. scenes: Scene[];
  38844. /**
  38845. * Event raised when a new scene is created
  38846. */
  38847. onNewSceneAddedObservable: Observable<Scene>;
  38848. /**
  38849. * Gets the list of created postprocesses
  38850. */
  38851. postProcesses: import("babylonjs/PostProcesses/postProcess").PostProcess[];
  38852. /**
  38853. * Gets a boolean indicating if the pointer is currently locked
  38854. */
  38855. isPointerLock: boolean;
  38856. /**
  38857. * Observable event triggered each time the rendering canvas is resized
  38858. */
  38859. onResizeObservable: Observable<Engine>;
  38860. /**
  38861. * Observable event triggered each time the canvas loses focus
  38862. */
  38863. onCanvasBlurObservable: Observable<Engine>;
  38864. /**
  38865. * Observable event triggered each time the canvas gains focus
  38866. */
  38867. onCanvasFocusObservable: Observable<Engine>;
  38868. /**
  38869. * Observable event triggered each time the canvas receives pointerout event
  38870. */
  38871. onCanvasPointerOutObservable: Observable<PointerEvent>;
  38872. /**
  38873. * Observable raised when the engine begins a new frame
  38874. */
  38875. onBeginFrameObservable: Observable<Engine>;
  38876. /**
  38877. * If set, will be used to request the next animation frame for the render loop
  38878. */
  38879. customAnimationFrameRequester: Nullable<ICustomAnimationFrameRequester>;
  38880. /**
  38881. * Observable raised when the engine ends the current frame
  38882. */
  38883. onEndFrameObservable: Observable<Engine>;
  38884. /**
  38885. * Observable raised when the engine is about to compile a shader
  38886. */
  38887. onBeforeShaderCompilationObservable: Observable<Engine>;
  38888. /**
  38889. * Observable raised when the engine has jsut compiled a shader
  38890. */
  38891. onAfterShaderCompilationObservable: Observable<Engine>;
  38892. /**
  38893. * Gets the audio engine
  38894. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  38895. * @ignorenaming
  38896. */
  38897. static audioEngine: IAudioEngine;
  38898. /**
  38899. * Default AudioEngine factory responsible of creating the Audio Engine.
  38900. * By default, this will create a BabylonJS Audio Engine if the workload has been embedded.
  38901. */
  38902. static AudioEngineFactory: (hostElement: Nullable<HTMLElement>) => IAudioEngine;
  38903. /**
  38904. * Default offline support factory responsible of creating a tool used to store data locally.
  38905. * By default, this will create a Database object if the workload has been embedded.
  38906. */
  38907. static OfflineProviderFactory: (urlToScene: string, callbackManifestChecked: (checked: boolean) => any, disableManifestCheck: boolean) => IOfflineProvider;
  38908. private _loadingScreen;
  38909. private _pointerLockRequested;
  38910. private _rescalePostProcess;
  38911. private _deterministicLockstep;
  38912. private _lockstepMaxSteps;
  38913. private _timeStep;
  38914. protected get _supportsHardwareTextureRescaling(): boolean;
  38915. private _fps;
  38916. private _deltaTime;
  38917. /** @hidden */
  38918. _drawCalls: PerfCounter;
  38919. /** 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 */
  38920. canvasTabIndex: number;
  38921. /**
  38922. * Turn this value on if you want to pause FPS computation when in background
  38923. */
  38924. disablePerformanceMonitorInBackground: boolean;
  38925. private _performanceMonitor;
  38926. /**
  38927. * Gets the performance monitor attached to this engine
  38928. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  38929. */
  38930. get performanceMonitor(): PerformanceMonitor;
  38931. private _onFocus;
  38932. private _onBlur;
  38933. private _onCanvasPointerOut;
  38934. private _onCanvasBlur;
  38935. private _onCanvasFocus;
  38936. private _onFullscreenChange;
  38937. private _onPointerLockChange;
  38938. /**
  38939. * Gets the HTML element used to attach event listeners
  38940. * @returns a HTML element
  38941. */
  38942. getInputElement(): Nullable<HTMLElement>;
  38943. /**
  38944. * Creates a new engine
  38945. * @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
  38946. * @param antialias defines enable antialiasing (default: false)
  38947. * @param options defines further options to be sent to the getContext() function
  38948. * @param adaptToDeviceRatio defines whether to adapt to the device's viewport characteristics (default: false)
  38949. */
  38950. constructor(canvasOrContext: Nullable<HTMLCanvasElement | WebGLRenderingContext>, antialias?: boolean, options?: EngineOptions, adaptToDeviceRatio?: boolean);
  38951. /**
  38952. * Gets current aspect ratio
  38953. * @param viewportOwner defines the camera to use to get the aspect ratio
  38954. * @param useScreen defines if screen size must be used (or the current render target if any)
  38955. * @returns a number defining the aspect ratio
  38956. */
  38957. getAspectRatio(viewportOwner: IViewportOwnerLike, useScreen?: boolean): number;
  38958. /**
  38959. * Gets current screen aspect ratio
  38960. * @returns a number defining the aspect ratio
  38961. */
  38962. getScreenAspectRatio(): number;
  38963. /**
  38964. * Gets the client rect of the HTML canvas attached with the current webGL context
  38965. * @returns a client rectanglee
  38966. */
  38967. getRenderingCanvasClientRect(): Nullable<ClientRect>;
  38968. /**
  38969. * Gets the client rect of the HTML element used for events
  38970. * @returns a client rectanglee
  38971. */
  38972. getInputElementClientRect(): Nullable<ClientRect>;
  38973. /**
  38974. * Gets a boolean indicating that the engine is running in deterministic lock step mode
  38975. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  38976. * @returns true if engine is in deterministic lock step mode
  38977. */
  38978. isDeterministicLockStep(): boolean;
  38979. /**
  38980. * Gets the max steps when engine is running in deterministic lock step
  38981. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  38982. * @returns the max steps
  38983. */
  38984. getLockstepMaxSteps(): number;
  38985. /**
  38986. * Returns the time in ms between steps when using deterministic lock step.
  38987. * @returns time step in (ms)
  38988. */
  38989. getTimeStep(): number;
  38990. /**
  38991. * Force the mipmap generation for the given render target texture
  38992. * @param texture defines the render target texture to use
  38993. * @param unbind defines whether or not to unbind the texture after generation. Defaults to true.
  38994. */
  38995. generateMipMapsForCubemap(texture: InternalTexture, unbind?: boolean): void;
  38996. /** States */
  38997. /**
  38998. * Set various states to the webGL context
  38999. * @param culling defines backface culling state
  39000. * @param zOffset defines the value to apply to zOffset (0 by default)
  39001. * @param force defines if states must be applied even if cache is up to date
  39002. * @param reverseSide defines if culling must be reversed (CCW instead of CW and CW instead of CCW)
  39003. */
  39004. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  39005. /**
  39006. * Set the z offset to apply to current rendering
  39007. * @param value defines the offset to apply
  39008. */
  39009. setZOffset(value: number): void;
  39010. /**
  39011. * Gets the current value of the zOffset
  39012. * @returns the current zOffset state
  39013. */
  39014. getZOffset(): number;
  39015. /**
  39016. * Enable or disable depth buffering
  39017. * @param enable defines the state to set
  39018. */
  39019. setDepthBuffer(enable: boolean): void;
  39020. /**
  39021. * Gets a boolean indicating if depth writing is enabled
  39022. * @returns the current depth writing state
  39023. */
  39024. getDepthWrite(): boolean;
  39025. /**
  39026. * Enable or disable depth writing
  39027. * @param enable defines the state to set
  39028. */
  39029. setDepthWrite(enable: boolean): void;
  39030. /**
  39031. * Gets a boolean indicating if stencil buffer is enabled
  39032. * @returns the current stencil buffer state
  39033. */
  39034. getStencilBuffer(): boolean;
  39035. /**
  39036. * Enable or disable the stencil buffer
  39037. * @param enable defines if the stencil buffer must be enabled or disabled
  39038. */
  39039. setStencilBuffer(enable: boolean): void;
  39040. /**
  39041. * Gets the current stencil mask
  39042. * @returns a number defining the new stencil mask to use
  39043. */
  39044. getStencilMask(): number;
  39045. /**
  39046. * Sets the current stencil mask
  39047. * @param mask defines the new stencil mask to use
  39048. */
  39049. setStencilMask(mask: number): void;
  39050. /**
  39051. * Gets the current stencil function
  39052. * @returns a number defining the stencil function to use
  39053. */
  39054. getStencilFunction(): number;
  39055. /**
  39056. * Gets the current stencil reference value
  39057. * @returns a number defining the stencil reference value to use
  39058. */
  39059. getStencilFunctionReference(): number;
  39060. /**
  39061. * Gets the current stencil mask
  39062. * @returns a number defining the stencil mask to use
  39063. */
  39064. getStencilFunctionMask(): number;
  39065. /**
  39066. * Sets the current stencil function
  39067. * @param stencilFunc defines the new stencil function to use
  39068. */
  39069. setStencilFunction(stencilFunc: number): void;
  39070. /**
  39071. * Sets the current stencil reference
  39072. * @param reference defines the new stencil reference to use
  39073. */
  39074. setStencilFunctionReference(reference: number): void;
  39075. /**
  39076. * Sets the current stencil mask
  39077. * @param mask defines the new stencil mask to use
  39078. */
  39079. setStencilFunctionMask(mask: number): void;
  39080. /**
  39081. * Gets the current stencil operation when stencil fails
  39082. * @returns a number defining stencil operation to use when stencil fails
  39083. */
  39084. getStencilOperationFail(): number;
  39085. /**
  39086. * Gets the current stencil operation when depth fails
  39087. * @returns a number defining stencil operation to use when depth fails
  39088. */
  39089. getStencilOperationDepthFail(): number;
  39090. /**
  39091. * Gets the current stencil operation when stencil passes
  39092. * @returns a number defining stencil operation to use when stencil passes
  39093. */
  39094. getStencilOperationPass(): number;
  39095. /**
  39096. * Sets the stencil operation to use when stencil fails
  39097. * @param operation defines the stencil operation to use when stencil fails
  39098. */
  39099. setStencilOperationFail(operation: number): void;
  39100. /**
  39101. * Sets the stencil operation to use when depth fails
  39102. * @param operation defines the stencil operation to use when depth fails
  39103. */
  39104. setStencilOperationDepthFail(operation: number): void;
  39105. /**
  39106. * Sets the stencil operation to use when stencil passes
  39107. * @param operation defines the stencil operation to use when stencil passes
  39108. */
  39109. setStencilOperationPass(operation: number): void;
  39110. /**
  39111. * Sets a boolean indicating if the dithering state is enabled or disabled
  39112. * @param value defines the dithering state
  39113. */
  39114. setDitheringState(value: boolean): void;
  39115. /**
  39116. * Sets a boolean indicating if the rasterizer state is enabled or disabled
  39117. * @param value defines the rasterizer state
  39118. */
  39119. setRasterizerState(value: boolean): void;
  39120. /**
  39121. * Gets the current depth function
  39122. * @returns a number defining the depth function
  39123. */
  39124. getDepthFunction(): Nullable<number>;
  39125. /**
  39126. * Sets the current depth function
  39127. * @param depthFunc defines the function to use
  39128. */
  39129. setDepthFunction(depthFunc: number): void;
  39130. /**
  39131. * Sets the current depth function to GREATER
  39132. */
  39133. setDepthFunctionToGreater(): void;
  39134. /**
  39135. * Sets the current depth function to GEQUAL
  39136. */
  39137. setDepthFunctionToGreaterOrEqual(): void;
  39138. /**
  39139. * Sets the current depth function to LESS
  39140. */
  39141. setDepthFunctionToLess(): void;
  39142. /**
  39143. * Sets the current depth function to LEQUAL
  39144. */
  39145. setDepthFunctionToLessOrEqual(): void;
  39146. private _cachedStencilBuffer;
  39147. private _cachedStencilFunction;
  39148. private _cachedStencilMask;
  39149. private _cachedStencilOperationPass;
  39150. private _cachedStencilOperationFail;
  39151. private _cachedStencilOperationDepthFail;
  39152. private _cachedStencilReference;
  39153. /**
  39154. * Caches the the state of the stencil buffer
  39155. */
  39156. cacheStencilState(): void;
  39157. /**
  39158. * Restores the state of the stencil buffer
  39159. */
  39160. restoreStencilState(): void;
  39161. /**
  39162. * Directly set the WebGL Viewport
  39163. * @param x defines the x coordinate of the viewport (in screen space)
  39164. * @param y defines the y coordinate of the viewport (in screen space)
  39165. * @param width defines the width of the viewport (in screen space)
  39166. * @param height defines the height of the viewport (in screen space)
  39167. * @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
  39168. */
  39169. setDirectViewport(x: number, y: number, width: number, height: number): Nullable<IViewportLike>;
  39170. /**
  39171. * Executes a scissor clear (ie. a clear on a specific portion of the screen)
  39172. * @param x defines the x-coordinate of the top left corner of the clear rectangle
  39173. * @param y defines the y-coordinate of the corner of the clear rectangle
  39174. * @param width defines the width of the clear rectangle
  39175. * @param height defines the height of the clear rectangle
  39176. * @param clearColor defines the clear color
  39177. */
  39178. scissorClear(x: number, y: number, width: number, height: number, clearColor: IColor4Like): void;
  39179. /**
  39180. * Enable scissor test on a specific rectangle (ie. render will only be executed on a specific portion of the screen)
  39181. * @param x defines the x-coordinate of the top left corner of the clear rectangle
  39182. * @param y defines the y-coordinate of the corner of the clear rectangle
  39183. * @param width defines the width of the clear rectangle
  39184. * @param height defines the height of the clear rectangle
  39185. */
  39186. enableScissor(x: number, y: number, width: number, height: number): void;
  39187. /**
  39188. * Disable previously set scissor test rectangle
  39189. */
  39190. disableScissor(): void;
  39191. protected _reportDrawCall(): void;
  39192. /**
  39193. * Initializes a webVR display and starts listening to display change events
  39194. * The onVRDisplayChangedObservable will be notified upon these changes
  39195. * @returns The onVRDisplayChangedObservable
  39196. */
  39197. initWebVR(): Observable<IDisplayChangedEventArgs>;
  39198. /** @hidden */
  39199. _prepareVRComponent(): void;
  39200. /** @hidden */
  39201. _connectVREvents(canvas?: HTMLCanvasElement, document?: any): void;
  39202. /** @hidden */
  39203. _submitVRFrame(): void;
  39204. /**
  39205. * Call this function to leave webVR mode
  39206. * Will do nothing if webVR is not supported or if there is no webVR device
  39207. * @see https://doc.babylonjs.com/how_to/webvr_camera
  39208. */
  39209. disableVR(): void;
  39210. /**
  39211. * Gets a boolean indicating that the system is in VR mode and is presenting
  39212. * @returns true if VR mode is engaged
  39213. */
  39214. isVRPresenting(): boolean;
  39215. /** @hidden */
  39216. _requestVRFrame(): void;
  39217. /** @hidden */
  39218. _loadFileAsync(url: string, offlineProvider?: IOfflineProvider, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  39219. /**
  39220. * Gets the source code of the vertex shader associated with a specific webGL program
  39221. * @param program defines the program to use
  39222. * @returns a string containing the source code of the vertex shader associated with the program
  39223. */
  39224. getVertexShaderSource(program: WebGLProgram): Nullable<string>;
  39225. /**
  39226. * Gets the source code of the fragment shader associated with a specific webGL program
  39227. * @param program defines the program to use
  39228. * @returns a string containing the source code of the fragment shader associated with the program
  39229. */
  39230. getFragmentShaderSource(program: WebGLProgram): Nullable<string>;
  39231. /**
  39232. * Sets a depth stencil texture from a render target to the according uniform.
  39233. * @param channel The texture channel
  39234. * @param uniform The uniform to set
  39235. * @param texture The render target texture containing the depth stencil texture to apply
  39236. */
  39237. setDepthStencilTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<RenderTargetTexture>): void;
  39238. /**
  39239. * Sets a texture to the webGL context from a postprocess
  39240. * @param channel defines the channel to use
  39241. * @param postProcess defines the source postprocess
  39242. */
  39243. setTextureFromPostProcess(channel: number, postProcess: Nullable<PostProcess>): void;
  39244. /**
  39245. * Binds the output of the passed in post process to the texture channel specified
  39246. * @param channel The channel the texture should be bound to
  39247. * @param postProcess The post process which's output should be bound
  39248. */
  39249. setTextureFromPostProcessOutput(channel: number, postProcess: Nullable<PostProcess>): void;
  39250. protected _rebuildBuffers(): void;
  39251. /** @hidden */
  39252. _renderFrame(): void;
  39253. _renderLoop(): void;
  39254. /** @hidden */
  39255. _renderViews(): boolean;
  39256. /**
  39257. * Toggle full screen mode
  39258. * @param requestPointerLock defines if a pointer lock should be requested from the user
  39259. */
  39260. switchFullscreen(requestPointerLock: boolean): void;
  39261. /**
  39262. * Enters full screen mode
  39263. * @param requestPointerLock defines if a pointer lock should be requested from the user
  39264. */
  39265. enterFullscreen(requestPointerLock: boolean): void;
  39266. /**
  39267. * Exits full screen mode
  39268. */
  39269. exitFullscreen(): void;
  39270. /**
  39271. * Enters Pointerlock mode
  39272. */
  39273. enterPointerlock(): void;
  39274. /**
  39275. * Exits Pointerlock mode
  39276. */
  39277. exitPointerlock(): void;
  39278. /**
  39279. * Begin a new frame
  39280. */
  39281. beginFrame(): void;
  39282. /**
  39283. * Enf the current frame
  39284. */
  39285. endFrame(): void;
  39286. resize(): void;
  39287. /**
  39288. * Force a specific size of the canvas
  39289. * @param width defines the new canvas' width
  39290. * @param height defines the new canvas' height
  39291. * @returns true if the size was changed
  39292. */
  39293. setSize(width: number, height: number): boolean;
  39294. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  39295. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  39296. protected _createShaderProgram(pipelineContext: WebGLPipelineContext, vertexShader: WebGLShader, fragmentShader: WebGLShader, context: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  39297. _releaseTexture(texture: InternalTexture): void;
  39298. /**
  39299. * @hidden
  39300. * Rescales a texture
  39301. * @param source input texutre
  39302. * @param destination destination texture
  39303. * @param scene scene to use to render the resize
  39304. * @param internalFormat format to use when resizing
  39305. * @param onComplete callback to be called when resize has completed
  39306. */
  39307. _rescaleTexture(source: InternalTexture, destination: InternalTexture, scene: Nullable<any>, internalFormat: number, onComplete: () => void): void;
  39308. /**
  39309. * Gets the current framerate
  39310. * @returns a number representing the framerate
  39311. */
  39312. getFps(): number;
  39313. /**
  39314. * Gets the time spent between current and previous frame
  39315. * @returns a number representing the delta time in ms
  39316. */
  39317. getDeltaTime(): number;
  39318. private _measureFps;
  39319. /** @hidden */
  39320. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement | ImageBitmap, faceIndex?: number, lod?: number): void;
  39321. /**
  39322. * Updates the sample count of a render target texture
  39323. * @see https://doc.babylonjs.com/features/webgl2#multisample-render-targets
  39324. * @param texture defines the texture to update
  39325. * @param samples defines the sample count to set
  39326. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  39327. */
  39328. updateRenderTargetTextureSampleCount(texture: Nullable<InternalTexture>, samples: number): number;
  39329. /**
  39330. * Updates a depth texture Comparison Mode and Function.
  39331. * If the comparison Function is equal to 0, the mode will be set to none.
  39332. * Otherwise, this only works in webgl 2 and requires a shadow sampler in the shader.
  39333. * @param texture The texture to set the comparison function for
  39334. * @param comparisonFunction The comparison function to set, 0 if no comparison required
  39335. */
  39336. updateTextureComparisonFunction(texture: InternalTexture, comparisonFunction: number): void;
  39337. /**
  39338. * Creates a webGL buffer to use with instanciation
  39339. * @param capacity defines the size of the buffer
  39340. * @returns the webGL buffer
  39341. */
  39342. createInstancesBuffer(capacity: number): DataBuffer;
  39343. /**
  39344. * Delete a webGL buffer used with instanciation
  39345. * @param buffer defines the webGL buffer to delete
  39346. */
  39347. deleteInstancesBuffer(buffer: WebGLBuffer): void;
  39348. private _clientWaitAsync;
  39349. /** @hidden */
  39350. _readPixelsAsync(x: number, y: number, w: number, h: number, format: number, type: number, outputBuffer: ArrayBufferView): Promise<ArrayBufferView> | null;
  39351. dispose(): void;
  39352. private _disableTouchAction;
  39353. /**
  39354. * Display the loading screen
  39355. * @see https://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  39356. */
  39357. displayLoadingUI(): void;
  39358. /**
  39359. * Hide the loading screen
  39360. * @see https://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  39361. */
  39362. hideLoadingUI(): void;
  39363. /**
  39364. * Gets the current loading screen object
  39365. * @see https://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  39366. */
  39367. get loadingScreen(): ILoadingScreen;
  39368. /**
  39369. * Sets the current loading screen object
  39370. * @see https://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  39371. */
  39372. set loadingScreen(loadingScreen: ILoadingScreen);
  39373. /**
  39374. * Sets the current loading screen text
  39375. * @see https://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  39376. */
  39377. set loadingUIText(text: string);
  39378. /**
  39379. * Sets the current loading screen background color
  39380. * @see https://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  39381. */
  39382. set loadingUIBackgroundColor(color: string);
  39383. /** Pointerlock and fullscreen */
  39384. /**
  39385. * Ask the browser to promote the current element to pointerlock mode
  39386. * @param element defines the DOM element to promote
  39387. */
  39388. static _RequestPointerlock(element: HTMLElement): void;
  39389. /**
  39390. * Asks the browser to exit pointerlock mode
  39391. */
  39392. static _ExitPointerlock(): void;
  39393. /**
  39394. * Ask the browser to promote the current element to fullscreen rendering mode
  39395. * @param element defines the DOM element to promote
  39396. */
  39397. static _RequestFullscreen(element: HTMLElement): void;
  39398. /**
  39399. * Asks the browser to exit fullscreen mode
  39400. */
  39401. static _ExitFullscreen(): void;
  39402. }
  39403. }
  39404. declare module "babylonjs/Engines/engineStore" {
  39405. import { Nullable } from "babylonjs/types";
  39406. import { Engine } from "babylonjs/Engines/engine";
  39407. import { Scene } from "babylonjs/scene";
  39408. /**
  39409. * The engine store class is responsible to hold all the instances of Engine and Scene created
  39410. * during the life time of the application.
  39411. */
  39412. export class EngineStore {
  39413. /** Gets the list of created engines */
  39414. static Instances: import("babylonjs/Engines/engine").Engine[];
  39415. /** @hidden */
  39416. static _LastCreatedScene: Nullable<Scene>;
  39417. /**
  39418. * Gets the latest created engine
  39419. */
  39420. static get LastCreatedEngine(): Nullable<Engine>;
  39421. /**
  39422. * Gets the latest created scene
  39423. */
  39424. static get LastCreatedScene(): Nullable<Scene>;
  39425. /**
  39426. * Gets or sets a global variable indicating if fallback texture must be used when a texture cannot be loaded
  39427. * @ignorenaming
  39428. */
  39429. static UseFallbackTexture: boolean;
  39430. /**
  39431. * Texture content used if a texture cannot loaded
  39432. * @ignorenaming
  39433. */
  39434. static FallbackTexture: string;
  39435. }
  39436. }
  39437. declare module "babylonjs/Misc/promise" {
  39438. /**
  39439. * Helper class that provides a small promise polyfill
  39440. */
  39441. export class PromisePolyfill {
  39442. /**
  39443. * Static function used to check if the polyfill is required
  39444. * If this is the case then the function will inject the polyfill to window.Promise
  39445. * @param force defines a boolean used to force the injection (mostly for testing purposes)
  39446. */
  39447. static Apply(force?: boolean): void;
  39448. }
  39449. }
  39450. declare module "babylonjs/Misc/interfaces/screenshotSize" {
  39451. /**
  39452. * Interface for screenshot methods with describe argument called `size` as object with options
  39453. * @link https://doc.babylonjs.com/api/classes/babylon.screenshottools
  39454. */
  39455. export interface IScreenshotSize {
  39456. /**
  39457. * number in pixels for canvas height
  39458. */
  39459. height?: number;
  39460. /**
  39461. * multiplier allowing render at a higher or lower resolution
  39462. * If value is defined then height and width will be ignored and taken from camera
  39463. */
  39464. precision?: number;
  39465. /**
  39466. * number in pixels for canvas width
  39467. */
  39468. width?: number;
  39469. }
  39470. }
  39471. declare module "babylonjs/Misc/tools" {
  39472. import { Nullable, float } from "babylonjs/types";
  39473. import { DomManagement } from "babylonjs/Misc/domManagement";
  39474. import { WebRequest } from "babylonjs/Misc/webRequest";
  39475. import { IFileRequest } from "babylonjs/Misc/fileRequest";
  39476. import { ReadFileError } from "babylonjs/Misc/fileTools";
  39477. import { IOfflineProvider } from "babylonjs/Offline/IOfflineProvider";
  39478. import { IScreenshotSize } from "babylonjs/Misc/interfaces/screenshotSize";
  39479. import { Camera } from "babylonjs/Cameras/camera";
  39480. import { Engine } from "babylonjs/Engines/engine";
  39481. interface IColor4Like {
  39482. r: float;
  39483. g: float;
  39484. b: float;
  39485. a: float;
  39486. }
  39487. /**
  39488. * Class containing a set of static utilities functions
  39489. */
  39490. export class Tools {
  39491. /**
  39492. * Gets or sets the base URL to use to load assets
  39493. */
  39494. static get BaseUrl(): string;
  39495. static set BaseUrl(value: string);
  39496. /**
  39497. * Enable/Disable Custom HTTP Request Headers globally.
  39498. * default = false
  39499. * @see CustomRequestHeaders
  39500. */
  39501. static UseCustomRequestHeaders: boolean;
  39502. /**
  39503. * Custom HTTP Request Headers to be sent with XMLHttpRequests
  39504. * i.e. when loading files, where the server/service expects an Authorization header
  39505. */
  39506. static CustomRequestHeaders: {
  39507. [key: string]: string;
  39508. };
  39509. /**
  39510. * Gets or sets the retry strategy to apply when an error happens while loading an asset
  39511. */
  39512. static get DefaultRetryStrategy(): (url: string, request: WebRequest, retryIndex: number) => number;
  39513. static set DefaultRetryStrategy(strategy: (url: string, request: WebRequest, retryIndex: number) => number);
  39514. /**
  39515. * Default behaviour for cors in the application.
  39516. * It can be a string if the expected behavior is identical in the entire app.
  39517. * Or a callback to be able to set it per url or on a group of them (in case of Video source for instance)
  39518. */
  39519. static get CorsBehavior(): string | ((url: string | string[]) => string);
  39520. static set CorsBehavior(value: string | ((url: string | string[]) => string));
  39521. /**
  39522. * Gets or sets a global variable indicating if fallback texture must be used when a texture cannot be loaded
  39523. * @ignorenaming
  39524. */
  39525. static get UseFallbackTexture(): boolean;
  39526. static set UseFallbackTexture(value: boolean);
  39527. /**
  39528. * Use this object to register external classes like custom textures or material
  39529. * to allow the laoders to instantiate them
  39530. */
  39531. static get RegisteredExternalClasses(): {
  39532. [key: string]: Object;
  39533. };
  39534. static set RegisteredExternalClasses(classes: {
  39535. [key: string]: Object;
  39536. });
  39537. /**
  39538. * Texture content used if a texture cannot loaded
  39539. * @ignorenaming
  39540. */
  39541. static get fallbackTexture(): string;
  39542. static set fallbackTexture(value: string);
  39543. /**
  39544. * Read the content of a byte array at a specified coordinates (taking in account wrapping)
  39545. * @param u defines the coordinate on X axis
  39546. * @param v defines the coordinate on Y axis
  39547. * @param width defines the width of the source data
  39548. * @param height defines the height of the source data
  39549. * @param pixels defines the source byte array
  39550. * @param color defines the output color
  39551. */
  39552. static FetchToRef(u: number, v: number, width: number, height: number, pixels: Uint8Array, color: IColor4Like): void;
  39553. /**
  39554. * Interpolates between a and b via alpha
  39555. * @param a The lower value (returned when alpha = 0)
  39556. * @param b The upper value (returned when alpha = 1)
  39557. * @param alpha The interpolation-factor
  39558. * @return The mixed value
  39559. */
  39560. static Mix(a: number, b: number, alpha: number): number;
  39561. /**
  39562. * Tries to instantiate a new object from a given class name
  39563. * @param className defines the class name to instantiate
  39564. * @returns the new object or null if the system was not able to do the instantiation
  39565. */
  39566. static Instantiate(className: string): any;
  39567. /**
  39568. * Provides a slice function that will work even on IE
  39569. * @param data defines the array to slice
  39570. * @param start defines the start of the data (optional)
  39571. * @param end defines the end of the data (optional)
  39572. * @returns the new sliced array
  39573. */
  39574. static Slice<T>(data: T, start?: number, end?: number): T;
  39575. /**
  39576. * Polyfill for setImmediate
  39577. * @param action defines the action to execute after the current execution block
  39578. */
  39579. static SetImmediate(action: () => void): void;
  39580. /**
  39581. * Function indicating if a number is an exponent of 2
  39582. * @param value defines the value to test
  39583. * @returns true if the value is an exponent of 2
  39584. */
  39585. static IsExponentOfTwo(value: number): boolean;
  39586. private static _tmpFloatArray;
  39587. /**
  39588. * Returns the nearest 32-bit single precision float representation of a Number
  39589. * @param value A Number. If the parameter is of a different type, it will get converted
  39590. * to a number or to NaN if it cannot be converted
  39591. * @returns number
  39592. */
  39593. static FloatRound(value: number): number;
  39594. /**
  39595. * Extracts the filename from a path
  39596. * @param path defines the path to use
  39597. * @returns the filename
  39598. */
  39599. static GetFilename(path: string): string;
  39600. /**
  39601. * Extracts the "folder" part of a path (everything before the filename).
  39602. * @param uri The URI to extract the info from
  39603. * @param returnUnchangedIfNoSlash Do not touch the URI if no slashes are present
  39604. * @returns The "folder" part of the path
  39605. */
  39606. static GetFolderPath(uri: string, returnUnchangedIfNoSlash?: boolean): string;
  39607. /**
  39608. * Extracts text content from a DOM element hierarchy
  39609. * Back Compat only, please use DomManagement.GetDOMTextContent instead.
  39610. */
  39611. static GetDOMTextContent: typeof DomManagement.GetDOMTextContent;
  39612. /**
  39613. * Convert an angle in radians to degrees
  39614. * @param angle defines the angle to convert
  39615. * @returns the angle in degrees
  39616. */
  39617. static ToDegrees(angle: number): number;
  39618. /**
  39619. * Convert an angle in degrees to radians
  39620. * @param angle defines the angle to convert
  39621. * @returns the angle in radians
  39622. */
  39623. static ToRadians(angle: number): number;
  39624. /**
  39625. * Returns an array if obj is not an array
  39626. * @param obj defines the object to evaluate as an array
  39627. * @param allowsNullUndefined defines a boolean indicating if obj is allowed to be null or undefined
  39628. * @returns either obj directly if obj is an array or a new array containing obj
  39629. */
  39630. static MakeArray(obj: any, allowsNullUndefined?: boolean): Nullable<Array<any>>;
  39631. /**
  39632. * Gets the pointer prefix to use
  39633. * @param engine defines the engine we are finding the prefix for
  39634. * @returns "pointer" if touch is enabled. Else returns "mouse"
  39635. */
  39636. static GetPointerPrefix(engine: Engine): string;
  39637. /**
  39638. * Sets the cors behavior on a dom element. This will add the required Tools.CorsBehavior to the element.
  39639. * @param url define the url we are trying
  39640. * @param element define the dom element where to configure the cors policy
  39641. */
  39642. static SetCorsBehavior(url: string | string[], element: {
  39643. crossOrigin: string | null;
  39644. }): void;
  39645. /**
  39646. * Removes unwanted characters from an url
  39647. * @param url defines the url to clean
  39648. * @returns the cleaned url
  39649. */
  39650. static CleanUrl(url: string): string;
  39651. /**
  39652. * Gets or sets a function used to pre-process url before using them to load assets
  39653. */
  39654. static get PreprocessUrl(): (url: string) => string;
  39655. static set PreprocessUrl(processor: (url: string) => string);
  39656. /**
  39657. * Loads an image as an HTMLImageElement.
  39658. * @param input url string, ArrayBuffer, or Blob to load
  39659. * @param onLoad callback called when the image successfully loads
  39660. * @param onError callback called when the image fails to load
  39661. * @param offlineProvider offline provider for caching
  39662. * @param mimeType optional mime type
  39663. * @returns the HTMLImageElement of the loaded image
  39664. */
  39665. static LoadImage(input: string | ArrayBuffer | Blob, onLoad: (img: HTMLImageElement | ImageBitmap) => void, onError: (message?: string, exception?: any) => void, offlineProvider: Nullable<IOfflineProvider>, mimeType?: string): Nullable<HTMLImageElement>;
  39666. /**
  39667. * Loads a file from a url
  39668. * @param url url string, ArrayBuffer, or Blob to load
  39669. * @param onSuccess callback called when the file successfully loads
  39670. * @param onProgress callback called while file is loading (if the server supports this mode)
  39671. * @param offlineProvider defines the offline provider for caching
  39672. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  39673. * @param onError callback called when the file fails to load
  39674. * @returns a file request object
  39675. */
  39676. 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;
  39677. /**
  39678. * Loads a file from a url
  39679. * @param url the file url to load
  39680. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  39681. * @returns a promise containing an ArrayBuffer corresponding to the loaded file
  39682. */
  39683. static LoadFileAsync(url: string, useArrayBuffer?: boolean): Promise<ArrayBuffer | string>;
  39684. /**
  39685. * Load a script (identified by an url). When the url returns, the
  39686. * content of this file is added into a new script element, attached to the DOM (body element)
  39687. * @param scriptUrl defines the url of the script to laod
  39688. * @param onSuccess defines the callback called when the script is loaded
  39689. * @param onError defines the callback to call if an error occurs
  39690. * @param scriptId defines the id of the script element
  39691. */
  39692. static LoadScript(scriptUrl: string, onSuccess: () => void, onError?: (message?: string, exception?: any) => void, scriptId?: string): void;
  39693. /**
  39694. * Load an asynchronous script (identified by an url). When the url returns, the
  39695. * content of this file is added into a new script element, attached to the DOM (body element)
  39696. * @param scriptUrl defines the url of the script to laod
  39697. * @param scriptId defines the id of the script element
  39698. * @returns a promise request object
  39699. */
  39700. static LoadScriptAsync(scriptUrl: string, scriptId?: string): Promise<void>;
  39701. /**
  39702. * Loads a file from a blob
  39703. * @param fileToLoad defines the blob to use
  39704. * @param callback defines the callback to call when data is loaded
  39705. * @param progressCallback defines the callback to call during loading process
  39706. * @returns a file request object
  39707. */
  39708. static ReadFileAsDataURL(fileToLoad: Blob, callback: (data: any) => void, progressCallback: (ev: ProgressEvent) => any): IFileRequest;
  39709. /**
  39710. * Reads a file from a File object
  39711. * @param file defines the file to load
  39712. * @param onSuccess defines the callback to call when data is loaded
  39713. * @param onProgress defines the callback to call during loading process
  39714. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  39715. * @param onError defines the callback to call when an error occurs
  39716. * @returns a file request object
  39717. */
  39718. static ReadFile(file: File, onSuccess: (data: any) => void, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: ReadFileError) => void): IFileRequest;
  39719. /**
  39720. * Creates a data url from a given string content
  39721. * @param content defines the content to convert
  39722. * @returns the new data url link
  39723. */
  39724. static FileAsURL(content: string): string;
  39725. /**
  39726. * Format the given number to a specific decimal format
  39727. * @param value defines the number to format
  39728. * @param decimals defines the number of decimals to use
  39729. * @returns the formatted string
  39730. */
  39731. static Format(value: number, decimals?: number): string;
  39732. /**
  39733. * Tries to copy an object by duplicating every property
  39734. * @param source defines the source object
  39735. * @param destination defines the target object
  39736. * @param doNotCopyList defines a list of properties to avoid
  39737. * @param mustCopyList defines a list of properties to copy (even if they start with _)
  39738. */
  39739. static DeepCopy(source: any, destination: any, doNotCopyList?: string[], mustCopyList?: string[]): void;
  39740. /**
  39741. * Gets a boolean indicating if the given object has no own property
  39742. * @param obj defines the object to test
  39743. * @returns true if object has no own property
  39744. */
  39745. static IsEmpty(obj: any): boolean;
  39746. /**
  39747. * Function used to register events at window level
  39748. * @param windowElement defines the Window object to use
  39749. * @param events defines the events to register
  39750. */
  39751. static RegisterTopRootEvents(windowElement: Window, events: {
  39752. name: string;
  39753. handler: Nullable<(e: FocusEvent) => any>;
  39754. }[]): void;
  39755. /**
  39756. * Function used to unregister events from window level
  39757. * @param windowElement defines the Window object to use
  39758. * @param events defines the events to unregister
  39759. */
  39760. static UnregisterTopRootEvents(windowElement: Window, events: {
  39761. name: string;
  39762. handler: Nullable<(e: FocusEvent) => any>;
  39763. }[]): void;
  39764. /**
  39765. * @ignore
  39766. */
  39767. static _ScreenshotCanvas: HTMLCanvasElement;
  39768. /**
  39769. * Dumps the current bound framebuffer
  39770. * @param width defines the rendering width
  39771. * @param height defines the rendering height
  39772. * @param engine defines the hosting engine
  39773. * @param successCallback defines the callback triggered once the data are available
  39774. * @param mimeType defines the mime type of the result
  39775. * @param fileName defines the filename to download. If present, the result will automatically be downloaded
  39776. */
  39777. static DumpFramebuffer(width: number, height: number, engine: Engine, successCallback?: (data: string) => void, mimeType?: string, fileName?: string): void;
  39778. /**
  39779. * Converts the canvas data to blob.
  39780. * This acts as a polyfill for browsers not supporting the to blob function.
  39781. * @param canvas Defines the canvas to extract the data from
  39782. * @param successCallback Defines the callback triggered once the data are available
  39783. * @param mimeType Defines the mime type of the result
  39784. */
  39785. static ToBlob(canvas: HTMLCanvasElement, successCallback: (blob: Nullable<Blob>) => void, mimeType?: string): void;
  39786. /**
  39787. * Encodes the canvas data to base 64 or automatically download the result if filename is defined
  39788. * @param successCallback defines the callback triggered once the data are available
  39789. * @param mimeType defines the mime type of the result
  39790. * @param fileName defines he filename to download. If present, the result will automatically be downloaded
  39791. */
  39792. static EncodeScreenshotCanvasData(successCallback?: (data: string) => void, mimeType?: string, fileName?: string): void;
  39793. /**
  39794. * Downloads a blob in the browser
  39795. * @param blob defines the blob to download
  39796. * @param fileName defines the name of the downloaded file
  39797. */
  39798. static Download(blob: Blob, fileName: string): void;
  39799. /**
  39800. * Captures a screenshot of the current rendering
  39801. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_png
  39802. * @param engine defines the rendering engine
  39803. * @param camera defines the source camera
  39804. * @param size This parameter can be set to a single number or to an object with the
  39805. * following (optional) properties: precision, width, height. If a single number is passed,
  39806. * it will be used for both width and height. If an object is passed, the screenshot size
  39807. * will be derived from the parameters. The precision property is a multiplier allowing
  39808. * rendering at a higher or lower resolution
  39809. * @param successCallback defines the callback receives a single parameter which contains the
  39810. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  39811. * src parameter of an <img> to display it
  39812. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  39813. * Check your browser for supported MIME types
  39814. */
  39815. static CreateScreenshot(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string): void;
  39816. /**
  39817. * Captures a screenshot of the current rendering
  39818. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_png
  39819. * @param engine defines the rendering engine
  39820. * @param camera defines the source camera
  39821. * @param size This parameter can be set to a single number or to an object with the
  39822. * following (optional) properties: precision, width, height. If a single number is passed,
  39823. * it will be used for both width and height. If an object is passed, the screenshot size
  39824. * will be derived from the parameters. The precision property is a multiplier allowing
  39825. * rendering at a higher or lower resolution
  39826. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  39827. * Check your browser for supported MIME types
  39828. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  39829. * to the src parameter of an <img> to display it
  39830. */
  39831. static CreateScreenshotAsync(engine: Engine, camera: Camera, size: IScreenshotSize | number, mimeType?: string): Promise<string>;
  39832. /**
  39833. * Generates an image screenshot from the specified camera.
  39834. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_png
  39835. * @param engine The engine to use for rendering
  39836. * @param camera The camera to use for rendering
  39837. * @param size This parameter can be set to a single number or to an object with the
  39838. * following (optional) properties: precision, width, height. If a single number is passed,
  39839. * it will be used for both width and height. If an object is passed, the screenshot size
  39840. * will be derived from the parameters. The precision property is a multiplier allowing
  39841. * rendering at a higher or lower resolution
  39842. * @param successCallback The callback receives a single parameter which contains the
  39843. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  39844. * src parameter of an <img> to display it
  39845. * @param mimeType The MIME type of the screenshot image (default: image/png).
  39846. * Check your browser for supported MIME types
  39847. * @param samples Texture samples (default: 1)
  39848. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  39849. * @param fileName A name for for the downloaded file.
  39850. */
  39851. static CreateScreenshotUsingRenderTarget(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): void;
  39852. /**
  39853. * Generates an image screenshot from the specified camera.
  39854. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_png
  39855. * @param engine The engine to use for rendering
  39856. * @param camera The camera to use for rendering
  39857. * @param size This parameter can be set to a single number or to an object with the
  39858. * following (optional) properties: precision, width, height. If a single number is passed,
  39859. * it will be used for both width and height. If an object is passed, the screenshot size
  39860. * will be derived from the parameters. The precision property is a multiplier allowing
  39861. * rendering at a higher or lower resolution
  39862. * @param mimeType The MIME type of the screenshot image (default: image/png).
  39863. * Check your browser for supported MIME types
  39864. * @param samples Texture samples (default: 1)
  39865. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  39866. * @param fileName A name for for the downloaded file.
  39867. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  39868. * to the src parameter of an <img> to display it
  39869. */
  39870. static CreateScreenshotUsingRenderTargetAsync(engine: Engine, camera: Camera, size: IScreenshotSize | number, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): Promise<string>;
  39871. /**
  39872. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  39873. * Be aware Math.random() could cause collisions, but:
  39874. * "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"
  39875. * @returns a pseudo random id
  39876. */
  39877. static RandomId(): string;
  39878. /**
  39879. * Test if the given uri is a base64 string
  39880. * @param uri The uri to test
  39881. * @return True if the uri is a base64 string or false otherwise
  39882. */
  39883. static IsBase64(uri: string): boolean;
  39884. /**
  39885. * Decode the given base64 uri.
  39886. * @param uri The uri to decode
  39887. * @return The decoded base64 data.
  39888. */
  39889. static DecodeBase64(uri: string): ArrayBuffer;
  39890. /**
  39891. * Gets the absolute url.
  39892. * @param url the input url
  39893. * @return the absolute url
  39894. */
  39895. static GetAbsoluteUrl(url: string): string;
  39896. /**
  39897. * No log
  39898. */
  39899. static readonly NoneLogLevel: number;
  39900. /**
  39901. * Only message logs
  39902. */
  39903. static readonly MessageLogLevel: number;
  39904. /**
  39905. * Only warning logs
  39906. */
  39907. static readonly WarningLogLevel: number;
  39908. /**
  39909. * Only error logs
  39910. */
  39911. static readonly ErrorLogLevel: number;
  39912. /**
  39913. * All logs
  39914. */
  39915. static readonly AllLogLevel: number;
  39916. /**
  39917. * Gets a value indicating the number of loading errors
  39918. * @ignorenaming
  39919. */
  39920. static get errorsCount(): number;
  39921. /**
  39922. * Callback called when a new log is added
  39923. */
  39924. static OnNewCacheEntry: (entry: string) => void;
  39925. /**
  39926. * Log a message to the console
  39927. * @param message defines the message to log
  39928. */
  39929. static Log(message: string): void;
  39930. /**
  39931. * Write a warning message to the console
  39932. * @param message defines the message to log
  39933. */
  39934. static Warn(message: string): void;
  39935. /**
  39936. * Write an error message to the console
  39937. * @param message defines the message to log
  39938. */
  39939. static Error(message: string): void;
  39940. /**
  39941. * Gets current log cache (list of logs)
  39942. */
  39943. static get LogCache(): string;
  39944. /**
  39945. * Clears the log cache
  39946. */
  39947. static ClearLogCache(): void;
  39948. /**
  39949. * Sets the current log level (MessageLogLevel / WarningLogLevel / ErrorLogLevel)
  39950. */
  39951. static set LogLevels(level: number);
  39952. /**
  39953. * Checks if the window object exists
  39954. * Back Compat only, please use DomManagement.IsWindowObjectExist instead.
  39955. */
  39956. static IsWindowObjectExist: typeof DomManagement.IsWindowObjectExist;
  39957. /**
  39958. * No performance log
  39959. */
  39960. static readonly PerformanceNoneLogLevel: number;
  39961. /**
  39962. * Use user marks to log performance
  39963. */
  39964. static readonly PerformanceUserMarkLogLevel: number;
  39965. /**
  39966. * Log performance to the console
  39967. */
  39968. static readonly PerformanceConsoleLogLevel: number;
  39969. private static _performance;
  39970. /**
  39971. * Sets the current performance log level
  39972. */
  39973. static set PerformanceLogLevel(level: number);
  39974. private static _StartPerformanceCounterDisabled;
  39975. private static _EndPerformanceCounterDisabled;
  39976. private static _StartUserMark;
  39977. private static _EndUserMark;
  39978. private static _StartPerformanceConsole;
  39979. private static _EndPerformanceConsole;
  39980. /**
  39981. * Starts a performance counter
  39982. */
  39983. static StartPerformanceCounter: (counterName: string, condition?: boolean) => void;
  39984. /**
  39985. * Ends a specific performance coutner
  39986. */
  39987. static EndPerformanceCounter: (counterName: string, condition?: boolean) => void;
  39988. /**
  39989. * Gets either window.performance.now() if supported or Date.now() else
  39990. */
  39991. static get Now(): number;
  39992. /**
  39993. * This method will return the name of the class used to create the instance of the given object.
  39994. * It will works only on Javascript basic data types (number, string, ...) and instance of class declared with the @className decorator.
  39995. * @param object the object to get the class name from
  39996. * @param isType defines if the object is actually a type
  39997. * @returns the name of the class, will be "object" for a custom data type not using the @className decorator
  39998. */
  39999. static GetClassName(object: any, isType?: boolean): string;
  40000. /**
  40001. * Gets the first element of an array satisfying a given predicate
  40002. * @param array defines the array to browse
  40003. * @param predicate defines the predicate to use
  40004. * @returns null if not found or the element
  40005. */
  40006. static First<T>(array: Array<T>, predicate: (item: T) => boolean): Nullable<T>;
  40007. /**
  40008. * This method will return the name of the full name of the class, including its owning module (if any).
  40009. * 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).
  40010. * @param object the object to get the class name from
  40011. * @param isType defines if the object is actually a type
  40012. * @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.
  40013. * @ignorenaming
  40014. */
  40015. static getFullClassName(object: any, isType?: boolean): Nullable<string>;
  40016. /**
  40017. * Returns a promise that resolves after the given amount of time.
  40018. * @param delay Number of milliseconds to delay
  40019. * @returns Promise that resolves after the given amount of time
  40020. */
  40021. static DelayAsync(delay: number): Promise<void>;
  40022. /**
  40023. * Utility function to detect if the current user agent is Safari
  40024. * @returns whether or not the current user agent is safari
  40025. */
  40026. static IsSafari(): boolean;
  40027. }
  40028. /**
  40029. * Use this className as a decorator on a given class definition to add it a name and optionally its module.
  40030. * You can then use the Tools.getClassName(obj) on an instance to retrieve its class name.
  40031. * This method is the only way to get it done in all cases, even if the .js file declaring the class is minified
  40032. * @param name The name of the class, case should be preserved
  40033. * @param module The name of the Module hosting the class, optional, but strongly recommended to specify if possible. Case should be preserved.
  40034. */
  40035. export function className(name: string, module?: string): (target: Object) => void;
  40036. /**
  40037. * An implementation of a loop for asynchronous functions.
  40038. */
  40039. export class AsyncLoop {
  40040. /**
  40041. * Defines the number of iterations for the loop
  40042. */
  40043. iterations: number;
  40044. /**
  40045. * Defines the current index of the loop.
  40046. */
  40047. index: number;
  40048. private _done;
  40049. private _fn;
  40050. private _successCallback;
  40051. /**
  40052. * Constructor.
  40053. * @param iterations the number of iterations.
  40054. * @param func the function to run each iteration
  40055. * @param successCallback the callback that will be called upon succesful execution
  40056. * @param offset starting offset.
  40057. */
  40058. constructor(
  40059. /**
  40060. * Defines the number of iterations for the loop
  40061. */
  40062. iterations: number, func: (asyncLoop: AsyncLoop) => void, successCallback: () => void, offset?: number);
  40063. /**
  40064. * Execute the next iteration. Must be called after the last iteration was finished.
  40065. */
  40066. executeNext(): void;
  40067. /**
  40068. * Break the loop and run the success callback.
  40069. */
  40070. breakLoop(): void;
  40071. /**
  40072. * Create and run an async loop.
  40073. * @param iterations the number of iterations.
  40074. * @param fn the function to run each iteration
  40075. * @param successCallback the callback that will be called upon succesful execution
  40076. * @param offset starting offset.
  40077. * @returns the created async loop object
  40078. */
  40079. static Run(iterations: number, fn: (asyncLoop: AsyncLoop) => void, successCallback: () => void, offset?: number): AsyncLoop;
  40080. /**
  40081. * A for-loop that will run a given number of iterations synchronous and the rest async.
  40082. * @param iterations total number of iterations
  40083. * @param syncedIterations number of synchronous iterations in each async iteration.
  40084. * @param fn the function to call each iteration.
  40085. * @param callback a success call back that will be called when iterating stops.
  40086. * @param breakFunction a break condition (optional)
  40087. * @param timeout timeout settings for the setTimeout function. default - 0.
  40088. * @returns the created async loop object
  40089. */
  40090. static SyncAsyncForLoop(iterations: number, syncedIterations: number, fn: (iteration: number) => void, callback: () => void, breakFunction?: () => boolean, timeout?: number): AsyncLoop;
  40091. }
  40092. }
  40093. declare module "babylonjs/Misc/stringDictionary" {
  40094. import { Nullable } from "babylonjs/types";
  40095. /**
  40096. * This class implement a typical dictionary using a string as key and the generic type T as value.
  40097. * The underlying implementation relies on an associative array to ensure the best performances.
  40098. * The value can be anything including 'null' but except 'undefined'
  40099. */
  40100. export class StringDictionary<T> {
  40101. /**
  40102. * This will clear this dictionary and copy the content from the 'source' one.
  40103. * If the T value is a custom object, it won't be copied/cloned, the same object will be used
  40104. * @param source the dictionary to take the content from and copy to this dictionary
  40105. */
  40106. copyFrom(source: StringDictionary<T>): void;
  40107. /**
  40108. * Get a value based from its key
  40109. * @param key the given key to get the matching value from
  40110. * @return the value if found, otherwise undefined is returned
  40111. */
  40112. get(key: string): T | undefined;
  40113. /**
  40114. * Get a value from its key or add it if it doesn't exist.
  40115. * This method will ensure you that a given key/data will be present in the dictionary.
  40116. * @param key the given key to get the matching value from
  40117. * @param factory the factory that will create the value if the key is not present in the dictionary.
  40118. * The factory will only be invoked if there's no data for the given key.
  40119. * @return the value corresponding to the key.
  40120. */
  40121. getOrAddWithFactory(key: string, factory: (key: string) => T): T;
  40122. /**
  40123. * Get a value from its key if present in the dictionary otherwise add it
  40124. * @param key the key to get the value from
  40125. * @param val if there's no such key/value pair in the dictionary add it with this value
  40126. * @return the value corresponding to the key
  40127. */
  40128. getOrAdd(key: string, val: T): T;
  40129. /**
  40130. * Check if there's a given key in the dictionary
  40131. * @param key the key to check for
  40132. * @return true if the key is present, false otherwise
  40133. */
  40134. contains(key: string): boolean;
  40135. /**
  40136. * Add a new key and its corresponding value
  40137. * @param key the key to add
  40138. * @param value the value corresponding to the key
  40139. * @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
  40140. */
  40141. add(key: string, value: T): boolean;
  40142. /**
  40143. * Update a specific value associated to a key
  40144. * @param key defines the key to use
  40145. * @param value defines the value to store
  40146. * @returns true if the value was updated (or false if the key was not found)
  40147. */
  40148. set(key: string, value: T): boolean;
  40149. /**
  40150. * Get the element of the given key and remove it from the dictionary
  40151. * @param key defines the key to search
  40152. * @returns the value associated with the key or null if not found
  40153. */
  40154. getAndRemove(key: string): Nullable<T>;
  40155. /**
  40156. * Remove a key/value from the dictionary.
  40157. * @param key the key to remove
  40158. * @return true if the item was successfully deleted, false if no item with such key exist in the dictionary
  40159. */
  40160. remove(key: string): boolean;
  40161. /**
  40162. * Clear the whole content of the dictionary
  40163. */
  40164. clear(): void;
  40165. /**
  40166. * Gets the current count
  40167. */
  40168. get count(): number;
  40169. /**
  40170. * Execute a callback on each key/val of the dictionary.
  40171. * Note that you can remove any element in this dictionary in the callback implementation
  40172. * @param callback the callback to execute on a given key/value pair
  40173. */
  40174. forEach(callback: (key: string, val: T) => void): void;
  40175. /**
  40176. * Execute a callback on every occurrence of the dictionary until it returns a valid TRes object.
  40177. * If the callback returns null or undefined the method will iterate to the next key/value pair
  40178. * Note that you can remove any element in this dictionary in the callback implementation
  40179. * @param callback the callback to execute, if it return a valid T instanced object the enumeration will stop and the object will be returned
  40180. * @returns the first item
  40181. */
  40182. first<TRes>(callback: (key: string, val: T) => TRes): TRes | null;
  40183. private _count;
  40184. private _data;
  40185. }
  40186. }
  40187. declare module "babylonjs/Collisions/collisionCoordinator" {
  40188. import { Nullable } from "babylonjs/types";
  40189. import { Scene } from "babylonjs/scene";
  40190. import { Vector3 } from "babylonjs/Maths/math.vector";
  40191. import { Collider } from "babylonjs/Collisions/collider";
  40192. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  40193. /** @hidden */
  40194. export interface ICollisionCoordinator {
  40195. createCollider(): Collider;
  40196. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: Nullable<AbstractMesh>, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  40197. init(scene: Scene): void;
  40198. }
  40199. /** @hidden */
  40200. export class DefaultCollisionCoordinator implements ICollisionCoordinator {
  40201. private _scene;
  40202. private _scaledPosition;
  40203. private _scaledVelocity;
  40204. private _finalPosition;
  40205. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: AbstractMesh, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  40206. createCollider(): Collider;
  40207. init(scene: Scene): void;
  40208. private _collideWithWorld;
  40209. }
  40210. }
  40211. declare module "babylonjs/Inputs/scene.inputManager" {
  40212. import { Nullable } from "babylonjs/types";
  40213. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  40214. import { Vector2 } from "babylonjs/Maths/math.vector";
  40215. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  40216. import { Scene } from "babylonjs/scene";
  40217. /**
  40218. * Class used to manage all inputs for the scene.
  40219. */
  40220. export class InputManager {
  40221. /** The distance in pixel that you have to move to prevent some events */
  40222. static DragMovementThreshold: number;
  40223. /** Time in milliseconds to wait to raise long press events if button is still pressed */
  40224. static LongPressDelay: number;
  40225. /** Time in milliseconds with two consecutive clicks will be considered as a double click */
  40226. static DoubleClickDelay: number;
  40227. /** If you need to check double click without raising a single click at first click, enable this flag */
  40228. static ExclusiveDoubleClickMode: boolean;
  40229. /** 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. */
  40230. private _alreadyAttached;
  40231. private _wheelEventName;
  40232. private _onPointerMove;
  40233. private _onPointerDown;
  40234. private _onPointerUp;
  40235. private _initClickEvent;
  40236. private _initActionManager;
  40237. private _delayedSimpleClick;
  40238. private _delayedSimpleClickTimeout;
  40239. private _previousDelayedSimpleClickTimeout;
  40240. private _meshPickProceed;
  40241. private _previousButtonPressed;
  40242. private _currentPickResult;
  40243. private _previousPickResult;
  40244. private _totalPointersPressed;
  40245. private _doubleClickOccured;
  40246. private _pointerOverMesh;
  40247. private _pickedDownMesh;
  40248. private _pickedUpMesh;
  40249. private _pointerX;
  40250. private _pointerY;
  40251. private _unTranslatedPointerX;
  40252. private _unTranslatedPointerY;
  40253. private _startingPointerPosition;
  40254. private _previousStartingPointerPosition;
  40255. private _startingPointerTime;
  40256. private _previousStartingPointerTime;
  40257. private _pointerCaptures;
  40258. private _meshUnderPointerId;
  40259. private _onKeyDown;
  40260. private _onKeyUp;
  40261. private _onCanvasFocusObserver;
  40262. private _onCanvasBlurObserver;
  40263. private _scene;
  40264. /**
  40265. * Creates a new InputManager
  40266. * @param scene defines the hosting scene
  40267. */
  40268. constructor(scene: Scene);
  40269. /**
  40270. * Gets the mesh that is currently under the pointer
  40271. */
  40272. get meshUnderPointer(): Nullable<AbstractMesh>;
  40273. /**
  40274. * When using more than one pointer (for example in XR) you can get the mesh under the specific pointer
  40275. * @param pointerId the pointer id to use
  40276. * @returns The mesh under this pointer id or null if not found
  40277. */
  40278. getMeshUnderPointerByPointerId(pointerId: number): Nullable<AbstractMesh>;
  40279. /**
  40280. * Gets the pointer coordinates in 2D without any translation (ie. straight out of the pointer event)
  40281. */
  40282. get unTranslatedPointer(): Vector2;
  40283. /**
  40284. * Gets or sets the current on-screen X position of the pointer
  40285. */
  40286. get pointerX(): number;
  40287. set pointerX(value: number);
  40288. /**
  40289. * Gets or sets the current on-screen Y position of the pointer
  40290. */
  40291. get pointerY(): number;
  40292. set pointerY(value: number);
  40293. private _updatePointerPosition;
  40294. private _processPointerMove;
  40295. private _setRayOnPointerInfo;
  40296. private _checkPrePointerObservable;
  40297. /**
  40298. * Use this method to simulate a pointer move on a mesh
  40299. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  40300. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  40301. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  40302. */
  40303. simulatePointerMove(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): void;
  40304. /**
  40305. * Use this method to simulate a pointer down 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. simulatePointerDown(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): void;
  40311. private _processPointerDown;
  40312. /** @hidden */
  40313. _isPointerSwiping(): boolean;
  40314. /**
  40315. * Use this method to simulate a pointer up on a mesh
  40316. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  40317. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  40318. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  40319. * @param doubleTap indicates that the pointer up event should be considered as part of a double click (false by default)
  40320. */
  40321. simulatePointerUp(pickResult: PickingInfo, pointerEventInit?: PointerEventInit, doubleTap?: boolean): void;
  40322. private _processPointerUp;
  40323. /**
  40324. * Gets a boolean indicating if the current pointer event is captured (meaning that the scene has already handled the pointer down)
  40325. * @param pointerId defines the pointer id to use in a multi-touch scenario (0 by default)
  40326. * @returns true if the pointer was captured
  40327. */
  40328. isPointerCaptured(pointerId?: number): boolean;
  40329. /**
  40330. * Attach events to the canvas (To handle actionManagers triggers and raise onPointerMove, onPointerDown and onPointerUp
  40331. * @param attachUp defines if you want to attach events to pointerup
  40332. * @param attachDown defines if you want to attach events to pointerdown
  40333. * @param attachMove defines if you want to attach events to pointermove
  40334. * @param elementToAttachTo defines the target DOM element to attach to (will use the canvas by default)
  40335. */
  40336. attachControl(attachUp?: boolean, attachDown?: boolean, attachMove?: boolean, elementToAttachTo?: Nullable<HTMLElement>): void;
  40337. /**
  40338. * Detaches all event handlers
  40339. */
  40340. detachControl(): void;
  40341. /**
  40342. * Force the value of meshUnderPointer
  40343. * @param mesh defines the mesh to use
  40344. * @param pointerId optional pointer id when using more than one pointer. Defaults to 0
  40345. */
  40346. setPointerOverMesh(mesh: Nullable<AbstractMesh>, pointerId?: number): void;
  40347. /**
  40348. * Gets the mesh under the pointer
  40349. * @returns a Mesh or null if no mesh is under the pointer
  40350. */
  40351. getPointerOverMesh(): Nullable<AbstractMesh>;
  40352. }
  40353. }
  40354. declare module "babylonjs/Animations/animationGroup" {
  40355. import { Animatable } from "babylonjs/Animations/animatable";
  40356. import { Animation } from "babylonjs/Animations/animation";
  40357. import { Scene, IDisposable } from "babylonjs/scene";
  40358. import { Observable } from "babylonjs/Misc/observable";
  40359. import { Nullable } from "babylonjs/types";
  40360. import "babylonjs/Animations/animatable";
  40361. /**
  40362. * This class defines the direct association between an animation and a target
  40363. */
  40364. export class TargetedAnimation {
  40365. /**
  40366. * Animation to perform
  40367. */
  40368. animation: Animation;
  40369. /**
  40370. * Target to animate
  40371. */
  40372. target: any;
  40373. /**
  40374. * Returns the string "TargetedAnimation"
  40375. * @returns "TargetedAnimation"
  40376. */
  40377. getClassName(): string;
  40378. /**
  40379. * Serialize the object
  40380. * @returns the JSON object representing the current entity
  40381. */
  40382. serialize(): any;
  40383. }
  40384. /**
  40385. * Use this class to create coordinated animations on multiple targets
  40386. */
  40387. export class AnimationGroup implements IDisposable {
  40388. /** The name of the animation group */
  40389. name: string;
  40390. private _scene;
  40391. private _targetedAnimations;
  40392. private _animatables;
  40393. private _from;
  40394. private _to;
  40395. private _isStarted;
  40396. private _isPaused;
  40397. private _speedRatio;
  40398. private _loopAnimation;
  40399. private _isAdditive;
  40400. /**
  40401. * Gets or sets the unique id of the node
  40402. */
  40403. uniqueId: number;
  40404. /**
  40405. * This observable will notify when one animation have ended
  40406. */
  40407. onAnimationEndObservable: Observable<TargetedAnimation>;
  40408. /**
  40409. * Observer raised when one animation loops
  40410. */
  40411. onAnimationLoopObservable: Observable<TargetedAnimation>;
  40412. /**
  40413. * Observer raised when all animations have looped
  40414. */
  40415. onAnimationGroupLoopObservable: Observable<AnimationGroup>;
  40416. /**
  40417. * This observable will notify when all animations have ended.
  40418. */
  40419. onAnimationGroupEndObservable: Observable<AnimationGroup>;
  40420. /**
  40421. * This observable will notify when all animations have paused.
  40422. */
  40423. onAnimationGroupPauseObservable: Observable<AnimationGroup>;
  40424. /**
  40425. * This observable will notify when all animations are playing.
  40426. */
  40427. onAnimationGroupPlayObservable: Observable<AnimationGroup>;
  40428. /**
  40429. * Gets the first frame
  40430. */
  40431. get from(): number;
  40432. /**
  40433. * Gets the last frame
  40434. */
  40435. get to(): number;
  40436. /**
  40437. * Define if the animations are started
  40438. */
  40439. get isStarted(): boolean;
  40440. /**
  40441. * Gets a value indicating that the current group is playing
  40442. */
  40443. get isPlaying(): boolean;
  40444. /**
  40445. * Gets or sets the speed ratio to use for all animations
  40446. */
  40447. get speedRatio(): number;
  40448. /**
  40449. * Gets or sets the speed ratio to use for all animations
  40450. */
  40451. set speedRatio(value: number);
  40452. /**
  40453. * Gets or sets if all animations should loop or not
  40454. */
  40455. get loopAnimation(): boolean;
  40456. set loopAnimation(value: boolean);
  40457. /**
  40458. * Gets or sets if all animations should be evaluated additively
  40459. */
  40460. get isAdditive(): boolean;
  40461. set isAdditive(value: boolean);
  40462. /**
  40463. * Gets the targeted animations for this animation group
  40464. */
  40465. get targetedAnimations(): Array<TargetedAnimation>;
  40466. /**
  40467. * returning the list of animatables controlled by this animation group.
  40468. */
  40469. get animatables(): Array<Animatable>;
  40470. /**
  40471. * Gets the list of target animations
  40472. */
  40473. get children(): TargetedAnimation[];
  40474. /**
  40475. * Instantiates a new Animation Group.
  40476. * This helps managing several animations at once.
  40477. * @see https://doc.babylonjs.com/how_to/group
  40478. * @param name Defines the name of the group
  40479. * @param scene Defines the scene the group belongs to
  40480. */
  40481. constructor(
  40482. /** The name of the animation group */
  40483. name: string, scene?: Nullable<Scene>);
  40484. /**
  40485. * Add an animation (with its target) in the group
  40486. * @param animation defines the animation we want to add
  40487. * @param target defines the target of the animation
  40488. * @returns the TargetedAnimation object
  40489. */
  40490. addTargetedAnimation(animation: Animation, target: any): TargetedAnimation;
  40491. /**
  40492. * This function will normalize every animation in the group to make sure they all go from beginFrame to endFrame
  40493. * It can add constant keys at begin or end
  40494. * @param beginFrame defines the new begin frame for all animations or the smallest begin frame of all animations if null (defaults to null)
  40495. * @param endFrame defines the new end frame for all animations or the largest end frame of all animations if null (defaults to null)
  40496. * @returns the animation group
  40497. */
  40498. normalize(beginFrame?: Nullable<number>, endFrame?: Nullable<number>): AnimationGroup;
  40499. private _animationLoopCount;
  40500. private _animationLoopFlags;
  40501. private _processLoop;
  40502. /**
  40503. * Start all animations on given targets
  40504. * @param loop defines if animations must loop
  40505. * @param speedRatio defines the ratio to apply to animation speed (1 by default)
  40506. * @param from defines the from key (optional)
  40507. * @param to defines the to key (optional)
  40508. * @param isAdditive defines the additive state for the resulting animatables (optional)
  40509. * @returns the current animation group
  40510. */
  40511. start(loop?: boolean, speedRatio?: number, from?: number, to?: number, isAdditive?: boolean): AnimationGroup;
  40512. /**
  40513. * Pause all animations
  40514. * @returns the animation group
  40515. */
  40516. pause(): AnimationGroup;
  40517. /**
  40518. * Play all animations to initial state
  40519. * This function will start() the animations if they were not started or will restart() them if they were paused
  40520. * @param loop defines if animations must loop
  40521. * @returns the animation group
  40522. */
  40523. play(loop?: boolean): AnimationGroup;
  40524. /**
  40525. * Reset all animations to initial state
  40526. * @returns the animation group
  40527. */
  40528. reset(): AnimationGroup;
  40529. /**
  40530. * Restart animations from key 0
  40531. * @returns the animation group
  40532. */
  40533. restart(): AnimationGroup;
  40534. /**
  40535. * Stop all animations
  40536. * @returns the animation group
  40537. */
  40538. stop(): AnimationGroup;
  40539. /**
  40540. * Set animation weight for all animatables
  40541. * @param weight defines the weight to use
  40542. * @return the animationGroup
  40543. * @see https://doc.babylonjs.com/babylon101/animations#animation-weights
  40544. */
  40545. setWeightForAllAnimatables(weight: number): AnimationGroup;
  40546. /**
  40547. * Synchronize and normalize all animatables with a source animatable
  40548. * @param root defines the root animatable to synchronize with
  40549. * @return the animationGroup
  40550. * @see https://doc.babylonjs.com/babylon101/animations#animation-weights
  40551. */
  40552. syncAllAnimationsWith(root: Animatable): AnimationGroup;
  40553. /**
  40554. * Goes to a specific frame in this animation group
  40555. * @param frame the frame number to go to
  40556. * @return the animationGroup
  40557. */
  40558. goToFrame(frame: number): AnimationGroup;
  40559. /**
  40560. * Dispose all associated resources
  40561. */
  40562. dispose(): void;
  40563. private _checkAnimationGroupEnded;
  40564. /**
  40565. * Clone the current animation group and returns a copy
  40566. * @param newName defines the name of the new group
  40567. * @param targetConverter defines an optional function used to convert current animation targets to new ones
  40568. * @returns the new aniamtion group
  40569. */
  40570. clone(newName: string, targetConverter?: (oldTarget: any) => any): AnimationGroup;
  40571. /**
  40572. * Serializes the animationGroup to an object
  40573. * @returns Serialized object
  40574. */
  40575. serialize(): any;
  40576. /**
  40577. * Returns a new AnimationGroup object parsed from the source provided.
  40578. * @param parsedAnimationGroup defines the source
  40579. * @param scene defines the scene that will receive the animationGroup
  40580. * @returns a new AnimationGroup
  40581. */
  40582. static Parse(parsedAnimationGroup: any, scene: Scene): AnimationGroup;
  40583. /**
  40584. * Convert the keyframes for all animations belonging to the group to be relative to a given reference frame.
  40585. * @param sourceAnimationGroup defines the AnimationGroup containing animations to convert
  40586. * @param referenceFrame defines the frame that keyframes in the range will be relative to
  40587. * @param range defines the name of the AnimationRange belonging to the animations in the group to convert
  40588. * @param cloneOriginal defines whether or not to clone the group and convert the clone or convert the original group (default is false)
  40589. * @param clonedName defines the name of the resulting cloned AnimationGroup if cloneOriginal is true
  40590. * @returns a new AnimationGroup if cloneOriginal is true or the original AnimationGroup if cloneOriginal is false
  40591. */
  40592. static MakeAnimationAdditive(sourceAnimationGroup: AnimationGroup, referenceFrame?: number, range?: string, cloneOriginal?: boolean, clonedName?: string): AnimationGroup;
  40593. /**
  40594. * Returns the string "AnimationGroup"
  40595. * @returns "AnimationGroup"
  40596. */
  40597. getClassName(): string;
  40598. /**
  40599. * Creates a detailled string about the object
  40600. * @param fullDetails defines if the output string will support multiple levels of logging within scene loading
  40601. * @returns a string representing the object
  40602. */
  40603. toString(fullDetails?: boolean): string;
  40604. }
  40605. }
  40606. declare module "babylonjs/scene" {
  40607. import { Nullable } from "babylonjs/types";
  40608. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  40609. import { Observable } from "babylonjs/Misc/observable";
  40610. import { SmartArrayNoDuplicate, SmartArray, ISmartArrayLike } from "babylonjs/Misc/smartArray";
  40611. import { Vector2, Vector3, Matrix } from "babylonjs/Maths/math.vector";
  40612. import { Geometry } from "babylonjs/Meshes/geometry";
  40613. import { TransformNode } from "babylonjs/Meshes/transformNode";
  40614. import { SubMesh } from "babylonjs/Meshes/subMesh";
  40615. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  40616. import { Mesh } from "babylonjs/Meshes/mesh";
  40617. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  40618. import { Bone } from "babylonjs/Bones/bone";
  40619. import { Skeleton } from "babylonjs/Bones/skeleton";
  40620. import { MorphTargetManager } from "babylonjs/Morph/morphTargetManager";
  40621. import { Camera } from "babylonjs/Cameras/camera";
  40622. import { AbstractScene } from "babylonjs/abstractScene";
  40623. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  40624. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  40625. import { Material } from "babylonjs/Materials/material";
  40626. import { ImageProcessingConfiguration } from "babylonjs/Materials/imageProcessingConfiguration";
  40627. import { Effect } from "babylonjs/Materials/effect";
  40628. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  40629. import { MultiMaterial } from "babylonjs/Materials/multiMaterial";
  40630. import { Light } from "babylonjs/Lights/light";
  40631. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  40632. import { ICollisionCoordinator } from "babylonjs/Collisions/collisionCoordinator";
  40633. import { PointerEventTypes, PointerInfoPre, PointerInfo } from "babylonjs/Events/pointerEvents";
  40634. import { KeyboardInfoPre, KeyboardInfo } from "babylonjs/Events/keyboardEvents";
  40635. import { PostProcessManager } from "babylonjs/PostProcesses/postProcessManager";
  40636. import { IOfflineProvider } from "babylonjs/Offline/IOfflineProvider";
  40637. import { RenderingGroupInfo, IRenderingManagerAutoClearSetup } from "babylonjs/Rendering/renderingManager";
  40638. import { ISceneComponent, ISceneSerializableComponent, Stage, SimpleStageAction, RenderTargetsStageAction, RenderTargetStageAction, MeshStageAction, EvaluateSubMeshStageAction, ActiveMeshStageAction, CameraStageAction, RenderingGroupStageAction, RenderingMeshStageAction, PointerMoveStageAction, PointerUpDownStageAction, CameraStageFrameBufferAction } from "babylonjs/sceneComponent";
  40639. import { Engine } from "babylonjs/Engines/engine";
  40640. import { Node } from "babylonjs/node";
  40641. import { MorphTarget } from "babylonjs/Morph/morphTarget";
  40642. import { AbstractActionManager } from "babylonjs/Actions/abstractActionManager";
  40643. import { WebRequest } from "babylonjs/Misc/webRequest";
  40644. import { InputManager } from "babylonjs/Inputs/scene.inputManager";
  40645. import { PerfCounter } from "babylonjs/Misc/perfCounter";
  40646. import { IFileRequest } from "babylonjs/Misc/fileRequest";
  40647. import { Color4, Color3 } from "babylonjs/Maths/math.color";
  40648. import { Plane } from "babylonjs/Maths/math.plane";
  40649. import { LoadFileError, RequestFileError, ReadFileError } from "babylonjs/Misc/fileTools";
  40650. import { IClipPlanesHolder } from "babylonjs/Misc/interfaces/iClipPlanesHolder";
  40651. import { Ray } from "babylonjs/Culling/ray";
  40652. import { TrianglePickingPredicate } from "babylonjs/Culling/ray";
  40653. import { Animation } from "babylonjs/Animations/animation";
  40654. import { Animatable } from "babylonjs/Animations/animatable";
  40655. import { AnimationGroup } from "babylonjs/Animations/animationGroup";
  40656. import { AnimationPropertiesOverride } from "babylonjs/Animations/animationPropertiesOverride";
  40657. import { Collider } from "babylonjs/Collisions/collider";
  40658. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  40659. /**
  40660. * Define an interface for all classes that will hold resources
  40661. */
  40662. export interface IDisposable {
  40663. /**
  40664. * Releases all held resources
  40665. */
  40666. dispose(): void;
  40667. }
  40668. /** Interface defining initialization parameters for Scene class */
  40669. export interface SceneOptions {
  40670. /**
  40671. * Defines that scene should keep up-to-date a map of geometry to enable fast look-up by uniqueId
  40672. * It will improve performance when the number of geometries becomes important.
  40673. */
  40674. useGeometryUniqueIdsMap?: boolean;
  40675. /**
  40676. * Defines that each material of the scene should keep up-to-date a map of referencing meshes for fast diposing
  40677. * It will improve performance when the number of mesh becomes important, but might consume a bit more memory
  40678. */
  40679. useMaterialMeshMap?: boolean;
  40680. /**
  40681. * Defines that each mesh of the scene should keep up-to-date a map of referencing cloned meshes for fast diposing
  40682. * It will improve performance when the number of mesh becomes important, but might consume a bit more memory
  40683. */
  40684. useClonedMeshMap?: boolean;
  40685. /** Defines if the creation of the scene should impact the engine (Eg. UtilityLayer's scene) */
  40686. virtual?: boolean;
  40687. }
  40688. /**
  40689. * Represents a scene to be rendered by the engine.
  40690. * @see https://doc.babylonjs.com/features/scene
  40691. */
  40692. export class Scene extends AbstractScene implements IAnimatable, IClipPlanesHolder {
  40693. /** The fog is deactivated */
  40694. static readonly FOGMODE_NONE: number;
  40695. /** The fog density is following an exponential function */
  40696. static readonly FOGMODE_EXP: number;
  40697. /** The fog density is following an exponential function faster than FOGMODE_EXP */
  40698. static readonly FOGMODE_EXP2: number;
  40699. /** The fog density is following a linear function. */
  40700. static readonly FOGMODE_LINEAR: number;
  40701. /**
  40702. * Gets or sets the minimum deltatime when deterministic lock step is enabled
  40703. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  40704. */
  40705. static MinDeltaTime: number;
  40706. /**
  40707. * Gets or sets the maximum deltatime when deterministic lock step is enabled
  40708. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  40709. */
  40710. static MaxDeltaTime: number;
  40711. /**
  40712. * Factory used to create the default material.
  40713. * @param name The name of the material to create
  40714. * @param scene The scene to create the material for
  40715. * @returns The default material
  40716. */
  40717. static DefaultMaterialFactory(scene: Scene): Material;
  40718. /**
  40719. * Factory used to create the a collision coordinator.
  40720. * @returns The collision coordinator
  40721. */
  40722. static CollisionCoordinatorFactory(): ICollisionCoordinator;
  40723. /** @hidden */
  40724. _inputManager: InputManager;
  40725. /** Define this parameter if you are using multiple cameras and you want to specify which one should be used for pointer position */
  40726. cameraToUseForPointers: Nullable<Camera>;
  40727. /** @hidden */
  40728. readonly _isScene: boolean;
  40729. /** @hidden */
  40730. _blockEntityCollection: boolean;
  40731. /**
  40732. * Gets or sets a boolean that indicates if the scene must clear the render buffer before rendering a frame
  40733. */
  40734. autoClear: boolean;
  40735. /**
  40736. * Gets or sets a boolean that indicates if the scene must clear the depth and stencil buffers before rendering a frame
  40737. */
  40738. autoClearDepthAndStencil: boolean;
  40739. /**
  40740. * Defines the color used to clear the render buffer (Default is (0.2, 0.2, 0.3, 1.0))
  40741. */
  40742. clearColor: Color4;
  40743. /**
  40744. * Defines the color used to simulate the ambient color (Default is (0, 0, 0))
  40745. */
  40746. ambientColor: Color3;
  40747. /**
  40748. * This is use to store the default BRDF lookup for PBR materials in your scene.
  40749. * It should only be one of the following (if not the default embedded one):
  40750. * * For uncorrelated BRDF (pbr.brdf.useEnergyConservation = false and pbr.brdf.useSmithVisibilityHeightCorrelated = false) : https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds
  40751. * * For correlated BRDF (pbr.brdf.useEnergyConservation = false and pbr.brdf.useSmithVisibilityHeightCorrelated = true) : https://assets.babylonjs.com/environments/correlatedBRDF.dds
  40752. * * For correlated multi scattering BRDF (pbr.brdf.useEnergyConservation = true and pbr.brdf.useSmithVisibilityHeightCorrelated = true) : https://assets.babylonjs.com/environments/correlatedMSBRDF.dds
  40753. * The material properties need to be setup according to the type of texture in use.
  40754. */
  40755. environmentBRDFTexture: BaseTexture;
  40756. /**
  40757. * Texture used in all pbr material as the reflection texture.
  40758. * As in the majority of the scene they are the same (exception for multi room and so on),
  40759. * this is easier to reference from here than from all the materials.
  40760. */
  40761. get environmentTexture(): Nullable<BaseTexture>;
  40762. /**
  40763. * Texture used in all pbr material as the reflection texture.
  40764. * As in the majority of the scene they are the same (exception for multi room and so on),
  40765. * this is easier to set here than in all the materials.
  40766. */
  40767. set environmentTexture(value: Nullable<BaseTexture>);
  40768. /** @hidden */
  40769. protected _environmentIntensity: number;
  40770. /**
  40771. * Intensity of the environment in all pbr material.
  40772. * This dims or reinforces the IBL lighting overall (reflection and diffuse).
  40773. * As in the majority of the scene they are the same (exception for multi room and so on),
  40774. * this is easier to reference from here than from all the materials.
  40775. */
  40776. get 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 set here than in all the materials.
  40782. */
  40783. set environmentIntensity(value: number);
  40784. /** @hidden */
  40785. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  40786. /**
  40787. * Default image processing configuration used either in the rendering
  40788. * Forward main pass or through the imageProcessingPostProcess if present.
  40789. * As in the majority of the scene they are the same (exception for multi camera),
  40790. * this is easier to reference from here than from all the materials and post process.
  40791. *
  40792. * No setter as we it is a shared configuration, you can set the values instead.
  40793. */
  40794. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  40795. private _forceWireframe;
  40796. /**
  40797. * Gets or sets a boolean indicating if all rendering must be done in wireframe
  40798. */
  40799. set forceWireframe(value: boolean);
  40800. get forceWireframe(): boolean;
  40801. private _skipFrustumClipping;
  40802. /**
  40803. * Gets or sets a boolean indicating if we should skip the frustum clipping part of the active meshes selection
  40804. */
  40805. set skipFrustumClipping(value: boolean);
  40806. get skipFrustumClipping(): boolean;
  40807. private _forcePointsCloud;
  40808. /**
  40809. * Gets or sets a boolean indicating if all rendering must be done in point cloud
  40810. */
  40811. set forcePointsCloud(value: boolean);
  40812. get forcePointsCloud(): boolean;
  40813. /**
  40814. * Gets or sets the active clipplane 1
  40815. */
  40816. clipPlane: Nullable<Plane>;
  40817. /**
  40818. * Gets or sets the active clipplane 2
  40819. */
  40820. clipPlane2: Nullable<Plane>;
  40821. /**
  40822. * Gets or sets the active clipplane 3
  40823. */
  40824. clipPlane3: Nullable<Plane>;
  40825. /**
  40826. * Gets or sets the active clipplane 4
  40827. */
  40828. clipPlane4: Nullable<Plane>;
  40829. /**
  40830. * Gets or sets the active clipplane 5
  40831. */
  40832. clipPlane5: Nullable<Plane>;
  40833. /**
  40834. * Gets or sets the active clipplane 6
  40835. */
  40836. clipPlane6: Nullable<Plane>;
  40837. /**
  40838. * Gets or sets a boolean indicating if animations are enabled
  40839. */
  40840. animationsEnabled: boolean;
  40841. private _animationPropertiesOverride;
  40842. /**
  40843. * Gets or sets the animation properties override
  40844. */
  40845. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  40846. set animationPropertiesOverride(value: Nullable<AnimationPropertiesOverride>);
  40847. /**
  40848. * Gets or sets a boolean indicating if a constant deltatime has to be used
  40849. * This is mostly useful for testing purposes when you do not want the animations to scale with the framerate
  40850. */
  40851. useConstantAnimationDeltaTime: boolean;
  40852. /**
  40853. * Gets or sets a boolean indicating if the scene must keep the meshUnderPointer property updated
  40854. * Please note that it requires to run a ray cast through the scene on every frame
  40855. */
  40856. constantlyUpdateMeshUnderPointer: boolean;
  40857. /**
  40858. * Defines the HTML cursor to use when hovering over interactive elements
  40859. */
  40860. hoverCursor: string;
  40861. /**
  40862. * Defines the HTML default cursor to use (empty by default)
  40863. */
  40864. defaultCursor: string;
  40865. /**
  40866. * Defines whether cursors are handled by the scene.
  40867. */
  40868. doNotHandleCursors: boolean;
  40869. /**
  40870. * This is used to call preventDefault() on pointer down
  40871. * in order to block unwanted artifacts like system double clicks
  40872. */
  40873. preventDefaultOnPointerDown: boolean;
  40874. /**
  40875. * This is used to call preventDefault() on pointer up
  40876. * in order to block unwanted artifacts like system double clicks
  40877. */
  40878. preventDefaultOnPointerUp: boolean;
  40879. /**
  40880. * Gets or sets user defined metadata
  40881. */
  40882. metadata: any;
  40883. /**
  40884. * For internal use only. Please do not use.
  40885. */
  40886. reservedDataStore: any;
  40887. /**
  40888. * Gets the name of the plugin used to load this scene (null by default)
  40889. */
  40890. loadingPluginName: string;
  40891. /**
  40892. * Use this array to add regular expressions used to disable offline support for specific urls
  40893. */
  40894. disableOfflineSupportExceptionRules: RegExp[];
  40895. /**
  40896. * An event triggered when the scene is disposed.
  40897. */
  40898. onDisposeObservable: Observable<Scene>;
  40899. private _onDisposeObserver;
  40900. /** Sets a function to be executed when this scene is disposed. */
  40901. set onDispose(callback: () => void);
  40902. /**
  40903. * An event triggered before rendering the scene (right after animations and physics)
  40904. */
  40905. onBeforeRenderObservable: Observable<Scene>;
  40906. private _onBeforeRenderObserver;
  40907. /** Sets a function to be executed before rendering this scene */
  40908. set beforeRender(callback: Nullable<() => void>);
  40909. /**
  40910. * An event triggered after rendering the scene
  40911. */
  40912. onAfterRenderObservable: Observable<Scene>;
  40913. /**
  40914. * An event triggered after rendering the scene for an active camera (When scene.render is called this will be called after each camera)
  40915. */
  40916. onAfterRenderCameraObservable: Observable<Camera>;
  40917. private _onAfterRenderObserver;
  40918. /** Sets a function to be executed after rendering this scene */
  40919. set afterRender(callback: Nullable<() => void>);
  40920. /**
  40921. * An event triggered before animating the scene
  40922. */
  40923. onBeforeAnimationsObservable: Observable<Scene>;
  40924. /**
  40925. * An event triggered after animations processing
  40926. */
  40927. onAfterAnimationsObservable: Observable<Scene>;
  40928. /**
  40929. * An event triggered before draw calls are ready to be sent
  40930. */
  40931. onBeforeDrawPhaseObservable: Observable<Scene>;
  40932. /**
  40933. * An event triggered after draw calls have been sent
  40934. */
  40935. onAfterDrawPhaseObservable: Observable<Scene>;
  40936. /**
  40937. * An event triggered when the scene is ready
  40938. */
  40939. onReadyObservable: Observable<Scene>;
  40940. /**
  40941. * An event triggered before rendering a camera
  40942. */
  40943. onBeforeCameraRenderObservable: Observable<Camera>;
  40944. private _onBeforeCameraRenderObserver;
  40945. /** Sets a function to be executed before rendering a camera*/
  40946. set beforeCameraRender(callback: () => void);
  40947. /**
  40948. * An event triggered after rendering a camera
  40949. */
  40950. onAfterCameraRenderObservable: Observable<Camera>;
  40951. private _onAfterCameraRenderObserver;
  40952. /** Sets a function to be executed after rendering a camera*/
  40953. set afterCameraRender(callback: () => void);
  40954. /**
  40955. * An event triggered when active meshes evaluation is about to start
  40956. */
  40957. onBeforeActiveMeshesEvaluationObservable: Observable<Scene>;
  40958. /**
  40959. * An event triggered when active meshes evaluation is done
  40960. */
  40961. onAfterActiveMeshesEvaluationObservable: Observable<Scene>;
  40962. /**
  40963. * An event triggered when particles rendering is about to start
  40964. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  40965. */
  40966. onBeforeParticlesRenderingObservable: Observable<Scene>;
  40967. /**
  40968. * An event triggered when particles rendering is done
  40969. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  40970. */
  40971. onAfterParticlesRenderingObservable: Observable<Scene>;
  40972. /**
  40973. * An event triggered when SceneLoader.Append or SceneLoader.Load or SceneLoader.ImportMesh were successfully executed
  40974. */
  40975. onDataLoadedObservable: Observable<Scene>;
  40976. /**
  40977. * An event triggered when a camera is created
  40978. */
  40979. onNewCameraAddedObservable: Observable<Camera>;
  40980. /**
  40981. * An event triggered when a camera is removed
  40982. */
  40983. onCameraRemovedObservable: Observable<Camera>;
  40984. /**
  40985. * An event triggered when a light is created
  40986. */
  40987. onNewLightAddedObservable: Observable<Light>;
  40988. /**
  40989. * An event triggered when a light is removed
  40990. */
  40991. onLightRemovedObservable: Observable<Light>;
  40992. /**
  40993. * An event triggered when a geometry is created
  40994. */
  40995. onNewGeometryAddedObservable: Observable<Geometry>;
  40996. /**
  40997. * An event triggered when a geometry is removed
  40998. */
  40999. onGeometryRemovedObservable: Observable<Geometry>;
  41000. /**
  41001. * An event triggered when a transform node is created
  41002. */
  41003. onNewTransformNodeAddedObservable: Observable<TransformNode>;
  41004. /**
  41005. * An event triggered when a transform node is removed
  41006. */
  41007. onTransformNodeRemovedObservable: Observable<TransformNode>;
  41008. /**
  41009. * An event triggered when a mesh is created
  41010. */
  41011. onNewMeshAddedObservable: Observable<AbstractMesh>;
  41012. /**
  41013. * An event triggered when a mesh is removed
  41014. */
  41015. onMeshRemovedObservable: Observable<AbstractMesh>;
  41016. /**
  41017. * An event triggered when a skeleton is created
  41018. */
  41019. onNewSkeletonAddedObservable: Observable<Skeleton>;
  41020. /**
  41021. * An event triggered when a skeleton is removed
  41022. */
  41023. onSkeletonRemovedObservable: Observable<Skeleton>;
  41024. /**
  41025. * An event triggered when a material is created
  41026. */
  41027. onNewMaterialAddedObservable: Observable<Material>;
  41028. /**
  41029. * An event triggered when a material is removed
  41030. */
  41031. onMaterialRemovedObservable: Observable<Material>;
  41032. /**
  41033. * An event triggered when a texture is created
  41034. */
  41035. onNewTextureAddedObservable: Observable<BaseTexture>;
  41036. /**
  41037. * An event triggered when a texture is removed
  41038. */
  41039. onTextureRemovedObservable: Observable<BaseTexture>;
  41040. /**
  41041. * An event triggered when render targets are about to be rendered
  41042. * Can happen multiple times per frame.
  41043. */
  41044. onBeforeRenderTargetsRenderObservable: Observable<Scene>;
  41045. /**
  41046. * An event triggered when render targets were rendered.
  41047. * Can happen multiple times per frame.
  41048. */
  41049. onAfterRenderTargetsRenderObservable: Observable<Scene>;
  41050. /**
  41051. * An event triggered before calculating deterministic simulation step
  41052. */
  41053. onBeforeStepObservable: Observable<Scene>;
  41054. /**
  41055. * An event triggered after calculating deterministic simulation step
  41056. */
  41057. onAfterStepObservable: Observable<Scene>;
  41058. /**
  41059. * An event triggered when the activeCamera property is updated
  41060. */
  41061. onActiveCameraChanged: Observable<Scene>;
  41062. /**
  41063. * This Observable will be triggered before rendering each renderingGroup of each rendered camera.
  41064. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  41065. * 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)
  41066. */
  41067. onBeforeRenderingGroupObservable: Observable<RenderingGroupInfo>;
  41068. /**
  41069. * This Observable will be triggered after rendering each renderingGroup of each rendered camera.
  41070. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  41071. * 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)
  41072. */
  41073. onAfterRenderingGroupObservable: Observable<RenderingGroupInfo>;
  41074. /**
  41075. * This Observable will when a mesh has been imported into the scene.
  41076. */
  41077. onMeshImportedObservable: Observable<AbstractMesh>;
  41078. /**
  41079. * This Observable will when an animation file has been imported into the scene.
  41080. */
  41081. onAnimationFileImportedObservable: Observable<Scene>;
  41082. /**
  41083. * Gets or sets a user defined funtion to select LOD from a mesh and a camera.
  41084. * By default this function is undefined and Babylon.js will select LOD based on distance to camera
  41085. */
  41086. customLODSelector: (mesh: AbstractMesh, camera: Camera) => Nullable<AbstractMesh>;
  41087. /** @hidden */
  41088. _registeredForLateAnimationBindings: SmartArrayNoDuplicate<any>;
  41089. /**
  41090. * Gets or sets a predicate used to select candidate meshes for a pointer down event
  41091. */
  41092. pointerDownPredicate: (Mesh: AbstractMesh) => boolean;
  41093. /**
  41094. * Gets or sets a predicate used to select candidate meshes for a pointer up event
  41095. */
  41096. pointerUpPredicate: (Mesh: AbstractMesh) => boolean;
  41097. /**
  41098. * Gets or sets a predicate used to select candidate meshes for a pointer move event
  41099. */
  41100. pointerMovePredicate: (Mesh: AbstractMesh) => boolean;
  41101. /** Callback called when a pointer move is detected */
  41102. onPointerMove: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  41103. /** Callback called when a pointer down is detected */
  41104. onPointerDown: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  41105. /** Callback called when a pointer up is detected */
  41106. onPointerUp: (evt: PointerEvent, pickInfo: Nullable<PickingInfo>, type: PointerEventTypes) => void;
  41107. /** Callback called when a pointer pick is detected */
  41108. onPointerPick: (evt: PointerEvent, pickInfo: PickingInfo) => void;
  41109. /**
  41110. * 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).
  41111. * You have the possibility to skip the process and the call to onPointerObservable by setting PointerInfoPre.skipOnPointerObservable to true
  41112. */
  41113. onPrePointerObservable: Observable<PointerInfoPre>;
  41114. /**
  41115. * Observable event triggered each time an input event is received from the rendering canvas
  41116. */
  41117. onPointerObservable: Observable<PointerInfo>;
  41118. /**
  41119. * Gets the pointer coordinates without any translation (ie. straight out of the pointer event)
  41120. */
  41121. get unTranslatedPointer(): Vector2;
  41122. /**
  41123. * Gets or sets the distance in pixel that you have to move to prevent some events. Default is 10 pixels
  41124. */
  41125. static get DragMovementThreshold(): number;
  41126. static set DragMovementThreshold(value: number);
  41127. /**
  41128. * Time in milliseconds to wait to raise long press events if button is still pressed. Default is 500 ms
  41129. */
  41130. static get LongPressDelay(): number;
  41131. static set LongPressDelay(value: number);
  41132. /**
  41133. * Time in milliseconds to wait to raise long press events if button is still pressed. Default is 300 ms
  41134. */
  41135. static get DoubleClickDelay(): number;
  41136. static set DoubleClickDelay(value: number);
  41137. /** If you need to check double click without raising a single click at first click, enable this flag */
  41138. static get ExclusiveDoubleClickMode(): boolean;
  41139. static set ExclusiveDoubleClickMode(value: boolean);
  41140. /** @hidden */
  41141. _mirroredCameraPosition: Nullable<Vector3>;
  41142. /**
  41143. * This observable event is triggered when any keyboard event si raised and registered during Scene.attachControl()
  41144. * You have the possibility to skip the process and the call to onKeyboardObservable by setting KeyboardInfoPre.skipOnPointerObservable to true
  41145. */
  41146. onPreKeyboardObservable: Observable<KeyboardInfoPre>;
  41147. /**
  41148. * Observable event triggered each time an keyboard event is received from the hosting window
  41149. */
  41150. onKeyboardObservable: Observable<KeyboardInfo>;
  41151. private _useRightHandedSystem;
  41152. /**
  41153. * Gets or sets a boolean indicating if the scene must use right-handed coordinates system
  41154. */
  41155. set useRightHandedSystem(value: boolean);
  41156. get useRightHandedSystem(): boolean;
  41157. private _timeAccumulator;
  41158. private _currentStepId;
  41159. private _currentInternalStep;
  41160. /**
  41161. * Sets the step Id used by deterministic lock step
  41162. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  41163. * @param newStepId defines the step Id
  41164. */
  41165. setStepId(newStepId: number): void;
  41166. /**
  41167. * Gets the step Id used by deterministic lock step
  41168. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  41169. * @returns the step Id
  41170. */
  41171. getStepId(): number;
  41172. /**
  41173. * Gets the internal step used by deterministic lock step
  41174. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  41175. * @returns the internal step
  41176. */
  41177. getInternalStep(): number;
  41178. private _fogEnabled;
  41179. /**
  41180. * Gets or sets a boolean indicating if fog is enabled on this scene
  41181. * @see https://doc.babylonjs.com/babylon101/environment#fog
  41182. * (Default is true)
  41183. */
  41184. set fogEnabled(value: boolean);
  41185. get fogEnabled(): boolean;
  41186. private _fogMode;
  41187. /**
  41188. * Gets or sets the fog mode to use
  41189. * @see https://doc.babylonjs.com/babylon101/environment#fog
  41190. * | mode | value |
  41191. * | --- | --- |
  41192. * | FOGMODE_NONE | 0 |
  41193. * | FOGMODE_EXP | 1 |
  41194. * | FOGMODE_EXP2 | 2 |
  41195. * | FOGMODE_LINEAR | 3 |
  41196. */
  41197. set fogMode(value: number);
  41198. get fogMode(): number;
  41199. /**
  41200. * Gets or sets the fog color to use
  41201. * @see https://doc.babylonjs.com/babylon101/environment#fog
  41202. * (Default is Color3(0.2, 0.2, 0.3))
  41203. */
  41204. fogColor: Color3;
  41205. /**
  41206. * Gets or sets the fog density to use
  41207. * @see https://doc.babylonjs.com/babylon101/environment#fog
  41208. * (Default is 0.1)
  41209. */
  41210. fogDensity: number;
  41211. /**
  41212. * Gets or sets the fog start distance to use
  41213. * @see https://doc.babylonjs.com/babylon101/environment#fog
  41214. * (Default is 0)
  41215. */
  41216. fogStart: number;
  41217. /**
  41218. * Gets or sets the fog end distance to use
  41219. * @see https://doc.babylonjs.com/babylon101/environment#fog
  41220. * (Default is 1000)
  41221. */
  41222. fogEnd: number;
  41223. /**
  41224. * Flag indicating that the frame buffer binding is handled by another component
  41225. */
  41226. prePass: boolean;
  41227. private _shadowsEnabled;
  41228. /**
  41229. * Gets or sets a boolean indicating if shadows are enabled on this scene
  41230. */
  41231. set shadowsEnabled(value: boolean);
  41232. get shadowsEnabled(): boolean;
  41233. private _lightsEnabled;
  41234. /**
  41235. * Gets or sets a boolean indicating if lights are enabled on this scene
  41236. */
  41237. set lightsEnabled(value: boolean);
  41238. get lightsEnabled(): boolean;
  41239. /** All of the active cameras added to this scene. */
  41240. activeCameras: Camera[];
  41241. /** @hidden */
  41242. _activeCamera: Nullable<Camera>;
  41243. /** Gets or sets the current active camera */
  41244. get activeCamera(): Nullable<Camera>;
  41245. set activeCamera(value: Nullable<Camera>);
  41246. private _defaultMaterial;
  41247. /** The default material used on meshes when no material is affected */
  41248. get defaultMaterial(): Material;
  41249. /** The default material used on meshes when no material is affected */
  41250. set defaultMaterial(value: Material);
  41251. private _texturesEnabled;
  41252. /**
  41253. * Gets or sets a boolean indicating if textures are enabled on this scene
  41254. */
  41255. set texturesEnabled(value: boolean);
  41256. get texturesEnabled(): boolean;
  41257. /**
  41258. * Gets or sets a boolean indicating if physic engines are enabled on this scene
  41259. */
  41260. physicsEnabled: boolean;
  41261. /**
  41262. * Gets or sets a boolean indicating if particles are enabled on this scene
  41263. */
  41264. particlesEnabled: boolean;
  41265. /**
  41266. * Gets or sets a boolean indicating if sprites are enabled on this scene
  41267. */
  41268. spritesEnabled: boolean;
  41269. private _skeletonsEnabled;
  41270. /**
  41271. * Gets or sets a boolean indicating if skeletons are enabled on this scene
  41272. */
  41273. set skeletonsEnabled(value: boolean);
  41274. get skeletonsEnabled(): boolean;
  41275. /**
  41276. * Gets or sets a boolean indicating if lens flares are enabled on this scene
  41277. */
  41278. lensFlaresEnabled: boolean;
  41279. /**
  41280. * Gets or sets a boolean indicating if collisions are enabled on this scene
  41281. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  41282. */
  41283. collisionsEnabled: boolean;
  41284. private _collisionCoordinator;
  41285. /** @hidden */
  41286. get collisionCoordinator(): ICollisionCoordinator;
  41287. /**
  41288. * Defines the gravity applied to this scene (used only for collisions)
  41289. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  41290. */
  41291. gravity: Vector3;
  41292. /**
  41293. * Gets or sets a boolean indicating if postprocesses are enabled on this scene
  41294. */
  41295. postProcessesEnabled: boolean;
  41296. /**
  41297. * Gets the current postprocess manager
  41298. */
  41299. postProcessManager: PostProcessManager;
  41300. /**
  41301. * Gets or sets a boolean indicating if render targets are enabled on this scene
  41302. */
  41303. renderTargetsEnabled: boolean;
  41304. /**
  41305. * Gets or sets a boolean indicating if next render targets must be dumped as image for debugging purposes
  41306. * We recommend not using it and instead rely on Spector.js: http://spector.babylonjs.com
  41307. */
  41308. dumpNextRenderTargets: boolean;
  41309. /**
  41310. * The list of user defined render targets added to the scene
  41311. */
  41312. customRenderTargets: RenderTargetTexture[];
  41313. /**
  41314. * Defines if texture loading must be delayed
  41315. * If true, textures will only be loaded when they need to be rendered
  41316. */
  41317. useDelayedTextureLoading: boolean;
  41318. /**
  41319. * Gets the list of meshes imported to the scene through SceneLoader
  41320. */
  41321. importedMeshesFiles: String[];
  41322. /**
  41323. * Gets or sets a boolean indicating if probes are enabled on this scene
  41324. */
  41325. probesEnabled: boolean;
  41326. /**
  41327. * Gets or sets the current offline provider to use to store scene data
  41328. * @see https://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  41329. */
  41330. offlineProvider: IOfflineProvider;
  41331. /**
  41332. * Gets or sets the action manager associated with the scene
  41333. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  41334. */
  41335. actionManager: AbstractActionManager;
  41336. private _meshesForIntersections;
  41337. /**
  41338. * Gets or sets a boolean indicating if procedural textures are enabled on this scene
  41339. */
  41340. proceduralTexturesEnabled: boolean;
  41341. private _engine;
  41342. private _totalVertices;
  41343. /** @hidden */
  41344. _activeIndices: PerfCounter;
  41345. /** @hidden */
  41346. _activeParticles: PerfCounter;
  41347. /** @hidden */
  41348. _activeBones: PerfCounter;
  41349. private _animationRatio;
  41350. /** @hidden */
  41351. _animationTimeLast: number;
  41352. /** @hidden */
  41353. _animationTime: number;
  41354. /**
  41355. * Gets or sets a general scale for animation speed
  41356. * @see https://www.babylonjs-playground.com/#IBU2W7#3
  41357. */
  41358. animationTimeScale: number;
  41359. /** @hidden */
  41360. _cachedMaterial: Nullable<Material>;
  41361. /** @hidden */
  41362. _cachedEffect: Nullable<Effect>;
  41363. /** @hidden */
  41364. _cachedVisibility: Nullable<number>;
  41365. private _renderId;
  41366. private _frameId;
  41367. private _executeWhenReadyTimeoutId;
  41368. private _intermediateRendering;
  41369. private _viewUpdateFlag;
  41370. private _projectionUpdateFlag;
  41371. /** @hidden */
  41372. _toBeDisposed: Nullable<IDisposable>[];
  41373. private _activeRequests;
  41374. /** @hidden */
  41375. _pendingData: any[];
  41376. private _isDisposed;
  41377. /**
  41378. * Gets or sets a boolean indicating that all submeshes of active meshes must be rendered
  41379. * Use this boolean to avoid computing frustum clipping on submeshes (This could help when you are CPU bound)
  41380. */
  41381. dispatchAllSubMeshesOfActiveMeshes: boolean;
  41382. private _activeMeshes;
  41383. private _processedMaterials;
  41384. private _renderTargets;
  41385. /** @hidden */
  41386. _activeParticleSystems: SmartArray<IParticleSystem>;
  41387. private _activeSkeletons;
  41388. private _softwareSkinnedMeshes;
  41389. private _renderingManager;
  41390. /** @hidden */
  41391. _activeAnimatables: import("babylonjs/Animations/animatable").Animatable[];
  41392. private _transformMatrix;
  41393. private _sceneUbo;
  41394. /** @hidden */
  41395. _viewMatrix: Matrix;
  41396. private _projectionMatrix;
  41397. /** @hidden */
  41398. _forcedViewPosition: Nullable<Vector3>;
  41399. /** @hidden */
  41400. _frustumPlanes: Plane[];
  41401. /**
  41402. * Gets the list of frustum planes (built from the active camera)
  41403. */
  41404. get frustumPlanes(): Plane[];
  41405. /**
  41406. * Gets or sets a boolean indicating if lights must be sorted by priority (off by default)
  41407. * This is useful if there are more lights that the maximum simulteanous authorized
  41408. */
  41409. requireLightSorting: boolean;
  41410. /** @hidden */
  41411. readonly useMaterialMeshMap: boolean;
  41412. /** @hidden */
  41413. readonly useClonedMeshMap: boolean;
  41414. private _externalData;
  41415. private _uid;
  41416. /**
  41417. * @hidden
  41418. * Backing store of defined scene components.
  41419. */
  41420. _components: ISceneComponent[];
  41421. /**
  41422. * @hidden
  41423. * Backing store of defined scene components.
  41424. */
  41425. _serializableComponents: ISceneSerializableComponent[];
  41426. /**
  41427. * List of components to register on the next registration step.
  41428. */
  41429. private _transientComponents;
  41430. /**
  41431. * Registers the transient components if needed.
  41432. */
  41433. private _registerTransientComponents;
  41434. /**
  41435. * @hidden
  41436. * Add a component to the scene.
  41437. * Note that the ccomponent could be registered on th next frame if this is called after
  41438. * the register component stage.
  41439. * @param component Defines the component to add to the scene
  41440. */
  41441. _addComponent(component: ISceneComponent): void;
  41442. /**
  41443. * @hidden
  41444. * Gets a component from the scene.
  41445. * @param name defines the name of the component to retrieve
  41446. * @returns the component or null if not present
  41447. */
  41448. _getComponent(name: string): Nullable<ISceneComponent>;
  41449. /**
  41450. * @hidden
  41451. * Defines the actions happening before camera updates.
  41452. */
  41453. _beforeCameraUpdateStage: Stage<SimpleStageAction>;
  41454. /**
  41455. * @hidden
  41456. * Defines the actions happening before clear the canvas.
  41457. */
  41458. _beforeClearStage: Stage<SimpleStageAction>;
  41459. /**
  41460. * @hidden
  41461. * Defines the actions when collecting render targets for the frame.
  41462. */
  41463. _gatherRenderTargetsStage: Stage<RenderTargetsStageAction>;
  41464. /**
  41465. * @hidden
  41466. * Defines the actions happening for one camera in the frame.
  41467. */
  41468. _gatherActiveCameraRenderTargetsStage: Stage<RenderTargetsStageAction>;
  41469. /**
  41470. * @hidden
  41471. * Defines the actions happening during the per mesh ready checks.
  41472. */
  41473. _isReadyForMeshStage: Stage<MeshStageAction>;
  41474. /**
  41475. * @hidden
  41476. * Defines the actions happening before evaluate active mesh checks.
  41477. */
  41478. _beforeEvaluateActiveMeshStage: Stage<SimpleStageAction>;
  41479. /**
  41480. * @hidden
  41481. * Defines the actions happening during the evaluate sub mesh checks.
  41482. */
  41483. _evaluateSubMeshStage: Stage<EvaluateSubMeshStageAction>;
  41484. /**
  41485. * @hidden
  41486. * Defines the actions happening during the active mesh stage.
  41487. */
  41488. _activeMeshStage: Stage<ActiveMeshStageAction>;
  41489. /**
  41490. * @hidden
  41491. * Defines the actions happening during the per camera render target step.
  41492. */
  41493. _cameraDrawRenderTargetStage: Stage<CameraStageFrameBufferAction>;
  41494. /**
  41495. * @hidden
  41496. * Defines the actions happening just before the active camera is drawing.
  41497. */
  41498. _beforeCameraDrawStage: Stage<CameraStageAction>;
  41499. /**
  41500. * @hidden
  41501. * Defines the actions happening just before a render target is drawing.
  41502. */
  41503. _beforeRenderTargetDrawStage: Stage<RenderTargetStageAction>;
  41504. /**
  41505. * @hidden
  41506. * Defines the actions happening just before a rendering group is drawing.
  41507. */
  41508. _beforeRenderingGroupDrawStage: Stage<RenderingGroupStageAction>;
  41509. /**
  41510. * @hidden
  41511. * Defines the actions happening just before a mesh is drawing.
  41512. */
  41513. _beforeRenderingMeshStage: Stage<RenderingMeshStageAction>;
  41514. /**
  41515. * @hidden
  41516. * Defines the actions happening just after a mesh has been drawn.
  41517. */
  41518. _afterRenderingMeshStage: Stage<RenderingMeshStageAction>;
  41519. /**
  41520. * @hidden
  41521. * Defines the actions happening just after a rendering group has been drawn.
  41522. */
  41523. _afterRenderingGroupDrawStage: Stage<RenderingGroupStageAction>;
  41524. /**
  41525. * @hidden
  41526. * Defines the actions happening just after the active camera has been drawn.
  41527. */
  41528. _afterCameraDrawStage: Stage<CameraStageAction>;
  41529. /**
  41530. * @hidden
  41531. * Defines the actions happening just after a render target has been drawn.
  41532. */
  41533. _afterRenderTargetDrawStage: Stage<RenderTargetStageAction>;
  41534. /**
  41535. * @hidden
  41536. * Defines the actions happening just after rendering all cameras and computing intersections.
  41537. */
  41538. _afterRenderStage: Stage<SimpleStageAction>;
  41539. /**
  41540. * @hidden
  41541. * Defines the actions happening when a pointer move event happens.
  41542. */
  41543. _pointerMoveStage: Stage<PointerMoveStageAction>;
  41544. /**
  41545. * @hidden
  41546. * Defines the actions happening when a pointer down event happens.
  41547. */
  41548. _pointerDownStage: Stage<PointerUpDownStageAction>;
  41549. /**
  41550. * @hidden
  41551. * Defines the actions happening when a pointer up event happens.
  41552. */
  41553. _pointerUpStage: Stage<PointerUpDownStageAction>;
  41554. /**
  41555. * an optional map from Geometry Id to Geometry index in the 'geometries' array
  41556. */
  41557. private geometriesByUniqueId;
  41558. /**
  41559. * Creates a new Scene
  41560. * @param engine defines the engine to use to render this scene
  41561. * @param options defines the scene options
  41562. */
  41563. constructor(engine: Engine, options?: SceneOptions);
  41564. /**
  41565. * Gets a string identifying the name of the class
  41566. * @returns "Scene" string
  41567. */
  41568. getClassName(): string;
  41569. private _defaultMeshCandidates;
  41570. /**
  41571. * @hidden
  41572. */
  41573. _getDefaultMeshCandidates(): ISmartArrayLike<AbstractMesh>;
  41574. private _defaultSubMeshCandidates;
  41575. /**
  41576. * @hidden
  41577. */
  41578. _getDefaultSubMeshCandidates(mesh: AbstractMesh): ISmartArrayLike<SubMesh>;
  41579. /**
  41580. * Sets the default candidate providers for the scene.
  41581. * This sets the getActiveMeshCandidates, getActiveSubMeshCandidates, getIntersectingSubMeshCandidates
  41582. * and getCollidingSubMeshCandidates to their default function
  41583. */
  41584. setDefaultCandidateProviders(): void;
  41585. /**
  41586. * Gets the mesh that is currently under the pointer
  41587. */
  41588. get meshUnderPointer(): Nullable<AbstractMesh>;
  41589. /**
  41590. * Gets or sets the current on-screen X position of the pointer
  41591. */
  41592. get pointerX(): number;
  41593. set pointerX(value: number);
  41594. /**
  41595. * Gets or sets the current on-screen Y position of the pointer
  41596. */
  41597. get pointerY(): number;
  41598. set pointerY(value: number);
  41599. /**
  41600. * Gets the cached material (ie. the latest rendered one)
  41601. * @returns the cached material
  41602. */
  41603. getCachedMaterial(): Nullable<Material>;
  41604. /**
  41605. * Gets the cached effect (ie. the latest rendered one)
  41606. * @returns the cached effect
  41607. */
  41608. getCachedEffect(): Nullable<Effect>;
  41609. /**
  41610. * Gets the cached visibility state (ie. the latest rendered one)
  41611. * @returns the cached visibility state
  41612. */
  41613. getCachedVisibility(): Nullable<number>;
  41614. /**
  41615. * Gets a boolean indicating if the current material / effect / visibility must be bind again
  41616. * @param material defines the current material
  41617. * @param effect defines the current effect
  41618. * @param visibility defines the current visibility state
  41619. * @returns true if one parameter is not cached
  41620. */
  41621. isCachedMaterialInvalid(material: Material, effect: Effect, visibility?: number): boolean;
  41622. /**
  41623. * Gets the engine associated with the scene
  41624. * @returns an Engine
  41625. */
  41626. getEngine(): Engine;
  41627. /**
  41628. * Gets the total number of vertices rendered per frame
  41629. * @returns the total number of vertices rendered per frame
  41630. */
  41631. getTotalVertices(): number;
  41632. /**
  41633. * Gets the performance counter for total vertices
  41634. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  41635. */
  41636. get totalVerticesPerfCounter(): PerfCounter;
  41637. /**
  41638. * Gets the total number of active indices rendered per frame (You can deduce the number of rendered triangles by dividing this number by 3)
  41639. * @returns the total number of active indices rendered per frame
  41640. */
  41641. getActiveIndices(): number;
  41642. /**
  41643. * Gets the performance counter for active indices
  41644. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  41645. */
  41646. get totalActiveIndicesPerfCounter(): PerfCounter;
  41647. /**
  41648. * Gets the total number of active particles rendered per frame
  41649. * @returns the total number of active particles rendered per frame
  41650. */
  41651. getActiveParticles(): number;
  41652. /**
  41653. * Gets the performance counter for active particles
  41654. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  41655. */
  41656. get activeParticlesPerfCounter(): PerfCounter;
  41657. /**
  41658. * Gets the total number of active bones rendered per frame
  41659. * @returns the total number of active bones rendered per frame
  41660. */
  41661. getActiveBones(): number;
  41662. /**
  41663. * Gets the performance counter for active bones
  41664. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  41665. */
  41666. get activeBonesPerfCounter(): PerfCounter;
  41667. /**
  41668. * Gets the array of active meshes
  41669. * @returns an array of AbstractMesh
  41670. */
  41671. getActiveMeshes(): SmartArray<AbstractMesh>;
  41672. /**
  41673. * Gets the animation ratio (which is 1.0 is the scene renders at 60fps and 2 if the scene renders at 30fps, etc.)
  41674. * @returns a number
  41675. */
  41676. getAnimationRatio(): number;
  41677. /**
  41678. * Gets an unique Id for the current render phase
  41679. * @returns a number
  41680. */
  41681. getRenderId(): number;
  41682. /**
  41683. * Gets an unique Id for the current frame
  41684. * @returns a number
  41685. */
  41686. getFrameId(): number;
  41687. /** Call this function if you want to manually increment the render Id*/
  41688. incrementRenderId(): void;
  41689. private _createUbo;
  41690. /**
  41691. * Use this method to simulate a pointer move on a mesh
  41692. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  41693. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  41694. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  41695. * @returns the current scene
  41696. */
  41697. simulatePointerMove(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  41698. /**
  41699. * Use this method to simulate a pointer down on a mesh
  41700. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  41701. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  41702. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  41703. * @returns the current scene
  41704. */
  41705. simulatePointerDown(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  41706. /**
  41707. * Use this method to simulate a pointer up on a mesh
  41708. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  41709. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  41710. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  41711. * @param doubleTap indicates that the pointer up event should be considered as part of a double click (false by default)
  41712. * @returns the current scene
  41713. */
  41714. simulatePointerUp(pickResult: PickingInfo, pointerEventInit?: PointerEventInit, doubleTap?: boolean): Scene;
  41715. /**
  41716. * Gets a boolean indicating if the current pointer event is captured (meaning that the scene has already handled the pointer down)
  41717. * @param pointerId defines the pointer id to use in a multi-touch scenario (0 by default)
  41718. * @returns true if the pointer was captured
  41719. */
  41720. isPointerCaptured(pointerId?: number): boolean;
  41721. /**
  41722. * Attach events to the canvas (To handle actionManagers triggers and raise onPointerMove, onPointerDown and onPointerUp
  41723. * @param attachUp defines if you want to attach events to pointerup
  41724. * @param attachDown defines if you want to attach events to pointerdown
  41725. * @param attachMove defines if you want to attach events to pointermove
  41726. */
  41727. attachControl(attachUp?: boolean, attachDown?: boolean, attachMove?: boolean): void;
  41728. /** Detaches all event handlers*/
  41729. detachControl(): void;
  41730. /**
  41731. * This function will check if the scene can be rendered (textures are loaded, shaders are compiled)
  41732. * Delay loaded resources are not taking in account
  41733. * @return true if all required resources are ready
  41734. */
  41735. isReady(): boolean;
  41736. /** Resets all cached information relative to material (including effect and visibility) */
  41737. resetCachedMaterial(): void;
  41738. /**
  41739. * Registers a function to be called before every frame render
  41740. * @param func defines the function to register
  41741. */
  41742. registerBeforeRender(func: () => void): void;
  41743. /**
  41744. * Unregisters a function called before every frame render
  41745. * @param func defines the function to unregister
  41746. */
  41747. unregisterBeforeRender(func: () => void): void;
  41748. /**
  41749. * Registers a function to be called after every frame render
  41750. * @param func defines the function to register
  41751. */
  41752. registerAfterRender(func: () => void): void;
  41753. /**
  41754. * Unregisters a function called after every frame render
  41755. * @param func defines the function to unregister
  41756. */
  41757. unregisterAfterRender(func: () => void): void;
  41758. private _executeOnceBeforeRender;
  41759. /**
  41760. * The provided function will run before render once and will be disposed afterwards.
  41761. * A timeout delay can be provided so that the function will be executed in N ms.
  41762. * The timeout is using the browser's native setTimeout so time percision cannot be guaranteed.
  41763. * @param func The function to be executed.
  41764. * @param timeout optional delay in ms
  41765. */
  41766. executeOnceBeforeRender(func: () => void, timeout?: number): void;
  41767. /** @hidden */
  41768. _addPendingData(data: any): void;
  41769. /** @hidden */
  41770. _removePendingData(data: any): void;
  41771. /**
  41772. * Returns the number of items waiting to be loaded
  41773. * @returns the number of items waiting to be loaded
  41774. */
  41775. getWaitingItemsCount(): number;
  41776. /**
  41777. * Returns a boolean indicating if the scene is still loading data
  41778. */
  41779. get isLoading(): boolean;
  41780. /**
  41781. * Registers a function to be executed when the scene is ready
  41782. * @param {Function} func - the function to be executed
  41783. */
  41784. executeWhenReady(func: () => void): void;
  41785. /**
  41786. * Returns a promise that resolves when the scene is ready
  41787. * @returns A promise that resolves when the scene is ready
  41788. */
  41789. whenReadyAsync(): Promise<void>;
  41790. /** @hidden */
  41791. _checkIsReady(): void;
  41792. /**
  41793. * Gets all animatable attached to the scene
  41794. */
  41795. get animatables(): Animatable[];
  41796. /**
  41797. * Resets the last animation time frame.
  41798. * Useful to override when animations start running when loading a scene for the first time.
  41799. */
  41800. resetLastAnimationTimeFrame(): void;
  41801. /**
  41802. * Gets the current view matrix
  41803. * @returns a Matrix
  41804. */
  41805. getViewMatrix(): Matrix;
  41806. /**
  41807. * Gets the current projection matrix
  41808. * @returns a Matrix
  41809. */
  41810. getProjectionMatrix(): Matrix;
  41811. /**
  41812. * Gets the current transform matrix
  41813. * @returns a Matrix made of View * Projection
  41814. */
  41815. getTransformMatrix(): Matrix;
  41816. /**
  41817. * Sets the current transform matrix
  41818. * @param viewL defines the View matrix to use
  41819. * @param projectionL defines the Projection matrix to use
  41820. * @param viewR defines the right View matrix to use (if provided)
  41821. * @param projectionR defines the right Projection matrix to use (if provided)
  41822. */
  41823. setTransformMatrix(viewL: Matrix, projectionL: Matrix, viewR?: Matrix, projectionR?: Matrix): void;
  41824. /**
  41825. * Gets the uniform buffer used to store scene data
  41826. * @returns a UniformBuffer
  41827. */
  41828. getSceneUniformBuffer(): UniformBuffer;
  41829. /**
  41830. * Gets an unique (relatively to the current scene) Id
  41831. * @returns an unique number for the scene
  41832. */
  41833. getUniqueId(): number;
  41834. /**
  41835. * Add a mesh to the list of scene's meshes
  41836. * @param newMesh defines the mesh to add
  41837. * @param recursive if all child meshes should also be added to the scene
  41838. */
  41839. addMesh(newMesh: AbstractMesh, recursive?: boolean): void;
  41840. /**
  41841. * Remove a mesh for the list of scene's meshes
  41842. * @param toRemove defines the mesh to remove
  41843. * @param recursive if all child meshes should also be removed from the scene
  41844. * @returns the index where the mesh was in the mesh list
  41845. */
  41846. removeMesh(toRemove: AbstractMesh, recursive?: boolean): number;
  41847. /**
  41848. * Add a transform node to the list of scene's transform nodes
  41849. * @param newTransformNode defines the transform node to add
  41850. */
  41851. addTransformNode(newTransformNode: TransformNode): void;
  41852. /**
  41853. * Remove a transform node for the list of scene's transform nodes
  41854. * @param toRemove defines the transform node to remove
  41855. * @returns the index where the transform node was in the transform node list
  41856. */
  41857. removeTransformNode(toRemove: TransformNode): number;
  41858. /**
  41859. * Remove a skeleton for the list of scene's skeletons
  41860. * @param toRemove defines the skeleton to remove
  41861. * @returns the index where the skeleton was in the skeleton list
  41862. */
  41863. removeSkeleton(toRemove: Skeleton): number;
  41864. /**
  41865. * Remove a morph target for the list of scene's morph targets
  41866. * @param toRemove defines the morph target to remove
  41867. * @returns the index where the morph target was in the morph target list
  41868. */
  41869. removeMorphTargetManager(toRemove: MorphTargetManager): number;
  41870. /**
  41871. * Remove a light for the list of scene's lights
  41872. * @param toRemove defines the light to remove
  41873. * @returns the index where the light was in the light list
  41874. */
  41875. removeLight(toRemove: Light): number;
  41876. /**
  41877. * Remove a camera for the list of scene's cameras
  41878. * @param toRemove defines the camera to remove
  41879. * @returns the index where the camera was in the camera list
  41880. */
  41881. removeCamera(toRemove: Camera): number;
  41882. /**
  41883. * Remove a particle system for the list of scene's particle systems
  41884. * @param toRemove defines the particle system to remove
  41885. * @returns the index where the particle system was in the particle system list
  41886. */
  41887. removeParticleSystem(toRemove: IParticleSystem): number;
  41888. /**
  41889. * Remove a animation for the list of scene's animations
  41890. * @param toRemove defines the animation to remove
  41891. * @returns the index where the animation was in the animation list
  41892. */
  41893. removeAnimation(toRemove: Animation): number;
  41894. /**
  41895. * Will stop the animation of the given target
  41896. * @param target - the target
  41897. * @param animationName - the name of the animation to stop (all animations will be stopped if both this and targetMask are empty)
  41898. * @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)
  41899. */
  41900. stopAnimation(target: any, animationName?: string, targetMask?: (target: any) => boolean): void;
  41901. /**
  41902. * Removes the given animation group from this scene.
  41903. * @param toRemove The animation group to remove
  41904. * @returns The index of the removed animation group
  41905. */
  41906. removeAnimationGroup(toRemove: AnimationGroup): number;
  41907. /**
  41908. * Removes the given multi-material from this scene.
  41909. * @param toRemove The multi-material to remove
  41910. * @returns The index of the removed multi-material
  41911. */
  41912. removeMultiMaterial(toRemove: MultiMaterial): number;
  41913. /**
  41914. * Removes the given material from this scene.
  41915. * @param toRemove The material to remove
  41916. * @returns The index of the removed material
  41917. */
  41918. removeMaterial(toRemove: Material): number;
  41919. /**
  41920. * Removes the given action manager from this scene.
  41921. * @param toRemove The action manager to remove
  41922. * @returns The index of the removed action manager
  41923. */
  41924. removeActionManager(toRemove: AbstractActionManager): number;
  41925. /**
  41926. * Removes the given texture from this scene.
  41927. * @param toRemove The texture to remove
  41928. * @returns The index of the removed texture
  41929. */
  41930. removeTexture(toRemove: BaseTexture): number;
  41931. /**
  41932. * Adds the given light to this scene
  41933. * @param newLight The light to add
  41934. */
  41935. addLight(newLight: Light): void;
  41936. /**
  41937. * Sorts the list list based on light priorities
  41938. */
  41939. sortLightsByPriority(): void;
  41940. /**
  41941. * Adds the given camera to this scene
  41942. * @param newCamera The camera to add
  41943. */
  41944. addCamera(newCamera: Camera): void;
  41945. /**
  41946. * Adds the given skeleton to this scene
  41947. * @param newSkeleton The skeleton to add
  41948. */
  41949. addSkeleton(newSkeleton: Skeleton): void;
  41950. /**
  41951. * Adds the given particle system to this scene
  41952. * @param newParticleSystem The particle system to add
  41953. */
  41954. addParticleSystem(newParticleSystem: IParticleSystem): void;
  41955. /**
  41956. * Adds the given animation to this scene
  41957. * @param newAnimation The animation to add
  41958. */
  41959. addAnimation(newAnimation: Animation): void;
  41960. /**
  41961. * Adds the given animation group to this scene.
  41962. * @param newAnimationGroup The animation group to add
  41963. */
  41964. addAnimationGroup(newAnimationGroup: AnimationGroup): void;
  41965. /**
  41966. * Adds the given multi-material to this scene
  41967. * @param newMultiMaterial The multi-material to add
  41968. */
  41969. addMultiMaterial(newMultiMaterial: MultiMaterial): void;
  41970. /**
  41971. * Adds the given material to this scene
  41972. * @param newMaterial The material to add
  41973. */
  41974. addMaterial(newMaterial: Material): void;
  41975. /**
  41976. * Adds the given morph target to this scene
  41977. * @param newMorphTargetManager The morph target to add
  41978. */
  41979. addMorphTargetManager(newMorphTargetManager: MorphTargetManager): void;
  41980. /**
  41981. * Adds the given geometry to this scene
  41982. * @param newGeometry The geometry to add
  41983. */
  41984. addGeometry(newGeometry: Geometry): void;
  41985. /**
  41986. * Adds the given action manager to this scene
  41987. * @param newActionManager The action manager to add
  41988. */
  41989. addActionManager(newActionManager: AbstractActionManager): void;
  41990. /**
  41991. * Adds the given texture to this scene.
  41992. * @param newTexture The texture to add
  41993. */
  41994. addTexture(newTexture: BaseTexture): void;
  41995. /**
  41996. * Switch active camera
  41997. * @param newCamera defines the new active camera
  41998. * @param attachControl defines if attachControl must be called for the new active camera (default: true)
  41999. */
  42000. switchActiveCamera(newCamera: Camera, attachControl?: boolean): void;
  42001. /**
  42002. * sets the active camera of the scene using its ID
  42003. * @param id defines the camera's ID
  42004. * @return the new active camera or null if none found.
  42005. */
  42006. setActiveCameraByID(id: string): Nullable<Camera>;
  42007. /**
  42008. * sets the active camera of the scene using its name
  42009. * @param name defines the camera's name
  42010. * @returns the new active camera or null if none found.
  42011. */
  42012. setActiveCameraByName(name: string): Nullable<Camera>;
  42013. /**
  42014. * get an animation group using its name
  42015. * @param name defines the material's name
  42016. * @return the animation group or null if none found.
  42017. */
  42018. getAnimationGroupByName(name: string): Nullable<AnimationGroup>;
  42019. /**
  42020. * Get a material using its unique id
  42021. * @param uniqueId defines the material's unique id
  42022. * @return the material or null if none found.
  42023. */
  42024. getMaterialByUniqueID(uniqueId: number): Nullable<Material>;
  42025. /**
  42026. * get a material using its id
  42027. * @param id defines the material's ID
  42028. * @return the material or null if none found.
  42029. */
  42030. getMaterialByID(id: string): Nullable<Material>;
  42031. /**
  42032. * Gets a the last added material using a given id
  42033. * @param id defines the material's ID
  42034. * @return the last material with the given id or null if none found.
  42035. */
  42036. getLastMaterialByID(id: string): Nullable<Material>;
  42037. /**
  42038. * Gets a material using its name
  42039. * @param name defines the material's name
  42040. * @return the material or null if none found.
  42041. */
  42042. getMaterialByName(name: string): Nullable<Material>;
  42043. /**
  42044. * Get a texture using its unique id
  42045. * @param uniqueId defines the texture's unique id
  42046. * @return the texture or null if none found.
  42047. */
  42048. getTextureByUniqueID(uniqueId: number): Nullable<BaseTexture>;
  42049. /**
  42050. * Gets a camera using its id
  42051. * @param id defines the id to look for
  42052. * @returns the camera or null if not found
  42053. */
  42054. getCameraByID(id: string): Nullable<Camera>;
  42055. /**
  42056. * Gets a camera using its unique id
  42057. * @param uniqueId defines the unique id to look for
  42058. * @returns the camera or null if not found
  42059. */
  42060. getCameraByUniqueID(uniqueId: number): Nullable<Camera>;
  42061. /**
  42062. * Gets a camera using its name
  42063. * @param name defines the camera's name
  42064. * @return the camera or null if none found.
  42065. */
  42066. getCameraByName(name: string): Nullable<Camera>;
  42067. /**
  42068. * Gets a bone using its id
  42069. * @param id defines the bone's id
  42070. * @return the bone or null if not found
  42071. */
  42072. getBoneByID(id: string): Nullable<Bone>;
  42073. /**
  42074. * Gets a bone using its id
  42075. * @param name defines the bone's name
  42076. * @return the bone or null if not found
  42077. */
  42078. getBoneByName(name: string): Nullable<Bone>;
  42079. /**
  42080. * Gets a light node using its name
  42081. * @param name defines the the light's name
  42082. * @return the light or null if none found.
  42083. */
  42084. getLightByName(name: string): Nullable<Light>;
  42085. /**
  42086. * Gets a light node using its id
  42087. * @param id defines the light's id
  42088. * @return the light or null if none found.
  42089. */
  42090. getLightByID(id: string): Nullable<Light>;
  42091. /**
  42092. * Gets a light node using its scene-generated unique ID
  42093. * @param uniqueId defines the light's unique id
  42094. * @return the light or null if none found.
  42095. */
  42096. getLightByUniqueID(uniqueId: number): Nullable<Light>;
  42097. /**
  42098. * Gets a particle system by id
  42099. * @param id defines the particle system id
  42100. * @return the corresponding system or null if none found
  42101. */
  42102. getParticleSystemByID(id: string): Nullable<IParticleSystem>;
  42103. /**
  42104. * Gets a geometry using its ID
  42105. * @param id defines the geometry's id
  42106. * @return the geometry or null if none found.
  42107. */
  42108. getGeometryByID(id: string): Nullable<Geometry>;
  42109. private _getGeometryByUniqueID;
  42110. /**
  42111. * Add a new geometry to this scene
  42112. * @param geometry defines the geometry to be added to the scene.
  42113. * @param force defines if the geometry must be pushed even if a geometry with this id already exists
  42114. * @return a boolean defining if the geometry was added or not
  42115. */
  42116. pushGeometry(geometry: Geometry, force?: boolean): boolean;
  42117. /**
  42118. * Removes an existing geometry
  42119. * @param geometry defines the geometry to be removed from the scene
  42120. * @return a boolean defining if the geometry was removed or not
  42121. */
  42122. removeGeometry(geometry: Geometry): boolean;
  42123. /**
  42124. * Gets the list of geometries attached to the scene
  42125. * @returns an array of Geometry
  42126. */
  42127. getGeometries(): Geometry[];
  42128. /**
  42129. * Gets the first added mesh found of a given ID
  42130. * @param id defines the id to search for
  42131. * @return the mesh found or null if not found at all
  42132. */
  42133. getMeshByID(id: string): Nullable<AbstractMesh>;
  42134. /**
  42135. * Gets a list of meshes using their id
  42136. * @param id defines the id to search for
  42137. * @returns a list of meshes
  42138. */
  42139. getMeshesByID(id: string): Array<AbstractMesh>;
  42140. /**
  42141. * Gets the first added transform node found of a given ID
  42142. * @param id defines the id to search for
  42143. * @return the found transform node or null if not found at all.
  42144. */
  42145. getTransformNodeByID(id: string): Nullable<TransformNode>;
  42146. /**
  42147. * Gets a transform node with its auto-generated unique id
  42148. * @param uniqueId efines the unique id to search for
  42149. * @return the found transform node or null if not found at all.
  42150. */
  42151. getTransformNodeByUniqueID(uniqueId: number): Nullable<TransformNode>;
  42152. /**
  42153. * Gets a list of transform nodes using their id
  42154. * @param id defines the id to search for
  42155. * @returns a list of transform nodes
  42156. */
  42157. getTransformNodesByID(id: string): Array<TransformNode>;
  42158. /**
  42159. * Gets a mesh with its auto-generated unique id
  42160. * @param uniqueId defines the unique id to search for
  42161. * @return the found mesh or null if not found at all.
  42162. */
  42163. getMeshByUniqueID(uniqueId: number): Nullable<AbstractMesh>;
  42164. /**
  42165. * Gets a the last added mesh using a given id
  42166. * @param id defines the id to search for
  42167. * @return the found mesh or null if not found at all.
  42168. */
  42169. getLastMeshByID(id: string): Nullable<AbstractMesh>;
  42170. /**
  42171. * Gets a the last added node (Mesh, Camera, Light) using a given id
  42172. * @param id defines the id to search for
  42173. * @return the found node or null if not found at all
  42174. */
  42175. getLastEntryByID(id: string): Nullable<Node>;
  42176. /**
  42177. * Gets a node (Mesh, Camera, Light) using a given id
  42178. * @param id defines the id to search for
  42179. * @return the found node or null if not found at all
  42180. */
  42181. getNodeByID(id: string): Nullable<Node>;
  42182. /**
  42183. * Gets a node (Mesh, Camera, Light) using a given name
  42184. * @param name defines the name to search for
  42185. * @return the found node or null if not found at all.
  42186. */
  42187. getNodeByName(name: string): Nullable<Node>;
  42188. /**
  42189. * Gets a mesh using a given name
  42190. * @param name defines the name to search for
  42191. * @return the found mesh or null if not found at all.
  42192. */
  42193. getMeshByName(name: string): Nullable<AbstractMesh>;
  42194. /**
  42195. * Gets a transform node using a given name
  42196. * @param name defines the name to search for
  42197. * @return the found transform node or null if not found at all.
  42198. */
  42199. getTransformNodeByName(name: string): Nullable<TransformNode>;
  42200. /**
  42201. * Gets a skeleton using a given id (if many are found, this function will pick the last one)
  42202. * @param id defines the id to search for
  42203. * @return the found skeleton or null if not found at all.
  42204. */
  42205. getLastSkeletonByID(id: string): Nullable<Skeleton>;
  42206. /**
  42207. * Gets a skeleton using a given auto generated unique id
  42208. * @param uniqueId defines the unique id to search for
  42209. * @return the found skeleton or null if not found at all.
  42210. */
  42211. getSkeletonByUniqueId(uniqueId: number): Nullable<Skeleton>;
  42212. /**
  42213. * Gets a skeleton using a given id (if many are found, this function will pick the first one)
  42214. * @param id defines the id to search for
  42215. * @return the found skeleton or null if not found at all.
  42216. */
  42217. getSkeletonById(id: string): Nullable<Skeleton>;
  42218. /**
  42219. * Gets a skeleton using a given name
  42220. * @param name defines the name to search for
  42221. * @return the found skeleton or null if not found at all.
  42222. */
  42223. getSkeletonByName(name: string): Nullable<Skeleton>;
  42224. /**
  42225. * Gets a morph target manager using a given id (if many are found, this function will pick the last one)
  42226. * @param id defines the id to search for
  42227. * @return the found morph target manager or null if not found at all.
  42228. */
  42229. getMorphTargetManagerById(id: number): Nullable<MorphTargetManager>;
  42230. /**
  42231. * Gets a morph target using a given id (if many are found, this function will pick the first one)
  42232. * @param id defines the id to search for
  42233. * @return the found morph target or null if not found at all.
  42234. */
  42235. getMorphTargetById(id: string): Nullable<MorphTarget>;
  42236. /**
  42237. * Gets a morph target using a given name (if many are found, this function will pick the first one)
  42238. * @param name defines the name to search for
  42239. * @return the found morph target or null if not found at all.
  42240. */
  42241. getMorphTargetByName(name: string): Nullable<MorphTarget>;
  42242. /**
  42243. * Gets a post process using a given name (if many are found, this function will pick the first one)
  42244. * @param name defines the name to search for
  42245. * @return the found post process or null if not found at all.
  42246. */
  42247. getPostProcessByName(name: string): Nullable<PostProcess>;
  42248. /**
  42249. * Gets a boolean indicating if the given mesh is active
  42250. * @param mesh defines the mesh to look for
  42251. * @returns true if the mesh is in the active list
  42252. */
  42253. isActiveMesh(mesh: AbstractMesh): boolean;
  42254. /**
  42255. * Return a unique id as a string which can serve as an identifier for the scene
  42256. */
  42257. get uid(): string;
  42258. /**
  42259. * Add an externaly attached data from its key.
  42260. * This method call will fail and return false, if such key already exists.
  42261. * If you don't care and just want to get the data no matter what, use the more convenient getOrAddExternalDataWithFactory() method.
  42262. * @param key the unique key that identifies the data
  42263. * @param data the data object to associate to the key for this Engine instance
  42264. * @return true if no such key were already present and the data was added successfully, false otherwise
  42265. */
  42266. addExternalData<T>(key: string, data: T): boolean;
  42267. /**
  42268. * Get an externaly attached data from its key
  42269. * @param key the unique key that identifies the data
  42270. * @return the associated data, if present (can be null), or undefined if not present
  42271. */
  42272. getExternalData<T>(key: string): Nullable<T>;
  42273. /**
  42274. * Get an externaly attached data from its key, create it using a factory if it's not already present
  42275. * @param key the unique key that identifies the data
  42276. * @param factory the factory that will be called to create the instance if and only if it doesn't exists
  42277. * @return the associated data, can be null if the factory returned null.
  42278. */
  42279. getOrAddExternalDataWithFactory<T>(key: string, factory: (k: string) => T): T;
  42280. /**
  42281. * Remove an externaly attached data from the Engine instance
  42282. * @param key the unique key that identifies the data
  42283. * @return true if the data was successfully removed, false if it doesn't exist
  42284. */
  42285. removeExternalData(key: string): boolean;
  42286. private _evaluateSubMesh;
  42287. /**
  42288. * Clear the processed materials smart array preventing retention point in material dispose.
  42289. */
  42290. freeProcessedMaterials(): void;
  42291. private _preventFreeActiveMeshesAndRenderingGroups;
  42292. /** Gets or sets a boolean blocking all the calls to freeActiveMeshes and freeRenderingGroups
  42293. * It can be used in order to prevent going through methods freeRenderingGroups and freeActiveMeshes several times to improve performance
  42294. * when disposing several meshes in a row or a hierarchy of meshes.
  42295. * When used, it is the responsability of the user to blockfreeActiveMeshesAndRenderingGroups back to false.
  42296. */
  42297. get blockfreeActiveMeshesAndRenderingGroups(): boolean;
  42298. set blockfreeActiveMeshesAndRenderingGroups(value: boolean);
  42299. /**
  42300. * Clear the active meshes smart array preventing retention point in mesh dispose.
  42301. */
  42302. freeActiveMeshes(): void;
  42303. /**
  42304. * Clear the info related to rendering groups preventing retention points during dispose.
  42305. */
  42306. freeRenderingGroups(): void;
  42307. /** @hidden */
  42308. _isInIntermediateRendering(): boolean;
  42309. /**
  42310. * Lambda returning the list of potentially active meshes.
  42311. */
  42312. getActiveMeshCandidates: () => ISmartArrayLike<AbstractMesh>;
  42313. /**
  42314. * Lambda returning the list of potentially active sub meshes.
  42315. */
  42316. getActiveSubMeshCandidates: (mesh: AbstractMesh) => ISmartArrayLike<SubMesh>;
  42317. /**
  42318. * Lambda returning the list of potentially intersecting sub meshes.
  42319. */
  42320. getIntersectingSubMeshCandidates: (mesh: AbstractMesh, localRay: Ray) => ISmartArrayLike<SubMesh>;
  42321. /**
  42322. * Lambda returning the list of potentially colliding sub meshes.
  42323. */
  42324. getCollidingSubMeshCandidates: (mesh: AbstractMesh, collider: Collider) => ISmartArrayLike<SubMesh>;
  42325. private _activeMeshesFrozen;
  42326. private _skipEvaluateActiveMeshesCompletely;
  42327. /**
  42328. * Use this function to stop evaluating active meshes. The current list will be keep alive between frames
  42329. * @param skipEvaluateActiveMeshes defines an optional boolean indicating that the evaluate active meshes step must be completely skipped
  42330. * @returns the current scene
  42331. */
  42332. freezeActiveMeshes(skipEvaluateActiveMeshes?: boolean): Scene;
  42333. /**
  42334. * Use this function to restart evaluating active meshes on every frame
  42335. * @returns the current scene
  42336. */
  42337. unfreezeActiveMeshes(): Scene;
  42338. private _evaluateActiveMeshes;
  42339. private _activeMesh;
  42340. /**
  42341. * Update the transform matrix to update from the current active camera
  42342. * @param force defines a boolean used to force the update even if cache is up to date
  42343. */
  42344. updateTransformMatrix(force?: boolean): void;
  42345. private _bindFrameBuffer;
  42346. /** @hidden */
  42347. _allowPostProcessClearColor: boolean;
  42348. /** @hidden */
  42349. _renderForCamera(camera: Camera, rigParent?: Camera): void;
  42350. private _processSubCameras;
  42351. private _checkIntersections;
  42352. /** @hidden */
  42353. _advancePhysicsEngineStep(step: number): void;
  42354. /**
  42355. * User updatable function that will return a deterministic frame time when engine is in deterministic lock step mode
  42356. */
  42357. getDeterministicFrameTime: () => number;
  42358. /** @hidden */
  42359. _animate(): void;
  42360. /** Execute all animations (for a frame) */
  42361. animate(): void;
  42362. /**
  42363. * Render the scene
  42364. * @param updateCameras defines a boolean indicating if cameras must update according to their inputs (true by default)
  42365. * @param ignoreAnimations defines a boolean indicating if animations should not be executed (false by default)
  42366. */
  42367. render(updateCameras?: boolean, ignoreAnimations?: boolean): void;
  42368. /**
  42369. * Freeze all materials
  42370. * A frozen material will not be updatable but should be faster to render
  42371. */
  42372. freezeMaterials(): void;
  42373. /**
  42374. * Unfreeze all materials
  42375. * A frozen material will not be updatable but should be faster to render
  42376. */
  42377. unfreezeMaterials(): void;
  42378. /**
  42379. * Releases all held ressources
  42380. */
  42381. dispose(): void;
  42382. /**
  42383. * Gets if the scene is already disposed
  42384. */
  42385. get isDisposed(): boolean;
  42386. /**
  42387. * Call this function to reduce memory footprint of the scene.
  42388. * Vertex buffers will not store CPU data anymore (this will prevent picking, collisions or physics to work correctly)
  42389. */
  42390. clearCachedVertexData(): void;
  42391. /**
  42392. * This function will remove the local cached buffer data from texture.
  42393. * It will save memory but will prevent the texture from being rebuilt
  42394. */
  42395. cleanCachedTextureBuffer(): void;
  42396. /**
  42397. * Get the world extend vectors with an optional filter
  42398. *
  42399. * @param filterPredicate the predicate - which meshes should be included when calculating the world size
  42400. * @returns {{ min: Vector3; max: Vector3 }} min and max vectors
  42401. */
  42402. getWorldExtends(filterPredicate?: (mesh: AbstractMesh) => boolean): {
  42403. min: Vector3;
  42404. max: Vector3;
  42405. };
  42406. /**
  42407. * Creates a ray that can be used to pick in the scene
  42408. * @param x defines the x coordinate of the origin (on-screen)
  42409. * @param y defines the y coordinate of the origin (on-screen)
  42410. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  42411. * @param camera defines the camera to use for the picking
  42412. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  42413. * @returns a Ray
  42414. */
  42415. createPickingRay(x: number, y: number, world: Matrix, camera: Nullable<Camera>, cameraViewSpace?: boolean): Ray;
  42416. /**
  42417. * Creates a ray that can be used to pick in the scene
  42418. * @param x defines the x coordinate of the origin (on-screen)
  42419. * @param y defines the y coordinate of the origin (on-screen)
  42420. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  42421. * @param result defines the ray where to store the picking ray
  42422. * @param camera defines the camera to use for the picking
  42423. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  42424. * @returns the current scene
  42425. */
  42426. createPickingRayToRef(x: number, y: number, world: Matrix, result: Ray, camera: Nullable<Camera>, cameraViewSpace?: boolean): Scene;
  42427. /**
  42428. * Creates a ray that can be used to pick in the scene
  42429. * @param x defines the x coordinate of the origin (on-screen)
  42430. * @param y defines the y coordinate of the origin (on-screen)
  42431. * @param camera defines the camera to use for the picking
  42432. * @returns a Ray
  42433. */
  42434. createPickingRayInCameraSpace(x: number, y: number, camera?: Camera): Ray;
  42435. /**
  42436. * Creates a ray that can be used to pick in the scene
  42437. * @param x defines the x coordinate of the origin (on-screen)
  42438. * @param y defines the y coordinate of the origin (on-screen)
  42439. * @param result defines the ray where to store the picking ray
  42440. * @param camera defines the camera to use for the picking
  42441. * @returns the current scene
  42442. */
  42443. createPickingRayInCameraSpaceToRef(x: number, y: number, result: Ray, camera?: Camera): Scene;
  42444. /** Launch a ray to try to pick a mesh in the scene
  42445. * @param x position on screen
  42446. * @param y position on screen
  42447. * @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
  42448. * @param fastCheck defines if the first intersection will be used (and not the closest)
  42449. * @param camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  42450. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  42451. * @returns a PickingInfo
  42452. */
  42453. pick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, camera?: Nullable<Camera>, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  42454. /** Launch a ray to try to pick a mesh in the scene using only bounding information of the main mesh (not using submeshes)
  42455. * @param x position on screen
  42456. * @param y position on screen
  42457. * @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
  42458. * @param fastCheck defines if the first intersection will be used (and not the closest)
  42459. * @param camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  42460. * @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)
  42461. */
  42462. pickWithBoundingInfo(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, camera?: Nullable<Camera>): Nullable<PickingInfo>;
  42463. /** Use the given ray to pick a mesh in the scene
  42464. * @param ray The ray to use to pick meshes
  42465. * @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
  42466. * @param fastCheck defines if the first intersection will be used (and not the closest)
  42467. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  42468. * @returns a PickingInfo
  42469. */
  42470. pickWithRay(ray: Ray, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  42471. /**
  42472. * Launch a ray to try to pick a mesh in the scene
  42473. * @param x X position on screen
  42474. * @param y Y position on screen
  42475. * @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
  42476. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  42477. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  42478. * @returns an array of PickingInfo
  42479. */
  42480. multiPick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, camera?: Camera, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  42481. /**
  42482. * Launch a ray to try to pick a mesh in the scene
  42483. * @param ray Ray to use
  42484. * @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
  42485. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  42486. * @returns an array of PickingInfo
  42487. */
  42488. multiPickWithRay(ray: Ray, predicate: (mesh: AbstractMesh) => boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  42489. /**
  42490. * Force the value of meshUnderPointer
  42491. * @param mesh defines the mesh to use
  42492. * @param pointerId optional pointer id when using more than one pointer
  42493. */
  42494. setPointerOverMesh(mesh: Nullable<AbstractMesh>, pointerId?: number): void;
  42495. /**
  42496. * Gets the mesh under the pointer
  42497. * @returns a Mesh or null if no mesh is under the pointer
  42498. */
  42499. getPointerOverMesh(): Nullable<AbstractMesh>;
  42500. /** @hidden */
  42501. _rebuildGeometries(): void;
  42502. /** @hidden */
  42503. _rebuildTextures(): void;
  42504. private _getByTags;
  42505. /**
  42506. * Get a list of meshes by tags
  42507. * @param tagsQuery defines the tags query to use
  42508. * @param forEach defines a predicate used to filter results
  42509. * @returns an array of Mesh
  42510. */
  42511. getMeshesByTags(tagsQuery: string, forEach?: (mesh: AbstractMesh) => void): Mesh[];
  42512. /**
  42513. * Get a list of cameras 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 Camera
  42517. */
  42518. getCamerasByTags(tagsQuery: string, forEach?: (camera: Camera) => void): Camera[];
  42519. /**
  42520. * Get a list of lights 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 Light
  42524. */
  42525. getLightsByTags(tagsQuery: string, forEach?: (light: Light) => void): Light[];
  42526. /**
  42527. * Get a list of materials 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 Material
  42531. */
  42532. getMaterialByTags(tagsQuery: string, forEach?: (material: Material) => void): Material[];
  42533. /**
  42534. * Get a list of transform nodes 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 TransformNode
  42538. */
  42539. getTransformNodesByTags(tagsQuery: string, forEach?: (transform: TransformNode) => void): TransformNode[];
  42540. /**
  42541. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  42542. * This allowed control for front to back rendering or reversly depending of the special needs.
  42543. *
  42544. * @param renderingGroupId The rendering group id corresponding to its index
  42545. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  42546. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  42547. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  42548. */
  42549. 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;
  42550. /**
  42551. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  42552. *
  42553. * @param renderingGroupId The rendering group id corresponding to its index
  42554. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  42555. * @param depth Automatically clears depth between groups if true and autoClear is true.
  42556. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  42557. */
  42558. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  42559. /**
  42560. * Gets the current auto clear configuration for one rendering group of the rendering
  42561. * manager.
  42562. * @param index the rendering group index to get the information for
  42563. * @returns The auto clear setup for the requested rendering group
  42564. */
  42565. getAutoClearDepthStencilSetup(index: number): IRenderingManagerAutoClearSetup;
  42566. private _blockMaterialDirtyMechanism;
  42567. /** Gets or sets a boolean blocking all the calls to markAllMaterialsAsDirty (ie. the materials won't be updated if they are out of sync) */
  42568. get blockMaterialDirtyMechanism(): boolean;
  42569. set blockMaterialDirtyMechanism(value: boolean);
  42570. /**
  42571. * Will flag all materials as dirty to trigger new shader compilation
  42572. * @param flag defines the flag used to specify which material part must be marked as dirty
  42573. * @param predicate If not null, it will be used to specifiy if a material has to be marked as dirty
  42574. */
  42575. markAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  42576. /** @hidden */
  42577. _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;
  42578. /** @hidden */
  42579. _loadFileAsync(url: string, onProgress?: (data: any) => void, useOfflineSupport?: boolean, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  42580. /** @hidden */
  42581. _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;
  42582. /** @hidden */
  42583. _requestFileAsync(url: string, onProgress?: (ev: ProgressEvent) => void, useOfflineSupport?: boolean, useArrayBuffer?: boolean, onOpened?: (request: WebRequest) => void): Promise<string | ArrayBuffer>;
  42584. /** @hidden */
  42585. _readFile(file: File, onSuccess: (data: string | ArrayBuffer) => void, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: ReadFileError) => void): IFileRequest;
  42586. /** @hidden */
  42587. _readFileAsync(file: File, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  42588. }
  42589. }
  42590. declare module "babylonjs/assetContainer" {
  42591. import { AbstractScene } from "babylonjs/abstractScene";
  42592. import { Scene } from "babylonjs/scene";
  42593. import { Mesh } from "babylonjs/Meshes/mesh";
  42594. import { TransformNode } from "babylonjs/Meshes/transformNode";
  42595. import { Skeleton } from "babylonjs/Bones/skeleton";
  42596. import { AnimationGroup } from "babylonjs/Animations/animationGroup";
  42597. import { Animatable } from "babylonjs/Animations/animatable";
  42598. import { Nullable } from "babylonjs/types";
  42599. import { Node } from "babylonjs/node";
  42600. /**
  42601. * Set of assets to keep when moving a scene into an asset container.
  42602. */
  42603. export class KeepAssets extends AbstractScene {
  42604. }
  42605. /**
  42606. * Class used to store the output of the AssetContainer.instantiateAllMeshesToScene function
  42607. */
  42608. export class InstantiatedEntries {
  42609. /**
  42610. * List of new root nodes (eg. nodes with no parent)
  42611. */
  42612. rootNodes: TransformNode[];
  42613. /**
  42614. * List of new skeletons
  42615. */
  42616. skeletons: Skeleton[];
  42617. /**
  42618. * List of new animation groups
  42619. */
  42620. animationGroups: AnimationGroup[];
  42621. }
  42622. /**
  42623. * Container with a set of assets that can be added or removed from a scene.
  42624. */
  42625. export class AssetContainer extends AbstractScene {
  42626. private _wasAddedToScene;
  42627. /**
  42628. * The scene the AssetContainer belongs to.
  42629. */
  42630. scene: Scene;
  42631. /**
  42632. * Instantiates an AssetContainer.
  42633. * @param scene The scene the AssetContainer belongs to.
  42634. */
  42635. constructor(scene: Scene);
  42636. /**
  42637. * Instantiate or clone all meshes and add the new ones to the scene.
  42638. * Skeletons and animation groups will all be cloned
  42639. * @param nameFunction defines an optional function used to get new names for clones
  42640. * @param cloneMaterials defines an optional boolean that defines if materials must be cloned as well (false by default)
  42641. * @returns a list of rootNodes, skeletons and aniamtion groups that were duplicated
  42642. */
  42643. instantiateModelsToScene(nameFunction?: (sourceName: string) => string, cloneMaterials?: boolean): InstantiatedEntries;
  42644. /**
  42645. * Adds all the assets from the container to the scene.
  42646. */
  42647. addAllToScene(): void;
  42648. /**
  42649. * Removes all the assets in the container from the scene
  42650. */
  42651. removeAllFromScene(): void;
  42652. /**
  42653. * Disposes all the assets in the container
  42654. */
  42655. dispose(): void;
  42656. private _moveAssets;
  42657. /**
  42658. * Removes all the assets contained in the scene and adds them to the container.
  42659. * @param keepAssets Set of assets to keep in the scene. (default: empty)
  42660. */
  42661. moveAllFromScene(keepAssets?: KeepAssets): void;
  42662. /**
  42663. * 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.
  42664. * @returns the root mesh
  42665. */
  42666. createRootMesh(): Mesh;
  42667. /**
  42668. * Merge animations (direct and animation groups) from this asset container into a scene
  42669. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  42670. * @param animatables set of animatables to retarget to a node from the scene
  42671. * @param targetConverter defines a function used to convert animation targets from the asset container to the scene (default: search node by name)
  42672. * @returns an array of the new AnimationGroup added to the scene (empty array if none)
  42673. */
  42674. mergeAnimationsTo(scene: Scene | null | undefined, animatables: Animatable[], targetConverter?: Nullable<(target: any) => Nullable<Node>>): AnimationGroup[];
  42675. }
  42676. }
  42677. declare module "babylonjs/abstractScene" {
  42678. import { Scene } from "babylonjs/scene";
  42679. import { Nullable } from "babylonjs/types";
  42680. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  42681. import { TransformNode } from "babylonjs/Meshes/transformNode";
  42682. import { Geometry } from "babylonjs/Meshes/geometry";
  42683. import { Skeleton } from "babylonjs/Bones/skeleton";
  42684. import { MorphTargetManager } from "babylonjs/Morph/morphTargetManager";
  42685. import { AssetContainer } from "babylonjs/assetContainer";
  42686. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  42687. import { AnimationGroup } from "babylonjs/Animations/animationGroup";
  42688. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  42689. import { Material } from "babylonjs/Materials/material";
  42690. import { MultiMaterial } from "babylonjs/Materials/multiMaterial";
  42691. import { AbstractActionManager } from "babylonjs/Actions/abstractActionManager";
  42692. import { Camera } from "babylonjs/Cameras/camera";
  42693. import { Light } from "babylonjs/Lights/light";
  42694. import { Node } from "babylonjs/node";
  42695. import { Animation } from "babylonjs/Animations/animation";
  42696. /**
  42697. * Defines how the parser contract is defined.
  42698. * These parsers are used to parse a list of specific assets (like particle systems, etc..)
  42699. */
  42700. export type BabylonFileParser = (parsedData: any, scene: Scene, container: AssetContainer, rootUrl: string) => void;
  42701. /**
  42702. * Defines how the individual parser contract is defined.
  42703. * These parser can parse an individual asset
  42704. */
  42705. export type IndividualBabylonFileParser = (parsedData: any, scene: Scene, rootUrl: string) => any;
  42706. /**
  42707. * Base class of the scene acting as a container for the different elements composing a scene.
  42708. * This class is dynamically extended by the different components of the scene increasing
  42709. * flexibility and reducing coupling
  42710. */
  42711. export abstract class AbstractScene {
  42712. /**
  42713. * Stores the list of available parsers in the application.
  42714. */
  42715. private static _BabylonFileParsers;
  42716. /**
  42717. * Stores the list of available individual parsers in the application.
  42718. */
  42719. private static _IndividualBabylonFileParsers;
  42720. /**
  42721. * Adds a parser in the list of available ones
  42722. * @param name Defines the name of the parser
  42723. * @param parser Defines the parser to add
  42724. */
  42725. static AddParser(name: string, parser: BabylonFileParser): void;
  42726. /**
  42727. * Gets a general parser from the list of avaialble ones
  42728. * @param name Defines the name of the parser
  42729. * @returns the requested parser or null
  42730. */
  42731. static GetParser(name: string): Nullable<BabylonFileParser>;
  42732. /**
  42733. * Adds n individual parser in the list of available ones
  42734. * @param name Defines the name of the parser
  42735. * @param parser Defines the parser to add
  42736. */
  42737. static AddIndividualParser(name: string, parser: IndividualBabylonFileParser): void;
  42738. /**
  42739. * Gets an individual parser from the list of avaialble ones
  42740. * @param name Defines the name of the parser
  42741. * @returns the requested parser or null
  42742. */
  42743. static GetIndividualParser(name: string): Nullable<IndividualBabylonFileParser>;
  42744. /**
  42745. * Parser json data and populate both a scene and its associated container object
  42746. * @param jsonData Defines the data to parse
  42747. * @param scene Defines the scene to parse the data for
  42748. * @param container Defines the container attached to the parsing sequence
  42749. * @param rootUrl Defines the root url of the data
  42750. */
  42751. static Parse(jsonData: any, scene: Scene, container: AssetContainer, rootUrl: string): void;
  42752. /**
  42753. * Gets the list of root nodes (ie. nodes with no parent)
  42754. */
  42755. rootNodes: Node[];
  42756. /** All of the cameras added to this scene
  42757. * @see https://doc.babylonjs.com/babylon101/cameras
  42758. */
  42759. cameras: Camera[];
  42760. /**
  42761. * All of the lights added to this scene
  42762. * @see https://doc.babylonjs.com/babylon101/lights
  42763. */
  42764. lights: Light[];
  42765. /**
  42766. * All of the (abstract) meshes added to this scene
  42767. */
  42768. meshes: AbstractMesh[];
  42769. /**
  42770. * The list of skeletons added to the scene
  42771. * @see https://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  42772. */
  42773. skeletons: Skeleton[];
  42774. /**
  42775. * All of the particle systems added to this scene
  42776. * @see https://doc.babylonjs.com/babylon101/particles
  42777. */
  42778. particleSystems: IParticleSystem[];
  42779. /**
  42780. * Gets a list of Animations associated with the scene
  42781. */
  42782. animations: Animation[];
  42783. /**
  42784. * All of the animation groups added to this scene
  42785. * @see https://doc.babylonjs.com/how_to/group
  42786. */
  42787. animationGroups: AnimationGroup[];
  42788. /**
  42789. * All of the multi-materials added to this scene
  42790. * @see https://doc.babylonjs.com/how_to/multi_materials
  42791. */
  42792. multiMaterials: MultiMaterial[];
  42793. /**
  42794. * All of the materials added to this scene
  42795. * In the context of a Scene, it is not supposed to be modified manually.
  42796. * Any addition or removal should be done using the addMaterial and removeMaterial Scene methods.
  42797. * Note also that the order of the Material within the array is not significant and might change.
  42798. * @see https://doc.babylonjs.com/babylon101/materials
  42799. */
  42800. materials: Material[];
  42801. /**
  42802. * The list of morph target managers added to the scene
  42803. * @see https://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh
  42804. */
  42805. morphTargetManagers: MorphTargetManager[];
  42806. /**
  42807. * The list of geometries used in the scene.
  42808. */
  42809. geometries: Geometry[];
  42810. /**
  42811. * All of the tranform nodes added to this scene
  42812. * In the context of a Scene, it is not supposed to be modified manually.
  42813. * Any addition or removal should be done using the addTransformNode and removeTransformNode Scene methods.
  42814. * Note also that the order of the TransformNode wihin the array is not significant and might change.
  42815. * @see https://doc.babylonjs.com/how_to/transformnode
  42816. */
  42817. transformNodes: TransformNode[];
  42818. /**
  42819. * ActionManagers available on the scene.
  42820. */
  42821. actionManagers: AbstractActionManager[];
  42822. /**
  42823. * Textures to keep.
  42824. */
  42825. textures: BaseTexture[];
  42826. /** @hidden */
  42827. protected _environmentTexture: Nullable<BaseTexture>;
  42828. /**
  42829. * Texture used in all pbr material as the reflection texture.
  42830. * As in the majority of the scene they are the same (exception for multi room and so on),
  42831. * this is easier to reference from here than from all the materials.
  42832. */
  42833. get environmentTexture(): Nullable<BaseTexture>;
  42834. set environmentTexture(value: Nullable<BaseTexture>);
  42835. /**
  42836. * The list of postprocesses added to the scene
  42837. */
  42838. postProcesses: import("babylonjs/PostProcesses/postProcess").PostProcess[];
  42839. /**
  42840. * @returns all meshes, lights, cameras, transformNodes and bones
  42841. */
  42842. getNodes(): Array<Node>;
  42843. }
  42844. }
  42845. declare module "babylonjs/Audio/sound" {
  42846. import { Observable } from "babylonjs/Misc/observable";
  42847. import { Vector3 } from "babylonjs/Maths/math.vector";
  42848. import { Nullable } from "babylonjs/types";
  42849. import { Scene } from "babylonjs/scene";
  42850. import { TransformNode } from "babylonjs/Meshes/transformNode";
  42851. /**
  42852. * Interface used to define options for Sound class
  42853. */
  42854. export interface ISoundOptions {
  42855. /**
  42856. * Does the sound autoplay once loaded.
  42857. */
  42858. autoplay?: boolean;
  42859. /**
  42860. * Does the sound loop after it finishes playing once.
  42861. */
  42862. loop?: boolean;
  42863. /**
  42864. * Sound's volume
  42865. */
  42866. volume?: number;
  42867. /**
  42868. * Is it a spatial sound?
  42869. */
  42870. spatialSound?: boolean;
  42871. /**
  42872. * Maximum distance to hear that sound
  42873. */
  42874. maxDistance?: number;
  42875. /**
  42876. * Uses user defined attenuation function
  42877. */
  42878. useCustomAttenuation?: boolean;
  42879. /**
  42880. * Define the roll off factor of spatial sounds.
  42881. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  42882. */
  42883. rolloffFactor?: number;
  42884. /**
  42885. * Define the reference distance the sound should be heard perfectly.
  42886. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  42887. */
  42888. refDistance?: number;
  42889. /**
  42890. * Define the distance attenuation model the sound will follow.
  42891. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  42892. */
  42893. distanceModel?: string;
  42894. /**
  42895. * Defines the playback speed (1 by default)
  42896. */
  42897. playbackRate?: number;
  42898. /**
  42899. * Defines if the sound is from a streaming source
  42900. */
  42901. streaming?: boolean;
  42902. /**
  42903. * Defines an optional length (in seconds) inside the sound file
  42904. */
  42905. length?: number;
  42906. /**
  42907. * Defines an optional offset (in seconds) inside the sound file
  42908. */
  42909. offset?: number;
  42910. /**
  42911. * If true, URLs will not be required to state the audio file codec to use.
  42912. */
  42913. skipCodecCheck?: boolean;
  42914. }
  42915. /**
  42916. * Defines a sound that can be played in the application.
  42917. * The sound can either be an ambient track or a simple sound played in reaction to a user action.
  42918. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  42919. */
  42920. export class Sound {
  42921. /**
  42922. * The name of the sound in the scene.
  42923. */
  42924. name: string;
  42925. /**
  42926. * Does the sound autoplay once loaded.
  42927. */
  42928. autoplay: boolean;
  42929. /**
  42930. * Does the sound loop after it finishes playing once.
  42931. */
  42932. loop: boolean;
  42933. /**
  42934. * Does the sound use a custom attenuation curve to simulate the falloff
  42935. * happening when the source gets further away from the camera.
  42936. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function
  42937. */
  42938. useCustomAttenuation: boolean;
  42939. /**
  42940. * The sound track id this sound belongs to.
  42941. */
  42942. soundTrackId: number;
  42943. /**
  42944. * Is this sound currently played.
  42945. */
  42946. isPlaying: boolean;
  42947. /**
  42948. * Is this sound currently paused.
  42949. */
  42950. isPaused: boolean;
  42951. /**
  42952. * Does this sound enables spatial sound.
  42953. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  42954. */
  42955. spatialSound: boolean;
  42956. /**
  42957. * Define the reference distance the sound should be heard perfectly.
  42958. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  42959. */
  42960. refDistance: number;
  42961. /**
  42962. * Define the roll off factor of spatial sounds.
  42963. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  42964. */
  42965. rolloffFactor: number;
  42966. /**
  42967. * Define the max distance the sound should be heard (intensity just became 0 at this point).
  42968. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  42969. */
  42970. maxDistance: number;
  42971. /**
  42972. * Define the distance attenuation model the sound will follow.
  42973. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  42974. */
  42975. distanceModel: string;
  42976. /**
  42977. * @hidden
  42978. * Back Compat
  42979. **/
  42980. onended: () => any;
  42981. /**
  42982. * Gets or sets an object used to store user defined information for the sound.
  42983. */
  42984. metadata: any;
  42985. /**
  42986. * Observable event when the current playing sound finishes.
  42987. */
  42988. onEndedObservable: Observable<Sound>;
  42989. private _panningModel;
  42990. private _playbackRate;
  42991. private _streaming;
  42992. private _startTime;
  42993. private _startOffset;
  42994. private _position;
  42995. /** @hidden */
  42996. _positionInEmitterSpace: boolean;
  42997. private _localDirection;
  42998. private _volume;
  42999. private _isReadyToPlay;
  43000. private _isDirectional;
  43001. private _readyToPlayCallback;
  43002. private _audioBuffer;
  43003. private _soundSource;
  43004. private _streamingSource;
  43005. private _soundPanner;
  43006. private _soundGain;
  43007. private _inputAudioNode;
  43008. private _outputAudioNode;
  43009. private _coneInnerAngle;
  43010. private _coneOuterAngle;
  43011. private _coneOuterGain;
  43012. private _scene;
  43013. private _connectedTransformNode;
  43014. private _customAttenuationFunction;
  43015. private _registerFunc;
  43016. private _isOutputConnected;
  43017. private _htmlAudioElement;
  43018. private _urlType;
  43019. private _length?;
  43020. private _offset?;
  43021. /** @hidden */
  43022. static _SceneComponentInitialization: (scene: Scene) => void;
  43023. /**
  43024. * Create a sound and attach it to a scene
  43025. * @param name Name of your sound
  43026. * @param urlOrArrayBuffer Url to the sound to load async or ArrayBuffer, it also works with MediaStreams
  43027. * @param scene defines the scene the sound belongs to
  43028. * @param readyToPlayCallback Provide a callback function if you'd like to load your code once the sound is ready to be played
  43029. * @param options Objects to provide with the current available options: autoplay, loop, volume, spatialSound, maxDistance, rolloffFactor, refDistance, distanceModel, panningModel, streaming
  43030. */
  43031. constructor(name: string, urlOrArrayBuffer: any, scene: Scene, readyToPlayCallback?: Nullable<() => void>, options?: ISoundOptions);
  43032. /**
  43033. * Release the sound and its associated resources
  43034. */
  43035. dispose(): void;
  43036. /**
  43037. * Gets if the sounds is ready to be played or not.
  43038. * @returns true if ready, otherwise false
  43039. */
  43040. isReady(): boolean;
  43041. private _soundLoaded;
  43042. /**
  43043. * Sets the data of the sound from an audiobuffer
  43044. * @param audioBuffer The audioBuffer containing the data
  43045. */
  43046. setAudioBuffer(audioBuffer: AudioBuffer): void;
  43047. /**
  43048. * Updates the current sounds options such as maxdistance, loop...
  43049. * @param options A JSON object containing values named as the object properties
  43050. */
  43051. updateOptions(options: ISoundOptions): void;
  43052. private _createSpatialParameters;
  43053. private _updateSpatialParameters;
  43054. /**
  43055. * Switch the panning model to HRTF:
  43056. * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
  43057. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  43058. */
  43059. switchPanningModelToHRTF(): void;
  43060. /**
  43061. * Switch the panning model to Equal Power:
  43062. * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
  43063. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  43064. */
  43065. switchPanningModelToEqualPower(): void;
  43066. private _switchPanningModel;
  43067. /**
  43068. * Connect this sound to a sound track audio node like gain...
  43069. * @param soundTrackAudioNode the sound track audio node to connect to
  43070. */
  43071. connectToSoundTrackAudioNode(soundTrackAudioNode: AudioNode): void;
  43072. /**
  43073. * Transform this sound into a directional source
  43074. * @param coneInnerAngle Size of the inner cone in degree
  43075. * @param coneOuterAngle Size of the outer cone in degree
  43076. * @param coneOuterGain Volume of the sound outside the outer cone (between 0.0 and 1.0)
  43077. */
  43078. setDirectionalCone(coneInnerAngle: number, coneOuterAngle: number, coneOuterGain: number): void;
  43079. /**
  43080. * Gets or sets the inner angle for the directional cone.
  43081. */
  43082. get directionalConeInnerAngle(): number;
  43083. /**
  43084. * Gets or sets the inner angle for the directional cone.
  43085. */
  43086. set directionalConeInnerAngle(value: number);
  43087. /**
  43088. * Gets or sets the outer angle for the directional cone.
  43089. */
  43090. get directionalConeOuterAngle(): number;
  43091. /**
  43092. * Gets or sets the outer angle for the directional cone.
  43093. */
  43094. set directionalConeOuterAngle(value: number);
  43095. /**
  43096. * Sets the position of the emitter if spatial sound is enabled
  43097. * @param newPosition Defines the new posisiton
  43098. */
  43099. setPosition(newPosition: Vector3): void;
  43100. /**
  43101. * Sets the local direction of the emitter if spatial sound is enabled
  43102. * @param newLocalDirection Defines the new local direction
  43103. */
  43104. setLocalDirectionToMesh(newLocalDirection: Vector3): void;
  43105. private _updateDirection;
  43106. /** @hidden */
  43107. updateDistanceFromListener(): void;
  43108. /**
  43109. * Sets a new custom attenuation function for the sound.
  43110. * @param callback Defines the function used for the attenuation
  43111. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function
  43112. */
  43113. setAttenuationFunction(callback: (currentVolume: number, currentDistance: number, maxDistance: number, refDistance: number, rolloffFactor: number) => number): void;
  43114. /**
  43115. * Play the sound
  43116. * @param time (optional) Start the sound after X seconds. Start immediately (0) by default.
  43117. * @param offset (optional) Start the sound at a specific time in seconds
  43118. * @param length (optional) Sound duration (in seconds)
  43119. */
  43120. play(time?: number, offset?: number, length?: number): void;
  43121. private _onended;
  43122. /**
  43123. * Stop the sound
  43124. * @param time (optional) Stop the sound after X seconds. Stop immediately (0) by default.
  43125. */
  43126. stop(time?: number): void;
  43127. /**
  43128. * Put the sound in pause
  43129. */
  43130. pause(): void;
  43131. /**
  43132. * Sets a dedicated volume for this sounds
  43133. * @param newVolume Define the new volume of the sound
  43134. * @param time Define time for gradual change to new volume
  43135. */
  43136. setVolume(newVolume: number, time?: number): void;
  43137. /**
  43138. * Set the sound play back rate
  43139. * @param newPlaybackRate Define the playback rate the sound should be played at
  43140. */
  43141. setPlaybackRate(newPlaybackRate: number): void;
  43142. /**
  43143. * Gets the volume of the sound.
  43144. * @returns the volume of the sound
  43145. */
  43146. getVolume(): number;
  43147. /**
  43148. * Attach the sound to a dedicated mesh
  43149. * @param transformNode The transform node to connect the sound with
  43150. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh
  43151. */
  43152. attachToMesh(transformNode: TransformNode): void;
  43153. /**
  43154. * Detach the sound from the previously attached mesh
  43155. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh
  43156. */
  43157. detachFromMesh(): void;
  43158. private _onRegisterAfterWorldMatrixUpdate;
  43159. /**
  43160. * Clone the current sound in the scene.
  43161. * @returns the new sound clone
  43162. */
  43163. clone(): Nullable<Sound>;
  43164. /**
  43165. * Gets the current underlying audio buffer containing the data
  43166. * @returns the audio buffer
  43167. */
  43168. getAudioBuffer(): Nullable<AudioBuffer>;
  43169. /**
  43170. * Gets the WebAudio AudioBufferSourceNode, lets you keep track of and stop instances of this Sound.
  43171. * @returns the source node
  43172. */
  43173. getSoundSource(): Nullable<AudioBufferSourceNode>;
  43174. /**
  43175. * Gets the WebAudio GainNode, gives you precise control over the gain of instances of this Sound.
  43176. * @returns the gain node
  43177. */
  43178. getSoundGain(): Nullable<GainNode>;
  43179. /**
  43180. * Serializes the Sound in a JSON representation
  43181. * @returns the JSON representation of the sound
  43182. */
  43183. serialize(): any;
  43184. /**
  43185. * Parse a JSON representation of a sound to innstantiate in a given scene
  43186. * @param parsedSound Define the JSON representation of the sound (usually coming from the serialize method)
  43187. * @param scene Define the scene the new parsed sound should be created in
  43188. * @param rootUrl Define the rooturl of the load in case we need to fetch relative dependencies
  43189. * @param sourceSound Define a cound place holder if do not need to instantiate a new one
  43190. * @returns the newly parsed sound
  43191. */
  43192. static Parse(parsedSound: any, scene: Scene, rootUrl: string, sourceSound?: Sound): Sound;
  43193. }
  43194. }
  43195. declare module "babylonjs/Actions/directAudioActions" {
  43196. import { Action } from "babylonjs/Actions/action";
  43197. import { Condition } from "babylonjs/Actions/condition";
  43198. import { Sound } from "babylonjs/Audio/sound";
  43199. /**
  43200. * This defines an action helpful to play a defined sound on a triggered action.
  43201. */
  43202. export class PlaySoundAction extends Action {
  43203. private _sound;
  43204. /**
  43205. * Instantiate the action
  43206. * @param triggerOptions defines the trigger options
  43207. * @param sound defines the sound to play
  43208. * @param condition defines the trigger related conditions
  43209. */
  43210. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  43211. /** @hidden */
  43212. _prepare(): void;
  43213. /**
  43214. * Execute the action and play the sound.
  43215. */
  43216. execute(): void;
  43217. /**
  43218. * Serializes the actions and its related information.
  43219. * @param parent defines the object to serialize in
  43220. * @returns the serialized object
  43221. */
  43222. serialize(parent: any): any;
  43223. }
  43224. /**
  43225. * This defines an action helpful to stop a defined sound on a triggered action.
  43226. */
  43227. export class StopSoundAction extends Action {
  43228. private _sound;
  43229. /**
  43230. * Instantiate the action
  43231. * @param triggerOptions defines the trigger options
  43232. * @param sound defines the sound to stop
  43233. * @param condition defines the trigger related conditions
  43234. */
  43235. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  43236. /** @hidden */
  43237. _prepare(): void;
  43238. /**
  43239. * Execute the action and stop the sound.
  43240. */
  43241. execute(): void;
  43242. /**
  43243. * Serializes the actions and its related information.
  43244. * @param parent defines the object to serialize in
  43245. * @returns the serialized object
  43246. */
  43247. serialize(parent: any): any;
  43248. }
  43249. }
  43250. declare module "babylonjs/Actions/interpolateValueAction" {
  43251. import { Action } from "babylonjs/Actions/action";
  43252. import { Condition } from "babylonjs/Actions/condition";
  43253. import { Observable } from "babylonjs/Misc/observable";
  43254. /**
  43255. * This defines an action responsible to change the value of a property
  43256. * by interpolating between its current value and the newly set one once triggered.
  43257. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  43258. */
  43259. export class InterpolateValueAction extends Action {
  43260. /**
  43261. * Defines the path of the property where the value should be interpolated
  43262. */
  43263. propertyPath: string;
  43264. /**
  43265. * Defines the target value at the end of the interpolation.
  43266. */
  43267. value: any;
  43268. /**
  43269. * Defines the time it will take for the property to interpolate to the value.
  43270. */
  43271. duration: number;
  43272. /**
  43273. * Defines if the other scene animations should be stopped when the action has been triggered
  43274. */
  43275. stopOtherAnimations?: boolean;
  43276. /**
  43277. * Defines a callback raised once the interpolation animation has been done.
  43278. */
  43279. onInterpolationDone?: () => void;
  43280. /**
  43281. * Observable triggered once the interpolation animation has been done.
  43282. */
  43283. onInterpolationDoneObservable: Observable<InterpolateValueAction>;
  43284. private _target;
  43285. private _effectiveTarget;
  43286. private _property;
  43287. /**
  43288. * Instantiate the action
  43289. * @param triggerOptions defines the trigger options
  43290. * @param target defines the object containing the value to interpolate
  43291. * @param propertyPath defines the path to the property in the target object
  43292. * @param value defines the target value at the end of the interpolation
  43293. * @param duration deines the time it will take for the property to interpolate to the value.
  43294. * @param condition defines the trigger related conditions
  43295. * @param stopOtherAnimations defines if the other scene animations should be stopped when the action has been triggered
  43296. * @param onInterpolationDone defines a callback raised once the interpolation animation has been done
  43297. */
  43298. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, duration?: number, condition?: Condition, stopOtherAnimations?: boolean, onInterpolationDone?: () => void);
  43299. /** @hidden */
  43300. _prepare(): void;
  43301. /**
  43302. * Execute the action starts the value interpolation.
  43303. */
  43304. execute(): void;
  43305. /**
  43306. * Serializes the actions and its related information.
  43307. * @param parent defines the object to serialize in
  43308. * @returns the serialized object
  43309. */
  43310. serialize(parent: any): any;
  43311. }
  43312. }
  43313. declare module "babylonjs/Actions/index" {
  43314. export * from "babylonjs/Actions/abstractActionManager";
  43315. export * from "babylonjs/Actions/action";
  43316. export * from "babylonjs/Actions/actionEvent";
  43317. export * from "babylonjs/Actions/actionManager";
  43318. export * from "babylonjs/Actions/condition";
  43319. export * from "babylonjs/Actions/directActions";
  43320. export * from "babylonjs/Actions/directAudioActions";
  43321. export * from "babylonjs/Actions/interpolateValueAction";
  43322. }
  43323. declare module "babylonjs/Animations/index" {
  43324. export * from "babylonjs/Animations/animatable";
  43325. export * from "babylonjs/Animations/animation";
  43326. export * from "babylonjs/Animations/animationGroup";
  43327. export * from "babylonjs/Animations/animationPropertiesOverride";
  43328. export * from "babylonjs/Animations/easing";
  43329. export * from "babylonjs/Animations/runtimeAnimation";
  43330. export * from "babylonjs/Animations/animationEvent";
  43331. export * from "babylonjs/Animations/animationGroup";
  43332. export * from "babylonjs/Animations/animationKey";
  43333. export * from "babylonjs/Animations/animationRange";
  43334. export * from "babylonjs/Animations/animatable.interface";
  43335. }
  43336. declare module "babylonjs/Audio/soundTrack" {
  43337. import { Sound } from "babylonjs/Audio/sound";
  43338. import { Analyser } from "babylonjs/Audio/analyser";
  43339. import { Scene } from "babylonjs/scene";
  43340. /**
  43341. * Options allowed during the creation of a sound track.
  43342. */
  43343. export interface ISoundTrackOptions {
  43344. /**
  43345. * The volume the sound track should take during creation
  43346. */
  43347. volume?: number;
  43348. /**
  43349. * Define if the sound track is the main sound track of the scene
  43350. */
  43351. mainTrack?: boolean;
  43352. }
  43353. /**
  43354. * It could be useful to isolate your music & sounds on several tracks to better manage volume on a grouped instance of sounds.
  43355. * It will be also used in a future release to apply effects on a specific track.
  43356. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks
  43357. */
  43358. export class SoundTrack {
  43359. /**
  43360. * The unique identifier of the sound track in the scene.
  43361. */
  43362. id: number;
  43363. /**
  43364. * The list of sounds included in the sound track.
  43365. */
  43366. soundCollection: Array<Sound>;
  43367. private _outputAudioNode;
  43368. private _scene;
  43369. private _connectedAnalyser;
  43370. private _options;
  43371. private _isInitialized;
  43372. /**
  43373. * Creates a new sound track.
  43374. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks
  43375. * @param scene Define the scene the sound track belongs to
  43376. * @param options
  43377. */
  43378. constructor(scene: Scene, options?: ISoundTrackOptions);
  43379. private _initializeSoundTrackAudioGraph;
  43380. /**
  43381. * Release the sound track and its associated resources
  43382. */
  43383. dispose(): void;
  43384. /**
  43385. * Adds a sound to this sound track
  43386. * @param sound define the cound to add
  43387. * @ignoreNaming
  43388. */
  43389. AddSound(sound: Sound): void;
  43390. /**
  43391. * Removes a sound to this sound track
  43392. * @param sound define the cound to remove
  43393. * @ignoreNaming
  43394. */
  43395. RemoveSound(sound: Sound): void;
  43396. /**
  43397. * Set a global volume for the full sound track.
  43398. * @param newVolume Define the new volume of the sound track
  43399. */
  43400. setVolume(newVolume: number): void;
  43401. /**
  43402. * Switch the panning model to HRTF:
  43403. * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
  43404. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  43405. */
  43406. switchPanningModelToHRTF(): void;
  43407. /**
  43408. * Switch the panning model to Equal Power:
  43409. * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
  43410. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  43411. */
  43412. switchPanningModelToEqualPower(): void;
  43413. /**
  43414. * Connect the sound track to an audio analyser allowing some amazing
  43415. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  43416. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  43417. * @param analyser The analyser to connect to the engine
  43418. */
  43419. connectToAnalyser(analyser: Analyser): void;
  43420. }
  43421. }
  43422. declare module "babylonjs/Audio/audioSceneComponent" {
  43423. import { Sound } from "babylonjs/Audio/sound";
  43424. import { SoundTrack } from "babylonjs/Audio/soundTrack";
  43425. import { Nullable } from "babylonjs/types";
  43426. import { Vector3 } from "babylonjs/Maths/math.vector";
  43427. import { ISceneSerializableComponent } from "babylonjs/sceneComponent";
  43428. import { Scene } from "babylonjs/scene";
  43429. import { AbstractScene } from "babylonjs/abstractScene";
  43430. import "babylonjs/Audio/audioEngine";
  43431. module "babylonjs/abstractScene" {
  43432. interface AbstractScene {
  43433. /**
  43434. * The list of sounds used in the scene.
  43435. */
  43436. sounds: Nullable<Array<Sound>>;
  43437. }
  43438. }
  43439. module "babylonjs/scene" {
  43440. interface Scene {
  43441. /**
  43442. * @hidden
  43443. * Backing field
  43444. */
  43445. _mainSoundTrack: SoundTrack;
  43446. /**
  43447. * The main sound track played by the scene.
  43448. * It cotains your primary collection of sounds.
  43449. */
  43450. mainSoundTrack: SoundTrack;
  43451. /**
  43452. * The list of sound tracks added to the scene
  43453. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  43454. */
  43455. soundTracks: Nullable<Array<SoundTrack>>;
  43456. /**
  43457. * Gets a sound using a given name
  43458. * @param name defines the name to search for
  43459. * @return the found sound or null if not found at all.
  43460. */
  43461. getSoundByName(name: string): Nullable<Sound>;
  43462. /**
  43463. * Gets or sets if audio support is enabled
  43464. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  43465. */
  43466. audioEnabled: boolean;
  43467. /**
  43468. * Gets or sets if audio will be output to headphones
  43469. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  43470. */
  43471. headphone: boolean;
  43472. /**
  43473. * Gets or sets custom audio listener position provider
  43474. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  43475. */
  43476. audioListenerPositionProvider: Nullable<() => Vector3>;
  43477. /**
  43478. * Gets or sets a refresh rate when using 3D audio positioning
  43479. */
  43480. audioPositioningRefreshRate: number;
  43481. }
  43482. }
  43483. /**
  43484. * Defines the sound scene component responsible to manage any sounds
  43485. * in a given scene.
  43486. */
  43487. export class AudioSceneComponent implements ISceneSerializableComponent {
  43488. private static _CameraDirectionLH;
  43489. private static _CameraDirectionRH;
  43490. /**
  43491. * The component name helpfull to identify the component in the list of scene components.
  43492. */
  43493. readonly name: string;
  43494. /**
  43495. * The scene the component belongs to.
  43496. */
  43497. scene: Scene;
  43498. private _audioEnabled;
  43499. /**
  43500. * Gets whether audio is enabled or not.
  43501. * Please use related enable/disable method to switch state.
  43502. */
  43503. get audioEnabled(): boolean;
  43504. private _headphone;
  43505. /**
  43506. * Gets whether audio is outputing to headphone or not.
  43507. * Please use the according Switch methods to change output.
  43508. */
  43509. get headphone(): boolean;
  43510. /**
  43511. * Gets or sets a refresh rate when using 3D audio positioning
  43512. */
  43513. audioPositioningRefreshRate: number;
  43514. private _audioListenerPositionProvider;
  43515. /**
  43516. * Gets the current audio listener position provider
  43517. */
  43518. get audioListenerPositionProvider(): Nullable<() => Vector3>;
  43519. /**
  43520. * Sets a custom listener position for all sounds in the scene
  43521. * By default, this is the position of the first active camera
  43522. */
  43523. set audioListenerPositionProvider(value: Nullable<() => Vector3>);
  43524. /**
  43525. * Creates a new instance of the component for the given scene
  43526. * @param scene Defines the scene to register the component in
  43527. */
  43528. constructor(scene: Scene);
  43529. /**
  43530. * Registers the component in a given scene
  43531. */
  43532. register(): void;
  43533. /**
  43534. * Rebuilds the elements related to this component in case of
  43535. * context lost for instance.
  43536. */
  43537. rebuild(): void;
  43538. /**
  43539. * Serializes the component data to the specified json object
  43540. * @param serializationObject The object to serialize to
  43541. */
  43542. serialize(serializationObject: any): void;
  43543. /**
  43544. * Adds all the elements from the container to the scene
  43545. * @param container the container holding the elements
  43546. */
  43547. addFromContainer(container: AbstractScene): void;
  43548. /**
  43549. * Removes all the elements in the container from the scene
  43550. * @param container contains the elements to remove
  43551. * @param dispose if the removed element should be disposed (default: false)
  43552. */
  43553. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  43554. /**
  43555. * Disposes the component and the associated ressources.
  43556. */
  43557. dispose(): void;
  43558. /**
  43559. * Disables audio in the associated scene.
  43560. */
  43561. disableAudio(): void;
  43562. /**
  43563. * Enables audio in the associated scene.
  43564. */
  43565. enableAudio(): void;
  43566. /**
  43567. * Switch audio to headphone output.
  43568. */
  43569. switchAudioModeForHeadphones(): void;
  43570. /**
  43571. * Switch audio to normal speakers.
  43572. */
  43573. switchAudioModeForNormalSpeakers(): void;
  43574. private _cachedCameraDirection;
  43575. private _cachedCameraPosition;
  43576. private _lastCheck;
  43577. private _afterRender;
  43578. }
  43579. }
  43580. declare module "babylonjs/Audio/weightedsound" {
  43581. import { Sound } from "babylonjs/Audio/sound";
  43582. /**
  43583. * Wraps one or more Sound objects and selects one with random weight for playback.
  43584. */
  43585. export class WeightedSound {
  43586. /** When true a Sound will be selected and played when the current playing Sound completes. */
  43587. loop: boolean;
  43588. private _coneInnerAngle;
  43589. private _coneOuterAngle;
  43590. private _volume;
  43591. /** A Sound is currently playing. */
  43592. isPlaying: boolean;
  43593. /** A Sound is currently paused. */
  43594. isPaused: boolean;
  43595. private _sounds;
  43596. private _weights;
  43597. private _currentIndex?;
  43598. /**
  43599. * Creates a new WeightedSound from the list of sounds given.
  43600. * @param loop When true a Sound will be selected and played when the current playing Sound completes.
  43601. * @param sounds Array of Sounds that will be selected from.
  43602. * @param weights Array of number values for selection weights; length must equal sounds, values will be normalized to 1
  43603. */
  43604. constructor(loop: boolean, sounds: Sound[], weights: number[]);
  43605. /**
  43606. * The size of cone in degrees for a directional sound in which there will be no attenuation.
  43607. */
  43608. get directionalConeInnerAngle(): number;
  43609. /**
  43610. * The size of cone in degress for a directional sound in which there will be no attenuation.
  43611. */
  43612. set directionalConeInnerAngle(value: number);
  43613. /**
  43614. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  43615. * Listener angles between innerAngle and outerAngle will falloff linearly.
  43616. */
  43617. get directionalConeOuterAngle(): number;
  43618. /**
  43619. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  43620. * Listener angles between innerAngle and outerAngle will falloff linearly.
  43621. */
  43622. set directionalConeOuterAngle(value: number);
  43623. /**
  43624. * Playback volume.
  43625. */
  43626. get volume(): number;
  43627. /**
  43628. * Playback volume.
  43629. */
  43630. set volume(value: number);
  43631. private _onended;
  43632. /**
  43633. * Suspend playback
  43634. */
  43635. pause(): void;
  43636. /**
  43637. * Stop playback
  43638. */
  43639. stop(): void;
  43640. /**
  43641. * Start playback.
  43642. * @param startOffset Position the clip head at a specific time in seconds.
  43643. */
  43644. play(startOffset?: number): void;
  43645. }
  43646. }
  43647. declare module "babylonjs/Audio/index" {
  43648. export * from "babylonjs/Audio/analyser";
  43649. export * from "babylonjs/Audio/audioEngine";
  43650. export * from "babylonjs/Audio/audioSceneComponent";
  43651. export * from "babylonjs/Audio/sound";
  43652. export * from "babylonjs/Audio/soundTrack";
  43653. export * from "babylonjs/Audio/weightedsound";
  43654. }
  43655. declare module "babylonjs/Behaviors/Cameras/bouncingBehavior" {
  43656. import { Behavior } from "babylonjs/Behaviors/behavior";
  43657. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  43658. import { BackEase } from "babylonjs/Animations/easing";
  43659. /**
  43660. * Add a bouncing effect to an ArcRotateCamera when reaching a specified minimum and maximum radius
  43661. * @see https://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  43662. */
  43663. export class BouncingBehavior implements Behavior<ArcRotateCamera> {
  43664. /**
  43665. * Gets the name of the behavior.
  43666. */
  43667. get name(): string;
  43668. /**
  43669. * The easing function used by animations
  43670. */
  43671. static EasingFunction: BackEase;
  43672. /**
  43673. * The easing mode used by animations
  43674. */
  43675. static EasingMode: number;
  43676. /**
  43677. * The duration of the animation, in milliseconds
  43678. */
  43679. transitionDuration: number;
  43680. /**
  43681. * Length of the distance animated by the transition when lower radius is reached
  43682. */
  43683. lowerRadiusTransitionRange: number;
  43684. /**
  43685. * Length of the distance animated by the transition when upper radius is reached
  43686. */
  43687. upperRadiusTransitionRange: number;
  43688. private _autoTransitionRange;
  43689. /**
  43690. * Gets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  43691. */
  43692. get autoTransitionRange(): boolean;
  43693. /**
  43694. * Sets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  43695. * Transition ranges will be set to 5% of the bounding box diagonal in world space
  43696. */
  43697. set autoTransitionRange(value: boolean);
  43698. private _attachedCamera;
  43699. private _onAfterCheckInputsObserver;
  43700. private _onMeshTargetChangedObserver;
  43701. /**
  43702. * Initializes the behavior.
  43703. */
  43704. init(): void;
  43705. /**
  43706. * Attaches the behavior to its arc rotate camera.
  43707. * @param camera Defines the camera to attach the behavior to
  43708. */
  43709. attach(camera: ArcRotateCamera): void;
  43710. /**
  43711. * Detaches the behavior from its current arc rotate camera.
  43712. */
  43713. detach(): void;
  43714. private _radiusIsAnimating;
  43715. private _radiusBounceTransition;
  43716. private _animatables;
  43717. private _cachedWheelPrecision;
  43718. /**
  43719. * Checks if the camera radius is at the specified limit. Takes into account animation locks.
  43720. * @param radiusLimit The limit to check against.
  43721. * @return Bool to indicate if at limit.
  43722. */
  43723. private _isRadiusAtLimit;
  43724. /**
  43725. * Applies an animation to the radius of the camera, extending by the radiusDelta.
  43726. * @param radiusDelta The delta by which to animate to. Can be negative.
  43727. */
  43728. private _applyBoundRadiusAnimation;
  43729. /**
  43730. * Removes all animation locks. Allows new animations to be added to any of the camera properties.
  43731. */
  43732. protected _clearAnimationLocks(): void;
  43733. /**
  43734. * Stops and removes all animations that have been applied to the camera
  43735. */
  43736. stopAllAnimations(): void;
  43737. }
  43738. }
  43739. declare module "babylonjs/Behaviors/Cameras/framingBehavior" {
  43740. import { Behavior } from "babylonjs/Behaviors/behavior";
  43741. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  43742. import { ExponentialEase } from "babylonjs/Animations/easing";
  43743. import { Nullable } from "babylonjs/types";
  43744. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  43745. import { Vector3 } from "babylonjs/Maths/math.vector";
  43746. /**
  43747. * 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.
  43748. * @see https://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  43749. */
  43750. export class FramingBehavior implements Behavior<ArcRotateCamera> {
  43751. /**
  43752. * Gets the name of the behavior.
  43753. */
  43754. get name(): string;
  43755. private _mode;
  43756. private _radiusScale;
  43757. private _positionScale;
  43758. private _defaultElevation;
  43759. private _elevationReturnTime;
  43760. private _elevationReturnWaitTime;
  43761. private _zoomStopsAnimation;
  43762. private _framingTime;
  43763. /**
  43764. * The easing function used by animations
  43765. */
  43766. static EasingFunction: ExponentialEase;
  43767. /**
  43768. * The easing mode used by animations
  43769. */
  43770. static EasingMode: number;
  43771. /**
  43772. * Sets the current mode used by the behavior
  43773. */
  43774. set mode(mode: number);
  43775. /**
  43776. * Gets current mode used by the behavior.
  43777. */
  43778. get mode(): number;
  43779. /**
  43780. * Sets the scale applied to the radius (1 by default)
  43781. */
  43782. set radiusScale(radius: number);
  43783. /**
  43784. * Gets the scale applied to the radius
  43785. */
  43786. get radiusScale(): number;
  43787. /**
  43788. * Sets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  43789. */
  43790. set positionScale(scale: number);
  43791. /**
  43792. * Gets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  43793. */
  43794. get positionScale(): number;
  43795. /**
  43796. * Sets the angle above/below the horizontal plane to return to when the return to default elevation idle
  43797. * behaviour is triggered, in radians.
  43798. */
  43799. set defaultElevation(elevation: number);
  43800. /**
  43801. * Gets the angle above/below the horizontal plane to return to when the return to default elevation idle
  43802. * behaviour is triggered, in radians.
  43803. */
  43804. get defaultElevation(): number;
  43805. /**
  43806. * Sets the time (in milliseconds) taken to return to the default beta position.
  43807. * Negative value indicates camera should not return to default.
  43808. */
  43809. set elevationReturnTime(speed: number);
  43810. /**
  43811. * Gets the time (in milliseconds) taken to return to the default beta position.
  43812. * Negative value indicates camera should not return to default.
  43813. */
  43814. get elevationReturnTime(): number;
  43815. /**
  43816. * Sets the delay (in milliseconds) taken before the camera returns to the default beta position.
  43817. */
  43818. set elevationReturnWaitTime(time: number);
  43819. /**
  43820. * Gets the delay (in milliseconds) taken before the camera returns to the default beta position.
  43821. */
  43822. get elevationReturnWaitTime(): number;
  43823. /**
  43824. * Sets the flag that indicates if user zooming should stop animation.
  43825. */
  43826. set zoomStopsAnimation(flag: boolean);
  43827. /**
  43828. * Gets the flag that indicates if user zooming should stop animation.
  43829. */
  43830. get zoomStopsAnimation(): boolean;
  43831. /**
  43832. * Sets the transition time when framing the mesh, in milliseconds
  43833. */
  43834. set framingTime(time: number);
  43835. /**
  43836. * Gets the transition time when framing the mesh, in milliseconds
  43837. */
  43838. get framingTime(): number;
  43839. /**
  43840. * Define if the behavior should automatically change the configured
  43841. * camera limits and sensibilities.
  43842. */
  43843. autoCorrectCameraLimitsAndSensibility: boolean;
  43844. private _onPrePointerObservableObserver;
  43845. private _onAfterCheckInputsObserver;
  43846. private _onMeshTargetChangedObserver;
  43847. private _attachedCamera;
  43848. private _isPointerDown;
  43849. private _lastInteractionTime;
  43850. /**
  43851. * Initializes the behavior.
  43852. */
  43853. init(): void;
  43854. /**
  43855. * Attaches the behavior to its arc rotate camera.
  43856. * @param camera Defines the camera to attach the behavior to
  43857. */
  43858. attach(camera: ArcRotateCamera): void;
  43859. /**
  43860. * Detaches the behavior from its current arc rotate camera.
  43861. */
  43862. detach(): void;
  43863. private _animatables;
  43864. private _betaIsAnimating;
  43865. private _betaTransition;
  43866. private _radiusTransition;
  43867. private _vectorTransition;
  43868. /**
  43869. * Targets the given mesh and updates zoom level accordingly.
  43870. * @param mesh The mesh to target.
  43871. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  43872. * @param onAnimationEnd Callback triggered at the end of the framing animation
  43873. */
  43874. zoomOnMesh(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  43875. /**
  43876. * Targets the given mesh with its children 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. zoomOnMeshHierarchy(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  43882. /**
  43883. * Targets the given meshes with their children and updates zoom level accordingly.
  43884. * @param meshes 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. zoomOnMeshesHierarchy(meshes: AbstractMesh[], focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  43889. /**
  43890. * Targets the bounding box info defined by its extends and updates zoom level accordingly.
  43891. * @param minimumWorld Determines the smaller position of the bounding box extend
  43892. * @param maximumWorld Determines the bigger position of the bounding box extend
  43893. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  43894. * @param onAnimationEnd Callback triggered at the end of the framing animation
  43895. */
  43896. zoomOnBoundingInfo(minimumWorld: Vector3, maximumWorld: Vector3, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  43897. /**
  43898. * Calculates the lowest radius for the camera based on the bounding box of the mesh.
  43899. * @param mesh The mesh on which to base the calculation. mesh boundingInfo used to estimate necessary
  43900. * frustum width.
  43901. * @return The minimum distance from the primary mesh's center point at which the camera must be kept in order
  43902. * to fully enclose the mesh in the viewing frustum.
  43903. */
  43904. protected _calculateLowerRadiusFromModelBoundingSphere(minimumWorld: Vector3, maximumWorld: Vector3): number;
  43905. /**
  43906. * Keeps the camera above the ground plane. If the user pulls the camera below the ground plane, the camera
  43907. * is automatically returned to its default position (expected to be above ground plane).
  43908. */
  43909. private _maintainCameraAboveGround;
  43910. /**
  43911. * Returns the frustum slope based on the canvas ratio and camera FOV
  43912. * @returns The frustum slope represented as a Vector2 with X and Y slopes
  43913. */
  43914. private _getFrustumSlope;
  43915. /**
  43916. * Removes all animation locks. Allows new animations to be added to any of the arcCamera properties.
  43917. */
  43918. private _clearAnimationLocks;
  43919. /**
  43920. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  43921. */
  43922. private _applyUserInteraction;
  43923. /**
  43924. * Stops and removes all animations that have been applied to the camera
  43925. */
  43926. stopAllAnimations(): void;
  43927. /**
  43928. * Gets a value indicating if the user is moving the camera
  43929. */
  43930. get isUserIsMoving(): boolean;
  43931. /**
  43932. * The camera can move all the way towards the mesh.
  43933. */
  43934. static IgnoreBoundsSizeMode: number;
  43935. /**
  43936. * The camera is not allowed to zoom closer to the mesh than the point at which the adjusted bounding sphere touches the frustum sides
  43937. */
  43938. static FitFrustumSidesMode: number;
  43939. }
  43940. }
  43941. declare module "babylonjs/Cameras/Inputs/BaseCameraPointersInput" {
  43942. import { Nullable } from "babylonjs/types";
  43943. import { Camera } from "babylonjs/Cameras/camera";
  43944. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  43945. import { PointerTouch } from "babylonjs/Events/pointerEvents";
  43946. /**
  43947. * Base class for Camera Pointer Inputs.
  43948. * See FollowCameraPointersInput in src/Cameras/Inputs/followCameraPointersInput.ts
  43949. * for example usage.
  43950. */
  43951. export abstract class BaseCameraPointersInput implements ICameraInput<Camera> {
  43952. /**
  43953. * Defines the camera the input is attached to.
  43954. */
  43955. abstract camera: Camera;
  43956. /**
  43957. * Whether keyboard modifier keys are pressed at time of last mouse event.
  43958. */
  43959. protected _altKey: boolean;
  43960. protected _ctrlKey: boolean;
  43961. protected _metaKey: boolean;
  43962. protected _shiftKey: boolean;
  43963. /**
  43964. * Which mouse buttons were pressed at time of last mouse event.
  43965. * https://developer.mozilla.org/en-US/docs/Web/API/MouseEvent/buttons
  43966. */
  43967. protected _buttonsPressed: number;
  43968. /**
  43969. * Defines the buttons associated with the input to handle camera move.
  43970. */
  43971. buttons: number[];
  43972. /**
  43973. * Attach the input controls to a specific dom element to get the input from.
  43974. * @param element Defines the element the controls should be listened from
  43975. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  43976. */
  43977. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  43978. /**
  43979. * Detach the current controls from the specified dom element.
  43980. * @param element Defines the element to stop listening the inputs from
  43981. */
  43982. detachControl(element: Nullable<HTMLElement>): void;
  43983. /**
  43984. * Gets the class name of the current input.
  43985. * @returns the class name
  43986. */
  43987. getClassName(): string;
  43988. /**
  43989. * Get the friendly name associated with the input class.
  43990. * @returns the input friendly name
  43991. */
  43992. getSimpleName(): string;
  43993. /**
  43994. * Called on pointer POINTERDOUBLETAP event.
  43995. * Override this method to provide functionality on POINTERDOUBLETAP event.
  43996. */
  43997. protected onDoubleTap(type: string): void;
  43998. /**
  43999. * Called on pointer POINTERMOVE event if only a single touch is active.
  44000. * Override this method to provide functionality.
  44001. */
  44002. protected onTouch(point: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  44003. /**
  44004. * Called on pointer POINTERMOVE event if multiple touches are active.
  44005. * Override this method to provide functionality.
  44006. */
  44007. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  44008. /**
  44009. * Called on JS contextmenu event.
  44010. * Override this method to provide functionality.
  44011. */
  44012. protected onContextMenu(evt: PointerEvent): void;
  44013. /**
  44014. * Called each time a new POINTERDOWN event occurs. Ie, for each button
  44015. * press.
  44016. * Override this method to provide functionality.
  44017. */
  44018. protected onButtonDown(evt: PointerEvent): void;
  44019. /**
  44020. * Called each time a new POINTERUP event occurs. Ie, for each button
  44021. * release.
  44022. * Override this method to provide functionality.
  44023. */
  44024. protected onButtonUp(evt: PointerEvent): void;
  44025. /**
  44026. * Called when window becomes inactive.
  44027. * Override this method to provide functionality.
  44028. */
  44029. protected onLostFocus(): void;
  44030. private _pointerInput;
  44031. private _observer;
  44032. private _onLostFocus;
  44033. private pointA;
  44034. private pointB;
  44035. }
  44036. }
  44037. declare module "babylonjs/Cameras/Inputs/arcRotateCameraPointersInput" {
  44038. import { Nullable } from "babylonjs/types";
  44039. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  44040. import { BaseCameraPointersInput } from "babylonjs/Cameras/Inputs/BaseCameraPointersInput";
  44041. import { PointerTouch } from "babylonjs/Events/pointerEvents";
  44042. /**
  44043. * Manage the pointers inputs to control an arc rotate camera.
  44044. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  44045. */
  44046. export class ArcRotateCameraPointersInput extends BaseCameraPointersInput {
  44047. /**
  44048. * Defines the camera the input is attached to.
  44049. */
  44050. camera: ArcRotateCamera;
  44051. /**
  44052. * Gets the class name of the current input.
  44053. * @returns the class name
  44054. */
  44055. getClassName(): string;
  44056. /**
  44057. * Defines the buttons associated with the input to handle camera move.
  44058. */
  44059. buttons: number[];
  44060. /**
  44061. * Defines the pointer angular sensibility along the X axis or how fast is
  44062. * the camera rotating.
  44063. */
  44064. angularSensibilityX: number;
  44065. /**
  44066. * Defines the pointer angular sensibility along the Y axis or how fast is
  44067. * the camera rotating.
  44068. */
  44069. angularSensibilityY: number;
  44070. /**
  44071. * Defines the pointer pinch precision or how fast is the camera zooming.
  44072. */
  44073. pinchPrecision: number;
  44074. /**
  44075. * pinchDeltaPercentage will be used instead of pinchPrecision if different
  44076. * from 0.
  44077. * It defines the percentage of current camera.radius to use as delta when
  44078. * pinch zoom is used.
  44079. */
  44080. pinchDeltaPercentage: number;
  44081. /**
  44082. * When useNaturalPinchZoom is true, multi touch zoom will zoom in such
  44083. * that any object in the plane at the camera's target point will scale
  44084. * perfectly with finger motion.
  44085. * Overrides pinchDeltaPercentage and pinchPrecision.
  44086. */
  44087. useNaturalPinchZoom: boolean;
  44088. /**
  44089. * Defines the pointer panning sensibility or how fast is the camera moving.
  44090. */
  44091. panningSensibility: number;
  44092. /**
  44093. * Defines whether panning (2 fingers swipe) is enabled through multitouch.
  44094. */
  44095. multiTouchPanning: boolean;
  44096. /**
  44097. * Defines whether panning is enabled for both pan (2 fingers swipe) and
  44098. * zoom (pinch) through multitouch.
  44099. */
  44100. multiTouchPanAndZoom: boolean;
  44101. /**
  44102. * Revers pinch action direction.
  44103. */
  44104. pinchInwards: boolean;
  44105. private _isPanClick;
  44106. private _twoFingerActivityCount;
  44107. private _isPinching;
  44108. /**
  44109. * Called on pointer POINTERMOVE event if only a single touch is active.
  44110. */
  44111. protected onTouch(point: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  44112. /**
  44113. * Called on pointer POINTERDOUBLETAP event.
  44114. */
  44115. protected onDoubleTap(type: string): void;
  44116. /**
  44117. * Called on pointer POINTERMOVE event if multiple touches are active.
  44118. */
  44119. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  44120. /**
  44121. * Called each time a new POINTERDOWN event occurs. Ie, for each button
  44122. * press.
  44123. */
  44124. protected onButtonDown(evt: PointerEvent): void;
  44125. /**
  44126. * Called each time a new POINTERUP event occurs. Ie, for each button
  44127. * release.
  44128. */
  44129. protected onButtonUp(evt: PointerEvent): void;
  44130. /**
  44131. * Called when window becomes inactive.
  44132. */
  44133. protected onLostFocus(): void;
  44134. }
  44135. }
  44136. declare module "babylonjs/Cameras/Inputs/arcRotateCameraKeyboardMoveInput" {
  44137. import { Nullable } from "babylonjs/types";
  44138. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  44139. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  44140. /**
  44141. * Manage the keyboard inputs to control the movement of an arc rotate camera.
  44142. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  44143. */
  44144. export class ArcRotateCameraKeyboardMoveInput implements ICameraInput<ArcRotateCamera> {
  44145. /**
  44146. * Defines the camera the input is attached to.
  44147. */
  44148. camera: ArcRotateCamera;
  44149. /**
  44150. * Defines the list of key codes associated with the up action (increase alpha)
  44151. */
  44152. keysUp: number[];
  44153. /**
  44154. * Defines the list of key codes associated with the down action (decrease alpha)
  44155. */
  44156. keysDown: number[];
  44157. /**
  44158. * Defines the list of key codes associated with the left action (increase beta)
  44159. */
  44160. keysLeft: number[];
  44161. /**
  44162. * Defines the list of key codes associated with the right action (decrease beta)
  44163. */
  44164. keysRight: number[];
  44165. /**
  44166. * Defines the list of key codes associated with the reset action.
  44167. * Those keys reset the camera to its last stored state (with the method camera.storeState())
  44168. */
  44169. keysReset: number[];
  44170. /**
  44171. * Defines the panning sensibility of the inputs.
  44172. * (How fast is the camera panning)
  44173. */
  44174. panningSensibility: number;
  44175. /**
  44176. * Defines the zooming sensibility of the inputs.
  44177. * (How fast is the camera zooming)
  44178. */
  44179. zoomingSensibility: number;
  44180. /**
  44181. * Defines whether maintaining the alt key down switch the movement mode from
  44182. * orientation to zoom.
  44183. */
  44184. useAltToZoom: boolean;
  44185. /**
  44186. * Rotation speed of the camera
  44187. */
  44188. angularSpeed: number;
  44189. private _keys;
  44190. private _ctrlPressed;
  44191. private _altPressed;
  44192. private _onCanvasBlurObserver;
  44193. private _onKeyboardObserver;
  44194. private _engine;
  44195. private _scene;
  44196. /**
  44197. * Attach the input controls to a specific dom element to get the input from.
  44198. * @param element Defines the element the controls should be listened from
  44199. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  44200. */
  44201. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  44202. /**
  44203. * Detach the current controls from the specified dom element.
  44204. * @param element Defines the element to stop listening the inputs from
  44205. */
  44206. detachControl(element: Nullable<HTMLElement>): void;
  44207. /**
  44208. * Update the current camera state depending on the inputs that have been used this frame.
  44209. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  44210. */
  44211. checkInputs(): void;
  44212. /**
  44213. * Gets the class name of the current intput.
  44214. * @returns the class name
  44215. */
  44216. getClassName(): string;
  44217. /**
  44218. * Get the friendly name associated with the input class.
  44219. * @returns the input friendly name
  44220. */
  44221. getSimpleName(): string;
  44222. }
  44223. }
  44224. declare module "babylonjs/Cameras/Inputs/arcRotateCameraMouseWheelInput" {
  44225. import { Nullable } from "babylonjs/types";
  44226. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  44227. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  44228. /**
  44229. * Manage the mouse wheel inputs to control an arc rotate camera.
  44230. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  44231. */
  44232. export class ArcRotateCameraMouseWheelInput implements ICameraInput<ArcRotateCamera> {
  44233. /**
  44234. * Defines the camera the input is attached to.
  44235. */
  44236. camera: ArcRotateCamera;
  44237. /**
  44238. * Gets or Set the mouse wheel precision or how fast is the camera zooming.
  44239. */
  44240. wheelPrecision: number;
  44241. /**
  44242. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  44243. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  44244. */
  44245. wheelDeltaPercentage: number;
  44246. private _wheel;
  44247. private _observer;
  44248. private computeDeltaFromMouseWheelLegacyEvent;
  44249. /**
  44250. * Attach the input controls to a specific dom element to get the input from.
  44251. * @param element Defines the element the controls should be listened from
  44252. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  44253. */
  44254. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  44255. /**
  44256. * Detach the current controls from the specified dom element.
  44257. * @param element Defines the element to stop listening the inputs from
  44258. */
  44259. detachControl(element: Nullable<HTMLElement>): void;
  44260. /**
  44261. * Gets the class name of the current intput.
  44262. * @returns the class name
  44263. */
  44264. getClassName(): string;
  44265. /**
  44266. * Get the friendly name associated with the input class.
  44267. * @returns the input friendly name
  44268. */
  44269. getSimpleName(): string;
  44270. }
  44271. }
  44272. declare module "babylonjs/Cameras/arcRotateCameraInputsManager" {
  44273. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  44274. import { CameraInputsManager } from "babylonjs/Cameras/cameraInputsManager";
  44275. /**
  44276. * Default Inputs manager for the ArcRotateCamera.
  44277. * It groups all the default supported inputs for ease of use.
  44278. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  44279. */
  44280. export class ArcRotateCameraInputsManager extends CameraInputsManager<ArcRotateCamera> {
  44281. /**
  44282. * Instantiates a new ArcRotateCameraInputsManager.
  44283. * @param camera Defines the camera the inputs belong to
  44284. */
  44285. constructor(camera: ArcRotateCamera);
  44286. /**
  44287. * Add mouse wheel input support to the input manager.
  44288. * @returns the current input manager
  44289. */
  44290. addMouseWheel(): ArcRotateCameraInputsManager;
  44291. /**
  44292. * Add pointers input support to the input manager.
  44293. * @returns the current input manager
  44294. */
  44295. addPointers(): ArcRotateCameraInputsManager;
  44296. /**
  44297. * Add keyboard input support to the input manager.
  44298. * @returns the current input manager
  44299. */
  44300. addKeyboard(): ArcRotateCameraInputsManager;
  44301. }
  44302. }
  44303. declare module "babylonjs/Cameras/arcRotateCamera" {
  44304. import { Observable } from "babylonjs/Misc/observable";
  44305. import { Nullable } from "babylonjs/types";
  44306. import { Scene } from "babylonjs/scene";
  44307. import { Matrix, Vector3, Vector2 } from "babylonjs/Maths/math.vector";
  44308. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  44309. import { AutoRotationBehavior } from "babylonjs/Behaviors/Cameras/autoRotationBehavior";
  44310. import { BouncingBehavior } from "babylonjs/Behaviors/Cameras/bouncingBehavior";
  44311. import { FramingBehavior } from "babylonjs/Behaviors/Cameras/framingBehavior";
  44312. import { Camera } from "babylonjs/Cameras/camera";
  44313. import { TargetCamera } from "babylonjs/Cameras/targetCamera";
  44314. import { ArcRotateCameraInputsManager } from "babylonjs/Cameras/arcRotateCameraInputsManager";
  44315. import { Collider } from "babylonjs/Collisions/collider";
  44316. /**
  44317. * This represents an orbital type of camera.
  44318. *
  44319. * 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.
  44320. * 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.
  44321. * @see https://doc.babylonjs.com/babylon101/cameras#arc-rotate-camera
  44322. */
  44323. export class ArcRotateCamera extends TargetCamera {
  44324. /**
  44325. * Defines the rotation angle of the camera along the longitudinal axis.
  44326. */
  44327. alpha: number;
  44328. /**
  44329. * Defines the rotation angle of the camera along the latitudinal axis.
  44330. */
  44331. beta: number;
  44332. /**
  44333. * Defines the radius of the camera from it s target point.
  44334. */
  44335. radius: number;
  44336. protected _target: Vector3;
  44337. protected _targetHost: Nullable<AbstractMesh>;
  44338. /**
  44339. * Defines the target point of the camera.
  44340. * The camera looks towards it form the radius distance.
  44341. * Please note that you can set the target to a mesh and thus the target will be copied from mesh.position
  44342. */
  44343. get target(): Vector3;
  44344. set target(value: Vector3);
  44345. /**
  44346. * Define the current local position of the camera in the scene
  44347. */
  44348. get position(): Vector3;
  44349. set position(newPosition: Vector3);
  44350. protected _upToYMatrix: Matrix;
  44351. protected _YToUpMatrix: Matrix;
  44352. /**
  44353. * The vector the camera should consider as up. (default is Vector3(0, 1, 0) as returned by Vector3.Up())
  44354. * Setting this will copy the given vector to the camera's upVector, and set rotation matrices to and from Y up.
  44355. * DO NOT set the up vector using copyFrom or copyFromFloats, as this bypasses setting the above matrices.
  44356. */
  44357. set upVector(vec: Vector3);
  44358. get upVector(): Vector3;
  44359. /**
  44360. * Sets the Y-up to camera up-vector rotation matrix, and the up-vector to Y-up rotation matrix.
  44361. */
  44362. setMatUp(): void;
  44363. /**
  44364. * Current inertia value on the longitudinal axis.
  44365. * The bigger this number the longer it will take for the camera to stop.
  44366. */
  44367. inertialAlphaOffset: number;
  44368. /**
  44369. * Current inertia value on the latitudinal axis.
  44370. * The bigger this number the longer it will take for the camera to stop.
  44371. */
  44372. inertialBetaOffset: number;
  44373. /**
  44374. * Current inertia value on the radius axis.
  44375. * The bigger this number the longer it will take for the camera to stop.
  44376. */
  44377. inertialRadiusOffset: number;
  44378. /**
  44379. * Minimum allowed angle on the longitudinal axis.
  44380. * This can help limiting how the Camera is able to move in the scene.
  44381. */
  44382. lowerAlphaLimit: Nullable<number>;
  44383. /**
  44384. * Maximum allowed angle on the longitudinal axis.
  44385. * This can help limiting how the Camera is able to move in the scene.
  44386. */
  44387. upperAlphaLimit: Nullable<number>;
  44388. /**
  44389. * Minimum allowed angle on the latitudinal axis.
  44390. * This can help limiting how the Camera is able to move in the scene.
  44391. */
  44392. lowerBetaLimit: number;
  44393. /**
  44394. * Maximum allowed angle on the latitudinal axis.
  44395. * This can help limiting how the Camera is able to move in the scene.
  44396. */
  44397. upperBetaLimit: number;
  44398. /**
  44399. * Minimum allowed distance of the camera to the target (The camera can not get closer).
  44400. * This can help limiting how the Camera is able to move in the scene.
  44401. */
  44402. lowerRadiusLimit: Nullable<number>;
  44403. /**
  44404. * Maximum allowed distance of the camera to the target (The camera can not get further).
  44405. * This can help limiting how the Camera is able to move in the scene.
  44406. */
  44407. upperRadiusLimit: Nullable<number>;
  44408. /**
  44409. * Defines the current inertia value used during panning of the camera along the X axis.
  44410. */
  44411. inertialPanningX: number;
  44412. /**
  44413. * Defines the current inertia value used during panning of the camera along the Y axis.
  44414. */
  44415. inertialPanningY: number;
  44416. /**
  44417. * Defines the distance used to consider the camera in pan mode vs pinch/zoom.
  44418. * Basically if your fingers moves away from more than this distance you will be considered
  44419. * in pinch mode.
  44420. */
  44421. pinchToPanMaxDistance: number;
  44422. /**
  44423. * Defines the maximum distance the camera can pan.
  44424. * This could help keeping the cammera always in your scene.
  44425. */
  44426. panningDistanceLimit: Nullable<number>;
  44427. /**
  44428. * Defines the target of the camera before paning.
  44429. */
  44430. panningOriginTarget: Vector3;
  44431. /**
  44432. * Defines the value of the inertia used during panning.
  44433. * 0 would mean stop inertia and one would mean no decelleration at all.
  44434. */
  44435. panningInertia: number;
  44436. /**
  44437. * Gets or Set the pointer angular sensibility along the X axis or how fast is the camera rotating.
  44438. */
  44439. get angularSensibilityX(): number;
  44440. set angularSensibilityX(value: number);
  44441. /**
  44442. * Gets or Set the pointer angular sensibility along the Y axis or how fast is the camera rotating.
  44443. */
  44444. get angularSensibilityY(): number;
  44445. set angularSensibilityY(value: number);
  44446. /**
  44447. * Gets or Set the pointer pinch precision or how fast is the camera zooming.
  44448. */
  44449. get pinchPrecision(): number;
  44450. set pinchPrecision(value: number);
  44451. /**
  44452. * Gets or Set the pointer pinch delta percentage or how fast is the camera zooming.
  44453. * It will be used instead of pinchDeltaPrecision if different from 0.
  44454. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  44455. */
  44456. get pinchDeltaPercentage(): number;
  44457. set pinchDeltaPercentage(value: number);
  44458. /**
  44459. * Gets or Set the pointer use natural pinch zoom to override the pinch precision
  44460. * and pinch delta percentage.
  44461. * When useNaturalPinchZoom is true, multi touch zoom will zoom in such
  44462. * that any object in the plane at the camera's target point will scale
  44463. * perfectly with finger motion.
  44464. */
  44465. get useNaturalPinchZoom(): boolean;
  44466. set useNaturalPinchZoom(value: boolean);
  44467. /**
  44468. * Gets or Set the pointer panning sensibility or how fast is the camera moving.
  44469. */
  44470. get panningSensibility(): number;
  44471. set panningSensibility(value: number);
  44472. /**
  44473. * Gets or Set the list of keyboard keys used to control beta angle in a positive direction.
  44474. */
  44475. get keysUp(): number[];
  44476. set keysUp(value: number[]);
  44477. /**
  44478. * Gets or Set the list of keyboard keys used to control beta angle in a negative direction.
  44479. */
  44480. get keysDown(): number[];
  44481. set keysDown(value: number[]);
  44482. /**
  44483. * Gets or Set the list of keyboard keys used to control alpha angle in a negative direction.
  44484. */
  44485. get keysLeft(): number[];
  44486. set keysLeft(value: number[]);
  44487. /**
  44488. * Gets or Set the list of keyboard keys used to control alpha angle in a positive direction.
  44489. */
  44490. get keysRight(): number[];
  44491. set keysRight(value: number[]);
  44492. /**
  44493. * Gets or Set the mouse wheel precision or how fast is the camera zooming.
  44494. */
  44495. get wheelPrecision(): number;
  44496. set wheelPrecision(value: number);
  44497. /**
  44498. * Gets or Set the mouse wheel delta percentage or how fast is the camera zooming.
  44499. * It will be used instead of pinchDeltaPrecision if different from 0.
  44500. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  44501. */
  44502. get wheelDeltaPercentage(): number;
  44503. set wheelDeltaPercentage(value: number);
  44504. /**
  44505. * Defines how much the radius should be scaled while zomming on a particular mesh (through the zoomOn function)
  44506. */
  44507. zoomOnFactor: number;
  44508. /**
  44509. * Defines a screen offset for the camera position.
  44510. */
  44511. targetScreenOffset: Vector2;
  44512. /**
  44513. * Allows the camera to be completely reversed.
  44514. * If false the camera can not arrive upside down.
  44515. */
  44516. allowUpsideDown: boolean;
  44517. /**
  44518. * Define if double tap/click is used to restore the previously saved state of the camera.
  44519. */
  44520. useInputToRestoreState: boolean;
  44521. /** @hidden */
  44522. _viewMatrix: Matrix;
  44523. /** @hidden */
  44524. _useCtrlForPanning: boolean;
  44525. /** @hidden */
  44526. _panningMouseButton: number;
  44527. /**
  44528. * Defines the input associated to the camera.
  44529. */
  44530. inputs: ArcRotateCameraInputsManager;
  44531. /** @hidden */
  44532. _reset: () => void;
  44533. /**
  44534. * Defines the allowed panning axis.
  44535. */
  44536. panningAxis: Vector3;
  44537. protected _localDirection: Vector3;
  44538. protected _transformedDirection: Vector3;
  44539. private _bouncingBehavior;
  44540. /**
  44541. * Gets the bouncing behavior of the camera if it has been enabled.
  44542. * @see https://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  44543. */
  44544. get bouncingBehavior(): Nullable<BouncingBehavior>;
  44545. /**
  44546. * Defines if the bouncing behavior of the camera is enabled on the camera.
  44547. * @see https://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  44548. */
  44549. get useBouncingBehavior(): boolean;
  44550. set useBouncingBehavior(value: boolean);
  44551. private _framingBehavior;
  44552. /**
  44553. * Gets the framing behavior of the camera if it has been enabled.
  44554. * @see https://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  44555. */
  44556. get framingBehavior(): Nullable<FramingBehavior>;
  44557. /**
  44558. * Defines if the framing behavior of the camera is enabled on the camera.
  44559. * @see https://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  44560. */
  44561. get useFramingBehavior(): boolean;
  44562. set useFramingBehavior(value: boolean);
  44563. private _autoRotationBehavior;
  44564. /**
  44565. * Gets the auto rotation behavior of the camera if it has been enabled.
  44566. * @see https://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  44567. */
  44568. get autoRotationBehavior(): Nullable<AutoRotationBehavior>;
  44569. /**
  44570. * Defines if the auto rotation behavior of the camera is enabled on the camera.
  44571. * @see https://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  44572. */
  44573. get useAutoRotationBehavior(): boolean;
  44574. set useAutoRotationBehavior(value: boolean);
  44575. /**
  44576. * Observable triggered when the mesh target has been changed on the camera.
  44577. */
  44578. onMeshTargetChangedObservable: Observable<Nullable<AbstractMesh>>;
  44579. /**
  44580. * Event raised when the camera is colliding with a mesh.
  44581. */
  44582. onCollide: (collidedMesh: AbstractMesh) => void;
  44583. /**
  44584. * Defines whether the camera should check collision with the objects oh the scene.
  44585. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#how-can-i-do-this
  44586. */
  44587. checkCollisions: boolean;
  44588. /**
  44589. * Defines the collision radius of the camera.
  44590. * This simulates a sphere around the camera.
  44591. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  44592. */
  44593. collisionRadius: Vector3;
  44594. protected _collider: Collider;
  44595. protected _previousPosition: Vector3;
  44596. protected _collisionVelocity: Vector3;
  44597. protected _newPosition: Vector3;
  44598. protected _previousAlpha: number;
  44599. protected _previousBeta: number;
  44600. protected _previousRadius: number;
  44601. protected _collisionTriggered: boolean;
  44602. protected _targetBoundingCenter: Nullable<Vector3>;
  44603. private _computationVector;
  44604. /**
  44605. * Instantiates a new ArcRotateCamera in a given scene
  44606. * @param name Defines the name of the camera
  44607. * @param alpha Defines the camera rotation along the logitudinal axis
  44608. * @param beta Defines the camera rotation along the latitudinal axis
  44609. * @param radius Defines the camera distance from its target
  44610. * @param target Defines the camera target
  44611. * @param scene Defines the scene the camera belongs to
  44612. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  44613. */
  44614. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  44615. /** @hidden */
  44616. _initCache(): void;
  44617. /** @hidden */
  44618. _updateCache(ignoreParentClass?: boolean): void;
  44619. protected _getTargetPosition(): Vector3;
  44620. private _storedAlpha;
  44621. private _storedBeta;
  44622. private _storedRadius;
  44623. private _storedTarget;
  44624. private _storedTargetScreenOffset;
  44625. /**
  44626. * Stores the current state of the camera (alpha, beta, radius and target)
  44627. * @returns the camera itself
  44628. */
  44629. storeState(): Camera;
  44630. /**
  44631. * @hidden
  44632. * Restored camera state. You must call storeState() first
  44633. */
  44634. _restoreStateValues(): boolean;
  44635. /** @hidden */
  44636. _isSynchronizedViewMatrix(): boolean;
  44637. /**
  44638. * Attached controls to the current camera.
  44639. * @param element Defines the element the controls should be listened from
  44640. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  44641. * @param useCtrlForPanning Defines whether ctrl is used for paning within the controls
  44642. * @param panningMouseButton Defines whether panning is allowed through mouse click button
  44643. */
  44644. attachControl(element: HTMLElement, noPreventDefault?: boolean, useCtrlForPanning?: boolean, panningMouseButton?: number): void;
  44645. /**
  44646. * Detach the current controls from the camera.
  44647. * The camera will stop reacting to inputs.
  44648. * @param element Defines the element to stop listening the inputs from
  44649. */
  44650. detachControl(element: HTMLElement): void;
  44651. /** @hidden */
  44652. _checkInputs(): void;
  44653. protected _checkLimits(): void;
  44654. /**
  44655. * Rebuilds angles (alpha, beta) and radius from the give position and target
  44656. */
  44657. rebuildAnglesAndRadius(): void;
  44658. /**
  44659. * Use a position to define the current camera related information like alpha, beta and radius
  44660. * @param position Defines the position to set the camera at
  44661. */
  44662. setPosition(position: Vector3): void;
  44663. /**
  44664. * Defines the target the camera should look at.
  44665. * This will automatically adapt alpha beta and radius to fit within the new target.
  44666. * @param target Defines the new target as a Vector or a mesh
  44667. * @param toBoundingCenter In case of a mesh target, defines whether to target the mesh position or its bounding information center
  44668. * @param allowSamePosition If false, prevents reapplying the new computed position if it is identical to the current one (optim)
  44669. */
  44670. setTarget(target: AbstractMesh | Vector3, toBoundingCenter?: boolean, allowSamePosition?: boolean): void;
  44671. /** @hidden */
  44672. _getViewMatrix(): Matrix;
  44673. protected _onCollisionPositionChange: (collisionId: number, newPosition: Vector3, collidedMesh?: Nullable<AbstractMesh>) => void;
  44674. /**
  44675. * Zooms on a mesh to be at the min distance where we could see it fully in the current viewport.
  44676. * @param meshes Defines the mesh to zoom on
  44677. * @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)
  44678. */
  44679. zoomOn(meshes?: AbstractMesh[], doNotUpdateMaxZ?: boolean): void;
  44680. /**
  44681. * Focus on a mesh or a bounding box. This adapts the target and maxRadius if necessary but does not update the current radius.
  44682. * The target will be changed but the radius
  44683. * @param meshesOrMinMaxVectorAndDistance Defines the mesh or bounding info to focus 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. focusOn(meshesOrMinMaxVectorAndDistance: AbstractMesh[] | {
  44687. min: Vector3;
  44688. max: Vector3;
  44689. distance: number;
  44690. }, doNotUpdateMaxZ?: boolean): void;
  44691. /**
  44692. * @override
  44693. * Override Camera.createRigCamera
  44694. */
  44695. createRigCamera(name: string, cameraIndex: number): Camera;
  44696. /**
  44697. * @hidden
  44698. * @override
  44699. * Override Camera._updateRigCameras
  44700. */
  44701. _updateRigCameras(): void;
  44702. /**
  44703. * Destroy the camera and release the current resources hold by it.
  44704. */
  44705. dispose(): void;
  44706. /**
  44707. * Gets the current object class name.
  44708. * @return the class name
  44709. */
  44710. getClassName(): string;
  44711. }
  44712. }
  44713. declare module "babylonjs/Behaviors/Cameras/autoRotationBehavior" {
  44714. import { Behavior } from "babylonjs/Behaviors/behavior";
  44715. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  44716. /**
  44717. * The autoRotation behavior (AutoRotationBehavior) is designed to create a smooth rotation of an ArcRotateCamera when there is no user interaction.
  44718. * @see https://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  44719. */
  44720. export class AutoRotationBehavior implements Behavior<ArcRotateCamera> {
  44721. /**
  44722. * Gets the name of the behavior.
  44723. */
  44724. get name(): string;
  44725. private _zoomStopsAnimation;
  44726. private _idleRotationSpeed;
  44727. private _idleRotationWaitTime;
  44728. private _idleRotationSpinupTime;
  44729. /**
  44730. * Sets the flag that indicates if user zooming should stop animation.
  44731. */
  44732. set zoomStopsAnimation(flag: boolean);
  44733. /**
  44734. * Gets the flag that indicates if user zooming should stop animation.
  44735. */
  44736. get zoomStopsAnimation(): boolean;
  44737. /**
  44738. * Sets the default speed at which the camera rotates around the model.
  44739. */
  44740. set idleRotationSpeed(speed: number);
  44741. /**
  44742. * Gets the default speed at which the camera rotates around the model.
  44743. */
  44744. get idleRotationSpeed(): number;
  44745. /**
  44746. * Sets the time (in milliseconds) to wait after user interaction before the camera starts rotating.
  44747. */
  44748. set idleRotationWaitTime(time: number);
  44749. /**
  44750. * Gets the time (milliseconds) to wait after user interaction before the camera starts rotating.
  44751. */
  44752. get idleRotationWaitTime(): number;
  44753. /**
  44754. * Sets the time (milliseconds) to take to spin up to the full idle rotation speed.
  44755. */
  44756. set idleRotationSpinupTime(time: number);
  44757. /**
  44758. * Gets the time (milliseconds) to take to spin up to the full idle rotation speed.
  44759. */
  44760. get idleRotationSpinupTime(): number;
  44761. /**
  44762. * Gets a value indicating if the camera is currently rotating because of this behavior
  44763. */
  44764. get rotationInProgress(): boolean;
  44765. private _onPrePointerObservableObserver;
  44766. private _onAfterCheckInputsObserver;
  44767. private _attachedCamera;
  44768. private _isPointerDown;
  44769. private _lastFrameTime;
  44770. private _lastInteractionTime;
  44771. private _cameraRotationSpeed;
  44772. /**
  44773. * Initializes the behavior.
  44774. */
  44775. init(): void;
  44776. /**
  44777. * Attaches the behavior to its arc rotate camera.
  44778. * @param camera Defines the camera to attach the behavior to
  44779. */
  44780. attach(camera: ArcRotateCamera): void;
  44781. /**
  44782. * Detaches the behavior from its current arc rotate camera.
  44783. */
  44784. detach(): void;
  44785. /**
  44786. * Returns true if user is scrolling.
  44787. * @return true if user is scrolling.
  44788. */
  44789. private _userIsZooming;
  44790. private _lastFrameRadius;
  44791. private _shouldAnimationStopForInteraction;
  44792. /**
  44793. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  44794. */
  44795. private _applyUserInteraction;
  44796. private _userIsMoving;
  44797. }
  44798. }
  44799. declare module "babylonjs/Behaviors/Cameras/index" {
  44800. export * from "babylonjs/Behaviors/Cameras/autoRotationBehavior";
  44801. export * from "babylonjs/Behaviors/Cameras/bouncingBehavior";
  44802. export * from "babylonjs/Behaviors/Cameras/framingBehavior";
  44803. }
  44804. declare module "babylonjs/Behaviors/Meshes/attachToBoxBehavior" {
  44805. import { Mesh } from "babylonjs/Meshes/mesh";
  44806. import { TransformNode } from "babylonjs/Meshes/transformNode";
  44807. import { Behavior } from "babylonjs/Behaviors/behavior";
  44808. /**
  44809. * A behavior that when attached to a mesh will will place a specified node on the meshes face pointing towards the camera
  44810. */
  44811. export class AttachToBoxBehavior implements Behavior<Mesh> {
  44812. private ui;
  44813. /**
  44814. * The name of the behavior
  44815. */
  44816. name: string;
  44817. /**
  44818. * The distance away from the face of the mesh that the UI should be attached to (default: 0.15)
  44819. */
  44820. distanceAwayFromFace: number;
  44821. /**
  44822. * The distance from the bottom of the face that the UI should be attached to (default: 0.15)
  44823. */
  44824. distanceAwayFromBottomOfFace: number;
  44825. private _faceVectors;
  44826. private _target;
  44827. private _scene;
  44828. private _onRenderObserver;
  44829. private _tmpMatrix;
  44830. private _tmpVector;
  44831. /**
  44832. * Creates the AttachToBoxBehavior, used to attach UI to the closest face of the box to a camera
  44833. * @param ui The transform node that should be attched to the mesh
  44834. */
  44835. constructor(ui: TransformNode);
  44836. /**
  44837. * Initializes the behavior
  44838. */
  44839. init(): void;
  44840. private _closestFace;
  44841. private _zeroVector;
  44842. private _lookAtTmpMatrix;
  44843. private _lookAtToRef;
  44844. /**
  44845. * Attaches the AttachToBoxBehavior to the passed in mesh
  44846. * @param target The mesh that the specified node will be attached to
  44847. */
  44848. attach(target: Mesh): void;
  44849. /**
  44850. * Detaches the behavior from the mesh
  44851. */
  44852. detach(): void;
  44853. }
  44854. }
  44855. declare module "babylonjs/Behaviors/Meshes/fadeInOutBehavior" {
  44856. import { Behavior } from "babylonjs/Behaviors/behavior";
  44857. import { Mesh } from "babylonjs/Meshes/mesh";
  44858. /**
  44859. * A behavior that when attached to a mesh will allow the mesh to fade in and out
  44860. */
  44861. export class FadeInOutBehavior implements Behavior<Mesh> {
  44862. /**
  44863. * Time in milliseconds to delay before fading in (Default: 0)
  44864. */
  44865. delay: number;
  44866. /**
  44867. * Time in milliseconds for the mesh to fade in (Default: 300)
  44868. */
  44869. fadeInTime: number;
  44870. private _millisecondsPerFrame;
  44871. private _hovered;
  44872. private _hoverValue;
  44873. private _ownerNode;
  44874. /**
  44875. * Instatiates the FadeInOutBehavior
  44876. */
  44877. constructor();
  44878. /**
  44879. * The name of the behavior
  44880. */
  44881. get name(): string;
  44882. /**
  44883. * Initializes the behavior
  44884. */
  44885. init(): void;
  44886. /**
  44887. * Attaches the fade behavior on the passed in mesh
  44888. * @param ownerNode The mesh that will be faded in/out once attached
  44889. */
  44890. attach(ownerNode: Mesh): void;
  44891. /**
  44892. * Detaches the behavior from the mesh
  44893. */
  44894. detach(): void;
  44895. /**
  44896. * Triggers the mesh to begin fading in or out
  44897. * @param value if the object should fade in or out (true to fade in)
  44898. */
  44899. fadeIn(value: boolean): void;
  44900. private _update;
  44901. private _setAllVisibility;
  44902. }
  44903. }
  44904. declare module "babylonjs/Misc/pivotTools" {
  44905. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  44906. /**
  44907. * Class containing a set of static utilities functions for managing Pivots
  44908. * @hidden
  44909. */
  44910. export class PivotTools {
  44911. private static _PivotCached;
  44912. private static _OldPivotPoint;
  44913. private static _PivotTranslation;
  44914. private static _PivotTmpVector;
  44915. /** @hidden */
  44916. static _RemoveAndStorePivotPoint(mesh: AbstractMesh): void;
  44917. /** @hidden */
  44918. static _RestorePivotPoint(mesh: AbstractMesh): void;
  44919. }
  44920. }
  44921. declare module "babylonjs/Meshes/Builders/planeBuilder" {
  44922. import { Scene } from "babylonjs/scene";
  44923. import { Vector4 } from "babylonjs/Maths/math.vector";
  44924. import { Mesh } from "babylonjs/Meshes/mesh";
  44925. import { Nullable } from "babylonjs/types";
  44926. import { Plane } from "babylonjs/Maths/math.plane";
  44927. /**
  44928. * Class containing static functions to help procedurally build meshes
  44929. */
  44930. export class PlaneBuilder {
  44931. /**
  44932. * Creates a plane mesh
  44933. * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
  44934. * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value of `size`)
  44935. * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane
  44936. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  44937. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  44938. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  44939. * @param name defines the name of the mesh
  44940. * @param options defines the options used to create the mesh
  44941. * @param scene defines the hosting scene
  44942. * @returns the plane mesh
  44943. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  44944. */
  44945. static CreatePlane(name: string, options: {
  44946. size?: number;
  44947. width?: number;
  44948. height?: number;
  44949. sideOrientation?: number;
  44950. frontUVs?: Vector4;
  44951. backUVs?: Vector4;
  44952. updatable?: boolean;
  44953. sourcePlane?: Plane;
  44954. }, scene?: Nullable<Scene>): Mesh;
  44955. }
  44956. }
  44957. declare module "babylonjs/Behaviors/Meshes/pointerDragBehavior" {
  44958. import { Behavior } from "babylonjs/Behaviors/behavior";
  44959. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  44960. import { Observable } from "babylonjs/Misc/observable";
  44961. import { Vector3 } from "babylonjs/Maths/math.vector";
  44962. import { Ray } from "babylonjs/Culling/ray";
  44963. import "babylonjs/Meshes/Builders/planeBuilder";
  44964. /**
  44965. * A behavior that when attached to a mesh will allow the mesh to be dragged around the screen based on pointer events
  44966. */
  44967. export class PointerDragBehavior implements Behavior<AbstractMesh> {
  44968. private static _AnyMouseID;
  44969. /**
  44970. * Abstract mesh the behavior is set on
  44971. */
  44972. attachedNode: AbstractMesh;
  44973. private _dragPlane;
  44974. private _scene;
  44975. private _pointerObserver;
  44976. private _beforeRenderObserver;
  44977. private static _planeScene;
  44978. private _useAlternatePickedPointAboveMaxDragAngleDragSpeed;
  44979. /**
  44980. * 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)
  44981. */
  44982. maxDragAngle: number;
  44983. /**
  44984. * @hidden
  44985. */
  44986. _useAlternatePickedPointAboveMaxDragAngle: boolean;
  44987. /**
  44988. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  44989. */
  44990. currentDraggingPointerID: number;
  44991. /**
  44992. * The last position where the pointer hit the drag plane in world space
  44993. */
  44994. lastDragPosition: Vector3;
  44995. /**
  44996. * If the behavior is currently in a dragging state
  44997. */
  44998. dragging: boolean;
  44999. /**
  45000. * 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)
  45001. */
  45002. dragDeltaRatio: number;
  45003. /**
  45004. * If the drag plane orientation should be updated during the dragging (Default: true)
  45005. */
  45006. updateDragPlane: boolean;
  45007. private _debugMode;
  45008. private _moving;
  45009. /**
  45010. * Fires each time the attached mesh is dragged with the pointer
  45011. * * delta between last drag position and current drag position in world space
  45012. * * dragDistance along the drag axis
  45013. * * dragPlaneNormal normal of the current drag plane used during the drag
  45014. * * dragPlanePoint in world space where the drag intersects the drag plane
  45015. */
  45016. onDragObservable: Observable<{
  45017. delta: Vector3;
  45018. dragPlanePoint: Vector3;
  45019. dragPlaneNormal: Vector3;
  45020. dragDistance: number;
  45021. pointerId: number;
  45022. }>;
  45023. /**
  45024. * Fires each time a drag begins (eg. mouse down on mesh)
  45025. */
  45026. onDragStartObservable: Observable<{
  45027. dragPlanePoint: Vector3;
  45028. pointerId: number;
  45029. }>;
  45030. /**
  45031. * Fires each time a drag ends (eg. mouse release after drag)
  45032. */
  45033. onDragEndObservable: Observable<{
  45034. dragPlanePoint: Vector3;
  45035. pointerId: number;
  45036. }>;
  45037. /**
  45038. * If the attached mesh should be moved when dragged
  45039. */
  45040. moveAttached: boolean;
  45041. /**
  45042. * If the drag behavior will react to drag events (Default: true)
  45043. */
  45044. enabled: boolean;
  45045. /**
  45046. * If pointer events should start and release the drag (Default: true)
  45047. */
  45048. startAndReleaseDragOnPointerEvents: boolean;
  45049. /**
  45050. * If camera controls should be detached during the drag
  45051. */
  45052. detachCameraControls: boolean;
  45053. /**
  45054. * If set, the drag plane/axis will be rotated based on the attached mesh's world rotation (Default: true)
  45055. */
  45056. useObjectOrientationForDragging: boolean;
  45057. private _options;
  45058. /**
  45059. * Gets the options used by the behavior
  45060. */
  45061. get options(): {
  45062. dragAxis?: Vector3;
  45063. dragPlaneNormal?: Vector3;
  45064. };
  45065. /**
  45066. * Sets the options used by the behavior
  45067. */
  45068. set options(options: {
  45069. dragAxis?: Vector3;
  45070. dragPlaneNormal?: Vector3;
  45071. });
  45072. /**
  45073. * Creates a pointer drag behavior that can be attached to a mesh
  45074. * @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)
  45075. */
  45076. constructor(options?: {
  45077. dragAxis?: Vector3;
  45078. dragPlaneNormal?: Vector3;
  45079. });
  45080. /**
  45081. * Predicate to determine if it is valid to move the object to a new position when it is moved
  45082. */
  45083. validateDrag: (targetPosition: Vector3) => boolean;
  45084. /**
  45085. * The name of the behavior
  45086. */
  45087. get name(): string;
  45088. /**
  45089. * Initializes the behavior
  45090. */
  45091. init(): void;
  45092. private _tmpVector;
  45093. private _alternatePickedPoint;
  45094. private _worldDragAxis;
  45095. private _targetPosition;
  45096. private _attachedElement;
  45097. /**
  45098. * Attaches the drag behavior the passed in mesh
  45099. * @param ownerNode The mesh that will be dragged around once attached
  45100. * @param predicate Predicate to use for pick filtering
  45101. */
  45102. attach(ownerNode: AbstractMesh, predicate?: (m: AbstractMesh) => boolean): void;
  45103. /**
  45104. * Force relase the drag action by code.
  45105. */
  45106. releaseDrag(): void;
  45107. private _startDragRay;
  45108. private _lastPointerRay;
  45109. /**
  45110. * Simulates the start of a pointer drag event on the behavior
  45111. * @param pointerId pointerID of the pointer that should be simulated (Default: Any mouse pointer ID)
  45112. * @param fromRay initial ray of the pointer to be simulated (Default: Ray from camera to attached mesh)
  45113. * @param startPickedPoint picked point of the pointer to be simulated (Default: attached mesh position)
  45114. */
  45115. startDrag(pointerId?: number, fromRay?: Ray, startPickedPoint?: Vector3): void;
  45116. private _startDrag;
  45117. private _dragDelta;
  45118. private _moveDrag;
  45119. private _pickWithRayOnDragPlane;
  45120. private _pointA;
  45121. private _pointC;
  45122. private _localAxis;
  45123. private _lookAt;
  45124. private _updateDragPlanePosition;
  45125. /**
  45126. * Detaches the behavior from the mesh
  45127. */
  45128. detach(): void;
  45129. }
  45130. }
  45131. declare module "babylonjs/Behaviors/Meshes/multiPointerScaleBehavior" {
  45132. import { Mesh } from "babylonjs/Meshes/mesh";
  45133. import { Behavior } from "babylonjs/Behaviors/behavior";
  45134. /**
  45135. * A behavior that when attached to a mesh will allow the mesh to be scaled
  45136. */
  45137. export class MultiPointerScaleBehavior implements Behavior<Mesh> {
  45138. private _dragBehaviorA;
  45139. private _dragBehaviorB;
  45140. private _startDistance;
  45141. private _initialScale;
  45142. private _targetScale;
  45143. private _ownerNode;
  45144. private _sceneRenderObserver;
  45145. /**
  45146. * Instantiate a new behavior that when attached to a mesh will allow the mesh to be scaled
  45147. */
  45148. constructor();
  45149. /**
  45150. * The name of the behavior
  45151. */
  45152. get name(): string;
  45153. /**
  45154. * Initializes the behavior
  45155. */
  45156. init(): void;
  45157. private _getCurrentDistance;
  45158. /**
  45159. * Attaches the scale behavior the passed in mesh
  45160. * @param ownerNode The mesh that will be scaled around once attached
  45161. */
  45162. attach(ownerNode: Mesh): void;
  45163. /**
  45164. * Detaches the behavior from the mesh
  45165. */
  45166. detach(): void;
  45167. }
  45168. }
  45169. declare module "babylonjs/Behaviors/Meshes/sixDofDragBehavior" {
  45170. import { Behavior } from "babylonjs/Behaviors/behavior";
  45171. import { Mesh } from "babylonjs/Meshes/mesh";
  45172. import { Observable } from "babylonjs/Misc/observable";
  45173. /**
  45174. * 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
  45175. */
  45176. export class SixDofDragBehavior implements Behavior<Mesh> {
  45177. private static _virtualScene;
  45178. private _ownerNode;
  45179. private _sceneRenderObserver;
  45180. private _scene;
  45181. private _targetPosition;
  45182. private _virtualOriginMesh;
  45183. private _virtualDragMesh;
  45184. private _pointerObserver;
  45185. private _moving;
  45186. private _startingOrientation;
  45187. private _attachedElement;
  45188. /**
  45189. * 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)
  45190. */
  45191. private zDragFactor;
  45192. /**
  45193. * If the object should rotate to face the drag origin
  45194. */
  45195. rotateDraggedObject: boolean;
  45196. /**
  45197. * If the behavior is currently in a dragging state
  45198. */
  45199. dragging: boolean;
  45200. /**
  45201. * 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)
  45202. */
  45203. dragDeltaRatio: number;
  45204. /**
  45205. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  45206. */
  45207. currentDraggingPointerID: number;
  45208. /**
  45209. * If camera controls should be detached during the drag
  45210. */
  45211. detachCameraControls: boolean;
  45212. /**
  45213. * Fires each time a drag starts
  45214. */
  45215. onDragStartObservable: Observable<{}>;
  45216. /**
  45217. * Fires each time a drag ends (eg. mouse release after drag)
  45218. */
  45219. onDragEndObservable: Observable<{}>;
  45220. /**
  45221. * 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
  45222. */
  45223. constructor();
  45224. /**
  45225. * The name of the behavior
  45226. */
  45227. get name(): string;
  45228. /**
  45229. * Initializes the behavior
  45230. */
  45231. init(): void;
  45232. /**
  45233. * In the case of multiplea active cameras, the cameraToUseForPointers should be used if set instead of active camera
  45234. */
  45235. private get _pointerCamera();
  45236. /**
  45237. * Attaches the scale behavior the passed in mesh
  45238. * @param ownerNode The mesh that will be scaled around once attached
  45239. */
  45240. attach(ownerNode: Mesh): void;
  45241. /**
  45242. * Detaches the behavior from the mesh
  45243. */
  45244. detach(): void;
  45245. }
  45246. }
  45247. declare module "babylonjs/Behaviors/Meshes/index" {
  45248. export * from "babylonjs/Behaviors/Meshes/attachToBoxBehavior";
  45249. export * from "babylonjs/Behaviors/Meshes/fadeInOutBehavior";
  45250. export * from "babylonjs/Behaviors/Meshes/multiPointerScaleBehavior";
  45251. export * from "babylonjs/Behaviors/Meshes/pointerDragBehavior";
  45252. export * from "babylonjs/Behaviors/Meshes/sixDofDragBehavior";
  45253. }
  45254. declare module "babylonjs/Behaviors/index" {
  45255. export * from "babylonjs/Behaviors/behavior";
  45256. export * from "babylonjs/Behaviors/Cameras/index";
  45257. export * from "babylonjs/Behaviors/Meshes/index";
  45258. }
  45259. declare module "babylonjs/Bones/boneIKController" {
  45260. import { Bone } from "babylonjs/Bones/bone";
  45261. import { Vector3 } from "babylonjs/Maths/math.vector";
  45262. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  45263. import { Nullable } from "babylonjs/types";
  45264. /**
  45265. * Class used to apply inverse kinematics to bones
  45266. * @see https://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#boneikcontroller
  45267. */
  45268. export class BoneIKController {
  45269. private static _tmpVecs;
  45270. private static _tmpQuat;
  45271. private static _tmpMats;
  45272. /**
  45273. * Gets or sets the target mesh
  45274. */
  45275. targetMesh: AbstractMesh;
  45276. /** Gets or sets the mesh used as pole */
  45277. poleTargetMesh: AbstractMesh;
  45278. /**
  45279. * Gets or sets the bone used as pole
  45280. */
  45281. poleTargetBone: Nullable<Bone>;
  45282. /**
  45283. * Gets or sets the target position
  45284. */
  45285. targetPosition: Vector3;
  45286. /**
  45287. * Gets or sets the pole target position
  45288. */
  45289. poleTargetPosition: Vector3;
  45290. /**
  45291. * Gets or sets the pole target local offset
  45292. */
  45293. poleTargetLocalOffset: Vector3;
  45294. /**
  45295. * Gets or sets the pole angle
  45296. */
  45297. poleAngle: number;
  45298. /**
  45299. * Gets or sets the mesh associated with the controller
  45300. */
  45301. mesh: AbstractMesh;
  45302. /**
  45303. * 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)
  45304. */
  45305. slerpAmount: number;
  45306. private _bone1Quat;
  45307. private _bone1Mat;
  45308. private _bone2Ang;
  45309. private _bone1;
  45310. private _bone2;
  45311. private _bone1Length;
  45312. private _bone2Length;
  45313. private _maxAngle;
  45314. private _maxReach;
  45315. private _rightHandedSystem;
  45316. private _bendAxis;
  45317. private _slerping;
  45318. private _adjustRoll;
  45319. /**
  45320. * Gets or sets maximum allowed angle
  45321. */
  45322. get maxAngle(): number;
  45323. set maxAngle(value: number);
  45324. /**
  45325. * Creates a new BoneIKController
  45326. * @param mesh defines the mesh to control
  45327. * @param bone defines the bone to control
  45328. * @param options defines options to set up the controller
  45329. */
  45330. constructor(mesh: AbstractMesh, bone: Bone, options?: {
  45331. targetMesh?: AbstractMesh;
  45332. poleTargetMesh?: AbstractMesh;
  45333. poleTargetBone?: Bone;
  45334. poleTargetLocalOffset?: Vector3;
  45335. poleAngle?: number;
  45336. bendAxis?: Vector3;
  45337. maxAngle?: number;
  45338. slerpAmount?: number;
  45339. });
  45340. private _setMaxAngle;
  45341. /**
  45342. * Force the controller to update the bones
  45343. */
  45344. update(): void;
  45345. }
  45346. }
  45347. declare module "babylonjs/Bones/boneLookController" {
  45348. import { Vector3 } from "babylonjs/Maths/math.vector";
  45349. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  45350. import { Bone } from "babylonjs/Bones/bone";
  45351. import { Space } from "babylonjs/Maths/math.axis";
  45352. /**
  45353. * Class used to make a bone look toward a point in space
  45354. * @see https://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#bonelookcontroller
  45355. */
  45356. export class BoneLookController {
  45357. private static _tmpVecs;
  45358. private static _tmpQuat;
  45359. private static _tmpMats;
  45360. /**
  45361. * The target Vector3 that the bone will look at
  45362. */
  45363. target: Vector3;
  45364. /**
  45365. * The mesh that the bone is attached to
  45366. */
  45367. mesh: AbstractMesh;
  45368. /**
  45369. * The bone that will be looking to the target
  45370. */
  45371. bone: Bone;
  45372. /**
  45373. * The up axis of the coordinate system that is used when the bone is rotated
  45374. */
  45375. upAxis: Vector3;
  45376. /**
  45377. * The space that the up axis is in - Space.BONE, Space.LOCAL (default), or Space.WORLD
  45378. */
  45379. upAxisSpace: Space;
  45380. /**
  45381. * Used to make an adjustment to the yaw of the bone
  45382. */
  45383. adjustYaw: number;
  45384. /**
  45385. * Used to make an adjustment to the pitch of the bone
  45386. */
  45387. adjustPitch: number;
  45388. /**
  45389. * Used to make an adjustment to the roll of the bone
  45390. */
  45391. adjustRoll: number;
  45392. /**
  45393. * 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)
  45394. */
  45395. slerpAmount: number;
  45396. private _minYaw;
  45397. private _maxYaw;
  45398. private _minPitch;
  45399. private _maxPitch;
  45400. private _minYawSin;
  45401. private _minYawCos;
  45402. private _maxYawSin;
  45403. private _maxYawCos;
  45404. private _midYawConstraint;
  45405. private _minPitchTan;
  45406. private _maxPitchTan;
  45407. private _boneQuat;
  45408. private _slerping;
  45409. private _transformYawPitch;
  45410. private _transformYawPitchInv;
  45411. private _firstFrameSkipped;
  45412. private _yawRange;
  45413. private _fowardAxis;
  45414. /**
  45415. * Gets or sets the minimum yaw angle that the bone can look to
  45416. */
  45417. get minYaw(): number;
  45418. set minYaw(value: number);
  45419. /**
  45420. * Gets or sets the maximum yaw angle that the bone can look to
  45421. */
  45422. get maxYaw(): number;
  45423. set maxYaw(value: number);
  45424. /**
  45425. * Gets or sets the minimum pitch angle that the bone can look to
  45426. */
  45427. get minPitch(): number;
  45428. set minPitch(value: number);
  45429. /**
  45430. * Gets or sets the maximum pitch angle that the bone can look to
  45431. */
  45432. get maxPitch(): number;
  45433. set maxPitch(value: number);
  45434. /**
  45435. * Create a BoneLookController
  45436. * @param mesh the mesh that the bone belongs to
  45437. * @param bone the bone that will be looking to the target
  45438. * @param target the target Vector3 to look at
  45439. * @param options optional settings:
  45440. * * maxYaw: the maximum angle the bone will yaw to
  45441. * * minYaw: the minimum angle the bone will yaw to
  45442. * * maxPitch: the maximum angle the bone will pitch to
  45443. * * minPitch: the minimum angle the bone will yaw to
  45444. * * slerpAmount: set the between 0 and 1 to make the bone slerp to the target.
  45445. * * upAxis: the up axis of the coordinate system
  45446. * * upAxisSpace: the space that the up axis is in - Space.BONE, Space.LOCAL (default), or Space.WORLD.
  45447. * * yawAxis: set yawAxis if the bone does not yaw on the y axis
  45448. * * pitchAxis: set pitchAxis if the bone does not pitch on the x axis
  45449. * * adjustYaw: used to make an adjustment to the yaw of the bone
  45450. * * adjustPitch: used to make an adjustment to the pitch of the bone
  45451. * * adjustRoll: used to make an adjustment to the roll of the bone
  45452. **/
  45453. constructor(mesh: AbstractMesh, bone: Bone, target: Vector3, options?: {
  45454. maxYaw?: number;
  45455. minYaw?: number;
  45456. maxPitch?: number;
  45457. minPitch?: number;
  45458. slerpAmount?: number;
  45459. upAxis?: Vector3;
  45460. upAxisSpace?: Space;
  45461. yawAxis?: Vector3;
  45462. pitchAxis?: Vector3;
  45463. adjustYaw?: number;
  45464. adjustPitch?: number;
  45465. adjustRoll?: number;
  45466. });
  45467. /**
  45468. * Update the bone to look at the target. This should be called before the scene is rendered (use scene.registerBeforeRender())
  45469. */
  45470. update(): void;
  45471. private _getAngleDiff;
  45472. private _getAngleBetween;
  45473. private _isAngleBetween;
  45474. }
  45475. }
  45476. declare module "babylonjs/Bones/index" {
  45477. export * from "babylonjs/Bones/bone";
  45478. export * from "babylonjs/Bones/boneIKController";
  45479. export * from "babylonjs/Bones/boneLookController";
  45480. export * from "babylonjs/Bones/skeleton";
  45481. }
  45482. declare module "babylonjs/Cameras/Inputs/arcRotateCameraGamepadInput" {
  45483. import { Nullable } from "babylonjs/types";
  45484. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  45485. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  45486. import { Gamepad } from "babylonjs/Gamepads/gamepad";
  45487. /**
  45488. * Manage the gamepad inputs to control an arc rotate camera.
  45489. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  45490. */
  45491. export class ArcRotateCameraGamepadInput implements ICameraInput<ArcRotateCamera> {
  45492. /**
  45493. * Defines the camera the input is attached to.
  45494. */
  45495. camera: ArcRotateCamera;
  45496. /**
  45497. * Defines the gamepad the input is gathering event from.
  45498. */
  45499. gamepad: Nullable<Gamepad>;
  45500. /**
  45501. * Defines the gamepad rotation sensiblity.
  45502. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  45503. */
  45504. gamepadRotationSensibility: number;
  45505. /**
  45506. * Defines the gamepad move sensiblity.
  45507. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  45508. */
  45509. gamepadMoveSensibility: number;
  45510. private _yAxisScale;
  45511. /**
  45512. * Gets or sets a boolean indicating that Yaxis (for right stick) should be inverted
  45513. */
  45514. get invertYAxis(): boolean;
  45515. set invertYAxis(value: boolean);
  45516. private _onGamepadConnectedObserver;
  45517. private _onGamepadDisconnectedObserver;
  45518. /**
  45519. * Attach the input controls to a specific dom element to get the input from.
  45520. * @param element Defines the element the controls should be listened from
  45521. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  45522. */
  45523. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  45524. /**
  45525. * Detach the current controls from the specified dom element.
  45526. * @param element Defines the element to stop listening the inputs from
  45527. */
  45528. detachControl(element: Nullable<HTMLElement>): void;
  45529. /**
  45530. * Update the current camera state depending on the inputs that have been used this frame.
  45531. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  45532. */
  45533. checkInputs(): void;
  45534. /**
  45535. * Gets the class name of the current intput.
  45536. * @returns the class name
  45537. */
  45538. getClassName(): string;
  45539. /**
  45540. * Get the friendly name associated with the input class.
  45541. * @returns the input friendly name
  45542. */
  45543. getSimpleName(): string;
  45544. }
  45545. }
  45546. declare module "babylonjs/Cameras/Inputs/arcRotateCameraVRDeviceOrientationInput" {
  45547. import { Nullable } from "babylonjs/types";
  45548. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  45549. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  45550. module "babylonjs/Cameras/arcRotateCameraInputsManager" {
  45551. interface ArcRotateCameraInputsManager {
  45552. /**
  45553. * Add orientation input support to the input manager.
  45554. * @returns the current input manager
  45555. */
  45556. addVRDeviceOrientation(): ArcRotateCameraInputsManager;
  45557. }
  45558. }
  45559. /**
  45560. * Manage the device orientation inputs (gyroscope) to control an arc rotate camera.
  45561. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  45562. */
  45563. export class ArcRotateCameraVRDeviceOrientationInput implements ICameraInput<ArcRotateCamera> {
  45564. /**
  45565. * Defines the camera the input is attached to.
  45566. */
  45567. camera: ArcRotateCamera;
  45568. /**
  45569. * Defines a correction factor applied on the alpha value retrieved from the orientation events.
  45570. */
  45571. alphaCorrection: number;
  45572. /**
  45573. * Defines a correction factor applied on the gamma value retrieved from the orientation events.
  45574. */
  45575. gammaCorrection: number;
  45576. private _alpha;
  45577. private _gamma;
  45578. private _dirty;
  45579. private _deviceOrientationHandler;
  45580. /**
  45581. * Instantiate a new ArcRotateCameraVRDeviceOrientationInput.
  45582. */
  45583. constructor();
  45584. /**
  45585. * Attach the input controls to a specific dom element to get the input from.
  45586. * @param element Defines the element the controls should be listened from
  45587. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  45588. */
  45589. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  45590. /** @hidden */
  45591. _onOrientationEvent(evt: DeviceOrientationEvent): void;
  45592. /**
  45593. * Update the current camera state depending on the inputs that have been used this frame.
  45594. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  45595. */
  45596. checkInputs(): void;
  45597. /**
  45598. * Detach the current controls from the specified dom element.
  45599. * @param element Defines the element to stop listening the inputs from
  45600. */
  45601. detachControl(element: Nullable<HTMLElement>): void;
  45602. /**
  45603. * Gets the class name of the current intput.
  45604. * @returns the class name
  45605. */
  45606. getClassName(): string;
  45607. /**
  45608. * Get the friendly name associated with the input class.
  45609. * @returns the input friendly name
  45610. */
  45611. getSimpleName(): string;
  45612. }
  45613. }
  45614. declare module "babylonjs/Cameras/Inputs/flyCameraMouseInput" {
  45615. import { Nullable } from "babylonjs/types";
  45616. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  45617. import { FlyCamera } from "babylonjs/Cameras/flyCamera";
  45618. /**
  45619. * Listen to mouse events to control the camera.
  45620. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  45621. */
  45622. export class FlyCameraMouseInput implements ICameraInput<FlyCamera> {
  45623. /**
  45624. * Defines the camera the input is attached to.
  45625. */
  45626. camera: FlyCamera;
  45627. /**
  45628. * Defines if touch is enabled. (Default is true.)
  45629. */
  45630. touchEnabled: boolean;
  45631. /**
  45632. * Defines the buttons associated with the input to handle camera rotation.
  45633. */
  45634. buttons: number[];
  45635. /**
  45636. * Assign buttons for Yaw control.
  45637. */
  45638. buttonsYaw: number[];
  45639. /**
  45640. * Assign buttons for Pitch control.
  45641. */
  45642. buttonsPitch: number[];
  45643. /**
  45644. * Assign buttons for Roll control.
  45645. */
  45646. buttonsRoll: number[];
  45647. /**
  45648. * Detect if any button is being pressed while mouse is moved.
  45649. * -1 = Mouse locked.
  45650. * 0 = Left button.
  45651. * 1 = Middle Button.
  45652. * 2 = Right Button.
  45653. */
  45654. activeButton: number;
  45655. /**
  45656. * Defines the pointer's angular sensibility, to control the camera rotation speed.
  45657. * Higher values reduce its sensitivity.
  45658. */
  45659. angularSensibility: number;
  45660. private _mousemoveCallback;
  45661. private _observer;
  45662. private _rollObserver;
  45663. private previousPosition;
  45664. private noPreventDefault;
  45665. private element;
  45666. /**
  45667. * Listen to mouse events to control the camera.
  45668. * @param touchEnabled Define if touch is enabled. (Default is true.)
  45669. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  45670. */
  45671. constructor(touchEnabled?: boolean);
  45672. /**
  45673. * Attach the mouse control to the HTML DOM element.
  45674. * @param element Defines the element that listens to the input events.
  45675. * @param noPreventDefault Defines whether events caught by the controls should call preventdefault().
  45676. */
  45677. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  45678. /**
  45679. * Detach the current controls from the specified dom element.
  45680. * @param element Defines the element to stop listening the inputs from
  45681. */
  45682. detachControl(element: Nullable<HTMLElement>): void;
  45683. /**
  45684. * Gets the class name of the current input.
  45685. * @returns the class name.
  45686. */
  45687. getClassName(): string;
  45688. /**
  45689. * Get the friendly name associated with the input class.
  45690. * @returns the input's friendly name.
  45691. */
  45692. getSimpleName(): string;
  45693. private _pointerInput;
  45694. private _onMouseMove;
  45695. /**
  45696. * Rotate camera by mouse offset.
  45697. */
  45698. private rotateCamera;
  45699. }
  45700. }
  45701. declare module "babylonjs/Cameras/flyCameraInputsManager" {
  45702. import { FlyCamera } from "babylonjs/Cameras/flyCamera";
  45703. import { CameraInputsManager } from "babylonjs/Cameras/cameraInputsManager";
  45704. /**
  45705. * Default Inputs manager for the FlyCamera.
  45706. * It groups all the default supported inputs for ease of use.
  45707. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  45708. */
  45709. export class FlyCameraInputsManager extends CameraInputsManager<FlyCamera> {
  45710. /**
  45711. * Instantiates a new FlyCameraInputsManager.
  45712. * @param camera Defines the camera the inputs belong to.
  45713. */
  45714. constructor(camera: FlyCamera);
  45715. /**
  45716. * Add keyboard input support to the input manager.
  45717. * @returns the new FlyCameraKeyboardMoveInput().
  45718. */
  45719. addKeyboard(): FlyCameraInputsManager;
  45720. /**
  45721. * Add mouse input support to the input manager.
  45722. * @param touchEnabled Enable touch screen support.
  45723. * @returns the new FlyCameraMouseInput().
  45724. */
  45725. addMouse(touchEnabled?: boolean): FlyCameraInputsManager;
  45726. }
  45727. }
  45728. declare module "babylonjs/Cameras/flyCamera" {
  45729. import { Scene } from "babylonjs/scene";
  45730. import { Vector3, Quaternion } from "babylonjs/Maths/math.vector";
  45731. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  45732. import { TargetCamera } from "babylonjs/Cameras/targetCamera";
  45733. import { FlyCameraInputsManager } from "babylonjs/Cameras/flyCameraInputsManager";
  45734. /**
  45735. * This is a flying camera, designed for 3D movement and rotation in all directions,
  45736. * such as in a 3D Space Shooter or a Flight Simulator.
  45737. */
  45738. export class FlyCamera extends TargetCamera {
  45739. /**
  45740. * Define the collision ellipsoid of the camera.
  45741. * This is helpful for simulating a camera body, like a player's body.
  45742. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  45743. */
  45744. ellipsoid: Vector3;
  45745. /**
  45746. * Define an offset for the position of the ellipsoid around the camera.
  45747. * This can be helpful if the camera is attached away from the player's body center,
  45748. * such as at its head.
  45749. */
  45750. ellipsoidOffset: Vector3;
  45751. /**
  45752. * Enable or disable collisions of the camera with the rest of the scene objects.
  45753. */
  45754. checkCollisions: boolean;
  45755. /**
  45756. * Enable or disable gravity on the camera.
  45757. */
  45758. applyGravity: boolean;
  45759. /**
  45760. * Define the current direction the camera is moving to.
  45761. */
  45762. cameraDirection: Vector3;
  45763. /**
  45764. * Define the current local rotation of the camera as a quaternion to prevent Gimbal lock.
  45765. * This overrides and empties cameraRotation.
  45766. */
  45767. rotationQuaternion: Quaternion;
  45768. /**
  45769. * Track Roll to maintain the wanted Rolling when looking around.
  45770. */
  45771. _trackRoll: number;
  45772. /**
  45773. * Slowly correct the Roll to its original value after a Pitch+Yaw rotation.
  45774. */
  45775. rollCorrect: number;
  45776. /**
  45777. * Mimic a banked turn, Rolling the camera when Yawing.
  45778. * It's recommended to use rollCorrect = 10 for faster banking correction.
  45779. */
  45780. bankedTurn: boolean;
  45781. /**
  45782. * Limit in radians for how much Roll banking will add. (Default: 90°)
  45783. */
  45784. bankedTurnLimit: number;
  45785. /**
  45786. * Value of 0 disables the banked Roll.
  45787. * Value of 1 is equal to the Yaw angle in radians.
  45788. */
  45789. bankedTurnMultiplier: number;
  45790. /**
  45791. * The inputs manager loads all the input sources, such as keyboard and mouse.
  45792. */
  45793. inputs: FlyCameraInputsManager;
  45794. /**
  45795. * Gets the input sensibility for mouse input.
  45796. * Higher values reduce sensitivity.
  45797. */
  45798. get angularSensibility(): number;
  45799. /**
  45800. * Sets the input sensibility for a mouse input.
  45801. * Higher values reduce sensitivity.
  45802. */
  45803. set angularSensibility(value: number);
  45804. /**
  45805. * Get the keys for camera movement forward.
  45806. */
  45807. get keysForward(): number[];
  45808. /**
  45809. * Set the keys for camera movement forward.
  45810. */
  45811. set keysForward(value: number[]);
  45812. /**
  45813. * Get the keys for camera movement backward.
  45814. */
  45815. get keysBackward(): number[];
  45816. set keysBackward(value: number[]);
  45817. /**
  45818. * Get the keys for camera movement up.
  45819. */
  45820. get keysUp(): number[];
  45821. /**
  45822. * Set the keys for camera movement up.
  45823. */
  45824. set keysUp(value: number[]);
  45825. /**
  45826. * Get the keys for camera movement down.
  45827. */
  45828. get keysDown(): number[];
  45829. /**
  45830. * Set the keys for camera movement down.
  45831. */
  45832. set keysDown(value: number[]);
  45833. /**
  45834. * Get the keys for camera movement left.
  45835. */
  45836. get keysLeft(): number[];
  45837. /**
  45838. * Set the keys for camera movement left.
  45839. */
  45840. set keysLeft(value: number[]);
  45841. /**
  45842. * Set the keys for camera movement right.
  45843. */
  45844. get keysRight(): number[];
  45845. /**
  45846. * Set the keys for camera movement right.
  45847. */
  45848. set keysRight(value: number[]);
  45849. /**
  45850. * Event raised when the camera collides with a mesh in the scene.
  45851. */
  45852. onCollide: (collidedMesh: AbstractMesh) => void;
  45853. private _collider;
  45854. private _needMoveForGravity;
  45855. private _oldPosition;
  45856. private _diffPosition;
  45857. private _newPosition;
  45858. /** @hidden */
  45859. _localDirection: Vector3;
  45860. /** @hidden */
  45861. _transformedDirection: Vector3;
  45862. /**
  45863. * Instantiates a FlyCamera.
  45864. * This is a flying camera, designed for 3D movement and rotation in all directions,
  45865. * such as in a 3D Space Shooter or a Flight Simulator.
  45866. * @param name Define the name of the camera in the scene.
  45867. * @param position Define the starting position of the camera in the scene.
  45868. * @param scene Define the scene the camera belongs to.
  45869. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active, if no other camera has been defined as active.
  45870. */
  45871. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  45872. /**
  45873. * Attach a control to the HTML DOM element.
  45874. * @param element Defines the element that listens to the input events.
  45875. * @param noPreventDefault Defines whether events caught by the controls should call preventdefault(). https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault
  45876. */
  45877. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  45878. /**
  45879. * Detach a control from the HTML DOM element.
  45880. * The camera will stop reacting to that input.
  45881. * @param element Defines the element that listens to the input events.
  45882. */
  45883. detachControl(element: HTMLElement): void;
  45884. private _collisionMask;
  45885. /**
  45886. * Get the mask that the camera ignores in collision events.
  45887. */
  45888. get collisionMask(): number;
  45889. /**
  45890. * Set the mask that the camera ignores in collision events.
  45891. */
  45892. set collisionMask(mask: number);
  45893. /** @hidden */
  45894. _collideWithWorld(displacement: Vector3): void;
  45895. /** @hidden */
  45896. private _onCollisionPositionChange;
  45897. /** @hidden */
  45898. _checkInputs(): void;
  45899. /** @hidden */
  45900. _decideIfNeedsToMove(): boolean;
  45901. /** @hidden */
  45902. _updatePosition(): void;
  45903. /**
  45904. * Restore the Roll to its target value at the rate specified.
  45905. * @param rate - Higher means slower restoring.
  45906. * @hidden
  45907. */
  45908. restoreRoll(rate: number): void;
  45909. /**
  45910. * Destroy the camera and release the current resources held by it.
  45911. */
  45912. dispose(): void;
  45913. /**
  45914. * Get the current object class name.
  45915. * @returns the class name.
  45916. */
  45917. getClassName(): string;
  45918. }
  45919. }
  45920. declare module "babylonjs/Cameras/Inputs/flyCameraKeyboardInput" {
  45921. import { Nullable } from "babylonjs/types";
  45922. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  45923. import { FlyCamera } from "babylonjs/Cameras/flyCamera";
  45924. /**
  45925. * Listen to keyboard events to control the camera.
  45926. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  45927. */
  45928. export class FlyCameraKeyboardInput implements ICameraInput<FlyCamera> {
  45929. /**
  45930. * Defines the camera the input is attached to.
  45931. */
  45932. camera: FlyCamera;
  45933. /**
  45934. * The list of keyboard keys used to control the forward move of the camera.
  45935. */
  45936. keysForward: number[];
  45937. /**
  45938. * The list of keyboard keys used to control the backward move of the camera.
  45939. */
  45940. keysBackward: number[];
  45941. /**
  45942. * The list of keyboard keys used to control the forward move of the camera.
  45943. */
  45944. keysUp: number[];
  45945. /**
  45946. * The list of keyboard keys used to control the backward move of the camera.
  45947. */
  45948. keysDown: number[];
  45949. /**
  45950. * The list of keyboard keys used to control the right strafe move of the camera.
  45951. */
  45952. keysRight: number[];
  45953. /**
  45954. * The list of keyboard keys used to control the left strafe move of the camera.
  45955. */
  45956. keysLeft: number[];
  45957. private _keys;
  45958. private _onCanvasBlurObserver;
  45959. private _onKeyboardObserver;
  45960. private _engine;
  45961. private _scene;
  45962. /**
  45963. * Attach the input controls to a specific dom element to get the input from.
  45964. * @param element Defines the element the controls should be listened from
  45965. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  45966. */
  45967. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  45968. /**
  45969. * Detach the current controls from the specified dom element.
  45970. * @param element Defines the element to stop listening the inputs from
  45971. */
  45972. detachControl(element: Nullable<HTMLElement>): void;
  45973. /**
  45974. * Gets the class name of the current intput.
  45975. * @returns the class name
  45976. */
  45977. getClassName(): string;
  45978. /** @hidden */
  45979. _onLostFocus(e: FocusEvent): void;
  45980. /**
  45981. * Get the friendly name associated with the input class.
  45982. * @returns the input friendly name
  45983. */
  45984. getSimpleName(): string;
  45985. /**
  45986. * Update the current camera state depending on the inputs that have been used this frame.
  45987. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  45988. */
  45989. checkInputs(): void;
  45990. }
  45991. }
  45992. declare module "babylonjs/Cameras/Inputs/followCameraMouseWheelInput" {
  45993. import { Nullable } from "babylonjs/types";
  45994. import { FollowCamera } from "babylonjs/Cameras/followCamera";
  45995. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  45996. /**
  45997. * Manage the mouse wheel inputs to control a follow camera.
  45998. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  45999. */
  46000. export class FollowCameraMouseWheelInput implements ICameraInput<FollowCamera> {
  46001. /**
  46002. * Defines the camera the input is attached to.
  46003. */
  46004. camera: FollowCamera;
  46005. /**
  46006. * Moue wheel controls zoom. (Mouse wheel modifies camera.radius value.)
  46007. */
  46008. axisControlRadius: boolean;
  46009. /**
  46010. * Moue wheel controls height. (Mouse wheel modifies camera.heightOffset value.)
  46011. */
  46012. axisControlHeight: boolean;
  46013. /**
  46014. * Moue wheel controls angle. (Mouse wheel modifies camera.rotationOffset value.)
  46015. */
  46016. axisControlRotation: boolean;
  46017. /**
  46018. * Gets or Set the mouse wheel precision or how fast is the camera moves in
  46019. * relation to mouseWheel events.
  46020. */
  46021. wheelPrecision: number;
  46022. /**
  46023. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  46024. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  46025. */
  46026. wheelDeltaPercentage: number;
  46027. private _wheel;
  46028. private _observer;
  46029. /**
  46030. * Attach the input controls to a specific dom element to get the input from.
  46031. * @param element Defines the element the controls should be listened from
  46032. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  46033. */
  46034. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  46035. /**
  46036. * Detach the current controls from the specified dom element.
  46037. * @param element Defines the element to stop listening the inputs from
  46038. */
  46039. detachControl(element: Nullable<HTMLElement>): void;
  46040. /**
  46041. * Gets the class name of the current intput.
  46042. * @returns the class name
  46043. */
  46044. getClassName(): string;
  46045. /**
  46046. * Get the friendly name associated with the input class.
  46047. * @returns the input friendly name
  46048. */
  46049. getSimpleName(): string;
  46050. }
  46051. }
  46052. declare module "babylonjs/Cameras/Inputs/followCameraPointersInput" {
  46053. import { Nullable } from "babylonjs/types";
  46054. import { FollowCamera } from "babylonjs/Cameras/followCamera";
  46055. import { BaseCameraPointersInput } from "babylonjs/Cameras/Inputs/BaseCameraPointersInput";
  46056. import { PointerTouch } from "babylonjs/Events/pointerEvents";
  46057. /**
  46058. * Manage the pointers inputs to control an follow camera.
  46059. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  46060. */
  46061. export class FollowCameraPointersInput extends BaseCameraPointersInput {
  46062. /**
  46063. * Defines the camera the input is attached to.
  46064. */
  46065. camera: FollowCamera;
  46066. /**
  46067. * Gets the class name of the current input.
  46068. * @returns the class name
  46069. */
  46070. getClassName(): string;
  46071. /**
  46072. * Defines the pointer angular sensibility along the X axis or how fast is
  46073. * the camera rotating.
  46074. * A negative number will reverse the axis direction.
  46075. */
  46076. angularSensibilityX: number;
  46077. /**
  46078. * Defines the pointer angular sensibility along the Y axis or how fast is
  46079. * the camera rotating.
  46080. * A negative number will reverse the axis direction.
  46081. */
  46082. angularSensibilityY: number;
  46083. /**
  46084. * Defines the pointer pinch precision or how fast is the camera zooming.
  46085. * A negative number will reverse the axis direction.
  46086. */
  46087. pinchPrecision: number;
  46088. /**
  46089. * pinchDeltaPercentage will be used instead of pinchPrecision if different
  46090. * from 0.
  46091. * It defines the percentage of current camera.radius to use as delta when
  46092. * pinch zoom is used.
  46093. */
  46094. pinchDeltaPercentage: number;
  46095. /**
  46096. * Pointer X axis controls zoom. (X axis modifies camera.radius value.)
  46097. */
  46098. axisXControlRadius: boolean;
  46099. /**
  46100. * Pointer X axis controls height. (X axis modifies camera.heightOffset value.)
  46101. */
  46102. axisXControlHeight: boolean;
  46103. /**
  46104. * Pointer X axis controls angle. (X axis modifies camera.rotationOffset value.)
  46105. */
  46106. axisXControlRotation: boolean;
  46107. /**
  46108. * Pointer Y axis controls zoom. (Y axis modifies camera.radius value.)
  46109. */
  46110. axisYControlRadius: boolean;
  46111. /**
  46112. * Pointer Y axis controls height. (Y axis modifies camera.heightOffset value.)
  46113. */
  46114. axisYControlHeight: boolean;
  46115. /**
  46116. * Pointer Y axis controls angle. (Y axis modifies camera.rotationOffset value.)
  46117. */
  46118. axisYControlRotation: boolean;
  46119. /**
  46120. * Pinch controls zoom. (Pinch modifies camera.radius value.)
  46121. */
  46122. axisPinchControlRadius: boolean;
  46123. /**
  46124. * Pinch controls height. (Pinch modifies camera.heightOffset value.)
  46125. */
  46126. axisPinchControlHeight: boolean;
  46127. /**
  46128. * Pinch controls angle. (Pinch modifies camera.rotationOffset value.)
  46129. */
  46130. axisPinchControlRotation: boolean;
  46131. /**
  46132. * Log error messages if basic misconfiguration has occurred.
  46133. */
  46134. warningEnable: boolean;
  46135. protected onTouch(pointA: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  46136. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  46137. private _warningCounter;
  46138. private _warning;
  46139. }
  46140. }
  46141. declare module "babylonjs/Cameras/followCameraInputsManager" {
  46142. import { CameraInputsManager } from "babylonjs/Cameras/cameraInputsManager";
  46143. import { FollowCamera } from "babylonjs/Cameras/followCamera";
  46144. /**
  46145. * Default Inputs manager for the FollowCamera.
  46146. * It groups all the default supported inputs for ease of use.
  46147. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  46148. */
  46149. export class FollowCameraInputsManager extends CameraInputsManager<FollowCamera> {
  46150. /**
  46151. * Instantiates a new FollowCameraInputsManager.
  46152. * @param camera Defines the camera the inputs belong to
  46153. */
  46154. constructor(camera: FollowCamera);
  46155. /**
  46156. * Add keyboard input support to the input manager.
  46157. * @returns the current input manager
  46158. */
  46159. addKeyboard(): FollowCameraInputsManager;
  46160. /**
  46161. * Add mouse wheel input support to the input manager.
  46162. * @returns the current input manager
  46163. */
  46164. addMouseWheel(): FollowCameraInputsManager;
  46165. /**
  46166. * Add pointers input support to the input manager.
  46167. * @returns the current input manager
  46168. */
  46169. addPointers(): FollowCameraInputsManager;
  46170. /**
  46171. * Add orientation input support to the input manager.
  46172. * @returns the current input manager
  46173. */
  46174. addVRDeviceOrientation(): FollowCameraInputsManager;
  46175. }
  46176. }
  46177. declare module "babylonjs/Cameras/followCamera" {
  46178. import { Nullable } from "babylonjs/types";
  46179. import { TargetCamera } from "babylonjs/Cameras/targetCamera";
  46180. import { Scene } from "babylonjs/scene";
  46181. import { Vector3 } from "babylonjs/Maths/math.vector";
  46182. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  46183. import { FollowCameraInputsManager } from "babylonjs/Cameras/followCameraInputsManager";
  46184. /**
  46185. * A follow camera takes a mesh as a target and follows it as it moves. Both a free camera version followCamera and
  46186. * an arc rotate version arcFollowCamera are available.
  46187. * @see https://doc.babylonjs.com/features/cameras#follow-camera
  46188. */
  46189. export class FollowCamera extends TargetCamera {
  46190. /**
  46191. * Distance the follow camera should follow an object at
  46192. */
  46193. radius: number;
  46194. /**
  46195. * Minimum allowed distance of the camera to the axis of rotation
  46196. * (The camera can not get closer).
  46197. * This can help limiting how the Camera is able to move in the scene.
  46198. */
  46199. lowerRadiusLimit: Nullable<number>;
  46200. /**
  46201. * Maximum allowed distance of the camera to the axis of rotation
  46202. * (The camera can not get further).
  46203. * This can help limiting how the Camera is able to move in the scene.
  46204. */
  46205. upperRadiusLimit: Nullable<number>;
  46206. /**
  46207. * Define a rotation offset between the camera and the object it follows
  46208. */
  46209. rotationOffset: number;
  46210. /**
  46211. * Minimum allowed angle to camera position relative to target object.
  46212. * This can help limiting how the Camera is able to move in the scene.
  46213. */
  46214. lowerRotationOffsetLimit: Nullable<number>;
  46215. /**
  46216. * Maximum allowed angle to camera position relative to target object.
  46217. * This can help limiting how the Camera is able to move in the scene.
  46218. */
  46219. upperRotationOffsetLimit: Nullable<number>;
  46220. /**
  46221. * Define a height offset between the camera and the object it follows.
  46222. * It can help following an object from the top (like a car chaing a plane)
  46223. */
  46224. heightOffset: number;
  46225. /**
  46226. * Minimum allowed height of camera position relative to target object.
  46227. * This can help limiting how the Camera is able to move in the scene.
  46228. */
  46229. lowerHeightOffsetLimit: Nullable<number>;
  46230. /**
  46231. * Maximum allowed height of camera position relative to target object.
  46232. * This can help limiting how the Camera is able to move in the scene.
  46233. */
  46234. upperHeightOffsetLimit: Nullable<number>;
  46235. /**
  46236. * Define how fast the camera can accelerate to follow it s target.
  46237. */
  46238. cameraAcceleration: number;
  46239. /**
  46240. * Define the speed limit of the camera following an object.
  46241. */
  46242. maxCameraSpeed: number;
  46243. /**
  46244. * Define the target of the camera.
  46245. */
  46246. lockedTarget: Nullable<AbstractMesh>;
  46247. /**
  46248. * Defines the input associated with the camera.
  46249. */
  46250. inputs: FollowCameraInputsManager;
  46251. /**
  46252. * Instantiates the follow camera.
  46253. * @see https://doc.babylonjs.com/features/cameras#follow-camera
  46254. * @param name Define the name of the camera in the scene
  46255. * @param position Define the position of the camera
  46256. * @param scene Define the scene the camera belong to
  46257. * @param lockedTarget Define the target of the camera
  46258. */
  46259. constructor(name: string, position: Vector3, scene: Scene, lockedTarget?: Nullable<AbstractMesh>);
  46260. private _follow;
  46261. /**
  46262. * Attached controls to the current camera.
  46263. * @param element Defines the element the controls should be listened from
  46264. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  46265. */
  46266. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  46267. /**
  46268. * Detach the current controls from the camera.
  46269. * The camera will stop reacting to inputs.
  46270. * @param element Defines the element to stop listening the inputs from
  46271. */
  46272. detachControl(element: HTMLElement): void;
  46273. /** @hidden */
  46274. _checkInputs(): void;
  46275. private _checkLimits;
  46276. /**
  46277. * Gets the camera class name.
  46278. * @returns the class name
  46279. */
  46280. getClassName(): string;
  46281. }
  46282. /**
  46283. * Arc Rotate version of the follow camera.
  46284. * It still follows a Defined mesh but in an Arc Rotate Camera fashion.
  46285. * @see https://doc.babylonjs.com/features/cameras#follow-camera
  46286. */
  46287. export class ArcFollowCamera extends TargetCamera {
  46288. /** The longitudinal angle of the camera */
  46289. alpha: number;
  46290. /** The latitudinal angle of the camera */
  46291. beta: number;
  46292. /** The radius of the camera from its target */
  46293. radius: number;
  46294. private _cartesianCoordinates;
  46295. /** Define the camera target (the mesh it should follow) */
  46296. private _meshTarget;
  46297. /**
  46298. * Instantiates a new ArcFollowCamera
  46299. * @see https://doc.babylonjs.com/features/cameras#follow-camera
  46300. * @param name Define the name of the camera
  46301. * @param alpha Define the rotation angle of the camera around the logitudinal axis
  46302. * @param beta Define the rotation angle of the camera around the elevation axis
  46303. * @param radius Define the radius of the camera from its target point
  46304. * @param target Define the target of the camera
  46305. * @param scene Define the scene the camera belongs to
  46306. */
  46307. constructor(name: string,
  46308. /** The longitudinal angle of the camera */
  46309. alpha: number,
  46310. /** The latitudinal angle of the camera */
  46311. beta: number,
  46312. /** The radius of the camera from its target */
  46313. radius: number,
  46314. /** Define the camera target (the mesh it should follow) */
  46315. target: Nullable<AbstractMesh>, scene: Scene);
  46316. private _follow;
  46317. /** @hidden */
  46318. _checkInputs(): void;
  46319. /**
  46320. * Returns the class name of the object.
  46321. * It is mostly used internally for serialization purposes.
  46322. */
  46323. getClassName(): string;
  46324. }
  46325. }
  46326. declare module "babylonjs/Cameras/Inputs/followCameraKeyboardMoveInput" {
  46327. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  46328. import { FollowCamera } from "babylonjs/Cameras/followCamera";
  46329. import { Nullable } from "babylonjs/types";
  46330. /**
  46331. * Manage the keyboard inputs to control the movement of a follow camera.
  46332. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  46333. */
  46334. export class FollowCameraKeyboardMoveInput implements ICameraInput<FollowCamera> {
  46335. /**
  46336. * Defines the camera the input is attached to.
  46337. */
  46338. camera: FollowCamera;
  46339. /**
  46340. * Defines the list of key codes associated with the up action (increase heightOffset)
  46341. */
  46342. keysHeightOffsetIncr: number[];
  46343. /**
  46344. * Defines the list of key codes associated with the down action (decrease heightOffset)
  46345. */
  46346. keysHeightOffsetDecr: number[];
  46347. /**
  46348. * Defines whether the Alt modifier key is required to move up/down (alter heightOffset)
  46349. */
  46350. keysHeightOffsetModifierAlt: boolean;
  46351. /**
  46352. * Defines whether the Ctrl modifier key is required to move up/down (alter heightOffset)
  46353. */
  46354. keysHeightOffsetModifierCtrl: boolean;
  46355. /**
  46356. * Defines whether the Shift modifier key is required to move up/down (alter heightOffset)
  46357. */
  46358. keysHeightOffsetModifierShift: boolean;
  46359. /**
  46360. * Defines the list of key codes associated with the left action (increase rotationOffset)
  46361. */
  46362. keysRotationOffsetIncr: number[];
  46363. /**
  46364. * Defines the list of key codes associated with the right action (decrease rotationOffset)
  46365. */
  46366. keysRotationOffsetDecr: number[];
  46367. /**
  46368. * Defines whether the Alt modifier key is required to move left/right (alter rotationOffset)
  46369. */
  46370. keysRotationOffsetModifierAlt: boolean;
  46371. /**
  46372. * Defines whether the Ctrl modifier key is required to move left/right (alter rotationOffset)
  46373. */
  46374. keysRotationOffsetModifierCtrl: boolean;
  46375. /**
  46376. * Defines whether the Shift modifier key is required to move left/right (alter rotationOffset)
  46377. */
  46378. keysRotationOffsetModifierShift: boolean;
  46379. /**
  46380. * Defines the list of key codes associated with the zoom-in action (decrease radius)
  46381. */
  46382. keysRadiusIncr: number[];
  46383. /**
  46384. * Defines the list of key codes associated with the zoom-out action (increase radius)
  46385. */
  46386. keysRadiusDecr: number[];
  46387. /**
  46388. * Defines whether the Alt modifier key is required to zoom in/out (alter radius value)
  46389. */
  46390. keysRadiusModifierAlt: boolean;
  46391. /**
  46392. * Defines whether the Ctrl modifier key is required to zoom in/out (alter radius value)
  46393. */
  46394. keysRadiusModifierCtrl: boolean;
  46395. /**
  46396. * Defines whether the Shift modifier key is required to zoom in/out (alter radius value)
  46397. */
  46398. keysRadiusModifierShift: boolean;
  46399. /**
  46400. * Defines the rate of change of heightOffset.
  46401. */
  46402. heightSensibility: number;
  46403. /**
  46404. * Defines the rate of change of rotationOffset.
  46405. */
  46406. rotationSensibility: number;
  46407. /**
  46408. * Defines the rate of change of radius.
  46409. */
  46410. radiusSensibility: number;
  46411. private _keys;
  46412. private _ctrlPressed;
  46413. private _altPressed;
  46414. private _shiftPressed;
  46415. private _onCanvasBlurObserver;
  46416. private _onKeyboardObserver;
  46417. private _engine;
  46418. private _scene;
  46419. /**
  46420. * Attach the input controls to a specific dom element to get the input from.
  46421. * @param element Defines the element the controls should be listened from
  46422. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  46423. */
  46424. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  46425. /**
  46426. * Detach the current controls from the specified dom element.
  46427. * @param element Defines the element to stop listening the inputs from
  46428. */
  46429. detachControl(element: Nullable<HTMLElement>): void;
  46430. /**
  46431. * Update the current camera state depending on the inputs that have been used this frame.
  46432. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  46433. */
  46434. checkInputs(): void;
  46435. /**
  46436. * Gets the class name of the current input.
  46437. * @returns the class name
  46438. */
  46439. getClassName(): string;
  46440. /**
  46441. * Get the friendly name associated with the input class.
  46442. * @returns the input friendly name
  46443. */
  46444. getSimpleName(): string;
  46445. /**
  46446. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  46447. * allow modification of the heightOffset value.
  46448. */
  46449. private _modifierHeightOffset;
  46450. /**
  46451. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  46452. * allow modification of the rotationOffset value.
  46453. */
  46454. private _modifierRotationOffset;
  46455. /**
  46456. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  46457. * allow modification of the radius value.
  46458. */
  46459. private _modifierRadius;
  46460. }
  46461. }
  46462. declare module "babylonjs/Cameras/Inputs/freeCameraDeviceOrientationInput" {
  46463. import { Nullable } from "babylonjs/types";
  46464. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  46465. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  46466. import { Observable } from "babylonjs/Misc/observable";
  46467. module "babylonjs/Cameras/freeCameraInputsManager" {
  46468. interface FreeCameraInputsManager {
  46469. /**
  46470. * @hidden
  46471. */
  46472. _deviceOrientationInput: Nullable<FreeCameraDeviceOrientationInput>;
  46473. /**
  46474. * Add orientation input support to the input manager.
  46475. * @returns the current input manager
  46476. */
  46477. addDeviceOrientation(): FreeCameraInputsManager;
  46478. }
  46479. }
  46480. /**
  46481. * Takes information about the orientation of the device as reported by the deviceorientation event to orient the camera.
  46482. * Screen rotation is taken into account.
  46483. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  46484. */
  46485. export class FreeCameraDeviceOrientationInput implements ICameraInput<FreeCamera> {
  46486. private _camera;
  46487. private _screenOrientationAngle;
  46488. private _constantTranform;
  46489. private _screenQuaternion;
  46490. private _alpha;
  46491. private _beta;
  46492. private _gamma;
  46493. /**
  46494. * Can be used to detect if a device orientation sensor is available on a device
  46495. * @param timeout amount of time in milliseconds to wait for a response from the sensor (default: infinite)
  46496. * @returns a promise that will resolve on orientation change
  46497. */
  46498. static WaitForOrientationChangeAsync(timeout?: number): Promise<unknown>;
  46499. /**
  46500. * @hidden
  46501. */
  46502. _onDeviceOrientationChangedObservable: Observable<void>;
  46503. /**
  46504. * Instantiates a new input
  46505. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  46506. */
  46507. constructor();
  46508. /**
  46509. * Define the camera controlled by the input.
  46510. */
  46511. get camera(): FreeCamera;
  46512. set camera(camera: FreeCamera);
  46513. /**
  46514. * Attach the input controls to a specific dom element to get the input from.
  46515. * @param element Defines the element the controls should be listened from
  46516. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  46517. */
  46518. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  46519. private _orientationChanged;
  46520. private _deviceOrientation;
  46521. /**
  46522. * Detach the current controls from the specified dom element.
  46523. * @param element Defines the element to stop listening the inputs from
  46524. */
  46525. detachControl(element: Nullable<HTMLElement>): void;
  46526. /**
  46527. * Update the current camera state depending on the inputs that have been used this frame.
  46528. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  46529. */
  46530. checkInputs(): void;
  46531. /**
  46532. * Gets the class name of the current intput.
  46533. * @returns the class name
  46534. */
  46535. getClassName(): string;
  46536. /**
  46537. * Get the friendly name associated with the input class.
  46538. * @returns the input friendly name
  46539. */
  46540. getSimpleName(): string;
  46541. }
  46542. }
  46543. declare module "babylonjs/Cameras/Inputs/freeCameraGamepadInput" {
  46544. import { Nullable } from "babylonjs/types";
  46545. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  46546. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  46547. import { Gamepad } from "babylonjs/Gamepads/gamepad";
  46548. /**
  46549. * Manage the gamepad inputs to control a free camera.
  46550. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  46551. */
  46552. export class FreeCameraGamepadInput implements ICameraInput<FreeCamera> {
  46553. /**
  46554. * Define the camera the input is attached to.
  46555. */
  46556. camera: FreeCamera;
  46557. /**
  46558. * Define the Gamepad controlling the input
  46559. */
  46560. gamepad: Nullable<Gamepad>;
  46561. /**
  46562. * Defines the gamepad rotation sensiblity.
  46563. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  46564. */
  46565. gamepadAngularSensibility: number;
  46566. /**
  46567. * Defines the gamepad move sensiblity.
  46568. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  46569. */
  46570. gamepadMoveSensibility: number;
  46571. private _yAxisScale;
  46572. /**
  46573. * Gets or sets a boolean indicating that Yaxis (for right stick) should be inverted
  46574. */
  46575. get invertYAxis(): boolean;
  46576. set invertYAxis(value: boolean);
  46577. private _onGamepadConnectedObserver;
  46578. private _onGamepadDisconnectedObserver;
  46579. private _cameraTransform;
  46580. private _deltaTransform;
  46581. private _vector3;
  46582. private _vector2;
  46583. /**
  46584. * Attach the input controls to a specific dom element to get the input from.
  46585. * @param element Defines the element the controls should be listened from
  46586. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  46587. */
  46588. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  46589. /**
  46590. * Detach the current controls from the specified dom element.
  46591. * @param element Defines the element to stop listening the inputs from
  46592. */
  46593. detachControl(element: Nullable<HTMLElement>): void;
  46594. /**
  46595. * Update the current camera state depending on the inputs that have been used this frame.
  46596. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  46597. */
  46598. checkInputs(): void;
  46599. /**
  46600. * Gets the class name of the current intput.
  46601. * @returns the class name
  46602. */
  46603. getClassName(): string;
  46604. /**
  46605. * Get the friendly name associated with the input class.
  46606. * @returns the input friendly name
  46607. */
  46608. getSimpleName(): string;
  46609. }
  46610. }
  46611. declare module "babylonjs/Misc/virtualJoystick" {
  46612. import { Nullable } from "babylonjs/types";
  46613. import { Vector3 } from "babylonjs/Maths/math.vector";
  46614. /**
  46615. * Defines the potential axis of a Joystick
  46616. */
  46617. export enum JoystickAxis {
  46618. /** X axis */
  46619. X = 0,
  46620. /** Y axis */
  46621. Y = 1,
  46622. /** Z axis */
  46623. Z = 2
  46624. }
  46625. /**
  46626. * Represents the different customization options available
  46627. * for VirtualJoystick
  46628. */
  46629. interface VirtualJoystickCustomizations {
  46630. /**
  46631. * Size of the joystick's puck
  46632. */
  46633. puckSize: number;
  46634. /**
  46635. * Size of the joystick's container
  46636. */
  46637. containerSize: number;
  46638. /**
  46639. * Color of the joystick && puck
  46640. */
  46641. color: string;
  46642. /**
  46643. * Image URL for the joystick's puck
  46644. */
  46645. puckImage?: string;
  46646. /**
  46647. * Image URL for the joystick's container
  46648. */
  46649. containerImage?: string;
  46650. /**
  46651. * Defines the unmoving position of the joystick container
  46652. */
  46653. position?: {
  46654. x: number;
  46655. y: number;
  46656. };
  46657. /**
  46658. * Defines whether or not the joystick container is always visible
  46659. */
  46660. alwaysVisible: boolean;
  46661. /**
  46662. * Defines whether or not to limit the movement of the puck to the joystick's container
  46663. */
  46664. limitToContainer: boolean;
  46665. }
  46666. /**
  46667. * Class used to define virtual joystick (used in touch mode)
  46668. */
  46669. export class VirtualJoystick {
  46670. /**
  46671. * Gets or sets a boolean indicating that left and right values must be inverted
  46672. */
  46673. reverseLeftRight: boolean;
  46674. /**
  46675. * Gets or sets a boolean indicating that up and down values must be inverted
  46676. */
  46677. reverseUpDown: boolean;
  46678. /**
  46679. * Gets the offset value for the position (ie. the change of the position value)
  46680. */
  46681. deltaPosition: Vector3;
  46682. /**
  46683. * Gets a boolean indicating if the virtual joystick was pressed
  46684. */
  46685. pressed: boolean;
  46686. /**
  46687. * Canvas the virtual joystick will render onto, default z-index of this is 5
  46688. */
  46689. static Canvas: Nullable<HTMLCanvasElement>;
  46690. /**
  46691. * boolean indicating whether or not the joystick's puck's movement should be limited to the joystick's container area
  46692. */
  46693. limitToContainer: boolean;
  46694. private static _globalJoystickIndex;
  46695. private static _alwaysVisibleSticks;
  46696. private static vjCanvasContext;
  46697. private static vjCanvasWidth;
  46698. private static vjCanvasHeight;
  46699. private static halfWidth;
  46700. private static _GetDefaultOptions;
  46701. private _action;
  46702. private _axisTargetedByLeftAndRight;
  46703. private _axisTargetedByUpAndDown;
  46704. private _joystickSensibility;
  46705. private _inversedSensibility;
  46706. private _joystickPointerID;
  46707. private _joystickColor;
  46708. private _joystickPointerPos;
  46709. private _joystickPreviousPointerPos;
  46710. private _joystickPointerStartPos;
  46711. private _deltaJoystickVector;
  46712. private _leftJoystick;
  46713. private _touches;
  46714. private _joystickPosition;
  46715. private _alwaysVisible;
  46716. private _puckImage;
  46717. private _containerImage;
  46718. private _joystickPuckSize;
  46719. private _joystickContainerSize;
  46720. private _clearPuckSize;
  46721. private _clearContainerSize;
  46722. private _clearPuckSizeOffset;
  46723. private _clearContainerSizeOffset;
  46724. private _onPointerDownHandlerRef;
  46725. private _onPointerMoveHandlerRef;
  46726. private _onPointerUpHandlerRef;
  46727. private _onResize;
  46728. /**
  46729. * Creates a new virtual joystick
  46730. * @param leftJoystick defines that the joystick is for left hand (false by default)
  46731. * @param customizations Defines the options we want to customize the VirtualJoystick
  46732. */
  46733. constructor(leftJoystick?: boolean, customizations?: Partial<VirtualJoystickCustomizations>);
  46734. /**
  46735. * Defines joystick sensibility (ie. the ratio beteen a physical move and virtual joystick position change)
  46736. * @param newJoystickSensibility defines the new sensibility
  46737. */
  46738. setJoystickSensibility(newJoystickSensibility: number): void;
  46739. private _onPointerDown;
  46740. private _onPointerMove;
  46741. private _onPointerUp;
  46742. /**
  46743. * Change the color of the virtual joystick
  46744. * @param newColor a string that must be a CSS color value (like "red") or the hexa value (like "#FF0000")
  46745. */
  46746. setJoystickColor(newColor: string): void;
  46747. /**
  46748. * Size of the joystick's container
  46749. */
  46750. set containerSize(newSize: number);
  46751. get containerSize(): number;
  46752. /**
  46753. * Size of the joystick's puck
  46754. */
  46755. set puckSize(newSize: number);
  46756. get puckSize(): number;
  46757. /**
  46758. * Clears the set position of the joystick
  46759. */
  46760. clearPosition(): void;
  46761. /**
  46762. * Defines whether or not the joystick container is always visible
  46763. */
  46764. set alwaysVisible(value: boolean);
  46765. get alwaysVisible(): boolean;
  46766. /**
  46767. * Sets the constant position of the Joystick container
  46768. * @param x X axis coordinate
  46769. * @param y Y axis coordinate
  46770. */
  46771. setPosition(x: number, y: number): void;
  46772. /**
  46773. * Defines a callback to call when the joystick is touched
  46774. * @param action defines the callback
  46775. */
  46776. setActionOnTouch(action: () => any): void;
  46777. /**
  46778. * Defines which axis you'd like to control for left & right
  46779. * @param axis defines the axis to use
  46780. */
  46781. setAxisForLeftRight(axis: JoystickAxis): void;
  46782. /**
  46783. * Defines which axis you'd like to control for up & down
  46784. * @param axis defines the axis to use
  46785. */
  46786. setAxisForUpDown(axis: JoystickAxis): void;
  46787. /**
  46788. * Clears the canvas from the previous puck / container draw
  46789. */
  46790. private _clearPreviousDraw;
  46791. /**
  46792. * Loads `urlPath` to be used for the container's image
  46793. * @param urlPath defines the urlPath of an image to use
  46794. */
  46795. setContainerImage(urlPath: string): void;
  46796. /**
  46797. * Loads `urlPath` to be used for the puck's image
  46798. * @param urlPath defines the urlPath of an image to use
  46799. */
  46800. setPuckImage(urlPath: string): void;
  46801. /**
  46802. * Draws the Virtual Joystick's container
  46803. */
  46804. private _drawContainer;
  46805. /**
  46806. * Draws the Virtual Joystick's puck
  46807. */
  46808. private _drawPuck;
  46809. private _drawVirtualJoystick;
  46810. /**
  46811. * Release internal HTML canvas
  46812. */
  46813. releaseCanvas(): void;
  46814. }
  46815. }
  46816. declare module "babylonjs/Cameras/Inputs/freeCameraVirtualJoystickInput" {
  46817. import { VirtualJoystick } from "babylonjs/Misc/virtualJoystick";
  46818. import { Nullable } from "babylonjs/types";
  46819. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  46820. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  46821. module "babylonjs/Cameras/freeCameraInputsManager" {
  46822. interface FreeCameraInputsManager {
  46823. /**
  46824. * Add virtual joystick input support to the input manager.
  46825. * @returns the current input manager
  46826. */
  46827. addVirtualJoystick(): FreeCameraInputsManager;
  46828. }
  46829. }
  46830. /**
  46831. * Manage the Virtual Joystick inputs to control the movement of a free camera.
  46832. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  46833. */
  46834. export class FreeCameraVirtualJoystickInput implements ICameraInput<FreeCamera> {
  46835. /**
  46836. * Defines the camera the input is attached to.
  46837. */
  46838. camera: FreeCamera;
  46839. private _leftjoystick;
  46840. private _rightjoystick;
  46841. /**
  46842. * Gets the left stick of the virtual joystick.
  46843. * @returns The virtual Joystick
  46844. */
  46845. getLeftJoystick(): VirtualJoystick;
  46846. /**
  46847. * Gets the right stick of the virtual joystick.
  46848. * @returns The virtual Joystick
  46849. */
  46850. getRightJoystick(): VirtualJoystick;
  46851. /**
  46852. * Update the current camera state depending on the inputs that have been used this frame.
  46853. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  46854. */
  46855. checkInputs(): void;
  46856. /**
  46857. * Attach the input controls to a specific dom element to get the input from.
  46858. * @param element Defines the element the controls should be listened from
  46859. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  46860. */
  46861. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  46862. /**
  46863. * Detach the current controls from the specified dom element.
  46864. * @param element Defines the element to stop listening the inputs from
  46865. */
  46866. detachControl(element: Nullable<HTMLElement>): void;
  46867. /**
  46868. * Gets the class name of the current intput.
  46869. * @returns the class name
  46870. */
  46871. getClassName(): string;
  46872. /**
  46873. * Get the friendly name associated with the input class.
  46874. * @returns the input friendly name
  46875. */
  46876. getSimpleName(): string;
  46877. }
  46878. }
  46879. declare module "babylonjs/Cameras/Inputs/index" {
  46880. export * from "babylonjs/Cameras/Inputs/arcRotateCameraGamepadInput";
  46881. export * from "babylonjs/Cameras/Inputs/arcRotateCameraKeyboardMoveInput";
  46882. export * from "babylonjs/Cameras/Inputs/arcRotateCameraMouseWheelInput";
  46883. export * from "babylonjs/Cameras/Inputs/arcRotateCameraPointersInput";
  46884. export * from "babylonjs/Cameras/Inputs/arcRotateCameraVRDeviceOrientationInput";
  46885. export * from "babylonjs/Cameras/Inputs/flyCameraKeyboardInput";
  46886. export * from "babylonjs/Cameras/Inputs/flyCameraMouseInput";
  46887. export * from "babylonjs/Cameras/Inputs/followCameraKeyboardMoveInput";
  46888. export * from "babylonjs/Cameras/Inputs/followCameraMouseWheelInput";
  46889. export * from "babylonjs/Cameras/Inputs/followCameraPointersInput";
  46890. export * from "babylonjs/Cameras/Inputs/freeCameraDeviceOrientationInput";
  46891. export * from "babylonjs/Cameras/Inputs/freeCameraGamepadInput";
  46892. export * from "babylonjs/Cameras/Inputs/freeCameraKeyboardMoveInput";
  46893. export * from "babylonjs/Cameras/Inputs/freeCameraMouseInput";
  46894. export * from "babylonjs/Cameras/Inputs/freeCameraTouchInput";
  46895. export * from "babylonjs/Cameras/Inputs/freeCameraVirtualJoystickInput";
  46896. }
  46897. declare module "babylonjs/Cameras/touchCamera" {
  46898. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  46899. import { Scene } from "babylonjs/scene";
  46900. import { Vector3 } from "babylonjs/Maths/math.vector";
  46901. /**
  46902. * This represents a FPS type of camera controlled by touch.
  46903. * This is like a universal camera minus the Gamepad controls.
  46904. * @see https://doc.babylonjs.com/features/cameras#universal-camera
  46905. */
  46906. export class TouchCamera extends FreeCamera {
  46907. /**
  46908. * Defines the touch sensibility for rotation.
  46909. * The higher the faster.
  46910. */
  46911. get touchAngularSensibility(): number;
  46912. set touchAngularSensibility(value: number);
  46913. /**
  46914. * Defines the touch sensibility for move.
  46915. * The higher the faster.
  46916. */
  46917. get touchMoveSensibility(): number;
  46918. set touchMoveSensibility(value: number);
  46919. /**
  46920. * Instantiates a new touch camera.
  46921. * This represents a FPS type of camera controlled by touch.
  46922. * This is like a universal camera minus the Gamepad controls.
  46923. * @see https://doc.babylonjs.com/features/cameras#universal-camera
  46924. * @param name Define the name of the camera in the scene
  46925. * @param position Define the start position of the camera in the scene
  46926. * @param scene Define the scene the camera belongs to
  46927. */
  46928. constructor(name: string, position: Vector3, scene: Scene);
  46929. /**
  46930. * Gets the current object class name.
  46931. * @return the class name
  46932. */
  46933. getClassName(): string;
  46934. /** @hidden */
  46935. _setupInputs(): void;
  46936. }
  46937. }
  46938. declare module "babylonjs/Cameras/deviceOrientationCamera" {
  46939. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  46940. import { Scene } from "babylonjs/scene";
  46941. import { Vector3 } from "babylonjs/Maths/math.vector";
  46942. import "babylonjs/Cameras/Inputs/freeCameraDeviceOrientationInput";
  46943. import { Axis } from "babylonjs/Maths/math.axis";
  46944. /**
  46945. * This is a camera specifically designed to react to device orientation events such as a modern mobile device
  46946. * being tilted forward or back and left or right.
  46947. */
  46948. export class DeviceOrientationCamera extends FreeCamera {
  46949. private _initialQuaternion;
  46950. private _quaternionCache;
  46951. private _tmpDragQuaternion;
  46952. private _disablePointerInputWhenUsingDeviceOrientation;
  46953. /**
  46954. * Creates a new device orientation camera
  46955. * @param name The name of the camera
  46956. * @param position The start position camera
  46957. * @param scene The scene the camera belongs to
  46958. */
  46959. constructor(name: string, position: Vector3, scene: Scene);
  46960. /**
  46961. * Gets or sets a boolean indicating that pointer input must be disabled on first orientation sensor update (Default: true)
  46962. */
  46963. get disablePointerInputWhenUsingDeviceOrientation(): boolean;
  46964. set disablePointerInputWhenUsingDeviceOrientation(value: boolean);
  46965. private _dragFactor;
  46966. /**
  46967. * Enabled turning on the y axis when the orientation sensor is active
  46968. * @param dragFactor the factor that controls the turn speed (default: 1/300)
  46969. */
  46970. enableHorizontalDragging(dragFactor?: number): void;
  46971. /**
  46972. * Gets the current instance class name ("DeviceOrientationCamera").
  46973. * This helps avoiding instanceof at run time.
  46974. * @returns the class name
  46975. */
  46976. getClassName(): string;
  46977. /**
  46978. * @hidden
  46979. * Checks and applies the current values of the inputs to the camera. (Internal use only)
  46980. */
  46981. _checkInputs(): void;
  46982. /**
  46983. * Reset the camera to its default orientation on the specified axis only.
  46984. * @param axis The axis to reset
  46985. */
  46986. resetToCurrentRotation(axis?: Axis): void;
  46987. }
  46988. }
  46989. declare module "babylonjs/Gamepads/xboxGamepad" {
  46990. import { Observable } from "babylonjs/Misc/observable";
  46991. import { Gamepad } from "babylonjs/Gamepads/gamepad";
  46992. /**
  46993. * Defines supported buttons for XBox360 compatible gamepads
  46994. */
  46995. export enum Xbox360Button {
  46996. /** A */
  46997. A = 0,
  46998. /** B */
  46999. B = 1,
  47000. /** X */
  47001. X = 2,
  47002. /** Y */
  47003. Y = 3,
  47004. /** Left button */
  47005. LB = 4,
  47006. /** Right button */
  47007. RB = 5,
  47008. /** Back */
  47009. Back = 8,
  47010. /** Start */
  47011. Start = 9,
  47012. /** Left stick */
  47013. LeftStick = 10,
  47014. /** Right stick */
  47015. RightStick = 11
  47016. }
  47017. /** Defines values for XBox360 DPad */
  47018. export enum Xbox360Dpad {
  47019. /** Up */
  47020. Up = 12,
  47021. /** Down */
  47022. Down = 13,
  47023. /** Left */
  47024. Left = 14,
  47025. /** Right */
  47026. Right = 15
  47027. }
  47028. /**
  47029. * Defines a XBox360 gamepad
  47030. */
  47031. export class Xbox360Pad extends Gamepad {
  47032. private _leftTrigger;
  47033. private _rightTrigger;
  47034. private _onlefttriggerchanged;
  47035. private _onrighttriggerchanged;
  47036. private _onbuttondown;
  47037. private _onbuttonup;
  47038. private _ondpaddown;
  47039. private _ondpadup;
  47040. /** Observable raised when a button is pressed */
  47041. onButtonDownObservable: Observable<Xbox360Button>;
  47042. /** Observable raised when a button is released */
  47043. onButtonUpObservable: Observable<Xbox360Button>;
  47044. /** Observable raised when a pad is pressed */
  47045. onPadDownObservable: Observable<Xbox360Dpad>;
  47046. /** Observable raised when a pad is released */
  47047. onPadUpObservable: Observable<Xbox360Dpad>;
  47048. private _buttonA;
  47049. private _buttonB;
  47050. private _buttonX;
  47051. private _buttonY;
  47052. private _buttonBack;
  47053. private _buttonStart;
  47054. private _buttonLB;
  47055. private _buttonRB;
  47056. private _buttonLeftStick;
  47057. private _buttonRightStick;
  47058. private _dPadUp;
  47059. private _dPadDown;
  47060. private _dPadLeft;
  47061. private _dPadRight;
  47062. private _isXboxOnePad;
  47063. /**
  47064. * Creates a new XBox360 gamepad object
  47065. * @param id defines the id of this gamepad
  47066. * @param index defines its index
  47067. * @param gamepad defines the internal HTML gamepad object
  47068. * @param xboxOne defines if it is a XBox One gamepad
  47069. */
  47070. constructor(id: string, index: number, gamepad: any, xboxOne?: boolean);
  47071. /**
  47072. * Defines the callback to call when left trigger is pressed
  47073. * @param callback defines the callback to use
  47074. */
  47075. onlefttriggerchanged(callback: (value: number) => void): void;
  47076. /**
  47077. * Defines the callback to call when right trigger is pressed
  47078. * @param callback defines the callback to use
  47079. */
  47080. onrighttriggerchanged(callback: (value: number) => void): void;
  47081. /**
  47082. * Gets the left trigger value
  47083. */
  47084. get leftTrigger(): number;
  47085. /**
  47086. * Sets the left trigger value
  47087. */
  47088. set leftTrigger(newValue: number);
  47089. /**
  47090. * Gets the right trigger value
  47091. */
  47092. get rightTrigger(): number;
  47093. /**
  47094. * Sets the right trigger value
  47095. */
  47096. set rightTrigger(newValue: number);
  47097. /**
  47098. * Defines the callback to call when a button is pressed
  47099. * @param callback defines the callback to use
  47100. */
  47101. onbuttondown(callback: (buttonPressed: Xbox360Button) => void): void;
  47102. /**
  47103. * Defines the callback to call when a button is released
  47104. * @param callback defines the callback to use
  47105. */
  47106. onbuttonup(callback: (buttonReleased: Xbox360Button) => void): void;
  47107. /**
  47108. * Defines the callback to call when a pad is pressed
  47109. * @param callback defines the callback to use
  47110. */
  47111. ondpaddown(callback: (dPadPressed: Xbox360Dpad) => void): void;
  47112. /**
  47113. * Defines the callback to call when a pad is released
  47114. * @param callback defines the callback to use
  47115. */
  47116. ondpadup(callback: (dPadReleased: Xbox360Dpad) => void): void;
  47117. private _setButtonValue;
  47118. private _setDPadValue;
  47119. /**
  47120. * Gets the value of the `A` button
  47121. */
  47122. get buttonA(): number;
  47123. /**
  47124. * Sets the value of the `A` button
  47125. */
  47126. set buttonA(value: number);
  47127. /**
  47128. * Gets the value of the `B` button
  47129. */
  47130. get buttonB(): number;
  47131. /**
  47132. * Sets the value of the `B` button
  47133. */
  47134. set buttonB(value: number);
  47135. /**
  47136. * Gets the value of the `X` button
  47137. */
  47138. get buttonX(): number;
  47139. /**
  47140. * Sets the value of the `X` button
  47141. */
  47142. set buttonX(value: number);
  47143. /**
  47144. * Gets the value of the `Y` button
  47145. */
  47146. get buttonY(): number;
  47147. /**
  47148. * Sets the value of the `Y` button
  47149. */
  47150. set buttonY(value: number);
  47151. /**
  47152. * Gets the value of the `Start` button
  47153. */
  47154. get buttonStart(): number;
  47155. /**
  47156. * Sets the value of the `Start` button
  47157. */
  47158. set buttonStart(value: number);
  47159. /**
  47160. * Gets the value of the `Back` button
  47161. */
  47162. get buttonBack(): number;
  47163. /**
  47164. * Sets the value of the `Back` button
  47165. */
  47166. set buttonBack(value: number);
  47167. /**
  47168. * Gets the value of the `Left` button
  47169. */
  47170. get buttonLB(): number;
  47171. /**
  47172. * Sets the value of the `Left` button
  47173. */
  47174. set buttonLB(value: number);
  47175. /**
  47176. * Gets the value of the `Right` button
  47177. */
  47178. get buttonRB(): number;
  47179. /**
  47180. * Sets the value of the `Right` button
  47181. */
  47182. set buttonRB(value: number);
  47183. /**
  47184. * Gets the value of the Left joystick
  47185. */
  47186. get buttonLeftStick(): number;
  47187. /**
  47188. * Sets the value of the Left joystick
  47189. */
  47190. set buttonLeftStick(value: number);
  47191. /**
  47192. * Gets the value of the Right joystick
  47193. */
  47194. get buttonRightStick(): number;
  47195. /**
  47196. * Sets the value of the Right joystick
  47197. */
  47198. set buttonRightStick(value: number);
  47199. /**
  47200. * Gets the value of D-pad up
  47201. */
  47202. get dPadUp(): number;
  47203. /**
  47204. * Sets the value of D-pad up
  47205. */
  47206. set dPadUp(value: number);
  47207. /**
  47208. * Gets the value of D-pad down
  47209. */
  47210. get dPadDown(): number;
  47211. /**
  47212. * Sets the value of D-pad down
  47213. */
  47214. set dPadDown(value: number);
  47215. /**
  47216. * Gets the value of D-pad left
  47217. */
  47218. get dPadLeft(): number;
  47219. /**
  47220. * Sets the value of D-pad left
  47221. */
  47222. set dPadLeft(value: number);
  47223. /**
  47224. * Gets the value of D-pad right
  47225. */
  47226. get dPadRight(): number;
  47227. /**
  47228. * Sets the value of D-pad right
  47229. */
  47230. set dPadRight(value: number);
  47231. /**
  47232. * Force the gamepad to synchronize with device values
  47233. */
  47234. update(): void;
  47235. /**
  47236. * Disposes the gamepad
  47237. */
  47238. dispose(): void;
  47239. }
  47240. }
  47241. declare module "babylonjs/Gamepads/dualShockGamepad" {
  47242. import { Observable } from "babylonjs/Misc/observable";
  47243. import { Gamepad } from "babylonjs/Gamepads/gamepad";
  47244. /**
  47245. * Defines supported buttons for DualShock compatible gamepads
  47246. */
  47247. export enum DualShockButton {
  47248. /** Cross */
  47249. Cross = 0,
  47250. /** Circle */
  47251. Circle = 1,
  47252. /** Square */
  47253. Square = 2,
  47254. /** Triangle */
  47255. Triangle = 3,
  47256. /** L1 */
  47257. L1 = 4,
  47258. /** R1 */
  47259. R1 = 5,
  47260. /** Share */
  47261. Share = 8,
  47262. /** Options */
  47263. Options = 9,
  47264. /** Left stick */
  47265. LeftStick = 10,
  47266. /** Right stick */
  47267. RightStick = 11
  47268. }
  47269. /** Defines values for DualShock DPad */
  47270. export enum DualShockDpad {
  47271. /** Up */
  47272. Up = 12,
  47273. /** Down */
  47274. Down = 13,
  47275. /** Left */
  47276. Left = 14,
  47277. /** Right */
  47278. Right = 15
  47279. }
  47280. /**
  47281. * Defines a DualShock gamepad
  47282. */
  47283. export class DualShockPad extends Gamepad {
  47284. private _leftTrigger;
  47285. private _rightTrigger;
  47286. private _onlefttriggerchanged;
  47287. private _onrighttriggerchanged;
  47288. private _onbuttondown;
  47289. private _onbuttonup;
  47290. private _ondpaddown;
  47291. private _ondpadup;
  47292. /** Observable raised when a button is pressed */
  47293. onButtonDownObservable: Observable<DualShockButton>;
  47294. /** Observable raised when a button is released */
  47295. onButtonUpObservable: Observable<DualShockButton>;
  47296. /** Observable raised when a pad is pressed */
  47297. onPadDownObservable: Observable<DualShockDpad>;
  47298. /** Observable raised when a pad is released */
  47299. onPadUpObservable: Observable<DualShockDpad>;
  47300. private _buttonCross;
  47301. private _buttonCircle;
  47302. private _buttonSquare;
  47303. private _buttonTriangle;
  47304. private _buttonShare;
  47305. private _buttonOptions;
  47306. private _buttonL1;
  47307. private _buttonR1;
  47308. private _buttonLeftStick;
  47309. private _buttonRightStick;
  47310. private _dPadUp;
  47311. private _dPadDown;
  47312. private _dPadLeft;
  47313. private _dPadRight;
  47314. /**
  47315. * Creates a new DualShock gamepad object
  47316. * @param id defines the id of this gamepad
  47317. * @param index defines its index
  47318. * @param gamepad defines the internal HTML gamepad object
  47319. */
  47320. constructor(id: string, index: number, gamepad: any);
  47321. /**
  47322. * Defines the callback to call when left trigger is pressed
  47323. * @param callback defines the callback to use
  47324. */
  47325. onlefttriggerchanged(callback: (value: number) => void): void;
  47326. /**
  47327. * Defines the callback to call when right trigger is pressed
  47328. * @param callback defines the callback to use
  47329. */
  47330. onrighttriggerchanged(callback: (value: number) => void): void;
  47331. /**
  47332. * Gets the left trigger value
  47333. */
  47334. get leftTrigger(): number;
  47335. /**
  47336. * Sets the left trigger value
  47337. */
  47338. set leftTrigger(newValue: number);
  47339. /**
  47340. * Gets the right trigger value
  47341. */
  47342. get rightTrigger(): number;
  47343. /**
  47344. * Sets the right trigger value
  47345. */
  47346. set rightTrigger(newValue: number);
  47347. /**
  47348. * Defines the callback to call when a button is pressed
  47349. * @param callback defines the callback to use
  47350. */
  47351. onbuttondown(callback: (buttonPressed: DualShockButton) => void): void;
  47352. /**
  47353. * Defines the callback to call when a button is released
  47354. * @param callback defines the callback to use
  47355. */
  47356. onbuttonup(callback: (buttonReleased: DualShockButton) => void): void;
  47357. /**
  47358. * Defines the callback to call when a pad is pressed
  47359. * @param callback defines the callback to use
  47360. */
  47361. ondpaddown(callback: (dPadPressed: DualShockDpad) => void): void;
  47362. /**
  47363. * Defines the callback to call when a pad is released
  47364. * @param callback defines the callback to use
  47365. */
  47366. ondpadup(callback: (dPadReleased: DualShockDpad) => void): void;
  47367. private _setButtonValue;
  47368. private _setDPadValue;
  47369. /**
  47370. * Gets the value of the `Cross` button
  47371. */
  47372. get buttonCross(): number;
  47373. /**
  47374. * Sets the value of the `Cross` button
  47375. */
  47376. set buttonCross(value: number);
  47377. /**
  47378. * Gets the value of the `Circle` button
  47379. */
  47380. get buttonCircle(): number;
  47381. /**
  47382. * Sets the value of the `Circle` button
  47383. */
  47384. set buttonCircle(value: number);
  47385. /**
  47386. * Gets the value of the `Square` button
  47387. */
  47388. get buttonSquare(): number;
  47389. /**
  47390. * Sets the value of the `Square` button
  47391. */
  47392. set buttonSquare(value: number);
  47393. /**
  47394. * Gets the value of the `Triangle` button
  47395. */
  47396. get buttonTriangle(): number;
  47397. /**
  47398. * Sets the value of the `Triangle` button
  47399. */
  47400. set buttonTriangle(value: number);
  47401. /**
  47402. * Gets the value of the `Options` button
  47403. */
  47404. get buttonOptions(): number;
  47405. /**
  47406. * Sets the value of the `Options` button
  47407. */
  47408. set buttonOptions(value: number);
  47409. /**
  47410. * Gets the value of the `Share` button
  47411. */
  47412. get buttonShare(): number;
  47413. /**
  47414. * Sets the value of the `Share` button
  47415. */
  47416. set buttonShare(value: number);
  47417. /**
  47418. * Gets the value of the `L1` button
  47419. */
  47420. get buttonL1(): number;
  47421. /**
  47422. * Sets the value of the `L1` button
  47423. */
  47424. set buttonL1(value: number);
  47425. /**
  47426. * Gets the value of the `R1` button
  47427. */
  47428. get buttonR1(): number;
  47429. /**
  47430. * Sets the value of the `R1` button
  47431. */
  47432. set buttonR1(value: number);
  47433. /**
  47434. * Gets the value of the Left joystick
  47435. */
  47436. get buttonLeftStick(): number;
  47437. /**
  47438. * Sets the value of the Left joystick
  47439. */
  47440. set buttonLeftStick(value: number);
  47441. /**
  47442. * Gets the value of the Right joystick
  47443. */
  47444. get buttonRightStick(): number;
  47445. /**
  47446. * Sets the value of the Right joystick
  47447. */
  47448. set buttonRightStick(value: number);
  47449. /**
  47450. * Gets the value of D-pad up
  47451. */
  47452. get dPadUp(): number;
  47453. /**
  47454. * Sets the value of D-pad up
  47455. */
  47456. set dPadUp(value: number);
  47457. /**
  47458. * Gets the value of D-pad down
  47459. */
  47460. get dPadDown(): number;
  47461. /**
  47462. * Sets the value of D-pad down
  47463. */
  47464. set dPadDown(value: number);
  47465. /**
  47466. * Gets the value of D-pad left
  47467. */
  47468. get dPadLeft(): number;
  47469. /**
  47470. * Sets the value of D-pad left
  47471. */
  47472. set dPadLeft(value: number);
  47473. /**
  47474. * Gets the value of D-pad right
  47475. */
  47476. get dPadRight(): number;
  47477. /**
  47478. * Sets the value of D-pad right
  47479. */
  47480. set dPadRight(value: number);
  47481. /**
  47482. * Force the gamepad to synchronize with device values
  47483. */
  47484. update(): void;
  47485. /**
  47486. * Disposes the gamepad
  47487. */
  47488. dispose(): void;
  47489. }
  47490. }
  47491. declare module "babylonjs/Gamepads/gamepadManager" {
  47492. import { Observable } from "babylonjs/Misc/observable";
  47493. import { Nullable } from "babylonjs/types";
  47494. import { Scene } from "babylonjs/scene";
  47495. import { Gamepad } from "babylonjs/Gamepads/gamepad";
  47496. /**
  47497. * Manager for handling gamepads
  47498. */
  47499. export class GamepadManager {
  47500. private _scene?;
  47501. private _babylonGamepads;
  47502. private _oneGamepadConnected;
  47503. /** @hidden */
  47504. _isMonitoring: boolean;
  47505. private _gamepadEventSupported;
  47506. private _gamepadSupport?;
  47507. /**
  47508. * observable to be triggered when the gamepad controller has been connected
  47509. */
  47510. onGamepadConnectedObservable: Observable<Gamepad>;
  47511. /**
  47512. * observable to be triggered when the gamepad controller has been disconnected
  47513. */
  47514. onGamepadDisconnectedObservable: Observable<Gamepad>;
  47515. private _onGamepadConnectedEvent;
  47516. private _onGamepadDisconnectedEvent;
  47517. /**
  47518. * Initializes the gamepad manager
  47519. * @param _scene BabylonJS scene
  47520. */
  47521. constructor(_scene?: Scene | undefined);
  47522. /**
  47523. * The gamepads in the game pad manager
  47524. */
  47525. get gamepads(): Gamepad[];
  47526. /**
  47527. * Get the gamepad controllers based on type
  47528. * @param type The type of gamepad controller
  47529. * @returns Nullable gamepad
  47530. */
  47531. getGamepadByType(type?: number): Nullable<Gamepad>;
  47532. /**
  47533. * Disposes the gamepad manager
  47534. */
  47535. dispose(): void;
  47536. private _addNewGamepad;
  47537. private _startMonitoringGamepads;
  47538. private _stopMonitoringGamepads;
  47539. /** @hidden */
  47540. _checkGamepadsStatus(): void;
  47541. private _updateGamepadObjects;
  47542. }
  47543. }
  47544. declare module "babylonjs/Gamepads/gamepadSceneComponent" {
  47545. import { Nullable } from "babylonjs/types";
  47546. import { Scene } from "babylonjs/scene";
  47547. import { ISceneComponent } from "babylonjs/sceneComponent";
  47548. import { GamepadManager } from "babylonjs/Gamepads/gamepadManager";
  47549. module "babylonjs/scene" {
  47550. interface Scene {
  47551. /** @hidden */
  47552. _gamepadManager: Nullable<GamepadManager>;
  47553. /**
  47554. * Gets the gamepad manager associated with the scene
  47555. * @see https://doc.babylonjs.com/how_to/how_to_use_gamepads
  47556. */
  47557. gamepadManager: GamepadManager;
  47558. }
  47559. }
  47560. module "babylonjs/Cameras/freeCameraInputsManager" {
  47561. /**
  47562. * Interface representing a free camera inputs manager
  47563. */
  47564. interface FreeCameraInputsManager {
  47565. /**
  47566. * Adds gamepad input support to the FreeCameraInputsManager.
  47567. * @returns the FreeCameraInputsManager
  47568. */
  47569. addGamepad(): FreeCameraInputsManager;
  47570. }
  47571. }
  47572. module "babylonjs/Cameras/arcRotateCameraInputsManager" {
  47573. /**
  47574. * Interface representing an arc rotate camera inputs manager
  47575. */
  47576. interface ArcRotateCameraInputsManager {
  47577. /**
  47578. * Adds gamepad input support to the ArcRotateCamera InputManager.
  47579. * @returns the camera inputs manager
  47580. */
  47581. addGamepad(): ArcRotateCameraInputsManager;
  47582. }
  47583. }
  47584. /**
  47585. * Defines the gamepad scene component responsible to manage gamepads in a given scene
  47586. */
  47587. export class GamepadSystemSceneComponent implements ISceneComponent {
  47588. /**
  47589. * The component name helpfull to identify the component in the list of scene components.
  47590. */
  47591. readonly name: string;
  47592. /**
  47593. * The scene the component belongs to.
  47594. */
  47595. scene: Scene;
  47596. /**
  47597. * Creates a new instance of the component for the given scene
  47598. * @param scene Defines the scene to register the component in
  47599. */
  47600. constructor(scene: Scene);
  47601. /**
  47602. * Registers the component in a given scene
  47603. */
  47604. register(): void;
  47605. /**
  47606. * Rebuilds the elements related to this component in case of
  47607. * context lost for instance.
  47608. */
  47609. rebuild(): void;
  47610. /**
  47611. * Disposes the component and the associated ressources
  47612. */
  47613. dispose(): void;
  47614. private _beforeCameraUpdate;
  47615. }
  47616. }
  47617. declare module "babylonjs/Cameras/universalCamera" {
  47618. import { TouchCamera } from "babylonjs/Cameras/touchCamera";
  47619. import { Scene } from "babylonjs/scene";
  47620. import { Vector3 } from "babylonjs/Maths/math.vector";
  47621. import "babylonjs/Gamepads/gamepadSceneComponent";
  47622. /**
  47623. * 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,
  47624. * which still works and will still be found in many Playgrounds.
  47625. * @see https://doc.babylonjs.com/features/cameras#universal-camera
  47626. */
  47627. export class UniversalCamera extends TouchCamera {
  47628. /**
  47629. * Defines the gamepad rotation sensiblity.
  47630. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  47631. */
  47632. get gamepadAngularSensibility(): number;
  47633. set gamepadAngularSensibility(value: number);
  47634. /**
  47635. * Defines the gamepad move sensiblity.
  47636. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  47637. */
  47638. get gamepadMoveSensibility(): number;
  47639. set gamepadMoveSensibility(value: number);
  47640. /**
  47641. * 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,
  47642. * which still works and will still be found in many Playgrounds.
  47643. * @see https://doc.babylonjs.com/features/cameras#universal-camera
  47644. * @param name Define the name of the camera in the scene
  47645. * @param position Define the start position of the camera in the scene
  47646. * @param scene Define the scene the camera belongs to
  47647. */
  47648. constructor(name: string, position: Vector3, scene: Scene);
  47649. /**
  47650. * Gets the current object class name.
  47651. * @return the class name
  47652. */
  47653. getClassName(): string;
  47654. }
  47655. }
  47656. declare module "babylonjs/Cameras/gamepadCamera" {
  47657. import { UniversalCamera } from "babylonjs/Cameras/universalCamera";
  47658. import { Scene } from "babylonjs/scene";
  47659. import { Vector3 } from "babylonjs/Maths/math.vector";
  47660. /**
  47661. * This represents a FPS type of camera. This is only here for back compat purpose.
  47662. * Please use the UniversalCamera instead as both are identical.
  47663. * @see https://doc.babylonjs.com/features/cameras#universal-camera
  47664. */
  47665. export class GamepadCamera extends UniversalCamera {
  47666. /**
  47667. * Instantiates a new Gamepad Camera
  47668. * This represents a FPS type of camera. This is only here for back compat purpose.
  47669. * Please use the UniversalCamera instead as both are identical.
  47670. * @see https://doc.babylonjs.com/features/cameras#universal-camera
  47671. * @param name Define the name of the camera in the scene
  47672. * @param position Define the start position of the camera in the scene
  47673. * @param scene Define the scene the camera belongs to
  47674. */
  47675. constructor(name: string, position: Vector3, scene: Scene);
  47676. /**
  47677. * Gets the current object class name.
  47678. * @return the class name
  47679. */
  47680. getClassName(): string;
  47681. }
  47682. }
  47683. declare module "babylonjs/Shaders/pass.fragment" {
  47684. /** @hidden */
  47685. export var passPixelShader: {
  47686. name: string;
  47687. shader: string;
  47688. };
  47689. }
  47690. declare module "babylonjs/Shaders/passCube.fragment" {
  47691. /** @hidden */
  47692. export var passCubePixelShader: {
  47693. name: string;
  47694. shader: string;
  47695. };
  47696. }
  47697. declare module "babylonjs/PostProcesses/passPostProcess" {
  47698. import { Nullable } from "babylonjs/types";
  47699. import { Camera } from "babylonjs/Cameras/camera";
  47700. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  47701. import { Engine } from "babylonjs/Engines/engine";
  47702. import "babylonjs/Shaders/pass.fragment";
  47703. import "babylonjs/Shaders/passCube.fragment";
  47704. import { Scene } from "babylonjs/scene";
  47705. /**
  47706. * PassPostProcess which produces an output the same as it's input
  47707. */
  47708. export class PassPostProcess extends PostProcess {
  47709. /**
  47710. * Gets a string identifying the name of the class
  47711. * @returns "PassPostProcess" string
  47712. */
  47713. getClassName(): string;
  47714. /**
  47715. * Creates the PassPostProcess
  47716. * @param name The name of the effect.
  47717. * @param options The required width/height ratio to downsize to before computing the render pass.
  47718. * @param camera The camera to apply the render pass to.
  47719. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  47720. * @param engine The engine which the post process will be applied. (default: current engine)
  47721. * @param reusable If the post process can be reused on the same frame. (default: false)
  47722. * @param textureType The type of texture to be used when performing the post processing.
  47723. * @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)
  47724. */
  47725. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  47726. /** @hidden */
  47727. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): PassPostProcess;
  47728. }
  47729. /**
  47730. * PassCubePostProcess which produces an output the same as it's input (which must be a cube texture)
  47731. */
  47732. export class PassCubePostProcess extends PostProcess {
  47733. private _face;
  47734. /**
  47735. * Gets or sets the cube face to display.
  47736. * * 0 is +X
  47737. * * 1 is -X
  47738. * * 2 is +Y
  47739. * * 3 is -Y
  47740. * * 4 is +Z
  47741. * * 5 is -Z
  47742. */
  47743. get face(): number;
  47744. set face(value: number);
  47745. /**
  47746. * Gets a string identifying the name of the class
  47747. * @returns "PassCubePostProcess" string
  47748. */
  47749. getClassName(): string;
  47750. /**
  47751. * Creates the PassCubePostProcess
  47752. * @param name The name of the effect.
  47753. * @param options The required width/height ratio to downsize to before computing the render pass.
  47754. * @param camera The camera to apply the render pass to.
  47755. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  47756. * @param engine The engine which the post process will be applied. (default: current engine)
  47757. * @param reusable If the post process can be reused on the same frame. (default: false)
  47758. * @param textureType The type of texture to be used when performing the post processing.
  47759. * @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)
  47760. */
  47761. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  47762. /** @hidden */
  47763. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): PassCubePostProcess;
  47764. }
  47765. }
  47766. declare module "babylonjs/Shaders/anaglyph.fragment" {
  47767. /** @hidden */
  47768. export var anaglyphPixelShader: {
  47769. name: string;
  47770. shader: string;
  47771. };
  47772. }
  47773. declare module "babylonjs/PostProcesses/anaglyphPostProcess" {
  47774. import { Engine } from "babylonjs/Engines/engine";
  47775. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  47776. import { Camera } from "babylonjs/Cameras/camera";
  47777. import "babylonjs/Shaders/anaglyph.fragment";
  47778. /**
  47779. * Postprocess used to generate anaglyphic rendering
  47780. */
  47781. export class AnaglyphPostProcess extends PostProcess {
  47782. private _passedProcess;
  47783. /**
  47784. * Gets a string identifying the name of the class
  47785. * @returns "AnaglyphPostProcess" string
  47786. */
  47787. getClassName(): string;
  47788. /**
  47789. * Creates a new AnaglyphPostProcess
  47790. * @param name defines postprocess name
  47791. * @param options defines creation options or target ratio scale
  47792. * @param rigCameras defines cameras using this postprocess
  47793. * @param samplingMode defines required sampling mode (BABYLON.Texture.NEAREST_SAMPLINGMODE by default)
  47794. * @param engine defines hosting engine
  47795. * @param reusable defines if the postprocess will be reused multiple times per frame
  47796. */
  47797. constructor(name: string, options: number | PostProcessOptions, rigCameras: Camera[], samplingMode?: number, engine?: Engine, reusable?: boolean);
  47798. }
  47799. }
  47800. declare module "babylonjs/Cameras/RigModes/stereoscopicAnaglyphRigMode" { }
  47801. declare module "babylonjs/Cameras/Stereoscopic/anaglyphArcRotateCamera" {
  47802. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  47803. import { Scene } from "babylonjs/scene";
  47804. import { Vector3 } from "babylonjs/Maths/math.vector";
  47805. import "babylonjs/Cameras/RigModes/stereoscopicAnaglyphRigMode";
  47806. /**
  47807. * Camera used to simulate anaglyphic rendering (based on ArcRotateCamera)
  47808. * @see https://doc.babylonjs.com/features/cameras#anaglyph-cameras
  47809. */
  47810. export class AnaglyphArcRotateCamera extends ArcRotateCamera {
  47811. /**
  47812. * Creates a new AnaglyphArcRotateCamera
  47813. * @param name defines camera name
  47814. * @param alpha defines alpha angle (in radians)
  47815. * @param beta defines beta angle (in radians)
  47816. * @param radius defines radius
  47817. * @param target defines camera target
  47818. * @param interaxialDistance defines distance between each color axis
  47819. * @param scene defines the hosting scene
  47820. */
  47821. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, scene: Scene);
  47822. /**
  47823. * Gets camera class name
  47824. * @returns AnaglyphArcRotateCamera
  47825. */
  47826. getClassName(): string;
  47827. }
  47828. }
  47829. declare module "babylonjs/Cameras/Stereoscopic/anaglyphFreeCamera" {
  47830. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  47831. import { Scene } from "babylonjs/scene";
  47832. import { Vector3 } from "babylonjs/Maths/math.vector";
  47833. import "babylonjs/Cameras/RigModes/stereoscopicAnaglyphRigMode";
  47834. /**
  47835. * Camera used to simulate anaglyphic rendering (based on FreeCamera)
  47836. * @see https://doc.babylonjs.com/features/cameras#anaglyph-cameras
  47837. */
  47838. export class AnaglyphFreeCamera extends FreeCamera {
  47839. /**
  47840. * Creates a new AnaglyphFreeCamera
  47841. * @param name defines camera name
  47842. * @param position defines initial position
  47843. * @param interaxialDistance defines distance between each color axis
  47844. * @param scene defines the hosting scene
  47845. */
  47846. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  47847. /**
  47848. * Gets camera class name
  47849. * @returns AnaglyphFreeCamera
  47850. */
  47851. getClassName(): string;
  47852. }
  47853. }
  47854. declare module "babylonjs/Cameras/Stereoscopic/anaglyphGamepadCamera" {
  47855. import { GamepadCamera } from "babylonjs/Cameras/gamepadCamera";
  47856. import { Scene } from "babylonjs/scene";
  47857. import { Vector3 } from "babylonjs/Maths/math.vector";
  47858. import "babylonjs/Cameras/RigModes/stereoscopicAnaglyphRigMode";
  47859. /**
  47860. * Camera used to simulate anaglyphic rendering (based on GamepadCamera)
  47861. * @see https://doc.babylonjs.com/features/cameras#anaglyph-cameras
  47862. */
  47863. export class AnaglyphGamepadCamera extends GamepadCamera {
  47864. /**
  47865. * Creates a new AnaglyphGamepadCamera
  47866. * @param name defines camera name
  47867. * @param position defines initial position
  47868. * @param interaxialDistance defines distance between each color axis
  47869. * @param scene defines the hosting scene
  47870. */
  47871. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  47872. /**
  47873. * Gets camera class name
  47874. * @returns AnaglyphGamepadCamera
  47875. */
  47876. getClassName(): string;
  47877. }
  47878. }
  47879. declare module "babylonjs/Cameras/Stereoscopic/anaglyphUniversalCamera" {
  47880. import { UniversalCamera } from "babylonjs/Cameras/universalCamera";
  47881. import { Scene } from "babylonjs/scene";
  47882. import { Vector3 } from "babylonjs/Maths/math.vector";
  47883. import "babylonjs/Cameras/RigModes/stereoscopicAnaglyphRigMode";
  47884. /**
  47885. * Camera used to simulate anaglyphic rendering (based on UniversalCamera)
  47886. * @see https://doc.babylonjs.com/features/cameras#anaglyph-cameras
  47887. */
  47888. export class AnaglyphUniversalCamera extends UniversalCamera {
  47889. /**
  47890. * Creates a new AnaglyphUniversalCamera
  47891. * @param name defines camera name
  47892. * @param position defines initial position
  47893. * @param interaxialDistance defines distance between each color axis
  47894. * @param scene defines the hosting scene
  47895. */
  47896. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  47897. /**
  47898. * Gets camera class name
  47899. * @returns AnaglyphUniversalCamera
  47900. */
  47901. getClassName(): string;
  47902. }
  47903. }
  47904. declare module "babylonjs/Cameras/RigModes/stereoscopicRigMode" { }
  47905. declare module "babylonjs/Cameras/Stereoscopic/stereoscopicArcRotateCamera" {
  47906. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  47907. import { Scene } from "babylonjs/scene";
  47908. import { Vector3 } from "babylonjs/Maths/math.vector";
  47909. import "babylonjs/Cameras/RigModes/stereoscopicRigMode";
  47910. /**
  47911. * Camera used to simulate stereoscopic rendering (based on ArcRotateCamera)
  47912. * @see https://doc.babylonjs.com/features/cameras
  47913. */
  47914. export class StereoscopicArcRotateCamera extends ArcRotateCamera {
  47915. /**
  47916. * Creates a new StereoscopicArcRotateCamera
  47917. * @param name defines camera name
  47918. * @param alpha defines alpha angle (in radians)
  47919. * @param beta defines beta angle (in radians)
  47920. * @param radius defines radius
  47921. * @param target defines camera target
  47922. * @param interaxialDistance defines distance between each color axis
  47923. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  47924. * @param scene defines the hosting scene
  47925. */
  47926. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  47927. /**
  47928. * Gets camera class name
  47929. * @returns StereoscopicArcRotateCamera
  47930. */
  47931. getClassName(): string;
  47932. }
  47933. }
  47934. declare module "babylonjs/Cameras/Stereoscopic/stereoscopicFreeCamera" {
  47935. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  47936. import { Scene } from "babylonjs/scene";
  47937. import { Vector3 } from "babylonjs/Maths/math.vector";
  47938. import "babylonjs/Cameras/RigModes/stereoscopicRigMode";
  47939. /**
  47940. * Camera used to simulate stereoscopic rendering (based on FreeCamera)
  47941. * @see https://doc.babylonjs.com/features/cameras
  47942. */
  47943. export class StereoscopicFreeCamera extends FreeCamera {
  47944. /**
  47945. * Creates a new StereoscopicFreeCamera
  47946. * @param name defines camera name
  47947. * @param position defines initial position
  47948. * @param interaxialDistance defines distance between each color axis
  47949. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  47950. * @param scene defines the hosting scene
  47951. */
  47952. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  47953. /**
  47954. * Gets camera class name
  47955. * @returns StereoscopicFreeCamera
  47956. */
  47957. getClassName(): string;
  47958. }
  47959. }
  47960. declare module "babylonjs/Cameras/Stereoscopic/stereoscopicGamepadCamera" {
  47961. import { GamepadCamera } from "babylonjs/Cameras/gamepadCamera";
  47962. import { Scene } from "babylonjs/scene";
  47963. import { Vector3 } from "babylonjs/Maths/math.vector";
  47964. import "babylonjs/Cameras/RigModes/stereoscopicRigMode";
  47965. /**
  47966. * Camera used to simulate stereoscopic rendering (based on GamepadCamera)
  47967. * @see https://doc.babylonjs.com/features/cameras
  47968. */
  47969. export class StereoscopicGamepadCamera extends GamepadCamera {
  47970. /**
  47971. * Creates a new StereoscopicGamepadCamera
  47972. * @param name defines camera name
  47973. * @param position defines initial position
  47974. * @param interaxialDistance defines distance between each color axis
  47975. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  47976. * @param scene defines the hosting scene
  47977. */
  47978. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  47979. /**
  47980. * Gets camera class name
  47981. * @returns StereoscopicGamepadCamera
  47982. */
  47983. getClassName(): string;
  47984. }
  47985. }
  47986. declare module "babylonjs/Cameras/Stereoscopic/stereoscopicUniversalCamera" {
  47987. import { UniversalCamera } from "babylonjs/Cameras/universalCamera";
  47988. import { Scene } from "babylonjs/scene";
  47989. import { Vector3 } from "babylonjs/Maths/math.vector";
  47990. import "babylonjs/Cameras/RigModes/stereoscopicRigMode";
  47991. /**
  47992. * Camera used to simulate stereoscopic rendering (based on UniversalCamera)
  47993. * @see https://doc.babylonjs.com/features/cameras
  47994. */
  47995. export class StereoscopicUniversalCamera extends UniversalCamera {
  47996. /**
  47997. * Creates a new StereoscopicUniversalCamera
  47998. * @param name defines camera name
  47999. * @param position defines initial position
  48000. * @param interaxialDistance defines distance between each color axis
  48001. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  48002. * @param scene defines the hosting scene
  48003. */
  48004. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  48005. /**
  48006. * Gets camera class name
  48007. * @returns StereoscopicUniversalCamera
  48008. */
  48009. getClassName(): string;
  48010. }
  48011. }
  48012. declare module "babylonjs/Cameras/Stereoscopic/index" {
  48013. export * from "babylonjs/Cameras/Stereoscopic/anaglyphArcRotateCamera";
  48014. export * from "babylonjs/Cameras/Stereoscopic/anaglyphFreeCamera";
  48015. export * from "babylonjs/Cameras/Stereoscopic/anaglyphGamepadCamera";
  48016. export * from "babylonjs/Cameras/Stereoscopic/anaglyphUniversalCamera";
  48017. export * from "babylonjs/Cameras/Stereoscopic/stereoscopicArcRotateCamera";
  48018. export * from "babylonjs/Cameras/Stereoscopic/stereoscopicFreeCamera";
  48019. export * from "babylonjs/Cameras/Stereoscopic/stereoscopicGamepadCamera";
  48020. export * from "babylonjs/Cameras/Stereoscopic/stereoscopicUniversalCamera";
  48021. }
  48022. declare module "babylonjs/Cameras/virtualJoysticksCamera" {
  48023. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  48024. import { Scene } from "babylonjs/scene";
  48025. import { Vector3 } from "babylonjs/Maths/math.vector";
  48026. import "babylonjs/Cameras/Inputs/freeCameraVirtualJoystickInput";
  48027. /**
  48028. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  48029. * It is identical to the Free Camera and simply adds by default a virtual joystick.
  48030. * Virtual Joysticks are on-screen 2D graphics that are used to control the camera or other scene items.
  48031. * @see https://doc.babylonjs.com/features/cameras#virtual-joysticks-camera
  48032. */
  48033. export class VirtualJoysticksCamera extends FreeCamera {
  48034. /**
  48035. * Intantiates a VirtualJoysticksCamera. It can be useful in First Person Shooter game for instance.
  48036. * It is identical to the Free Camera and simply adds by default a virtual joystick.
  48037. * Virtual Joysticks are on-screen 2D graphics that are used to control the camera or other scene items.
  48038. * @see https://doc.babylonjs.com/features/cameras#virtual-joysticks-camera
  48039. * @param name Define the name of the camera in the scene
  48040. * @param position Define the start position of the camera in the scene
  48041. * @param scene Define the scene the camera belongs to
  48042. */
  48043. constructor(name: string, position: Vector3, scene: Scene);
  48044. /**
  48045. * Gets the current object class name.
  48046. * @return the class name
  48047. */
  48048. getClassName(): string;
  48049. }
  48050. }
  48051. declare module "babylonjs/Cameras/VR/vrCameraMetrics" {
  48052. import { Matrix } from "babylonjs/Maths/math.vector";
  48053. /**
  48054. * This represents all the required metrics to create a VR camera.
  48055. * @see https://doc.babylonjs.com/babylon101/cameras#device-orientation-camera
  48056. */
  48057. export class VRCameraMetrics {
  48058. /**
  48059. * Define the horizontal resolution off the screen.
  48060. */
  48061. hResolution: number;
  48062. /**
  48063. * Define the vertical resolution off the screen.
  48064. */
  48065. vResolution: number;
  48066. /**
  48067. * Define the horizontal screen size.
  48068. */
  48069. hScreenSize: number;
  48070. /**
  48071. * Define the vertical screen size.
  48072. */
  48073. vScreenSize: number;
  48074. /**
  48075. * Define the vertical screen center position.
  48076. */
  48077. vScreenCenter: number;
  48078. /**
  48079. * Define the distance of the eyes to the screen.
  48080. */
  48081. eyeToScreenDistance: number;
  48082. /**
  48083. * Define the distance between both lenses
  48084. */
  48085. lensSeparationDistance: number;
  48086. /**
  48087. * Define the distance between both viewer's eyes.
  48088. */
  48089. interpupillaryDistance: number;
  48090. /**
  48091. * Define the distortion factor of the VR postprocess.
  48092. * Please, touch with care.
  48093. */
  48094. distortionK: number[];
  48095. /**
  48096. * Define the chromatic aberration correction factors for the VR post process.
  48097. */
  48098. chromaAbCorrection: number[];
  48099. /**
  48100. * Define the scale factor of the post process.
  48101. * The smaller the better but the slower.
  48102. */
  48103. postProcessScaleFactor: number;
  48104. /**
  48105. * Define an offset for the lens center.
  48106. */
  48107. lensCenterOffset: number;
  48108. /**
  48109. * Define if the current vr camera should compensate the distortion of the lense or not.
  48110. */
  48111. compensateDistortion: boolean;
  48112. /**
  48113. * Defines if multiview should be enabled when rendering (Default: false)
  48114. */
  48115. multiviewEnabled: boolean;
  48116. /**
  48117. * Gets the rendering aspect ratio based on the provided resolutions.
  48118. */
  48119. get aspectRatio(): number;
  48120. /**
  48121. * Gets the aspect ratio based on the FOV, scale factors, and real screen sizes.
  48122. */
  48123. get aspectRatioFov(): number;
  48124. /**
  48125. * @hidden
  48126. */
  48127. get leftHMatrix(): Matrix;
  48128. /**
  48129. * @hidden
  48130. */
  48131. get rightHMatrix(): Matrix;
  48132. /**
  48133. * @hidden
  48134. */
  48135. get leftPreViewMatrix(): Matrix;
  48136. /**
  48137. * @hidden
  48138. */
  48139. get rightPreViewMatrix(): Matrix;
  48140. /**
  48141. * Get the default VRMetrics based on the most generic setup.
  48142. * @returns the default vr metrics
  48143. */
  48144. static GetDefault(): VRCameraMetrics;
  48145. }
  48146. }
  48147. declare module "babylonjs/Shaders/vrDistortionCorrection.fragment" {
  48148. /** @hidden */
  48149. export var vrDistortionCorrectionPixelShader: {
  48150. name: string;
  48151. shader: string;
  48152. };
  48153. }
  48154. declare module "babylonjs/PostProcesses/vrDistortionCorrectionPostProcess" {
  48155. import { Camera } from "babylonjs/Cameras/camera";
  48156. import { VRCameraMetrics } from "babylonjs/Cameras/VR/vrCameraMetrics";
  48157. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  48158. import "babylonjs/Shaders/vrDistortionCorrection.fragment";
  48159. /**
  48160. * VRDistortionCorrectionPostProcess used for mobile VR
  48161. */
  48162. export class VRDistortionCorrectionPostProcess extends PostProcess {
  48163. private _isRightEye;
  48164. private _distortionFactors;
  48165. private _postProcessScaleFactor;
  48166. private _lensCenterOffset;
  48167. private _scaleIn;
  48168. private _scaleFactor;
  48169. private _lensCenter;
  48170. /**
  48171. * Gets a string identifying the name of the class
  48172. * @returns "VRDistortionCorrectionPostProcess" string
  48173. */
  48174. getClassName(): string;
  48175. /**
  48176. * Initializes the VRDistortionCorrectionPostProcess
  48177. * @param name The name of the effect.
  48178. * @param camera The camera to apply the render pass to.
  48179. * @param isRightEye If this is for the right eye distortion
  48180. * @param vrMetrics All the required metrics for the VR camera
  48181. */
  48182. constructor(name: string, camera: Camera, isRightEye: boolean, vrMetrics: VRCameraMetrics);
  48183. }
  48184. }
  48185. declare module "babylonjs/Cameras/RigModes/vrRigMode" { }
  48186. declare module "babylonjs/Cameras/VR/vrDeviceOrientationArcRotateCamera" {
  48187. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  48188. import { VRCameraMetrics } from "babylonjs/Cameras/VR/vrCameraMetrics";
  48189. import { Scene } from "babylonjs/scene";
  48190. import { Vector3 } from "babylonjs/Maths/math.vector";
  48191. import "babylonjs/Cameras/Inputs/arcRotateCameraVRDeviceOrientationInput";
  48192. import "babylonjs/Cameras/RigModes/vrRigMode";
  48193. /**
  48194. * Camera used to simulate VR rendering (based on ArcRotateCamera)
  48195. * @see https://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  48196. */
  48197. export class VRDeviceOrientationArcRotateCamera extends ArcRotateCamera {
  48198. /**
  48199. * Creates a new VRDeviceOrientationArcRotateCamera
  48200. * @param name defines camera name
  48201. * @param alpha defines the camera rotation along the logitudinal axis
  48202. * @param beta defines the camera rotation along the latitudinal axis
  48203. * @param radius defines the camera distance from its target
  48204. * @param target defines the camera target
  48205. * @param scene defines the scene the camera belongs to
  48206. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  48207. * @param vrCameraMetrics defines the vr metrics associated to the camera
  48208. */
  48209. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  48210. /**
  48211. * Gets camera class name
  48212. * @returns VRDeviceOrientationArcRotateCamera
  48213. */
  48214. getClassName(): string;
  48215. }
  48216. }
  48217. declare module "babylonjs/Cameras/VR/vrDeviceOrientationFreeCamera" {
  48218. import { DeviceOrientationCamera } from "babylonjs/Cameras/deviceOrientationCamera";
  48219. import { VRCameraMetrics } from "babylonjs/Cameras/VR/vrCameraMetrics";
  48220. import { Scene } from "babylonjs/scene";
  48221. import { Vector3 } from "babylonjs/Maths/math.vector";
  48222. import "babylonjs/Cameras/RigModes/vrRigMode";
  48223. /**
  48224. * Camera used to simulate VR rendering (based on FreeCamera)
  48225. * @see https://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  48226. */
  48227. export class VRDeviceOrientationFreeCamera extends DeviceOrientationCamera {
  48228. /**
  48229. * Creates a new VRDeviceOrientationFreeCamera
  48230. * @param name defines camera name
  48231. * @param position defines the start position of the camera
  48232. * @param scene defines the scene the camera belongs to
  48233. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  48234. * @param vrCameraMetrics defines the vr metrics associated to the camera
  48235. */
  48236. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  48237. /**
  48238. * Gets camera class name
  48239. * @returns VRDeviceOrientationFreeCamera
  48240. */
  48241. getClassName(): string;
  48242. }
  48243. }
  48244. declare module "babylonjs/Cameras/VR/vrDeviceOrientationGamepadCamera" {
  48245. import { VRDeviceOrientationFreeCamera } from "babylonjs/Cameras/VR/vrDeviceOrientationFreeCamera";
  48246. import { VRCameraMetrics } from "babylonjs/Cameras/VR/vrCameraMetrics";
  48247. import { Scene } from "babylonjs/scene";
  48248. import { Vector3 } from "babylonjs/Maths/math.vector";
  48249. import "babylonjs/Gamepads/gamepadSceneComponent";
  48250. /**
  48251. * Camera used to simulate VR rendering (based on VRDeviceOrientationFreeCamera)
  48252. * @see https://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  48253. */
  48254. export class VRDeviceOrientationGamepadCamera extends VRDeviceOrientationFreeCamera {
  48255. /**
  48256. * Creates a new VRDeviceOrientationGamepadCamera
  48257. * @param name defines camera name
  48258. * @param position defines the start position of the camera
  48259. * @param scene defines the scene the camera belongs to
  48260. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  48261. * @param vrCameraMetrics defines the vr metrics associated to the camera
  48262. */
  48263. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  48264. /**
  48265. * Gets camera class name
  48266. * @returns VRDeviceOrientationGamepadCamera
  48267. */
  48268. getClassName(): string;
  48269. }
  48270. }
  48271. declare module "babylonjs/Materials/Textures/dynamicTexture" {
  48272. import { Scene } from "babylonjs/scene";
  48273. import { Texture } from "babylonjs/Materials/Textures/texture";
  48274. import "babylonjs/Engines/Extensions/engine.dynamicTexture";
  48275. /**
  48276. * A class extending Texture allowing drawing on a texture
  48277. * @see https://doc.babylonjs.com/how_to/dynamictexture
  48278. */
  48279. export class DynamicTexture extends Texture {
  48280. private _generateMipMaps;
  48281. private _canvas;
  48282. private _context;
  48283. /**
  48284. * Creates a DynamicTexture
  48285. * @param name defines the name of the texture
  48286. * @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
  48287. * @param scene defines the scene where you want the texture
  48288. * @param generateMipMaps defines the use of MinMaps or not (default is false)
  48289. * @param samplingMode defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  48290. * @param format defines the texture format to use (default is Engine.TEXTUREFORMAT_RGBA)
  48291. */
  48292. constructor(name: string, options: any, scene: Scene | null | undefined, generateMipMaps: boolean, samplingMode?: number, format?: number);
  48293. /**
  48294. * Get the current class name of the texture useful for serialization or dynamic coding.
  48295. * @returns "DynamicTexture"
  48296. */
  48297. getClassName(): string;
  48298. /**
  48299. * Gets the current state of canRescale
  48300. */
  48301. get canRescale(): boolean;
  48302. private _recreate;
  48303. /**
  48304. * Scales the texture
  48305. * @param ratio the scale factor to apply to both width and height
  48306. */
  48307. scale(ratio: number): void;
  48308. /**
  48309. * Resizes the texture
  48310. * @param width the new width
  48311. * @param height the new height
  48312. */
  48313. scaleTo(width: number, height: number): void;
  48314. /**
  48315. * Gets the context of the canvas used by the texture
  48316. * @returns the canvas context of the dynamic texture
  48317. */
  48318. getContext(): CanvasRenderingContext2D;
  48319. /**
  48320. * Clears the texture
  48321. */
  48322. clear(): void;
  48323. /**
  48324. * Updates the texture
  48325. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  48326. * @param premulAlpha defines if alpha is stored as premultiplied (default is false)
  48327. */
  48328. update(invertY?: boolean, premulAlpha?: boolean): void;
  48329. /**
  48330. * Draws text onto the texture
  48331. * @param text defines the text to be drawn
  48332. * @param x defines the placement of the text from the left
  48333. * @param y defines the placement of the text from the top when invertY is true and from the bottom when false
  48334. * @param font defines the font to be used with font-style, font-size, font-name
  48335. * @param color defines the color used for the text
  48336. * @param clearColor defines the color for the canvas, use null to not overwrite canvas
  48337. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  48338. * @param update defines whether texture is immediately update (default is true)
  48339. */
  48340. drawText(text: string, x: number | null | undefined, y: number | null | undefined, font: string, color: string | null, clearColor: string, invertY?: boolean, update?: boolean): void;
  48341. /**
  48342. * Clones the texture
  48343. * @returns the clone of the texture.
  48344. */
  48345. clone(): DynamicTexture;
  48346. /**
  48347. * Serializes the dynamic texture. The scene should be ready before the dynamic texture is serialized
  48348. * @returns a serialized dynamic texture object
  48349. */
  48350. serialize(): any;
  48351. private _IsCanvasElement;
  48352. /** @hidden */
  48353. _rebuild(): void;
  48354. }
  48355. }
  48356. declare module "babylonjs/Meshes/Builders/groundBuilder" {
  48357. import { Scene } from "babylonjs/scene";
  48358. import { Color3 } from "babylonjs/Maths/math.color";
  48359. import { Mesh } from "babylonjs/Meshes/mesh";
  48360. import { GroundMesh } from "babylonjs/Meshes/groundMesh";
  48361. import { Nullable } from "babylonjs/types";
  48362. /**
  48363. * Class containing static functions to help procedurally build meshes
  48364. */
  48365. export class GroundBuilder {
  48366. /**
  48367. * Creates a ground mesh
  48368. * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
  48369. * * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side
  48370. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  48371. * @param name defines the name of the mesh
  48372. * @param options defines the options used to create the mesh
  48373. * @param scene defines the hosting scene
  48374. * @returns the ground mesh
  48375. * @see https://doc.babylonjs.com/how_to/set_shapes#ground
  48376. */
  48377. static CreateGround(name: string, options: {
  48378. width?: number;
  48379. height?: number;
  48380. subdivisions?: number;
  48381. subdivisionsX?: number;
  48382. subdivisionsY?: number;
  48383. updatable?: boolean;
  48384. }, scene: any): Mesh;
  48385. /**
  48386. * Creates a tiled ground mesh
  48387. * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
  48388. * * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates
  48389. * * 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
  48390. * * 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
  48391. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  48392. * @param name defines the name of the mesh
  48393. * @param options defines the options used to create the mesh
  48394. * @param scene defines the hosting scene
  48395. * @returns the tiled ground mesh
  48396. * @see https://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  48397. */
  48398. static CreateTiledGround(name: string, options: {
  48399. xmin: number;
  48400. zmin: number;
  48401. xmax: number;
  48402. zmax: number;
  48403. subdivisions?: {
  48404. w: number;
  48405. h: number;
  48406. };
  48407. precision?: {
  48408. w: number;
  48409. h: number;
  48410. };
  48411. updatable?: boolean;
  48412. }, scene?: Nullable<Scene>): Mesh;
  48413. /**
  48414. * Creates a ground mesh from a height map
  48415. * * The parameter `url` sets the URL of the height map image resource.
  48416. * * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  48417. * * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  48418. * * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  48419. * * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  48420. * * 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.
  48421. * * 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).
  48422. * * The parameter `alphaFilter` will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  48423. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  48424. * @param name defines the name of the mesh
  48425. * @param url defines the url to the height map
  48426. * @param options defines the options used to create the mesh
  48427. * @param scene defines the hosting scene
  48428. * @returns the ground mesh
  48429. * @see https://doc.babylonjs.com/babylon101/height_map
  48430. * @see https://doc.babylonjs.com/how_to/set_shapes#ground-from-a-height-map
  48431. */
  48432. static CreateGroundFromHeightMap(name: string, url: string, options: {
  48433. width?: number;
  48434. height?: number;
  48435. subdivisions?: number;
  48436. minHeight?: number;
  48437. maxHeight?: number;
  48438. colorFilter?: Color3;
  48439. alphaFilter?: number;
  48440. updatable?: boolean;
  48441. onReady?: (mesh: GroundMesh) => void;
  48442. }, scene?: Nullable<Scene>): GroundMesh;
  48443. }
  48444. }
  48445. declare module "babylonjs/Meshes/Builders/torusBuilder" {
  48446. import { Vector4 } from "babylonjs/Maths/math.vector";
  48447. import { Mesh } from "babylonjs/Meshes/mesh";
  48448. /**
  48449. * Class containing static functions to help procedurally build meshes
  48450. */
  48451. export class TorusBuilder {
  48452. /**
  48453. * Creates a torus mesh
  48454. * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
  48455. * * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5)
  48456. * * The parameter `tessellation` sets the number of torus sides (postive integer, default 16)
  48457. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  48458. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  48459. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  48460. * @param name defines the name of the mesh
  48461. * @param options defines the options used to create the mesh
  48462. * @param scene defines the hosting scene
  48463. * @returns the torus mesh
  48464. * @see https://doc.babylonjs.com/how_to/set_shapes#torus
  48465. */
  48466. static CreateTorus(name: string, options: {
  48467. diameter?: number;
  48468. thickness?: number;
  48469. tessellation?: number;
  48470. updatable?: boolean;
  48471. sideOrientation?: number;
  48472. frontUVs?: Vector4;
  48473. backUVs?: Vector4;
  48474. }, scene: any): Mesh;
  48475. }
  48476. }
  48477. declare module "babylonjs/Meshes/Builders/cylinderBuilder" {
  48478. import { Vector4 } from "babylonjs/Maths/math.vector";
  48479. import { Color4 } from "babylonjs/Maths/math.color";
  48480. import { Mesh } from "babylonjs/Meshes/mesh";
  48481. /**
  48482. * Class containing static functions to help procedurally build meshes
  48483. */
  48484. export class CylinderBuilder {
  48485. /**
  48486. * Creates a cylinder or a cone mesh
  48487. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  48488. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  48489. * * 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.
  48490. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  48491. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  48492. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  48493. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  48494. * * 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).
  48495. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  48496. * * 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).
  48497. * * 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
  48498. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  48499. * * 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
  48500. * * 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.
  48501. * * If `enclose` is false, a ring surface is one element.
  48502. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  48503. * * 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
  48504. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  48505. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  48506. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  48507. * @param name defines the name of the mesh
  48508. * @param options defines the options used to create the mesh
  48509. * @param scene defines the hosting scene
  48510. * @returns the cylinder mesh
  48511. * @see https://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  48512. */
  48513. static CreateCylinder(name: string, options: {
  48514. height?: number;
  48515. diameterTop?: number;
  48516. diameterBottom?: number;
  48517. diameter?: number;
  48518. tessellation?: number;
  48519. subdivisions?: number;
  48520. arc?: number;
  48521. faceColors?: Color4[];
  48522. faceUV?: Vector4[];
  48523. updatable?: boolean;
  48524. hasRings?: boolean;
  48525. enclose?: boolean;
  48526. cap?: number;
  48527. sideOrientation?: number;
  48528. frontUVs?: Vector4;
  48529. backUVs?: Vector4;
  48530. }, scene: any): Mesh;
  48531. }
  48532. }
  48533. declare module "babylonjs/XR/webXRTypes" {
  48534. import { Nullable } from "babylonjs/types";
  48535. import { IDisposable } from "babylonjs/scene";
  48536. /**
  48537. * States of the webXR experience
  48538. */
  48539. export enum WebXRState {
  48540. /**
  48541. * Transitioning to being in XR mode
  48542. */
  48543. ENTERING_XR = 0,
  48544. /**
  48545. * Transitioning to non XR mode
  48546. */
  48547. EXITING_XR = 1,
  48548. /**
  48549. * In XR mode and presenting
  48550. */
  48551. IN_XR = 2,
  48552. /**
  48553. * Not entered XR mode
  48554. */
  48555. NOT_IN_XR = 3
  48556. }
  48557. /**
  48558. * Abstraction of the XR render target
  48559. */
  48560. export interface WebXRRenderTarget extends IDisposable {
  48561. /**
  48562. * xrpresent context of the canvas which can be used to display/mirror xr content
  48563. */
  48564. canvasContext: WebGLRenderingContext;
  48565. /**
  48566. * xr layer for the canvas
  48567. */
  48568. xrLayer: Nullable<XRWebGLLayer>;
  48569. /**
  48570. * Initializes the xr layer for the session
  48571. * @param xrSession xr session
  48572. * @returns a promise that will resolve once the XR Layer has been created
  48573. */
  48574. initializeXRLayerAsync(xrSession: XRSession): Promise<XRWebGLLayer>;
  48575. }
  48576. }
  48577. declare module "babylonjs/XR/webXRManagedOutputCanvas" {
  48578. import { Nullable } from "babylonjs/types";
  48579. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  48580. import { WebXRRenderTarget } from "babylonjs/XR/webXRTypes";
  48581. import { WebXRSessionManager } from "babylonjs/XR/webXRSessionManager";
  48582. import { Observable } from "babylonjs/Misc/observable";
  48583. /**
  48584. * COnfiguration object for WebXR output canvas
  48585. */
  48586. export class WebXRManagedOutputCanvasOptions {
  48587. /**
  48588. * An optional canvas in case you wish to create it yourself and provide it here.
  48589. * If not provided, a new canvas will be created
  48590. */
  48591. canvasElement?: HTMLCanvasElement;
  48592. /**
  48593. * Options for this XR Layer output
  48594. */
  48595. canvasOptions?: XRWebGLLayerOptions;
  48596. /**
  48597. * CSS styling for a newly created canvas (if not provided)
  48598. */
  48599. newCanvasCssStyle?: string;
  48600. /**
  48601. * Get the default values of the configuration object
  48602. * @param engine defines the engine to use (can be null)
  48603. * @returns default values of this configuration object
  48604. */
  48605. static GetDefaults(engine?: ThinEngine): WebXRManagedOutputCanvasOptions;
  48606. }
  48607. /**
  48608. * Creates a canvas that is added/removed from the webpage when entering/exiting XR
  48609. */
  48610. export class WebXRManagedOutputCanvas implements WebXRRenderTarget {
  48611. private _options;
  48612. private _canvas;
  48613. private _engine;
  48614. private _originalCanvasSize;
  48615. /**
  48616. * Rendering context of the canvas which can be used to display/mirror xr content
  48617. */
  48618. canvasContext: WebGLRenderingContext;
  48619. /**
  48620. * xr layer for the canvas
  48621. */
  48622. xrLayer: Nullable<XRWebGLLayer>;
  48623. /**
  48624. * Obseervers registered here will be triggered when the xr layer was initialized
  48625. */
  48626. onXRLayerInitObservable: Observable<XRWebGLLayer>;
  48627. /**
  48628. * Initializes the canvas to be added/removed upon entering/exiting xr
  48629. * @param _xrSessionManager The XR Session manager
  48630. * @param _options optional configuration for this canvas output. defaults will be used if not provided
  48631. */
  48632. constructor(_xrSessionManager: WebXRSessionManager, _options?: WebXRManagedOutputCanvasOptions);
  48633. /**
  48634. * Disposes of the object
  48635. */
  48636. dispose(): void;
  48637. /**
  48638. * Initializes the xr layer for the session
  48639. * @param xrSession xr session
  48640. * @returns a promise that will resolve once the XR Layer has been created
  48641. */
  48642. initializeXRLayerAsync(xrSession: XRSession): Promise<XRWebGLLayer>;
  48643. private _addCanvas;
  48644. private _removeCanvas;
  48645. private _setCanvasSize;
  48646. private _setManagedOutputCanvas;
  48647. }
  48648. }
  48649. declare module "babylonjs/XR/webXRSessionManager" {
  48650. import { Observable } from "babylonjs/Misc/observable";
  48651. import { Nullable } from "babylonjs/types";
  48652. import { IDisposable, Scene } from "babylonjs/scene";
  48653. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  48654. import { WebXRRenderTarget } from "babylonjs/XR/webXRTypes";
  48655. import { WebXRManagedOutputCanvasOptions } from "babylonjs/XR/webXRManagedOutputCanvas";
  48656. /**
  48657. * Manages an XRSession to work with Babylon's engine
  48658. * @see https://doc.babylonjs.com/how_to/webxr_session_manager
  48659. */
  48660. export class WebXRSessionManager implements IDisposable {
  48661. /** The scene which the session should be created for */
  48662. scene: Scene;
  48663. private _referenceSpace;
  48664. private _rttProvider;
  48665. private _sessionEnded;
  48666. private _xrNavigator;
  48667. private baseLayer;
  48668. /**
  48669. * The base reference space from which the session started. good if you want to reset your
  48670. * reference space
  48671. */
  48672. baseReferenceSpace: XRReferenceSpace;
  48673. /**
  48674. * Current XR frame
  48675. */
  48676. currentFrame: Nullable<XRFrame>;
  48677. /** WebXR timestamp updated every frame */
  48678. currentTimestamp: number;
  48679. /**
  48680. * Used just in case of a failure to initialize an immersive session.
  48681. * The viewer reference space is compensated using this height, creating a kind of "viewer-floor" reference space
  48682. */
  48683. defaultHeightCompensation: number;
  48684. /**
  48685. * Fires every time a new xrFrame arrives which can be used to update the camera
  48686. */
  48687. onXRFrameObservable: Observable<XRFrame>;
  48688. /**
  48689. * Fires when the reference space changed
  48690. */
  48691. onXRReferenceSpaceChanged: Observable<XRReferenceSpace>;
  48692. /**
  48693. * Fires when the xr session is ended either by the device or manually done
  48694. */
  48695. onXRSessionEnded: Observable<any>;
  48696. /**
  48697. * Fires when the xr session is ended either by the device or manually done
  48698. */
  48699. onXRSessionInit: Observable<XRSession>;
  48700. /**
  48701. * Underlying xr session
  48702. */
  48703. session: XRSession;
  48704. /**
  48705. * The viewer (head position) reference space. This can be used to get the XR world coordinates
  48706. * or get the offset the player is currently at.
  48707. */
  48708. viewerReferenceSpace: XRReferenceSpace;
  48709. /**
  48710. * Constructs a WebXRSessionManager, this must be initialized within a user action before usage
  48711. * @param scene The scene which the session should be created for
  48712. */
  48713. constructor(
  48714. /** The scene which the session should be created for */
  48715. scene: Scene);
  48716. /**
  48717. * The current reference space used in this session. This reference space can constantly change!
  48718. * It is mainly used to offset the camera's position.
  48719. */
  48720. get referenceSpace(): XRReferenceSpace;
  48721. /**
  48722. * Set a new reference space and triggers the observable
  48723. */
  48724. set referenceSpace(newReferenceSpace: XRReferenceSpace);
  48725. /**
  48726. * Disposes of the session manager
  48727. */
  48728. dispose(): void;
  48729. /**
  48730. * Stops the xrSession and restores the render loop
  48731. * @returns Promise which resolves after it exits XR
  48732. */
  48733. exitXRAsync(): Promise<void>;
  48734. /**
  48735. * Gets the correct render target texture to be rendered this frame for this eye
  48736. * @param eye the eye for which to get the render target
  48737. * @returns the render target for the specified eye
  48738. */
  48739. getRenderTargetTextureForEye(eye: XREye): RenderTargetTexture;
  48740. /**
  48741. * Creates a WebXRRenderTarget object for the XR session
  48742. * @param onStateChangedObservable optional, mechanism for enabling/disabling XR rendering canvas, used only on Web
  48743. * @param options optional options to provide when creating a new render target
  48744. * @returns a WebXR render target to which the session can render
  48745. */
  48746. getWebXRRenderTarget(options?: WebXRManagedOutputCanvasOptions): WebXRRenderTarget;
  48747. /**
  48748. * Initializes the manager
  48749. * After initialization enterXR can be called to start an XR session
  48750. * @returns Promise which resolves after it is initialized
  48751. */
  48752. initializeAsync(): Promise<void>;
  48753. /**
  48754. * Initializes an xr session
  48755. * @param xrSessionMode mode to initialize
  48756. * @param xrSessionInit defines optional and required values to pass to the session builder
  48757. * @returns a promise which will resolve once the session has been initialized
  48758. */
  48759. initializeSessionAsync(xrSessionMode?: XRSessionMode, xrSessionInit?: XRSessionInit): Promise<XRSession>;
  48760. /**
  48761. * Checks if a session would be supported for the creation options specified
  48762. * @param sessionMode session mode to check if supported eg. immersive-vr
  48763. * @returns A Promise that resolves to true if supported and false if not
  48764. */
  48765. isSessionSupportedAsync(sessionMode: XRSessionMode): Promise<boolean>;
  48766. /**
  48767. * Resets the reference space to the one started the session
  48768. */
  48769. resetReferenceSpace(): void;
  48770. /**
  48771. * Starts rendering to the xr layer
  48772. */
  48773. runXRRenderLoop(): void;
  48774. /**
  48775. * Sets the reference space on the xr session
  48776. * @param referenceSpaceType space to set
  48777. * @returns a promise that will resolve once the reference space has been set
  48778. */
  48779. setReferenceSpaceTypeAsync(referenceSpaceType?: XRReferenceSpaceType): Promise<XRReferenceSpace>;
  48780. /**
  48781. * Updates the render state of the session
  48782. * @param state state to set
  48783. * @returns a promise that resolves once the render state has been updated
  48784. */
  48785. updateRenderStateAsync(state: XRRenderState): Promise<void>;
  48786. /**
  48787. * Returns a promise that resolves with a boolean indicating if the provided session mode is supported by this browser
  48788. * @param sessionMode defines the session to test
  48789. * @returns a promise with boolean as final value
  48790. */
  48791. static IsSessionSupportedAsync(sessionMode: XRSessionMode): Promise<boolean>;
  48792. private _createRenderTargetTexture;
  48793. }
  48794. }
  48795. declare module "babylonjs/XR/webXRCamera" {
  48796. import { Vector3 } from "babylonjs/Maths/math.vector";
  48797. import { Scene } from "babylonjs/scene";
  48798. import { Camera } from "babylonjs/Cameras/camera";
  48799. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  48800. import { WebXRSessionManager } from "babylonjs/XR/webXRSessionManager";
  48801. import { Observable } from "babylonjs/Misc/observable";
  48802. /**
  48803. * WebXR Camera which holds the views for the xrSession
  48804. * @see https://doc.babylonjs.com/how_to/webxr_camera
  48805. */
  48806. export class WebXRCamera extends FreeCamera {
  48807. private _xrSessionManager;
  48808. private _firstFrame;
  48809. private _referenceQuaternion;
  48810. private _referencedPosition;
  48811. private _xrInvPositionCache;
  48812. private _xrInvQuaternionCache;
  48813. /**
  48814. * Observable raised before camera teleportation
  48815. */
  48816. onBeforeCameraTeleport: Observable<Vector3>;
  48817. /**
  48818. * Observable raised after camera teleportation
  48819. */
  48820. onAfterCameraTeleport: Observable<Vector3>;
  48821. /**
  48822. * Should position compensation execute on first frame.
  48823. * This is used when copying the position from a native (non XR) camera
  48824. */
  48825. compensateOnFirstFrame: boolean;
  48826. /**
  48827. * Creates a new webXRCamera, this should only be set at the camera after it has been updated by the xrSessionManager
  48828. * @param name the name of the camera
  48829. * @param scene the scene to add the camera to
  48830. * @param _xrSessionManager a constructed xr session manager
  48831. */
  48832. constructor(name: string, scene: Scene, _xrSessionManager: WebXRSessionManager);
  48833. /**
  48834. * Return the user's height, unrelated to the current ground.
  48835. * This will be the y position of this camera, when ground level is 0.
  48836. */
  48837. get realWorldHeight(): number;
  48838. /** @hidden */
  48839. _updateForDualEyeDebugging(): void;
  48840. /**
  48841. * Sets this camera's transformation based on a non-vr camera
  48842. * @param otherCamera the non-vr camera to copy the transformation from
  48843. * @param resetToBaseReferenceSpace should XR reset to the base reference space
  48844. */
  48845. setTransformationFromNonVRCamera(otherCamera?: Camera, resetToBaseReferenceSpace?: boolean): void;
  48846. /**
  48847. * Gets the current instance class name ("WebXRCamera").
  48848. * @returns the class name
  48849. */
  48850. getClassName(): string;
  48851. private _rotate180;
  48852. private _updateFromXRSession;
  48853. private _updateNumberOfRigCameras;
  48854. private _updateReferenceSpace;
  48855. private _updateReferenceSpaceOffset;
  48856. }
  48857. }
  48858. declare module "babylonjs/XR/webXRFeaturesManager" {
  48859. import { WebXRSessionManager } from "babylonjs/XR/webXRSessionManager";
  48860. import { IDisposable } from "babylonjs/scene";
  48861. /**
  48862. * Defining the interface required for a (webxr) feature
  48863. */
  48864. export interface IWebXRFeature extends IDisposable {
  48865. /**
  48866. * Is this feature attached
  48867. */
  48868. attached: boolean;
  48869. /**
  48870. * Should auto-attach be disabled?
  48871. */
  48872. disableAutoAttach: boolean;
  48873. /**
  48874. * Attach the feature to the session
  48875. * Will usually be called by the features manager
  48876. *
  48877. * @param force should attachment be forced (even when already attached)
  48878. * @returns true if successful.
  48879. */
  48880. attach(force?: boolean): boolean;
  48881. /**
  48882. * Detach the feature from the session
  48883. * Will usually be called by the features manager
  48884. *
  48885. * @returns true if successful.
  48886. */
  48887. detach(): boolean;
  48888. /**
  48889. * This function will be executed during before enabling the feature and can be used to not-allow enabling it.
  48890. * Note that at this point the session has NOT started, so this is purely checking if the browser supports it
  48891. *
  48892. * @returns whether or not the feature is compatible in this environment
  48893. */
  48894. isCompatible(): boolean;
  48895. /**
  48896. * The name of the native xr feature name, if applicable (like anchor, hit-test, or hand-tracking)
  48897. */
  48898. xrNativeFeatureName?: string;
  48899. /**
  48900. * A list of (Babylon WebXR) features this feature depends on
  48901. */
  48902. dependsOn?: string[];
  48903. }
  48904. /**
  48905. * A list of the currently available features without referencing them
  48906. */
  48907. export class WebXRFeatureName {
  48908. /**
  48909. * The name of the anchor system feature
  48910. */
  48911. static readonly ANCHOR_SYSTEM: string;
  48912. /**
  48913. * The name of the background remover feature
  48914. */
  48915. static readonly BACKGROUND_REMOVER: string;
  48916. /**
  48917. * The name of the hit test feature
  48918. */
  48919. static readonly HIT_TEST: string;
  48920. /**
  48921. * physics impostors for xr controllers feature
  48922. */
  48923. static readonly PHYSICS_CONTROLLERS: string;
  48924. /**
  48925. * The name of the plane detection feature
  48926. */
  48927. static readonly PLANE_DETECTION: string;
  48928. /**
  48929. * The name of the pointer selection feature
  48930. */
  48931. static readonly POINTER_SELECTION: string;
  48932. /**
  48933. * The name of the teleportation feature
  48934. */
  48935. static readonly TELEPORTATION: string;
  48936. /**
  48937. * The name of the feature points feature.
  48938. */
  48939. static readonly FEATURE_POINTS: string;
  48940. /**
  48941. * The name of the hand tracking feature.
  48942. */
  48943. static readonly HAND_TRACKING: string;
  48944. }
  48945. /**
  48946. * Defining the constructor of a feature. Used to register the modules.
  48947. */
  48948. export type WebXRFeatureConstructor = (xrSessionManager: WebXRSessionManager, options?: any) => () => IWebXRFeature;
  48949. /**
  48950. * The WebXR features manager is responsible of enabling or disabling features required for the current XR session.
  48951. * It is mainly used in AR sessions.
  48952. *
  48953. * A feature can have a version that is defined by Babylon (and does not correspond with the webxr version).
  48954. */
  48955. export class WebXRFeaturesManager implements IDisposable {
  48956. private _xrSessionManager;
  48957. private static readonly _AvailableFeatures;
  48958. private _features;
  48959. /**
  48960. * constructs a new features manages.
  48961. *
  48962. * @param _xrSessionManager an instance of WebXRSessionManager
  48963. */
  48964. constructor(_xrSessionManager: WebXRSessionManager);
  48965. /**
  48966. * Used to register a module. After calling this function a developer can use this feature in the scene.
  48967. * Mainly used internally.
  48968. *
  48969. * @param featureName the name of the feature to register
  48970. * @param constructorFunction the function used to construct the module
  48971. * @param version the (babylon) version of the module
  48972. * @param stable is that a stable version of this module
  48973. */
  48974. static AddWebXRFeature(featureName: string, constructorFunction: WebXRFeatureConstructor, version?: number, stable?: boolean): void;
  48975. /**
  48976. * Returns a constructor of a specific feature.
  48977. *
  48978. * @param featureName the name of the feature to construct
  48979. * @param version the version of the feature to load
  48980. * @param xrSessionManager the xrSessionManager. Used to construct the module
  48981. * @param options optional options provided to the module.
  48982. * @returns a function that, when called, will return a new instance of this feature
  48983. */
  48984. static ConstructFeature(featureName: string, version: number | undefined, xrSessionManager: WebXRSessionManager, options?: any): () => IWebXRFeature;
  48985. /**
  48986. * Can be used to return the list of features currently registered
  48987. *
  48988. * @returns an Array of available features
  48989. */
  48990. static GetAvailableFeatures(): string[];
  48991. /**
  48992. * Gets the versions available for a specific feature
  48993. * @param featureName the name of the feature
  48994. * @returns an array with the available versions
  48995. */
  48996. static GetAvailableVersions(featureName: string): string[];
  48997. /**
  48998. * Return the latest unstable version of this feature
  48999. * @param featureName the name of the feature to search
  49000. * @returns the version number. if not found will return -1
  49001. */
  49002. static GetLatestVersionOfFeature(featureName: string): number;
  49003. /**
  49004. * Return the latest stable version of this feature
  49005. * @param featureName the name of the feature to search
  49006. * @returns the version number. if not found will return -1
  49007. */
  49008. static GetStableVersionOfFeature(featureName: string): number;
  49009. /**
  49010. * Attach a feature to the current session. Mainly used when session started to start the feature effect.
  49011. * Can be used during a session to start a feature
  49012. * @param featureName the name of feature to attach
  49013. */
  49014. attachFeature(featureName: string): void;
  49015. /**
  49016. * Can be used inside a session or when the session ends to detach a specific feature
  49017. * @param featureName the name of the feature to detach
  49018. */
  49019. detachFeature(featureName: string): void;
  49020. /**
  49021. * Used to disable an already-enabled feature
  49022. * The feature will be disposed and will be recreated once enabled.
  49023. * @param featureName the feature to disable
  49024. * @returns true if disable was successful
  49025. */
  49026. disableFeature(featureName: string | {
  49027. Name: string;
  49028. }): boolean;
  49029. /**
  49030. * dispose this features manager
  49031. */
  49032. dispose(): void;
  49033. /**
  49034. * 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.
  49035. * 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.
  49036. *
  49037. * @param featureName the name of the feature to load or the class of the feature
  49038. * @param version optional version to load. if not provided the latest version will be enabled
  49039. * @param moduleOptions options provided to the module. Ses the module documentation / constructor
  49040. * @param attachIfPossible if set to true (default) the feature will be automatically attached, if it is currently possible
  49041. * @param required is this feature required to the app. If set to true the session init will fail if the feature is not available.
  49042. * @returns a new constructed feature or throws an error if feature not found.
  49043. */
  49044. enableFeature(featureName: string | {
  49045. Name: string;
  49046. }, version?: number | string, moduleOptions?: any, attachIfPossible?: boolean, required?: boolean): IWebXRFeature;
  49047. /**
  49048. * get the implementation of an enabled feature.
  49049. * @param featureName the name of the feature to load
  49050. * @returns the feature class, if found
  49051. */
  49052. getEnabledFeature(featureName: string): IWebXRFeature;
  49053. /**
  49054. * Get the list of enabled features
  49055. * @returns an array of enabled features
  49056. */
  49057. getEnabledFeatures(): string[];
  49058. /**
  49059. * This function will exten the session creation configuration object with enabled features.
  49060. * If, for example, the anchors feature is enabled, it will be automatically added to the optional or required features list,
  49061. * according to the defined "required" variable, provided during enableFeature call
  49062. * @param xrSessionInit the xr Session init object to extend
  49063. *
  49064. * @returns an extended XRSessionInit object
  49065. */
  49066. extendXRSessionInitObject(xrSessionInit: XRSessionInit): XRSessionInit;
  49067. }
  49068. }
  49069. declare module "babylonjs/XR/webXRExperienceHelper" {
  49070. import { Observable } from "babylonjs/Misc/observable";
  49071. import { IDisposable, Scene } from "babylonjs/scene";
  49072. import { WebXRSessionManager } from "babylonjs/XR/webXRSessionManager";
  49073. import { WebXRCamera } from "babylonjs/XR/webXRCamera";
  49074. import { WebXRState, WebXRRenderTarget } from "babylonjs/XR/webXRTypes";
  49075. import { WebXRFeaturesManager } from "babylonjs/XR/webXRFeaturesManager";
  49076. /**
  49077. * Base set of functionality needed to create an XR experience (WebXRSessionManager, Camera, StateManagement, etc.)
  49078. * @see https://doc.babylonjs.com/how_to/webxr_experience_helpers
  49079. */
  49080. export class WebXRExperienceHelper implements IDisposable {
  49081. private scene;
  49082. private _nonVRCamera;
  49083. private _originalSceneAutoClear;
  49084. private _supported;
  49085. /**
  49086. * Camera used to render xr content
  49087. */
  49088. camera: WebXRCamera;
  49089. /** A features manager for this xr session */
  49090. featuresManager: WebXRFeaturesManager;
  49091. /**
  49092. * Observers registered here will be triggered after the camera's initial transformation is set
  49093. * This can be used to set a different ground level or an extra rotation.
  49094. *
  49095. * Note that ground level is considered to be at 0. The height defined by the XR camera will be added
  49096. * to the position set after this observable is done executing.
  49097. */
  49098. onInitialXRPoseSetObservable: Observable<WebXRCamera>;
  49099. /**
  49100. * Fires when the state of the experience helper has changed
  49101. */
  49102. onStateChangedObservable: Observable<WebXRState>;
  49103. /** Session manager used to keep track of xr session */
  49104. sessionManager: WebXRSessionManager;
  49105. /**
  49106. * The current state of the XR experience (eg. transitioning, in XR or not in XR)
  49107. */
  49108. state: WebXRState;
  49109. /**
  49110. * Creates a WebXRExperienceHelper
  49111. * @param scene The scene the helper should be created in
  49112. */
  49113. private constructor();
  49114. /**
  49115. * Creates the experience helper
  49116. * @param scene the scene to attach the experience helper to
  49117. * @returns a promise for the experience helper
  49118. */
  49119. static CreateAsync(scene: Scene): Promise<WebXRExperienceHelper>;
  49120. /**
  49121. * Disposes of the experience helper
  49122. */
  49123. dispose(): void;
  49124. /**
  49125. * Enters XR mode (This must be done within a user interaction in most browsers eg. button click)
  49126. * @param sessionMode options for the XR session
  49127. * @param referenceSpaceType frame of reference of the XR session
  49128. * @param renderTarget the output canvas that will be used to enter XR mode
  49129. * @param sessionCreationOptions optional XRSessionInit object to init the session with
  49130. * @returns promise that resolves after xr mode has entered
  49131. */
  49132. enterXRAsync(sessionMode: XRSessionMode, referenceSpaceType: XRReferenceSpaceType, renderTarget?: WebXRRenderTarget, sessionCreationOptions?: XRSessionInit): Promise<WebXRSessionManager>;
  49133. /**
  49134. * Exits XR mode and returns the scene to its original state
  49135. * @returns promise that resolves after xr mode has exited
  49136. */
  49137. exitXRAsync(): Promise<void>;
  49138. private _nonXRToXRCamera;
  49139. private _setState;
  49140. }
  49141. }
  49142. declare module "babylonjs/XR/motionController/webXRControllerComponent" {
  49143. import { IMinimalMotionControllerObject, MotionControllerComponentType } from "babylonjs/XR/motionController/webXRAbstractMotionController";
  49144. import { Observable } from "babylonjs/Misc/observable";
  49145. import { IDisposable } from "babylonjs/scene";
  49146. /**
  49147. * X-Y values for axes in WebXR
  49148. */
  49149. export interface IWebXRMotionControllerAxesValue {
  49150. /**
  49151. * The value of the x axis
  49152. */
  49153. x: number;
  49154. /**
  49155. * The value of the y-axis
  49156. */
  49157. y: number;
  49158. }
  49159. /**
  49160. * changed / previous values for the values of this component
  49161. */
  49162. export interface IWebXRMotionControllerComponentChangesValues<T> {
  49163. /**
  49164. * current (this frame) value
  49165. */
  49166. current: T;
  49167. /**
  49168. * previous (last change) value
  49169. */
  49170. previous: T;
  49171. }
  49172. /**
  49173. * Represents changes in the component between current frame and last values recorded
  49174. */
  49175. export interface IWebXRMotionControllerComponentChanges {
  49176. /**
  49177. * will be populated with previous and current values if axes changed
  49178. */
  49179. axes?: IWebXRMotionControllerComponentChangesValues<IWebXRMotionControllerAxesValue>;
  49180. /**
  49181. * will be populated with previous and current values if pressed changed
  49182. */
  49183. pressed?: IWebXRMotionControllerComponentChangesValues<boolean>;
  49184. /**
  49185. * will be populated with previous and current values if touched changed
  49186. */
  49187. touched?: IWebXRMotionControllerComponentChangesValues<boolean>;
  49188. /**
  49189. * will be populated with previous and current values if value changed
  49190. */
  49191. value?: IWebXRMotionControllerComponentChangesValues<number>;
  49192. }
  49193. /**
  49194. * This class represents a single component (for example button or thumbstick) of a motion controller
  49195. */
  49196. export class WebXRControllerComponent implements IDisposable {
  49197. /**
  49198. * the id of this component
  49199. */
  49200. id: string;
  49201. /**
  49202. * the type of the component
  49203. */
  49204. type: MotionControllerComponentType;
  49205. private _buttonIndex;
  49206. private _axesIndices;
  49207. private _axes;
  49208. private _changes;
  49209. private _currentValue;
  49210. private _hasChanges;
  49211. private _pressed;
  49212. private _touched;
  49213. /**
  49214. * button component type
  49215. */
  49216. static BUTTON_TYPE: MotionControllerComponentType;
  49217. /**
  49218. * squeeze component type
  49219. */
  49220. static SQUEEZE_TYPE: MotionControllerComponentType;
  49221. /**
  49222. * Thumbstick component type
  49223. */
  49224. static THUMBSTICK_TYPE: MotionControllerComponentType;
  49225. /**
  49226. * Touchpad component type
  49227. */
  49228. static TOUCHPAD_TYPE: MotionControllerComponentType;
  49229. /**
  49230. * trigger component type
  49231. */
  49232. static TRIGGER_TYPE: MotionControllerComponentType;
  49233. /**
  49234. * If axes are available for this component (like a touchpad or thumbstick) the observers will be notified when
  49235. * the axes data changes
  49236. */
  49237. onAxisValueChangedObservable: Observable<{
  49238. x: number;
  49239. y: number;
  49240. }>;
  49241. /**
  49242. * Observers registered here will be triggered when the state of a button changes
  49243. * State change is either pressed / touched / value
  49244. */
  49245. onButtonStateChangedObservable: Observable<WebXRControllerComponent>;
  49246. /**
  49247. * Creates a new component for a motion controller.
  49248. * It is created by the motion controller itself
  49249. *
  49250. * @param id the id of this component
  49251. * @param type the type of the component
  49252. * @param _buttonIndex index in the buttons array of the gamepad
  49253. * @param _axesIndices indices of the values in the axes array of the gamepad
  49254. */
  49255. constructor(
  49256. /**
  49257. * the id of this component
  49258. */
  49259. id: string,
  49260. /**
  49261. * the type of the component
  49262. */
  49263. type: MotionControllerComponentType, _buttonIndex?: number, _axesIndices?: number[]);
  49264. /**
  49265. * The current axes data. If this component has no axes it will still return an object { x: 0, y: 0 }
  49266. */
  49267. get axes(): IWebXRMotionControllerAxesValue;
  49268. /**
  49269. * Get the changes. Elements will be populated only if they changed with their previous and current value
  49270. */
  49271. get changes(): IWebXRMotionControllerComponentChanges;
  49272. /**
  49273. * Return whether or not the component changed the last frame
  49274. */
  49275. get hasChanges(): boolean;
  49276. /**
  49277. * is the button currently pressed
  49278. */
  49279. get pressed(): boolean;
  49280. /**
  49281. * is the button currently touched
  49282. */
  49283. get touched(): boolean;
  49284. /**
  49285. * Get the current value of this component
  49286. */
  49287. get value(): number;
  49288. /**
  49289. * Dispose this component
  49290. */
  49291. dispose(): void;
  49292. /**
  49293. * Are there axes correlating to this component
  49294. * @return true is axes data is available
  49295. */
  49296. isAxes(): boolean;
  49297. /**
  49298. * Is this component a button (hence - pressable)
  49299. * @returns true if can be pressed
  49300. */
  49301. isButton(): boolean;
  49302. /**
  49303. * update this component using the gamepad object it is in. Called on every frame
  49304. * @param nativeController the native gamepad controller object
  49305. */
  49306. update(nativeController: IMinimalMotionControllerObject): void;
  49307. }
  49308. }
  49309. declare module "babylonjs/Loading/sceneLoader" {
  49310. import { Observable } from "babylonjs/Misc/observable";
  49311. import { Nullable } from "babylonjs/types";
  49312. import { Scene } from "babylonjs/scene";
  49313. import { Engine } from "babylonjs/Engines/engine";
  49314. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  49315. import { AnimationGroup } from "babylonjs/Animations/animationGroup";
  49316. import { AssetContainer } from "babylonjs/assetContainer";
  49317. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  49318. import { Skeleton } from "babylonjs/Bones/skeleton";
  49319. import { IFileRequest } from "babylonjs/Misc/fileRequest";
  49320. import { WebRequest } from "babylonjs/Misc/webRequest";
  49321. /**
  49322. * Interface used to represent data loading progression
  49323. */
  49324. export interface ISceneLoaderProgressEvent {
  49325. /**
  49326. * Defines if data length to load can be evaluated
  49327. */
  49328. readonly lengthComputable: boolean;
  49329. /**
  49330. * Defines the loaded data length
  49331. */
  49332. readonly loaded: number;
  49333. /**
  49334. * Defines the data length to load
  49335. */
  49336. readonly total: number;
  49337. }
  49338. /**
  49339. * Interface used by SceneLoader plugins to define supported file extensions
  49340. */
  49341. export interface ISceneLoaderPluginExtensions {
  49342. /**
  49343. * Defines the list of supported extensions
  49344. */
  49345. [extension: string]: {
  49346. isBinary: boolean;
  49347. };
  49348. }
  49349. /**
  49350. * Interface used by SceneLoader plugin factory
  49351. */
  49352. export interface ISceneLoaderPluginFactory {
  49353. /**
  49354. * Defines the name of the factory
  49355. */
  49356. name: string;
  49357. /**
  49358. * Function called to create a new plugin
  49359. * @return the new plugin
  49360. */
  49361. createPlugin(): ISceneLoaderPlugin | ISceneLoaderPluginAsync;
  49362. /**
  49363. * The callback that returns true if the data can be directly loaded.
  49364. * @param data string containing the file data
  49365. * @returns if the data can be loaded directly
  49366. */
  49367. canDirectLoad?(data: string): boolean;
  49368. }
  49369. /**
  49370. * Interface used to define the base of ISceneLoaderPlugin and ISceneLoaderPluginAsync
  49371. */
  49372. export interface ISceneLoaderPluginBase {
  49373. /**
  49374. * The friendly name of this plugin.
  49375. */
  49376. name: string;
  49377. /**
  49378. * The file extensions supported by this plugin.
  49379. */
  49380. extensions: string | ISceneLoaderPluginExtensions;
  49381. /**
  49382. * The callback called when loading from a url.
  49383. * @param scene scene loading this url
  49384. * @param url url to load
  49385. * @param onSuccess callback called when the file successfully loads
  49386. * @param onProgress callback called while file is loading (if the server supports this mode)
  49387. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  49388. * @param onError callback called when the file fails to load
  49389. * @returns a file request object
  49390. */
  49391. requestFile?(scene: Scene, url: string, onSuccess: (data: any, request?: WebRequest) => void, onProgress?: (ev: ISceneLoaderProgressEvent) => void, useArrayBuffer?: boolean, onError?: (error: any) => void): IFileRequest;
  49392. /**
  49393. * The callback called when loading from a file object.
  49394. * @param scene scene loading this file
  49395. * @param file defines the file to load
  49396. * @param onSuccess defines the callback to call when data is loaded
  49397. * @param onProgress defines the callback to call during loading process
  49398. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  49399. * @param onError defines the callback to call when an error occurs
  49400. * @returns a file request object
  49401. */
  49402. readFile?(scene: Scene, file: File, onSuccess: (data: any) => void, onProgress?: (ev: ISceneLoaderProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: any) => void): IFileRequest;
  49403. /**
  49404. * The callback that returns true if the data can be directly loaded.
  49405. * @param data string containing the file data
  49406. * @returns if the data can be loaded directly
  49407. */
  49408. canDirectLoad?(data: string): boolean;
  49409. /**
  49410. * The callback that returns the data to pass to the plugin if the data can be directly loaded.
  49411. * @param scene scene loading this data
  49412. * @param data string containing the data
  49413. * @returns data to pass to the plugin
  49414. */
  49415. directLoad?(scene: Scene, data: string): any;
  49416. /**
  49417. * The callback that allows custom handling of the root url based on the response url.
  49418. * @param rootUrl the original root url
  49419. * @param responseURL the response url if available
  49420. * @returns the new root url
  49421. */
  49422. rewriteRootURL?(rootUrl: string, responseURL?: string): string;
  49423. }
  49424. /**
  49425. * Interface used to define a SceneLoader plugin
  49426. */
  49427. export interface ISceneLoaderPlugin extends ISceneLoaderPluginBase {
  49428. /**
  49429. * Import meshes into a scene.
  49430. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  49431. * @param scene The scene to import into
  49432. * @param data The data to import
  49433. * @param rootUrl The root url for scene and resources
  49434. * @param meshes The meshes array to import into
  49435. * @param particleSystems The particle systems array to import into
  49436. * @param skeletons The skeletons array to import into
  49437. * @param onError The callback when import fails
  49438. * @returns True if successful or false otherwise
  49439. */
  49440. importMesh(meshesNames: any, scene: Scene, data: any, rootUrl: string, meshes: AbstractMesh[], particleSystems: IParticleSystem[], skeletons: Skeleton[], onError?: (message: string, exception?: any) => void): boolean;
  49441. /**
  49442. * Load into a scene.
  49443. * @param scene The scene to load into
  49444. * @param data The data to import
  49445. * @param rootUrl The root url for scene and resources
  49446. * @param onError The callback when import fails
  49447. * @returns True if successful or false otherwise
  49448. */
  49449. load(scene: Scene, data: any, rootUrl: string, onError?: (message: string, exception?: any) => void): boolean;
  49450. /**
  49451. * Load into an asset container.
  49452. * @param scene The scene to load into
  49453. * @param data The data to import
  49454. * @param rootUrl The root url for scene and resources
  49455. * @param onError The callback when import fails
  49456. * @returns The loaded asset container
  49457. */
  49458. loadAssetContainer(scene: Scene, data: any, rootUrl: string, onError?: (message: string, exception?: any) => void): AssetContainer;
  49459. }
  49460. /**
  49461. * Interface used to define an async SceneLoader plugin
  49462. */
  49463. export interface ISceneLoaderPluginAsync extends ISceneLoaderPluginBase {
  49464. /**
  49465. * Import meshes into a scene.
  49466. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  49467. * @param scene The scene to import into
  49468. * @param data The data to import
  49469. * @param rootUrl The root url for scene and resources
  49470. * @param onProgress The callback when the load progresses
  49471. * @param fileName Defines the name of the file to load
  49472. * @returns The loaded meshes, particle systems, skeletons, and animation groups
  49473. */
  49474. importMeshAsync(meshesNames: any, scene: Scene, data: any, rootUrl: string, onProgress?: (event: ISceneLoaderProgressEvent) => void, fileName?: string): Promise<{
  49475. meshes: AbstractMesh[];
  49476. particleSystems: IParticleSystem[];
  49477. skeletons: Skeleton[];
  49478. animationGroups: AnimationGroup[];
  49479. }>;
  49480. /**
  49481. * Load into a scene.
  49482. * @param scene The scene to load into
  49483. * @param data The data to import
  49484. * @param rootUrl The root url for scene and resources
  49485. * @param onProgress The callback when the load progresses
  49486. * @param fileName Defines the name of the file to load
  49487. * @returns Nothing
  49488. */
  49489. loadAsync(scene: Scene, data: any, rootUrl: string, onProgress?: (event: ISceneLoaderProgressEvent) => void, fileName?: string): Promise<void>;
  49490. /**
  49491. * Load into an asset container.
  49492. * @param scene The scene to load into
  49493. * @param data The data to import
  49494. * @param rootUrl The root url for scene and resources
  49495. * @param onProgress The callback when the load progresses
  49496. * @param fileName Defines the name of the file to load
  49497. * @returns The loaded asset container
  49498. */
  49499. loadAssetContainerAsync(scene: Scene, data: any, rootUrl: string, onProgress?: (event: ISceneLoaderProgressEvent) => void, fileName?: string): Promise<AssetContainer>;
  49500. }
  49501. /**
  49502. * Mode that determines how to handle old animation groups before loading new ones.
  49503. */
  49504. export enum SceneLoaderAnimationGroupLoadingMode {
  49505. /**
  49506. * Reset all old animations to initial state then dispose them.
  49507. */
  49508. Clean = 0,
  49509. /**
  49510. * Stop all old animations.
  49511. */
  49512. Stop = 1,
  49513. /**
  49514. * Restart old animations from first frame.
  49515. */
  49516. Sync = 2,
  49517. /**
  49518. * Old animations remains untouched.
  49519. */
  49520. NoSync = 3
  49521. }
  49522. /**
  49523. * Defines a plugin registered by the SceneLoader
  49524. */
  49525. interface IRegisteredPlugin {
  49526. /**
  49527. * Defines the plugin to use
  49528. */
  49529. plugin: ISceneLoaderPlugin | ISceneLoaderPluginAsync | ISceneLoaderPluginFactory;
  49530. /**
  49531. * Defines if the plugin supports binary data
  49532. */
  49533. isBinary: boolean;
  49534. }
  49535. /**
  49536. * Class used to load scene from various file formats using registered plugins
  49537. * @see https://doc.babylonjs.com/how_to/load_from_any_file_type
  49538. */
  49539. export class SceneLoader {
  49540. /**
  49541. * No logging while loading
  49542. */
  49543. static readonly NO_LOGGING: number;
  49544. /**
  49545. * Minimal logging while loading
  49546. */
  49547. static readonly MINIMAL_LOGGING: number;
  49548. /**
  49549. * Summary logging while loading
  49550. */
  49551. static readonly SUMMARY_LOGGING: number;
  49552. /**
  49553. * Detailled logging while loading
  49554. */
  49555. static readonly DETAILED_LOGGING: number;
  49556. /**
  49557. * Gets or sets a boolean indicating if entire scene must be loaded even if scene contains incremental data
  49558. */
  49559. static get ForceFullSceneLoadingForIncremental(): boolean;
  49560. static set ForceFullSceneLoadingForIncremental(value: boolean);
  49561. /**
  49562. * Gets or sets a boolean indicating if loading screen must be displayed while loading a scene
  49563. */
  49564. static get ShowLoadingScreen(): boolean;
  49565. static set ShowLoadingScreen(value: boolean);
  49566. /**
  49567. * Defines the current logging level (while loading the scene)
  49568. * @ignorenaming
  49569. */
  49570. static get loggingLevel(): number;
  49571. static set loggingLevel(value: number);
  49572. /**
  49573. * Gets or set a boolean indicating if matrix weights must be cleaned upon loading
  49574. */
  49575. static get CleanBoneMatrixWeights(): boolean;
  49576. static set CleanBoneMatrixWeights(value: boolean);
  49577. /**
  49578. * Event raised when a plugin is used to load a scene
  49579. */
  49580. static OnPluginActivatedObservable: Observable<ISceneLoaderPlugin | ISceneLoaderPluginAsync>;
  49581. private static _registeredPlugins;
  49582. private static _showingLoadingScreen;
  49583. /**
  49584. * Gets the default plugin (used to load Babylon files)
  49585. * @returns the .babylon plugin
  49586. */
  49587. static GetDefaultPlugin(): IRegisteredPlugin;
  49588. private static _GetPluginForExtension;
  49589. private static _GetPluginForDirectLoad;
  49590. private static _GetPluginForFilename;
  49591. private static _GetDirectLoad;
  49592. private static _LoadData;
  49593. private static _GetFileInfo;
  49594. /**
  49595. * Gets a plugin that can load the given extension
  49596. * @param extension defines the extension to load
  49597. * @returns a plugin or null if none works
  49598. */
  49599. static GetPluginForExtension(extension: string): ISceneLoaderPlugin | ISceneLoaderPluginAsync | ISceneLoaderPluginFactory;
  49600. /**
  49601. * Gets a boolean indicating that the given extension can be loaded
  49602. * @param extension defines the extension to load
  49603. * @returns true if the extension is supported
  49604. */
  49605. static IsPluginForExtensionAvailable(extension: string): boolean;
  49606. /**
  49607. * Adds a new plugin to the list of registered plugins
  49608. * @param plugin defines the plugin to add
  49609. */
  49610. static RegisterPlugin(plugin: ISceneLoaderPlugin | ISceneLoaderPluginAsync): void;
  49611. /**
  49612. * Import meshes into a scene
  49613. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  49614. * @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)
  49615. * @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)
  49616. * @param scene the instance of BABYLON.Scene to append to
  49617. * @param onSuccess a callback with a list of imported meshes, particleSystems, and skeletons when import succeeds
  49618. * @param onProgress a callback with a progress event for each file being loaded
  49619. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  49620. * @param pluginExtension the extension used to determine the plugin
  49621. * @returns The loaded plugin
  49622. */
  49623. 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>;
  49624. /**
  49625. * Import meshes into a scene
  49626. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  49627. * @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)
  49628. * @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)
  49629. * @param scene the instance of BABYLON.Scene to append to
  49630. * @param onProgress a callback with a progress event for each file being loaded
  49631. * @param pluginExtension the extension used to determine the plugin
  49632. * @returns The loaded list of imported meshes, particle systems, skeletons, and animation groups
  49633. */
  49634. static ImportMeshAsync(meshNames: any, rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onProgress?: Nullable<(event: ISceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<{
  49635. meshes: AbstractMesh[];
  49636. particleSystems: IParticleSystem[];
  49637. skeletons: Skeleton[];
  49638. animationGroups: AnimationGroup[];
  49639. }>;
  49640. /**
  49641. * Load a scene
  49642. * @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)
  49643. * @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)
  49644. * @param engine is the instance of BABYLON.Engine to use to create the scene
  49645. * @param onSuccess a callback with the scene when import succeeds
  49646. * @param onProgress a callback with a progress event for each file being loaded
  49647. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  49648. * @param pluginExtension the extension used to determine the plugin
  49649. * @returns The loaded plugin
  49650. */
  49651. 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>;
  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 onProgress a callback with a progress event for each file being loaded
  49658. * @param pluginExtension the extension used to determine the plugin
  49659. * @returns The loaded scene
  49660. */
  49661. static LoadAsync(rootUrl: string, sceneFilename?: string | File, engine?: Nullable<Engine>, onProgress?: Nullable<(event: ISceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  49662. /**
  49663. * Append a scene
  49664. * @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)
  49665. * @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)
  49666. * @param scene is the instance of BABYLON.Scene to append to
  49667. * @param onSuccess a callback with the scene when import succeeds
  49668. * @param onProgress a callback with a progress event for each file being loaded
  49669. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  49670. * @param pluginExtension the extension used to determine the plugin
  49671. * @returns The loaded plugin
  49672. */
  49673. 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>;
  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 onProgress a callback with a progress event for each file being loaded
  49680. * @param pluginExtension the extension used to determine the plugin
  49681. * @returns The given scene
  49682. */
  49683. static AppendAsync(rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onProgress?: Nullable<(event: ISceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  49684. /**
  49685. * Load a scene into an asset container
  49686. * @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)
  49687. * @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)
  49688. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  49689. * @param onSuccess a callback with the scene when import succeeds
  49690. * @param onProgress a callback with a progress event for each file being loaded
  49691. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  49692. * @param pluginExtension the extension used to determine the plugin
  49693. * @returns The loaded plugin
  49694. */
  49695. 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>;
  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 (default: empty string)
  49700. * @param scene is the instance of Scene to append to
  49701. * @param onProgress a callback with a progress event for each file being loaded
  49702. * @param pluginExtension the extension used to determine the plugin
  49703. * @returns The loaded asset container
  49704. */
  49705. static LoadAssetContainerAsync(rootUrl: string, sceneFilename?: string, scene?: Nullable<Scene>, onProgress?: Nullable<(event: ISceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<AssetContainer>;
  49706. /**
  49707. * Import animations from a file into a scene
  49708. * @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)
  49709. * @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)
  49710. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  49711. * @param overwriteAnimations when true, animations are cleaned before importing new ones. Animations are appended otherwise
  49712. * @param animationGroupLoadingMode defines how to handle old animations groups before importing new ones
  49713. * @param targetConverter defines a function used to convert animation targets from loaded scene to current scene (default: search node by name)
  49714. * @param onSuccess a callback with the scene when import succeeds
  49715. * @param onProgress a callback with a progress event for each file being loaded
  49716. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  49717. * @param pluginExtension the extension used to determine the plugin
  49718. */
  49719. 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;
  49720. /**
  49721. * Import animations from a file into a scene
  49722. * @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)
  49723. * @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)
  49724. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  49725. * @param overwriteAnimations when true, animations are cleaned before importing new ones. Animations are appended otherwise
  49726. * @param animationGroupLoadingMode defines how to handle old animations groups before importing new ones
  49727. * @param targetConverter defines a function used to convert animation targets from loaded scene to current scene (default: search node by name)
  49728. * @param onSuccess a callback with the scene when import succeeds
  49729. * @param onProgress a callback with a progress event for each file being loaded
  49730. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  49731. * @param pluginExtension the extension used to determine the plugin
  49732. * @returns the updated scene with imported animations
  49733. */
  49734. 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>;
  49735. }
  49736. }
  49737. declare module "babylonjs/XR/motionController/webXRAbstractMotionController" {
  49738. import { IDisposable, Scene } from "babylonjs/scene";
  49739. import { WebXRControllerComponent } from "babylonjs/XR/motionController/webXRControllerComponent";
  49740. import { Observable } from "babylonjs/Misc/observable";
  49741. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  49742. import { Nullable } from "babylonjs/types";
  49743. /**
  49744. * Handedness type in xrInput profiles. These can be used to define layouts in the Layout Map.
  49745. */
  49746. export type MotionControllerHandedness = "none" | "left" | "right";
  49747. /**
  49748. * The type of components available in motion controllers.
  49749. * This is not the name of the component.
  49750. */
  49751. export type MotionControllerComponentType = "trigger" | "squeeze" | "touchpad" | "thumbstick" | "button";
  49752. /**
  49753. * The state of a controller component
  49754. */
  49755. export type MotionControllerComponentStateType = "default" | "touched" | "pressed";
  49756. /**
  49757. * The schema of motion controller layout.
  49758. * No object will be initialized using this interface
  49759. * This is used just to define the profile.
  49760. */
  49761. export interface IMotionControllerLayout {
  49762. /**
  49763. * Path to load the assets. Usually relative to the base path
  49764. */
  49765. assetPath: string;
  49766. /**
  49767. * Available components (unsorted)
  49768. */
  49769. components: {
  49770. /**
  49771. * A map of component Ids
  49772. */
  49773. [componentId: string]: {
  49774. /**
  49775. * The type of input the component outputs
  49776. */
  49777. type: MotionControllerComponentType;
  49778. /**
  49779. * The indices of this component in the gamepad object
  49780. */
  49781. gamepadIndices: {
  49782. /**
  49783. * Index of button
  49784. */
  49785. button?: number;
  49786. /**
  49787. * If available, index of x-axis
  49788. */
  49789. xAxis?: number;
  49790. /**
  49791. * If available, index of y-axis
  49792. */
  49793. yAxis?: number;
  49794. };
  49795. /**
  49796. * The mesh's root node name
  49797. */
  49798. rootNodeName: string;
  49799. /**
  49800. * Animation definitions for this model
  49801. */
  49802. visualResponses: {
  49803. [stateKey: string]: {
  49804. /**
  49805. * What property will be animated
  49806. */
  49807. componentProperty: "xAxis" | "yAxis" | "button" | "state";
  49808. /**
  49809. * What states influence this visual response
  49810. */
  49811. states: MotionControllerComponentStateType[];
  49812. /**
  49813. * Type of animation - movement or visibility
  49814. */
  49815. valueNodeProperty: "transform" | "visibility";
  49816. /**
  49817. * Base node name to move. Its position will be calculated according to the min and max nodes
  49818. */
  49819. valueNodeName?: string;
  49820. /**
  49821. * Minimum movement node
  49822. */
  49823. minNodeName?: string;
  49824. /**
  49825. * Max movement node
  49826. */
  49827. maxNodeName?: string;
  49828. };
  49829. };
  49830. /**
  49831. * If touch enabled, what is the name of node to display user feedback
  49832. */
  49833. touchPointNodeName?: string;
  49834. };
  49835. };
  49836. /**
  49837. * Is it xr standard mapping or not
  49838. */
  49839. gamepadMapping: "" | "xr-standard";
  49840. /**
  49841. * Base root node of this entire model
  49842. */
  49843. rootNodeName: string;
  49844. /**
  49845. * Defines the main button component id
  49846. */
  49847. selectComponentId: string;
  49848. }
  49849. /**
  49850. * A definition for the layout map in the input profile
  49851. */
  49852. export interface IMotionControllerLayoutMap {
  49853. /**
  49854. * Layouts with handedness type as a key
  49855. */
  49856. [handedness: string]: IMotionControllerLayout;
  49857. }
  49858. /**
  49859. * The XR Input profile schema
  49860. * Profiles can be found here:
  49861. * https://github.com/immersive-web/webxr-input-profiles/tree/master/packages/registry/profiles
  49862. */
  49863. export interface IMotionControllerProfile {
  49864. /**
  49865. * fallback profiles for this profileId
  49866. */
  49867. fallbackProfileIds: string[];
  49868. /**
  49869. * The layout map, with handedness as key
  49870. */
  49871. layouts: IMotionControllerLayoutMap;
  49872. /**
  49873. * The id of this profile
  49874. * correlates to the profile(s) in the xrInput.profiles array
  49875. */
  49876. profileId: string;
  49877. }
  49878. /**
  49879. * A helper-interface for the 3 meshes needed for controller button animation
  49880. * The meshes are provided to the _lerpButtonTransform function to calculate the current position of the value mesh
  49881. */
  49882. export interface IMotionControllerButtonMeshMap {
  49883. /**
  49884. * the mesh that defines the pressed value mesh position.
  49885. * This is used to find the max-position of this button
  49886. */
  49887. pressedMesh: AbstractMesh;
  49888. /**
  49889. * the mesh that defines the unpressed value mesh position.
  49890. * This is used to find the min (or initial) position of this button
  49891. */
  49892. unpressedMesh: AbstractMesh;
  49893. /**
  49894. * The mesh that will be changed when value changes
  49895. */
  49896. valueMesh: AbstractMesh;
  49897. }
  49898. /**
  49899. * A helper-interface for the 3 meshes needed for controller axis animation.
  49900. * This will be expanded when touchpad animations are fully supported
  49901. * The meshes are provided to the _lerpAxisTransform function to calculate the current position of the value mesh
  49902. */
  49903. export interface IMotionControllerMeshMap {
  49904. /**
  49905. * the mesh that defines the maximum value mesh position.
  49906. */
  49907. maxMesh?: AbstractMesh;
  49908. /**
  49909. * the mesh that defines the minimum value mesh position.
  49910. */
  49911. minMesh?: AbstractMesh;
  49912. /**
  49913. * The mesh that will be changed when axis value changes
  49914. */
  49915. valueMesh?: AbstractMesh;
  49916. }
  49917. /**
  49918. * The elements needed for change-detection of the gamepad objects in motion controllers
  49919. */
  49920. export interface IMinimalMotionControllerObject {
  49921. /**
  49922. * Available axes of this controller
  49923. */
  49924. axes: number[];
  49925. /**
  49926. * An array of available buttons
  49927. */
  49928. buttons: Array<{
  49929. /**
  49930. * Value of the button/trigger
  49931. */
  49932. value: number;
  49933. /**
  49934. * If the button/trigger is currently touched
  49935. */
  49936. touched: boolean;
  49937. /**
  49938. * If the button/trigger is currently pressed
  49939. */
  49940. pressed: boolean;
  49941. }>;
  49942. /**
  49943. * EXPERIMENTAL haptic support.
  49944. */
  49945. hapticActuators?: Array<{
  49946. pulse: (value: number, duration: number) => Promise<boolean>;
  49947. }>;
  49948. }
  49949. /**
  49950. * An Abstract Motion controller
  49951. * This class receives an xrInput and a profile layout and uses those to initialize the components
  49952. * Each component has an observable to check for changes in value and state
  49953. */
  49954. export abstract class WebXRAbstractMotionController implements IDisposable {
  49955. protected scene: Scene;
  49956. protected layout: IMotionControllerLayout;
  49957. /**
  49958. * The gamepad object correlating to this controller
  49959. */
  49960. gamepadObject: IMinimalMotionControllerObject;
  49961. /**
  49962. * handedness (left/right/none) of this controller
  49963. */
  49964. handedness: MotionControllerHandedness;
  49965. private _initComponent;
  49966. private _modelReady;
  49967. /**
  49968. * A map of components (WebXRControllerComponent) in this motion controller
  49969. * Components have a ComponentType and can also have both button and axis definitions
  49970. */
  49971. readonly components: {
  49972. [id: string]: WebXRControllerComponent;
  49973. };
  49974. /**
  49975. * Disable the model's animation. Can be set at any time.
  49976. */
  49977. disableAnimation: boolean;
  49978. /**
  49979. * Observers registered here will be triggered when the model of this controller is done loading
  49980. */
  49981. onModelLoadedObservable: Observable<WebXRAbstractMotionController>;
  49982. /**
  49983. * The profile id of this motion controller
  49984. */
  49985. abstract profileId: string;
  49986. /**
  49987. * The root mesh of the model. It is null if the model was not yet initialized
  49988. */
  49989. rootMesh: Nullable<AbstractMesh>;
  49990. /**
  49991. * constructs a new abstract motion controller
  49992. * @param scene the scene to which the model of the controller will be added
  49993. * @param layout The profile layout to load
  49994. * @param gamepadObject The gamepad object correlating to this controller
  49995. * @param handedness handedness (left/right/none) of this controller
  49996. * @param _doNotLoadControllerMesh set this flag to ignore the mesh loading
  49997. */
  49998. constructor(scene: Scene, layout: IMotionControllerLayout,
  49999. /**
  50000. * The gamepad object correlating to this controller
  50001. */
  50002. gamepadObject: IMinimalMotionControllerObject,
  50003. /**
  50004. * handedness (left/right/none) of this controller
  50005. */
  50006. handedness: MotionControllerHandedness, _doNotLoadControllerMesh?: boolean);
  50007. /**
  50008. * Dispose this controller, the model mesh and all its components
  50009. */
  50010. dispose(): void;
  50011. /**
  50012. * Returns all components of specific type
  50013. * @param type the type to search for
  50014. * @return an array of components with this type
  50015. */
  50016. getAllComponentsOfType(type: MotionControllerComponentType): WebXRControllerComponent[];
  50017. /**
  50018. * get a component based an its component id as defined in layout.components
  50019. * @param id the id of the component
  50020. * @returns the component correlates to the id or undefined if not found
  50021. */
  50022. getComponent(id: string): WebXRControllerComponent;
  50023. /**
  50024. * Get the list of components available in this motion controller
  50025. * @returns an array of strings correlating to available components
  50026. */
  50027. getComponentIds(): string[];
  50028. /**
  50029. * Get the first component of specific type
  50030. * @param type type of component to find
  50031. * @return a controller component or null if not found
  50032. */
  50033. getComponentOfType(type: MotionControllerComponentType): Nullable<WebXRControllerComponent>;
  50034. /**
  50035. * Get the main (Select) component of this controller as defined in the layout
  50036. * @returns the main component of this controller
  50037. */
  50038. getMainComponent(): WebXRControllerComponent;
  50039. /**
  50040. * Loads the model correlating to this controller
  50041. * When the mesh is loaded, the onModelLoadedObservable will be triggered
  50042. * @returns A promise fulfilled with the result of the model loading
  50043. */
  50044. loadModel(): Promise<boolean>;
  50045. /**
  50046. * Update this model using the current XRFrame
  50047. * @param xrFrame the current xr frame to use and update the model
  50048. */
  50049. updateFromXRFrame(xrFrame: XRFrame): void;
  50050. /**
  50051. * Backwards compatibility due to a deeply-integrated typo
  50052. */
  50053. get handness(): XREye;
  50054. /**
  50055. * Pulse (vibrate) this controller
  50056. * If the controller does not support pulses, this function will fail silently and return Promise<false> directly after called
  50057. * Consecutive calls to this function will cancel the last pulse call
  50058. *
  50059. * @param value the strength of the pulse in 0.0...1.0 range
  50060. * @param duration Duration of the pulse in milliseconds
  50061. * @param hapticActuatorIndex optional index of actuator (will usually be 0)
  50062. * @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
  50063. */
  50064. pulse(value: number, duration: number, hapticActuatorIndex?: number): Promise<boolean>;
  50065. protected _getChildByName(node: AbstractMesh, name: string): AbstractMesh | undefined;
  50066. protected _getImmediateChildByName(node: AbstractMesh, name: string): AbstractMesh | undefined;
  50067. /**
  50068. * Moves the axis on the controller mesh based on its current state
  50069. * @param axis the index of the axis
  50070. * @param axisValue the value of the axis which determines the meshes new position
  50071. * @hidden
  50072. */
  50073. protected _lerpTransform(axisMap: IMotionControllerMeshMap, axisValue: number, fixValueCoordinates?: boolean): void;
  50074. /**
  50075. * Update the model itself with the current frame data
  50076. * @param xrFrame the frame to use for updating the model mesh
  50077. */
  50078. protected updateModel(xrFrame: XRFrame): void;
  50079. /**
  50080. * Get the filename and path for this controller's model
  50081. * @returns a map of filename and path
  50082. */
  50083. protected abstract _getFilenameAndPath(): {
  50084. filename: string;
  50085. path: string;
  50086. };
  50087. /**
  50088. * This function is called before the mesh is loaded. It checks for loading constraints.
  50089. * For example, this function can check if the GLB loader is available
  50090. * If this function returns false, the generic controller will be loaded instead
  50091. * @returns Is the client ready to load the mesh
  50092. */
  50093. protected abstract _getModelLoadingConstraints(): boolean;
  50094. /**
  50095. * This function will be called after the model was successfully loaded and can be used
  50096. * for mesh transformations before it is available for the user
  50097. * @param meshes the loaded meshes
  50098. */
  50099. protected abstract _processLoadedModel(meshes: AbstractMesh[]): void;
  50100. /**
  50101. * Set the root mesh for this controller. Important for the WebXR controller class
  50102. * @param meshes the loaded meshes
  50103. */
  50104. protected abstract _setRootMesh(meshes: AbstractMesh[]): void;
  50105. /**
  50106. * A function executed each frame that updates the mesh (if needed)
  50107. * @param xrFrame the current xrFrame
  50108. */
  50109. protected abstract _updateModel(xrFrame: XRFrame): void;
  50110. private _getGenericFilenameAndPath;
  50111. private _getGenericParentMesh;
  50112. }
  50113. }
  50114. declare module "babylonjs/XR/motionController/webXRGenericMotionController" {
  50115. import { WebXRAbstractMotionController, IMinimalMotionControllerObject, MotionControllerHandedness } from "babylonjs/XR/motionController/webXRAbstractMotionController";
  50116. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  50117. import { Scene } from "babylonjs/scene";
  50118. /**
  50119. * A generic trigger-only motion controller for WebXR
  50120. */
  50121. export class WebXRGenericTriggerMotionController extends WebXRAbstractMotionController {
  50122. /**
  50123. * Static version of the profile id of this controller
  50124. */
  50125. static ProfileId: string;
  50126. profileId: string;
  50127. constructor(scene: Scene, gamepadObject: IMinimalMotionControllerObject, handedness: MotionControllerHandedness);
  50128. protected _getFilenameAndPath(): {
  50129. filename: string;
  50130. path: string;
  50131. };
  50132. protected _getModelLoadingConstraints(): boolean;
  50133. protected _processLoadedModel(meshes: AbstractMesh[]): void;
  50134. protected _setRootMesh(meshes: AbstractMesh[]): void;
  50135. protected _updateModel(): void;
  50136. }
  50137. }
  50138. declare module "babylonjs/Meshes/Builders/sphereBuilder" {
  50139. import { Vector4 } from "babylonjs/Maths/math.vector";
  50140. import { Mesh } from "babylonjs/Meshes/mesh";
  50141. import { Scene } from "babylonjs/scene";
  50142. import { Nullable } from "babylonjs/types";
  50143. /**
  50144. * Class containing static functions to help procedurally build meshes
  50145. */
  50146. export class SphereBuilder {
  50147. /**
  50148. * Creates a sphere mesh
  50149. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  50150. * * 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`)
  50151. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  50152. * * 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
  50153. * * 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)
  50154. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  50155. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  50156. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  50157. * @param name defines the name of the mesh
  50158. * @param options defines the options used to create the mesh
  50159. * @param scene defines the hosting scene
  50160. * @returns the sphere mesh
  50161. * @see https://doc.babylonjs.com/how_to/set_shapes#sphere
  50162. */
  50163. static CreateSphere(name: string, options: {
  50164. segments?: number;
  50165. diameter?: number;
  50166. diameterX?: number;
  50167. diameterY?: number;
  50168. diameterZ?: number;
  50169. arc?: number;
  50170. slice?: number;
  50171. sideOrientation?: number;
  50172. frontUVs?: Vector4;
  50173. backUVs?: Vector4;
  50174. updatable?: boolean;
  50175. }, scene?: Nullable<Scene>): Mesh;
  50176. }
  50177. }
  50178. declare module "babylonjs/XR/motionController/webXRProfiledMotionController" {
  50179. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  50180. import { WebXRAbstractMotionController, IMotionControllerProfile } from "babylonjs/XR/motionController/webXRAbstractMotionController";
  50181. import { Scene } from "babylonjs/scene";
  50182. /**
  50183. * A profiled motion controller has its profile loaded from an online repository.
  50184. * The class is responsible of loading the model, mapping the keys and enabling model-animations
  50185. */
  50186. export class WebXRProfiledMotionController extends WebXRAbstractMotionController {
  50187. private _repositoryUrl;
  50188. private _buttonMeshMapping;
  50189. private _touchDots;
  50190. /**
  50191. * The profile ID of this controller. Will be populated when the controller initializes.
  50192. */
  50193. profileId: string;
  50194. constructor(scene: Scene, xrInput: XRInputSource, _profile: IMotionControllerProfile, _repositoryUrl: string);
  50195. dispose(): void;
  50196. protected _getFilenameAndPath(): {
  50197. filename: string;
  50198. path: string;
  50199. };
  50200. protected _getModelLoadingConstraints(): boolean;
  50201. protected _processLoadedModel(_meshes: AbstractMesh[]): void;
  50202. protected _setRootMesh(meshes: AbstractMesh[]): void;
  50203. protected _updateModel(_xrFrame: XRFrame): void;
  50204. }
  50205. }
  50206. declare module "babylonjs/XR/motionController/webXRMotionControllerManager" {
  50207. import { WebXRAbstractMotionController } from "babylonjs/XR/motionController/webXRAbstractMotionController";
  50208. import { Scene } from "babylonjs/scene";
  50209. /**
  50210. * A construction function type to create a new controller based on an xrInput object
  50211. */
  50212. export type MotionControllerConstructor = (xrInput: XRInputSource, scene: Scene) => WebXRAbstractMotionController;
  50213. /**
  50214. * The MotionController Manager manages all registered motion controllers and loads the right one when needed.
  50215. *
  50216. * When this repository is complete: https://github.com/immersive-web/webxr-input-profiles/tree/master/packages/assets
  50217. * it should be replaced with auto-loaded controllers.
  50218. *
  50219. * When using a model try to stay as generic as possible. Eventually there will be no need in any of the controller classes
  50220. */
  50221. export class WebXRMotionControllerManager {
  50222. private static _AvailableControllers;
  50223. private static _Fallbacks;
  50224. private static _ProfileLoadingPromises;
  50225. private static _ProfilesList;
  50226. /**
  50227. * The base URL of the online controller repository. Can be changed at any time.
  50228. */
  50229. static BaseRepositoryUrl: string;
  50230. /**
  50231. * Which repository gets priority - local or online
  50232. */
  50233. static PrioritizeOnlineRepository: boolean;
  50234. /**
  50235. * Use the online repository, or use only locally-defined controllers
  50236. */
  50237. static UseOnlineRepository: boolean;
  50238. /**
  50239. * Clear the cache used for profile loading and reload when requested again
  50240. */
  50241. static ClearProfilesCache(): void;
  50242. /**
  50243. * Register the default fallbacks.
  50244. * This function is called automatically when this file is imported.
  50245. */
  50246. static DefaultFallbacks(): void;
  50247. /**
  50248. * Find a fallback profile if the profile was not found. There are a few predefined generic profiles.
  50249. * @param profileId the profile to which a fallback needs to be found
  50250. * @return an array with corresponding fallback profiles
  50251. */
  50252. static FindFallbackWithProfileId(profileId: string): string[];
  50253. /**
  50254. * When acquiring a new xrInput object (usually by the WebXRInput class), match it with the correct profile.
  50255. * The order of search:
  50256. *
  50257. * 1) Iterate the profiles array of the xr input and try finding a corresponding motion controller
  50258. * 2) (If not found) search in the gamepad id and try using it (legacy versions only)
  50259. * 3) search for registered fallbacks (should be redundant, nonetheless it makes sense to check)
  50260. * 4) return the generic trigger controller if none were found
  50261. *
  50262. * @param xrInput the xrInput to which a new controller is initialized
  50263. * @param scene the scene to which the model will be added
  50264. * @param forceProfile force a certain profile for this controller
  50265. * @return A promise that fulfils with the motion controller class for this profile id or the generic standard class if none was found
  50266. */
  50267. static GetMotionControllerWithXRInput(xrInput: XRInputSource, scene: Scene, forceProfile?: string): Promise<WebXRAbstractMotionController>;
  50268. /**
  50269. * Register a new controller based on its profile. This function will be called by the controller classes themselves.
  50270. *
  50271. * If you are missing a profile, make sure it is imported in your source, otherwise it will not register.
  50272. *
  50273. * @param type the profile type to register
  50274. * @param constructFunction the function to be called when loading this profile
  50275. */
  50276. static RegisterController(type: string, constructFunction: MotionControllerConstructor): void;
  50277. /**
  50278. * Register a fallback to a specific profile.
  50279. * @param profileId the profileId that will receive the fallbacks
  50280. * @param fallbacks A list of fallback profiles
  50281. */
  50282. static RegisterFallbacksForProfileId(profileId: string, fallbacks: string[]): void;
  50283. /**
  50284. * Will update the list of profiles available in the repository
  50285. * @return a promise that resolves to a map of profiles available online
  50286. */
  50287. static UpdateProfilesList(): Promise<{
  50288. [profile: string]: string;
  50289. }>;
  50290. private static _LoadProfileFromRepository;
  50291. private static _LoadProfilesFromAvailableControllers;
  50292. }
  50293. }
  50294. declare module "babylonjs/XR/webXRInputSource" {
  50295. import { Observable } from "babylonjs/Misc/observable";
  50296. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  50297. import { Ray } from "babylonjs/Culling/ray";
  50298. import { Scene } from "babylonjs/scene";
  50299. import { WebXRAbstractMotionController } from "babylonjs/XR/motionController/webXRAbstractMotionController";
  50300. /**
  50301. * Configuration options for the WebXR controller creation
  50302. */
  50303. export interface IWebXRControllerOptions {
  50304. /**
  50305. * Should the controller mesh be animated when a user interacts with it
  50306. * The pressed buttons / thumbstick and touchpad animations will be disabled
  50307. */
  50308. disableMotionControllerAnimation?: boolean;
  50309. /**
  50310. * Do not load the controller mesh, in case a different mesh needs to be loaded.
  50311. */
  50312. doNotLoadControllerMesh?: boolean;
  50313. /**
  50314. * Force a specific controller type for this controller.
  50315. * This can be used when creating your own profile or when testing different controllers
  50316. */
  50317. forceControllerProfile?: string;
  50318. /**
  50319. * Defines a rendering group ID for meshes that will be loaded.
  50320. * This is for the default controllers only.
  50321. */
  50322. renderingGroupId?: number;
  50323. }
  50324. /**
  50325. * Represents an XR controller
  50326. */
  50327. export class WebXRInputSource {
  50328. private _scene;
  50329. /** The underlying input source for the controller */
  50330. inputSource: XRInputSource;
  50331. private _options;
  50332. private _tmpVector;
  50333. private _uniqueId;
  50334. private _disposed;
  50335. /**
  50336. * 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
  50337. */
  50338. grip?: AbstractMesh;
  50339. /**
  50340. * If available, this is the gamepad object related to this controller.
  50341. * Using this object it is possible to get click events and trackpad changes of the
  50342. * webxr controller that is currently being used.
  50343. */
  50344. motionController?: WebXRAbstractMotionController;
  50345. /**
  50346. * Event that fires when the controller is removed/disposed.
  50347. * The object provided as event data is this controller, after associated assets were disposed.
  50348. * uniqueId is still available.
  50349. */
  50350. onDisposeObservable: Observable<WebXRInputSource>;
  50351. /**
  50352. * Will be triggered when the mesh associated with the motion controller is done loading.
  50353. * It is also possible that this will never trigger (!) if no mesh was loaded, or if the developer decides to load a different mesh
  50354. * A shortened version of controller -> motion controller -> on mesh loaded.
  50355. */
  50356. onMeshLoadedObservable: Observable<AbstractMesh>;
  50357. /**
  50358. * Observers registered here will trigger when a motion controller profile was assigned to this xr controller
  50359. */
  50360. onMotionControllerInitObservable: Observable<WebXRAbstractMotionController>;
  50361. /**
  50362. * Pointer which can be used to select objects or attach a visible laser to
  50363. */
  50364. pointer: AbstractMesh;
  50365. /**
  50366. * Creates the input source object
  50367. * @see https://doc.babylonjs.com/how_to/webxr_controllers_support
  50368. * @param _scene the scene which the controller should be associated to
  50369. * @param inputSource the underlying input source for the controller
  50370. * @param _options options for this controller creation
  50371. */
  50372. constructor(_scene: Scene,
  50373. /** The underlying input source for the controller */
  50374. inputSource: XRInputSource, _options?: IWebXRControllerOptions);
  50375. /**
  50376. * Get this controllers unique id
  50377. */
  50378. get uniqueId(): string;
  50379. /**
  50380. * Disposes of the object
  50381. */
  50382. dispose(): void;
  50383. /**
  50384. * Gets a world space ray coming from the pointer or grip
  50385. * @param result the resulting ray
  50386. * @param gripIfAvailable use the grip mesh instead of the pointer, if available
  50387. */
  50388. getWorldPointerRayToRef(result: Ray, gripIfAvailable?: boolean): void;
  50389. /**
  50390. * Updates the controller pose based on the given XRFrame
  50391. * @param xrFrame xr frame to update the pose with
  50392. * @param referenceSpace reference space to use
  50393. */
  50394. updateFromXRFrame(xrFrame: XRFrame, referenceSpace: XRReferenceSpace): void;
  50395. }
  50396. }
  50397. declare module "babylonjs/XR/webXRInput" {
  50398. import { Observable } from "babylonjs/Misc/observable";
  50399. import { IDisposable } from "babylonjs/scene";
  50400. import { WebXRInputSource, IWebXRControllerOptions } from "babylonjs/XR/webXRInputSource";
  50401. import { WebXRSessionManager } from "babylonjs/XR/webXRSessionManager";
  50402. import { WebXRCamera } from "babylonjs/XR/webXRCamera";
  50403. /**
  50404. * The schema for initialization options of the XR Input class
  50405. */
  50406. export interface IWebXRInputOptions {
  50407. /**
  50408. * If set to true no model will be automatically loaded
  50409. */
  50410. doNotLoadControllerMeshes?: boolean;
  50411. /**
  50412. * If set, this profile will be used for all controllers loaded (for example "microsoft-mixed-reality")
  50413. * If not found, the xr input profile data will be used.
  50414. * Profiles are defined here - https://github.com/immersive-web/webxr-input-profiles/
  50415. */
  50416. forceInputProfile?: string;
  50417. /**
  50418. * Do not send a request to the controller repository to load the profile.
  50419. *
  50420. * Instead, use the controllers available in babylon itself.
  50421. */
  50422. disableOnlineControllerRepository?: boolean;
  50423. /**
  50424. * A custom URL for the controllers repository
  50425. */
  50426. customControllersRepositoryURL?: string;
  50427. /**
  50428. * Should the controller model's components not move according to the user input
  50429. */
  50430. disableControllerAnimation?: boolean;
  50431. /**
  50432. * Optional options to pass to the controller. Will be overridden by the Input options where applicable
  50433. */
  50434. controllerOptions?: IWebXRControllerOptions;
  50435. }
  50436. /**
  50437. * XR input used to track XR inputs such as controllers/rays
  50438. */
  50439. export class WebXRInput implements IDisposable {
  50440. /**
  50441. * the xr session manager for this session
  50442. */
  50443. xrSessionManager: WebXRSessionManager;
  50444. /**
  50445. * the WebXR camera for this session. Mainly used for teleportation
  50446. */
  50447. xrCamera: WebXRCamera;
  50448. private readonly options;
  50449. /**
  50450. * XR controllers being tracked
  50451. */
  50452. controllers: Array<WebXRInputSource>;
  50453. private _frameObserver;
  50454. private _sessionEndedObserver;
  50455. private _sessionInitObserver;
  50456. /**
  50457. * Event when a controller has been connected/added
  50458. */
  50459. onControllerAddedObservable: Observable<WebXRInputSource>;
  50460. /**
  50461. * Event when a controller has been removed/disconnected
  50462. */
  50463. onControllerRemovedObservable: Observable<WebXRInputSource>;
  50464. /**
  50465. * Initializes the WebXRInput
  50466. * @param xrSessionManager the xr session manager for this session
  50467. * @param xrCamera the WebXR camera for this session. Mainly used for teleportation
  50468. * @param options = initialization options for this xr input
  50469. */
  50470. constructor(
  50471. /**
  50472. * the xr session manager for this session
  50473. */
  50474. xrSessionManager: WebXRSessionManager,
  50475. /**
  50476. * the WebXR camera for this session. Mainly used for teleportation
  50477. */
  50478. xrCamera: WebXRCamera, options?: IWebXRInputOptions);
  50479. private _onInputSourcesChange;
  50480. private _addAndRemoveControllers;
  50481. /**
  50482. * Disposes of the object
  50483. */
  50484. dispose(): void;
  50485. }
  50486. }
  50487. declare module "babylonjs/XR/features/WebXRAbstractFeature" {
  50488. import { IWebXRFeature } from "babylonjs/XR/webXRFeaturesManager";
  50489. import { Observable, EventState } from "babylonjs/Misc/observable";
  50490. import { WebXRSessionManager } from "babylonjs/XR/webXRSessionManager";
  50491. /**
  50492. * This is the base class for all WebXR features.
  50493. * Since most features require almost the same resources and callbacks, this class can be used to simplify the development
  50494. * Note that since the features manager is using the `IWebXRFeature` you are in no way obligated to use this class
  50495. */
  50496. export abstract class WebXRAbstractFeature implements IWebXRFeature {
  50497. protected _xrSessionManager: WebXRSessionManager;
  50498. private _attached;
  50499. private _removeOnDetach;
  50500. /**
  50501. * Should auto-attach be disabled?
  50502. */
  50503. disableAutoAttach: boolean;
  50504. /**
  50505. * The name of the native xr feature name (like anchor, hit-test, or hand-tracking)
  50506. */
  50507. xrNativeFeatureName: string;
  50508. /**
  50509. * Construct a new (abstract) WebXR feature
  50510. * @param _xrSessionManager the xr session manager for this feature
  50511. */
  50512. constructor(_xrSessionManager: WebXRSessionManager);
  50513. /**
  50514. * Is this feature attached
  50515. */
  50516. get attached(): boolean;
  50517. /**
  50518. * attach this feature
  50519. *
  50520. * @param force should attachment be forced (even when already attached)
  50521. * @returns true if successful, false is failed or already attached
  50522. */
  50523. attach(force?: boolean): boolean;
  50524. /**
  50525. * detach this feature.
  50526. *
  50527. * @returns true if successful, false if failed or already detached
  50528. */
  50529. detach(): boolean;
  50530. /**
  50531. * Dispose this feature and all of the resources attached
  50532. */
  50533. dispose(): void;
  50534. /**
  50535. * This function will be executed during before enabling the feature and can be used to not-allow enabling it.
  50536. * Note that at this point the session has NOT started, so this is purely checking if the browser supports it
  50537. *
  50538. * @returns whether or not the feature is compatible in this environment
  50539. */
  50540. isCompatible(): boolean;
  50541. /**
  50542. * This is used to register callbacks that will automatically be removed when detach is called.
  50543. * @param observable the observable to which the observer will be attached
  50544. * @param callback the callback to register
  50545. */
  50546. protected _addNewAttachObserver<T>(observable: Observable<T>, callback: (eventData: T, eventState: EventState) => void): void;
  50547. /**
  50548. * Code in this function will be executed on each xrFrame received from the browser.
  50549. * This function will not execute after the feature is detached.
  50550. * @param _xrFrame the current frame
  50551. */
  50552. protected abstract _onXRFrame(_xrFrame: XRFrame): void;
  50553. }
  50554. }
  50555. declare module "babylonjs/Rendering/utilityLayerRenderer" {
  50556. import { IDisposable, Scene } from "babylonjs/scene";
  50557. import { Nullable } from "babylonjs/types";
  50558. import { Observable } from "babylonjs/Misc/observable";
  50559. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  50560. import { HemisphericLight } from "babylonjs/Lights/hemisphericLight";
  50561. import { Camera } from "babylonjs/Cameras/camera";
  50562. /**
  50563. * Renders a layer on top of an existing scene
  50564. */
  50565. export class UtilityLayerRenderer implements IDisposable {
  50566. /** the original scene that will be rendered on top of */
  50567. originalScene: Scene;
  50568. private _pointerCaptures;
  50569. private _lastPointerEvents;
  50570. private static _DefaultUtilityLayer;
  50571. private static _DefaultKeepDepthUtilityLayer;
  50572. private _sharedGizmoLight;
  50573. private _renderCamera;
  50574. /**
  50575. * Gets the camera that is used to render the utility layer (when not set, this will be the last active camera)
  50576. * @param getRigParentIfPossible if the current active camera is a rig camera, should its parent camera be returned
  50577. * @returns the camera that is used when rendering the utility layer
  50578. */
  50579. getRenderCamera(getRigParentIfPossible?: boolean): Camera;
  50580. /**
  50581. * Sets the camera that should be used when rendering the utility layer (If set to null the last active camera will be used)
  50582. * @param cam the camera that should be used when rendering the utility layer
  50583. */
  50584. setRenderCamera(cam: Nullable<Camera>): void;
  50585. /**
  50586. * @hidden
  50587. * Light which used by gizmos to get light shading
  50588. */
  50589. _getSharedGizmoLight(): HemisphericLight;
  50590. /**
  50591. * If the picking should be done on the utility layer prior to the actual scene (Default: true)
  50592. */
  50593. pickUtilitySceneFirst: boolean;
  50594. /**
  50595. * 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)
  50596. */
  50597. static get DefaultUtilityLayer(): UtilityLayerRenderer;
  50598. /**
  50599. * 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)
  50600. */
  50601. static get DefaultKeepDepthUtilityLayer(): UtilityLayerRenderer;
  50602. /**
  50603. * The scene that is rendered on top of the original scene
  50604. */
  50605. utilityLayerScene: Scene;
  50606. /**
  50607. * If the utility layer should automatically be rendered on top of existing scene
  50608. */
  50609. shouldRender: boolean;
  50610. /**
  50611. * If set to true, only pointer down onPointerObservable events will be blocked when picking is occluded by original scene
  50612. */
  50613. onlyCheckPointerDownEvents: boolean;
  50614. /**
  50615. * If set to false, only pointerUp, pointerDown and pointerMove will be sent to the utilityLayerScene (false by default)
  50616. */
  50617. processAllEvents: boolean;
  50618. /**
  50619. * Observable raised when the pointer move from the utility layer scene to the main scene
  50620. */
  50621. onPointerOutObservable: Observable<number>;
  50622. /** Gets or sets a predicate that will be used to indicate utility meshes present in the main scene */
  50623. mainSceneTrackerPredicate: (mesh: Nullable<AbstractMesh>) => boolean;
  50624. private _afterRenderObserver;
  50625. private _sceneDisposeObserver;
  50626. private _originalPointerObserver;
  50627. /**
  50628. * Instantiates a UtilityLayerRenderer
  50629. * @param originalScene the original scene that will be rendered on top of
  50630. * @param handleEvents boolean indicating if the utility layer should handle events
  50631. */
  50632. constructor(
  50633. /** the original scene that will be rendered on top of */
  50634. originalScene: Scene, handleEvents?: boolean);
  50635. private _notifyObservers;
  50636. /**
  50637. * Renders the utility layers scene on top of the original scene
  50638. */
  50639. render(): void;
  50640. /**
  50641. * Disposes of the renderer
  50642. */
  50643. dispose(): void;
  50644. private _updateCamera;
  50645. }
  50646. }
  50647. declare module "babylonjs/XR/features/WebXRControllerPointerSelection" {
  50648. import { WebXRSessionManager } from "babylonjs/XR/webXRSessionManager";
  50649. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  50650. import { WebXRInput } from "babylonjs/XR/webXRInput";
  50651. import { WebXRInputSource } from "babylonjs/XR/webXRInputSource";
  50652. import { Scene } from "babylonjs/scene";
  50653. import { Nullable } from "babylonjs/types";
  50654. import { Color3 } from "babylonjs/Maths/math.color";
  50655. import { WebXRAbstractFeature } from "babylonjs/XR/features/WebXRAbstractFeature";
  50656. import { WebXRCamera } from "babylonjs/XR/webXRCamera";
  50657. /**
  50658. * Options interface for the pointer selection module
  50659. */
  50660. export interface IWebXRControllerPointerSelectionOptions {
  50661. /**
  50662. * if provided, this scene will be used to render meshes.
  50663. */
  50664. customUtilityLayerScene?: Scene;
  50665. /**
  50666. * 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)
  50667. * If not disabled, the last picked point will be used to execute a pointer up event
  50668. * If disabled, pointer up event will be triggered right after the pointer down event.
  50669. * Used in screen and gaze target ray mode only
  50670. */
  50671. disablePointerUpOnTouchOut: boolean;
  50672. /**
  50673. * For gaze mode for tracked-pointer / controllers (time to select instead of button press)
  50674. */
  50675. forceGazeMode: boolean;
  50676. /**
  50677. * 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
  50678. * to start a new countdown to the pointer down event.
  50679. * Defaults to 1.
  50680. */
  50681. gazeModePointerMovedFactor?: number;
  50682. /**
  50683. * Different button type to use instead of the main component
  50684. */
  50685. overrideButtonId?: string;
  50686. /**
  50687. * use this rendering group id for the meshes (optional)
  50688. */
  50689. renderingGroupId?: number;
  50690. /**
  50691. * The amount of time in milliseconds it takes between pick found something to a pointer down event.
  50692. * Used in gaze modes. Tracked pointer uses the trigger, screen uses touch events
  50693. * 3000 means 3 seconds between pointing at something and selecting it
  50694. */
  50695. timeToSelect?: number;
  50696. /**
  50697. * Should meshes created here be added to a utility layer or the main scene
  50698. */
  50699. useUtilityLayer?: boolean;
  50700. /**
  50701. * Optional WebXR camera to be used for gaze selection
  50702. */
  50703. gazeCamera?: WebXRCamera;
  50704. /**
  50705. * the xr input to use with this pointer selection
  50706. */
  50707. xrInput: WebXRInput;
  50708. }
  50709. /**
  50710. * A module that will enable pointer selection for motion controllers of XR Input Sources
  50711. */
  50712. export class WebXRControllerPointerSelection extends WebXRAbstractFeature {
  50713. private readonly _options;
  50714. private static _idCounter;
  50715. private _attachController;
  50716. private _controllers;
  50717. private _scene;
  50718. private _tmpVectorForPickCompare;
  50719. /**
  50720. * The module's name
  50721. */
  50722. static readonly Name: string;
  50723. /**
  50724. * The (Babylon) version of this module.
  50725. * This is an integer representing the implementation version.
  50726. * This number does not correspond to the WebXR specs version
  50727. */
  50728. static readonly Version: number;
  50729. /**
  50730. * Disable lighting on the laser pointer (so it will always be visible)
  50731. */
  50732. disablePointerLighting: boolean;
  50733. /**
  50734. * Disable lighting on the selection mesh (so it will always be visible)
  50735. */
  50736. disableSelectionMeshLighting: boolean;
  50737. /**
  50738. * Should the laser pointer be displayed
  50739. */
  50740. displayLaserPointer: boolean;
  50741. /**
  50742. * Should the selection mesh be displayed (The ring at the end of the laser pointer)
  50743. */
  50744. displaySelectionMesh: boolean;
  50745. /**
  50746. * This color will be set to the laser pointer when selection is triggered
  50747. */
  50748. laserPointerPickedColor: Color3;
  50749. /**
  50750. * Default color of the laser pointer
  50751. */
  50752. laserPointerDefaultColor: Color3;
  50753. /**
  50754. * default color of the selection ring
  50755. */
  50756. selectionMeshDefaultColor: Color3;
  50757. /**
  50758. * This color will be applied to the selection ring when selection is triggered
  50759. */
  50760. selectionMeshPickedColor: Color3;
  50761. /**
  50762. * Optional filter to be used for ray selection. This predicate shares behavior with
  50763. * scene.pointerMovePredicate which takes priority if it is also assigned.
  50764. */
  50765. raySelectionPredicate: (mesh: AbstractMesh) => boolean;
  50766. /**
  50767. * constructs a new background remover module
  50768. * @param _xrSessionManager the session manager for this module
  50769. * @param _options read-only options to be used in this module
  50770. */
  50771. constructor(_xrSessionManager: WebXRSessionManager, _options: IWebXRControllerPointerSelectionOptions);
  50772. /**
  50773. * attach this feature
  50774. * Will usually be called by the features manager
  50775. *
  50776. * @returns true if successful.
  50777. */
  50778. attach(): boolean;
  50779. /**
  50780. * detach this feature.
  50781. * Will usually be called by the features manager
  50782. *
  50783. * @returns true if successful.
  50784. */
  50785. detach(): boolean;
  50786. /**
  50787. * Will get the mesh under a specific pointer.
  50788. * `scene.meshUnderPointer` will only return one mesh - either left or right.
  50789. * @param controllerId the controllerId to check
  50790. * @returns The mesh under pointer or null if no mesh is under the pointer
  50791. */
  50792. getMeshUnderPointer(controllerId: string): Nullable<AbstractMesh>;
  50793. /**
  50794. * Get the xr controller that correlates to the pointer id in the pointer event
  50795. *
  50796. * @param id the pointer id to search for
  50797. * @returns the controller that correlates to this id or null if not found
  50798. */
  50799. getXRControllerByPointerId(id: number): Nullable<WebXRInputSource>;
  50800. protected _onXRFrame(_xrFrame: XRFrame): void;
  50801. private _attachGazeMode;
  50802. private _attachScreenRayMode;
  50803. private _attachTrackedPointerRayMode;
  50804. private _convertNormalToDirectionOfRay;
  50805. private _detachController;
  50806. private _generateNewMeshPair;
  50807. private _pickingMoved;
  50808. private _updatePointerDistance;
  50809. /** @hidden */
  50810. get lasterPointerDefaultColor(): Color3;
  50811. }
  50812. }
  50813. declare module "babylonjs/XR/webXREnterExitUI" {
  50814. import { Nullable } from "babylonjs/types";
  50815. import { Observable } from "babylonjs/Misc/observable";
  50816. import { IDisposable, Scene } from "babylonjs/scene";
  50817. import { WebXRExperienceHelper } from "babylonjs/XR/webXRExperienceHelper";
  50818. import { WebXRRenderTarget } from "babylonjs/XR/webXRTypes";
  50819. /**
  50820. * Button which can be used to enter a different mode of XR
  50821. */
  50822. export class WebXREnterExitUIButton {
  50823. /** button element */
  50824. element: HTMLElement;
  50825. /** XR initialization options for the button */
  50826. sessionMode: XRSessionMode;
  50827. /** Reference space type */
  50828. referenceSpaceType: XRReferenceSpaceType;
  50829. /**
  50830. * Creates a WebXREnterExitUIButton
  50831. * @param element button element
  50832. * @param sessionMode XR initialization session mode
  50833. * @param referenceSpaceType the type of reference space to be used
  50834. */
  50835. constructor(
  50836. /** button element */
  50837. element: HTMLElement,
  50838. /** XR initialization options for the button */
  50839. sessionMode: XRSessionMode,
  50840. /** Reference space type */
  50841. referenceSpaceType: XRReferenceSpaceType);
  50842. /**
  50843. * Extendable function which can be used to update the button's visuals when the state changes
  50844. * @param activeButton the current active button in the UI
  50845. */
  50846. update(activeButton: Nullable<WebXREnterExitUIButton>): void;
  50847. }
  50848. /**
  50849. * Options to create the webXR UI
  50850. */
  50851. export class WebXREnterExitUIOptions {
  50852. /**
  50853. * User provided buttons to enable/disable WebXR. The system will provide default if not set
  50854. */
  50855. customButtons?: Array<WebXREnterExitUIButton>;
  50856. /**
  50857. * A reference space type to use when creating the default button.
  50858. * Default is local-floor
  50859. */
  50860. referenceSpaceType?: XRReferenceSpaceType;
  50861. /**
  50862. * Context to enter xr with
  50863. */
  50864. renderTarget?: Nullable<WebXRRenderTarget>;
  50865. /**
  50866. * A session mode to use when creating the default button.
  50867. * Default is immersive-vr
  50868. */
  50869. sessionMode?: XRSessionMode;
  50870. /**
  50871. * A list of optional features to init the session with
  50872. */
  50873. optionalFeatures?: string[];
  50874. /**
  50875. * A list of optional features to init the session with
  50876. */
  50877. requiredFeatures?: string[];
  50878. }
  50879. /**
  50880. * UI to allow the user to enter/exit XR mode
  50881. */
  50882. export class WebXREnterExitUI implements IDisposable {
  50883. private scene;
  50884. /** version of the options passed to this UI */
  50885. options: WebXREnterExitUIOptions;
  50886. private _activeButton;
  50887. private _buttons;
  50888. /**
  50889. * The HTML Div Element to which buttons are added.
  50890. */
  50891. readonly overlay: HTMLDivElement;
  50892. /**
  50893. * Fired every time the active button is changed.
  50894. *
  50895. * When xr is entered via a button that launches xr that button will be the callback parameter
  50896. *
  50897. * When exiting xr the callback parameter will be null)
  50898. */
  50899. activeButtonChangedObservable: Observable<Nullable<WebXREnterExitUIButton>>;
  50900. /**
  50901. *
  50902. * @param scene babylon scene object to use
  50903. * @param options (read-only) version of the options passed to this UI
  50904. */
  50905. private constructor();
  50906. /**
  50907. * Creates UI to allow the user to enter/exit XR mode
  50908. * @param scene the scene to add the ui to
  50909. * @param helper the xr experience helper to enter/exit xr with
  50910. * @param options options to configure the UI
  50911. * @returns the created ui
  50912. */
  50913. static CreateAsync(scene: Scene, helper: WebXRExperienceHelper, options: WebXREnterExitUIOptions): Promise<WebXREnterExitUI>;
  50914. /**
  50915. * Disposes of the XR UI component
  50916. */
  50917. dispose(): void;
  50918. private _updateButtons;
  50919. }
  50920. }
  50921. declare module "babylonjs/Meshes/Builders/linesBuilder" {
  50922. import { Vector3 } from "babylonjs/Maths/math.vector";
  50923. import { Color4 } from "babylonjs/Maths/math.color";
  50924. import { Nullable } from "babylonjs/types";
  50925. import { LinesMesh } from "babylonjs/Meshes/linesMesh";
  50926. import { Scene } from "babylonjs/scene";
  50927. /**
  50928. * Class containing static functions to help procedurally build meshes
  50929. */
  50930. export class LinesBuilder {
  50931. /**
  50932. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  50933. * * 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
  50934. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  50935. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  50936. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  50937. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  50938. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  50939. * * 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
  50940. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  50941. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  50942. * @see https://doc.babylonjs.com/how_to/parametric_shapes#line-system
  50943. * @param name defines the name of the new line system
  50944. * @param options defines the options used to create the line system
  50945. * @param scene defines the hosting scene
  50946. * @returns a new line system mesh
  50947. */
  50948. static CreateLineSystem(name: string, options: {
  50949. lines: Vector3[][];
  50950. updatable?: boolean;
  50951. instance?: Nullable<LinesMesh>;
  50952. colors?: Nullable<Color4[][]>;
  50953. useVertexAlpha?: boolean;
  50954. }, scene: Nullable<Scene>): LinesMesh;
  50955. /**
  50956. * Creates a line mesh
  50957. * 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
  50958. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  50959. * * The parameter `points` is an array successive Vector3
  50960. * * 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
  50961. * * The optional parameter `colors` is an array of successive Color4, one per line point
  50962. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  50963. * * When updating an instance, remember that only point positions can change, not the number of points
  50964. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  50965. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lines
  50966. * @param name defines the name of the new line system
  50967. * @param options defines the options used to create the line system
  50968. * @param scene defines the hosting scene
  50969. * @returns a new line mesh
  50970. */
  50971. static CreateLines(name: string, options: {
  50972. points: Vector3[];
  50973. updatable?: boolean;
  50974. instance?: Nullable<LinesMesh>;
  50975. colors?: Color4[];
  50976. useVertexAlpha?: boolean;
  50977. }, scene?: Nullable<Scene>): LinesMesh;
  50978. /**
  50979. * Creates a dashed line mesh
  50980. * * 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
  50981. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  50982. * * The parameter `points` is an array successive Vector3
  50983. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  50984. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  50985. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  50986. * * 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
  50987. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  50988. * * When updating an instance, remember that only point positions can change, not the number of points
  50989. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  50990. * @param name defines the name of the mesh
  50991. * @param options defines the options used to create the mesh
  50992. * @param scene defines the hosting scene
  50993. * @returns the dashed line mesh
  50994. * @see https://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  50995. */
  50996. static CreateDashedLines(name: string, options: {
  50997. points: Vector3[];
  50998. dashSize?: number;
  50999. gapSize?: number;
  51000. dashNb?: number;
  51001. updatable?: boolean;
  51002. instance?: LinesMesh;
  51003. useVertexAlpha?: boolean;
  51004. }, scene?: Nullable<Scene>): LinesMesh;
  51005. }
  51006. }
  51007. declare module "babylonjs/Misc/timer" {
  51008. import { Observable, Observer } from "babylonjs/Misc/observable";
  51009. import { Nullable } from "babylonjs/types";
  51010. import { IDisposable } from "babylonjs/scene";
  51011. /**
  51012. * Construction options for a timer
  51013. */
  51014. export interface ITimerOptions<T> {
  51015. /**
  51016. * Time-to-end
  51017. */
  51018. timeout: number;
  51019. /**
  51020. * The context observable is used to calculate time deltas and provides the context of the timer's callbacks. Will usually be OnBeforeRenderObservable.
  51021. * Countdown calculation is done ONLY when the observable is notifying its observers, meaning that if
  51022. * you choose an observable that doesn't trigger too often, the wait time might extend further than the requested max time
  51023. */
  51024. contextObservable: Observable<T>;
  51025. /**
  51026. * Optional parameters when adding an observer to the observable
  51027. */
  51028. observableParameters?: {
  51029. mask?: number;
  51030. insertFirst?: boolean;
  51031. scope?: any;
  51032. };
  51033. /**
  51034. * An optional break condition that will stop the times prematurely. In this case onEnded will not be triggered!
  51035. */
  51036. breakCondition?: (data?: ITimerData<T>) => boolean;
  51037. /**
  51038. * Will be triggered when the time condition has met
  51039. */
  51040. onEnded?: (data: ITimerData<any>) => void;
  51041. /**
  51042. * Will be triggered when the break condition has met (prematurely ended)
  51043. */
  51044. onAborted?: (data: ITimerData<any>) => void;
  51045. /**
  51046. * Optional function to execute on each tick (or count)
  51047. */
  51048. onTick?: (data: ITimerData<any>) => void;
  51049. }
  51050. /**
  51051. * An interface defining the data sent by the timer
  51052. */
  51053. export interface ITimerData<T> {
  51054. /**
  51055. * When did it start
  51056. */
  51057. startTime: number;
  51058. /**
  51059. * Time now
  51060. */
  51061. currentTime: number;
  51062. /**
  51063. * Time passed since started
  51064. */
  51065. deltaTime: number;
  51066. /**
  51067. * How much is completed, in [0.0...1.0].
  51068. * Note that this CAN be higher than 1 due to the fact that we don't actually measure time but delta between observable calls
  51069. */
  51070. completeRate: number;
  51071. /**
  51072. * What the registered observable sent in the last count
  51073. */
  51074. payload: T;
  51075. }
  51076. /**
  51077. * The current state of the timer
  51078. */
  51079. export enum TimerState {
  51080. /**
  51081. * Timer initialized, not yet started
  51082. */
  51083. INIT = 0,
  51084. /**
  51085. * Timer started and counting
  51086. */
  51087. STARTED = 1,
  51088. /**
  51089. * Timer ended (whether aborted or time reached)
  51090. */
  51091. ENDED = 2
  51092. }
  51093. /**
  51094. * A simple version of the timer. Will take options and start the timer immediately after calling it
  51095. *
  51096. * @param options options with which to initialize this timer
  51097. */
  51098. export function setAndStartTimer(options: ITimerOptions<any>): Nullable<Observer<any>>;
  51099. /**
  51100. * An advanced implementation of a timer class
  51101. */
  51102. export class AdvancedTimer<T = any> implements IDisposable {
  51103. /**
  51104. * Will notify each time the timer calculates the remaining time
  51105. */
  51106. onEachCountObservable: Observable<ITimerData<T>>;
  51107. /**
  51108. * Will trigger when the timer was aborted due to the break condition
  51109. */
  51110. onTimerAbortedObservable: Observable<ITimerData<T>>;
  51111. /**
  51112. * Will trigger when the timer ended successfully
  51113. */
  51114. onTimerEndedObservable: Observable<ITimerData<T>>;
  51115. /**
  51116. * Will trigger when the timer state has changed
  51117. */
  51118. onStateChangedObservable: Observable<TimerState>;
  51119. private _observer;
  51120. private _contextObservable;
  51121. private _observableParameters;
  51122. private _startTime;
  51123. private _timer;
  51124. private _state;
  51125. private _breakCondition;
  51126. private _timeToEnd;
  51127. private _breakOnNextTick;
  51128. /**
  51129. * Will construct a new advanced timer based on the options provided. Timer will not start until start() is called.
  51130. * @param options construction options for this advanced timer
  51131. */
  51132. constructor(options: ITimerOptions<T>);
  51133. /**
  51134. * set a breaking condition for this timer. Default is to never break during count
  51135. * @param predicate the new break condition. Returns true to break, false otherwise
  51136. */
  51137. set breakCondition(predicate: (data: ITimerData<T>) => boolean);
  51138. /**
  51139. * Reset ALL associated observables in this advanced timer
  51140. */
  51141. clearObservables(): void;
  51142. /**
  51143. * Will start a new iteration of this timer. Only one instance of this timer can run at a time.
  51144. *
  51145. * @param timeToEnd how much time to measure until timer ended
  51146. */
  51147. start(timeToEnd?: number): void;
  51148. /**
  51149. * Will force a stop on the next tick.
  51150. */
  51151. stop(): void;
  51152. /**
  51153. * Dispose this timer, clearing all resources
  51154. */
  51155. dispose(): void;
  51156. private _setState;
  51157. private _tick;
  51158. private _stop;
  51159. }
  51160. }
  51161. declare module "babylonjs/XR/features/WebXRControllerTeleportation" {
  51162. import { IWebXRFeature } from "babylonjs/XR/webXRFeaturesManager";
  51163. import { WebXRSessionManager } from "babylonjs/XR/webXRSessionManager";
  51164. import { WebXRInput } from "babylonjs/XR/webXRInput";
  51165. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  51166. import { Vector3 } from "babylonjs/Maths/math.vector";
  51167. import { Material } from "babylonjs/Materials/material";
  51168. import { WebXRAbstractFeature } from "babylonjs/XR/features/WebXRAbstractFeature";
  51169. import { Scene } from "babylonjs/scene";
  51170. /**
  51171. * The options container for the teleportation module
  51172. */
  51173. export interface IWebXRTeleportationOptions {
  51174. /**
  51175. * if provided, this scene will be used to render meshes.
  51176. */
  51177. customUtilityLayerScene?: Scene;
  51178. /**
  51179. * Values to configure the default target mesh
  51180. */
  51181. defaultTargetMeshOptions?: {
  51182. /**
  51183. * Fill color of the teleportation area
  51184. */
  51185. teleportationFillColor?: string;
  51186. /**
  51187. * Border color for the teleportation area
  51188. */
  51189. teleportationBorderColor?: string;
  51190. /**
  51191. * Disable the mesh's animation sequence
  51192. */
  51193. disableAnimation?: boolean;
  51194. /**
  51195. * Disable lighting on the material or the ring and arrow
  51196. */
  51197. disableLighting?: boolean;
  51198. /**
  51199. * Override the default material of the torus and arrow
  51200. */
  51201. torusArrowMaterial?: Material;
  51202. };
  51203. /**
  51204. * A list of meshes to use as floor meshes.
  51205. * Meshes can be added and removed after initializing the feature using the
  51206. * addFloorMesh and removeFloorMesh functions
  51207. * If empty, rotation will still work
  51208. */
  51209. floorMeshes?: AbstractMesh[];
  51210. /**
  51211. * use this rendering group id for the meshes (optional)
  51212. */
  51213. renderingGroupId?: number;
  51214. /**
  51215. * Should teleportation move only to snap points
  51216. */
  51217. snapPointsOnly?: boolean;
  51218. /**
  51219. * An array of points to which the teleportation will snap to.
  51220. * If the teleportation ray is in the proximity of one of those points, it will be corrected to this point.
  51221. */
  51222. snapPositions?: Vector3[];
  51223. /**
  51224. * How close should the teleportation ray be in order to snap to position.
  51225. * Default to 0.8 units (meters)
  51226. */
  51227. snapToPositionRadius?: number;
  51228. /**
  51229. * Provide your own teleportation mesh instead of babylon's wonderful doughnut.
  51230. * If you want to support rotation, make sure your mesh has a direction indicator.
  51231. *
  51232. * When left untouched, the default mesh will be initialized.
  51233. */
  51234. teleportationTargetMesh?: AbstractMesh;
  51235. /**
  51236. * If main component is used (no thumbstick), how long should the "long press" take before teleport
  51237. */
  51238. timeToTeleport?: number;
  51239. /**
  51240. * Disable using the thumbstick and use the main component (usually trigger) on long press.
  51241. * This will be automatically true if the controller doesn't have a thumbstick or touchpad.
  51242. */
  51243. useMainComponentOnly?: boolean;
  51244. /**
  51245. * Should meshes created here be added to a utility layer or the main scene
  51246. */
  51247. useUtilityLayer?: boolean;
  51248. /**
  51249. * Babylon XR Input class for controller
  51250. */
  51251. xrInput: WebXRInput;
  51252. /**
  51253. * Meshes that the teleportation ray cannot go through
  51254. */
  51255. pickBlockerMeshes?: AbstractMesh[];
  51256. }
  51257. /**
  51258. * This is a teleportation feature to be used with WebXR-enabled motion controllers.
  51259. * When enabled and attached, the feature will allow a user to move around and rotate in the scene using
  51260. * the input of the attached controllers.
  51261. */
  51262. export class WebXRMotionControllerTeleportation extends WebXRAbstractFeature {
  51263. private _options;
  51264. private _controllers;
  51265. private _currentTeleportationControllerId;
  51266. private _floorMeshes;
  51267. private _quadraticBezierCurve;
  51268. private _selectionFeature;
  51269. private _snapToPositions;
  51270. private _snappedToPoint;
  51271. private _teleportationRingMaterial?;
  51272. private _tmpRay;
  51273. private _tmpVector;
  51274. private _tmpQuaternion;
  51275. /**
  51276. * The module's name
  51277. */
  51278. static readonly Name: string;
  51279. /**
  51280. * The (Babylon) version of this module.
  51281. * This is an integer representing the implementation version.
  51282. * This number does not correspond to the webxr specs version
  51283. */
  51284. static readonly Version: number;
  51285. /**
  51286. * Is movement backwards enabled
  51287. */
  51288. backwardsMovementEnabled: boolean;
  51289. /**
  51290. * Distance to travel when moving backwards
  51291. */
  51292. backwardsTeleportationDistance: number;
  51293. /**
  51294. * The distance from the user to the inspection point in the direction of the controller
  51295. * A higher number will allow the user to move further
  51296. * defaults to 5 (meters, in xr units)
  51297. */
  51298. parabolicCheckRadius: number;
  51299. /**
  51300. * Should the module support parabolic ray on top of direct ray
  51301. * If enabled, the user will be able to point "at the sky" and move according to predefined radius distance
  51302. * Very helpful when moving between floors / different heights
  51303. */
  51304. parabolicRayEnabled: boolean;
  51305. /**
  51306. * How much rotation should be applied when rotating right and left
  51307. */
  51308. rotationAngle: number;
  51309. /**
  51310. * Is rotation enabled when moving forward?
  51311. * Disabling this feature will prevent the user from deciding the direction when teleporting
  51312. */
  51313. rotationEnabled: boolean;
  51314. /**
  51315. * constructs a new anchor system
  51316. * @param _xrSessionManager an instance of WebXRSessionManager
  51317. * @param _options configuration object for this feature
  51318. */
  51319. constructor(_xrSessionManager: WebXRSessionManager, _options: IWebXRTeleportationOptions);
  51320. /**
  51321. * Get the snapPointsOnly flag
  51322. */
  51323. get snapPointsOnly(): boolean;
  51324. /**
  51325. * Sets the snapPointsOnly flag
  51326. * @param snapToPoints should teleportation be exclusively to snap points
  51327. */
  51328. set snapPointsOnly(snapToPoints: boolean);
  51329. /**
  51330. * Add a new mesh to the floor meshes array
  51331. * @param mesh the mesh to use as floor mesh
  51332. */
  51333. addFloorMesh(mesh: AbstractMesh): void;
  51334. /**
  51335. * Add a new snap-to point to fix teleportation to this position
  51336. * @param newSnapPoint The new Snap-To point
  51337. */
  51338. addSnapPoint(newSnapPoint: Vector3): void;
  51339. attach(): boolean;
  51340. detach(): boolean;
  51341. dispose(): void;
  51342. /**
  51343. * Remove a mesh from the floor meshes array
  51344. * @param mesh the mesh to remove
  51345. */
  51346. removeFloorMesh(mesh: AbstractMesh): void;
  51347. /**
  51348. * Remove a mesh from the floor meshes array using its name
  51349. * @param name the mesh name to remove
  51350. */
  51351. removeFloorMeshByName(name: string): void;
  51352. /**
  51353. * 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
  51354. * @param snapPointToRemove the point (or a clone of it) to be removed from the array
  51355. * @returns was the point found and removed or not
  51356. */
  51357. removeSnapPoint(snapPointToRemove: Vector3): boolean;
  51358. /**
  51359. * This function sets a selection feature that will be disabled when
  51360. * the forward ray is shown and will be reattached when hidden.
  51361. * This is used to remove the selection rays when moving.
  51362. * @param selectionFeature the feature to disable when forward movement is enabled
  51363. */
  51364. setSelectionFeature(selectionFeature: IWebXRFeature): void;
  51365. protected _onXRFrame(_xrFrame: XRFrame): void;
  51366. private _attachController;
  51367. private _createDefaultTargetMesh;
  51368. private _detachController;
  51369. private _findClosestSnapPointWithRadius;
  51370. private _setTargetMeshPosition;
  51371. private _setTargetMeshVisibility;
  51372. private _showParabolicPath;
  51373. private _teleportForward;
  51374. }
  51375. }
  51376. declare module "babylonjs/XR/webXRDefaultExperience" {
  51377. import { WebXRExperienceHelper } from "babylonjs/XR/webXRExperienceHelper";
  51378. import { Scene } from "babylonjs/scene";
  51379. import { WebXRInput, IWebXRInputOptions } from "babylonjs/XR/webXRInput";
  51380. import { WebXRControllerPointerSelection } from "babylonjs/XR/features/WebXRControllerPointerSelection";
  51381. import { WebXRRenderTarget } from "babylonjs/XR/webXRTypes";
  51382. import { WebXREnterExitUI, WebXREnterExitUIOptions } from "babylonjs/XR/webXREnterExitUI";
  51383. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  51384. import { WebXRManagedOutputCanvasOptions } from "babylonjs/XR/webXRManagedOutputCanvas";
  51385. import { WebXRMotionControllerTeleportation } from "babylonjs/XR/features/WebXRControllerTeleportation";
  51386. /**
  51387. * Options for the default xr helper
  51388. */
  51389. export class WebXRDefaultExperienceOptions {
  51390. /**
  51391. * Enable or disable default UI to enter XR
  51392. */
  51393. disableDefaultUI?: boolean;
  51394. /**
  51395. * Should teleportation not initialize. defaults to false.
  51396. */
  51397. disableTeleportation?: boolean;
  51398. /**
  51399. * Floor meshes that will be used for teleport
  51400. */
  51401. floorMeshes?: Array<AbstractMesh>;
  51402. /**
  51403. * If set to true, the first frame will not be used to reset position
  51404. * The first frame is mainly used when copying transformation from the old camera
  51405. * Mainly used in AR
  51406. */
  51407. ignoreNativeCameraTransformation?: boolean;
  51408. /**
  51409. * Disable the controller mesh-loading. Can be used if you want to load your own meshes
  51410. */
  51411. inputOptions?: IWebXRInputOptions;
  51412. /**
  51413. * optional configuration for the output canvas
  51414. */
  51415. outputCanvasOptions?: WebXRManagedOutputCanvasOptions;
  51416. /**
  51417. * optional UI options. This can be used among other to change session mode and reference space type
  51418. */
  51419. uiOptions?: WebXREnterExitUIOptions;
  51420. /**
  51421. * When loading teleportation and pointer select, use stable versions instead of latest.
  51422. */
  51423. useStablePlugins?: boolean;
  51424. /**
  51425. * An optional rendering group id that will be set globally for teleportation, pointer selection and default controller meshes
  51426. */
  51427. renderingGroupId?: number;
  51428. /**
  51429. * A list of optional features to init the session with
  51430. * If set to true, all features we support will be added
  51431. */
  51432. optionalFeatures?: boolean | string[];
  51433. }
  51434. /**
  51435. * Default experience which provides a similar setup to the previous webVRExperience
  51436. */
  51437. export class WebXRDefaultExperience {
  51438. /**
  51439. * Base experience
  51440. */
  51441. baseExperience: WebXRExperienceHelper;
  51442. /**
  51443. * Enables ui for entering/exiting xr
  51444. */
  51445. enterExitUI: WebXREnterExitUI;
  51446. /**
  51447. * Input experience extension
  51448. */
  51449. input: WebXRInput;
  51450. /**
  51451. * Enables laser pointer and selection
  51452. */
  51453. pointerSelection: WebXRControllerPointerSelection;
  51454. /**
  51455. * Default target xr should render to
  51456. */
  51457. renderTarget: WebXRRenderTarget;
  51458. /**
  51459. * Enables teleportation
  51460. */
  51461. teleportation: WebXRMotionControllerTeleportation;
  51462. private constructor();
  51463. /**
  51464. * Creates the default xr experience
  51465. * @param scene scene
  51466. * @param options options for basic configuration
  51467. * @returns resulting WebXRDefaultExperience
  51468. */
  51469. static CreateAsync(scene: Scene, options?: WebXRDefaultExperienceOptions): Promise<WebXRDefaultExperience>;
  51470. /**
  51471. * DIsposes of the experience helper
  51472. */
  51473. dispose(): void;
  51474. }
  51475. }
  51476. declare module "babylonjs/Cameras/VR/vrExperienceHelper" {
  51477. import { Observable } from "babylonjs/Misc/observable";
  51478. import { Nullable } from "babylonjs/types";
  51479. import { Camera } from "babylonjs/Cameras/camera";
  51480. import { DeviceOrientationCamera } from "babylonjs/Cameras/deviceOrientationCamera";
  51481. import { VRDeviceOrientationFreeCamera } from "babylonjs/Cameras/VR/vrDeviceOrientationFreeCamera";
  51482. import { WebVROptions, WebVRFreeCamera } from "babylonjs/Cameras/VR/webVRCamera";
  51483. import { Scene } from "babylonjs/scene";
  51484. import { Vector3 } from "babylonjs/Maths/math.vector";
  51485. import { Color3 } from "babylonjs/Maths/math.color";
  51486. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  51487. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  51488. import { Mesh } from "babylonjs/Meshes/mesh";
  51489. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  51490. import { EasingFunction } from "babylonjs/Animations/easing";
  51491. import { VRCameraMetrics } from "babylonjs/Cameras/VR/vrCameraMetrics";
  51492. import "babylonjs/Meshes/Builders/groundBuilder";
  51493. import "babylonjs/Meshes/Builders/torusBuilder";
  51494. import "babylonjs/Meshes/Builders/cylinderBuilder";
  51495. import "babylonjs/Gamepads/gamepadSceneComponent";
  51496. import "babylonjs/Animations/animatable";
  51497. import { WebXRDefaultExperience } from "babylonjs/XR/webXRDefaultExperience";
  51498. /**
  51499. * Options to modify the vr teleportation behavior.
  51500. */
  51501. export interface VRTeleportationOptions {
  51502. /**
  51503. * The name of the mesh which should be used as the teleportation floor. (default: null)
  51504. */
  51505. floorMeshName?: string;
  51506. /**
  51507. * A list of meshes to be used as the teleportation floor. (default: empty)
  51508. */
  51509. floorMeshes?: Mesh[];
  51510. /**
  51511. * The teleportation mode. (default: TELEPORTATIONMODE_CONSTANTTIME)
  51512. */
  51513. teleportationMode?: number;
  51514. /**
  51515. * The duration of the animation in ms, apply when animationMode is TELEPORTATIONMODE_CONSTANTTIME. (default 122ms)
  51516. */
  51517. teleportationTime?: number;
  51518. /**
  51519. * The speed of the animation in distance/sec, apply when animationMode is TELEPORTATIONMODE_CONSTANTSPEED. (default 20 units / sec)
  51520. */
  51521. teleportationSpeed?: number;
  51522. /**
  51523. * The easing function used in the animation or null for Linear. (default CircleEase)
  51524. */
  51525. easingFunction?: EasingFunction;
  51526. }
  51527. /**
  51528. * Options to modify the vr experience helper's behavior.
  51529. */
  51530. export interface VRExperienceHelperOptions extends WebVROptions {
  51531. /**
  51532. * Create a DeviceOrientationCamera to be used as your out of vr camera. (default: true)
  51533. */
  51534. createDeviceOrientationCamera?: boolean;
  51535. /**
  51536. * Create a VRDeviceOrientationFreeCamera to be used for VR when no external HMD is found. (default: true)
  51537. */
  51538. createFallbackVRDeviceOrientationFreeCamera?: boolean;
  51539. /**
  51540. * Uses the main button on the controller to toggle the laser casted. (default: true)
  51541. */
  51542. laserToggle?: boolean;
  51543. /**
  51544. * A list of meshes to be used as the teleportation floor. If specified, teleportation will be enabled (default: undefined)
  51545. */
  51546. floorMeshes?: Mesh[];
  51547. /**
  51548. * Distortion metrics for the fallback vrDeviceOrientationCamera (default: VRCameraMetrics.Default)
  51549. */
  51550. vrDeviceOrientationCameraMetrics?: VRCameraMetrics;
  51551. /**
  51552. * Defines if WebXR should be used instead of WebVR (if available)
  51553. */
  51554. useXR?: boolean;
  51555. }
  51556. /**
  51557. * Event containing information after VR has been entered
  51558. */
  51559. export class OnAfterEnteringVRObservableEvent {
  51560. /**
  51561. * If entering vr was successful
  51562. */
  51563. success: boolean;
  51564. }
  51565. /**
  51566. * Helps to quickly add VR support to an existing scene.
  51567. * See https://doc.babylonjs.com/how_to/webvr_helper
  51568. */
  51569. export class VRExperienceHelper {
  51570. /** Options to modify the vr experience helper's behavior. */
  51571. webVROptions: VRExperienceHelperOptions;
  51572. private _scene;
  51573. private _position;
  51574. private _btnVR;
  51575. private _btnVRDisplayed;
  51576. private _webVRsupported;
  51577. private _webVRready;
  51578. private _webVRrequesting;
  51579. private _webVRpresenting;
  51580. private _hasEnteredVR;
  51581. private _fullscreenVRpresenting;
  51582. private _inputElement;
  51583. private _webVRCamera;
  51584. private _vrDeviceOrientationCamera;
  51585. private _deviceOrientationCamera;
  51586. private _existingCamera;
  51587. private _onKeyDown;
  51588. private _onVrDisplayPresentChange;
  51589. private _onVRDisplayChanged;
  51590. private _onVRRequestPresentStart;
  51591. private _onVRRequestPresentComplete;
  51592. /**
  51593. * 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)
  51594. */
  51595. enableGazeEvenWhenNoPointerLock: boolean;
  51596. /**
  51597. * Gets or sets a boolean indicating that the VREXperienceHelper will exit VR if double tap is detected
  51598. */
  51599. exitVROnDoubleTap: boolean;
  51600. /**
  51601. * Observable raised right before entering VR.
  51602. */
  51603. onEnteringVRObservable: Observable<VRExperienceHelper>;
  51604. /**
  51605. * Observable raised when entering VR has completed.
  51606. */
  51607. onAfterEnteringVRObservable: Observable<OnAfterEnteringVRObservableEvent>;
  51608. /**
  51609. * Observable raised when exiting VR.
  51610. */
  51611. onExitingVRObservable: Observable<VRExperienceHelper>;
  51612. /**
  51613. * Observable raised when controller mesh is loaded.
  51614. */
  51615. onControllerMeshLoadedObservable: Observable<WebVRController>;
  51616. /** Return this.onEnteringVRObservable
  51617. * Note: This one is for backward compatibility. Please use onEnteringVRObservable directly
  51618. */
  51619. get onEnteringVR(): Observable<VRExperienceHelper>;
  51620. /** Return this.onExitingVRObservable
  51621. * Note: This one is for backward compatibility. Please use onExitingVRObservable directly
  51622. */
  51623. get onExitingVR(): Observable<VRExperienceHelper>;
  51624. /** Return this.onControllerMeshLoadedObservable
  51625. * Note: This one is for backward compatibility. Please use onControllerMeshLoadedObservable directly
  51626. */
  51627. get onControllerMeshLoaded(): Observable<WebVRController>;
  51628. private _rayLength;
  51629. private _useCustomVRButton;
  51630. private _teleportationRequested;
  51631. private _teleportActive;
  51632. private _floorMeshName;
  51633. private _floorMeshesCollection;
  51634. private _teleportationMode;
  51635. private _teleportationTime;
  51636. private _teleportationSpeed;
  51637. private _teleportationEasing;
  51638. private _rotationAllowed;
  51639. private _teleportBackwardsVector;
  51640. private _teleportationTarget;
  51641. private _isDefaultTeleportationTarget;
  51642. private _postProcessMove;
  51643. private _teleportationFillColor;
  51644. private _teleportationBorderColor;
  51645. private _rotationAngle;
  51646. private _haloCenter;
  51647. private _cameraGazer;
  51648. private _padSensibilityUp;
  51649. private _padSensibilityDown;
  51650. private _leftController;
  51651. private _rightController;
  51652. private _gazeColor;
  51653. private _laserColor;
  51654. private _pickedLaserColor;
  51655. private _pickedGazeColor;
  51656. /**
  51657. * Observable raised when a new mesh is selected based on meshSelectionPredicate
  51658. */
  51659. onNewMeshSelected: Observable<AbstractMesh>;
  51660. /**
  51661. * Observable raised when a new mesh is selected based on meshSelectionPredicate.
  51662. * This observable will provide the mesh and the controller used to select the mesh
  51663. */
  51664. onMeshSelectedWithController: Observable<{
  51665. mesh: AbstractMesh;
  51666. controller: WebVRController;
  51667. }>;
  51668. /**
  51669. * Observable raised when a new mesh is picked based on meshSelectionPredicate
  51670. */
  51671. onNewMeshPicked: Observable<PickingInfo>;
  51672. private _circleEase;
  51673. /**
  51674. * Observable raised before camera teleportation
  51675. */
  51676. onBeforeCameraTeleport: Observable<Vector3>;
  51677. /**
  51678. * Observable raised after camera teleportation
  51679. */
  51680. onAfterCameraTeleport: Observable<Vector3>;
  51681. /**
  51682. * Observable raised when current selected mesh gets unselected
  51683. */
  51684. onSelectedMeshUnselected: Observable<AbstractMesh>;
  51685. private _raySelectionPredicate;
  51686. /**
  51687. * To be optionaly changed by user to define custom ray selection
  51688. */
  51689. raySelectionPredicate: (mesh: AbstractMesh) => boolean;
  51690. /**
  51691. * To be optionaly changed by user to define custom selection logic (after ray selection)
  51692. */
  51693. meshSelectionPredicate: (mesh: AbstractMesh) => boolean;
  51694. /**
  51695. * Set teleportation enabled. If set to false camera teleportation will be disabled but camera rotation will be kept.
  51696. */
  51697. teleportationEnabled: boolean;
  51698. private _defaultHeight;
  51699. private _teleportationInitialized;
  51700. private _interactionsEnabled;
  51701. private _interactionsRequested;
  51702. private _displayGaze;
  51703. private _displayLaserPointer;
  51704. /**
  51705. * The mesh used to display where the user is going to teleport.
  51706. */
  51707. get teleportationTarget(): Mesh;
  51708. /**
  51709. * Sets the mesh to be used to display where the user is going to teleport.
  51710. */
  51711. set teleportationTarget(value: Mesh);
  51712. /**
  51713. * 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
  51714. * when set bakeCurrentTransformIntoVertices will be called on the mesh.
  51715. * See https://doc.babylonjs.com/resources/baking_transformations
  51716. */
  51717. get gazeTrackerMesh(): Mesh;
  51718. set gazeTrackerMesh(value: Mesh);
  51719. /**
  51720. * If the gaze trackers scale should be updated to be constant size when pointing at near/far meshes
  51721. */
  51722. updateGazeTrackerScale: boolean;
  51723. /**
  51724. * If the gaze trackers color should be updated when selecting meshes
  51725. */
  51726. updateGazeTrackerColor: boolean;
  51727. /**
  51728. * If the controller laser color should be updated when selecting meshes
  51729. */
  51730. updateControllerLaserColor: boolean;
  51731. /**
  51732. * The gaze tracking mesh corresponding to the left controller
  51733. */
  51734. get leftControllerGazeTrackerMesh(): Nullable<Mesh>;
  51735. /**
  51736. * The gaze tracking mesh corresponding to the right controller
  51737. */
  51738. get rightControllerGazeTrackerMesh(): Nullable<Mesh>;
  51739. /**
  51740. * If the ray of the gaze should be displayed.
  51741. */
  51742. get displayGaze(): boolean;
  51743. /**
  51744. * Sets if the ray of the gaze should be displayed.
  51745. */
  51746. set displayGaze(value: boolean);
  51747. /**
  51748. * If the ray of the LaserPointer should be displayed.
  51749. */
  51750. get displayLaserPointer(): boolean;
  51751. /**
  51752. * Sets if the ray of the LaserPointer should be displayed.
  51753. */
  51754. set displayLaserPointer(value: boolean);
  51755. /**
  51756. * The deviceOrientationCamera used as the camera when not in VR.
  51757. */
  51758. get deviceOrientationCamera(): Nullable<DeviceOrientationCamera>;
  51759. /**
  51760. * Based on the current WebVR support, returns the current VR camera used.
  51761. */
  51762. get currentVRCamera(): Nullable<Camera>;
  51763. /**
  51764. * The webVRCamera which is used when in VR.
  51765. */
  51766. get webVRCamera(): WebVRFreeCamera;
  51767. /**
  51768. * The deviceOrientationCamera that is used as a fallback when vr device is not connected.
  51769. */
  51770. get vrDeviceOrientationCamera(): Nullable<VRDeviceOrientationFreeCamera>;
  51771. /**
  51772. * The html button that is used to trigger entering into VR.
  51773. */
  51774. get vrButton(): Nullable<HTMLButtonElement>;
  51775. private get _teleportationRequestInitiated();
  51776. /**
  51777. * Defines whether or not Pointer lock should be requested when switching to
  51778. * full screen.
  51779. */
  51780. requestPointerLockOnFullScreen: boolean;
  51781. /**
  51782. * If asking to force XR, this will be populated with the default xr experience
  51783. */
  51784. xr: WebXRDefaultExperience;
  51785. /**
  51786. * Was the XR test done already. If this is true AND this.xr exists, xr is initialized.
  51787. * If this is true and no this.xr, xr exists but is not supported, using WebVR.
  51788. */
  51789. xrTestDone: boolean;
  51790. /**
  51791. * Instantiates a VRExperienceHelper.
  51792. * Helps to quickly add VR support to an existing scene.
  51793. * @param scene The scene the VRExperienceHelper belongs to.
  51794. * @param webVROptions Options to modify the vr experience helper's behavior.
  51795. */
  51796. constructor(scene: Scene,
  51797. /** Options to modify the vr experience helper's behavior. */
  51798. webVROptions?: VRExperienceHelperOptions);
  51799. private completeVRInit;
  51800. private _onDefaultMeshLoaded;
  51801. private _onResize;
  51802. private _onFullscreenChange;
  51803. /**
  51804. * Gets a value indicating if we are currently in VR mode.
  51805. */
  51806. get isInVRMode(): boolean;
  51807. private onVrDisplayPresentChange;
  51808. private onVRDisplayChanged;
  51809. private moveButtonToBottomRight;
  51810. private displayVRButton;
  51811. private updateButtonVisibility;
  51812. private _cachedAngularSensibility;
  51813. /**
  51814. * Attempt to enter VR. If a headset is connected and ready, will request present on that.
  51815. * Otherwise, will use the fullscreen API.
  51816. */
  51817. enterVR(): void;
  51818. /**
  51819. * Attempt to exit VR, or fullscreen.
  51820. */
  51821. exitVR(): void;
  51822. /**
  51823. * The position of the vr experience helper.
  51824. */
  51825. get position(): Vector3;
  51826. /**
  51827. * Sets the position of the vr experience helper.
  51828. */
  51829. set position(value: Vector3);
  51830. /**
  51831. * Enables controllers and user interactions such as selecting and object or clicking on an object.
  51832. */
  51833. enableInteractions(): void;
  51834. private get _noControllerIsActive();
  51835. private beforeRender;
  51836. private _isTeleportationFloor;
  51837. /**
  51838. * Adds a floor mesh to be used for teleportation.
  51839. * @param floorMesh the mesh to be used for teleportation.
  51840. */
  51841. addFloorMesh(floorMesh: Mesh): void;
  51842. /**
  51843. * Removes a floor mesh from being used for teleportation.
  51844. * @param floorMesh the mesh to be removed.
  51845. */
  51846. removeFloorMesh(floorMesh: Mesh): void;
  51847. /**
  51848. * Enables interactions and teleportation using the VR controllers and gaze.
  51849. * @param vrTeleportationOptions options to modify teleportation behavior.
  51850. */
  51851. enableTeleportation(vrTeleportationOptions?: VRTeleportationOptions): void;
  51852. private _onNewGamepadConnected;
  51853. private _tryEnableInteractionOnController;
  51854. private _onNewGamepadDisconnected;
  51855. private _enableInteractionOnController;
  51856. private _checkTeleportWithRay;
  51857. private _checkRotate;
  51858. private _checkTeleportBackwards;
  51859. private _enableTeleportationOnController;
  51860. private _createTeleportationCircles;
  51861. private _displayTeleportationTarget;
  51862. private _hideTeleportationTarget;
  51863. private _rotateCamera;
  51864. private _moveTeleportationSelectorTo;
  51865. private _workingVector;
  51866. private _workingQuaternion;
  51867. private _workingMatrix;
  51868. /**
  51869. * Time Constant Teleportation Mode
  51870. */
  51871. static readonly TELEPORTATIONMODE_CONSTANTTIME: number;
  51872. /**
  51873. * Speed Constant Teleportation Mode
  51874. */
  51875. static readonly TELEPORTATIONMODE_CONSTANTSPEED: number;
  51876. /**
  51877. * Teleports the users feet to the desired location
  51878. * @param location The location where the user's feet should be placed
  51879. */
  51880. teleportCamera(location: Vector3): void;
  51881. private _convertNormalToDirectionOfRay;
  51882. private _castRayAndSelectObject;
  51883. private _notifySelectedMeshUnselected;
  51884. /**
  51885. * Permanently set new colors for the laser pointer
  51886. * @param color the new laser color
  51887. * @param pickedColor the new laser color when picked mesh detected
  51888. */
  51889. setLaserColor(color: Color3, pickedColor?: Color3): void;
  51890. /**
  51891. * Set lighting enabled / disabled on the laser pointer of both controllers
  51892. * @param enabled should the lighting be enabled on the laser pointer
  51893. */
  51894. setLaserLightingState(enabled?: boolean): void;
  51895. /**
  51896. * Permanently set new colors for the gaze pointer
  51897. * @param color the new gaze color
  51898. * @param pickedColor the new gaze color when picked mesh detected
  51899. */
  51900. setGazeColor(color: Color3, pickedColor?: Color3): void;
  51901. /**
  51902. * Sets the color of the laser ray from the vr controllers.
  51903. * @param color new color for the ray.
  51904. */
  51905. changeLaserColor(color: Color3): void;
  51906. /**
  51907. * Sets the color of the ray from the vr headsets gaze.
  51908. * @param color new color for the ray.
  51909. */
  51910. changeGazeColor(color: Color3): void;
  51911. /**
  51912. * Exits VR and disposes of the vr experience helper
  51913. */
  51914. dispose(): void;
  51915. /**
  51916. * Gets the name of the VRExperienceHelper class
  51917. * @returns "VRExperienceHelper"
  51918. */
  51919. getClassName(): string;
  51920. }
  51921. }
  51922. declare module "babylonjs/Cameras/VR/index" {
  51923. export * from "babylonjs/Cameras/VR/vrCameraMetrics";
  51924. export * from "babylonjs/Cameras/VR/vrDeviceOrientationArcRotateCamera";
  51925. export * from "babylonjs/Cameras/VR/vrDeviceOrientationFreeCamera";
  51926. export * from "babylonjs/Cameras/VR/vrDeviceOrientationGamepadCamera";
  51927. export * from "babylonjs/Cameras/VR/vrExperienceHelper";
  51928. export * from "babylonjs/Cameras/VR/webVRCamera";
  51929. }
  51930. declare module "babylonjs/Cameras/RigModes/index" {
  51931. export * from "babylonjs/Cameras/RigModes/stereoscopicAnaglyphRigMode";
  51932. export * from "babylonjs/Cameras/RigModes/stereoscopicRigMode";
  51933. export * from "babylonjs/Cameras/RigModes/vrRigMode";
  51934. export * from "babylonjs/Cameras/RigModes/webVRRigMode";
  51935. }
  51936. declare module "babylonjs/Cameras/index" {
  51937. export * from "babylonjs/Cameras/Inputs/index";
  51938. export * from "babylonjs/Cameras/cameraInputsManager";
  51939. export * from "babylonjs/Cameras/camera";
  51940. export * from "babylonjs/Cameras/targetCamera";
  51941. export * from "babylonjs/Cameras/freeCamera";
  51942. export * from "babylonjs/Cameras/freeCameraInputsManager";
  51943. export * from "babylonjs/Cameras/touchCamera";
  51944. export * from "babylonjs/Cameras/arcRotateCamera";
  51945. export * from "babylonjs/Cameras/arcRotateCameraInputsManager";
  51946. export * from "babylonjs/Cameras/deviceOrientationCamera";
  51947. export * from "babylonjs/Cameras/flyCamera";
  51948. export * from "babylonjs/Cameras/flyCameraInputsManager";
  51949. export * from "babylonjs/Cameras/followCamera";
  51950. export * from "babylonjs/Cameras/followCameraInputsManager";
  51951. export * from "babylonjs/Cameras/gamepadCamera";
  51952. export * from "babylonjs/Cameras/Stereoscopic/index";
  51953. export * from "babylonjs/Cameras/universalCamera";
  51954. export * from "babylonjs/Cameras/virtualJoysticksCamera";
  51955. export * from "babylonjs/Cameras/VR/index";
  51956. export * from "babylonjs/Cameras/RigModes/index";
  51957. }
  51958. declare module "babylonjs/Collisions/index" {
  51959. export * from "babylonjs/Collisions/collider";
  51960. export * from "babylonjs/Collisions/collisionCoordinator";
  51961. export * from "babylonjs/Collisions/pickingInfo";
  51962. export * from "babylonjs/Collisions/intersectionInfo";
  51963. export * from "babylonjs/Collisions/meshCollisionData";
  51964. }
  51965. declare module "babylonjs/Culling/Octrees/octreeBlock" {
  51966. import { SmartArrayNoDuplicate } from "babylonjs/Misc/smartArray";
  51967. import { Vector3 } from "babylonjs/Maths/math.vector";
  51968. import { Ray } from "babylonjs/Culling/ray";
  51969. import { Plane } from "babylonjs/Maths/math.plane";
  51970. /**
  51971. * Contains an array of blocks representing the octree
  51972. */
  51973. export interface IOctreeContainer<T> {
  51974. /**
  51975. * Blocks within the octree
  51976. */
  51977. blocks: Array<OctreeBlock<T>>;
  51978. }
  51979. /**
  51980. * Class used to store a cell in an octree
  51981. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  51982. */
  51983. export class OctreeBlock<T> {
  51984. /**
  51985. * Gets the content of the current block
  51986. */
  51987. entries: T[];
  51988. /**
  51989. * Gets the list of block children
  51990. */
  51991. blocks: Array<OctreeBlock<T>>;
  51992. private _depth;
  51993. private _maxDepth;
  51994. private _capacity;
  51995. private _minPoint;
  51996. private _maxPoint;
  51997. private _boundingVectors;
  51998. private _creationFunc;
  51999. /**
  52000. * Creates a new block
  52001. * @param minPoint defines the minimum vector (in world space) of the block's bounding box
  52002. * @param maxPoint defines the maximum vector (in world space) of the block's bounding box
  52003. * @param capacity defines the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  52004. * @param depth defines the current depth of this block in the octree
  52005. * @param maxDepth defines the maximal depth allowed (beyond this value, the capacity is ignored)
  52006. * @param creationFunc defines a callback to call when an element is added to the block
  52007. */
  52008. constructor(minPoint: Vector3, maxPoint: Vector3, capacity: number, depth: number, maxDepth: number, creationFunc: (entry: T, block: OctreeBlock<T>) => void);
  52009. /**
  52010. * Gets the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  52011. */
  52012. get capacity(): number;
  52013. /**
  52014. * Gets the minimum vector (in world space) of the block's bounding box
  52015. */
  52016. get minPoint(): Vector3;
  52017. /**
  52018. * Gets the maximum vector (in world space) of the block's bounding box
  52019. */
  52020. get maxPoint(): Vector3;
  52021. /**
  52022. * Add a new element to this block
  52023. * @param entry defines the element to add
  52024. */
  52025. addEntry(entry: T): void;
  52026. /**
  52027. * Remove an element from this block
  52028. * @param entry defines the element to remove
  52029. */
  52030. removeEntry(entry: T): void;
  52031. /**
  52032. * Add an array of elements to this block
  52033. * @param entries defines the array of elements to add
  52034. */
  52035. addEntries(entries: T[]): void;
  52036. /**
  52037. * Test if the current block intersects the furstum planes and if yes, then add its content to the selection array
  52038. * @param frustumPlanes defines the frustum planes to test
  52039. * @param selection defines the array to store current content if selection is positive
  52040. * @param allowDuplicate defines if the selection array can contains duplicated entries
  52041. */
  52042. select(frustumPlanes: Plane[], selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  52043. /**
  52044. * Test if the current block intersect with the given bounding sphere and if yes, then add its content to the selection array
  52045. * @param sphereCenter defines the bounding sphere center
  52046. * @param sphereRadius defines the bounding sphere radius
  52047. * @param selection defines the array to store current content if selection is positive
  52048. * @param allowDuplicate defines if the selection array can contains duplicated entries
  52049. */
  52050. intersects(sphereCenter: Vector3, sphereRadius: number, selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  52051. /**
  52052. * Test if the current block intersect with the given ray and if yes, then add its content to the selection array
  52053. * @param ray defines the ray to test with
  52054. * @param selection defines the array to store current content if selection is positive
  52055. */
  52056. intersectsRay(ray: Ray, selection: SmartArrayNoDuplicate<T>): void;
  52057. /**
  52058. * Subdivide the content into child blocks (this block will then be empty)
  52059. */
  52060. createInnerBlocks(): void;
  52061. /**
  52062. * @hidden
  52063. */
  52064. 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;
  52065. }
  52066. }
  52067. declare module "babylonjs/Culling/Octrees/octree" {
  52068. import { SmartArray } from "babylonjs/Misc/smartArray";
  52069. import { Vector3 } from "babylonjs/Maths/math.vector";
  52070. import { SubMesh } from "babylonjs/Meshes/subMesh";
  52071. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  52072. import { Ray } from "babylonjs/Culling/ray";
  52073. import { OctreeBlock } from "babylonjs/Culling/Octrees/octreeBlock";
  52074. import { Plane } from "babylonjs/Maths/math.plane";
  52075. /**
  52076. * Octrees are a really powerful data structure that can quickly select entities based on space coordinates.
  52077. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  52078. */
  52079. export class Octree<T> {
  52080. /** 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.) */
  52081. maxDepth: number;
  52082. /**
  52083. * Blocks within the octree containing objects
  52084. */
  52085. blocks: Array<OctreeBlock<T>>;
  52086. /**
  52087. * Content stored in the octree
  52088. */
  52089. dynamicContent: T[];
  52090. private _maxBlockCapacity;
  52091. private _selectionContent;
  52092. private _creationFunc;
  52093. /**
  52094. * Creates a octree
  52095. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  52096. * @param creationFunc function to be used to instatiate the octree
  52097. * @param maxBlockCapacity defines the maximum number of meshes you want on your octree's leaves (default: 64)
  52098. * @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.)
  52099. */
  52100. constructor(creationFunc: (entry: T, block: OctreeBlock<T>) => void, maxBlockCapacity?: number,
  52101. /** 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.) */
  52102. maxDepth?: number);
  52103. /**
  52104. * Updates the octree by adding blocks for the passed in meshes within the min and max world parameters
  52105. * @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);
  52106. * @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);
  52107. * @param entries meshes to be added to the octree blocks
  52108. */
  52109. update(worldMin: Vector3, worldMax: Vector3, entries: T[]): void;
  52110. /**
  52111. * Adds a mesh to the octree
  52112. * @param entry Mesh to add to the octree
  52113. */
  52114. addMesh(entry: T): void;
  52115. /**
  52116. * Remove an element from the octree
  52117. * @param entry defines the element to remove
  52118. */
  52119. removeMesh(entry: T): void;
  52120. /**
  52121. * Selects an array of meshes within the frustum
  52122. * @param frustumPlanes The frustum planes to use which will select all meshes within it
  52123. * @param allowDuplicate If duplicate objects are allowed in the resulting object array
  52124. * @returns array of meshes within the frustum
  52125. */
  52126. select(frustumPlanes: Plane[], allowDuplicate?: boolean): SmartArray<T>;
  52127. /**
  52128. * Test if the octree intersect with the given bounding sphere and if yes, then add its content to the selection array
  52129. * @param sphereCenter defines the bounding sphere center
  52130. * @param sphereRadius defines the bounding sphere radius
  52131. * @param allowDuplicate defines if the selection array can contains duplicated entries
  52132. * @returns an array of objects that intersect the sphere
  52133. */
  52134. intersects(sphereCenter: Vector3, sphereRadius: number, allowDuplicate?: boolean): SmartArray<T>;
  52135. /**
  52136. * Test if the octree intersect with the given ray and if yes, then add its content to resulting array
  52137. * @param ray defines the ray to test with
  52138. * @returns array of intersected objects
  52139. */
  52140. intersectsRay(ray: Ray): SmartArray<T>;
  52141. /**
  52142. * Adds a mesh into the octree block if it intersects the block
  52143. */
  52144. static CreationFuncForMeshes: (entry: AbstractMesh, block: OctreeBlock<AbstractMesh>) => void;
  52145. /**
  52146. * Adds a submesh into the octree block if it intersects the block
  52147. */
  52148. static CreationFuncForSubMeshes: (entry: SubMesh, block: OctreeBlock<SubMesh>) => void;
  52149. }
  52150. }
  52151. declare module "babylonjs/Culling/Octrees/octreeSceneComponent" {
  52152. import { ISmartArrayLike } from "babylonjs/Misc/smartArray";
  52153. import { Scene } from "babylonjs/scene";
  52154. import { SubMesh } from "babylonjs/Meshes/subMesh";
  52155. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  52156. import { Ray } from "babylonjs/Culling/ray";
  52157. import { Octree } from "babylonjs/Culling/Octrees/octree";
  52158. import { Collider } from "babylonjs/Collisions/collider";
  52159. module "babylonjs/scene" {
  52160. interface Scene {
  52161. /**
  52162. * @hidden
  52163. * Backing Filed
  52164. */
  52165. _selectionOctree: Octree<AbstractMesh>;
  52166. /**
  52167. * Gets the octree used to boost mesh selection (picking)
  52168. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  52169. */
  52170. selectionOctree: Octree<AbstractMesh>;
  52171. /**
  52172. * Creates or updates the octree used to boost selection (picking)
  52173. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  52174. * @param maxCapacity defines the maximum capacity per leaf
  52175. * @param maxDepth defines the maximum depth of the octree
  52176. * @returns an octree of AbstractMesh
  52177. */
  52178. createOrUpdateSelectionOctree(maxCapacity?: number, maxDepth?: number): Octree<AbstractMesh>;
  52179. }
  52180. }
  52181. module "babylonjs/Meshes/abstractMesh" {
  52182. interface AbstractMesh {
  52183. /**
  52184. * @hidden
  52185. * Backing Field
  52186. */
  52187. _submeshesOctree: Octree<SubMesh>;
  52188. /**
  52189. * This function will create an octree to help to select the right submeshes for rendering, picking and collision computations.
  52190. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  52191. * @param maxCapacity defines the maximum size of each block (64 by default)
  52192. * @param maxDepth defines the maximum depth to use (no more than 2 levels by default)
  52193. * @returns the new octree
  52194. * @see https://www.babylonjs-playground.com/#NA4OQ#12
  52195. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  52196. */
  52197. createOrUpdateSubmeshesOctree(maxCapacity?: number, maxDepth?: number): Octree<SubMesh>;
  52198. }
  52199. }
  52200. /**
  52201. * Defines the octree scene component responsible to manage any octrees
  52202. * in a given scene.
  52203. */
  52204. export class OctreeSceneComponent {
  52205. /**
  52206. * The component name help to identify the component in the list of scene components.
  52207. */
  52208. readonly name: string;
  52209. /**
  52210. * The scene the component belongs to.
  52211. */
  52212. scene: Scene;
  52213. /**
  52214. * Indicates if the meshes have been checked to make sure they are isEnabled()
  52215. */
  52216. readonly checksIsEnabled: boolean;
  52217. /**
  52218. * Creates a new instance of the component for the given scene
  52219. * @param scene Defines the scene to register the component in
  52220. */
  52221. constructor(scene: Scene);
  52222. /**
  52223. * Registers the component in a given scene
  52224. */
  52225. register(): void;
  52226. /**
  52227. * Return the list of active meshes
  52228. * @returns the list of active meshes
  52229. */
  52230. getActiveMeshCandidates(): ISmartArrayLike<AbstractMesh>;
  52231. /**
  52232. * Return the list of active sub meshes
  52233. * @param mesh The mesh to get the candidates sub meshes from
  52234. * @returns the list of active sub meshes
  52235. */
  52236. getActiveSubMeshCandidates(mesh: AbstractMesh): ISmartArrayLike<SubMesh>;
  52237. private _tempRay;
  52238. /**
  52239. * Return the list of sub meshes intersecting with a given local ray
  52240. * @param mesh defines the mesh to find the submesh for
  52241. * @param localRay defines the ray in local space
  52242. * @returns the list of intersecting sub meshes
  52243. */
  52244. getIntersectingSubMeshCandidates(mesh: AbstractMesh, localRay: Ray): ISmartArrayLike<SubMesh>;
  52245. /**
  52246. * Return the list of sub meshes colliding with a collider
  52247. * @param mesh defines the mesh to find the submesh for
  52248. * @param collider defines the collider to evaluate the collision against
  52249. * @returns the list of colliding sub meshes
  52250. */
  52251. getCollidingSubMeshCandidates(mesh: AbstractMesh, collider: Collider): ISmartArrayLike<SubMesh>;
  52252. /**
  52253. * Rebuilds the elements related to this component in case of
  52254. * context lost for instance.
  52255. */
  52256. rebuild(): void;
  52257. /**
  52258. * Disposes the component and the associated ressources.
  52259. */
  52260. dispose(): void;
  52261. }
  52262. }
  52263. declare module "babylonjs/Culling/Octrees/index" {
  52264. export * from "babylonjs/Culling/Octrees/octree";
  52265. export * from "babylonjs/Culling/Octrees/octreeBlock";
  52266. export * from "babylonjs/Culling/Octrees/octreeSceneComponent";
  52267. }
  52268. declare module "babylonjs/Culling/index" {
  52269. export * from "babylonjs/Culling/boundingBox";
  52270. export * from "babylonjs/Culling/boundingInfo";
  52271. export * from "babylonjs/Culling/boundingSphere";
  52272. export * from "babylonjs/Culling/Octrees/index";
  52273. export * from "babylonjs/Culling/ray";
  52274. }
  52275. declare module "babylonjs/Gizmos/gizmo" {
  52276. import { Nullable } from "babylonjs/types";
  52277. import { IDisposable } from "babylonjs/scene";
  52278. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  52279. import { Mesh } from "babylonjs/Meshes/mesh";
  52280. import { Node } from "babylonjs/node";
  52281. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  52282. /**
  52283. * Renders gizmos on top of an existing scene which provide controls for position, rotation, etc.
  52284. */
  52285. export class Gizmo implements IDisposable {
  52286. /** The utility layer the gizmo will be added to */
  52287. gizmoLayer: UtilityLayerRenderer;
  52288. /**
  52289. * The root mesh of the gizmo
  52290. */
  52291. _rootMesh: Mesh;
  52292. private _attachedMesh;
  52293. private _attachedNode;
  52294. /**
  52295. * Ratio for the scale of the gizmo (Default: 1)
  52296. */
  52297. protected _scaleRatio: number;
  52298. /**
  52299. * Ratio for the scale of the gizmo (Default: 1)
  52300. */
  52301. set scaleRatio(value: number);
  52302. get scaleRatio(): number;
  52303. /**
  52304. * If a custom mesh has been set (Default: false)
  52305. */
  52306. protected _customMeshSet: boolean;
  52307. /**
  52308. * Mesh that the gizmo will be attached to. (eg. on a drag gizmo the mesh that will be dragged)
  52309. * * When set, interactions will be enabled
  52310. */
  52311. get attachedMesh(): Nullable<AbstractMesh>;
  52312. set attachedMesh(value: Nullable<AbstractMesh>);
  52313. /**
  52314. * Node that the gizmo will be attached to. (eg. on a drag gizmo the mesh, bone or NodeTransform that will be dragged)
  52315. * * When set, interactions will be enabled
  52316. */
  52317. get attachedNode(): Nullable<Node>;
  52318. set attachedNode(value: Nullable<Node>);
  52319. /**
  52320. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  52321. * @param mesh The mesh to replace the default mesh of the gizmo
  52322. */
  52323. setCustomMesh(mesh: Mesh): void;
  52324. protected _updateGizmoRotationToMatchAttachedMesh: boolean;
  52325. /**
  52326. * If set the gizmo's rotation will be updated to match the attached mesh each frame (Default: true)
  52327. */
  52328. set updateGizmoRotationToMatchAttachedMesh(value: boolean);
  52329. get updateGizmoRotationToMatchAttachedMesh(): boolean;
  52330. /**
  52331. * If set the gizmo's position will be updated to match the attached mesh each frame (Default: true)
  52332. */
  52333. updateGizmoPositionToMatchAttachedMesh: boolean;
  52334. /**
  52335. * When set, the gizmo will always appear the same size no matter where the camera is (default: true)
  52336. */
  52337. updateScale: boolean;
  52338. protected _interactionsEnabled: boolean;
  52339. protected _attachedNodeChanged(value: Nullable<Node>): void;
  52340. private _beforeRenderObserver;
  52341. private _tempQuaternion;
  52342. private _tempVector;
  52343. private _tempVector2;
  52344. private _tempMatrix1;
  52345. private _tempMatrix2;
  52346. private _rightHandtoLeftHandMatrix;
  52347. /**
  52348. * Creates a gizmo
  52349. * @param gizmoLayer The utility layer the gizmo will be added to
  52350. */
  52351. constructor(
  52352. /** The utility layer the gizmo will be added to */
  52353. gizmoLayer?: UtilityLayerRenderer);
  52354. /**
  52355. * Updates the gizmo to match the attached mesh's position/rotation
  52356. */
  52357. protected _update(): void;
  52358. /**
  52359. * computes the rotation/scaling/position of the transform once the Node world matrix has changed.
  52360. * @param value Node, TransformNode or mesh
  52361. */
  52362. protected _matrixChanged(): void;
  52363. /**
  52364. * Disposes of the gizmo
  52365. */
  52366. dispose(): void;
  52367. }
  52368. }
  52369. declare module "babylonjs/Gizmos/planeDragGizmo" {
  52370. import { Observable } from "babylonjs/Misc/observable";
  52371. import { Nullable } from "babylonjs/types";
  52372. import { Vector3 } from "babylonjs/Maths/math.vector";
  52373. import { Color3 } from "babylonjs/Maths/math.color";
  52374. import { TransformNode } from "babylonjs/Meshes/transformNode";
  52375. import { Node } from "babylonjs/node";
  52376. import { PointerDragBehavior } from "babylonjs/Behaviors/Meshes/pointerDragBehavior";
  52377. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  52378. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  52379. import { StandardMaterial } from "babylonjs/Materials/standardMaterial";
  52380. import { Scene } from "babylonjs/scene";
  52381. import { PositionGizmo } from "babylonjs/Gizmos/positionGizmo";
  52382. /**
  52383. * Single plane drag gizmo
  52384. */
  52385. export class PlaneDragGizmo extends Gizmo {
  52386. /**
  52387. * Drag behavior responsible for the gizmos dragging interactions
  52388. */
  52389. dragBehavior: PointerDragBehavior;
  52390. private _pointerObserver;
  52391. /**
  52392. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  52393. */
  52394. snapDistance: number;
  52395. /**
  52396. * Event that fires each time the gizmo snaps to a new location.
  52397. * * snapDistance is the the change in distance
  52398. */
  52399. onSnapObservable: Observable<{
  52400. snapDistance: number;
  52401. }>;
  52402. private _plane;
  52403. private _coloredMaterial;
  52404. private _hoverMaterial;
  52405. private _isEnabled;
  52406. private _parent;
  52407. /** @hidden */
  52408. static _CreatePlane(scene: Scene, material: StandardMaterial): TransformNode;
  52409. /** @hidden */
  52410. static _CreateArrowInstance(scene: Scene, arrow: TransformNode): TransformNode;
  52411. /**
  52412. * Creates a PlaneDragGizmo
  52413. * @param gizmoLayer The utility layer the gizmo will be added to
  52414. * @param dragPlaneNormal The axis normal to which the gizmo will be able to drag on
  52415. * @param color The color of the gizmo
  52416. */
  52417. constructor(dragPlaneNormal: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<PositionGizmo>);
  52418. protected _attachedNodeChanged(value: Nullable<Node>): void;
  52419. /**
  52420. * If the gizmo is enabled
  52421. */
  52422. set isEnabled(value: boolean);
  52423. get isEnabled(): boolean;
  52424. /**
  52425. * Disposes of the gizmo
  52426. */
  52427. dispose(): void;
  52428. }
  52429. }
  52430. declare module "babylonjs/Gizmos/positionGizmo" {
  52431. import { Observable } from "babylonjs/Misc/observable";
  52432. import { Nullable } from "babylonjs/types";
  52433. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  52434. import { Node } from "babylonjs/node";
  52435. import { Mesh } from "babylonjs/Meshes/mesh";
  52436. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  52437. import { AxisDragGizmo } from "babylonjs/Gizmos/axisDragGizmo";
  52438. import { PlaneDragGizmo } from "babylonjs/Gizmos/planeDragGizmo";
  52439. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  52440. /**
  52441. * Gizmo that enables dragging a mesh along 3 axis
  52442. */
  52443. export class PositionGizmo extends Gizmo {
  52444. /**
  52445. * Internal gizmo used for interactions on the x axis
  52446. */
  52447. xGizmo: AxisDragGizmo;
  52448. /**
  52449. * Internal gizmo used for interactions on the y axis
  52450. */
  52451. yGizmo: AxisDragGizmo;
  52452. /**
  52453. * Internal gizmo used for interactions on the z axis
  52454. */
  52455. zGizmo: AxisDragGizmo;
  52456. /**
  52457. * Internal gizmo used for interactions on the yz plane
  52458. */
  52459. xPlaneGizmo: PlaneDragGizmo;
  52460. /**
  52461. * Internal gizmo used for interactions on the xz plane
  52462. */
  52463. yPlaneGizmo: PlaneDragGizmo;
  52464. /**
  52465. * Internal gizmo used for interactions on the xy plane
  52466. */
  52467. zPlaneGizmo: PlaneDragGizmo;
  52468. /**
  52469. * private variables
  52470. */
  52471. private _meshAttached;
  52472. private _nodeAttached;
  52473. private _snapDistance;
  52474. /** Fires an event when any of it's sub gizmos are dragged */
  52475. onDragStartObservable: Observable<unknown>;
  52476. /** Fires an event when any of it's sub gizmos are released from dragging */
  52477. onDragEndObservable: Observable<unknown>;
  52478. /**
  52479. * If set to true, planar drag is enabled
  52480. */
  52481. private _planarGizmoEnabled;
  52482. get attachedMesh(): Nullable<AbstractMesh>;
  52483. set attachedMesh(mesh: Nullable<AbstractMesh>);
  52484. get attachedNode(): Nullable<Node>;
  52485. set attachedNode(node: Nullable<Node>);
  52486. /**
  52487. * Creates a PositionGizmo
  52488. * @param gizmoLayer The utility layer the gizmo will be added to
  52489. @param thickness display gizmo axis thickness
  52490. */
  52491. constructor(gizmoLayer?: UtilityLayerRenderer, thickness?: number);
  52492. /**
  52493. * If the planar drag gizmo is enabled
  52494. * setting this will enable/disable XY, XZ and YZ planes regardless of individual gizmo settings.
  52495. */
  52496. set planarGizmoEnabled(value: boolean);
  52497. get planarGizmoEnabled(): boolean;
  52498. set updateGizmoRotationToMatchAttachedMesh(value: boolean);
  52499. get updateGizmoRotationToMatchAttachedMesh(): boolean;
  52500. /**
  52501. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  52502. */
  52503. set snapDistance(value: number);
  52504. get snapDistance(): number;
  52505. /**
  52506. * Ratio for the scale of the gizmo (Default: 1)
  52507. */
  52508. set scaleRatio(value: number);
  52509. get scaleRatio(): number;
  52510. /**
  52511. * Disposes of the gizmo
  52512. */
  52513. dispose(): void;
  52514. /**
  52515. * CustomMeshes are not supported by this gizmo
  52516. * @param mesh The mesh to replace the default mesh of the gizmo
  52517. */
  52518. setCustomMesh(mesh: Mesh): void;
  52519. }
  52520. }
  52521. declare module "babylonjs/Gizmos/axisDragGizmo" {
  52522. import { Observable } from "babylonjs/Misc/observable";
  52523. import { Nullable } from "babylonjs/types";
  52524. import { Vector3 } from "babylonjs/Maths/math.vector";
  52525. import { TransformNode } from "babylonjs/Meshes/transformNode";
  52526. import { Node } from "babylonjs/node";
  52527. import { PointerDragBehavior } from "babylonjs/Behaviors/Meshes/pointerDragBehavior";
  52528. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  52529. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  52530. import { StandardMaterial } from "babylonjs/Materials/standardMaterial";
  52531. import { Scene } from "babylonjs/scene";
  52532. import { PositionGizmo } from "babylonjs/Gizmos/positionGizmo";
  52533. import { Color3 } from "babylonjs/Maths/math.color";
  52534. /**
  52535. * Single axis drag gizmo
  52536. */
  52537. export class AxisDragGizmo extends Gizmo {
  52538. /**
  52539. * Drag behavior responsible for the gizmos dragging interactions
  52540. */
  52541. dragBehavior: PointerDragBehavior;
  52542. private _pointerObserver;
  52543. /**
  52544. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  52545. */
  52546. snapDistance: number;
  52547. /**
  52548. * Event that fires each time the gizmo snaps to a new location.
  52549. * * snapDistance is the the change in distance
  52550. */
  52551. onSnapObservable: Observable<{
  52552. snapDistance: number;
  52553. }>;
  52554. private _isEnabled;
  52555. private _parent;
  52556. private _arrow;
  52557. private _coloredMaterial;
  52558. private _hoverMaterial;
  52559. /** @hidden */
  52560. static _CreateArrow(scene: Scene, material: StandardMaterial, thickness?: number): TransformNode;
  52561. /** @hidden */
  52562. static _CreateArrowInstance(scene: Scene, arrow: TransformNode): TransformNode;
  52563. /**
  52564. * Creates an AxisDragGizmo
  52565. * @param gizmoLayer The utility layer the gizmo will be added to
  52566. * @param dragAxis The axis which the gizmo will be able to drag on
  52567. * @param color The color of the gizmo
  52568. * @param thickness display gizmo axis thickness
  52569. */
  52570. constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<PositionGizmo>, thickness?: number);
  52571. protected _attachedNodeChanged(value: Nullable<Node>): void;
  52572. /**
  52573. * If the gizmo is enabled
  52574. */
  52575. set isEnabled(value: boolean);
  52576. get isEnabled(): boolean;
  52577. /**
  52578. * Disposes of the gizmo
  52579. */
  52580. dispose(): void;
  52581. }
  52582. }
  52583. declare module "babylonjs/Debug/axesViewer" {
  52584. import { Vector3 } from "babylonjs/Maths/math.vector";
  52585. import { Nullable } from "babylonjs/types";
  52586. import { Scene } from "babylonjs/scene";
  52587. import { TransformNode } from "babylonjs/Meshes/transformNode";
  52588. /**
  52589. * The Axes viewer will show 3 axes in a specific point in space
  52590. */
  52591. export class AxesViewer {
  52592. private _xAxis;
  52593. private _yAxis;
  52594. private _zAxis;
  52595. private _scaleLinesFactor;
  52596. private _instanced;
  52597. /**
  52598. * Gets the hosting scene
  52599. */
  52600. scene: Nullable<Scene>;
  52601. /**
  52602. * Gets or sets a number used to scale line length
  52603. */
  52604. scaleLines: number;
  52605. /** Gets the node hierarchy used to render x-axis */
  52606. get xAxis(): TransformNode;
  52607. /** Gets the node hierarchy used to render y-axis */
  52608. get yAxis(): TransformNode;
  52609. /** Gets the node hierarchy used to render z-axis */
  52610. get zAxis(): TransformNode;
  52611. /**
  52612. * Creates a new AxesViewer
  52613. * @param scene defines the hosting scene
  52614. * @param scaleLines defines a number used to scale line length (1 by default)
  52615. * @param renderingGroupId defines a number used to set the renderingGroupId of the meshes (2 by default)
  52616. * @param xAxis defines the node hierarchy used to render the x-axis
  52617. * @param yAxis defines the node hierarchy used to render the y-axis
  52618. * @param zAxis defines the node hierarchy used to render the z-axis
  52619. */
  52620. constructor(scene: Scene, scaleLines?: number, renderingGroupId?: Nullable<number>, xAxis?: TransformNode, yAxis?: TransformNode, zAxis?: TransformNode);
  52621. /**
  52622. * Force the viewer to update
  52623. * @param position defines the position of the viewer
  52624. * @param xaxis defines the x axis of the viewer
  52625. * @param yaxis defines the y axis of the viewer
  52626. * @param zaxis defines the z axis of the viewer
  52627. */
  52628. update(position: Vector3, xaxis: Vector3, yaxis: Vector3, zaxis: Vector3): void;
  52629. /**
  52630. * Creates an instance of this axes viewer.
  52631. * @returns a new axes viewer with instanced meshes
  52632. */
  52633. createInstance(): AxesViewer;
  52634. /** Releases resources */
  52635. dispose(): void;
  52636. private static _SetRenderingGroupId;
  52637. }
  52638. }
  52639. declare module "babylonjs/Debug/boneAxesViewer" {
  52640. import { Nullable } from "babylonjs/types";
  52641. import { AxesViewer } from "babylonjs/Debug/axesViewer";
  52642. import { Vector3 } from "babylonjs/Maths/math.vector";
  52643. import { Mesh } from "babylonjs/Meshes/mesh";
  52644. import { Bone } from "babylonjs/Bones/bone";
  52645. import { Scene } from "babylonjs/scene";
  52646. /**
  52647. * The BoneAxesViewer will attach 3 axes to a specific bone of a specific mesh
  52648. * @see demo here: https://www.babylonjs-playground.com/#0DE8F4#8
  52649. */
  52650. export class BoneAxesViewer extends AxesViewer {
  52651. /**
  52652. * Gets or sets the target mesh where to display the axes viewer
  52653. */
  52654. mesh: Nullable<Mesh>;
  52655. /**
  52656. * Gets or sets the target bone where to display the axes viewer
  52657. */
  52658. bone: Nullable<Bone>;
  52659. /** Gets current position */
  52660. pos: Vector3;
  52661. /** Gets direction of X axis */
  52662. xaxis: Vector3;
  52663. /** Gets direction of Y axis */
  52664. yaxis: Vector3;
  52665. /** Gets direction of Z axis */
  52666. zaxis: Vector3;
  52667. /**
  52668. * Creates a new BoneAxesViewer
  52669. * @param scene defines the hosting scene
  52670. * @param bone defines the target bone
  52671. * @param mesh defines the target mesh
  52672. * @param scaleLines defines a scaling factor for line length (1 by default)
  52673. */
  52674. constructor(scene: Scene, bone: Bone, mesh: Mesh, scaleLines?: number);
  52675. /**
  52676. * Force the viewer to update
  52677. */
  52678. update(): void;
  52679. /** Releases resources */
  52680. dispose(): void;
  52681. }
  52682. }
  52683. declare module "babylonjs/Debug/debugLayer" {
  52684. import { Scene } from "babylonjs/scene";
  52685. /**
  52686. * Interface used to define scene explorer extensibility option
  52687. */
  52688. export interface IExplorerExtensibilityOption {
  52689. /**
  52690. * Define the option label
  52691. */
  52692. label: string;
  52693. /**
  52694. * Defines the action to execute on click
  52695. */
  52696. action: (entity: any) => void;
  52697. }
  52698. /**
  52699. * Defines a group of actions associated with a predicate to use when extending the Inspector scene explorer
  52700. */
  52701. export interface IExplorerExtensibilityGroup {
  52702. /**
  52703. * Defines a predicate to test if a given type mut be extended
  52704. */
  52705. predicate: (entity: any) => boolean;
  52706. /**
  52707. * Gets the list of options added to a type
  52708. */
  52709. entries: IExplorerExtensibilityOption[];
  52710. }
  52711. /**
  52712. * Interface used to define the options to use to create the Inspector
  52713. */
  52714. export interface IInspectorOptions {
  52715. /**
  52716. * Display in overlay mode (default: false)
  52717. */
  52718. overlay?: boolean;
  52719. /**
  52720. * HTML element to use as root (the parent of the rendering canvas will be used as default value)
  52721. */
  52722. globalRoot?: HTMLElement;
  52723. /**
  52724. * Display the Scene explorer
  52725. */
  52726. showExplorer?: boolean;
  52727. /**
  52728. * Display the property inspector
  52729. */
  52730. showInspector?: boolean;
  52731. /**
  52732. * Display in embed mode (both panes on the right)
  52733. */
  52734. embedMode?: boolean;
  52735. /**
  52736. * let the Inspector handles resize of the canvas when panes are resized (default to true)
  52737. */
  52738. handleResize?: boolean;
  52739. /**
  52740. * Allow the panes to popup (default: true)
  52741. */
  52742. enablePopup?: boolean;
  52743. /**
  52744. * Allow the panes to be closed by users (default: true)
  52745. */
  52746. enableClose?: boolean;
  52747. /**
  52748. * Optional list of extensibility entries
  52749. */
  52750. explorerExtensibility?: IExplorerExtensibilityGroup[];
  52751. /**
  52752. * Optional URL to get the inspector script from (by default it uses the babylonjs CDN).
  52753. */
  52754. inspectorURL?: string;
  52755. /**
  52756. * Optional initial tab (default to DebugLayerTab.Properties)
  52757. */
  52758. initialTab?: DebugLayerTab;
  52759. }
  52760. module "babylonjs/scene" {
  52761. interface Scene {
  52762. /**
  52763. * @hidden
  52764. * Backing field
  52765. */
  52766. _debugLayer: DebugLayer;
  52767. /**
  52768. * Gets the debug layer (aka Inspector) associated with the scene
  52769. * @see https://doc.babylonjs.com/features/playground_debuglayer
  52770. */
  52771. debugLayer: DebugLayer;
  52772. }
  52773. }
  52774. /**
  52775. * Enum of inspector action tab
  52776. */
  52777. export enum DebugLayerTab {
  52778. /**
  52779. * Properties tag (default)
  52780. */
  52781. Properties = 0,
  52782. /**
  52783. * Debug tab
  52784. */
  52785. Debug = 1,
  52786. /**
  52787. * Statistics tab
  52788. */
  52789. Statistics = 2,
  52790. /**
  52791. * Tools tab
  52792. */
  52793. Tools = 3,
  52794. /**
  52795. * Settings tab
  52796. */
  52797. Settings = 4
  52798. }
  52799. /**
  52800. * The debug layer (aka Inspector) is the go to tool in order to better understand
  52801. * what is happening in your scene
  52802. * @see https://doc.babylonjs.com/features/playground_debuglayer
  52803. */
  52804. export class DebugLayer {
  52805. /**
  52806. * Define the url to get the inspector script from.
  52807. * By default it uses the babylonjs CDN.
  52808. * @ignoreNaming
  52809. */
  52810. static InspectorURL: string;
  52811. private _scene;
  52812. private BJSINSPECTOR;
  52813. private _onPropertyChangedObservable?;
  52814. /**
  52815. * Observable triggered when a property is changed through the inspector.
  52816. */
  52817. get onPropertyChangedObservable(): any;
  52818. /**
  52819. * Instantiates a new debug layer.
  52820. * The debug layer (aka Inspector) is the go to tool in order to better understand
  52821. * what is happening in your scene
  52822. * @see https://doc.babylonjs.com/features/playground_debuglayer
  52823. * @param scene Defines the scene to inspect
  52824. */
  52825. constructor(scene: Scene);
  52826. /** Creates the inspector window. */
  52827. private _createInspector;
  52828. /**
  52829. * Select a specific entity in the scene explorer and highlight a specific block in that entity property grid
  52830. * @param entity defines the entity to select
  52831. * @param lineContainerTitles defines the specific blocks to highlight (could be a string or an array of strings)
  52832. */
  52833. select(entity: any, lineContainerTitles?: string | string[]): void;
  52834. /** Get the inspector from bundle or global */
  52835. private _getGlobalInspector;
  52836. /**
  52837. * Get if the inspector is visible or not.
  52838. * @returns true if visible otherwise, false
  52839. */
  52840. isVisible(): boolean;
  52841. /**
  52842. * Hide the inspector and close its window.
  52843. */
  52844. hide(): void;
  52845. /**
  52846. * Update the scene in the inspector
  52847. */
  52848. setAsActiveScene(): void;
  52849. /**
  52850. * Launch the debugLayer.
  52851. * @param config Define the configuration of the inspector
  52852. * @return a promise fulfilled when the debug layer is visible
  52853. */
  52854. show(config?: IInspectorOptions): Promise<DebugLayer>;
  52855. }
  52856. }
  52857. declare module "babylonjs/Meshes/Builders/boxBuilder" {
  52858. import { Nullable } from "babylonjs/types";
  52859. import { Scene } from "babylonjs/scene";
  52860. import { Vector4 } from "babylonjs/Maths/math.vector";
  52861. import { Color4 } from "babylonjs/Maths/math.color";
  52862. import { Mesh } from "babylonjs/Meshes/mesh";
  52863. /**
  52864. * Class containing static functions to help procedurally build meshes
  52865. */
  52866. export class BoxBuilder {
  52867. /**
  52868. * Creates a box mesh
  52869. * * The parameter `size` sets the size (float) of each box side (default 1)
  52870. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value of `size`)
  52871. * * 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)
  52872. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  52873. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  52874. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  52875. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  52876. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  52877. * @param name defines the name of the mesh
  52878. * @param options defines the options used to create the mesh
  52879. * @param scene defines the hosting scene
  52880. * @returns the box mesh
  52881. */
  52882. static CreateBox(name: string, options: {
  52883. size?: number;
  52884. width?: number;
  52885. height?: number;
  52886. depth?: number;
  52887. faceUV?: Vector4[];
  52888. faceColors?: Color4[];
  52889. sideOrientation?: number;
  52890. frontUVs?: Vector4;
  52891. backUVs?: Vector4;
  52892. wrap?: boolean;
  52893. topBaseAt?: number;
  52894. bottomBaseAt?: number;
  52895. updatable?: boolean;
  52896. }, scene?: Nullable<Scene>): Mesh;
  52897. }
  52898. }
  52899. declare module "babylonjs/Debug/physicsViewer" {
  52900. import { Nullable } from "babylonjs/types";
  52901. import { Scene } from "babylonjs/scene";
  52902. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  52903. import { Mesh } from "babylonjs/Meshes/mesh";
  52904. import { IPhysicsEnginePlugin } from "babylonjs/Physics/IPhysicsEngine";
  52905. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  52906. /**
  52907. * Used to show the physics impostor around the specific mesh
  52908. */
  52909. export class PhysicsViewer {
  52910. /** @hidden */
  52911. protected _impostors: Array<Nullable<PhysicsImpostor>>;
  52912. /** @hidden */
  52913. protected _meshes: Array<Nullable<AbstractMesh>>;
  52914. /** @hidden */
  52915. protected _scene: Nullable<Scene>;
  52916. /** @hidden */
  52917. protected _numMeshes: number;
  52918. /** @hidden */
  52919. protected _physicsEnginePlugin: Nullable<IPhysicsEnginePlugin>;
  52920. private _renderFunction;
  52921. private _utilityLayer;
  52922. private _debugBoxMesh;
  52923. private _debugSphereMesh;
  52924. private _debugCylinderMesh;
  52925. private _debugMaterial;
  52926. private _debugMeshMeshes;
  52927. /**
  52928. * Creates a new PhysicsViewer
  52929. * @param scene defines the hosting scene
  52930. */
  52931. constructor(scene: Scene);
  52932. /** @hidden */
  52933. protected _updateDebugMeshes(): void;
  52934. /**
  52935. * Renders a specified physic impostor
  52936. * @param impostor defines the impostor to render
  52937. * @param targetMesh defines the mesh represented by the impostor
  52938. * @returns the new debug mesh used to render the impostor
  52939. */
  52940. showImpostor(impostor: PhysicsImpostor, targetMesh?: Mesh): Nullable<AbstractMesh>;
  52941. /**
  52942. * Hides a specified physic impostor
  52943. * @param impostor defines the impostor to hide
  52944. */
  52945. hideImpostor(impostor: Nullable<PhysicsImpostor>): void;
  52946. private _getDebugMaterial;
  52947. private _getDebugBoxMesh;
  52948. private _getDebugSphereMesh;
  52949. private _getDebugCylinderMesh;
  52950. private _getDebugMeshMesh;
  52951. private _getDebugMesh;
  52952. /** Releases all resources */
  52953. dispose(): void;
  52954. }
  52955. }
  52956. declare module "babylonjs/Debug/rayHelper" {
  52957. import { Nullable } from "babylonjs/types";
  52958. import { Ray } from "babylonjs/Culling/ray";
  52959. import { Vector3 } from "babylonjs/Maths/math.vector";
  52960. import { Color3 } from "babylonjs/Maths/math.color";
  52961. import { Scene } from "babylonjs/scene";
  52962. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  52963. import "babylonjs/Meshes/Builders/linesBuilder";
  52964. /**
  52965. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  52966. * in order to better appreciate the issue one might have.
  52967. * @see https://doc.babylonjs.com/babylon101/raycasts#debugging
  52968. */
  52969. export class RayHelper {
  52970. /**
  52971. * Defines the ray we are currently tryin to visualize.
  52972. */
  52973. ray: Nullable<Ray>;
  52974. private _renderPoints;
  52975. private _renderLine;
  52976. private _renderFunction;
  52977. private _scene;
  52978. private _onAfterRenderObserver;
  52979. private _onAfterStepObserver;
  52980. private _attachedToMesh;
  52981. private _meshSpaceDirection;
  52982. private _meshSpaceOrigin;
  52983. /**
  52984. * Helper function to create a colored helper in a scene in one line.
  52985. * @param ray Defines the ray we are currently tryin to visualize
  52986. * @param scene Defines the scene the ray is used in
  52987. * @param color Defines the color we want to see the ray in
  52988. * @returns The newly created ray helper.
  52989. */
  52990. static CreateAndShow(ray: Ray, scene: Scene, color: Color3): RayHelper;
  52991. /**
  52992. * Instantiate a new ray helper.
  52993. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  52994. * in order to better appreciate the issue one might have.
  52995. * @see https://doc.babylonjs.com/babylon101/raycasts#debugging
  52996. * @param ray Defines the ray we are currently tryin to visualize
  52997. */
  52998. constructor(ray: Ray);
  52999. /**
  53000. * Shows the ray we are willing to debug.
  53001. * @param scene Defines the scene the ray needs to be rendered in
  53002. * @param color Defines the color the ray needs to be rendered in
  53003. */
  53004. show(scene: Scene, color?: Color3): void;
  53005. /**
  53006. * Hides the ray we are debugging.
  53007. */
  53008. hide(): void;
  53009. private _render;
  53010. /**
  53011. * Attach a ray helper to a mesh so that we can easily see its orientation for instance or information like its normals.
  53012. * @param mesh Defines the mesh we want the helper attached to
  53013. * @param meshSpaceDirection Defines the direction of the Ray in mesh space (local space of the mesh node)
  53014. * @param meshSpaceOrigin Defines the origin of the Ray in mesh space (local space of the mesh node)
  53015. * @param length Defines the length of the ray
  53016. */
  53017. attachToMesh(mesh: AbstractMesh, meshSpaceDirection?: Vector3, meshSpaceOrigin?: Vector3, length?: number): void;
  53018. /**
  53019. * Detach the ray helper from the mesh it has previously been attached to.
  53020. */
  53021. detachFromMesh(): void;
  53022. private _updateToMesh;
  53023. /**
  53024. * Dispose the helper and release its associated resources.
  53025. */
  53026. dispose(): void;
  53027. }
  53028. }
  53029. declare module "babylonjs/Debug/ISkeletonViewer" {
  53030. /**
  53031. * Defines the options associated with the creation of a SkeletonViewer.
  53032. */
  53033. export interface ISkeletonViewerOptions {
  53034. /** Should the system pause animations before building the Viewer? */
  53035. pauseAnimations: boolean;
  53036. /** Should the system return the skeleton to rest before building? */
  53037. returnToRest: boolean;
  53038. /** public Display Mode of the Viewer */
  53039. displayMode: number;
  53040. /** Flag to toggle if the Viewer should use the CPU for animations or not? */
  53041. displayOptions: ISkeletonViewerDisplayOptions;
  53042. /** Flag to toggle if the Viewer should use the CPU for animations or not? */
  53043. computeBonesUsingShaders: boolean;
  53044. }
  53045. /**
  53046. * Defines how to display the various bone meshes for the viewer.
  53047. */
  53048. export interface ISkeletonViewerDisplayOptions {
  53049. /** How far down to start tapering the bone spurs */
  53050. midStep?: number;
  53051. /** How big is the midStep? */
  53052. midStepFactor?: number;
  53053. /** Base for the Sphere Size */
  53054. sphereBaseSize?: number;
  53055. /** The ratio of the sphere to the longest bone in units */
  53056. sphereScaleUnit?: number;
  53057. /** Ratio for the Sphere Size */
  53058. sphereFactor?: number;
  53059. }
  53060. }
  53061. declare module "babylonjs/Meshes/Builders/ribbonBuilder" {
  53062. import { Nullable } from "babylonjs/types";
  53063. import { Scene } from "babylonjs/scene";
  53064. import { Vector3, Vector2, Vector4 } from "babylonjs/Maths/math.vector";
  53065. import { Color4 } from "babylonjs/Maths/math.color";
  53066. import { Mesh } from "babylonjs/Meshes/mesh";
  53067. /**
  53068. * Class containing static functions to help procedurally build meshes
  53069. */
  53070. export class RibbonBuilder {
  53071. /**
  53072. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  53073. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  53074. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  53075. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  53076. * * 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
  53077. * * 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
  53078. * * 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
  53079. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  53080. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  53081. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  53082. * * 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
  53083. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  53084. * * 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
  53085. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  53086. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  53087. * @param name defines the name of the mesh
  53088. * @param options defines the options used to create the mesh
  53089. * @param scene defines the hosting scene
  53090. * @returns the ribbon mesh
  53091. * @see https://doc.babylonjs.com/how_to/ribbon_tutorial
  53092. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  53093. */
  53094. static CreateRibbon(name: string, options: {
  53095. pathArray: Vector3[][];
  53096. closeArray?: boolean;
  53097. closePath?: boolean;
  53098. offset?: number;
  53099. updatable?: boolean;
  53100. sideOrientation?: number;
  53101. frontUVs?: Vector4;
  53102. backUVs?: Vector4;
  53103. instance?: Mesh;
  53104. invertUV?: boolean;
  53105. uvs?: Vector2[];
  53106. colors?: Color4[];
  53107. }, scene?: Nullable<Scene>): Mesh;
  53108. }
  53109. }
  53110. declare module "babylonjs/Meshes/Builders/shapeBuilder" {
  53111. import { Nullable } from "babylonjs/types";
  53112. import { Scene } from "babylonjs/scene";
  53113. import { Vector3, Vector4 } from "babylonjs/Maths/math.vector";
  53114. import { Mesh } from "babylonjs/Meshes/mesh";
  53115. /**
  53116. * Class containing static functions to help procedurally build meshes
  53117. */
  53118. export class ShapeBuilder {
  53119. /**
  53120. * 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.
  53121. * * 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.
  53122. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  53123. * * 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.
  53124. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  53125. * * 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
  53126. * * 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
  53127. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  53128. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  53129. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  53130. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  53131. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  53132. * @param name defines the name of the mesh
  53133. * @param options defines the options used to create the mesh
  53134. * @param scene defines the hosting scene
  53135. * @returns the extruded shape mesh
  53136. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  53137. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  53138. */
  53139. static ExtrudeShape(name: string, options: {
  53140. shape: Vector3[];
  53141. path: Vector3[];
  53142. scale?: number;
  53143. rotation?: number;
  53144. cap?: number;
  53145. updatable?: boolean;
  53146. sideOrientation?: number;
  53147. frontUVs?: Vector4;
  53148. backUVs?: Vector4;
  53149. instance?: Mesh;
  53150. invertUV?: boolean;
  53151. }, scene?: Nullable<Scene>): Mesh;
  53152. /**
  53153. * Creates an custom extruded shape mesh.
  53154. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  53155. * * 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.
  53156. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  53157. * * 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
  53158. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  53159. * * 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
  53160. * * It must returns a float value that will be the scale value applied to the shape on each path point
  53161. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  53162. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  53163. * * 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
  53164. * * 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
  53165. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  53166. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  53167. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  53168. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  53169. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  53170. * @param name defines the name of the mesh
  53171. * @param options defines the options used to create the mesh
  53172. * @param scene defines the hosting scene
  53173. * @returns the custom extruded shape mesh
  53174. * @see https://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  53175. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  53176. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  53177. */
  53178. static ExtrudeShapeCustom(name: string, options: {
  53179. shape: Vector3[];
  53180. path: Vector3[];
  53181. scaleFunction?: any;
  53182. rotationFunction?: any;
  53183. ribbonCloseArray?: boolean;
  53184. ribbonClosePath?: boolean;
  53185. cap?: number;
  53186. updatable?: boolean;
  53187. sideOrientation?: number;
  53188. frontUVs?: Vector4;
  53189. backUVs?: Vector4;
  53190. instance?: Mesh;
  53191. invertUV?: boolean;
  53192. }, scene?: Nullable<Scene>): Mesh;
  53193. private static _ExtrudeShapeGeneric;
  53194. }
  53195. }
  53196. declare module "babylonjs/Debug/skeletonViewer" {
  53197. import { Color3 } from "babylonjs/Maths/math.color";
  53198. import { Scene } from "babylonjs/scene";
  53199. import { Nullable } from "babylonjs/types";
  53200. import { Skeleton } from "babylonjs/Bones/skeleton";
  53201. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  53202. import { LinesMesh } from "babylonjs/Meshes/linesMesh";
  53203. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  53204. import { StandardMaterial } from "babylonjs/Materials/standardMaterial";
  53205. import { ISkeletonViewerOptions } from "babylonjs/Debug/ISkeletonViewer";
  53206. /**
  53207. * Class used to render a debug view of a given skeleton
  53208. * @see http://www.babylonjs-playground.com/#1BZJVJ#8
  53209. */
  53210. export class SkeletonViewer {
  53211. /** defines the skeleton to render */
  53212. skeleton: Skeleton;
  53213. /** defines the mesh attached to the skeleton */
  53214. mesh: AbstractMesh;
  53215. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  53216. autoUpdateBonesMatrices: boolean;
  53217. /** defines the rendering group id to use with the viewer */
  53218. renderingGroupId: number;
  53219. /** is the options for the viewer */
  53220. options: Partial<ISkeletonViewerOptions>;
  53221. /** public Display constants BABYLON.SkeletonViewer.DISPLAY_LINES */
  53222. static readonly DISPLAY_LINES: number;
  53223. /** public Display constants BABYLON.SkeletonViewer.DISPLAY_SPHERES */
  53224. static readonly DISPLAY_SPHERES: number;
  53225. /** public Display constants BABYLON.SkeletonViewer.DISPLAY_SPHERE_AND_SPURS */
  53226. static readonly DISPLAY_SPHERE_AND_SPURS: number;
  53227. /** If SkeletonViewer scene scope. */
  53228. private _scene;
  53229. /** Gets or sets the color used to render the skeleton */
  53230. color: Color3;
  53231. /** Array of the points of the skeleton fo the line view. */
  53232. private _debugLines;
  53233. /** The SkeletonViewers Mesh. */
  53234. private _debugMesh;
  53235. /** If SkeletonViewer is enabled. */
  53236. private _isEnabled;
  53237. /** If SkeletonViewer is ready. */
  53238. private _ready;
  53239. /** SkeletonViewer render observable. */
  53240. private _obs;
  53241. /** The Utility Layer to render the gizmos in. */
  53242. private _utilityLayer;
  53243. private _boneIndices;
  53244. /** Gets the Scene. */
  53245. get scene(): Scene;
  53246. /** Gets the utilityLayer. */
  53247. get utilityLayer(): Nullable<UtilityLayerRenderer>;
  53248. /** Checks Ready Status. */
  53249. get isReady(): Boolean;
  53250. /** Sets Ready Status. */
  53251. set ready(value: boolean);
  53252. /** Gets the debugMesh */
  53253. get debugMesh(): Nullable<AbstractMesh> | Nullable<LinesMesh>;
  53254. /** Sets the debugMesh */
  53255. set debugMesh(value: Nullable<AbstractMesh> | Nullable<LinesMesh>);
  53256. /** Gets the material */
  53257. get material(): StandardMaterial;
  53258. /** Sets the material */
  53259. set material(value: StandardMaterial);
  53260. /** Gets the material */
  53261. get displayMode(): number;
  53262. /** Sets the material */
  53263. set displayMode(value: number);
  53264. /**
  53265. * Creates a new SkeletonViewer
  53266. * @param skeleton defines the skeleton to render
  53267. * @param mesh defines the mesh attached to the skeleton
  53268. * @param scene defines the hosting scene
  53269. * @param autoUpdateBonesMatrices defines a boolean indicating if bones matrices must be forced to update before rendering (true by default)
  53270. * @param renderingGroupId defines the rendering group id to use with the viewer
  53271. * @param options All of the extra constructor options for the SkeletonViewer
  53272. */
  53273. constructor(
  53274. /** defines the skeleton to render */
  53275. skeleton: Skeleton,
  53276. /** defines the mesh attached to the skeleton */
  53277. mesh: AbstractMesh,
  53278. /** The Scene scope*/
  53279. scene: Scene,
  53280. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  53281. autoUpdateBonesMatrices?: boolean,
  53282. /** defines the rendering group id to use with the viewer */
  53283. renderingGroupId?: number,
  53284. /** is the options for the viewer */
  53285. options?: Partial<ISkeletonViewerOptions>);
  53286. /** The Dynamic bindings for the update functions */
  53287. private _bindObs;
  53288. /** Update the viewer to sync with current skeleton state, only used to manually update. */
  53289. update(): void;
  53290. /** Gets or sets a boolean indicating if the viewer is enabled */
  53291. set isEnabled(value: boolean);
  53292. get isEnabled(): boolean;
  53293. private _getBonePosition;
  53294. private _getLinesForBonesWithLength;
  53295. private _getLinesForBonesNoLength;
  53296. /** function to revert the mesh and scene back to the initial state. */
  53297. private _revert;
  53298. /** function to build and bind sphere joint points and spur bone representations. */
  53299. private _buildSpheresAndSpurs;
  53300. /** Update the viewer to sync with current skeleton state, only used for the line display. */
  53301. private _displayLinesUpdate;
  53302. /** Changes the displayMode of the skeleton viewer
  53303. * @param mode The displayMode numerical value
  53304. */
  53305. changeDisplayMode(mode: number): void;
  53306. /** Changes the displayMode of the skeleton viewer
  53307. * @param option String of the option name
  53308. * @param value The numerical option value
  53309. */
  53310. changeDisplayOptions(option: string, value: number): void;
  53311. /** Release associated resources */
  53312. dispose(): void;
  53313. }
  53314. }
  53315. declare module "babylonjs/Debug/index" {
  53316. export * from "babylonjs/Debug/axesViewer";
  53317. export * from "babylonjs/Debug/boneAxesViewer";
  53318. export * from "babylonjs/Debug/debugLayer";
  53319. export * from "babylonjs/Debug/physicsViewer";
  53320. export * from "babylonjs/Debug/rayHelper";
  53321. export * from "babylonjs/Debug/skeletonViewer";
  53322. export * from "babylonjs/Debug/ISkeletonViewer";
  53323. }
  53324. declare module "babylonjs/DeviceInput/InputDevices/deviceEnums" {
  53325. /**
  53326. * Enum for Device Types
  53327. */
  53328. export enum DeviceType {
  53329. /** Generic */
  53330. Generic = 0,
  53331. /** Keyboard */
  53332. Keyboard = 1,
  53333. /** Mouse */
  53334. Mouse = 2,
  53335. /** Touch Pointers */
  53336. Touch = 3,
  53337. /** PS4 Dual Shock */
  53338. DualShock = 4,
  53339. /** Xbox */
  53340. Xbox = 5,
  53341. /** Switch Controller */
  53342. Switch = 6
  53343. }
  53344. /**
  53345. * Enum for All Pointers (Touch/Mouse)
  53346. */
  53347. export enum PointerInput {
  53348. /** Horizontal Axis */
  53349. Horizontal = 0,
  53350. /** Vertical Axis */
  53351. Vertical = 1,
  53352. /** Left Click or Touch */
  53353. LeftClick = 2,
  53354. /** Middle Click */
  53355. MiddleClick = 3,
  53356. /** Right Click */
  53357. RightClick = 4,
  53358. /** Browser Back */
  53359. BrowserBack = 5,
  53360. /** Browser Forward */
  53361. BrowserForward = 6
  53362. }
  53363. /**
  53364. * Enum for Dual Shock Gamepad
  53365. */
  53366. export enum DualShockInput {
  53367. /** Cross */
  53368. Cross = 0,
  53369. /** Circle */
  53370. Circle = 1,
  53371. /** Square */
  53372. Square = 2,
  53373. /** Triangle */
  53374. Triangle = 3,
  53375. /** L1 */
  53376. L1 = 4,
  53377. /** R1 */
  53378. R1 = 5,
  53379. /** L2 */
  53380. L2 = 6,
  53381. /** R2 */
  53382. R2 = 7,
  53383. /** Share */
  53384. Share = 8,
  53385. /** Options */
  53386. Options = 9,
  53387. /** L3 */
  53388. L3 = 10,
  53389. /** R3 */
  53390. R3 = 11,
  53391. /** DPadUp */
  53392. DPadUp = 12,
  53393. /** DPadDown */
  53394. DPadDown = 13,
  53395. /** DPadLeft */
  53396. DPadLeft = 14,
  53397. /** DRight */
  53398. DPadRight = 15,
  53399. /** Home */
  53400. Home = 16,
  53401. /** TouchPad */
  53402. TouchPad = 17,
  53403. /** LStickXAxis */
  53404. LStickXAxis = 18,
  53405. /** LStickYAxis */
  53406. LStickYAxis = 19,
  53407. /** RStickXAxis */
  53408. RStickXAxis = 20,
  53409. /** RStickYAxis */
  53410. RStickYAxis = 21
  53411. }
  53412. /**
  53413. * Enum for Xbox Gamepad
  53414. */
  53415. export enum XboxInput {
  53416. /** A */
  53417. A = 0,
  53418. /** B */
  53419. B = 1,
  53420. /** X */
  53421. X = 2,
  53422. /** Y */
  53423. Y = 3,
  53424. /** LB */
  53425. LB = 4,
  53426. /** RB */
  53427. RB = 5,
  53428. /** LT */
  53429. LT = 6,
  53430. /** RT */
  53431. RT = 7,
  53432. /** Back */
  53433. Back = 8,
  53434. /** Start */
  53435. Start = 9,
  53436. /** LS */
  53437. LS = 10,
  53438. /** RS */
  53439. RS = 11,
  53440. /** DPadUp */
  53441. DPadUp = 12,
  53442. /** DPadDown */
  53443. DPadDown = 13,
  53444. /** DPadLeft */
  53445. DPadLeft = 14,
  53446. /** DRight */
  53447. DPadRight = 15,
  53448. /** Home */
  53449. Home = 16,
  53450. /** LStickXAxis */
  53451. LStickXAxis = 17,
  53452. /** LStickYAxis */
  53453. LStickYAxis = 18,
  53454. /** RStickXAxis */
  53455. RStickXAxis = 19,
  53456. /** RStickYAxis */
  53457. RStickYAxis = 20
  53458. }
  53459. /**
  53460. * Enum for Switch (Pro/JoyCon L+R) Gamepad
  53461. */
  53462. export enum SwitchInput {
  53463. /** B */
  53464. B = 0,
  53465. /** A */
  53466. A = 1,
  53467. /** Y */
  53468. Y = 2,
  53469. /** X */
  53470. X = 3,
  53471. /** L */
  53472. L = 4,
  53473. /** R */
  53474. R = 5,
  53475. /** ZL */
  53476. ZL = 6,
  53477. /** ZR */
  53478. ZR = 7,
  53479. /** Minus */
  53480. Minus = 8,
  53481. /** Plus */
  53482. Plus = 9,
  53483. /** LS */
  53484. LS = 10,
  53485. /** RS */
  53486. RS = 11,
  53487. /** DPadUp */
  53488. DPadUp = 12,
  53489. /** DPadDown */
  53490. DPadDown = 13,
  53491. /** DPadLeft */
  53492. DPadLeft = 14,
  53493. /** DRight */
  53494. DPadRight = 15,
  53495. /** Home */
  53496. Home = 16,
  53497. /** Capture */
  53498. Capture = 17,
  53499. /** LStickXAxis */
  53500. LStickXAxis = 18,
  53501. /** LStickYAxis */
  53502. LStickYAxis = 19,
  53503. /** RStickXAxis */
  53504. RStickXAxis = 20,
  53505. /** RStickYAxis */
  53506. RStickYAxis = 21
  53507. }
  53508. }
  53509. declare module "babylonjs/DeviceInput/deviceInputSystem" {
  53510. import { Engine } from "babylonjs/Engines/engine";
  53511. import { IDisposable } from "babylonjs/scene";
  53512. import { Nullable } from "babylonjs/types";
  53513. import { DeviceType } from "babylonjs/DeviceInput/InputDevices/deviceEnums";
  53514. /**
  53515. * This class will take all inputs from Keyboard, Pointer, and
  53516. * any Gamepads and provide a polling system that all devices
  53517. * will use. This class assumes that there will only be one
  53518. * pointer device and one keyboard.
  53519. */
  53520. export class DeviceInputSystem implements IDisposable {
  53521. /**
  53522. * Callback to be triggered when a device is connected
  53523. */
  53524. onDeviceConnected: (deviceType: DeviceType, deviceSlot: number) => void;
  53525. /**
  53526. * Callback to be triggered when a device is disconnected
  53527. */
  53528. onDeviceDisconnected: (deviceType: DeviceType, deviceSlot: number) => void;
  53529. /**
  53530. * Callback to be triggered when event driven input is updated
  53531. */
  53532. onInputChanged: (deviceType: DeviceType, deviceSlot: number, inputIndex: number, previousState: Nullable<number>, currentState: Nullable<number>) => void;
  53533. private _inputs;
  53534. private _gamepads;
  53535. private _keyboardActive;
  53536. private _pointerActive;
  53537. private _elementToAttachTo;
  53538. private _keyboardDownEvent;
  53539. private _keyboardUpEvent;
  53540. private _pointerMoveEvent;
  53541. private _pointerDownEvent;
  53542. private _pointerUpEvent;
  53543. private _gamepadConnectedEvent;
  53544. private _gamepadDisconnectedEvent;
  53545. private static _MAX_KEYCODES;
  53546. private static _MAX_POINTER_INPUTS;
  53547. private constructor();
  53548. /**
  53549. * Creates a new DeviceInputSystem instance
  53550. * @param engine Engine to pull input element from
  53551. * @returns The new instance
  53552. */
  53553. static Create(engine: Engine): DeviceInputSystem;
  53554. /**
  53555. * Checks for current device input value, given an id and input index
  53556. * @param deviceName Id of connected device
  53557. * @param inputIndex Index of device input
  53558. * @returns Current value of input
  53559. */
  53560. /**
  53561. * Checks for current device input value, given an id and input index. Throws exception if requested device not initialized.
  53562. * @param deviceType Enum specifiying device type
  53563. * @param deviceSlot "Slot" or index that device is referenced in
  53564. * @param inputIndex Id of input to be checked
  53565. * @returns Current value of input
  53566. */
  53567. pollInput(deviceType: DeviceType, deviceSlot: number, inputIndex: number): number;
  53568. /**
  53569. * Dispose of all the eventlisteners
  53570. */
  53571. dispose(): void;
  53572. /**
  53573. * Add device and inputs to device array
  53574. * @param deviceType Enum specifiying device type
  53575. * @param deviceSlot "Slot" or index that device is referenced in
  53576. * @param numberOfInputs Number of input entries to create for given device
  53577. */
  53578. private _registerDevice;
  53579. /**
  53580. * Given a specific device name, remove that device from the device map
  53581. * @param deviceType Enum specifiying device type
  53582. * @param deviceSlot "Slot" or index that device is referenced in
  53583. */
  53584. private _unregisterDevice;
  53585. /**
  53586. * Handle all actions that come from keyboard interaction
  53587. */
  53588. private _handleKeyActions;
  53589. /**
  53590. * Handle all actions that come from pointer interaction
  53591. */
  53592. private _handlePointerActions;
  53593. /**
  53594. * Handle all actions that come from gamepad interaction
  53595. */
  53596. private _handleGamepadActions;
  53597. /**
  53598. * Update all non-event based devices with each frame
  53599. * @param deviceType Enum specifiying device type
  53600. * @param deviceSlot "Slot" or index that device is referenced in
  53601. * @param inputIndex Id of input to be checked
  53602. */
  53603. private _updateDevice;
  53604. /**
  53605. * Gets DeviceType from the device name
  53606. * @param deviceName Name of Device from DeviceInputSystem
  53607. * @returns DeviceType enum value
  53608. */
  53609. private _getGamepadDeviceType;
  53610. }
  53611. }
  53612. declare module "babylonjs/DeviceInput/InputDevices/deviceTypes" {
  53613. import { DeviceType, PointerInput, DualShockInput, XboxInput, SwitchInput } from "babylonjs/DeviceInput/InputDevices/deviceEnums";
  53614. /**
  53615. * Type to handle enforcement of inputs
  53616. */
  53617. 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;
  53618. }
  53619. declare module "babylonjs/DeviceInput/InputDevices/deviceSourceManager" {
  53620. import { DeviceInputSystem } from "babylonjs/DeviceInput/deviceInputSystem";
  53621. import { Engine } from "babylonjs/Engines/engine";
  53622. import { IDisposable } from "babylonjs/scene";
  53623. import { DeviceType } from "babylonjs/DeviceInput/InputDevices/deviceEnums";
  53624. import { Nullable } from "babylonjs/types";
  53625. import { Observable } from "babylonjs/Misc/observable";
  53626. import { DeviceInput } from "babylonjs/DeviceInput/InputDevices/deviceTypes";
  53627. /**
  53628. * Class that handles all input for a specific device
  53629. */
  53630. export class DeviceSource<T extends DeviceType> {
  53631. /** Type of device */
  53632. readonly deviceType: DeviceType;
  53633. /** "Slot" or index that device is referenced in */
  53634. readonly deviceSlot: number;
  53635. /**
  53636. * Observable to handle device input changes per device
  53637. */
  53638. readonly onInputChangedObservable: Observable<{
  53639. inputIndex: DeviceInput<T>;
  53640. previousState: Nullable<number>;
  53641. currentState: Nullable<number>;
  53642. }>;
  53643. private readonly _deviceInputSystem;
  53644. /**
  53645. * Default Constructor
  53646. * @param deviceInputSystem Reference to DeviceInputSystem
  53647. * @param deviceType Type of device
  53648. * @param deviceSlot "Slot" or index that device is referenced in
  53649. */
  53650. constructor(deviceInputSystem: DeviceInputSystem,
  53651. /** Type of device */
  53652. deviceType: DeviceType,
  53653. /** "Slot" or index that device is referenced in */
  53654. deviceSlot?: number);
  53655. /**
  53656. * Get input for specific input
  53657. * @param inputIndex index of specific input on device
  53658. * @returns Input value from DeviceInputSystem
  53659. */
  53660. getInput(inputIndex: DeviceInput<T>): number;
  53661. }
  53662. /**
  53663. * Class to keep track of devices
  53664. */
  53665. export class DeviceSourceManager implements IDisposable {
  53666. /**
  53667. * Observable to be triggered when before a device is connected
  53668. */
  53669. readonly onBeforeDeviceConnectedObservable: Observable<{
  53670. deviceType: DeviceType;
  53671. deviceSlot: number;
  53672. }>;
  53673. /**
  53674. * Observable to be triggered when before a device is disconnected
  53675. */
  53676. readonly onBeforeDeviceDisconnectedObservable: Observable<{
  53677. deviceType: DeviceType;
  53678. deviceSlot: number;
  53679. }>;
  53680. /**
  53681. * Observable to be triggered when after a device is connected
  53682. */
  53683. readonly onAfterDeviceConnectedObservable: Observable<{
  53684. deviceType: DeviceType;
  53685. deviceSlot: number;
  53686. }>;
  53687. /**
  53688. * Observable to be triggered when after a device is disconnected
  53689. */
  53690. readonly onAfterDeviceDisconnectedObservable: Observable<{
  53691. deviceType: DeviceType;
  53692. deviceSlot: number;
  53693. }>;
  53694. private readonly _devices;
  53695. private readonly _firstDevice;
  53696. private readonly _deviceInputSystem;
  53697. /**
  53698. * Default Constructor
  53699. * @param engine engine to pull input element from
  53700. */
  53701. constructor(engine: Engine);
  53702. /**
  53703. * Gets a DeviceSource, given a type and slot
  53704. * @param deviceType Enum specifying device type
  53705. * @param deviceSlot "Slot" or index that device is referenced in
  53706. * @returns DeviceSource object
  53707. */
  53708. getDeviceSource<T extends DeviceType>(deviceType: T, deviceSlot?: number): Nullable<DeviceSource<T>>;
  53709. /**
  53710. * Gets an array of DeviceSource objects for a given device type
  53711. * @param deviceType Enum specifying device type
  53712. * @returns Array of DeviceSource objects
  53713. */
  53714. getDeviceSources<T extends DeviceType>(deviceType: T): ReadonlyArray<DeviceSource<T>>;
  53715. /**
  53716. * Dispose of DeviceInputSystem and other parts
  53717. */
  53718. dispose(): void;
  53719. /**
  53720. * Function to add device name to device list
  53721. * @param deviceType Enum specifying device type
  53722. * @param deviceSlot "Slot" or index that device is referenced in
  53723. */
  53724. private _addDevice;
  53725. /**
  53726. * Function to remove device name to device list
  53727. * @param deviceType Enum specifying device type
  53728. * @param deviceSlot "Slot" or index that device is referenced in
  53729. */
  53730. private _removeDevice;
  53731. /**
  53732. * Updates array storing first connected device of each type
  53733. * @param type Type of Device
  53734. */
  53735. private _updateFirstDevices;
  53736. }
  53737. }
  53738. declare module "babylonjs/DeviceInput/index" {
  53739. export * from "babylonjs/DeviceInput/deviceInputSystem";
  53740. export * from "babylonjs/DeviceInput/InputDevices/deviceEnums";
  53741. export * from "babylonjs/DeviceInput/InputDevices/deviceTypes";
  53742. import "babylonjs/DeviceInput/InputDevices/deviceSourceManager";
  53743. export * from "babylonjs/DeviceInput/InputDevices/deviceSourceManager";
  53744. }
  53745. declare module "babylonjs/Engines/nullEngine" {
  53746. import { Nullable, FloatArray, IndicesArray } from "babylonjs/types";
  53747. import { Engine } from "babylonjs/Engines/engine";
  53748. import { RenderTargetCreationOptions } from "babylonjs/Materials/Textures/renderTargetCreationOptions";
  53749. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  53750. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  53751. import { Effect } from "babylonjs/Materials/effect";
  53752. import { IPipelineContext } from "babylonjs/Engines/IPipelineContext";
  53753. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  53754. import { IColor4Like, IViewportLike } from "babylonjs/Maths/math.like";
  53755. import { ISceneLike } from "babylonjs/Engines/thinEngine";
  53756. /**
  53757. * Options to create the null engine
  53758. */
  53759. export class NullEngineOptions {
  53760. /**
  53761. * Render width (Default: 512)
  53762. */
  53763. renderWidth: number;
  53764. /**
  53765. * Render height (Default: 256)
  53766. */
  53767. renderHeight: number;
  53768. /**
  53769. * Texture size (Default: 512)
  53770. */
  53771. textureSize: number;
  53772. /**
  53773. * If delta time between frames should be constant
  53774. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  53775. */
  53776. deterministicLockstep: boolean;
  53777. /**
  53778. * Maximum about of steps between frames (Default: 4)
  53779. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  53780. */
  53781. lockstepMaxSteps: number;
  53782. /**
  53783. * Make the matrix computations to be performed in 64 bits instead of 32 bits. False by default
  53784. */
  53785. useHighPrecisionMatrix?: boolean;
  53786. }
  53787. /**
  53788. * The null engine class provides support for headless version of babylon.js.
  53789. * This can be used in server side scenario or for testing purposes
  53790. */
  53791. export class NullEngine extends Engine {
  53792. private _options;
  53793. /**
  53794. * Gets a boolean indicating that the engine is running in deterministic lock step mode
  53795. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  53796. * @returns true if engine is in deterministic lock step mode
  53797. */
  53798. isDeterministicLockStep(): boolean;
  53799. /**
  53800. * Gets the max steps when engine is running in deterministic lock step
  53801. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  53802. * @returns the max steps
  53803. */
  53804. getLockstepMaxSteps(): number;
  53805. /**
  53806. * Gets the current hardware scaling level.
  53807. * By default the hardware scaling level is computed from the window device ratio.
  53808. * 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.
  53809. * @returns a number indicating the current hardware scaling level
  53810. */
  53811. getHardwareScalingLevel(): number;
  53812. constructor(options?: NullEngineOptions);
  53813. /**
  53814. * Creates a vertex buffer
  53815. * @param vertices the data for the vertex buffer
  53816. * @returns the new WebGL static buffer
  53817. */
  53818. createVertexBuffer(vertices: FloatArray): DataBuffer;
  53819. /**
  53820. * Creates a new index buffer
  53821. * @param indices defines the content of the index buffer
  53822. * @param updatable defines if the index buffer must be updatable
  53823. * @returns a new webGL buffer
  53824. */
  53825. createIndexBuffer(indices: IndicesArray): DataBuffer;
  53826. /**
  53827. * Clear the current render buffer or the current render target (if any is set up)
  53828. * @param color defines the color to use
  53829. * @param backBuffer defines if the back buffer must be cleared
  53830. * @param depth defines if the depth buffer must be cleared
  53831. * @param stencil defines if the stencil buffer must be cleared
  53832. */
  53833. clear(color: IColor4Like, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  53834. /**
  53835. * Gets the current render width
  53836. * @param useScreen defines if screen size must be used (or the current render target if any)
  53837. * @returns a number defining the current render width
  53838. */
  53839. getRenderWidth(useScreen?: boolean): number;
  53840. /**
  53841. * Gets the current render height
  53842. * @param useScreen defines if screen size must be used (or the current render target if any)
  53843. * @returns a number defining the current render height
  53844. */
  53845. getRenderHeight(useScreen?: boolean): number;
  53846. /**
  53847. * Set the WebGL's viewport
  53848. * @param viewport defines the viewport element to be used
  53849. * @param requiredWidth defines the width required for rendering. If not provided the rendering canvas' width is used
  53850. * @param requiredHeight defines the height required for rendering. If not provided the rendering canvas' height is used
  53851. */
  53852. setViewport(viewport: IViewportLike, requiredWidth?: number, requiredHeight?: number): void;
  53853. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: string, context?: WebGLRenderingContext): WebGLProgram;
  53854. /**
  53855. * Gets the list of webGL uniform locations associated with a specific program based on a list of uniform names
  53856. * @param pipelineContext defines the pipeline context to use
  53857. * @param uniformsNames defines the list of uniform names
  53858. * @returns an array of webGL uniform locations
  53859. */
  53860. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): Nullable<WebGLUniformLocation>[];
  53861. /**
  53862. * Gets the lsit of active attributes for a given webGL program
  53863. * @param pipelineContext defines the pipeline context to use
  53864. * @param attributesNames defines the list of attribute names to get
  53865. * @returns an array of indices indicating the offset of each attribute
  53866. */
  53867. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  53868. /**
  53869. * Binds an effect to the webGL context
  53870. * @param effect defines the effect to bind
  53871. */
  53872. bindSamplers(effect: Effect): void;
  53873. /**
  53874. * Activates an effect, mkaing it the current one (ie. the one used for rendering)
  53875. * @param effect defines the effect to activate
  53876. */
  53877. enableEffect(effect: Effect): void;
  53878. /**
  53879. * Set various states to the webGL context
  53880. * @param culling defines backface culling state
  53881. * @param zOffset defines the value to apply to zOffset (0 by default)
  53882. * @param force defines if states must be applied even if cache is up to date
  53883. * @param reverseSide defines if culling must be reversed (CCW instead of CW and CW instead of CCW)
  53884. */
  53885. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  53886. /**
  53887. * Set the value of an uniform to an array of int32
  53888. * @param uniform defines the webGL uniform location where to store the value
  53889. * @param array defines the array of int32 to store
  53890. */
  53891. setIntArray(uniform: WebGLUniformLocation, array: Int32Array): void;
  53892. /**
  53893. * Set the value of an uniform to an array of int32 (stored as vec2)
  53894. * @param uniform defines the webGL uniform location where to store the value
  53895. * @param array defines the array of int32 to store
  53896. */
  53897. setIntArray2(uniform: WebGLUniformLocation, array: Int32Array): void;
  53898. /**
  53899. * Set the value of an uniform to an array of int32 (stored as vec3)
  53900. * @param uniform defines the webGL uniform location where to store the value
  53901. * @param array defines the array of int32 to store
  53902. */
  53903. setIntArray3(uniform: WebGLUniformLocation, array: Int32Array): void;
  53904. /**
  53905. * Set the value of an uniform to an array of int32 (stored as vec4)
  53906. * @param uniform defines the webGL uniform location where to store the value
  53907. * @param array defines the array of int32 to store
  53908. */
  53909. setIntArray4(uniform: WebGLUniformLocation, array: Int32Array): void;
  53910. /**
  53911. * Set the value of an uniform to an array of float32
  53912. * @param uniform defines the webGL uniform location where to store the value
  53913. * @param array defines the array of float32 to store
  53914. */
  53915. setFloatArray(uniform: WebGLUniformLocation, array: Float32Array): void;
  53916. /**
  53917. * Set the value of an uniform to an array of float32 (stored as vec2)
  53918. * @param uniform defines the webGL uniform location where to store the value
  53919. * @param array defines the array of float32 to store
  53920. */
  53921. setFloatArray2(uniform: WebGLUniformLocation, array: Float32Array): void;
  53922. /**
  53923. * Set the value of an uniform to an array of float32 (stored as vec3)
  53924. * @param uniform defines the webGL uniform location where to store the value
  53925. * @param array defines the array of float32 to store
  53926. */
  53927. setFloatArray3(uniform: WebGLUniformLocation, array: Float32Array): void;
  53928. /**
  53929. * Set the value of an uniform to an array of float32 (stored as vec4)
  53930. * @param uniform defines the webGL uniform location where to store the value
  53931. * @param array defines the array of float32 to store
  53932. */
  53933. setFloatArray4(uniform: WebGLUniformLocation, array: Float32Array): void;
  53934. /**
  53935. * Set the value of an uniform to an array of number
  53936. * @param uniform defines the webGL uniform location where to store the value
  53937. * @param array defines the array of number to store
  53938. */
  53939. setArray(uniform: WebGLUniformLocation, array: number[]): void;
  53940. /**
  53941. * Set the value of an uniform to an array of number (stored as vec2)
  53942. * @param uniform defines the webGL uniform location where to store the value
  53943. * @param array defines the array of number to store
  53944. */
  53945. setArray2(uniform: WebGLUniformLocation, array: number[]): void;
  53946. /**
  53947. * Set the value of an uniform to an array of number (stored as vec3)
  53948. * @param uniform defines the webGL uniform location where to store the value
  53949. * @param array defines the array of number to store
  53950. */
  53951. setArray3(uniform: WebGLUniformLocation, array: number[]): void;
  53952. /**
  53953. * Set the value of an uniform to an array of number (stored as vec4)
  53954. * @param uniform defines the webGL uniform location where to store the value
  53955. * @param array defines the array of number to store
  53956. */
  53957. setArray4(uniform: WebGLUniformLocation, array: number[]): void;
  53958. /**
  53959. * Set the value of an uniform to an array of float32 (stored as matrices)
  53960. * @param uniform defines the webGL uniform location where to store the value
  53961. * @param matrices defines the array of float32 to store
  53962. */
  53963. setMatrices(uniform: WebGLUniformLocation, matrices: Float32Array): void;
  53964. /**
  53965. * Set the value of an uniform to a matrix (3x3)
  53966. * @param uniform defines the webGL uniform location where to store the value
  53967. * @param matrix defines the Float32Array representing the 3x3 matrix to store
  53968. */
  53969. setMatrix3x3(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  53970. /**
  53971. * Set the value of an uniform to a matrix (2x2)
  53972. * @param uniform defines the webGL uniform location where to store the value
  53973. * @param matrix defines the Float32Array representing the 2x2 matrix to store
  53974. */
  53975. setMatrix2x2(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  53976. /**
  53977. * Set the value of an uniform to a number (float)
  53978. * @param uniform defines the webGL uniform location where to store the value
  53979. * @param value defines the float number to store
  53980. */
  53981. setFloat(uniform: WebGLUniformLocation, value: number): void;
  53982. /**
  53983. * Set the value of an uniform to a vec2
  53984. * @param uniform defines the webGL uniform location where to store the value
  53985. * @param x defines the 1st component of the value
  53986. * @param y defines the 2nd component of the value
  53987. */
  53988. setFloat2(uniform: WebGLUniformLocation, x: number, y: number): void;
  53989. /**
  53990. * Set the value of an uniform to a vec3
  53991. * @param uniform defines the webGL uniform location where to store the value
  53992. * @param x defines the 1st component of the value
  53993. * @param y defines the 2nd component of the value
  53994. * @param z defines the 3rd component of the value
  53995. */
  53996. setFloat3(uniform: WebGLUniformLocation, x: number, y: number, z: number): void;
  53997. /**
  53998. * Set the value of an uniform to a boolean
  53999. * @param uniform defines the webGL uniform location where to store the value
  54000. * @param bool defines the boolean to store
  54001. */
  54002. setBool(uniform: WebGLUniformLocation, bool: number): void;
  54003. /**
  54004. * Set the value of an uniform to a vec4
  54005. * @param uniform defines the webGL uniform location where to store the value
  54006. * @param x defines the 1st component of the value
  54007. * @param y defines the 2nd component of the value
  54008. * @param z defines the 3rd component of the value
  54009. * @param w defines the 4th component of the value
  54010. */
  54011. setFloat4(uniform: WebGLUniformLocation, x: number, y: number, z: number, w: number): void;
  54012. /**
  54013. * Sets the current alpha mode
  54014. * @param mode defines the mode to use (one of the Engine.ALPHA_XXX)
  54015. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  54016. * @see https://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  54017. */
  54018. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  54019. /**
  54020. * Bind webGl buffers directly to the webGL context
  54021. * @param vertexBuffers defines the vertex buffer to bind
  54022. * @param indexBuffer defines the index buffer to bind
  54023. * @param vertexDeclaration defines the vertex declaration to use with the vertex buffer
  54024. * @param vertexStrideSize defines the vertex stride of the vertex buffer
  54025. * @param effect defines the effect associated with the vertex buffer
  54026. */
  54027. bindBuffers(vertexBuffers: {
  54028. [key: string]: VertexBuffer;
  54029. }, indexBuffer: DataBuffer, effect: Effect): void;
  54030. /**
  54031. * Force the entire cache to be cleared
  54032. * You should not have to use this function unless your engine needs to share the webGL context with another engine
  54033. * @param bruteForce defines a boolean to force clearing ALL caches (including stencil, detoh and alpha states)
  54034. */
  54035. wipeCaches(bruteForce?: boolean): void;
  54036. /**
  54037. * Send a draw order
  54038. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  54039. * @param indexStart defines the starting index
  54040. * @param indexCount defines the number of index to draw
  54041. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  54042. */
  54043. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  54044. /**
  54045. * Draw a list of indexed primitives
  54046. * @param fillMode defines the primitive to use
  54047. * @param indexStart defines the starting index
  54048. * @param indexCount defines the number of index to draw
  54049. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  54050. */
  54051. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  54052. /**
  54053. * Draw a list of unindexed primitives
  54054. * @param fillMode defines the primitive to use
  54055. * @param verticesStart defines the index of first vertex to draw
  54056. * @param verticesCount defines the count of vertices to draw
  54057. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  54058. */
  54059. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  54060. /** @hidden */
  54061. _createTexture(): WebGLTexture;
  54062. /** @hidden */
  54063. _releaseTexture(texture: InternalTexture): void;
  54064. /**
  54065. * Usually called from Texture.ts.
  54066. * Passed information to create a WebGLTexture
  54067. * @param urlArg defines a value which contains one of the following:
  54068. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  54069. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  54070. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  54071. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  54072. * @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)
  54073. * @param scene needed for loading to the correct scene
  54074. * @param samplingMode mode with should be used sample / access the texture (Default: Texture.TRILINEAR_SAMPLINGMODE)
  54075. * @param onLoad optional callback to be called upon successful completion
  54076. * @param onError optional callback to be called upon failure
  54077. * @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
  54078. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  54079. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  54080. * @param forcedExtension defines the extension to use to pick the right loader
  54081. * @param mimeType defines an optional mime type
  54082. * @returns a InternalTexture for assignment back into BABYLON.Texture
  54083. */
  54084. 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;
  54085. /**
  54086. * Creates a new render target texture
  54087. * @param size defines the size of the texture
  54088. * @param options defines the options used to create the texture
  54089. * @returns a new render target texture stored in an InternalTexture
  54090. */
  54091. createRenderTargetTexture(size: any, options: boolean | RenderTargetCreationOptions): InternalTexture;
  54092. /**
  54093. * Update the sampling mode of a given texture
  54094. * @param samplingMode defines the required sampling mode
  54095. * @param texture defines the texture to update
  54096. */
  54097. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  54098. /**
  54099. * Binds the frame buffer to the specified texture.
  54100. * @param texture The texture to render to or null for the default canvas
  54101. * @param faceIndex The face of the texture to render to in case of cube texture
  54102. * @param requiredWidth The width of the target to render to
  54103. * @param requiredHeight The height of the target to render to
  54104. * @param forceFullscreenViewport Forces the viewport to be the entire texture/screen if true
  54105. * @param lodLevel defines le lod level to bind to the frame buffer
  54106. */
  54107. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean): void;
  54108. /**
  54109. * Unbind the current render target texture from the webGL context
  54110. * @param texture defines the render target texture to unbind
  54111. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  54112. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  54113. */
  54114. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  54115. /**
  54116. * Creates a dynamic vertex buffer
  54117. * @param vertices the data for the dynamic vertex buffer
  54118. * @returns the new WebGL dynamic buffer
  54119. */
  54120. createDynamicVertexBuffer(vertices: FloatArray): DataBuffer;
  54121. /**
  54122. * Update the content of a dynamic texture
  54123. * @param texture defines the texture to update
  54124. * @param canvas defines the canvas containing the source
  54125. * @param invertY defines if data must be stored with Y axis inverted
  54126. * @param premulAlpha defines if alpha is stored as premultiplied
  54127. * @param format defines the format of the data
  54128. * @param forceBindTexture if the texture should be forced to be bound eg. after a graphics context loss (Default: false)
  54129. */
  54130. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement, invertY: boolean, premulAlpha?: boolean, format?: number): void;
  54131. /**
  54132. * Gets a boolean indicating if all created effects are ready
  54133. * @returns true if all effects are ready
  54134. */
  54135. areAllEffectsReady(): boolean;
  54136. /**
  54137. * @hidden
  54138. * Get the current error code of the webGL context
  54139. * @returns the error code
  54140. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  54141. */
  54142. getError(): number;
  54143. /** @hidden */
  54144. _getUnpackAlignement(): number;
  54145. /** @hidden */
  54146. _unpackFlipY(value: boolean): void;
  54147. /**
  54148. * Update a dynamic index buffer
  54149. * @param indexBuffer defines the target index buffer
  54150. * @param indices defines the data to update
  54151. * @param offset defines the offset in the target index buffer where update should start
  54152. */
  54153. updateDynamicIndexBuffer(indexBuffer: WebGLBuffer, indices: IndicesArray, offset?: number): void;
  54154. /**
  54155. * Updates a dynamic vertex buffer.
  54156. * @param vertexBuffer the vertex buffer to update
  54157. * @param vertices the data used to update the vertex buffer
  54158. * @param byteOffset the byte offset of the data (optional)
  54159. * @param byteLength the byte length of the data (optional)
  54160. */
  54161. updateDynamicVertexBuffer(vertexBuffer: WebGLBuffer, vertices: FloatArray, byteOffset?: number, byteLength?: number): void;
  54162. /** @hidden */
  54163. _bindTextureDirectly(target: number, texture: InternalTexture): boolean;
  54164. /** @hidden */
  54165. _bindTexture(channel: number, texture: InternalTexture): void;
  54166. protected _deleteBuffer(buffer: WebGLBuffer): void;
  54167. /**
  54168. * 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
  54169. */
  54170. releaseEffects(): void;
  54171. displayLoadingUI(): void;
  54172. hideLoadingUI(): void;
  54173. /** @hidden */
  54174. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  54175. /** @hidden */
  54176. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  54177. /** @hidden */
  54178. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  54179. /** @hidden */
  54180. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  54181. }
  54182. }
  54183. declare module "babylonjs/Instrumentation/timeToken" {
  54184. import { Nullable } from "babylonjs/types";
  54185. /**
  54186. * @hidden
  54187. **/
  54188. export class _TimeToken {
  54189. _startTimeQuery: Nullable<WebGLQuery>;
  54190. _endTimeQuery: Nullable<WebGLQuery>;
  54191. _timeElapsedQuery: Nullable<WebGLQuery>;
  54192. _timeElapsedQueryEnded: boolean;
  54193. }
  54194. }
  54195. declare module "babylonjs/Engines/Extensions/engine.occlusionQuery" {
  54196. import { Nullable, int } from "babylonjs/types";
  54197. import { _TimeToken } from "babylonjs/Instrumentation/timeToken";
  54198. /** @hidden */
  54199. export class _OcclusionDataStorage {
  54200. /** @hidden */
  54201. occlusionInternalRetryCounter: number;
  54202. /** @hidden */
  54203. isOcclusionQueryInProgress: boolean;
  54204. /** @hidden */
  54205. isOccluded: boolean;
  54206. /** @hidden */
  54207. occlusionRetryCount: number;
  54208. /** @hidden */
  54209. occlusionType: number;
  54210. /** @hidden */
  54211. occlusionQueryAlgorithmType: number;
  54212. }
  54213. module "babylonjs/Engines/engine" {
  54214. interface Engine {
  54215. /**
  54216. * Create a new webGL query (you must be sure that queries are supported by checking getCaps() function)
  54217. * @return the new query
  54218. */
  54219. createQuery(): WebGLQuery;
  54220. /**
  54221. * Delete and release a webGL query
  54222. * @param query defines the query to delete
  54223. * @return the current engine
  54224. */
  54225. deleteQuery(query: WebGLQuery): Engine;
  54226. /**
  54227. * Check if a given query has resolved and got its value
  54228. * @param query defines the query to check
  54229. * @returns true if the query got its value
  54230. */
  54231. isQueryResultAvailable(query: WebGLQuery): boolean;
  54232. /**
  54233. * Gets the value of a given query
  54234. * @param query defines the query to check
  54235. * @returns the value of the query
  54236. */
  54237. getQueryResult(query: WebGLQuery): number;
  54238. /**
  54239. * Initiates an occlusion query
  54240. * @param algorithmType defines the algorithm to use
  54241. * @param query defines the query to use
  54242. * @returns the current engine
  54243. * @see https://doc.babylonjs.com/features/occlusionquery
  54244. */
  54245. beginOcclusionQuery(algorithmType: number, query: WebGLQuery): Engine;
  54246. /**
  54247. * Ends an occlusion query
  54248. * @see https://doc.babylonjs.com/features/occlusionquery
  54249. * @param algorithmType defines the algorithm to use
  54250. * @returns the current engine
  54251. */
  54252. endOcclusionQuery(algorithmType: number): Engine;
  54253. /**
  54254. * Starts a time query (used to measure time spent by the GPU on a specific frame)
  54255. * Please note that only one query can be issued at a time
  54256. * @returns a time token used to track the time span
  54257. */
  54258. startTimeQuery(): Nullable<_TimeToken>;
  54259. /**
  54260. * Ends a time query
  54261. * @param token defines the token used to measure the time span
  54262. * @returns the time spent (in ns)
  54263. */
  54264. endTimeQuery(token: _TimeToken): int;
  54265. /** @hidden */
  54266. _currentNonTimestampToken: Nullable<_TimeToken>;
  54267. /** @hidden */
  54268. _createTimeQuery(): WebGLQuery;
  54269. /** @hidden */
  54270. _deleteTimeQuery(query: WebGLQuery): void;
  54271. /** @hidden */
  54272. _getGlAlgorithmType(algorithmType: number): number;
  54273. /** @hidden */
  54274. _getTimeQueryResult(query: WebGLQuery): any;
  54275. /** @hidden */
  54276. _getTimeQueryAvailability(query: WebGLQuery): any;
  54277. }
  54278. }
  54279. module "babylonjs/Meshes/abstractMesh" {
  54280. interface AbstractMesh {
  54281. /**
  54282. * Backing filed
  54283. * @hidden
  54284. */
  54285. __occlusionDataStorage: _OcclusionDataStorage;
  54286. /**
  54287. * Access property
  54288. * @hidden
  54289. */
  54290. _occlusionDataStorage: _OcclusionDataStorage;
  54291. /**
  54292. * 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.
  54293. * The default value is -1 which means don't break the query and wait till the result
  54294. * @see https://doc.babylonjs.com/features/occlusionquery
  54295. */
  54296. occlusionRetryCount: number;
  54297. /**
  54298. * 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:
  54299. * * OCCLUSION_TYPE_NONE (Default Value): this option means no occlusion query whith the Mesh.
  54300. * * OCCLUSION_TYPE_OPTIMISTIC: this option is means use occlusion query and if occlusionRetryCount is reached and the query is broken show the mesh.
  54301. * * 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.
  54302. * @see https://doc.babylonjs.com/features/occlusionquery
  54303. */
  54304. occlusionType: number;
  54305. /**
  54306. * This property determines the type of occlusion query algorithm to run in WebGl, you can use:
  54307. * * AbstractMesh.OCCLUSION_ALGORITHM_TYPE_ACCURATE which is mapped to GL_ANY_SAMPLES_PASSED.
  54308. * * 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.
  54309. * @see https://doc.babylonjs.com/features/occlusionquery
  54310. */
  54311. occlusionQueryAlgorithmType: number;
  54312. /**
  54313. * 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
  54314. * @see https://doc.babylonjs.com/features/occlusionquery
  54315. */
  54316. isOccluded: boolean;
  54317. /**
  54318. * Flag to check the progress status of the query
  54319. * @see https://doc.babylonjs.com/features/occlusionquery
  54320. */
  54321. isOcclusionQueryInProgress: boolean;
  54322. }
  54323. }
  54324. }
  54325. declare module "babylonjs/Engines/Extensions/engine.transformFeedback" {
  54326. import { Nullable } from "babylonjs/types";
  54327. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  54328. /** @hidden */
  54329. export var _forceTransformFeedbackToBundle: boolean;
  54330. module "babylonjs/Engines/engine" {
  54331. interface Engine {
  54332. /**
  54333. * Creates a webGL transform feedback object
  54334. * Please makes sure to check webGLVersion property to check if you are running webGL 2+
  54335. * @returns the webGL transform feedback object
  54336. */
  54337. createTransformFeedback(): WebGLTransformFeedback;
  54338. /**
  54339. * Delete a webGL transform feedback object
  54340. * @param value defines the webGL transform feedback object to delete
  54341. */
  54342. deleteTransformFeedback(value: WebGLTransformFeedback): void;
  54343. /**
  54344. * Bind a webGL transform feedback object to the webgl context
  54345. * @param value defines the webGL transform feedback object to bind
  54346. */
  54347. bindTransformFeedback(value: Nullable<WebGLTransformFeedback>): void;
  54348. /**
  54349. * Begins a transform feedback operation
  54350. * @param usePoints defines if points or triangles must be used
  54351. */
  54352. beginTransformFeedback(usePoints: boolean): void;
  54353. /**
  54354. * Ends a transform feedback operation
  54355. */
  54356. endTransformFeedback(): void;
  54357. /**
  54358. * Specify the varyings to use with transform feedback
  54359. * @param program defines the associated webGL program
  54360. * @param value defines the list of strings representing the varying names
  54361. */
  54362. setTranformFeedbackVaryings(program: WebGLProgram, value: string[]): void;
  54363. /**
  54364. * Bind a webGL buffer for a transform feedback operation
  54365. * @param value defines the webGL buffer to bind
  54366. */
  54367. bindTransformFeedbackBuffer(value: Nullable<DataBuffer>): void;
  54368. }
  54369. }
  54370. }
  54371. declare module "babylonjs/Engines/Extensions/engine.views" {
  54372. import { Camera } from "babylonjs/Cameras/camera";
  54373. import { Nullable } from "babylonjs/types";
  54374. /**
  54375. * Class used to define an additional view for the engine
  54376. * @see https://doc.babylonjs.com/how_to/multi_canvases
  54377. */
  54378. export class EngineView {
  54379. /** Defines the canvas where to render the view */
  54380. target: HTMLCanvasElement;
  54381. /** Defines an optional camera used to render the view (will use active camera else) */
  54382. camera?: Camera;
  54383. }
  54384. module "babylonjs/Engines/engine" {
  54385. interface Engine {
  54386. /**
  54387. * Gets or sets the HTML element to use for attaching events
  54388. */
  54389. inputElement: Nullable<HTMLElement>;
  54390. /**
  54391. * Gets the current engine view
  54392. * @see https://doc.babylonjs.com/how_to/multi_canvases
  54393. */
  54394. activeView: Nullable<EngineView>;
  54395. /** Gets or sets the list of views */
  54396. views: EngineView[];
  54397. /**
  54398. * Register a new child canvas
  54399. * @param canvas defines the canvas to register
  54400. * @param camera defines an optional camera to use with this canvas (it will overwrite the scene.camera for this view)
  54401. * @returns the associated view
  54402. */
  54403. registerView(canvas: HTMLCanvasElement, camera?: Camera): EngineView;
  54404. /**
  54405. * Remove a registered child canvas
  54406. * @param canvas defines the canvas to remove
  54407. * @returns the current engine
  54408. */
  54409. unRegisterView(canvas: HTMLCanvasElement): Engine;
  54410. }
  54411. }
  54412. }
  54413. declare module "babylonjs/Engines/Extensions/engine.textureSelector" {
  54414. import { Nullable } from "babylonjs/types";
  54415. module "babylonjs/Engines/engine" {
  54416. interface Engine {
  54417. /** @hidden */
  54418. _excludedCompressedTextures: string[];
  54419. /** @hidden */
  54420. _textureFormatInUse: string;
  54421. /**
  54422. * Gets the list of texture formats supported
  54423. */
  54424. readonly texturesSupported: Array<string>;
  54425. /**
  54426. * Gets the texture format in use
  54427. */
  54428. readonly textureFormatInUse: Nullable<string>;
  54429. /**
  54430. * Set the compressed texture extensions or file names to skip.
  54431. *
  54432. * @param skippedFiles defines the list of those texture files you want to skip
  54433. * Example: [".dds", ".env", "myfile.png"]
  54434. */
  54435. setCompressedTextureExclusions(skippedFiles: Array<string>): void;
  54436. /**
  54437. * Set the compressed texture format to use, based on the formats you have, and the formats
  54438. * supported by the hardware / browser.
  54439. *
  54440. * Khronos Texture Container (.ktx) files are used to support this. This format has the
  54441. * advantage of being specifically designed for OpenGL. Header elements directly correspond
  54442. * to API arguments needed to compressed textures. This puts the burden on the container
  54443. * generator to house the arcane code for determining these for current & future formats.
  54444. *
  54445. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  54446. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  54447. *
  54448. * Note: The result of this call is not taken into account when a texture is base64.
  54449. *
  54450. * @param formatsAvailable defines the list of those format families you have created
  54451. * on your server. Syntax: '-' + format family + '.ktx'. (Case and order do not matter.)
  54452. *
  54453. * Current families are astc, dxt, pvrtc, etc2, & etc1.
  54454. * @returns The extension selected.
  54455. */
  54456. setTextureFormatToUse(formatsAvailable: Array<string>): Nullable<string>;
  54457. }
  54458. }
  54459. }
  54460. declare module "babylonjs/Engines/Extensions/index" {
  54461. export * from "babylonjs/Engines/Extensions/engine.alpha";
  54462. export * from "babylonjs/Engines/Extensions/engine.occlusionQuery";
  54463. export * from "babylonjs/Engines/Extensions/engine.transformFeedback";
  54464. export * from "babylonjs/Engines/Extensions/engine.multiview";
  54465. export * from "babylonjs/Engines/Extensions/engine.rawTexture";
  54466. export * from "babylonjs/Engines/Extensions/engine.dynamicTexture";
  54467. export * from "babylonjs/Engines/Extensions/engine.videoTexture";
  54468. export * from "babylonjs/Engines/Extensions/engine.multiRender";
  54469. export * from "babylonjs/Engines/Extensions/engine.cubeTexture";
  54470. export * from "babylonjs/Engines/Extensions/engine.renderTarget";
  54471. export * from "babylonjs/Engines/Extensions/engine.renderTargetCube";
  54472. export * from "babylonjs/Engines/Extensions/engine.webVR";
  54473. export * from "babylonjs/Engines/Extensions/engine.uniformBuffer";
  54474. export * from "babylonjs/Engines/Extensions/engine.dynamicBuffer";
  54475. export * from "babylonjs/Engines/Extensions/engine.views";
  54476. export * from "babylonjs/Engines/Extensions/engine.readTexture";
  54477. import "babylonjs/Engines/Extensions/engine.textureSelector";
  54478. export * from "babylonjs/Engines/Extensions/engine.textureSelector";
  54479. }
  54480. declare module "babylonjs/Misc/HighDynamicRange/panoramaToCubemap" {
  54481. import { Nullable } from "babylonjs/types";
  54482. /**
  54483. * CubeMap information grouping all the data for each faces as well as the cubemap size.
  54484. */
  54485. export interface CubeMapInfo {
  54486. /**
  54487. * The pixel array for the front face.
  54488. * This is stored in format, left to right, up to down format.
  54489. */
  54490. front: Nullable<ArrayBufferView>;
  54491. /**
  54492. * The pixel array for the back face.
  54493. * This is stored in format, left to right, up to down format.
  54494. */
  54495. back: Nullable<ArrayBufferView>;
  54496. /**
  54497. * The pixel array for the left face.
  54498. * This is stored in format, left to right, up to down format.
  54499. */
  54500. left: Nullable<ArrayBufferView>;
  54501. /**
  54502. * The pixel array for the right face.
  54503. * This is stored in format, left to right, up to down format.
  54504. */
  54505. right: Nullable<ArrayBufferView>;
  54506. /**
  54507. * The pixel array for the up face.
  54508. * This is stored in format, left to right, up to down format.
  54509. */
  54510. up: Nullable<ArrayBufferView>;
  54511. /**
  54512. * The pixel array for the down face.
  54513. * This is stored in format, left to right, up to down format.
  54514. */
  54515. down: Nullable<ArrayBufferView>;
  54516. /**
  54517. * The size of the cubemap stored.
  54518. *
  54519. * Each faces will be size * size pixels.
  54520. */
  54521. size: number;
  54522. /**
  54523. * The format of the texture.
  54524. *
  54525. * RGBA, RGB.
  54526. */
  54527. format: number;
  54528. /**
  54529. * The type of the texture data.
  54530. *
  54531. * UNSIGNED_INT, FLOAT.
  54532. */
  54533. type: number;
  54534. /**
  54535. * Specifies whether the texture is in gamma space.
  54536. */
  54537. gammaSpace: boolean;
  54538. }
  54539. /**
  54540. * Helper class useful to convert panorama picture to their cubemap representation in 6 faces.
  54541. */
  54542. export class PanoramaToCubeMapTools {
  54543. private static FACE_LEFT;
  54544. private static FACE_RIGHT;
  54545. private static FACE_FRONT;
  54546. private static FACE_BACK;
  54547. private static FACE_DOWN;
  54548. private static FACE_UP;
  54549. /**
  54550. * Converts a panorma stored in RGB right to left up to down format into a cubemap (6 faces).
  54551. *
  54552. * @param float32Array The source data.
  54553. * @param inputWidth The width of the input panorama.
  54554. * @param inputHeight The height of the input panorama.
  54555. * @param size The willing size of the generated cubemap (each faces will be size * size pixels)
  54556. * @return The cubemap data
  54557. */
  54558. static ConvertPanoramaToCubemap(float32Array: Float32Array, inputWidth: number, inputHeight: number, size: number): CubeMapInfo;
  54559. private static CreateCubemapTexture;
  54560. private static CalcProjectionSpherical;
  54561. }
  54562. }
  54563. declare module "babylonjs/Misc/HighDynamicRange/cubemapToSphericalPolynomial" {
  54564. import { SphericalPolynomial } from "babylonjs/Maths/sphericalPolynomial";
  54565. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  54566. import { Nullable } from "babylonjs/types";
  54567. import { CubeMapInfo } from "babylonjs/Misc/HighDynamicRange/panoramaToCubemap";
  54568. /**
  54569. * Helper class dealing with the extraction of spherical polynomial dataArray
  54570. * from a cube map.
  54571. */
  54572. export class CubeMapToSphericalPolynomialTools {
  54573. private static FileFaces;
  54574. /**
  54575. * Converts a texture to the according Spherical Polynomial data.
  54576. * This extracts the first 3 orders only as they are the only one used in the lighting.
  54577. *
  54578. * @param texture The texture to extract the information from.
  54579. * @return The Spherical Polynomial data.
  54580. */
  54581. static ConvertCubeMapTextureToSphericalPolynomial(texture: BaseTexture): Nullable<SphericalPolynomial>;
  54582. /**
  54583. * Converts a cubemap to the according Spherical Polynomial data.
  54584. * This extracts the first 3 orders only as they are the only one used in the lighting.
  54585. *
  54586. * @param cubeInfo The Cube map to extract the information from.
  54587. * @return The Spherical Polynomial data.
  54588. */
  54589. static ConvertCubeMapToSphericalPolynomial(cubeInfo: CubeMapInfo): SphericalPolynomial;
  54590. }
  54591. }
  54592. declare module "babylonjs/Materials/Textures/baseTexture.polynomial" {
  54593. import { Nullable } from "babylonjs/types";
  54594. import { SphericalPolynomial } from "babylonjs/Maths/sphericalPolynomial";
  54595. module "babylonjs/Materials/Textures/baseTexture" {
  54596. interface BaseTexture {
  54597. /**
  54598. * Get the polynomial representation of the texture data.
  54599. * This is mainly use as a fast way to recover IBL Diffuse irradiance data.
  54600. * @see https://learnopengl.com/PBR/IBL/Diffuse-irradiance
  54601. */
  54602. sphericalPolynomial: Nullable<SphericalPolynomial>;
  54603. }
  54604. }
  54605. }
  54606. declare module "babylonjs/Shaders/rgbdEncode.fragment" {
  54607. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  54608. /** @hidden */
  54609. export var rgbdEncodePixelShader: {
  54610. name: string;
  54611. shader: string;
  54612. };
  54613. }
  54614. declare module "babylonjs/Shaders/rgbdDecode.fragment" {
  54615. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  54616. /** @hidden */
  54617. export var rgbdDecodePixelShader: {
  54618. name: string;
  54619. shader: string;
  54620. };
  54621. }
  54622. declare module "babylonjs/Misc/environmentTextureTools" {
  54623. import { Nullable } from "babylonjs/types";
  54624. import { SphericalPolynomial } from "babylonjs/Maths/sphericalPolynomial";
  54625. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  54626. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  54627. import "babylonjs/Engines/Extensions/engine.renderTargetCube";
  54628. import "babylonjs/Engines/Extensions/engine.readTexture";
  54629. import "babylonjs/Materials/Textures/baseTexture.polynomial";
  54630. import "babylonjs/Shaders/rgbdEncode.fragment";
  54631. import "babylonjs/Shaders/rgbdDecode.fragment";
  54632. /**
  54633. * Raw texture data and descriptor sufficient for WebGL texture upload
  54634. */
  54635. export interface EnvironmentTextureInfo {
  54636. /**
  54637. * Version of the environment map
  54638. */
  54639. version: number;
  54640. /**
  54641. * Width of image
  54642. */
  54643. width: number;
  54644. /**
  54645. * Irradiance information stored in the file.
  54646. */
  54647. irradiance: any;
  54648. /**
  54649. * Specular information stored in the file.
  54650. */
  54651. specular: any;
  54652. }
  54653. /**
  54654. * Defines One Image in the file. It requires only the position in the file
  54655. * as well as the length.
  54656. */
  54657. interface BufferImageData {
  54658. /**
  54659. * Length of the image data.
  54660. */
  54661. length: number;
  54662. /**
  54663. * Position of the data from the null terminator delimiting the end of the JSON.
  54664. */
  54665. position: number;
  54666. }
  54667. /**
  54668. * Defines the specular data enclosed in the file.
  54669. * This corresponds to the version 1 of the data.
  54670. */
  54671. export interface EnvironmentTextureSpecularInfoV1 {
  54672. /**
  54673. * Defines where the specular Payload is located. It is a runtime value only not stored in the file.
  54674. */
  54675. specularDataPosition?: number;
  54676. /**
  54677. * This contains all the images data needed to reconstruct the cubemap.
  54678. */
  54679. mipmaps: Array<BufferImageData>;
  54680. /**
  54681. * Defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness.
  54682. */
  54683. lodGenerationScale: number;
  54684. }
  54685. /**
  54686. * Sets of helpers addressing the serialization and deserialization of environment texture
  54687. * stored in a BabylonJS env file.
  54688. * Those files are usually stored as .env files.
  54689. */
  54690. export class EnvironmentTextureTools {
  54691. /**
  54692. * Magic number identifying the env file.
  54693. */
  54694. private static _MagicBytes;
  54695. /**
  54696. * Gets the environment info from an env file.
  54697. * @param data The array buffer containing the .env bytes.
  54698. * @returns the environment file info (the json header) if successfully parsed.
  54699. */
  54700. static GetEnvInfo(data: ArrayBufferView): Nullable<EnvironmentTextureInfo>;
  54701. /**
  54702. * Creates an environment texture from a loaded cube texture.
  54703. * @param texture defines the cube texture to convert in env file
  54704. * @return a promise containing the environment data if succesfull.
  54705. */
  54706. static CreateEnvTextureAsync(texture: BaseTexture): Promise<ArrayBuffer>;
  54707. /**
  54708. * Creates a JSON representation of the spherical data.
  54709. * @param texture defines the texture containing the polynomials
  54710. * @return the JSON representation of the spherical info
  54711. */
  54712. private static _CreateEnvTextureIrradiance;
  54713. /**
  54714. * Creates the ArrayBufferViews used for initializing environment texture image data.
  54715. * @param data the image data
  54716. * @param info parameters that determine what views will be created for accessing the underlying buffer
  54717. * @return the views described by info providing access to the underlying buffer
  54718. */
  54719. static CreateImageDataArrayBufferViews(data: ArrayBufferView, info: EnvironmentTextureInfo): Array<Array<ArrayBufferView>>;
  54720. /**
  54721. * Uploads the texture info contained in the env file to the GPU.
  54722. * @param texture defines the internal texture to upload to
  54723. * @param data defines the data to load
  54724. * @param info defines the texture info retrieved through the GetEnvInfo method
  54725. * @returns a promise
  54726. */
  54727. static UploadEnvLevelsAsync(texture: InternalTexture, data: ArrayBufferView, info: EnvironmentTextureInfo): Promise<void>;
  54728. private static _OnImageReadyAsync;
  54729. /**
  54730. * Uploads the levels of image data to the GPU.
  54731. * @param texture defines the internal texture to upload to
  54732. * @param imageData defines the array buffer views of image data [mipmap][face]
  54733. * @returns a promise
  54734. */
  54735. static UploadLevelsAsync(texture: InternalTexture, imageData: ArrayBufferView[][]): Promise<void>;
  54736. /**
  54737. * Uploads spherical polynomials information to the texture.
  54738. * @param texture defines the texture we are trying to upload the information to
  54739. * @param info defines the environment texture info retrieved through the GetEnvInfo method
  54740. */
  54741. static UploadEnvSpherical(texture: InternalTexture, info: EnvironmentTextureInfo): void;
  54742. /** @hidden */
  54743. static _UpdateRGBDAsync(internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number): Promise<void>;
  54744. }
  54745. }
  54746. declare module "babylonjs/Engines/Processors/shaderCodeInliner" {
  54747. /**
  54748. * Class used to inline functions in shader code
  54749. */
  54750. export class ShaderCodeInliner {
  54751. private static readonly _RegexpFindFunctionNameAndType;
  54752. private _sourceCode;
  54753. private _functionDescr;
  54754. private _numMaxIterations;
  54755. /** Gets or sets the token used to mark the functions to inline */
  54756. inlineToken: string;
  54757. /** Gets or sets the debug mode */
  54758. debug: boolean;
  54759. /** Gets the code after the inlining process */
  54760. get code(): string;
  54761. /**
  54762. * Initializes the inliner
  54763. * @param sourceCode shader code source to inline
  54764. * @param numMaxIterations maximum number of iterations (used to detect recursive calls)
  54765. */
  54766. constructor(sourceCode: string, numMaxIterations?: number);
  54767. /**
  54768. * Start the processing of the shader code
  54769. */
  54770. processCode(): void;
  54771. private _collectFunctions;
  54772. private _processInlining;
  54773. private _extractBetweenMarkers;
  54774. private _skipWhitespaces;
  54775. private _removeComments;
  54776. private _replaceFunctionCallsByCode;
  54777. private _findBackward;
  54778. private _escapeRegExp;
  54779. private _replaceNames;
  54780. }
  54781. }
  54782. declare module "babylonjs/Engines/nativeEngine" {
  54783. import { Nullable, IndicesArray, DataArray } from "babylonjs/types";
  54784. import { Engine } from "babylonjs/Engines/engine";
  54785. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  54786. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  54787. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  54788. import { Effect } from "babylonjs/Materials/effect";
  54789. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  54790. import { Matrix, Viewport, Color3 } from "babylonjs/Maths/math";
  54791. import { IColor4Like } from "babylonjs/Maths/math.like";
  54792. import { Scene } from "babylonjs/scene";
  54793. import { RenderTargetCreationOptions } from "babylonjs/Materials/Textures/renderTargetCreationOptions";
  54794. import { IPipelineContext } from "babylonjs/Engines/IPipelineContext";
  54795. import { ISceneLike } from "babylonjs/Engines/thinEngine";
  54796. /**
  54797. * Container for accessors for natively-stored mesh data buffers.
  54798. */
  54799. class NativeDataBuffer extends DataBuffer {
  54800. /**
  54801. * Accessor value used to identify/retrieve a natively-stored index buffer.
  54802. */
  54803. nativeIndexBuffer?: any;
  54804. /**
  54805. * Accessor value used to identify/retrieve a natively-stored vertex buffer.
  54806. */
  54807. nativeVertexBuffer?: any;
  54808. }
  54809. /** @hidden */
  54810. class NativeTexture extends InternalTexture {
  54811. getInternalTexture(): InternalTexture;
  54812. getViewCount(): number;
  54813. }
  54814. /** @hidden */
  54815. export class NativeEngine extends Engine {
  54816. private readonly _native;
  54817. /** Defines the invalid handle returned by bgfx when resource creation goes wrong */
  54818. private readonly INVALID_HANDLE;
  54819. private _boundBuffersVertexArray;
  54820. getHardwareScalingLevel(): number;
  54821. constructor();
  54822. dispose(): void;
  54823. /**
  54824. * Can be used to override the current requestAnimationFrame requester.
  54825. * @hidden
  54826. */
  54827. protected _queueNewFrame(bindedRenderFunction: any, requester?: any): number;
  54828. /**
  54829. * Override default engine behavior.
  54830. * @param color
  54831. * @param backBuffer
  54832. * @param depth
  54833. * @param stencil
  54834. */
  54835. _bindUnboundFramebuffer(framebuffer: Nullable<WebGLFramebuffer>): void;
  54836. /**
  54837. * Gets host document
  54838. * @returns the host document object
  54839. */
  54840. getHostDocument(): Nullable<Document>;
  54841. clear(color: Nullable<IColor4Like>, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  54842. createIndexBuffer(indices: IndicesArray, updateable?: boolean): NativeDataBuffer;
  54843. createVertexBuffer(data: DataArray, updateable?: boolean): NativeDataBuffer;
  54844. protected _recordVertexArrayObject(vertexArray: any, vertexBuffers: {
  54845. [key: string]: VertexBuffer;
  54846. }, indexBuffer: Nullable<NativeDataBuffer>, effect: Effect): void;
  54847. bindBuffers(vertexBuffers: {
  54848. [key: string]: VertexBuffer;
  54849. }, indexBuffer: Nullable<NativeDataBuffer>, effect: Effect): void;
  54850. recordVertexArrayObject(vertexBuffers: {
  54851. [key: string]: VertexBuffer;
  54852. }, indexBuffer: Nullable<NativeDataBuffer>, effect: Effect): WebGLVertexArrayObject;
  54853. bindVertexArrayObject(vertexArray: WebGLVertexArrayObject): void;
  54854. releaseVertexArrayObject(vertexArray: WebGLVertexArrayObject): void;
  54855. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  54856. /**
  54857. * Draw a list of indexed primitives
  54858. * @param fillMode defines the primitive to use
  54859. * @param indexStart defines the starting index
  54860. * @param indexCount defines the number of index to draw
  54861. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  54862. */
  54863. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  54864. /**
  54865. * Draw a list of unindexed primitives
  54866. * @param fillMode defines the primitive to use
  54867. * @param verticesStart defines the index of first vertex to draw
  54868. * @param verticesCount defines the count of vertices to draw
  54869. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  54870. */
  54871. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  54872. createPipelineContext(): IPipelineContext;
  54873. _preparePipelineContext(pipelineContext: IPipelineContext, vertexSourceCode: string, fragmentSourceCode: string, createAsRaw: boolean, rebuildRebind: any, defines: Nullable<string>, transformFeedbackVaryings: Nullable<string[]>): void;
  54874. /** @hidden */
  54875. _isRenderingStateCompiled(pipelineContext: IPipelineContext): boolean;
  54876. /** @hidden */
  54877. _executeWhenRenderingStateIsCompiled(pipelineContext: IPipelineContext, action: () => void): void;
  54878. createRawShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): any;
  54879. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): any;
  54880. protected _setProgram(program: WebGLProgram): void;
  54881. _releaseEffect(effect: Effect): void;
  54882. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  54883. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): WebGLUniformLocation[];
  54884. bindUniformBlock(pipelineContext: IPipelineContext, blockName: string, index: number): void;
  54885. bindSamplers(effect: Effect): void;
  54886. setMatrix(uniform: WebGLUniformLocation, matrix: Matrix): void;
  54887. getRenderWidth(useScreen?: boolean): number;
  54888. getRenderHeight(useScreen?: boolean): number;
  54889. setViewport(viewport: Viewport, requiredWidth?: number, requiredHeight?: number): void;
  54890. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  54891. /**
  54892. * Set the z offset to apply to current rendering
  54893. * @param value defines the offset to apply
  54894. */
  54895. setZOffset(value: number): void;
  54896. /**
  54897. * Gets the current value of the zOffset
  54898. * @returns the current zOffset state
  54899. */
  54900. getZOffset(): number;
  54901. /**
  54902. * Enable or disable depth buffering
  54903. * @param enable defines the state to set
  54904. */
  54905. setDepthBuffer(enable: boolean): void;
  54906. /**
  54907. * Gets a boolean indicating if depth writing is enabled
  54908. * @returns the current depth writing state
  54909. */
  54910. getDepthWrite(): boolean;
  54911. /**
  54912. * Enable or disable depth writing
  54913. * @param enable defines the state to set
  54914. */
  54915. setDepthWrite(enable: boolean): void;
  54916. /**
  54917. * Enable or disable color writing
  54918. * @param enable defines the state to set
  54919. */
  54920. setColorWrite(enable: boolean): void;
  54921. /**
  54922. * Gets a boolean indicating if color writing is enabled
  54923. * @returns the current color writing state
  54924. */
  54925. getColorWrite(): boolean;
  54926. /**
  54927. * Sets alpha constants used by some alpha blending modes
  54928. * @param r defines the red component
  54929. * @param g defines the green component
  54930. * @param b defines the blue component
  54931. * @param a defines the alpha component
  54932. */
  54933. setAlphaConstants(r: number, g: number, b: number, a: number): void;
  54934. /**
  54935. * Sets the current alpha mode
  54936. * @param mode defines the mode to use (one of the BABYLON.Constants.ALPHA_XXX)
  54937. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  54938. * @see https://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  54939. */
  54940. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  54941. /**
  54942. * Gets the current alpha mode
  54943. * @see https://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  54944. * @returns the current alpha mode
  54945. */
  54946. getAlphaMode(): number;
  54947. setInt(uniform: WebGLUniformLocation, int: number): void;
  54948. setIntArray(uniform: WebGLUniformLocation, array: Int32Array): void;
  54949. setIntArray2(uniform: WebGLUniformLocation, array: Int32Array): void;
  54950. setIntArray3(uniform: WebGLUniformLocation, array: Int32Array): void;
  54951. setIntArray4(uniform: WebGLUniformLocation, array: Int32Array): void;
  54952. setFloatArray(uniform: WebGLUniformLocation, array: Float32Array): void;
  54953. setFloatArray2(uniform: WebGLUniformLocation, array: Float32Array): void;
  54954. setFloatArray3(uniform: WebGLUniformLocation, array: Float32Array): void;
  54955. setFloatArray4(uniform: WebGLUniformLocation, array: Float32Array): void;
  54956. setArray(uniform: WebGLUniformLocation, array: number[]): void;
  54957. setArray2(uniform: WebGLUniformLocation, array: number[]): void;
  54958. setArray3(uniform: WebGLUniformLocation, array: number[]): void;
  54959. setArray4(uniform: WebGLUniformLocation, array: number[]): void;
  54960. setMatrices(uniform: WebGLUniformLocation, matrices: Float32Array): void;
  54961. setMatrix3x3(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  54962. setMatrix2x2(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  54963. setFloat(uniform: WebGLUniformLocation, value: number): void;
  54964. setFloat2(uniform: WebGLUniformLocation, x: number, y: number): void;
  54965. setFloat3(uniform: WebGLUniformLocation, x: number, y: number, z: number): void;
  54966. setFloat4(uniform: WebGLUniformLocation, x: number, y: number, z: number, w: number): void;
  54967. setColor3(uniform: WebGLUniformLocation, color3: Color3): void;
  54968. setColor4(uniform: WebGLUniformLocation, color3: Color3, alpha: number): void;
  54969. wipeCaches(bruteForce?: boolean): void;
  54970. _createTexture(): WebGLTexture;
  54971. protected _deleteTexture(texture: Nullable<WebGLTexture>): void;
  54972. /**
  54973. * Usually called from Texture.ts.
  54974. * Passed information to create a WebGLTexture
  54975. * @param url defines a value which contains one of the following:
  54976. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  54977. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  54978. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  54979. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  54980. * @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)
  54981. * @param scene needed for loading to the correct scene
  54982. * @param samplingMode mode with should be used sample / access the texture (Default: Texture.TRILINEAR_SAMPLINGMODE)
  54983. * @param onLoad optional callback to be called upon successful completion
  54984. * @param onError optional callback to be called upon failure
  54985. * @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
  54986. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  54987. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  54988. * @param forcedExtension defines the extension to use to pick the right loader
  54989. * @param mimeType defines an optional mime type
  54990. * @returns a InternalTexture for assignment back into BABYLON.Texture
  54991. */
  54992. 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;
  54993. /**
  54994. * Creates a cube texture
  54995. * @param rootUrl defines the url where the files to load is located
  54996. * @param scene defines the current scene
  54997. * @param files defines the list of files to load (1 per face)
  54998. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  54999. * @param onLoad defines an optional callback raised when the texture is loaded
  55000. * @param onError defines an optional callback raised if there is an issue to load the texture
  55001. * @param format defines the format of the data
  55002. * @param forcedExtension defines the extension to use to pick the right loader
  55003. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  55004. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  55005. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  55006. * @param fallback defines texture to use while falling back when (compressed) texture file not found.
  55007. * @returns the cube texture as an InternalTexture
  55008. */
  55009. 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;
  55010. private _getSamplingFilter;
  55011. private static _GetNativeTextureFormat;
  55012. createRenderTargetTexture(size: number | {
  55013. width: number;
  55014. height: number;
  55015. }, options: boolean | RenderTargetCreationOptions): NativeTexture;
  55016. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  55017. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean): void;
  55018. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  55019. createDynamicVertexBuffer(data: DataArray): DataBuffer;
  55020. updateDynamicIndexBuffer(indexBuffer: DataBuffer, indices: IndicesArray, offset?: number): void;
  55021. /**
  55022. * Updates a dynamic vertex buffer.
  55023. * @param vertexBuffer the vertex buffer to update
  55024. * @param data the data used to update the vertex buffer
  55025. * @param byteOffset the byte offset of the data (optional)
  55026. * @param byteLength the byte length of the data (optional)
  55027. */
  55028. updateDynamicVertexBuffer(vertexBuffer: DataBuffer, data: DataArray, byteOffset?: number, byteLength?: number): void;
  55029. protected _setTexture(channel: number, texture: Nullable<BaseTexture>, isPartOfTextureArray?: boolean, depthStencilTexture?: boolean): boolean;
  55030. private _updateAnisotropicLevel;
  55031. private _getAddressMode;
  55032. /** @hidden */
  55033. _bindTexture(channel: number, texture: InternalTexture): void;
  55034. protected _deleteBuffer(buffer: NativeDataBuffer): void;
  55035. releaseEffects(): void;
  55036. /** @hidden */
  55037. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  55038. /** @hidden */
  55039. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  55040. /** @hidden */
  55041. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  55042. /** @hidden */
  55043. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  55044. }
  55045. }
  55046. declare module "babylonjs/Engines/index" {
  55047. export * from "babylonjs/Engines/constants";
  55048. export * from "babylonjs/Engines/engineCapabilities";
  55049. export * from "babylonjs/Engines/instancingAttributeInfo";
  55050. export * from "babylonjs/Engines/thinEngine";
  55051. export * from "babylonjs/Engines/engine";
  55052. export * from "babylonjs/Engines/engineStore";
  55053. export * from "babylonjs/Engines/nullEngine";
  55054. export * from "babylonjs/Engines/Extensions/index";
  55055. export * from "babylonjs/Engines/IPipelineContext";
  55056. export * from "babylonjs/Engines/WebGL/webGLPipelineContext";
  55057. export * from "babylonjs/Engines/WebGL/webGL2ShaderProcessors";
  55058. export * from "babylonjs/Engines/nativeEngine";
  55059. export * from "babylonjs/Engines/Processors/shaderCodeInliner";
  55060. export * from "babylonjs/Engines/performanceConfigurator";
  55061. }
  55062. declare module "babylonjs/Events/clipboardEvents" {
  55063. /**
  55064. * Gather the list of clipboard event types as constants.
  55065. */
  55066. export class ClipboardEventTypes {
  55067. /**
  55068. * The clipboard event is fired when a copy command is active (pressed).
  55069. */
  55070. static readonly COPY: number;
  55071. /**
  55072. * The clipboard event is fired when a cut command is active (pressed).
  55073. */
  55074. static readonly CUT: number;
  55075. /**
  55076. * The clipboard event is fired when a paste command is active (pressed).
  55077. */
  55078. static readonly PASTE: number;
  55079. }
  55080. /**
  55081. * This class is used to store clipboard related info for the onClipboardObservable event.
  55082. */
  55083. export class ClipboardInfo {
  55084. /**
  55085. * Defines the type of event (BABYLON.ClipboardEventTypes)
  55086. */
  55087. type: number;
  55088. /**
  55089. * Defines the related dom event
  55090. */
  55091. event: ClipboardEvent;
  55092. /**
  55093. *Creates an instance of ClipboardInfo.
  55094. * @param type Defines the type of event (BABYLON.ClipboardEventTypes)
  55095. * @param event Defines the related dom event
  55096. */
  55097. constructor(
  55098. /**
  55099. * Defines the type of event (BABYLON.ClipboardEventTypes)
  55100. */
  55101. type: number,
  55102. /**
  55103. * Defines the related dom event
  55104. */
  55105. event: ClipboardEvent);
  55106. /**
  55107. * Get the clipboard event's type from the keycode.
  55108. * @param keyCode Defines the keyCode for the current keyboard event.
  55109. * @return {number}
  55110. */
  55111. static GetTypeFromCharacter(keyCode: number): number;
  55112. }
  55113. }
  55114. declare module "babylonjs/Events/index" {
  55115. export * from "babylonjs/Events/keyboardEvents";
  55116. export * from "babylonjs/Events/pointerEvents";
  55117. export * from "babylonjs/Events/clipboardEvents";
  55118. }
  55119. declare module "babylonjs/Gamepads/Controllers/daydreamController" {
  55120. import { Scene } from "babylonjs/scene";
  55121. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  55122. import { GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  55123. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  55124. import { ExtendedGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  55125. /**
  55126. * Google Daydream controller
  55127. */
  55128. export class DaydreamController extends WebVRController {
  55129. /**
  55130. * Base Url for the controller model.
  55131. */
  55132. static MODEL_BASE_URL: string;
  55133. /**
  55134. * File name for the controller model.
  55135. */
  55136. static MODEL_FILENAME: string;
  55137. /**
  55138. * Gamepad Id prefix used to identify Daydream Controller.
  55139. */
  55140. static readonly GAMEPAD_ID_PREFIX: string;
  55141. /**
  55142. * Creates a new DaydreamController from a gamepad
  55143. * @param vrGamepad the gamepad that the controller should be created from
  55144. */
  55145. constructor(vrGamepad: any);
  55146. /**
  55147. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  55148. * @param scene scene in which to add meshes
  55149. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  55150. */
  55151. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  55152. /**
  55153. * Called once for each button that changed state since the last frame
  55154. * @param buttonIdx Which button index changed
  55155. * @param state New state of the button
  55156. * @param changes Which properties on the state changed since last frame
  55157. */
  55158. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  55159. }
  55160. }
  55161. declare module "babylonjs/Gamepads/Controllers/gearVRController" {
  55162. import { Scene } from "babylonjs/scene";
  55163. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  55164. import { GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  55165. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  55166. import { ExtendedGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  55167. /**
  55168. * Gear VR Controller
  55169. */
  55170. export class GearVRController extends WebVRController {
  55171. /**
  55172. * Base Url for the controller model.
  55173. */
  55174. static MODEL_BASE_URL: string;
  55175. /**
  55176. * File name for the controller model.
  55177. */
  55178. static MODEL_FILENAME: string;
  55179. /**
  55180. * Gamepad Id prefix used to identify this controller.
  55181. */
  55182. static readonly GAMEPAD_ID_PREFIX: string;
  55183. private readonly _buttonIndexToObservableNameMap;
  55184. /**
  55185. * Creates a new GearVRController from a gamepad
  55186. * @param vrGamepad the gamepad that the controller should be created from
  55187. */
  55188. constructor(vrGamepad: any);
  55189. /**
  55190. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  55191. * @param scene scene in which to add meshes
  55192. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  55193. */
  55194. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  55195. /**
  55196. * Called once for each button that changed state since the last frame
  55197. * @param buttonIdx Which button index changed
  55198. * @param state New state of the button
  55199. * @param changes Which properties on the state changed since last frame
  55200. */
  55201. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  55202. }
  55203. }
  55204. declare module "babylonjs/Gamepads/Controllers/genericController" {
  55205. import { Scene } from "babylonjs/scene";
  55206. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  55207. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  55208. import { ExtendedGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  55209. import { GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  55210. /**
  55211. * Generic Controller
  55212. */
  55213. export class GenericController extends WebVRController {
  55214. /**
  55215. * Base Url for the controller model.
  55216. */
  55217. static readonly MODEL_BASE_URL: string;
  55218. /**
  55219. * File name for the controller model.
  55220. */
  55221. static readonly MODEL_FILENAME: string;
  55222. /**
  55223. * Creates a new GenericController from a gamepad
  55224. * @param vrGamepad the gamepad that the controller should be created from
  55225. */
  55226. constructor(vrGamepad: any);
  55227. /**
  55228. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  55229. * @param scene scene in which to add meshes
  55230. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  55231. */
  55232. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  55233. /**
  55234. * Called once for each button that changed state since the last frame
  55235. * @param buttonIdx Which button index changed
  55236. * @param state New state of the button
  55237. * @param changes Which properties on the state changed since last frame
  55238. */
  55239. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  55240. }
  55241. }
  55242. declare module "babylonjs/Gamepads/Controllers/oculusTouchController" {
  55243. import { Observable } from "babylonjs/Misc/observable";
  55244. import { Scene } from "babylonjs/scene";
  55245. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  55246. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  55247. import { ExtendedGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  55248. import { GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  55249. /**
  55250. * Oculus Touch Controller
  55251. */
  55252. export class OculusTouchController extends WebVRController {
  55253. /**
  55254. * Base Url for the controller model.
  55255. */
  55256. static MODEL_BASE_URL: string;
  55257. /**
  55258. * File name for the left controller model.
  55259. */
  55260. static MODEL_LEFT_FILENAME: string;
  55261. /**
  55262. * File name for the right controller model.
  55263. */
  55264. static MODEL_RIGHT_FILENAME: string;
  55265. /**
  55266. * Base Url for the Quest controller model.
  55267. */
  55268. static QUEST_MODEL_BASE_URL: string;
  55269. /**
  55270. * @hidden
  55271. * If the controllers are running on a device that needs the updated Quest controller models
  55272. */
  55273. static _IsQuest: boolean;
  55274. /**
  55275. * Fired when the secondary trigger on this controller is modified
  55276. */
  55277. onSecondaryTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  55278. /**
  55279. * Fired when the thumb rest on this controller is modified
  55280. */
  55281. onThumbRestChangedObservable: Observable<ExtendedGamepadButton>;
  55282. /**
  55283. * Creates a new OculusTouchController from a gamepad
  55284. * @param vrGamepad the gamepad that the controller should be created from
  55285. */
  55286. constructor(vrGamepad: any);
  55287. /**
  55288. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  55289. * @param scene scene in which to add meshes
  55290. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  55291. */
  55292. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  55293. /**
  55294. * Fired when the A button on this controller is modified
  55295. */
  55296. get onAButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  55297. /**
  55298. * Fired when the B button on this controller is modified
  55299. */
  55300. get onBButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  55301. /**
  55302. * Fired when the X button on this controller is modified
  55303. */
  55304. get onXButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  55305. /**
  55306. * Fired when the Y button on this controller is modified
  55307. */
  55308. get onYButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  55309. /**
  55310. * Called once for each button that changed state since the last frame
  55311. * 0) thumb stick (touch, press, value = pressed (0,1)). value is in this.leftStick
  55312. * 1) index trigger (touch (?), press (only when value > 0.1), value 0 to 1)
  55313. * 2) secondary trigger (same)
  55314. * 3) A (right) X (left), touch, pressed = value
  55315. * 4) B / Y
  55316. * 5) thumb rest
  55317. * @param buttonIdx Which button index changed
  55318. * @param state New state of the button
  55319. * @param changes Which properties on the state changed since last frame
  55320. */
  55321. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  55322. }
  55323. }
  55324. declare module "babylonjs/Gamepads/Controllers/viveController" {
  55325. import { Scene } from "babylonjs/scene";
  55326. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  55327. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  55328. import { ExtendedGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  55329. import { GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  55330. import { Observable } from "babylonjs/Misc/observable";
  55331. /**
  55332. * Vive Controller
  55333. */
  55334. export class ViveController extends WebVRController {
  55335. /**
  55336. * Base Url for the controller model.
  55337. */
  55338. static MODEL_BASE_URL: string;
  55339. /**
  55340. * File name for the controller model.
  55341. */
  55342. static MODEL_FILENAME: string;
  55343. /**
  55344. * Creates a new ViveController from a gamepad
  55345. * @param vrGamepad the gamepad that the controller should be created from
  55346. */
  55347. constructor(vrGamepad: any);
  55348. /**
  55349. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  55350. * @param scene scene in which to add meshes
  55351. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  55352. */
  55353. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  55354. /**
  55355. * Fired when the left button on this controller is modified
  55356. */
  55357. get onLeftButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  55358. /**
  55359. * Fired when the right button on this controller is modified
  55360. */
  55361. get onRightButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  55362. /**
  55363. * Fired when the menu button on this controller is modified
  55364. */
  55365. get onMenuButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  55366. /**
  55367. * Called once for each button that changed state since the last frame
  55368. * Vive mapping:
  55369. * 0: touchpad
  55370. * 1: trigger
  55371. * 2: left AND right buttons
  55372. * 3: menu button
  55373. * @param buttonIdx Which button index changed
  55374. * @param state New state of the button
  55375. * @param changes Which properties on the state changed since last frame
  55376. */
  55377. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  55378. }
  55379. }
  55380. declare module "babylonjs/Gamepads/Controllers/windowsMotionController" {
  55381. import { Observable } from "babylonjs/Misc/observable";
  55382. import { Scene } from "babylonjs/scene";
  55383. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  55384. import { Ray } from "babylonjs/Culling/ray";
  55385. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  55386. import { ExtendedGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  55387. import { StickValues, GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  55388. /**
  55389. * Defines the WindowsMotionController object that the state of the windows motion controller
  55390. */
  55391. export class WindowsMotionController extends WebVRController {
  55392. /**
  55393. * The base url used to load the left and right controller models
  55394. */
  55395. static MODEL_BASE_URL: string;
  55396. /**
  55397. * The name of the left controller model file
  55398. */
  55399. static MODEL_LEFT_FILENAME: string;
  55400. /**
  55401. * The name of the right controller model file
  55402. */
  55403. static MODEL_RIGHT_FILENAME: string;
  55404. /**
  55405. * The controller name prefix for this controller type
  55406. */
  55407. static readonly GAMEPAD_ID_PREFIX: string;
  55408. /**
  55409. * The controller id pattern for this controller type
  55410. */
  55411. private static readonly GAMEPAD_ID_PATTERN;
  55412. private _loadedMeshInfo;
  55413. protected readonly _mapping: {
  55414. buttons: string[];
  55415. buttonMeshNames: {
  55416. trigger: string;
  55417. menu: string;
  55418. grip: string;
  55419. thumbstick: string;
  55420. trackpad: string;
  55421. };
  55422. buttonObservableNames: {
  55423. trigger: string;
  55424. menu: string;
  55425. grip: string;
  55426. thumbstick: string;
  55427. trackpad: string;
  55428. };
  55429. axisMeshNames: string[];
  55430. pointingPoseMeshName: string;
  55431. };
  55432. /**
  55433. * Fired when the trackpad on this controller is clicked
  55434. */
  55435. onTrackpadChangedObservable: Observable<ExtendedGamepadButton>;
  55436. /**
  55437. * Fired when the trackpad on this controller is modified
  55438. */
  55439. onTrackpadValuesChangedObservable: Observable<StickValues>;
  55440. /**
  55441. * The current x and y values of this controller's trackpad
  55442. */
  55443. trackpad: StickValues;
  55444. /**
  55445. * Creates a new WindowsMotionController from a gamepad
  55446. * @param vrGamepad the gamepad that the controller should be created from
  55447. */
  55448. constructor(vrGamepad: any);
  55449. /**
  55450. * Fired when the trigger on this controller is modified
  55451. */
  55452. get onTriggerButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  55453. /**
  55454. * Fired when the menu button on this controller is modified
  55455. */
  55456. get onMenuButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  55457. /**
  55458. * Fired when the grip button on this controller is modified
  55459. */
  55460. get onGripButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  55461. /**
  55462. * Fired when the thumbstick button on this controller is modified
  55463. */
  55464. get onThumbstickButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  55465. /**
  55466. * Fired when the touchpad button on this controller is modified
  55467. */
  55468. get onTouchpadButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  55469. /**
  55470. * Fired when the touchpad values on this controller are modified
  55471. */
  55472. get onTouchpadValuesChangedObservable(): Observable<StickValues>;
  55473. protected _updateTrackpad(): void;
  55474. /**
  55475. * Called once per frame by the engine.
  55476. */
  55477. update(): void;
  55478. /**
  55479. * Called once for each button that changed state since the last frame
  55480. * @param buttonIdx Which button index changed
  55481. * @param state New state of the button
  55482. * @param changes Which properties on the state changed since last frame
  55483. */
  55484. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  55485. /**
  55486. * Moves the buttons on the controller mesh based on their current state
  55487. * @param buttonName the name of the button to move
  55488. * @param buttonValue the value of the button which determines the buttons new position
  55489. */
  55490. protected _lerpButtonTransform(buttonName: string, buttonValue: number): void;
  55491. /**
  55492. * Moves the axis on the controller mesh based on its current state
  55493. * @param axis the index of the axis
  55494. * @param axisValue the value of the axis which determines the meshes new position
  55495. * @hidden
  55496. */
  55497. protected _lerpAxisTransform(axis: number, axisValue: number): void;
  55498. /**
  55499. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  55500. * @param scene scene in which to add meshes
  55501. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  55502. */
  55503. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void, forceDefault?: boolean): void;
  55504. /**
  55505. * Takes a list of meshes (as loaded from the glTF file) and finds the root node, as well as nodes that
  55506. * can be transformed by button presses and axes values, based on this._mapping.
  55507. *
  55508. * @param scene scene in which the meshes exist
  55509. * @param meshes list of meshes that make up the controller model to process
  55510. * @return structured view of the given meshes, with mapping of buttons and axes to meshes that can be transformed.
  55511. */
  55512. private processModel;
  55513. private createMeshInfo;
  55514. /**
  55515. * Gets the ray of the controller in the direction the controller is pointing
  55516. * @param length the length the resulting ray should be
  55517. * @returns a ray in the direction the controller is pointing
  55518. */
  55519. getForwardRay(length?: number): Ray;
  55520. /**
  55521. * Disposes of the controller
  55522. */
  55523. dispose(): void;
  55524. }
  55525. /**
  55526. * This class represents a new windows motion controller in XR.
  55527. */
  55528. export class XRWindowsMotionController extends WindowsMotionController {
  55529. /**
  55530. * Changing the original WIndowsMotionController mapping to fir the new mapping
  55531. */
  55532. protected readonly _mapping: {
  55533. buttons: string[];
  55534. buttonMeshNames: {
  55535. trigger: string;
  55536. menu: string;
  55537. grip: string;
  55538. thumbstick: string;
  55539. trackpad: string;
  55540. };
  55541. buttonObservableNames: {
  55542. trigger: string;
  55543. menu: string;
  55544. grip: string;
  55545. thumbstick: string;
  55546. trackpad: string;
  55547. };
  55548. axisMeshNames: string[];
  55549. pointingPoseMeshName: string;
  55550. };
  55551. /**
  55552. * Construct a new XR-Based windows motion controller
  55553. *
  55554. * @param gamepadInfo the gamepad object from the browser
  55555. */
  55556. constructor(gamepadInfo: any);
  55557. /**
  55558. * holds the thumbstick values (X,Y)
  55559. */
  55560. thumbstickValues: StickValues;
  55561. /**
  55562. * Fired when the thumbstick on this controller is clicked
  55563. */
  55564. onThumbstickStateChangedObservable: Observable<ExtendedGamepadButton>;
  55565. /**
  55566. * Fired when the thumbstick on this controller is modified
  55567. */
  55568. onThumbstickValuesChangedObservable: Observable<StickValues>;
  55569. /**
  55570. * Fired when the touchpad button on this controller is modified
  55571. */
  55572. onTrackpadChangedObservable: Observable<ExtendedGamepadButton>;
  55573. /**
  55574. * Fired when the touchpad values on this controller are modified
  55575. */
  55576. onTrackpadValuesChangedObservable: Observable<StickValues>;
  55577. /**
  55578. * Fired when the thumbstick button on this controller is modified
  55579. * here to prevent breaking changes
  55580. */
  55581. get onThumbstickButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  55582. /**
  55583. * updating the thumbstick(!) and not the trackpad.
  55584. * This is named this way due to the difference between WebVR and XR and to avoid
  55585. * changing the parent class.
  55586. */
  55587. protected _updateTrackpad(): void;
  55588. /**
  55589. * Disposes the class with joy
  55590. */
  55591. dispose(): void;
  55592. }
  55593. }
  55594. declare module "babylonjs/Gamepads/Controllers/index" {
  55595. export * from "babylonjs/Gamepads/Controllers/daydreamController";
  55596. export * from "babylonjs/Gamepads/Controllers/gearVRController";
  55597. export * from "babylonjs/Gamepads/Controllers/genericController";
  55598. export * from "babylonjs/Gamepads/Controllers/oculusTouchController";
  55599. export * from "babylonjs/Gamepads/Controllers/poseEnabledController";
  55600. export * from "babylonjs/Gamepads/Controllers/viveController";
  55601. export * from "babylonjs/Gamepads/Controllers/webVRController";
  55602. export * from "babylonjs/Gamepads/Controllers/windowsMotionController";
  55603. }
  55604. declare module "babylonjs/Gamepads/index" {
  55605. export * from "babylonjs/Gamepads/Controllers/index";
  55606. export * from "babylonjs/Gamepads/gamepad";
  55607. export * from "babylonjs/Gamepads/gamepadManager";
  55608. export * from "babylonjs/Gamepads/gamepadSceneComponent";
  55609. export * from "babylonjs/Gamepads/xboxGamepad";
  55610. export * from "babylonjs/Gamepads/dualShockGamepad";
  55611. }
  55612. declare module "babylonjs/Meshes/Builders/polyhedronBuilder" {
  55613. import { Scene } from "babylonjs/scene";
  55614. import { Vector4 } from "babylonjs/Maths/math.vector";
  55615. import { Color4 } from "babylonjs/Maths/math.color";
  55616. import { Mesh } from "babylonjs/Meshes/mesh";
  55617. import { Nullable } from "babylonjs/types";
  55618. /**
  55619. * Class containing static functions to help procedurally build meshes
  55620. */
  55621. export class PolyhedronBuilder {
  55622. /**
  55623. * Creates a polyhedron mesh
  55624. * * 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
  55625. * * The parameter `size` (positive float, default 1) sets the polygon size
  55626. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  55627. * * 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`
  55628. * * 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
  55629. * * 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)`)
  55630. * * 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
  55631. * * 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
  55632. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  55633. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  55634. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  55635. * @param name defines the name of the mesh
  55636. * @param options defines the options used to create the mesh
  55637. * @param scene defines the hosting scene
  55638. * @returns the polyhedron mesh
  55639. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes
  55640. */
  55641. static CreatePolyhedron(name: string, options: {
  55642. type?: number;
  55643. size?: number;
  55644. sizeX?: number;
  55645. sizeY?: number;
  55646. sizeZ?: number;
  55647. custom?: any;
  55648. faceUV?: Vector4[];
  55649. faceColors?: Color4[];
  55650. flat?: boolean;
  55651. updatable?: boolean;
  55652. sideOrientation?: number;
  55653. frontUVs?: Vector4;
  55654. backUVs?: Vector4;
  55655. }, scene?: Nullable<Scene>): Mesh;
  55656. }
  55657. }
  55658. declare module "babylonjs/Gizmos/scaleGizmo" {
  55659. import { Observable } from "babylonjs/Misc/observable";
  55660. import { Nullable } from "babylonjs/types";
  55661. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  55662. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  55663. import { AxisScaleGizmo } from "babylonjs/Gizmos/axisScaleGizmo";
  55664. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  55665. import { Node } from "babylonjs/node";
  55666. /**
  55667. * Gizmo that enables scaling a mesh along 3 axis
  55668. */
  55669. export class ScaleGizmo extends Gizmo {
  55670. /**
  55671. * Internal gizmo used for interactions on the x axis
  55672. */
  55673. xGizmo: AxisScaleGizmo;
  55674. /**
  55675. * Internal gizmo used for interactions on the y axis
  55676. */
  55677. yGizmo: AxisScaleGizmo;
  55678. /**
  55679. * Internal gizmo used for interactions on the z axis
  55680. */
  55681. zGizmo: AxisScaleGizmo;
  55682. /**
  55683. * Internal gizmo used to scale all axis equally
  55684. */
  55685. uniformScaleGizmo: AxisScaleGizmo;
  55686. private _meshAttached;
  55687. private _nodeAttached;
  55688. private _snapDistance;
  55689. private _uniformScalingMesh;
  55690. private _octahedron;
  55691. private _sensitivity;
  55692. /** Fires an event when any of it's sub gizmos are dragged */
  55693. onDragStartObservable: Observable<unknown>;
  55694. /** Fires an event when any of it's sub gizmos are released from dragging */
  55695. onDragEndObservable: Observable<unknown>;
  55696. get attachedMesh(): Nullable<AbstractMesh>;
  55697. set attachedMesh(mesh: Nullable<AbstractMesh>);
  55698. get attachedNode(): Nullable<Node>;
  55699. set attachedNode(node: Nullable<Node>);
  55700. /**
  55701. * Creates a ScaleGizmo
  55702. * @param gizmoLayer The utility layer the gizmo will be added to
  55703. * @param thickness display gizmo axis thickness
  55704. */
  55705. constructor(gizmoLayer?: UtilityLayerRenderer, thickness?: number);
  55706. set updateGizmoRotationToMatchAttachedMesh(value: boolean);
  55707. get updateGizmoRotationToMatchAttachedMesh(): boolean;
  55708. /**
  55709. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  55710. */
  55711. set snapDistance(value: number);
  55712. get snapDistance(): number;
  55713. /**
  55714. * Ratio for the scale of the gizmo (Default: 1)
  55715. */
  55716. set scaleRatio(value: number);
  55717. get scaleRatio(): number;
  55718. /**
  55719. * Sensitivity factor for dragging (Default: 1)
  55720. */
  55721. set sensitivity(value: number);
  55722. get sensitivity(): number;
  55723. /**
  55724. * Disposes of the gizmo
  55725. */
  55726. dispose(): void;
  55727. }
  55728. }
  55729. declare module "babylonjs/Gizmos/axisScaleGizmo" {
  55730. import { Observable } from "babylonjs/Misc/observable";
  55731. import { Nullable } from "babylonjs/types";
  55732. import { Vector3 } from "babylonjs/Maths/math.vector";
  55733. import { Node } from "babylonjs/node";
  55734. import { Mesh } from "babylonjs/Meshes/mesh";
  55735. import { PointerDragBehavior } from "babylonjs/Behaviors/Meshes/pointerDragBehavior";
  55736. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  55737. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  55738. import { ScaleGizmo } from "babylonjs/Gizmos/scaleGizmo";
  55739. import { Color3 } from "babylonjs/Maths/math.color";
  55740. /**
  55741. * Single axis scale gizmo
  55742. */
  55743. export class AxisScaleGizmo extends Gizmo {
  55744. /**
  55745. * Drag behavior responsible for the gizmos dragging interactions
  55746. */
  55747. dragBehavior: PointerDragBehavior;
  55748. private _pointerObserver;
  55749. /**
  55750. * Scale distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  55751. */
  55752. snapDistance: number;
  55753. /**
  55754. * Event that fires each time the gizmo snaps to a new location.
  55755. * * snapDistance is the the change in distance
  55756. */
  55757. onSnapObservable: Observable<{
  55758. snapDistance: number;
  55759. }>;
  55760. /**
  55761. * If the scaling operation should be done on all axis (default: false)
  55762. */
  55763. uniformScaling: boolean;
  55764. /**
  55765. * Custom sensitivity value for the drag strength
  55766. */
  55767. sensitivity: number;
  55768. private _isEnabled;
  55769. private _parent;
  55770. private _arrow;
  55771. private _coloredMaterial;
  55772. private _hoverMaterial;
  55773. /**
  55774. * Creates an AxisScaleGizmo
  55775. * @param gizmoLayer The utility layer the gizmo will be added to
  55776. * @param dragAxis The axis which the gizmo will be able to scale on
  55777. * @param color The color of the gizmo
  55778. * @param thickness display gizmo axis thickness
  55779. */
  55780. constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<ScaleGizmo>, thickness?: number);
  55781. protected _attachedNodeChanged(value: Nullable<Node>): void;
  55782. /**
  55783. * If the gizmo is enabled
  55784. */
  55785. set isEnabled(value: boolean);
  55786. get isEnabled(): boolean;
  55787. /**
  55788. * Disposes of the gizmo
  55789. */
  55790. dispose(): void;
  55791. /**
  55792. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  55793. * @param mesh The mesh to replace the default mesh of the gizmo
  55794. * @param useGizmoMaterial If the gizmo's default material should be used (default: false)
  55795. */
  55796. setCustomMesh(mesh: Mesh, useGizmoMaterial?: boolean): void;
  55797. }
  55798. }
  55799. declare module "babylonjs/Gizmos/boundingBoxGizmo" {
  55800. import { Observable } from "babylonjs/Misc/observable";
  55801. import { Nullable } from "babylonjs/types";
  55802. import { Vector3 } from "babylonjs/Maths/math.vector";
  55803. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  55804. import { Mesh } from "babylonjs/Meshes/mesh";
  55805. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  55806. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  55807. import { Color3 } from "babylonjs/Maths/math.color";
  55808. import "babylonjs/Meshes/Builders/boxBuilder";
  55809. /**
  55810. * Bounding box gizmo
  55811. */
  55812. export class BoundingBoxGizmo extends Gizmo {
  55813. private _lineBoundingBox;
  55814. private _rotateSpheresParent;
  55815. private _scaleBoxesParent;
  55816. private _boundingDimensions;
  55817. private _renderObserver;
  55818. private _pointerObserver;
  55819. private _scaleDragSpeed;
  55820. private _tmpQuaternion;
  55821. private _tmpVector;
  55822. private _tmpRotationMatrix;
  55823. /**
  55824. * 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)
  55825. */
  55826. ignoreChildren: boolean;
  55827. /**
  55828. * 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)
  55829. */
  55830. includeChildPredicate: Nullable<(abstractMesh: AbstractMesh) => boolean>;
  55831. /**
  55832. * The size of the rotation spheres attached to the bounding box (Default: 0.1)
  55833. */
  55834. rotationSphereSize: number;
  55835. /**
  55836. * The size of the scale boxes attached to the bounding box (Default: 0.1)
  55837. */
  55838. scaleBoxSize: number;
  55839. /**
  55840. * 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)
  55841. */
  55842. fixedDragMeshScreenSize: boolean;
  55843. /**
  55844. * The distance away from the object which the draggable meshes should appear world sized when fixedDragMeshScreenSize is set to true (default: 10)
  55845. */
  55846. fixedDragMeshScreenSizeDistanceFactor: number;
  55847. /**
  55848. * Fired when a rotation sphere or scale box is dragged
  55849. */
  55850. onDragStartObservable: Observable<{}>;
  55851. /**
  55852. * Fired when a scale box is dragged
  55853. */
  55854. onScaleBoxDragObservable: Observable<{}>;
  55855. /**
  55856. * Fired when a scale box drag is ended
  55857. */
  55858. onScaleBoxDragEndObservable: Observable<{}>;
  55859. /**
  55860. * Fired when a rotation sphere is dragged
  55861. */
  55862. onRotationSphereDragObservable: Observable<{}>;
  55863. /**
  55864. * Fired when a rotation sphere drag is ended
  55865. */
  55866. onRotationSphereDragEndObservable: Observable<{}>;
  55867. /**
  55868. * 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)
  55869. */
  55870. scalePivot: Nullable<Vector3>;
  55871. /**
  55872. * Mesh used as a pivot to rotate the attached node
  55873. */
  55874. private _anchorMesh;
  55875. private _existingMeshScale;
  55876. private _dragMesh;
  55877. private pointerDragBehavior;
  55878. private coloredMaterial;
  55879. private hoverColoredMaterial;
  55880. /**
  55881. * Sets the color of the bounding box gizmo
  55882. * @param color the color to set
  55883. */
  55884. setColor(color: Color3): void;
  55885. /**
  55886. * Creates an BoundingBoxGizmo
  55887. * @param gizmoLayer The utility layer the gizmo will be added to
  55888. * @param color The color of the gizmo
  55889. */
  55890. constructor(color?: Color3, gizmoLayer?: UtilityLayerRenderer);
  55891. protected _attachedNodeChanged(value: Nullable<AbstractMesh>): void;
  55892. private _selectNode;
  55893. /**
  55894. * Updates the bounding box information for the Gizmo
  55895. */
  55896. updateBoundingBox(): void;
  55897. private _updateRotationSpheres;
  55898. private _updateScaleBoxes;
  55899. /**
  55900. * Enables rotation on the specified axis and disables rotation on the others
  55901. * @param axis The list of axis that should be enabled (eg. "xy" or "xyz")
  55902. */
  55903. setEnabledRotationAxis(axis: string): void;
  55904. /**
  55905. * Enables/disables scaling
  55906. * @param enable if scaling should be enabled
  55907. * @param homogeneousScaling defines if scaling should only be homogeneous
  55908. */
  55909. setEnabledScaling(enable: boolean, homogeneousScaling?: boolean): void;
  55910. private _updateDummy;
  55911. /**
  55912. * Enables a pointer drag behavior on the bounding box of the gizmo
  55913. */
  55914. enableDragBehavior(): void;
  55915. /**
  55916. * Disposes of the gizmo
  55917. */
  55918. dispose(): void;
  55919. /**
  55920. * 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)
  55921. * @param mesh the mesh to wrap in the bounding box mesh and make not pickable
  55922. * @returns the bounding box mesh with the passed in mesh as a child
  55923. */
  55924. static MakeNotPickableAndWrapInBoundingBox(mesh: Mesh): Mesh;
  55925. /**
  55926. * CustomMeshes are not supported by this gizmo
  55927. * @param mesh The mesh to replace the default mesh of the gizmo
  55928. */
  55929. setCustomMesh(mesh: Mesh): void;
  55930. }
  55931. }
  55932. declare module "babylonjs/Gizmos/planeRotationGizmo" {
  55933. import { Observable } from "babylonjs/Misc/observable";
  55934. import { Nullable } from "babylonjs/types";
  55935. import { Vector3 } from "babylonjs/Maths/math.vector";
  55936. import { Color3 } from "babylonjs/Maths/math.color";
  55937. import { Node } from "babylonjs/node";
  55938. import { PointerDragBehavior } from "babylonjs/Behaviors/Meshes/pointerDragBehavior";
  55939. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  55940. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  55941. import "babylonjs/Meshes/Builders/linesBuilder";
  55942. import { RotationGizmo } from "babylonjs/Gizmos/rotationGizmo";
  55943. /**
  55944. * Single plane rotation gizmo
  55945. */
  55946. export class PlaneRotationGizmo extends Gizmo {
  55947. /**
  55948. * Drag behavior responsible for the gizmos dragging interactions
  55949. */
  55950. dragBehavior: PointerDragBehavior;
  55951. private _pointerObserver;
  55952. /**
  55953. * Rotation distance in radians that the gizmo will snap to (Default: 0)
  55954. */
  55955. snapDistance: number;
  55956. /**
  55957. * Event that fires each time the gizmo snaps to a new location.
  55958. * * snapDistance is the the change in distance
  55959. */
  55960. onSnapObservable: Observable<{
  55961. snapDistance: number;
  55962. }>;
  55963. private _isEnabled;
  55964. private _parent;
  55965. /**
  55966. * Creates a PlaneRotationGizmo
  55967. * @param gizmoLayer The utility layer the gizmo will be added to
  55968. * @param planeNormal The normal of the plane which the gizmo will be able to rotate on
  55969. * @param color The color of the gizmo
  55970. * @param tessellation Amount of tessellation to be used when creating rotation circles
  55971. * @param useEulerRotation Use and update Euler angle instead of quaternion
  55972. * @param thickness display gizmo axis thickness
  55973. */
  55974. constructor(planeNormal: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, tessellation?: number, parent?: Nullable<RotationGizmo>, useEulerRotation?: boolean, thickness?: number);
  55975. protected _attachedNodeChanged(value: Nullable<Node>): void;
  55976. /**
  55977. * If the gizmo is enabled
  55978. */
  55979. set isEnabled(value: boolean);
  55980. get isEnabled(): boolean;
  55981. /**
  55982. * Disposes of the gizmo
  55983. */
  55984. dispose(): void;
  55985. }
  55986. }
  55987. declare module "babylonjs/Gizmos/rotationGizmo" {
  55988. import { Observable } from "babylonjs/Misc/observable";
  55989. import { Nullable } from "babylonjs/types";
  55990. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  55991. import { Mesh } from "babylonjs/Meshes/mesh";
  55992. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  55993. import { PlaneRotationGizmo } from "babylonjs/Gizmos/planeRotationGizmo";
  55994. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  55995. import { Node } from "babylonjs/node";
  55996. /**
  55997. * Gizmo that enables rotating a mesh along 3 axis
  55998. */
  55999. export class RotationGizmo extends Gizmo {
  56000. /**
  56001. * Internal gizmo used for interactions on the x axis
  56002. */
  56003. xGizmo: PlaneRotationGizmo;
  56004. /**
  56005. * Internal gizmo used for interactions on the y axis
  56006. */
  56007. yGizmo: PlaneRotationGizmo;
  56008. /**
  56009. * Internal gizmo used for interactions on the z axis
  56010. */
  56011. zGizmo: PlaneRotationGizmo;
  56012. /** Fires an event when any of it's sub gizmos are dragged */
  56013. onDragStartObservable: Observable<unknown>;
  56014. /** Fires an event when any of it's sub gizmos are released from dragging */
  56015. onDragEndObservable: Observable<unknown>;
  56016. private _meshAttached;
  56017. private _nodeAttached;
  56018. get attachedMesh(): Nullable<AbstractMesh>;
  56019. set attachedMesh(mesh: Nullable<AbstractMesh>);
  56020. get attachedNode(): Nullable<Node>;
  56021. set attachedNode(node: Nullable<Node>);
  56022. /**
  56023. * Creates a RotationGizmo
  56024. * @param gizmoLayer The utility layer the gizmo will be added to
  56025. * @param tessellation Amount of tessellation to be used when creating rotation circles
  56026. * @param useEulerRotation Use and update Euler angle instead of quaternion
  56027. * @param thickness display gizmo axis thickness
  56028. */
  56029. constructor(gizmoLayer?: UtilityLayerRenderer, tessellation?: number, useEulerRotation?: boolean, thickness?: number);
  56030. set updateGizmoRotationToMatchAttachedMesh(value: boolean);
  56031. get updateGizmoRotationToMatchAttachedMesh(): boolean;
  56032. /**
  56033. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  56034. */
  56035. set snapDistance(value: number);
  56036. get snapDistance(): number;
  56037. /**
  56038. * Ratio for the scale of the gizmo (Default: 1)
  56039. */
  56040. set scaleRatio(value: number);
  56041. get scaleRatio(): number;
  56042. /**
  56043. * Disposes of the gizmo
  56044. */
  56045. dispose(): void;
  56046. /**
  56047. * CustomMeshes are not supported by this gizmo
  56048. * @param mesh The mesh to replace the default mesh of the gizmo
  56049. */
  56050. setCustomMesh(mesh: Mesh): void;
  56051. }
  56052. }
  56053. declare module "babylonjs/Gizmos/gizmoManager" {
  56054. import { Observable } from "babylonjs/Misc/observable";
  56055. import { Nullable } from "babylonjs/types";
  56056. import { Scene, IDisposable } from "babylonjs/scene";
  56057. import { Node } from "babylonjs/node";
  56058. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  56059. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  56060. import { SixDofDragBehavior } from "babylonjs/Behaviors/Meshes/sixDofDragBehavior";
  56061. import { RotationGizmo } from "babylonjs/Gizmos/rotationGizmo";
  56062. import { PositionGizmo } from "babylonjs/Gizmos/positionGizmo";
  56063. import { ScaleGizmo } from "babylonjs/Gizmos/scaleGizmo";
  56064. import { BoundingBoxGizmo } from "babylonjs/Gizmos/boundingBoxGizmo";
  56065. /**
  56066. * Helps setup gizmo's in the scene to rotate/scale/position nodes
  56067. */
  56068. export class GizmoManager implements IDisposable {
  56069. private scene;
  56070. /**
  56071. * Gizmo's created by the gizmo manager, gizmo will be null until gizmo has been enabled for the first time
  56072. */
  56073. gizmos: {
  56074. positionGizmo: Nullable<PositionGizmo>;
  56075. rotationGizmo: Nullable<RotationGizmo>;
  56076. scaleGizmo: Nullable<ScaleGizmo>;
  56077. boundingBoxGizmo: Nullable<BoundingBoxGizmo>;
  56078. };
  56079. /** When true, the gizmo will be detached from the current object when a pointer down occurs with an empty picked mesh */
  56080. clearGizmoOnEmptyPointerEvent: boolean;
  56081. /** Fires an event when the manager is attached to a mesh */
  56082. onAttachedToMeshObservable: Observable<Nullable<AbstractMesh>>;
  56083. /** Fires an event when the manager is attached to a node */
  56084. onAttachedToNodeObservable: Observable<Nullable<Node>>;
  56085. private _gizmosEnabled;
  56086. private _pointerObserver;
  56087. private _attachedMesh;
  56088. private _attachedNode;
  56089. private _boundingBoxColor;
  56090. private _defaultUtilityLayer;
  56091. private _defaultKeepDepthUtilityLayer;
  56092. private _thickness;
  56093. /**
  56094. * When bounding box gizmo is enabled, this can be used to track drag/end events
  56095. */
  56096. boundingBoxDragBehavior: SixDofDragBehavior;
  56097. /**
  56098. * Array of meshes which will have the gizmo attached when a pointer selected them. If null, all meshes are attachable. (Default: null)
  56099. */
  56100. attachableMeshes: Nullable<Array<AbstractMesh>>;
  56101. /**
  56102. * Array of nodes which will have the gizmo attached when a pointer selected them. If null, all nodes are attachable. (Default: null)
  56103. */
  56104. attachableNodes: Nullable<Array<Node>>;
  56105. /**
  56106. * If pointer events should perform attaching/detaching a gizmo, if false this can be done manually via attachToMesh/attachToNode. (Default: true)
  56107. */
  56108. usePointerToAttachGizmos: boolean;
  56109. /**
  56110. * Utility layer that the bounding box gizmo belongs to
  56111. */
  56112. get keepDepthUtilityLayer(): UtilityLayerRenderer;
  56113. /**
  56114. * Utility layer that all gizmos besides bounding box belong to
  56115. */
  56116. get utilityLayer(): UtilityLayerRenderer;
  56117. /**
  56118. * Instatiates a gizmo manager
  56119. * @param scene the scene to overlay the gizmos on top of
  56120. * @param thickness display gizmo axis thickness
  56121. */
  56122. constructor(scene: Scene, thickness?: number);
  56123. /**
  56124. * Attaches a set of gizmos to the specified mesh
  56125. * @param mesh The mesh the gizmo's should be attached to
  56126. */
  56127. attachToMesh(mesh: Nullable<AbstractMesh>): void;
  56128. /**
  56129. * Attaches a set of gizmos to the specified node
  56130. * @param node The node the gizmo's should be attached to
  56131. */
  56132. attachToNode(node: Nullable<Node>): void;
  56133. /**
  56134. * If the position gizmo is enabled
  56135. */
  56136. set positionGizmoEnabled(value: boolean);
  56137. get positionGizmoEnabled(): boolean;
  56138. /**
  56139. * If the rotation gizmo is enabled
  56140. */
  56141. set rotationGizmoEnabled(value: boolean);
  56142. get rotationGizmoEnabled(): boolean;
  56143. /**
  56144. * If the scale gizmo is enabled
  56145. */
  56146. set scaleGizmoEnabled(value: boolean);
  56147. get scaleGizmoEnabled(): boolean;
  56148. /**
  56149. * If the boundingBox gizmo is enabled
  56150. */
  56151. set boundingBoxGizmoEnabled(value: boolean);
  56152. get boundingBoxGizmoEnabled(): boolean;
  56153. /**
  56154. * Disposes of the gizmo manager
  56155. */
  56156. dispose(): void;
  56157. }
  56158. }
  56159. declare module "babylonjs/Lights/directionalLight" {
  56160. import { Camera } from "babylonjs/Cameras/camera";
  56161. import { Scene } from "babylonjs/scene";
  56162. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  56163. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  56164. import { Light } from "babylonjs/Lights/light";
  56165. import { ShadowLight } from "babylonjs/Lights/shadowLight";
  56166. import { Effect } from "babylonjs/Materials/effect";
  56167. /**
  56168. * A directional light is defined by a direction (what a surprise!).
  56169. * The light is emitted from everywhere in the specified direction, and has an infinite range.
  56170. * 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.
  56171. * Documentation: https://doc.babylonjs.com/babylon101/lights
  56172. */
  56173. export class DirectionalLight extends ShadowLight {
  56174. private _shadowFrustumSize;
  56175. /**
  56176. * Fix frustum size for the shadow generation. This is disabled if the value is 0.
  56177. */
  56178. get shadowFrustumSize(): number;
  56179. /**
  56180. * Specifies a fix frustum size for the shadow generation.
  56181. */
  56182. set shadowFrustumSize(value: number);
  56183. private _shadowOrthoScale;
  56184. /**
  56185. * Gets the shadow projection scale against the optimal computed one.
  56186. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  56187. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  56188. */
  56189. get shadowOrthoScale(): number;
  56190. /**
  56191. * Sets the shadow projection scale against the optimal computed one.
  56192. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  56193. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  56194. */
  56195. set shadowOrthoScale(value: number);
  56196. /**
  56197. * Automatically compute the projection matrix to best fit (including all the casters)
  56198. * on each frame.
  56199. */
  56200. autoUpdateExtends: boolean;
  56201. /**
  56202. * Automatically compute the shadowMinZ and shadowMaxZ for the projection matrix to best fit (including all the casters)
  56203. * on each frame. autoUpdateExtends must be set to true for this to work
  56204. */
  56205. autoCalcShadowZBounds: boolean;
  56206. private _orthoLeft;
  56207. private _orthoRight;
  56208. private _orthoTop;
  56209. private _orthoBottom;
  56210. /**
  56211. * Creates a DirectionalLight object in the scene, oriented towards the passed direction (Vector3).
  56212. * The directional light is emitted from everywhere in the given direction.
  56213. * It can cast shadows.
  56214. * Documentation : https://doc.babylonjs.com/babylon101/lights
  56215. * @param name The friendly name of the light
  56216. * @param direction The direction of the light
  56217. * @param scene The scene the light belongs to
  56218. */
  56219. constructor(name: string, direction: Vector3, scene: Scene);
  56220. /**
  56221. * Returns the string "DirectionalLight".
  56222. * @return The class name
  56223. */
  56224. getClassName(): string;
  56225. /**
  56226. * Returns the integer 1.
  56227. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  56228. */
  56229. getTypeID(): number;
  56230. /**
  56231. * Sets the passed matrix "matrix" as projection matrix for the shadows cast by the light according to the passed view matrix.
  56232. * Returns the DirectionalLight Shadow projection matrix.
  56233. */
  56234. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  56235. /**
  56236. * Sets the passed matrix "matrix" as fixed frustum projection matrix for the shadows cast by the light according to the passed view matrix.
  56237. * Returns the DirectionalLight Shadow projection matrix.
  56238. */
  56239. protected _setDefaultFixedFrustumShadowProjectionMatrix(matrix: Matrix): void;
  56240. /**
  56241. * Sets the passed matrix "matrix" as auto extend projection matrix for the shadows cast by the light according to the passed view matrix.
  56242. * Returns the DirectionalLight Shadow projection matrix.
  56243. */
  56244. protected _setDefaultAutoExtendShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  56245. protected _buildUniformLayout(): void;
  56246. /**
  56247. * Sets the passed Effect object with the DirectionalLight transformed position (or position if not parented) and the passed name.
  56248. * @param effect The effect to update
  56249. * @param lightIndex The index of the light in the effect to update
  56250. * @returns The directional light
  56251. */
  56252. transferToEffect(effect: Effect, lightIndex: string): DirectionalLight;
  56253. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): Light;
  56254. /**
  56255. * Gets the minZ used for shadow according to both the scene and the light.
  56256. *
  56257. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  56258. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  56259. * @param activeCamera The camera we are returning the min for
  56260. * @returns the depth min z
  56261. */
  56262. getDepthMinZ(activeCamera: Camera): number;
  56263. /**
  56264. * Gets the maxZ used for shadow according to both the scene and the light.
  56265. *
  56266. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  56267. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  56268. * @param activeCamera The camera we are returning the max for
  56269. * @returns the depth max z
  56270. */
  56271. getDepthMaxZ(activeCamera: Camera): number;
  56272. /**
  56273. * Prepares the list of defines specific to the light type.
  56274. * @param defines the list of defines
  56275. * @param lightIndex defines the index of the light for the effect
  56276. */
  56277. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  56278. }
  56279. }
  56280. declare module "babylonjs/Meshes/Builders/hemisphereBuilder" {
  56281. import { Mesh } from "babylonjs/Meshes/mesh";
  56282. /**
  56283. * Class containing static functions to help procedurally build meshes
  56284. */
  56285. export class HemisphereBuilder {
  56286. /**
  56287. * Creates a hemisphere mesh
  56288. * @param name defines the name of the mesh
  56289. * @param options defines the options used to create the mesh
  56290. * @param scene defines the hosting scene
  56291. * @returns the hemisphere mesh
  56292. */
  56293. static CreateHemisphere(name: string, options: {
  56294. segments?: number;
  56295. diameter?: number;
  56296. sideOrientation?: number;
  56297. }, scene: any): Mesh;
  56298. }
  56299. }
  56300. declare module "babylonjs/Lights/spotLight" {
  56301. import { Nullable } from "babylonjs/types";
  56302. import { Scene } from "babylonjs/scene";
  56303. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  56304. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  56305. import { Effect } from "babylonjs/Materials/effect";
  56306. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  56307. import { Light } from "babylonjs/Lights/light";
  56308. import { ShadowLight } from "babylonjs/Lights/shadowLight";
  56309. /**
  56310. * A spot light is defined by a position, a direction, an angle, and an exponent.
  56311. * These values define a cone of light starting from the position, emitting toward the direction.
  56312. * The angle, in radians, defines the size (field of illumination) of the spotlight's conical beam,
  56313. * and the exponent defines the speed of the decay of the light with distance (reach).
  56314. * Documentation: https://doc.babylonjs.com/babylon101/lights
  56315. */
  56316. export class SpotLight extends ShadowLight {
  56317. private _angle;
  56318. private _innerAngle;
  56319. private _cosHalfAngle;
  56320. private _lightAngleScale;
  56321. private _lightAngleOffset;
  56322. /**
  56323. * Gets the cone angle of the spot light in Radians.
  56324. */
  56325. get angle(): number;
  56326. /**
  56327. * Sets the cone angle of the spot light in Radians.
  56328. */
  56329. set angle(value: number);
  56330. /**
  56331. * Only used in gltf falloff mode, this defines the angle where
  56332. * the directional falloff will start before cutting at angle which could be seen
  56333. * as outer angle.
  56334. */
  56335. get innerAngle(): number;
  56336. /**
  56337. * Only used in gltf falloff mode, this defines the angle where
  56338. * the directional falloff will start before cutting at angle which could be seen
  56339. * as outer angle.
  56340. */
  56341. set innerAngle(value: number);
  56342. private _shadowAngleScale;
  56343. /**
  56344. * Allows scaling the angle of the light for shadow generation only.
  56345. */
  56346. get shadowAngleScale(): number;
  56347. /**
  56348. * Allows scaling the angle of the light for shadow generation only.
  56349. */
  56350. set shadowAngleScale(value: number);
  56351. /**
  56352. * The light decay speed with the distance from the emission spot.
  56353. */
  56354. exponent: number;
  56355. private _projectionTextureMatrix;
  56356. /**
  56357. * Allows reading the projecton texture
  56358. */
  56359. get projectionTextureMatrix(): Matrix;
  56360. protected _projectionTextureLightNear: number;
  56361. /**
  56362. * Gets the near clip of the Spotlight for texture projection.
  56363. */
  56364. get projectionTextureLightNear(): number;
  56365. /**
  56366. * Sets the near clip of the Spotlight for texture projection.
  56367. */
  56368. set projectionTextureLightNear(value: number);
  56369. protected _projectionTextureLightFar: number;
  56370. /**
  56371. * Gets the far clip of the Spotlight for texture projection.
  56372. */
  56373. get projectionTextureLightFar(): number;
  56374. /**
  56375. * Sets the far clip of the Spotlight for texture projection.
  56376. */
  56377. set projectionTextureLightFar(value: number);
  56378. protected _projectionTextureUpDirection: Vector3;
  56379. /**
  56380. * Gets the Up vector of the Spotlight for texture projection.
  56381. */
  56382. get projectionTextureUpDirection(): Vector3;
  56383. /**
  56384. * Sets the Up vector of the Spotlight for texture projection.
  56385. */
  56386. set projectionTextureUpDirection(value: Vector3);
  56387. private _projectionTexture;
  56388. /**
  56389. * Gets the projection texture of the light.
  56390. */
  56391. get projectionTexture(): Nullable<BaseTexture>;
  56392. /**
  56393. * Sets the projection texture of the light.
  56394. */
  56395. set projectionTexture(value: Nullable<BaseTexture>);
  56396. private _projectionTextureViewLightDirty;
  56397. private _projectionTextureProjectionLightDirty;
  56398. private _projectionTextureDirty;
  56399. private _projectionTextureViewTargetVector;
  56400. private _projectionTextureViewLightMatrix;
  56401. private _projectionTextureProjectionLightMatrix;
  56402. private _projectionTextureScalingMatrix;
  56403. /**
  56404. * Creates a SpotLight object in the scene. A spot light is a simply light oriented cone.
  56405. * It can cast shadows.
  56406. * Documentation : https://doc.babylonjs.com/babylon101/lights
  56407. * @param name The light friendly name
  56408. * @param position The position of the spot light in the scene
  56409. * @param direction The direction of the light in the scene
  56410. * @param angle The cone angle of the light in Radians
  56411. * @param exponent The light decay speed with the distance from the emission spot
  56412. * @param scene The scene the lights belongs to
  56413. */
  56414. constructor(name: string, position: Vector3, direction: Vector3, angle: number, exponent: number, scene: Scene);
  56415. /**
  56416. * Returns the string "SpotLight".
  56417. * @returns the class name
  56418. */
  56419. getClassName(): string;
  56420. /**
  56421. * Returns the integer 2.
  56422. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  56423. */
  56424. getTypeID(): number;
  56425. /**
  56426. * Overrides the direction setter to recompute the projection texture view light Matrix.
  56427. */
  56428. protected _setDirection(value: Vector3): void;
  56429. /**
  56430. * Overrides the position setter to recompute the projection texture view light Matrix.
  56431. */
  56432. protected _setPosition(value: Vector3): void;
  56433. /**
  56434. * 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.
  56435. * Returns the SpotLight.
  56436. */
  56437. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  56438. protected _computeProjectionTextureViewLightMatrix(): void;
  56439. protected _computeProjectionTextureProjectionLightMatrix(): void;
  56440. /**
  56441. * Main function for light texture projection matrix computing.
  56442. */
  56443. protected _computeProjectionTextureMatrix(): void;
  56444. protected _buildUniformLayout(): void;
  56445. private _computeAngleValues;
  56446. /**
  56447. * Sets the passed Effect "effect" with the Light textures.
  56448. * @param effect The effect to update
  56449. * @param lightIndex The index of the light in the effect to update
  56450. * @returns The light
  56451. */
  56452. transferTexturesToEffect(effect: Effect, lightIndex: string): Light;
  56453. /**
  56454. * Sets the passed Effect object with the SpotLight transfomed position (or position if not parented) and normalized direction.
  56455. * @param effect The effect to update
  56456. * @param lightIndex The index of the light in the effect to update
  56457. * @returns The spot light
  56458. */
  56459. transferToEffect(effect: Effect, lightIndex: string): SpotLight;
  56460. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): this;
  56461. /**
  56462. * Disposes the light and the associated resources.
  56463. */
  56464. dispose(): void;
  56465. /**
  56466. * Prepares the list of defines specific to the light type.
  56467. * @param defines the list of defines
  56468. * @param lightIndex defines the index of the light for the effect
  56469. */
  56470. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  56471. }
  56472. }
  56473. declare module "babylonjs/Gizmos/lightGizmo" {
  56474. import { Nullable } from "babylonjs/types";
  56475. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  56476. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  56477. import { StandardMaterial } from "babylonjs/Materials/standardMaterial";
  56478. import { Light } from "babylonjs/Lights/light";
  56479. import { Observable } from "babylonjs/Misc/observable";
  56480. /**
  56481. * Gizmo that enables viewing a light
  56482. */
  56483. export class LightGizmo extends Gizmo {
  56484. private _lightMesh;
  56485. private _material;
  56486. private _cachedPosition;
  56487. private _cachedForward;
  56488. private _attachedMeshParent;
  56489. private _pointerObserver;
  56490. /**
  56491. * Event that fires each time the gizmo is clicked
  56492. */
  56493. onClickedObservable: Observable<Light>;
  56494. /**
  56495. * Creates a LightGizmo
  56496. * @param gizmoLayer The utility layer the gizmo will be added to
  56497. */
  56498. constructor(gizmoLayer?: UtilityLayerRenderer);
  56499. private _light;
  56500. /**
  56501. * The light that the gizmo is attached to
  56502. */
  56503. set light(light: Nullable<Light>);
  56504. get light(): Nullable<Light>;
  56505. /**
  56506. * Gets the material used to render the light gizmo
  56507. */
  56508. get material(): StandardMaterial;
  56509. /**
  56510. * @hidden
  56511. * Updates the gizmo to match the attached mesh's position/rotation
  56512. */
  56513. protected _update(): void;
  56514. private static _Scale;
  56515. /**
  56516. * Creates the lines for a light mesh
  56517. */
  56518. private static _CreateLightLines;
  56519. /**
  56520. * Disposes of the light gizmo
  56521. */
  56522. dispose(): void;
  56523. private static _CreateHemisphericLightMesh;
  56524. private static _CreatePointLightMesh;
  56525. private static _CreateSpotLightMesh;
  56526. private static _CreateDirectionalLightMesh;
  56527. }
  56528. }
  56529. declare module "babylonjs/Gizmos/cameraGizmo" {
  56530. import { Nullable } from "babylonjs/types";
  56531. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  56532. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  56533. import { StandardMaterial } from "babylonjs/Materials/standardMaterial";
  56534. import { Camera } from "babylonjs/Cameras/camera";
  56535. import { Observable } from "babylonjs/Misc/observable";
  56536. /**
  56537. * Gizmo that enables viewing a camera
  56538. */
  56539. export class CameraGizmo extends Gizmo {
  56540. private _cameraMesh;
  56541. private _cameraLinesMesh;
  56542. private _material;
  56543. private _pointerObserver;
  56544. /**
  56545. * Event that fires each time the gizmo is clicked
  56546. */
  56547. onClickedObservable: Observable<Camera>;
  56548. /**
  56549. * Creates a CameraGizmo
  56550. * @param gizmoLayer The utility layer the gizmo will be added to
  56551. */
  56552. constructor(gizmoLayer?: UtilityLayerRenderer);
  56553. private _camera;
  56554. /** Gets or sets a boolean indicating if frustum lines must be rendered (true by default)) */
  56555. get displayFrustum(): boolean;
  56556. set displayFrustum(value: boolean);
  56557. /**
  56558. * The camera that the gizmo is attached to
  56559. */
  56560. set camera(camera: Nullable<Camera>);
  56561. get camera(): Nullable<Camera>;
  56562. /**
  56563. * Gets the material used to render the camera gizmo
  56564. */
  56565. get material(): StandardMaterial;
  56566. /**
  56567. * @hidden
  56568. * Updates the gizmo to match the attached mesh's position/rotation
  56569. */
  56570. protected _update(): void;
  56571. private static _Scale;
  56572. private _invProjection;
  56573. /**
  56574. * Disposes of the camera gizmo
  56575. */
  56576. dispose(): void;
  56577. private static _CreateCameraMesh;
  56578. private static _CreateCameraFrustum;
  56579. }
  56580. }
  56581. declare module "babylonjs/Gizmos/index" {
  56582. export * from "babylonjs/Gizmos/axisDragGizmo";
  56583. export * from "babylonjs/Gizmos/axisScaleGizmo";
  56584. export * from "babylonjs/Gizmos/boundingBoxGizmo";
  56585. export * from "babylonjs/Gizmos/gizmo";
  56586. export * from "babylonjs/Gizmos/gizmoManager";
  56587. export * from "babylonjs/Gizmos/planeRotationGizmo";
  56588. export * from "babylonjs/Gizmos/positionGizmo";
  56589. export * from "babylonjs/Gizmos/rotationGizmo";
  56590. export * from "babylonjs/Gizmos/scaleGizmo";
  56591. export * from "babylonjs/Gizmos/lightGizmo";
  56592. export * from "babylonjs/Gizmos/cameraGizmo";
  56593. export * from "babylonjs/Gizmos/planeDragGizmo";
  56594. }
  56595. declare module "babylonjs/Shaders/ShadersInclude/backgroundFragmentDeclaration" {
  56596. /** @hidden */
  56597. export var backgroundFragmentDeclaration: {
  56598. name: string;
  56599. shader: string;
  56600. };
  56601. }
  56602. declare module "babylonjs/Shaders/ShadersInclude/backgroundUboDeclaration" {
  56603. /** @hidden */
  56604. export var backgroundUboDeclaration: {
  56605. name: string;
  56606. shader: string;
  56607. };
  56608. }
  56609. declare module "babylonjs/Shaders/background.fragment" {
  56610. import "babylonjs/Shaders/ShadersInclude/backgroundFragmentDeclaration";
  56611. import "babylonjs/Shaders/ShadersInclude/backgroundUboDeclaration";
  56612. import "babylonjs/Shaders/ShadersInclude/reflectionFunction";
  56613. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  56614. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  56615. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  56616. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  56617. import "babylonjs/Shaders/ShadersInclude/lightsFragmentFunctions";
  56618. import "babylonjs/Shaders/ShadersInclude/shadowsFragmentFunctions";
  56619. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  56620. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration";
  56621. import "babylonjs/Shaders/ShadersInclude/fogFragmentDeclaration";
  56622. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragment";
  56623. import "babylonjs/Shaders/ShadersInclude/lightFragment";
  56624. import "babylonjs/Shaders/ShadersInclude/fogFragment";
  56625. /** @hidden */
  56626. export var backgroundPixelShader: {
  56627. name: string;
  56628. shader: string;
  56629. };
  56630. }
  56631. declare module "babylonjs/Shaders/ShadersInclude/backgroundVertexDeclaration" {
  56632. /** @hidden */
  56633. export var backgroundVertexDeclaration: {
  56634. name: string;
  56635. shader: string;
  56636. };
  56637. }
  56638. declare module "babylonjs/Shaders/background.vertex" {
  56639. import "babylonjs/Shaders/ShadersInclude/backgroundVertexDeclaration";
  56640. import "babylonjs/Shaders/ShadersInclude/backgroundUboDeclaration";
  56641. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  56642. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  56643. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  56644. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration";
  56645. import "babylonjs/Shaders/ShadersInclude/fogVertexDeclaration";
  56646. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  56647. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  56648. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  56649. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  56650. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertex";
  56651. import "babylonjs/Shaders/ShadersInclude/fogVertex";
  56652. import "babylonjs/Shaders/ShadersInclude/shadowsVertex";
  56653. /** @hidden */
  56654. export var backgroundVertexShader: {
  56655. name: string;
  56656. shader: string;
  56657. };
  56658. }
  56659. declare module "babylonjs/Materials/Background/backgroundMaterial" {
  56660. import { Nullable, int, float } from "babylonjs/types";
  56661. import { Scene } from "babylonjs/scene";
  56662. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  56663. import { SubMesh } from "babylonjs/Meshes/subMesh";
  56664. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  56665. import { Mesh } from "babylonjs/Meshes/mesh";
  56666. import { PushMaterial } from "babylonjs/Materials/pushMaterial";
  56667. import { ColorCurves } from "babylonjs/Materials/colorCurves";
  56668. import { ImageProcessingConfiguration } from "babylonjs/Materials/imageProcessingConfiguration";
  56669. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  56670. import { IShadowLight } from "babylonjs/Lights/shadowLight";
  56671. import { Color3 } from "babylonjs/Maths/math.color";
  56672. import "babylonjs/Shaders/background.fragment";
  56673. import "babylonjs/Shaders/background.vertex";
  56674. /**
  56675. * Background material used to create an efficient environement around your scene.
  56676. */
  56677. export class BackgroundMaterial extends PushMaterial {
  56678. /**
  56679. * Standard reflectance value at parallel view angle.
  56680. */
  56681. static StandardReflectance0: number;
  56682. /**
  56683. * Standard reflectance value at grazing angle.
  56684. */
  56685. static StandardReflectance90: number;
  56686. protected _primaryColor: Color3;
  56687. /**
  56688. * Key light Color (multiply against the environement texture)
  56689. */
  56690. primaryColor: Color3;
  56691. protected __perceptualColor: Nullable<Color3>;
  56692. /**
  56693. * Experimental Internal Use Only.
  56694. *
  56695. * Key light Color in "perceptual value" meaning the color you would like to see on screen.
  56696. * This acts as a helper to set the primary color to a more "human friendly" value.
  56697. * Conversion to linear space as well as exposure and tone mapping correction will be applied to keep the
  56698. * output color as close as possible from the chosen value.
  56699. * (This does not account for contrast color grading and color curves as they are considered post effect and not directly
  56700. * part of lighting setup.)
  56701. */
  56702. get _perceptualColor(): Nullable<Color3>;
  56703. set _perceptualColor(value: Nullable<Color3>);
  56704. protected _primaryColorShadowLevel: float;
  56705. /**
  56706. * Defines the level of the shadows (dark area of the reflection map) in order to help scaling the colors.
  56707. * The color opposite to the primary color is used at the level chosen to define what the black area would look.
  56708. */
  56709. get primaryColorShadowLevel(): float;
  56710. set primaryColorShadowLevel(value: float);
  56711. protected _primaryColorHighlightLevel: float;
  56712. /**
  56713. * Defines the level of the highliights (highlight area of the reflection map) in order to help scaling the colors.
  56714. * The primary color is used at the level chosen to define what the white area would look.
  56715. */
  56716. get primaryColorHighlightLevel(): float;
  56717. set primaryColorHighlightLevel(value: float);
  56718. protected _reflectionTexture: Nullable<BaseTexture>;
  56719. /**
  56720. * Reflection Texture used in the material.
  56721. * Should be author in a specific way for the best result (refer to the documentation).
  56722. */
  56723. reflectionTexture: Nullable<BaseTexture>;
  56724. protected _reflectionBlur: float;
  56725. /**
  56726. * Reflection Texture level of blur.
  56727. *
  56728. * Can be use to reuse an existing HDR Texture and target a specific LOD to prevent authoring the
  56729. * texture twice.
  56730. */
  56731. reflectionBlur: float;
  56732. protected _diffuseTexture: Nullable<BaseTexture>;
  56733. /**
  56734. * Diffuse Texture used in the material.
  56735. * Should be author in a specific way for the best result (refer to the documentation).
  56736. */
  56737. diffuseTexture: Nullable<BaseTexture>;
  56738. protected _shadowLights: Nullable<IShadowLight[]>;
  56739. /**
  56740. * Specify the list of lights casting shadow on the material.
  56741. * All scene shadow lights will be included if null.
  56742. */
  56743. shadowLights: Nullable<IShadowLight[]>;
  56744. protected _shadowLevel: float;
  56745. /**
  56746. * Helps adjusting the shadow to a softer level if required.
  56747. * 0 means black shadows and 1 means no shadows.
  56748. */
  56749. shadowLevel: float;
  56750. protected _sceneCenter: Vector3;
  56751. /**
  56752. * In case of opacity Fresnel or reflection falloff, this is use as a scene center.
  56753. * It is usually zero but might be interesting to modify according to your setup.
  56754. */
  56755. sceneCenter: Vector3;
  56756. protected _opacityFresnel: boolean;
  56757. /**
  56758. * This helps specifying that the material is falling off to the sky box at grazing angle.
  56759. * This helps ensuring a nice transition when the camera goes under the ground.
  56760. */
  56761. opacityFresnel: boolean;
  56762. protected _reflectionFresnel: boolean;
  56763. /**
  56764. * This helps specifying that the material is falling off from diffuse to the reflection texture at grazing angle.
  56765. * This helps adding a mirror texture on the ground.
  56766. */
  56767. reflectionFresnel: boolean;
  56768. protected _reflectionFalloffDistance: number;
  56769. /**
  56770. * This helps specifying the falloff radius off the reflection texture from the sceneCenter.
  56771. * This helps adding a nice falloff effect to the reflection if used as a mirror for instance.
  56772. */
  56773. reflectionFalloffDistance: number;
  56774. protected _reflectionAmount: number;
  56775. /**
  56776. * This specifies the weight of the reflection against the background in case of reflection Fresnel.
  56777. */
  56778. reflectionAmount: number;
  56779. protected _reflectionReflectance0: number;
  56780. /**
  56781. * This specifies the weight of the reflection at grazing angle.
  56782. */
  56783. reflectionReflectance0: number;
  56784. protected _reflectionReflectance90: number;
  56785. /**
  56786. * This specifies the weight of the reflection at a perpendicular point of view.
  56787. */
  56788. reflectionReflectance90: number;
  56789. /**
  56790. * Sets the reflection reflectance fresnel values according to the default standard
  56791. * empirically know to work well :-)
  56792. */
  56793. set reflectionStandardFresnelWeight(value: number);
  56794. protected _useRGBColor: boolean;
  56795. /**
  56796. * Helps to directly use the maps channels instead of their level.
  56797. */
  56798. useRGBColor: boolean;
  56799. protected _enableNoise: boolean;
  56800. /**
  56801. * This helps reducing the banding effect that could occur on the background.
  56802. */
  56803. enableNoise: boolean;
  56804. /**
  56805. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  56806. * Best used when trying to implement visual zoom effects like fish-eye or binoculars while not adjusting camera fov.
  56807. * Recommended to be keep at 1.0 except for special cases.
  56808. */
  56809. get fovMultiplier(): number;
  56810. set fovMultiplier(value: number);
  56811. private _fovMultiplier;
  56812. /**
  56813. * Enable the FOV adjustment feature controlled by fovMultiplier.
  56814. */
  56815. useEquirectangularFOV: boolean;
  56816. private _maxSimultaneousLights;
  56817. /**
  56818. * Number of Simultaneous lights allowed on the material.
  56819. */
  56820. maxSimultaneousLights: int;
  56821. private _shadowOnly;
  56822. /**
  56823. * Make the material only render shadows
  56824. */
  56825. shadowOnly: boolean;
  56826. /**
  56827. * Default configuration related to image processing available in the Background Material.
  56828. */
  56829. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  56830. /**
  56831. * Keep track of the image processing observer to allow dispose and replace.
  56832. */
  56833. private _imageProcessingObserver;
  56834. /**
  56835. * Attaches a new image processing configuration to the PBR Material.
  56836. * @param configuration (if null the scene configuration will be use)
  56837. */
  56838. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  56839. /**
  56840. * Gets the image processing configuration used either in this material.
  56841. */
  56842. get imageProcessingConfiguration(): Nullable<ImageProcessingConfiguration>;
  56843. /**
  56844. * Sets the Default image processing configuration used either in the this material.
  56845. *
  56846. * If sets to null, the scene one is in use.
  56847. */
  56848. set imageProcessingConfiguration(value: Nullable<ImageProcessingConfiguration>);
  56849. /**
  56850. * Gets wether the color curves effect is enabled.
  56851. */
  56852. get cameraColorCurvesEnabled(): boolean;
  56853. /**
  56854. * Sets wether the color curves effect is enabled.
  56855. */
  56856. set cameraColorCurvesEnabled(value: boolean);
  56857. /**
  56858. * Gets wether the color grading effect is enabled.
  56859. */
  56860. get cameraColorGradingEnabled(): boolean;
  56861. /**
  56862. * Gets wether the color grading effect is enabled.
  56863. */
  56864. set cameraColorGradingEnabled(value: boolean);
  56865. /**
  56866. * Gets wether tonemapping is enabled or not.
  56867. */
  56868. get cameraToneMappingEnabled(): boolean;
  56869. /**
  56870. * Sets wether tonemapping is enabled or not
  56871. */
  56872. set cameraToneMappingEnabled(value: boolean);
  56873. /**
  56874. * The camera exposure used on this material.
  56875. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  56876. * This corresponds to a photographic exposure.
  56877. */
  56878. get cameraExposure(): float;
  56879. /**
  56880. * The camera exposure used on this material.
  56881. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  56882. * This corresponds to a photographic exposure.
  56883. */
  56884. set cameraExposure(value: float);
  56885. /**
  56886. * Gets The camera contrast used on this material.
  56887. */
  56888. get cameraContrast(): float;
  56889. /**
  56890. * Sets The camera contrast used on this material.
  56891. */
  56892. set cameraContrast(value: float);
  56893. /**
  56894. * Gets the Color Grading 2D Lookup Texture.
  56895. */
  56896. get cameraColorGradingTexture(): Nullable<BaseTexture>;
  56897. /**
  56898. * Sets the Color Grading 2D Lookup Texture.
  56899. */
  56900. set cameraColorGradingTexture(value: Nullable<BaseTexture>);
  56901. /**
  56902. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  56903. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  56904. * 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;
  56905. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  56906. */
  56907. get cameraColorCurves(): Nullable<ColorCurves>;
  56908. /**
  56909. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  56910. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  56911. * 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;
  56912. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  56913. */
  56914. set cameraColorCurves(value: Nullable<ColorCurves>);
  56915. /**
  56916. * Due to a bug in iOS10, video tags (which are using the background material) are in BGR and not RGB.
  56917. * Setting this flag to true (not done automatically!) will convert it back to RGB.
  56918. */
  56919. switchToBGR: boolean;
  56920. private _renderTargets;
  56921. private _reflectionControls;
  56922. private _white;
  56923. private _primaryShadowColor;
  56924. private _primaryHighlightColor;
  56925. /**
  56926. * Instantiates a Background Material in the given scene
  56927. * @param name The friendly name of the material
  56928. * @param scene The scene to add the material to
  56929. */
  56930. constructor(name: string, scene: Scene);
  56931. /**
  56932. * Gets a boolean indicating that current material needs to register RTT
  56933. */
  56934. get hasRenderTargetTextures(): boolean;
  56935. /**
  56936. * The entire material has been created in order to prevent overdraw.
  56937. * @returns false
  56938. */
  56939. needAlphaTesting(): boolean;
  56940. /**
  56941. * The entire material has been created in order to prevent overdraw.
  56942. * @returns true if blending is enable
  56943. */
  56944. needAlphaBlending(): boolean;
  56945. /**
  56946. * Checks wether the material is ready to be rendered for a given mesh.
  56947. * @param mesh The mesh to render
  56948. * @param subMesh The submesh to check against
  56949. * @param useInstances Specify wether or not the material is used with instances
  56950. * @returns true if all the dependencies are ready (Textures, Effects...)
  56951. */
  56952. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  56953. /**
  56954. * Compute the primary color according to the chosen perceptual color.
  56955. */
  56956. private _computePrimaryColorFromPerceptualColor;
  56957. /**
  56958. * Compute the highlights and shadow colors according to their chosen levels.
  56959. */
  56960. private _computePrimaryColors;
  56961. /**
  56962. * Build the uniform buffer used in the material.
  56963. */
  56964. buildUniformLayout(): void;
  56965. /**
  56966. * Unbind the material.
  56967. */
  56968. unbind(): void;
  56969. /**
  56970. * Bind only the world matrix to the material.
  56971. * @param world The world matrix to bind.
  56972. */
  56973. bindOnlyWorldMatrix(world: Matrix): void;
  56974. /**
  56975. * Bind the material for a dedicated submeh (every used meshes will be considered opaque).
  56976. * @param world The world matrix to bind.
  56977. * @param subMesh The submesh to bind for.
  56978. */
  56979. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  56980. /**
  56981. * Checks to see if a texture is used in the material.
  56982. * @param texture - Base texture to use.
  56983. * @returns - Boolean specifying if a texture is used in the material.
  56984. */
  56985. hasTexture(texture: BaseTexture): boolean;
  56986. /**
  56987. * Dispose the material.
  56988. * @param forceDisposeEffect Force disposal of the associated effect.
  56989. * @param forceDisposeTextures Force disposal of the associated textures.
  56990. */
  56991. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  56992. /**
  56993. * Clones the material.
  56994. * @param name The cloned name.
  56995. * @returns The cloned material.
  56996. */
  56997. clone(name: string): BackgroundMaterial;
  56998. /**
  56999. * Serializes the current material to its JSON representation.
  57000. * @returns The JSON representation.
  57001. */
  57002. serialize(): any;
  57003. /**
  57004. * Gets the class name of the material
  57005. * @returns "BackgroundMaterial"
  57006. */
  57007. getClassName(): string;
  57008. /**
  57009. * Parse a JSON input to create back a background material.
  57010. * @param source The JSON data to parse
  57011. * @param scene The scene to create the parsed material in
  57012. * @param rootUrl The root url of the assets the material depends upon
  57013. * @returns the instantiated BackgroundMaterial.
  57014. */
  57015. static Parse(source: any, scene: Scene, rootUrl: string): BackgroundMaterial;
  57016. }
  57017. }
  57018. declare module "babylonjs/Helpers/environmentHelper" {
  57019. import { Observable } from "babylonjs/Misc/observable";
  57020. import { Nullable } from "babylonjs/types";
  57021. import { Scene } from "babylonjs/scene";
  57022. import { Vector3 } from "babylonjs/Maths/math.vector";
  57023. import { Color3 } from "babylonjs/Maths/math.color";
  57024. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  57025. import { Mesh } from "babylonjs/Meshes/mesh";
  57026. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  57027. import { MirrorTexture } from "babylonjs/Materials/Textures/mirrorTexture";
  57028. import { BackgroundMaterial } from "babylonjs/Materials/Background/backgroundMaterial";
  57029. import "babylonjs/Meshes/Builders/planeBuilder";
  57030. import "babylonjs/Meshes/Builders/boxBuilder";
  57031. /**
  57032. * Represents the different options available during the creation of
  57033. * a Environment helper.
  57034. *
  57035. * This can control the default ground, skybox and image processing setup of your scene.
  57036. */
  57037. export interface IEnvironmentHelperOptions {
  57038. /**
  57039. * Specifies whether or not to create a ground.
  57040. * True by default.
  57041. */
  57042. createGround: boolean;
  57043. /**
  57044. * Specifies the ground size.
  57045. * 15 by default.
  57046. */
  57047. groundSize: number;
  57048. /**
  57049. * The texture used on the ground for the main color.
  57050. * Comes from the BabylonJS CDN by default.
  57051. *
  57052. * Remarks: Can be either a texture or a url.
  57053. */
  57054. groundTexture: string | BaseTexture;
  57055. /**
  57056. * The color mixed in the ground texture by default.
  57057. * BabylonJS clearColor by default.
  57058. */
  57059. groundColor: Color3;
  57060. /**
  57061. * Specifies the ground opacity.
  57062. * 1 by default.
  57063. */
  57064. groundOpacity: number;
  57065. /**
  57066. * Enables the ground to receive shadows.
  57067. * True by default.
  57068. */
  57069. enableGroundShadow: boolean;
  57070. /**
  57071. * Helps preventing the shadow to be fully black on the ground.
  57072. * 0.5 by default.
  57073. */
  57074. groundShadowLevel: number;
  57075. /**
  57076. * Creates a mirror texture attach to the ground.
  57077. * false by default.
  57078. */
  57079. enableGroundMirror: boolean;
  57080. /**
  57081. * Specifies the ground mirror size ratio.
  57082. * 0.3 by default as the default kernel is 64.
  57083. */
  57084. groundMirrorSizeRatio: number;
  57085. /**
  57086. * Specifies the ground mirror blur kernel size.
  57087. * 64 by default.
  57088. */
  57089. groundMirrorBlurKernel: number;
  57090. /**
  57091. * Specifies the ground mirror visibility amount.
  57092. * 1 by default
  57093. */
  57094. groundMirrorAmount: number;
  57095. /**
  57096. * Specifies the ground mirror reflectance weight.
  57097. * This uses the standard weight of the background material to setup the fresnel effect
  57098. * of the mirror.
  57099. * 1 by default.
  57100. */
  57101. groundMirrorFresnelWeight: number;
  57102. /**
  57103. * Specifies the ground mirror Falloff distance.
  57104. * This can helps reducing the size of the reflection.
  57105. * 0 by Default.
  57106. */
  57107. groundMirrorFallOffDistance: number;
  57108. /**
  57109. * Specifies the ground mirror texture type.
  57110. * Unsigned Int by Default.
  57111. */
  57112. groundMirrorTextureType: number;
  57113. /**
  57114. * Specifies a bias applied to the ground vertical position to prevent z-fighting with
  57115. * the shown objects.
  57116. */
  57117. groundYBias: number;
  57118. /**
  57119. * Specifies whether or not to create a skybox.
  57120. * True by default.
  57121. */
  57122. createSkybox: boolean;
  57123. /**
  57124. * Specifies the skybox size.
  57125. * 20 by default.
  57126. */
  57127. skyboxSize: number;
  57128. /**
  57129. * The texture used on the skybox for the main color.
  57130. * Comes from the BabylonJS CDN by default.
  57131. *
  57132. * Remarks: Can be either a texture or a url.
  57133. */
  57134. skyboxTexture: string | BaseTexture;
  57135. /**
  57136. * The color mixed in the skybox texture by default.
  57137. * BabylonJS clearColor by default.
  57138. */
  57139. skyboxColor: Color3;
  57140. /**
  57141. * The background rotation around the Y axis of the scene.
  57142. * This helps aligning the key lights of your scene with the background.
  57143. * 0 by default.
  57144. */
  57145. backgroundYRotation: number;
  57146. /**
  57147. * Compute automatically the size of the elements to best fit with the scene.
  57148. */
  57149. sizeAuto: boolean;
  57150. /**
  57151. * Default position of the rootMesh if autoSize is not true.
  57152. */
  57153. rootPosition: Vector3;
  57154. /**
  57155. * Sets up the image processing in the scene.
  57156. * true by default.
  57157. */
  57158. setupImageProcessing: boolean;
  57159. /**
  57160. * The texture used as your environment texture in the scene.
  57161. * Comes from the BabylonJS CDN by default and in use if setupImageProcessing is true.
  57162. *
  57163. * Remarks: Can be either a texture or a url.
  57164. */
  57165. environmentTexture: string | BaseTexture;
  57166. /**
  57167. * The value of the exposure to apply to the scene.
  57168. * 0.6 by default if setupImageProcessing is true.
  57169. */
  57170. cameraExposure: number;
  57171. /**
  57172. * The value of the contrast to apply to the scene.
  57173. * 1.6 by default if setupImageProcessing is true.
  57174. */
  57175. cameraContrast: number;
  57176. /**
  57177. * Specifies whether or not tonemapping should be enabled in the scene.
  57178. * true by default if setupImageProcessing is true.
  57179. */
  57180. toneMappingEnabled: boolean;
  57181. }
  57182. /**
  57183. * The Environment helper class can be used to add a fully featuread none expensive background to your scene.
  57184. * It includes by default a skybox and a ground relying on the BackgroundMaterial.
  57185. * It also helps with the default setup of your imageProcessing configuration.
  57186. */
  57187. export class EnvironmentHelper {
  57188. /**
  57189. * Default ground texture URL.
  57190. */
  57191. private static _groundTextureCDNUrl;
  57192. /**
  57193. * Default skybox texture URL.
  57194. */
  57195. private static _skyboxTextureCDNUrl;
  57196. /**
  57197. * Default environment texture URL.
  57198. */
  57199. private static _environmentTextureCDNUrl;
  57200. /**
  57201. * Creates the default options for the helper.
  57202. */
  57203. private static _getDefaultOptions;
  57204. private _rootMesh;
  57205. /**
  57206. * Gets the root mesh created by the helper.
  57207. */
  57208. get rootMesh(): Mesh;
  57209. private _skybox;
  57210. /**
  57211. * Gets the skybox created by the helper.
  57212. */
  57213. get skybox(): Nullable<Mesh>;
  57214. private _skyboxTexture;
  57215. /**
  57216. * Gets the skybox texture created by the helper.
  57217. */
  57218. get skyboxTexture(): Nullable<BaseTexture>;
  57219. private _skyboxMaterial;
  57220. /**
  57221. * Gets the skybox material created by the helper.
  57222. */
  57223. get skyboxMaterial(): Nullable<BackgroundMaterial>;
  57224. private _ground;
  57225. /**
  57226. * Gets the ground mesh created by the helper.
  57227. */
  57228. get ground(): Nullable<Mesh>;
  57229. private _groundTexture;
  57230. /**
  57231. * Gets the ground texture created by the helper.
  57232. */
  57233. get groundTexture(): Nullable<BaseTexture>;
  57234. private _groundMirror;
  57235. /**
  57236. * Gets the ground mirror created by the helper.
  57237. */
  57238. get groundMirror(): Nullable<MirrorTexture>;
  57239. /**
  57240. * Gets the ground mirror render list to helps pushing the meshes
  57241. * you wish in the ground reflection.
  57242. */
  57243. get groundMirrorRenderList(): Nullable<AbstractMesh[]>;
  57244. private _groundMaterial;
  57245. /**
  57246. * Gets the ground material created by the helper.
  57247. */
  57248. get groundMaterial(): Nullable<BackgroundMaterial>;
  57249. /**
  57250. * Stores the creation options.
  57251. */
  57252. private readonly _scene;
  57253. private _options;
  57254. /**
  57255. * This observable will be notified with any error during the creation of the environment,
  57256. * mainly texture creation errors.
  57257. */
  57258. onErrorObservable: Observable<{
  57259. message?: string;
  57260. exception?: any;
  57261. }>;
  57262. /**
  57263. * constructor
  57264. * @param options Defines the options we want to customize the helper
  57265. * @param scene The scene to add the material to
  57266. */
  57267. constructor(options: Partial<IEnvironmentHelperOptions>, scene: Scene);
  57268. /**
  57269. * Updates the background according to the new options
  57270. * @param options
  57271. */
  57272. updateOptions(options: Partial<IEnvironmentHelperOptions>): void;
  57273. /**
  57274. * Sets the primary color of all the available elements.
  57275. * @param color the main color to affect to the ground and the background
  57276. */
  57277. setMainColor(color: Color3): void;
  57278. /**
  57279. * Setup the image processing according to the specified options.
  57280. */
  57281. private _setupImageProcessing;
  57282. /**
  57283. * Setup the environment texture according to the specified options.
  57284. */
  57285. private _setupEnvironmentTexture;
  57286. /**
  57287. * Setup the background according to the specified options.
  57288. */
  57289. private _setupBackground;
  57290. /**
  57291. * Get the scene sizes according to the setup.
  57292. */
  57293. private _getSceneSize;
  57294. /**
  57295. * Setup the ground according to the specified options.
  57296. */
  57297. private _setupGround;
  57298. /**
  57299. * Setup the ground material according to the specified options.
  57300. */
  57301. private _setupGroundMaterial;
  57302. /**
  57303. * Setup the ground diffuse texture according to the specified options.
  57304. */
  57305. private _setupGroundDiffuseTexture;
  57306. /**
  57307. * Setup the ground mirror texture according to the specified options.
  57308. */
  57309. private _setupGroundMirrorTexture;
  57310. /**
  57311. * Setup the ground to receive the mirror texture.
  57312. */
  57313. private _setupMirrorInGroundMaterial;
  57314. /**
  57315. * Setup the skybox according to the specified options.
  57316. */
  57317. private _setupSkybox;
  57318. /**
  57319. * Setup the skybox material according to the specified options.
  57320. */
  57321. private _setupSkyboxMaterial;
  57322. /**
  57323. * Setup the skybox reflection texture according to the specified options.
  57324. */
  57325. private _setupSkyboxReflectionTexture;
  57326. private _errorHandler;
  57327. /**
  57328. * Dispose all the elements created by the Helper.
  57329. */
  57330. dispose(): void;
  57331. }
  57332. }
  57333. declare module "babylonjs/Helpers/textureDome" {
  57334. import { Scene } from "babylonjs/scene";
  57335. import { TransformNode } from "babylonjs/Meshes/transformNode";
  57336. import { Mesh } from "babylonjs/Meshes/mesh";
  57337. import { Texture } from "babylonjs/Materials/Textures/texture";
  57338. import { BackgroundMaterial } from "babylonjs/Materials/Background/backgroundMaterial";
  57339. import "babylonjs/Meshes/Builders/sphereBuilder";
  57340. import { Nullable } from "babylonjs/types";
  57341. import { Observable } from "babylonjs/Misc/observable";
  57342. /**
  57343. * Display a 360/180 degree texture on an approximately spherical surface, useful for VR applications or skyboxes.
  57344. * As a subclass of TransformNode, this allow parenting to the camera or multiple textures with different locations in the scene.
  57345. * This class achieves its effect with a Texture and a correctly configured BackgroundMaterial on an inverted sphere.
  57346. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  57347. */
  57348. export abstract class TextureDome<T extends Texture> extends TransformNode {
  57349. protected onError: Nullable<(message?: string, exception?: any) => void>;
  57350. /**
  57351. * Define the source as a Monoscopic panoramic 360/180.
  57352. */
  57353. static readonly MODE_MONOSCOPIC: number;
  57354. /**
  57355. * Define the source as a Stereoscopic TopBottom/OverUnder panoramic 360/180.
  57356. */
  57357. static readonly MODE_TOPBOTTOM: number;
  57358. /**
  57359. * Define the source as a Stereoscopic Side by Side panoramic 360/180.
  57360. */
  57361. static readonly MODE_SIDEBYSIDE: number;
  57362. private _halfDome;
  57363. protected _useDirectMapping: boolean;
  57364. /**
  57365. * The texture being displayed on the sphere
  57366. */
  57367. protected _texture: T;
  57368. /**
  57369. * Gets the texture being displayed on the sphere
  57370. */
  57371. get texture(): T;
  57372. /**
  57373. * Sets the texture being displayed on the sphere
  57374. */
  57375. set texture(newTexture: T);
  57376. /**
  57377. * The skybox material
  57378. */
  57379. protected _material: BackgroundMaterial;
  57380. /**
  57381. * The surface used for the dome
  57382. */
  57383. protected _mesh: Mesh;
  57384. /**
  57385. * Gets the mesh used for the dome.
  57386. */
  57387. get mesh(): Mesh;
  57388. /**
  57389. * A mesh that will be used to mask the back of the dome in case it is a 180 degree movie.
  57390. */
  57391. private _halfDomeMask;
  57392. /**
  57393. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  57394. * Also see the options.resolution property.
  57395. */
  57396. get fovMultiplier(): number;
  57397. set fovMultiplier(value: number);
  57398. protected _textureMode: number;
  57399. /**
  57400. * Gets or set the current texture mode for the texture. It can be:
  57401. * * TextureDome.MODE_MONOSCOPIC : Define the texture source as a Monoscopic panoramic 360.
  57402. * * TextureDome.MODE_TOPBOTTOM : Define the texture source as a Stereoscopic TopBottom/OverUnder panoramic 360.
  57403. * * TextureDome.MODE_SIDEBYSIDE : Define the texture source as a Stereoscopic Side by Side panoramic 360.
  57404. */
  57405. get textureMode(): number;
  57406. /**
  57407. * Sets the current texture mode for the texture. It can be:
  57408. * * TextureDome.MODE_MONOSCOPIC : Define the texture source as a Monoscopic panoramic 360.
  57409. * * TextureDome.MODE_TOPBOTTOM : Define the texture source as a Stereoscopic TopBottom/OverUnder panoramic 360.
  57410. * * TextureDome.MODE_SIDEBYSIDE : Define the texture source as a Stereoscopic Side by Side panoramic 360.
  57411. */
  57412. set textureMode(value: number);
  57413. /**
  57414. * Is it a 180 degrees dome (half dome) or 360 texture (full dome)
  57415. */
  57416. get halfDome(): boolean;
  57417. /**
  57418. * Set the halfDome mode. If set, only the front (180 degrees) will be displayed and the back will be blacked out.
  57419. */
  57420. set halfDome(enabled: boolean);
  57421. /**
  57422. * Oberserver used in Stereoscopic VR Mode.
  57423. */
  57424. private _onBeforeCameraRenderObserver;
  57425. /**
  57426. * Observable raised when an error occured while loading the 360 image
  57427. */
  57428. onLoadErrorObservable: Observable<string>;
  57429. /**
  57430. * Create an instance of this class and pass through the parameters to the relevant classes- Texture, StandardMaterial, and Mesh.
  57431. * @param name Element's name, child elements will append suffixes for their own names.
  57432. * @param textureUrlOrElement defines the url(s) or the (video) HTML element to use
  57433. * @param options An object containing optional or exposed sub element properties
  57434. */
  57435. constructor(name: string, textureUrlOrElement: string | string[] | HTMLVideoElement, options: {
  57436. resolution?: number;
  57437. clickToPlay?: boolean;
  57438. autoPlay?: boolean;
  57439. loop?: boolean;
  57440. size?: number;
  57441. poster?: string;
  57442. faceForward?: boolean;
  57443. useDirectMapping?: boolean;
  57444. halfDomeMode?: boolean;
  57445. }, scene: Scene, onError?: Nullable<(message?: string, exception?: any) => void>);
  57446. protected abstract _initTexture(urlsOrElement: string | string[] | HTMLElement, scene: Scene, options: any): T;
  57447. protected _changeTextureMode(value: number): void;
  57448. /**
  57449. * Releases resources associated with this node.
  57450. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  57451. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  57452. */
  57453. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  57454. }
  57455. }
  57456. declare module "babylonjs/Helpers/photoDome" {
  57457. import { Scene } from "babylonjs/scene";
  57458. import { Texture } from "babylonjs/Materials/Textures/texture";
  57459. import { TextureDome } from "babylonjs/Helpers/textureDome";
  57460. /**
  57461. * Display a 360 degree photo on an approximately spherical surface, useful for VR applications or skyboxes.
  57462. * As a subclass of TransformNode, this allow parenting to the camera with different locations in the scene.
  57463. * This class achieves its effect with a Texture and a correctly configured BackgroundMaterial on an inverted sphere.
  57464. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  57465. */
  57466. export class PhotoDome extends TextureDome<Texture> {
  57467. /**
  57468. * Define the image as a Monoscopic panoramic 360 image.
  57469. */
  57470. static readonly MODE_MONOSCOPIC: number;
  57471. /**
  57472. * Define the image as a Stereoscopic TopBottom/OverUnder panoramic 360 image.
  57473. */
  57474. static readonly MODE_TOPBOTTOM: number;
  57475. /**
  57476. * Define the image as a Stereoscopic Side by Side panoramic 360 image.
  57477. */
  57478. static readonly MODE_SIDEBYSIDE: number;
  57479. /**
  57480. * Gets or sets the texture being displayed on the sphere
  57481. */
  57482. get photoTexture(): Texture;
  57483. /**
  57484. * sets the texture being displayed on the sphere
  57485. */
  57486. set photoTexture(value: Texture);
  57487. /**
  57488. * Gets the current video mode for the video. It can be:
  57489. * * TextureDome.MODE_MONOSCOPIC : Define the texture source as a Monoscopic panoramic 360.
  57490. * * TextureDome.MODE_TOPBOTTOM : Define the texture source as a Stereoscopic TopBottom/OverUnder panoramic 360.
  57491. * * TextureDome.MODE_SIDEBYSIDE : Define the texture source as a Stereoscopic Side by Side panoramic 360.
  57492. */
  57493. get imageMode(): number;
  57494. /**
  57495. * Sets the current video mode for the video. It can be:
  57496. * * TextureDome.MODE_MONOSCOPIC : Define the texture source as a Monoscopic panoramic 360.
  57497. * * TextureDome.MODE_TOPBOTTOM : Define the texture source as a Stereoscopic TopBottom/OverUnder panoramic 360.
  57498. * * TextureDome.MODE_SIDEBYSIDE : Define the texture source as a Stereoscopic Side by Side panoramic 360.
  57499. */
  57500. set imageMode(value: number);
  57501. protected _initTexture(urlsOrElement: string, scene: Scene, options: any): Texture;
  57502. }
  57503. }
  57504. declare module "babylonjs/Misc/rgbdTextureTools" {
  57505. import "babylonjs/Shaders/rgbdDecode.fragment";
  57506. import "babylonjs/Engines/Extensions/engine.renderTarget";
  57507. import { Texture } from "babylonjs/Materials/Textures/texture";
  57508. /**
  57509. * Class used to host RGBD texture specific utilities
  57510. */
  57511. export class RGBDTextureTools {
  57512. /**
  57513. * Expand the RGBD Texture from RGBD to Half Float if possible.
  57514. * @param texture the texture to expand.
  57515. */
  57516. static ExpandRGBDTexture(texture: Texture): void;
  57517. }
  57518. }
  57519. declare module "babylonjs/Misc/brdfTextureTools" {
  57520. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  57521. import { Scene } from "babylonjs/scene";
  57522. /**
  57523. * Class used to host texture specific utilities
  57524. */
  57525. export class BRDFTextureTools {
  57526. /**
  57527. * Prevents texture cache collision
  57528. */
  57529. private static _instanceNumber;
  57530. /**
  57531. * Gets a default environment BRDF for MS-BRDF Height Correlated BRDF
  57532. * @param scene defines the hosting scene
  57533. * @returns the environment BRDF texture
  57534. */
  57535. static GetEnvironmentBRDFTexture(scene: Scene): BaseTexture;
  57536. private static _environmentBRDFBase64Texture;
  57537. }
  57538. }
  57539. declare module "babylonjs/Materials/PBR/pbrClearCoatConfiguration" {
  57540. import { Nullable } from "babylonjs/types";
  57541. import { Color3 } from "babylonjs/Maths/math.color";
  57542. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  57543. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  57544. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  57545. import { EffectFallbacks } from "babylonjs/Materials/effectFallbacks";
  57546. import { Engine } from "babylonjs/Engines/engine";
  57547. import { Scene } from "babylonjs/scene";
  57548. /**
  57549. * @hidden
  57550. */
  57551. export interface IMaterialClearCoatDefines {
  57552. CLEARCOAT: boolean;
  57553. CLEARCOAT_DEFAULTIOR: boolean;
  57554. CLEARCOAT_TEXTURE: boolean;
  57555. CLEARCOAT_TEXTUREDIRECTUV: number;
  57556. CLEARCOAT_BUMP: boolean;
  57557. CLEARCOAT_BUMPDIRECTUV: number;
  57558. CLEARCOAT_TINT: boolean;
  57559. CLEARCOAT_TINT_TEXTURE: boolean;
  57560. CLEARCOAT_TINT_TEXTUREDIRECTUV: number;
  57561. /** @hidden */
  57562. _areTexturesDirty: boolean;
  57563. }
  57564. /**
  57565. * Define the code related to the clear coat parameters of the pbr material.
  57566. */
  57567. export class PBRClearCoatConfiguration {
  57568. /**
  57569. * This defaults to 1.5 corresponding to a 0.04 f0 or a 4% reflectance at normal incidence
  57570. * The default fits with a polyurethane material.
  57571. */
  57572. private static readonly _DefaultIndexOfRefraction;
  57573. private _isEnabled;
  57574. /**
  57575. * Defines if the clear coat is enabled in the material.
  57576. */
  57577. isEnabled: boolean;
  57578. /**
  57579. * Defines the clear coat layer strength (between 0 and 1) it defaults to 1.
  57580. */
  57581. intensity: number;
  57582. /**
  57583. * Defines the clear coat layer roughness.
  57584. */
  57585. roughness: number;
  57586. private _indexOfRefraction;
  57587. /**
  57588. * Defines the index of refraction of the clear coat.
  57589. * This defaults to 1.5 corresponding to a 0.04 f0 or a 4% reflectance at normal incidence
  57590. * The default fits with a polyurethane material.
  57591. * Changing the default value is more performance intensive.
  57592. */
  57593. indexOfRefraction: number;
  57594. private _texture;
  57595. /**
  57596. * Stores the clear coat values in a texture.
  57597. */
  57598. texture: Nullable<BaseTexture>;
  57599. private _bumpTexture;
  57600. /**
  57601. * Define the clear coat specific bump texture.
  57602. */
  57603. bumpTexture: Nullable<BaseTexture>;
  57604. private _isTintEnabled;
  57605. /**
  57606. * Defines if the clear coat tint is enabled in the material.
  57607. */
  57608. isTintEnabled: boolean;
  57609. /**
  57610. * Defines the clear coat tint of the material.
  57611. * This is only use if tint is enabled
  57612. */
  57613. tintColor: Color3;
  57614. /**
  57615. * Defines the distance at which the tint color should be found in the
  57616. * clear coat media.
  57617. * This is only use if tint is enabled
  57618. */
  57619. tintColorAtDistance: number;
  57620. /**
  57621. * Defines the clear coat layer thickness.
  57622. * This is only use if tint is enabled
  57623. */
  57624. tintThickness: number;
  57625. private _tintTexture;
  57626. /**
  57627. * Stores the clear tint values in a texture.
  57628. * rgb is tint
  57629. * a is a thickness factor
  57630. */
  57631. tintTexture: Nullable<BaseTexture>;
  57632. /** @hidden */
  57633. private _internalMarkAllSubMeshesAsTexturesDirty;
  57634. /** @hidden */
  57635. _markAllSubMeshesAsTexturesDirty(): void;
  57636. /**
  57637. * Instantiate a new istance of clear coat configuration.
  57638. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  57639. */
  57640. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  57641. /**
  57642. * Gets wehter the submesh is ready to be used or not.
  57643. * @param defines the list of "defines" to update.
  57644. * @param scene defines the scene the material belongs to.
  57645. * @param engine defines the engine the material belongs to.
  57646. * @param disableBumpMap defines wether the material disables bump or not.
  57647. * @returns - boolean indicating that the submesh is ready or not.
  57648. */
  57649. isReadyForSubMesh(defines: IMaterialClearCoatDefines, scene: Scene, engine: Engine, disableBumpMap: boolean): boolean;
  57650. /**
  57651. * Checks to see if a texture is used in the material.
  57652. * @param defines the list of "defines" to update.
  57653. * @param scene defines the scene to the material belongs to.
  57654. */
  57655. prepareDefines(defines: IMaterialClearCoatDefines, scene: Scene): void;
  57656. /**
  57657. * Binds the material data.
  57658. * @param uniformBuffer defines the Uniform buffer to fill in.
  57659. * @param scene defines the scene the material belongs to.
  57660. * @param engine defines the engine the material belongs to.
  57661. * @param disableBumpMap defines wether the material disables bump or not.
  57662. * @param isFrozen defines wether the material is frozen or not.
  57663. * @param invertNormalMapX If sets to true, x component of normal map value will be inverted (x = 1.0 - x).
  57664. * @param invertNormalMapY If sets to true, y component of normal map value will be inverted (y = 1.0 - y).
  57665. */
  57666. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, engine: Engine, disableBumpMap: boolean, isFrozen: boolean, invertNormalMapX: boolean, invertNormalMapY: boolean): void;
  57667. /**
  57668. * Checks to see if a texture is used in the material.
  57669. * @param texture - Base texture to use.
  57670. * @returns - Boolean specifying if a texture is used in the material.
  57671. */
  57672. hasTexture(texture: BaseTexture): boolean;
  57673. /**
  57674. * Returns an array of the actively used textures.
  57675. * @param activeTextures Array of BaseTextures
  57676. */
  57677. getActiveTextures(activeTextures: BaseTexture[]): void;
  57678. /**
  57679. * Returns the animatable textures.
  57680. * @param animatables Array of animatable textures.
  57681. */
  57682. getAnimatables(animatables: IAnimatable[]): void;
  57683. /**
  57684. * Disposes the resources of the material.
  57685. * @param forceDisposeTextures - Forces the disposal of all textures.
  57686. */
  57687. dispose(forceDisposeTextures?: boolean): void;
  57688. /**
  57689. * Get the current class name of the texture useful for serialization or dynamic coding.
  57690. * @returns "PBRClearCoatConfiguration"
  57691. */
  57692. getClassName(): string;
  57693. /**
  57694. * Add fallbacks to the effect fallbacks list.
  57695. * @param defines defines the Base texture to use.
  57696. * @param fallbacks defines the current fallback list.
  57697. * @param currentRank defines the current fallback rank.
  57698. * @returns the new fallback rank.
  57699. */
  57700. static AddFallbacks(defines: IMaterialClearCoatDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  57701. /**
  57702. * Add the required uniforms to the current list.
  57703. * @param uniforms defines the current uniform list.
  57704. */
  57705. static AddUniforms(uniforms: string[]): void;
  57706. /**
  57707. * Add the required samplers to the current list.
  57708. * @param samplers defines the current sampler list.
  57709. */
  57710. static AddSamplers(samplers: string[]): void;
  57711. /**
  57712. * Add the required uniforms to the current buffer.
  57713. * @param uniformBuffer defines the current uniform buffer.
  57714. */
  57715. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  57716. /**
  57717. * Makes a duplicate of the current configuration into another one.
  57718. * @param clearCoatConfiguration define the config where to copy the info
  57719. */
  57720. copyTo(clearCoatConfiguration: PBRClearCoatConfiguration): void;
  57721. /**
  57722. * Serializes this clear coat configuration.
  57723. * @returns - An object with the serialized config.
  57724. */
  57725. serialize(): any;
  57726. /**
  57727. * Parses a anisotropy Configuration from a serialized object.
  57728. * @param source - Serialized object.
  57729. * @param scene Defines the scene we are parsing for
  57730. * @param rootUrl Defines the rootUrl to load from
  57731. */
  57732. parse(source: any, scene: Scene, rootUrl: string): void;
  57733. }
  57734. }
  57735. declare module "babylonjs/Materials/PBR/pbrAnisotropicConfiguration" {
  57736. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  57737. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  57738. import { Vector2 } from "babylonjs/Maths/math.vector";
  57739. import { Scene } from "babylonjs/scene";
  57740. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  57741. import { Nullable } from "babylonjs/types";
  57742. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  57743. import { EffectFallbacks } from "babylonjs/Materials/effectFallbacks";
  57744. /**
  57745. * @hidden
  57746. */
  57747. export interface IMaterialAnisotropicDefines {
  57748. ANISOTROPIC: boolean;
  57749. ANISOTROPIC_TEXTURE: boolean;
  57750. ANISOTROPIC_TEXTUREDIRECTUV: number;
  57751. MAINUV1: boolean;
  57752. _areTexturesDirty: boolean;
  57753. _needUVs: boolean;
  57754. }
  57755. /**
  57756. * Define the code related to the anisotropic parameters of the pbr material.
  57757. */
  57758. export class PBRAnisotropicConfiguration {
  57759. private _isEnabled;
  57760. /**
  57761. * Defines if the anisotropy is enabled in the material.
  57762. */
  57763. isEnabled: boolean;
  57764. /**
  57765. * Defines the anisotropy strength (between 0 and 1) it defaults to 1.
  57766. */
  57767. intensity: number;
  57768. /**
  57769. * Defines if the effect is along the tangents, bitangents or in between.
  57770. * By default, the effect is "strectching" the highlights along the tangents.
  57771. */
  57772. direction: Vector2;
  57773. private _texture;
  57774. /**
  57775. * Stores the anisotropy values in a texture.
  57776. * rg is direction (like normal from -1 to 1)
  57777. * b is a intensity
  57778. */
  57779. texture: Nullable<BaseTexture>;
  57780. /** @hidden */
  57781. private _internalMarkAllSubMeshesAsTexturesDirty;
  57782. /** @hidden */
  57783. _markAllSubMeshesAsTexturesDirty(): void;
  57784. /**
  57785. * Instantiate a new istance of anisotropy configuration.
  57786. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  57787. */
  57788. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  57789. /**
  57790. * Specifies that the submesh is ready to be used.
  57791. * @param defines the list of "defines" to update.
  57792. * @param scene defines the scene the material belongs to.
  57793. * @returns - boolean indicating that the submesh is ready or not.
  57794. */
  57795. isReadyForSubMesh(defines: IMaterialAnisotropicDefines, scene: Scene): boolean;
  57796. /**
  57797. * Checks to see if a texture is used in the material.
  57798. * @param defines the list of "defines" to update.
  57799. * @param mesh the mesh we are preparing the defines for.
  57800. * @param scene defines the scene the material belongs to.
  57801. */
  57802. prepareDefines(defines: IMaterialAnisotropicDefines, mesh: AbstractMesh, scene: Scene): void;
  57803. /**
  57804. * Binds the material data.
  57805. * @param uniformBuffer defines the Uniform buffer to fill in.
  57806. * @param scene defines the scene the material belongs to.
  57807. * @param isFrozen defines wether the material is frozen or not.
  57808. */
  57809. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean): void;
  57810. /**
  57811. * Checks to see if a texture is used in the material.
  57812. * @param texture - Base texture to use.
  57813. * @returns - Boolean specifying if a texture is used in the material.
  57814. */
  57815. hasTexture(texture: BaseTexture): boolean;
  57816. /**
  57817. * Returns an array of the actively used textures.
  57818. * @param activeTextures Array of BaseTextures
  57819. */
  57820. getActiveTextures(activeTextures: BaseTexture[]): void;
  57821. /**
  57822. * Returns the animatable textures.
  57823. * @param animatables Array of animatable textures.
  57824. */
  57825. getAnimatables(animatables: IAnimatable[]): void;
  57826. /**
  57827. * Disposes the resources of the material.
  57828. * @param forceDisposeTextures - Forces the disposal of all textures.
  57829. */
  57830. dispose(forceDisposeTextures?: boolean): void;
  57831. /**
  57832. * Get the current class name of the texture useful for serialization or dynamic coding.
  57833. * @returns "PBRAnisotropicConfiguration"
  57834. */
  57835. getClassName(): string;
  57836. /**
  57837. * Add fallbacks to the effect fallbacks list.
  57838. * @param defines defines the Base texture to use.
  57839. * @param fallbacks defines the current fallback list.
  57840. * @param currentRank defines the current fallback rank.
  57841. * @returns the new fallback rank.
  57842. */
  57843. static AddFallbacks(defines: IMaterialAnisotropicDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  57844. /**
  57845. * Add the required uniforms to the current list.
  57846. * @param uniforms defines the current uniform list.
  57847. */
  57848. static AddUniforms(uniforms: string[]): void;
  57849. /**
  57850. * Add the required uniforms to the current buffer.
  57851. * @param uniformBuffer defines the current uniform buffer.
  57852. */
  57853. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  57854. /**
  57855. * Add the required samplers to the current list.
  57856. * @param samplers defines the current sampler list.
  57857. */
  57858. static AddSamplers(samplers: string[]): void;
  57859. /**
  57860. * Makes a duplicate of the current configuration into another one.
  57861. * @param anisotropicConfiguration define the config where to copy the info
  57862. */
  57863. copyTo(anisotropicConfiguration: PBRAnisotropicConfiguration): void;
  57864. /**
  57865. * Serializes this anisotropy configuration.
  57866. * @returns - An object with the serialized config.
  57867. */
  57868. serialize(): any;
  57869. /**
  57870. * Parses a anisotropy Configuration from a serialized object.
  57871. * @param source - Serialized object.
  57872. * @param scene Defines the scene we are parsing for
  57873. * @param rootUrl Defines the rootUrl to load from
  57874. */
  57875. parse(source: any, scene: Scene, rootUrl: string): void;
  57876. }
  57877. }
  57878. declare module "babylonjs/Materials/PBR/pbrBRDFConfiguration" {
  57879. import { Scene } from "babylonjs/scene";
  57880. /**
  57881. * @hidden
  57882. */
  57883. export interface IMaterialBRDFDefines {
  57884. BRDF_V_HEIGHT_CORRELATED: boolean;
  57885. MS_BRDF_ENERGY_CONSERVATION: boolean;
  57886. SPHERICAL_HARMONICS: boolean;
  57887. SPECULAR_GLOSSINESS_ENERGY_CONSERVATION: boolean;
  57888. /** @hidden */
  57889. _areMiscDirty: boolean;
  57890. }
  57891. /**
  57892. * Define the code related to the BRDF parameters of the pbr material.
  57893. */
  57894. export class PBRBRDFConfiguration {
  57895. /**
  57896. * Default value used for the energy conservation.
  57897. * This should only be changed to adapt to the type of texture in scene.environmentBRDFTexture.
  57898. */
  57899. static DEFAULT_USE_ENERGY_CONSERVATION: boolean;
  57900. /**
  57901. * Default value used for the Smith Visibility Height Correlated mode.
  57902. * This should only be changed to adapt to the type of texture in scene.environmentBRDFTexture.
  57903. */
  57904. static DEFAULT_USE_SMITH_VISIBILITY_HEIGHT_CORRELATED: boolean;
  57905. /**
  57906. * Default value used for the IBL diffuse part.
  57907. * This can help switching back to the polynomials mode globally which is a tiny bit
  57908. * less GPU intensive at the drawback of a lower quality.
  57909. */
  57910. static DEFAULT_USE_SPHERICAL_HARMONICS: boolean;
  57911. /**
  57912. * Default value used for activating energy conservation for the specular workflow.
  57913. * If activated, the albedo color is multiplied with (1. - maxChannel(specular color)).
  57914. * If deactivated, a material is only physically plausible, when (albedo color + specular color) < 1.
  57915. */
  57916. static DEFAULT_USE_SPECULAR_GLOSSINESS_INPUT_ENERGY_CONSERVATION: boolean;
  57917. private _useEnergyConservation;
  57918. /**
  57919. * Defines if the material uses energy conservation.
  57920. */
  57921. useEnergyConservation: boolean;
  57922. private _useSmithVisibilityHeightCorrelated;
  57923. /**
  57924. * LEGACY Mode set to false
  57925. * Defines if the material uses height smith correlated visibility term.
  57926. * If you intent to not use our default BRDF, you need to load a separate BRDF Texture for the PBR
  57927. * You can either load https://assets.babylonjs.com/environments/uncorrelatedBRDF.png
  57928. * or https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds to have more precision
  57929. * Not relying on height correlated will also disable energy conservation.
  57930. */
  57931. useSmithVisibilityHeightCorrelated: boolean;
  57932. private _useSphericalHarmonics;
  57933. /**
  57934. * LEGACY Mode set to false
  57935. * Defines if the material uses spherical harmonics vs spherical polynomials for the
  57936. * diffuse part of the IBL.
  57937. * The harmonics despite a tiny bigger cost has been proven to provide closer results
  57938. * to the ground truth.
  57939. */
  57940. useSphericalHarmonics: boolean;
  57941. private _useSpecularGlossinessInputEnergyConservation;
  57942. /**
  57943. * Defines if the material uses energy conservation, when the specular workflow is active.
  57944. * If activated, the albedo color is multiplied with (1. - maxChannel(specular color)).
  57945. * If deactivated, a material is only physically plausible, when (albedo color + specular color) < 1.
  57946. * In the deactivated case, the material author has to ensure energy conservation, for a physically plausible rendering.
  57947. */
  57948. useSpecularGlossinessInputEnergyConservation: boolean;
  57949. /** @hidden */
  57950. private _internalMarkAllSubMeshesAsMiscDirty;
  57951. /** @hidden */
  57952. _markAllSubMeshesAsMiscDirty(): void;
  57953. /**
  57954. * Instantiate a new istance of clear coat configuration.
  57955. * @param markAllSubMeshesAsMiscDirty Callback to flag the material to dirty
  57956. */
  57957. constructor(markAllSubMeshesAsMiscDirty: () => void);
  57958. /**
  57959. * Checks to see if a texture is used in the material.
  57960. * @param defines the list of "defines" to update.
  57961. */
  57962. prepareDefines(defines: IMaterialBRDFDefines): void;
  57963. /**
  57964. * Get the current class name of the texture useful for serialization or dynamic coding.
  57965. * @returns "PBRClearCoatConfiguration"
  57966. */
  57967. getClassName(): string;
  57968. /**
  57969. * Makes a duplicate of the current configuration into another one.
  57970. * @param brdfConfiguration define the config where to copy the info
  57971. */
  57972. copyTo(brdfConfiguration: PBRBRDFConfiguration): void;
  57973. /**
  57974. * Serializes this BRDF configuration.
  57975. * @returns - An object with the serialized config.
  57976. */
  57977. serialize(): any;
  57978. /**
  57979. * Parses a anisotropy Configuration from a serialized object.
  57980. * @param source - Serialized object.
  57981. * @param scene Defines the scene we are parsing for
  57982. * @param rootUrl Defines the rootUrl to load from
  57983. */
  57984. parse(source: any, scene: Scene, rootUrl: string): void;
  57985. }
  57986. }
  57987. declare module "babylonjs/Materials/PBR/pbrSheenConfiguration" {
  57988. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  57989. import { Color3 } from "babylonjs/Maths/math.color";
  57990. import { Scene } from "babylonjs/scene";
  57991. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  57992. import { Nullable } from "babylonjs/types";
  57993. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  57994. import { EffectFallbacks } from "babylonjs/Materials/effectFallbacks";
  57995. /**
  57996. * @hidden
  57997. */
  57998. export interface IMaterialSheenDefines {
  57999. SHEEN: boolean;
  58000. SHEEN_TEXTURE: boolean;
  58001. SHEEN_TEXTUREDIRECTUV: number;
  58002. SHEEN_LINKWITHALBEDO: boolean;
  58003. SHEEN_ROUGHNESS: boolean;
  58004. SHEEN_ALBEDOSCALING: boolean;
  58005. /** @hidden */
  58006. _areTexturesDirty: boolean;
  58007. }
  58008. /**
  58009. * Define the code related to the Sheen parameters of the pbr material.
  58010. */
  58011. export class PBRSheenConfiguration {
  58012. private _isEnabled;
  58013. /**
  58014. * Defines if the material uses sheen.
  58015. */
  58016. isEnabled: boolean;
  58017. private _linkSheenWithAlbedo;
  58018. /**
  58019. * Defines if the sheen is linked to the sheen color.
  58020. */
  58021. linkSheenWithAlbedo: boolean;
  58022. /**
  58023. * Defines the sheen intensity.
  58024. */
  58025. intensity: number;
  58026. /**
  58027. * Defines the sheen color.
  58028. */
  58029. color: Color3;
  58030. private _texture;
  58031. /**
  58032. * Stores the sheen tint values in a texture.
  58033. * rgb is tint
  58034. * a is a intensity or roughness if roughness has been defined
  58035. */
  58036. texture: Nullable<BaseTexture>;
  58037. private _roughness;
  58038. /**
  58039. * Defines the sheen roughness.
  58040. * It is not taken into account if linkSheenWithAlbedo is true.
  58041. * To stay backward compatible, material roughness is used instead if sheen roughness = null
  58042. */
  58043. roughness: Nullable<number>;
  58044. private _albedoScaling;
  58045. /**
  58046. * If true, the sheen effect is layered above the base BRDF with the albedo-scaling technique.
  58047. * It allows the strength of the sheen effect to not depend on the base color of the material,
  58048. * making it easier to setup and tweak the effect
  58049. */
  58050. albedoScaling: boolean;
  58051. /** @hidden */
  58052. private _internalMarkAllSubMeshesAsTexturesDirty;
  58053. /** @hidden */
  58054. _markAllSubMeshesAsTexturesDirty(): void;
  58055. /**
  58056. * Instantiate a new istance of clear coat configuration.
  58057. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  58058. */
  58059. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  58060. /**
  58061. * Specifies that the submesh is ready to be used.
  58062. * @param defines the list of "defines" to update.
  58063. * @param scene defines the scene the material belongs to.
  58064. * @returns - boolean indicating that the submesh is ready or not.
  58065. */
  58066. isReadyForSubMesh(defines: IMaterialSheenDefines, scene: Scene): boolean;
  58067. /**
  58068. * Checks to see if a texture is used in the material.
  58069. * @param defines the list of "defines" to update.
  58070. * @param scene defines the scene the material belongs to.
  58071. */
  58072. prepareDefines(defines: IMaterialSheenDefines, scene: Scene): void;
  58073. /**
  58074. * Binds the material data.
  58075. * @param uniformBuffer defines the Uniform buffer to fill in.
  58076. * @param scene defines the scene the material belongs to.
  58077. * @param isFrozen defines wether the material is frozen or not.
  58078. */
  58079. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean): void;
  58080. /**
  58081. * Checks to see if a texture is used in the material.
  58082. * @param texture - Base texture to use.
  58083. * @returns - Boolean specifying if a texture is used in the material.
  58084. */
  58085. hasTexture(texture: BaseTexture): boolean;
  58086. /**
  58087. * Returns an array of the actively used textures.
  58088. * @param activeTextures Array of BaseTextures
  58089. */
  58090. getActiveTextures(activeTextures: BaseTexture[]): void;
  58091. /**
  58092. * Returns the animatable textures.
  58093. * @param animatables Array of animatable textures.
  58094. */
  58095. getAnimatables(animatables: IAnimatable[]): void;
  58096. /**
  58097. * Disposes the resources of the material.
  58098. * @param forceDisposeTextures - Forces the disposal of all textures.
  58099. */
  58100. dispose(forceDisposeTextures?: boolean): void;
  58101. /**
  58102. * Get the current class name of the texture useful for serialization or dynamic coding.
  58103. * @returns "PBRSheenConfiguration"
  58104. */
  58105. getClassName(): string;
  58106. /**
  58107. * Add fallbacks to the effect fallbacks list.
  58108. * @param defines defines the Base texture to use.
  58109. * @param fallbacks defines the current fallback list.
  58110. * @param currentRank defines the current fallback rank.
  58111. * @returns the new fallback rank.
  58112. */
  58113. static AddFallbacks(defines: IMaterialSheenDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  58114. /**
  58115. * Add the required uniforms to the current list.
  58116. * @param uniforms defines the current uniform list.
  58117. */
  58118. static AddUniforms(uniforms: string[]): void;
  58119. /**
  58120. * Add the required uniforms to the current buffer.
  58121. * @param uniformBuffer defines the current uniform buffer.
  58122. */
  58123. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  58124. /**
  58125. * Add the required samplers to the current list.
  58126. * @param samplers defines the current sampler list.
  58127. */
  58128. static AddSamplers(samplers: string[]): void;
  58129. /**
  58130. * Makes a duplicate of the current configuration into another one.
  58131. * @param sheenConfiguration define the config where to copy the info
  58132. */
  58133. copyTo(sheenConfiguration: PBRSheenConfiguration): void;
  58134. /**
  58135. * Serializes this BRDF configuration.
  58136. * @returns - An object with the serialized config.
  58137. */
  58138. serialize(): any;
  58139. /**
  58140. * Parses a anisotropy Configuration from a serialized object.
  58141. * @param source - Serialized object.
  58142. * @param scene Defines the scene we are parsing for
  58143. * @param rootUrl Defines the rootUrl to load from
  58144. */
  58145. parse(source: any, scene: Scene, rootUrl: string): void;
  58146. }
  58147. }
  58148. declare module "babylonjs/Materials/PBR/pbrSubSurfaceConfiguration" {
  58149. import { Nullable } from "babylonjs/types";
  58150. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  58151. import { Color3 } from "babylonjs/Maths/math.color";
  58152. import { SmartArray } from "babylonjs/Misc/smartArray";
  58153. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  58154. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  58155. import { Effect } from "babylonjs/Materials/effect";
  58156. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  58157. import { EffectFallbacks } from "babylonjs/Materials/effectFallbacks";
  58158. import { Engine } from "babylonjs/Engines/engine";
  58159. import { Scene } from "babylonjs/scene";
  58160. /**
  58161. * @hidden
  58162. */
  58163. export interface IMaterialSubSurfaceDefines {
  58164. SUBSURFACE: boolean;
  58165. SS_REFRACTION: boolean;
  58166. SS_TRANSLUCENCY: boolean;
  58167. SS_SCATTERING: boolean;
  58168. SS_THICKNESSANDMASK_TEXTURE: boolean;
  58169. SS_THICKNESSANDMASK_TEXTUREDIRECTUV: number;
  58170. SS_REFRACTIONMAP_3D: boolean;
  58171. SS_REFRACTIONMAP_OPPOSITEZ: boolean;
  58172. SS_LODINREFRACTIONALPHA: boolean;
  58173. SS_GAMMAREFRACTION: boolean;
  58174. SS_RGBDREFRACTION: boolean;
  58175. SS_LINEARSPECULARREFRACTION: boolean;
  58176. SS_LINKREFRACTIONTOTRANSPARENCY: boolean;
  58177. SS_ALBEDOFORREFRACTIONTINT: boolean;
  58178. SS_MASK_FROM_THICKNESS_TEXTURE: boolean;
  58179. /** @hidden */
  58180. _areTexturesDirty: boolean;
  58181. }
  58182. /**
  58183. * Define the code related to the sub surface parameters of the pbr material.
  58184. */
  58185. export class PBRSubSurfaceConfiguration {
  58186. private _isRefractionEnabled;
  58187. /**
  58188. * Defines if the refraction is enabled in the material.
  58189. */
  58190. isRefractionEnabled: boolean;
  58191. private _isTranslucencyEnabled;
  58192. /**
  58193. * Defines if the translucency is enabled in the material.
  58194. */
  58195. isTranslucencyEnabled: boolean;
  58196. private _isScatteringEnabled;
  58197. /**
  58198. * Defines if the sub surface scattering is enabled in the material.
  58199. */
  58200. isScatteringEnabled: boolean;
  58201. private _scatteringDiffusionProfileIndex;
  58202. /**
  58203. * Diffusion profile for subsurface scattering.
  58204. * Useful for better scattering in the skins or foliages.
  58205. */
  58206. get scatteringDiffusionProfile(): Nullable<Color3>;
  58207. set scatteringDiffusionProfile(c: Nullable<Color3>);
  58208. /**
  58209. * Defines the refraction intensity of the material.
  58210. * The refraction when enabled replaces the Diffuse part of the material.
  58211. * The intensity helps transitionning between diffuse and refraction.
  58212. */
  58213. refractionIntensity: number;
  58214. /**
  58215. * Defines the translucency intensity of the material.
  58216. * When translucency has been enabled, this defines how much of the "translucency"
  58217. * is addded to the diffuse part of the material.
  58218. */
  58219. translucencyIntensity: number;
  58220. /**
  58221. * When enabled, transparent surfaces will be tinted with the albedo colour (independent of thickness)
  58222. */
  58223. useAlbedoToTintRefraction: boolean;
  58224. private _thicknessTexture;
  58225. /**
  58226. * Stores the average thickness of a mesh in a texture (The texture is holding the values linearly).
  58227. * The red channel of the texture should contain the thickness remapped between 0 and 1.
  58228. * 0 would mean minimumThickness
  58229. * 1 would mean maximumThickness
  58230. * The other channels might be use as a mask to vary the different effects intensity.
  58231. */
  58232. thicknessTexture: Nullable<BaseTexture>;
  58233. private _refractionTexture;
  58234. /**
  58235. * Defines the texture to use for refraction.
  58236. */
  58237. refractionTexture: Nullable<BaseTexture>;
  58238. private _indexOfRefraction;
  58239. /**
  58240. * Index of refraction of the material base layer.
  58241. * https://en.wikipedia.org/wiki/List_of_refractive_indices
  58242. *
  58243. * This does not only impact refraction but also the Base F0 of Dielectric Materials.
  58244. *
  58245. * From dielectric fresnel rules: F0 = square((iorT - iorI) / (iorT + iorI))
  58246. */
  58247. indexOfRefraction: number;
  58248. private _volumeIndexOfRefraction;
  58249. /**
  58250. * Index of refraction of the material's volume.
  58251. * https://en.wikipedia.org/wiki/List_of_refractive_indices
  58252. *
  58253. * This ONLY impacts refraction. If not provided or given a non-valid value,
  58254. * the volume will use the same IOR as the surface.
  58255. */
  58256. get volumeIndexOfRefraction(): number;
  58257. set volumeIndexOfRefraction(value: number);
  58258. private _invertRefractionY;
  58259. /**
  58260. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  58261. */
  58262. invertRefractionY: boolean;
  58263. private _linkRefractionWithTransparency;
  58264. /**
  58265. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  58266. * Materials half opaque for instance using refraction could benefit from this control.
  58267. */
  58268. linkRefractionWithTransparency: boolean;
  58269. /**
  58270. * Defines the minimum thickness stored in the thickness map.
  58271. * If no thickness map is defined, this value will be used to simulate thickness.
  58272. */
  58273. minimumThickness: number;
  58274. /**
  58275. * Defines the maximum thickness stored in the thickness map.
  58276. */
  58277. maximumThickness: number;
  58278. /**
  58279. * Defines the volume tint of the material.
  58280. * This is used for both translucency and scattering.
  58281. */
  58282. tintColor: Color3;
  58283. /**
  58284. * Defines the distance at which the tint color should be found in the media.
  58285. * This is used for refraction only.
  58286. */
  58287. tintColorAtDistance: number;
  58288. /**
  58289. * Defines how far each channel transmit through the media.
  58290. * It is defined as a color to simplify it selection.
  58291. */
  58292. diffusionDistance: Color3;
  58293. private _useMaskFromThicknessTexture;
  58294. /**
  58295. * Stores the intensity of the different subsurface effects in the thickness texture.
  58296. * * the green channel is the translucency intensity.
  58297. * * the blue channel is the scattering intensity.
  58298. * * the alpha channel is the refraction intensity.
  58299. */
  58300. useMaskFromThicknessTexture: boolean;
  58301. private _scene;
  58302. /** @hidden */
  58303. private _internalMarkAllSubMeshesAsTexturesDirty;
  58304. private _internalMarkScenePrePassDirty;
  58305. /** @hidden */
  58306. _markAllSubMeshesAsTexturesDirty(): void;
  58307. /** @hidden */
  58308. _markScenePrePassDirty(): void;
  58309. /**
  58310. * Instantiate a new istance of sub surface configuration.
  58311. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  58312. * @param markScenePrePassDirty Callback to flag the scene as prepass dirty
  58313. * @param scene The scene
  58314. */
  58315. constructor(markAllSubMeshesAsTexturesDirty: () => void, markScenePrePassDirty: () => void, scene: Scene);
  58316. /**
  58317. * Gets wehter the submesh is ready to be used or not.
  58318. * @param defines the list of "defines" to update.
  58319. * @param scene defines the scene the material belongs to.
  58320. * @returns - boolean indicating that the submesh is ready or not.
  58321. */
  58322. isReadyForSubMesh(defines: IMaterialSubSurfaceDefines, scene: Scene): boolean;
  58323. /**
  58324. * Checks to see if a texture is used in the material.
  58325. * @param defines the list of "defines" to update.
  58326. * @param scene defines the scene to the material belongs to.
  58327. */
  58328. prepareDefines(defines: IMaterialSubSurfaceDefines, scene: Scene): void;
  58329. /**
  58330. * Binds the material data.
  58331. * @param uniformBuffer defines the Uniform buffer to fill in.
  58332. * @param scene defines the scene the material belongs to.
  58333. * @param engine defines the engine the material belongs to.
  58334. * @param isFrozen defines whether the material is frozen or not.
  58335. * @param lodBasedMicrosurface defines whether the material relies on lod based microsurface or not.
  58336. * @param realTimeFiltering defines whether the textures should be filtered on the fly.
  58337. */
  58338. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, engine: Engine, isFrozen: boolean, lodBasedMicrosurface: boolean, realTimeFiltering: boolean): void;
  58339. /**
  58340. * Unbinds the material from the mesh.
  58341. * @param activeEffect defines the effect that should be unbound from.
  58342. * @returns true if unbound, otherwise false
  58343. */
  58344. unbind(activeEffect: Effect): boolean;
  58345. /**
  58346. * Returns the texture used for refraction or null if none is used.
  58347. * @param scene defines the scene the material belongs to.
  58348. * @returns - Refraction texture if present. If no refraction texture and refraction
  58349. * is linked with transparency, returns environment texture. Otherwise, returns null.
  58350. */
  58351. private _getRefractionTexture;
  58352. /**
  58353. * Returns true if alpha blending should be disabled.
  58354. */
  58355. get disableAlphaBlending(): boolean;
  58356. /**
  58357. * Fills the list of render target textures.
  58358. * @param renderTargets the list of render targets to update
  58359. */
  58360. fillRenderTargetTextures(renderTargets: SmartArray<RenderTargetTexture>): void;
  58361. /**
  58362. * Checks to see if a texture is used in the material.
  58363. * @param texture - Base texture to use.
  58364. * @returns - Boolean specifying if a texture is used in the material.
  58365. */
  58366. hasTexture(texture: BaseTexture): boolean;
  58367. /**
  58368. * Gets a boolean indicating that current material needs to register RTT
  58369. * @returns true if this uses a render target otherwise false.
  58370. */
  58371. hasRenderTargetTextures(): boolean;
  58372. /**
  58373. * Returns an array of the actively used textures.
  58374. * @param activeTextures Array of BaseTextures
  58375. */
  58376. getActiveTextures(activeTextures: BaseTexture[]): void;
  58377. /**
  58378. * Returns the animatable textures.
  58379. * @param animatables Array of animatable textures.
  58380. */
  58381. getAnimatables(animatables: IAnimatable[]): void;
  58382. /**
  58383. * Disposes the resources of the material.
  58384. * @param forceDisposeTextures - Forces the disposal of all textures.
  58385. */
  58386. dispose(forceDisposeTextures?: boolean): void;
  58387. /**
  58388. * Get the current class name of the texture useful for serialization or dynamic coding.
  58389. * @returns "PBRSubSurfaceConfiguration"
  58390. */
  58391. getClassName(): string;
  58392. /**
  58393. * Add fallbacks to the effect fallbacks list.
  58394. * @param defines defines the Base texture to use.
  58395. * @param fallbacks defines the current fallback list.
  58396. * @param currentRank defines the current fallback rank.
  58397. * @returns the new fallback rank.
  58398. */
  58399. static AddFallbacks(defines: IMaterialSubSurfaceDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  58400. /**
  58401. * Add the required uniforms to the current list.
  58402. * @param uniforms defines the current uniform list.
  58403. */
  58404. static AddUniforms(uniforms: string[]): void;
  58405. /**
  58406. * Add the required samplers to the current list.
  58407. * @param samplers defines the current sampler list.
  58408. */
  58409. static AddSamplers(samplers: string[]): void;
  58410. /**
  58411. * Add the required uniforms to the current buffer.
  58412. * @param uniformBuffer defines the current uniform buffer.
  58413. */
  58414. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  58415. /**
  58416. * Makes a duplicate of the current configuration into another one.
  58417. * @param configuration define the config where to copy the info
  58418. */
  58419. copyTo(configuration: PBRSubSurfaceConfiguration): void;
  58420. /**
  58421. * Serializes this Sub Surface configuration.
  58422. * @returns - An object with the serialized config.
  58423. */
  58424. serialize(): any;
  58425. /**
  58426. * Parses a anisotropy Configuration from a serialized object.
  58427. * @param source - Serialized object.
  58428. * @param scene Defines the scene we are parsing for
  58429. * @param rootUrl Defines the rootUrl to load from
  58430. */
  58431. parse(source: any, scene: Scene, rootUrl: string): void;
  58432. }
  58433. }
  58434. declare module "babylonjs/Shaders/ShadersInclude/pbrFragmentDeclaration" {
  58435. /** @hidden */
  58436. export var pbrFragmentDeclaration: {
  58437. name: string;
  58438. shader: string;
  58439. };
  58440. }
  58441. declare module "babylonjs/Shaders/ShadersInclude/pbrUboDeclaration" {
  58442. /** @hidden */
  58443. export var pbrUboDeclaration: {
  58444. name: string;
  58445. shader: string;
  58446. };
  58447. }
  58448. declare module "babylonjs/Shaders/ShadersInclude/pbrFragmentExtraDeclaration" {
  58449. /** @hidden */
  58450. export var pbrFragmentExtraDeclaration: {
  58451. name: string;
  58452. shader: string;
  58453. };
  58454. }
  58455. declare module "babylonjs/Shaders/ShadersInclude/pbrFragmentSamplersDeclaration" {
  58456. /** @hidden */
  58457. export var pbrFragmentSamplersDeclaration: {
  58458. name: string;
  58459. shader: string;
  58460. };
  58461. }
  58462. declare module "babylonjs/Shaders/ShadersInclude/importanceSampling" {
  58463. /** @hidden */
  58464. export var importanceSampling: {
  58465. name: string;
  58466. shader: string;
  58467. };
  58468. }
  58469. declare module "babylonjs/Shaders/ShadersInclude/pbrHelperFunctions" {
  58470. /** @hidden */
  58471. export var pbrHelperFunctions: {
  58472. name: string;
  58473. shader: string;
  58474. };
  58475. }
  58476. declare module "babylonjs/Shaders/ShadersInclude/harmonicsFunctions" {
  58477. /** @hidden */
  58478. export var harmonicsFunctions: {
  58479. name: string;
  58480. shader: string;
  58481. };
  58482. }
  58483. declare module "babylonjs/Shaders/ShadersInclude/pbrDirectLightingSetupFunctions" {
  58484. /** @hidden */
  58485. export var pbrDirectLightingSetupFunctions: {
  58486. name: string;
  58487. shader: string;
  58488. };
  58489. }
  58490. declare module "babylonjs/Shaders/ShadersInclude/pbrDirectLightingFalloffFunctions" {
  58491. /** @hidden */
  58492. export var pbrDirectLightingFalloffFunctions: {
  58493. name: string;
  58494. shader: string;
  58495. };
  58496. }
  58497. declare module "babylonjs/Shaders/ShadersInclude/pbrBRDFFunctions" {
  58498. /** @hidden */
  58499. export var pbrBRDFFunctions: {
  58500. name: string;
  58501. shader: string;
  58502. };
  58503. }
  58504. declare module "babylonjs/Shaders/ShadersInclude/hdrFilteringFunctions" {
  58505. /** @hidden */
  58506. export var hdrFilteringFunctions: {
  58507. name: string;
  58508. shader: string;
  58509. };
  58510. }
  58511. declare module "babylonjs/Shaders/ShadersInclude/pbrDirectLightingFunctions" {
  58512. /** @hidden */
  58513. export var pbrDirectLightingFunctions: {
  58514. name: string;
  58515. shader: string;
  58516. };
  58517. }
  58518. declare module "babylonjs/Shaders/ShadersInclude/pbrIBLFunctions" {
  58519. /** @hidden */
  58520. export var pbrIBLFunctions: {
  58521. name: string;
  58522. shader: string;
  58523. };
  58524. }
  58525. declare module "babylonjs/Shaders/ShadersInclude/pbrBlockAlbedoOpacity" {
  58526. /** @hidden */
  58527. export var pbrBlockAlbedoOpacity: {
  58528. name: string;
  58529. shader: string;
  58530. };
  58531. }
  58532. declare module "babylonjs/Shaders/ShadersInclude/pbrBlockReflectivity" {
  58533. /** @hidden */
  58534. export var pbrBlockReflectivity: {
  58535. name: string;
  58536. shader: string;
  58537. };
  58538. }
  58539. declare module "babylonjs/Shaders/ShadersInclude/pbrBlockAmbientOcclusion" {
  58540. /** @hidden */
  58541. export var pbrBlockAmbientOcclusion: {
  58542. name: string;
  58543. shader: string;
  58544. };
  58545. }
  58546. declare module "babylonjs/Shaders/ShadersInclude/pbrBlockAlphaFresnel" {
  58547. /** @hidden */
  58548. export var pbrBlockAlphaFresnel: {
  58549. name: string;
  58550. shader: string;
  58551. };
  58552. }
  58553. declare module "babylonjs/Shaders/ShadersInclude/pbrBlockAnisotropic" {
  58554. /** @hidden */
  58555. export var pbrBlockAnisotropic: {
  58556. name: string;
  58557. shader: string;
  58558. };
  58559. }
  58560. declare module "babylonjs/Shaders/ShadersInclude/pbrBlockReflection" {
  58561. /** @hidden */
  58562. export var pbrBlockReflection: {
  58563. name: string;
  58564. shader: string;
  58565. };
  58566. }
  58567. declare module "babylonjs/Shaders/ShadersInclude/pbrBlockSheen" {
  58568. /** @hidden */
  58569. export var pbrBlockSheen: {
  58570. name: string;
  58571. shader: string;
  58572. };
  58573. }
  58574. declare module "babylonjs/Shaders/ShadersInclude/pbrBlockClearcoat" {
  58575. /** @hidden */
  58576. export var pbrBlockClearcoat: {
  58577. name: string;
  58578. shader: string;
  58579. };
  58580. }
  58581. declare module "babylonjs/Shaders/ShadersInclude/pbrBlockSubSurface" {
  58582. /** @hidden */
  58583. export var pbrBlockSubSurface: {
  58584. name: string;
  58585. shader: string;
  58586. };
  58587. }
  58588. declare module "babylonjs/Shaders/ShadersInclude/pbrBlockNormalGeometric" {
  58589. /** @hidden */
  58590. export var pbrBlockNormalGeometric: {
  58591. name: string;
  58592. shader: string;
  58593. };
  58594. }
  58595. declare module "babylonjs/Shaders/ShadersInclude/pbrBlockNormalFinal" {
  58596. /** @hidden */
  58597. export var pbrBlockNormalFinal: {
  58598. name: string;
  58599. shader: string;
  58600. };
  58601. }
  58602. declare module "babylonjs/Shaders/ShadersInclude/pbrBlockLightmapInit" {
  58603. /** @hidden */
  58604. export var pbrBlockLightmapInit: {
  58605. name: string;
  58606. shader: string;
  58607. };
  58608. }
  58609. declare module "babylonjs/Shaders/ShadersInclude/pbrBlockGeometryInfo" {
  58610. /** @hidden */
  58611. export var pbrBlockGeometryInfo: {
  58612. name: string;
  58613. shader: string;
  58614. };
  58615. }
  58616. declare module "babylonjs/Shaders/ShadersInclude/pbrBlockReflectance0" {
  58617. /** @hidden */
  58618. export var pbrBlockReflectance0: {
  58619. name: string;
  58620. shader: string;
  58621. };
  58622. }
  58623. declare module "babylonjs/Shaders/ShadersInclude/pbrBlockReflectance" {
  58624. /** @hidden */
  58625. export var pbrBlockReflectance: {
  58626. name: string;
  58627. shader: string;
  58628. };
  58629. }
  58630. declare module "babylonjs/Shaders/ShadersInclude/pbrBlockDirectLighting" {
  58631. /** @hidden */
  58632. export var pbrBlockDirectLighting: {
  58633. name: string;
  58634. shader: string;
  58635. };
  58636. }
  58637. declare module "babylonjs/Shaders/ShadersInclude/pbrBlockFinalLitComponents" {
  58638. /** @hidden */
  58639. export var pbrBlockFinalLitComponents: {
  58640. name: string;
  58641. shader: string;
  58642. };
  58643. }
  58644. declare module "babylonjs/Shaders/ShadersInclude/pbrBlockFinalUnlitComponents" {
  58645. /** @hidden */
  58646. export var pbrBlockFinalUnlitComponents: {
  58647. name: string;
  58648. shader: string;
  58649. };
  58650. }
  58651. declare module "babylonjs/Shaders/ShadersInclude/pbrBlockFinalColorComposition" {
  58652. /** @hidden */
  58653. export var pbrBlockFinalColorComposition: {
  58654. name: string;
  58655. shader: string;
  58656. };
  58657. }
  58658. declare module "babylonjs/Shaders/ShadersInclude/pbrBlockImageProcessing" {
  58659. /** @hidden */
  58660. export var pbrBlockImageProcessing: {
  58661. name: string;
  58662. shader: string;
  58663. };
  58664. }
  58665. declare module "babylonjs/Shaders/ShadersInclude/pbrDebug" {
  58666. /** @hidden */
  58667. export var pbrDebug: {
  58668. name: string;
  58669. shader: string;
  58670. };
  58671. }
  58672. declare module "babylonjs/Shaders/pbr.fragment" {
  58673. import "babylonjs/Shaders/ShadersInclude/prePassDeclaration";
  58674. import "babylonjs/Shaders/ShadersInclude/pbrFragmentDeclaration";
  58675. import "babylonjs/Shaders/ShadersInclude/pbrUboDeclaration";
  58676. import "babylonjs/Shaders/ShadersInclude/pbrFragmentExtraDeclaration";
  58677. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  58678. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  58679. import "babylonjs/Shaders/ShadersInclude/pbrFragmentSamplersDeclaration";
  58680. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  58681. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration";
  58682. import "babylonjs/Shaders/ShadersInclude/logDepthDeclaration";
  58683. import "babylonjs/Shaders/ShadersInclude/fogFragmentDeclaration";
  58684. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  58685. import "babylonjs/Shaders/ShadersInclude/subSurfaceScatteringFunctions";
  58686. import "babylonjs/Shaders/ShadersInclude/importanceSampling";
  58687. import "babylonjs/Shaders/ShadersInclude/pbrHelperFunctions";
  58688. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  58689. import "babylonjs/Shaders/ShadersInclude/shadowsFragmentFunctions";
  58690. import "babylonjs/Shaders/ShadersInclude/harmonicsFunctions";
  58691. import "babylonjs/Shaders/ShadersInclude/pbrDirectLightingSetupFunctions";
  58692. import "babylonjs/Shaders/ShadersInclude/pbrDirectLightingFalloffFunctions";
  58693. import "babylonjs/Shaders/ShadersInclude/pbrBRDFFunctions";
  58694. import "babylonjs/Shaders/ShadersInclude/hdrFilteringFunctions";
  58695. import "babylonjs/Shaders/ShadersInclude/pbrDirectLightingFunctions";
  58696. import "babylonjs/Shaders/ShadersInclude/pbrIBLFunctions";
  58697. import "babylonjs/Shaders/ShadersInclude/bumpFragmentMainFunctions";
  58698. import "babylonjs/Shaders/ShadersInclude/bumpFragmentFunctions";
  58699. import "babylonjs/Shaders/ShadersInclude/reflectionFunction";
  58700. import "babylonjs/Shaders/ShadersInclude/pbrBlockAlbedoOpacity";
  58701. import "babylonjs/Shaders/ShadersInclude/pbrBlockReflectivity";
  58702. import "babylonjs/Shaders/ShadersInclude/pbrBlockAmbientOcclusion";
  58703. import "babylonjs/Shaders/ShadersInclude/pbrBlockAlphaFresnel";
  58704. import "babylonjs/Shaders/ShadersInclude/pbrBlockAnisotropic";
  58705. import "babylonjs/Shaders/ShadersInclude/pbrBlockReflection";
  58706. import "babylonjs/Shaders/ShadersInclude/pbrBlockSheen";
  58707. import "babylonjs/Shaders/ShadersInclude/pbrBlockClearcoat";
  58708. import "babylonjs/Shaders/ShadersInclude/pbrBlockSubSurface";
  58709. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragment";
  58710. import "babylonjs/Shaders/ShadersInclude/pbrBlockNormalGeometric";
  58711. import "babylonjs/Shaders/ShadersInclude/bumpFragment";
  58712. import "babylonjs/Shaders/ShadersInclude/pbrBlockNormalFinal";
  58713. import "babylonjs/Shaders/ShadersInclude/depthPrePass";
  58714. import "babylonjs/Shaders/ShadersInclude/pbrBlockLightmapInit";
  58715. import "babylonjs/Shaders/ShadersInclude/pbrBlockGeometryInfo";
  58716. import "babylonjs/Shaders/ShadersInclude/pbrBlockReflectance0";
  58717. import "babylonjs/Shaders/ShadersInclude/pbrBlockReflectance";
  58718. import "babylonjs/Shaders/ShadersInclude/pbrBlockDirectLighting";
  58719. import "babylonjs/Shaders/ShadersInclude/lightFragment";
  58720. import "babylonjs/Shaders/ShadersInclude/pbrBlockFinalLitComponents";
  58721. import "babylonjs/Shaders/ShadersInclude/pbrBlockFinalUnlitComponents";
  58722. import "babylonjs/Shaders/ShadersInclude/pbrBlockFinalColorComposition";
  58723. import "babylonjs/Shaders/ShadersInclude/logDepthFragment";
  58724. import "babylonjs/Shaders/ShadersInclude/fogFragment";
  58725. import "babylonjs/Shaders/ShadersInclude/pbrBlockImageProcessing";
  58726. import "babylonjs/Shaders/ShadersInclude/pbrDebug";
  58727. /** @hidden */
  58728. export var pbrPixelShader: {
  58729. name: string;
  58730. shader: string;
  58731. };
  58732. }
  58733. declare module "babylonjs/Shaders/ShadersInclude/pbrVertexDeclaration" {
  58734. /** @hidden */
  58735. export var pbrVertexDeclaration: {
  58736. name: string;
  58737. shader: string;
  58738. };
  58739. }
  58740. declare module "babylonjs/Shaders/pbr.vertex" {
  58741. import "babylonjs/Shaders/ShadersInclude/pbrVertexDeclaration";
  58742. import "babylonjs/Shaders/ShadersInclude/pbrUboDeclaration";
  58743. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  58744. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  58745. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  58746. import "babylonjs/Shaders/ShadersInclude/harmonicsFunctions";
  58747. import "babylonjs/Shaders/ShadersInclude/bumpVertexDeclaration";
  58748. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration";
  58749. import "babylonjs/Shaders/ShadersInclude/fogVertexDeclaration";
  58750. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  58751. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  58752. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  58753. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  58754. import "babylonjs/Shaders/ShadersInclude/logDepthDeclaration";
  58755. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  58756. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  58757. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  58758. import "babylonjs/Shaders/ShadersInclude/bumpVertex";
  58759. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertex";
  58760. import "babylonjs/Shaders/ShadersInclude/fogVertex";
  58761. import "babylonjs/Shaders/ShadersInclude/shadowsVertex";
  58762. import "babylonjs/Shaders/ShadersInclude/logDepthVertex";
  58763. /** @hidden */
  58764. export var pbrVertexShader: {
  58765. name: string;
  58766. shader: string;
  58767. };
  58768. }
  58769. declare module "babylonjs/Materials/PBR/pbrBaseMaterial" {
  58770. import { Nullable } from "babylonjs/types";
  58771. import { Scene } from "babylonjs/scene";
  58772. import { Matrix } from "babylonjs/Maths/math.vector";
  58773. import { SubMesh } from "babylonjs/Meshes/subMesh";
  58774. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  58775. import { Mesh } from "babylonjs/Meshes/mesh";
  58776. import { IMaterialClearCoatDefines, PBRClearCoatConfiguration } from "babylonjs/Materials/PBR/pbrClearCoatConfiguration";
  58777. import { IMaterialAnisotropicDefines, PBRAnisotropicConfiguration } from "babylonjs/Materials/PBR/pbrAnisotropicConfiguration";
  58778. import { IMaterialBRDFDefines, PBRBRDFConfiguration } from "babylonjs/Materials/PBR/pbrBRDFConfiguration";
  58779. import { IMaterialSheenDefines, PBRSheenConfiguration } from "babylonjs/Materials/PBR/pbrSheenConfiguration";
  58780. import { IMaterialSubSurfaceDefines, PBRSubSurfaceConfiguration } from "babylonjs/Materials/PBR/pbrSubSurfaceConfiguration";
  58781. import { Color3 } from "babylonjs/Maths/math.color";
  58782. import { ImageProcessingConfiguration, IImageProcessingConfigurationDefines } from "babylonjs/Materials/imageProcessingConfiguration";
  58783. import { Material, IMaterialCompilationOptions } from "babylonjs/Materials/material";
  58784. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  58785. import { PushMaterial } from "babylonjs/Materials/pushMaterial";
  58786. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  58787. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  58788. import "babylonjs/Materials/Textures/baseTexture.polynomial";
  58789. import "babylonjs/Shaders/pbr.fragment";
  58790. import "babylonjs/Shaders/pbr.vertex";
  58791. import { IMaterialDetailMapDefines, DetailMapConfiguration } from "babylonjs/Materials/material.detailMapConfiguration";
  58792. import { PrePassRenderer } from "babylonjs/Rendering/prePassRenderer";
  58793. /**
  58794. * Manages the defines for the PBR Material.
  58795. * @hidden
  58796. */
  58797. export class PBRMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines, IMaterialClearCoatDefines, IMaterialAnisotropicDefines, IMaterialBRDFDefines, IMaterialSheenDefines, IMaterialSubSurfaceDefines, IMaterialDetailMapDefines {
  58798. PBR: boolean;
  58799. NUM_SAMPLES: string;
  58800. REALTIME_FILTERING: boolean;
  58801. MAINUV1: boolean;
  58802. MAINUV2: boolean;
  58803. UV1: boolean;
  58804. UV2: boolean;
  58805. ALBEDO: boolean;
  58806. GAMMAALBEDO: boolean;
  58807. ALBEDODIRECTUV: number;
  58808. VERTEXCOLOR: boolean;
  58809. DETAIL: boolean;
  58810. DETAILDIRECTUV: number;
  58811. DETAIL_NORMALBLENDMETHOD: number;
  58812. AMBIENT: boolean;
  58813. AMBIENTDIRECTUV: number;
  58814. AMBIENTINGRAYSCALE: boolean;
  58815. OPACITY: boolean;
  58816. VERTEXALPHA: boolean;
  58817. OPACITYDIRECTUV: number;
  58818. OPACITYRGB: boolean;
  58819. ALPHATEST: boolean;
  58820. DEPTHPREPASS: boolean;
  58821. ALPHABLEND: boolean;
  58822. ALPHAFROMALBEDO: boolean;
  58823. ALPHATESTVALUE: string;
  58824. SPECULAROVERALPHA: boolean;
  58825. RADIANCEOVERALPHA: boolean;
  58826. ALPHAFRESNEL: boolean;
  58827. LINEARALPHAFRESNEL: boolean;
  58828. PREMULTIPLYALPHA: boolean;
  58829. EMISSIVE: boolean;
  58830. EMISSIVEDIRECTUV: number;
  58831. REFLECTIVITY: boolean;
  58832. REFLECTIVITYDIRECTUV: number;
  58833. SPECULARTERM: boolean;
  58834. MICROSURFACEFROMREFLECTIVITYMAP: boolean;
  58835. MICROSURFACEAUTOMATIC: boolean;
  58836. LODBASEDMICROSFURACE: boolean;
  58837. MICROSURFACEMAP: boolean;
  58838. MICROSURFACEMAPDIRECTUV: number;
  58839. METALLICWORKFLOW: boolean;
  58840. ROUGHNESSSTOREINMETALMAPALPHA: boolean;
  58841. ROUGHNESSSTOREINMETALMAPGREEN: boolean;
  58842. METALLNESSSTOREINMETALMAPBLUE: boolean;
  58843. AOSTOREINMETALMAPRED: boolean;
  58844. METALLIC_REFLECTANCE: boolean;
  58845. METALLIC_REFLECTANCEDIRECTUV: number;
  58846. ENVIRONMENTBRDF: boolean;
  58847. ENVIRONMENTBRDF_RGBD: boolean;
  58848. NORMAL: boolean;
  58849. TANGENT: boolean;
  58850. BUMP: boolean;
  58851. BUMPDIRECTUV: number;
  58852. OBJECTSPACE_NORMALMAP: boolean;
  58853. PARALLAX: boolean;
  58854. PARALLAXOCCLUSION: boolean;
  58855. NORMALXYSCALE: boolean;
  58856. LIGHTMAP: boolean;
  58857. LIGHTMAPDIRECTUV: number;
  58858. USELIGHTMAPASSHADOWMAP: boolean;
  58859. GAMMALIGHTMAP: boolean;
  58860. RGBDLIGHTMAP: boolean;
  58861. REFLECTION: boolean;
  58862. REFLECTIONMAP_3D: boolean;
  58863. REFLECTIONMAP_SPHERICAL: boolean;
  58864. REFLECTIONMAP_PLANAR: boolean;
  58865. REFLECTIONMAP_CUBIC: boolean;
  58866. USE_LOCAL_REFLECTIONMAP_CUBIC: boolean;
  58867. REFLECTIONMAP_PROJECTION: boolean;
  58868. REFLECTIONMAP_SKYBOX: boolean;
  58869. REFLECTIONMAP_EXPLICIT: boolean;
  58870. REFLECTIONMAP_EQUIRECTANGULAR: boolean;
  58871. REFLECTIONMAP_EQUIRECTANGULAR_FIXED: boolean;
  58872. REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED: boolean;
  58873. INVERTCUBICMAP: boolean;
  58874. USESPHERICALFROMREFLECTIONMAP: boolean;
  58875. USEIRRADIANCEMAP: boolean;
  58876. SPHERICAL_HARMONICS: boolean;
  58877. USESPHERICALINVERTEX: boolean;
  58878. REFLECTIONMAP_OPPOSITEZ: boolean;
  58879. LODINREFLECTIONALPHA: boolean;
  58880. GAMMAREFLECTION: boolean;
  58881. RGBDREFLECTION: boolean;
  58882. LINEARSPECULARREFLECTION: boolean;
  58883. RADIANCEOCCLUSION: boolean;
  58884. HORIZONOCCLUSION: boolean;
  58885. INSTANCES: boolean;
  58886. THIN_INSTANCES: boolean;
  58887. PREPASS: boolean;
  58888. SCENE_MRT_COUNT: number;
  58889. NUM_BONE_INFLUENCERS: number;
  58890. BonesPerMesh: number;
  58891. BONETEXTURE: boolean;
  58892. NONUNIFORMSCALING: boolean;
  58893. MORPHTARGETS: boolean;
  58894. MORPHTARGETS_NORMAL: boolean;
  58895. MORPHTARGETS_TANGENT: boolean;
  58896. MORPHTARGETS_UV: boolean;
  58897. NUM_MORPH_INFLUENCERS: number;
  58898. IMAGEPROCESSING: boolean;
  58899. VIGNETTE: boolean;
  58900. VIGNETTEBLENDMODEMULTIPLY: boolean;
  58901. VIGNETTEBLENDMODEOPAQUE: boolean;
  58902. TONEMAPPING: boolean;
  58903. TONEMAPPING_ACES: boolean;
  58904. CONTRAST: boolean;
  58905. COLORCURVES: boolean;
  58906. COLORGRADING: boolean;
  58907. COLORGRADING3D: boolean;
  58908. SAMPLER3DGREENDEPTH: boolean;
  58909. SAMPLER3DBGRMAP: boolean;
  58910. IMAGEPROCESSINGPOSTPROCESS: boolean;
  58911. EXPOSURE: boolean;
  58912. MULTIVIEW: boolean;
  58913. USEPHYSICALLIGHTFALLOFF: boolean;
  58914. USEGLTFLIGHTFALLOFF: boolean;
  58915. TWOSIDEDLIGHTING: boolean;
  58916. SHADOWFLOAT: boolean;
  58917. CLIPPLANE: boolean;
  58918. CLIPPLANE2: boolean;
  58919. CLIPPLANE3: boolean;
  58920. CLIPPLANE4: boolean;
  58921. CLIPPLANE5: boolean;
  58922. CLIPPLANE6: boolean;
  58923. POINTSIZE: boolean;
  58924. FOG: boolean;
  58925. LOGARITHMICDEPTH: boolean;
  58926. FORCENORMALFORWARD: boolean;
  58927. SPECULARAA: boolean;
  58928. CLEARCOAT: boolean;
  58929. CLEARCOAT_DEFAULTIOR: boolean;
  58930. CLEARCOAT_TEXTURE: boolean;
  58931. CLEARCOAT_TEXTUREDIRECTUV: number;
  58932. CLEARCOAT_BUMP: boolean;
  58933. CLEARCOAT_BUMPDIRECTUV: number;
  58934. CLEARCOAT_TINT: boolean;
  58935. CLEARCOAT_TINT_TEXTURE: boolean;
  58936. CLEARCOAT_TINT_TEXTUREDIRECTUV: number;
  58937. ANISOTROPIC: boolean;
  58938. ANISOTROPIC_TEXTURE: boolean;
  58939. ANISOTROPIC_TEXTUREDIRECTUV: number;
  58940. BRDF_V_HEIGHT_CORRELATED: boolean;
  58941. MS_BRDF_ENERGY_CONSERVATION: boolean;
  58942. SPECULAR_GLOSSINESS_ENERGY_CONSERVATION: boolean;
  58943. SHEEN: boolean;
  58944. SHEEN_TEXTURE: boolean;
  58945. SHEEN_TEXTUREDIRECTUV: number;
  58946. SHEEN_LINKWITHALBEDO: boolean;
  58947. SHEEN_ROUGHNESS: boolean;
  58948. SHEEN_ALBEDOSCALING: boolean;
  58949. SUBSURFACE: boolean;
  58950. SS_REFRACTION: boolean;
  58951. SS_TRANSLUCENCY: boolean;
  58952. SS_SCATTERING: boolean;
  58953. SS_THICKNESSANDMASK_TEXTURE: boolean;
  58954. SS_THICKNESSANDMASK_TEXTUREDIRECTUV: number;
  58955. SS_REFRACTIONMAP_3D: boolean;
  58956. SS_REFRACTIONMAP_OPPOSITEZ: boolean;
  58957. SS_LODINREFRACTIONALPHA: boolean;
  58958. SS_GAMMAREFRACTION: boolean;
  58959. SS_RGBDREFRACTION: boolean;
  58960. SS_LINEARSPECULARREFRACTION: boolean;
  58961. SS_LINKREFRACTIONTOTRANSPARENCY: boolean;
  58962. SS_ALBEDOFORREFRACTIONTINT: boolean;
  58963. SS_MASK_FROM_THICKNESS_TEXTURE: boolean;
  58964. UNLIT: boolean;
  58965. DEBUGMODE: number;
  58966. /**
  58967. * Initializes the PBR Material defines.
  58968. */
  58969. constructor();
  58970. /**
  58971. * Resets the PBR Material defines.
  58972. */
  58973. reset(): void;
  58974. }
  58975. /**
  58976. * The Physically based material base class of BJS.
  58977. *
  58978. * This offers the main features of a standard PBR material.
  58979. * For more information, please refer to the documentation :
  58980. * https://doc.babylonjs.com/how_to/physically_based_rendering
  58981. */
  58982. export abstract class PBRBaseMaterial extends PushMaterial {
  58983. /**
  58984. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  58985. */
  58986. static readonly PBRMATERIAL_OPAQUE: number;
  58987. /**
  58988. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  58989. */
  58990. static readonly PBRMATERIAL_ALPHATEST: number;
  58991. /**
  58992. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  58993. */
  58994. static readonly PBRMATERIAL_ALPHABLEND: number;
  58995. /**
  58996. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  58997. * They are also discarded below the alpha cutoff threshold to improve performances.
  58998. */
  58999. static readonly PBRMATERIAL_ALPHATESTANDBLEND: number;
  59000. /**
  59001. * Defines the default value of how much AO map is occluding the analytical lights
  59002. * (point spot...).
  59003. */
  59004. static DEFAULT_AO_ON_ANALYTICAL_LIGHTS: number;
  59005. /**
  59006. * PBRMaterialLightFalloff Physical: light is falling off following the inverse squared distance law.
  59007. */
  59008. static readonly LIGHTFALLOFF_PHYSICAL: number;
  59009. /**
  59010. * PBRMaterialLightFalloff gltf: light is falling off as described in the gltf moving to PBR document
  59011. * to enhance interoperability with other engines.
  59012. */
  59013. static readonly LIGHTFALLOFF_GLTF: number;
  59014. /**
  59015. * PBRMaterialLightFalloff Standard: light is falling off like in the standard material
  59016. * to enhance interoperability with other materials.
  59017. */
  59018. static readonly LIGHTFALLOFF_STANDARD: number;
  59019. /**
  59020. * Intensity of the direct lights e.g. the four lights available in your scene.
  59021. * This impacts both the direct diffuse and specular highlights.
  59022. */
  59023. protected _directIntensity: number;
  59024. /**
  59025. * Intensity of the emissive part of the material.
  59026. * This helps controlling the emissive effect without modifying the emissive color.
  59027. */
  59028. protected _emissiveIntensity: number;
  59029. /**
  59030. * Intensity of the environment e.g. how much the environment will light the object
  59031. * either through harmonics for rough material or through the refelction for shiny ones.
  59032. */
  59033. protected _environmentIntensity: number;
  59034. /**
  59035. * This is a special control allowing the reduction of the specular highlights coming from the
  59036. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  59037. */
  59038. protected _specularIntensity: number;
  59039. /**
  59040. * This stores the direct, emissive, environment, and specular light intensities into a Vector4.
  59041. */
  59042. private _lightingInfos;
  59043. /**
  59044. * Debug Control allowing disabling the bump map on this material.
  59045. */
  59046. protected _disableBumpMap: boolean;
  59047. /**
  59048. * AKA Diffuse Texture in standard nomenclature.
  59049. */
  59050. protected _albedoTexture: Nullable<BaseTexture>;
  59051. /**
  59052. * AKA Occlusion Texture in other nomenclature.
  59053. */
  59054. protected _ambientTexture: Nullable<BaseTexture>;
  59055. /**
  59056. * AKA Occlusion Texture Intensity in other nomenclature.
  59057. */
  59058. protected _ambientTextureStrength: number;
  59059. /**
  59060. * Defines how much the AO map is occluding the analytical lights (point spot...).
  59061. * 1 means it completely occludes it
  59062. * 0 mean it has no impact
  59063. */
  59064. protected _ambientTextureImpactOnAnalyticalLights: number;
  59065. /**
  59066. * Stores the alpha values in a texture.
  59067. */
  59068. protected _opacityTexture: Nullable<BaseTexture>;
  59069. /**
  59070. * Stores the reflection values in a texture.
  59071. */
  59072. protected _reflectionTexture: Nullable<BaseTexture>;
  59073. /**
  59074. * Stores the emissive values in a texture.
  59075. */
  59076. protected _emissiveTexture: Nullable<BaseTexture>;
  59077. /**
  59078. * AKA Specular texture in other nomenclature.
  59079. */
  59080. protected _reflectivityTexture: Nullable<BaseTexture>;
  59081. /**
  59082. * Used to switch from specular/glossiness to metallic/roughness workflow.
  59083. */
  59084. protected _metallicTexture: Nullable<BaseTexture>;
  59085. /**
  59086. * Specifies the metallic scalar of the metallic/roughness workflow.
  59087. * Can also be used to scale the metalness values of the metallic texture.
  59088. */
  59089. protected _metallic: Nullable<number>;
  59090. /**
  59091. * Specifies the roughness scalar of the metallic/roughness workflow.
  59092. * Can also be used to scale the roughness values of the metallic texture.
  59093. */
  59094. protected _roughness: Nullable<number>;
  59095. /**
  59096. * In metallic workflow, specifies an F0 factor to help configuring the material F0.
  59097. * By default the indexOfrefraction is used to compute F0;
  59098. *
  59099. * This is used as a factor against the default reflectance at normal incidence to tweak it.
  59100. *
  59101. * F0 = defaultF0 * metallicF0Factor * metallicReflectanceColor;
  59102. * F90 = metallicReflectanceColor;
  59103. */
  59104. protected _metallicF0Factor: number;
  59105. /**
  59106. * In metallic workflow, specifies an F90 color to help configuring the material F90.
  59107. * By default the F90 is always 1;
  59108. *
  59109. * Please note that this factor is also used as a factor against the default reflectance at normal incidence.
  59110. *
  59111. * F0 = defaultF0 * metallicF0Factor * metallicReflectanceColor
  59112. * F90 = metallicReflectanceColor;
  59113. */
  59114. protected _metallicReflectanceColor: Color3;
  59115. /**
  59116. * Defines to store metallicReflectanceColor in RGB and metallicF0Factor in A
  59117. * This is multiply against the scalar values defined in the material.
  59118. */
  59119. protected _metallicReflectanceTexture: Nullable<BaseTexture>;
  59120. /**
  59121. * Used to enable roughness/glossiness fetch from a separate channel depending on the current mode.
  59122. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  59123. */
  59124. protected _microSurfaceTexture: Nullable<BaseTexture>;
  59125. /**
  59126. * Stores surface normal data used to displace a mesh in a texture.
  59127. */
  59128. protected _bumpTexture: Nullable<BaseTexture>;
  59129. /**
  59130. * Stores the pre-calculated light information of a mesh in a texture.
  59131. */
  59132. protected _lightmapTexture: Nullable<BaseTexture>;
  59133. /**
  59134. * The color of a material in ambient lighting.
  59135. */
  59136. protected _ambientColor: Color3;
  59137. /**
  59138. * AKA Diffuse Color in other nomenclature.
  59139. */
  59140. protected _albedoColor: Color3;
  59141. /**
  59142. * AKA Specular Color in other nomenclature.
  59143. */
  59144. protected _reflectivityColor: Color3;
  59145. /**
  59146. * The color applied when light is reflected from a material.
  59147. */
  59148. protected _reflectionColor: Color3;
  59149. /**
  59150. * The color applied when light is emitted from a material.
  59151. */
  59152. protected _emissiveColor: Color3;
  59153. /**
  59154. * AKA Glossiness in other nomenclature.
  59155. */
  59156. protected _microSurface: number;
  59157. /**
  59158. * Specifies that the material will use the light map as a show map.
  59159. */
  59160. protected _useLightmapAsShadowmap: boolean;
  59161. /**
  59162. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  59163. * makes the reflect vector face the model (under horizon).
  59164. */
  59165. protected _useHorizonOcclusion: boolean;
  59166. /**
  59167. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  59168. * too much the area relying on ambient texture to define their ambient occlusion.
  59169. */
  59170. protected _useRadianceOcclusion: boolean;
  59171. /**
  59172. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  59173. */
  59174. protected _useAlphaFromAlbedoTexture: boolean;
  59175. /**
  59176. * Specifies that the material will keeps the specular highlights over a transparent surface (only the most limunous ones).
  59177. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  59178. */
  59179. protected _useSpecularOverAlpha: boolean;
  59180. /**
  59181. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  59182. */
  59183. protected _useMicroSurfaceFromReflectivityMapAlpha: boolean;
  59184. /**
  59185. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  59186. */
  59187. protected _useRoughnessFromMetallicTextureAlpha: boolean;
  59188. /**
  59189. * Specifies if the metallic texture contains the roughness information in its green channel.
  59190. */
  59191. protected _useRoughnessFromMetallicTextureGreen: boolean;
  59192. /**
  59193. * Specifies if the metallic texture contains the metallness information in its blue channel.
  59194. */
  59195. protected _useMetallnessFromMetallicTextureBlue: boolean;
  59196. /**
  59197. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  59198. */
  59199. protected _useAmbientOcclusionFromMetallicTextureRed: boolean;
  59200. /**
  59201. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  59202. */
  59203. protected _useAmbientInGrayScale: boolean;
  59204. /**
  59205. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  59206. * The material will try to infer what glossiness each pixel should be.
  59207. */
  59208. protected _useAutoMicroSurfaceFromReflectivityMap: boolean;
  59209. /**
  59210. * Defines the falloff type used in this material.
  59211. * It by default is Physical.
  59212. */
  59213. protected _lightFalloff: number;
  59214. /**
  59215. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  59216. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  59217. */
  59218. protected _useRadianceOverAlpha: boolean;
  59219. /**
  59220. * Allows using an object space normal map (instead of tangent space).
  59221. */
  59222. protected _useObjectSpaceNormalMap: boolean;
  59223. /**
  59224. * Allows using the bump map in parallax mode.
  59225. */
  59226. protected _useParallax: boolean;
  59227. /**
  59228. * Allows using the bump map in parallax occlusion mode.
  59229. */
  59230. protected _useParallaxOcclusion: boolean;
  59231. /**
  59232. * Controls the scale bias of the parallax mode.
  59233. */
  59234. protected _parallaxScaleBias: number;
  59235. /**
  59236. * If sets to true, disables all the lights affecting the material.
  59237. */
  59238. protected _disableLighting: boolean;
  59239. /**
  59240. * Number of Simultaneous lights allowed on the material.
  59241. */
  59242. protected _maxSimultaneousLights: number;
  59243. /**
  59244. * If sets to true, x component of normal map value will be inverted (x = 1.0 - x).
  59245. */
  59246. protected _invertNormalMapX: boolean;
  59247. /**
  59248. * If sets to true, y component of normal map value will be inverted (y = 1.0 - y).
  59249. */
  59250. protected _invertNormalMapY: boolean;
  59251. /**
  59252. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  59253. */
  59254. protected _twoSidedLighting: boolean;
  59255. /**
  59256. * Defines the alpha limits in alpha test mode.
  59257. */
  59258. protected _alphaCutOff: number;
  59259. /**
  59260. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  59261. */
  59262. protected _forceAlphaTest: boolean;
  59263. /**
  59264. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  59265. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  59266. */
  59267. protected _useAlphaFresnel: boolean;
  59268. /**
  59269. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  59270. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  59271. */
  59272. protected _useLinearAlphaFresnel: boolean;
  59273. /**
  59274. * Specifies the environment BRDF texture used to comput the scale and offset roughness values
  59275. * from cos thetav and roughness:
  59276. * http://blog.selfshadow.com/publications/s2013-shading-course/karis/s2013_pbs_epic_notes_v2.pdf
  59277. */
  59278. protected _environmentBRDFTexture: Nullable<BaseTexture>;
  59279. /**
  59280. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  59281. */
  59282. protected _forceIrradianceInFragment: boolean;
  59283. private _realTimeFiltering;
  59284. /**
  59285. * Enables realtime filtering on the texture.
  59286. */
  59287. get realTimeFiltering(): boolean;
  59288. set realTimeFiltering(b: boolean);
  59289. private _realTimeFilteringQuality;
  59290. /**
  59291. * Quality switch for realtime filtering
  59292. */
  59293. get realTimeFilteringQuality(): number;
  59294. set realTimeFilteringQuality(n: number);
  59295. /**
  59296. * Can this material render to several textures at once
  59297. */
  59298. get canRenderToMRT(): boolean;
  59299. /**
  59300. * Force normal to face away from face.
  59301. */
  59302. protected _forceNormalForward: boolean;
  59303. /**
  59304. * Enables specular anti aliasing in the PBR shader.
  59305. * It will both interacts on the Geometry for analytical and IBL lighting.
  59306. * It also prefilter the roughness map based on the bump values.
  59307. */
  59308. protected _enableSpecularAntiAliasing: boolean;
  59309. /**
  59310. * Default configuration related to image processing available in the PBR Material.
  59311. */
  59312. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  59313. /**
  59314. * Keep track of the image processing observer to allow dispose and replace.
  59315. */
  59316. private _imageProcessingObserver;
  59317. /**
  59318. * Attaches a new image processing configuration to the PBR Material.
  59319. * @param configuration
  59320. */
  59321. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  59322. /**
  59323. * Stores the available render targets.
  59324. */
  59325. private _renderTargets;
  59326. /**
  59327. * Sets the global ambient color for the material used in lighting calculations.
  59328. */
  59329. private _globalAmbientColor;
  59330. /**
  59331. * Enables the use of logarithmic depth buffers, which is good for wide depth buffers.
  59332. */
  59333. private _useLogarithmicDepth;
  59334. /**
  59335. * If set to true, no lighting calculations will be applied.
  59336. */
  59337. private _unlit;
  59338. private _debugMode;
  59339. /**
  59340. * @hidden
  59341. * This is reserved for the inspector.
  59342. * Defines the material debug mode.
  59343. * It helps seeing only some components of the material while troubleshooting.
  59344. */
  59345. debugMode: number;
  59346. /**
  59347. * @hidden
  59348. * This is reserved for the inspector.
  59349. * Specify from where on screen the debug mode should start.
  59350. * The value goes from -1 (full screen) to 1 (not visible)
  59351. * It helps with side by side comparison against the final render
  59352. * This defaults to -1
  59353. */
  59354. private debugLimit;
  59355. /**
  59356. * @hidden
  59357. * This is reserved for the inspector.
  59358. * As the default viewing range might not be enough (if the ambient is really small for instance)
  59359. * You can use the factor to better multiply the final value.
  59360. */
  59361. private debugFactor;
  59362. /**
  59363. * Defines the clear coat layer parameters for the material.
  59364. */
  59365. readonly clearCoat: PBRClearCoatConfiguration;
  59366. /**
  59367. * Defines the anisotropic parameters for the material.
  59368. */
  59369. readonly anisotropy: PBRAnisotropicConfiguration;
  59370. /**
  59371. * Defines the BRDF parameters for the material.
  59372. */
  59373. readonly brdf: PBRBRDFConfiguration;
  59374. /**
  59375. * Defines the Sheen parameters for the material.
  59376. */
  59377. readonly sheen: PBRSheenConfiguration;
  59378. /**
  59379. * Defines the SubSurface parameters for the material.
  59380. */
  59381. readonly subSurface: PBRSubSurfaceConfiguration;
  59382. /**
  59383. * Defines the detail map parameters for the material.
  59384. */
  59385. readonly detailMap: DetailMapConfiguration;
  59386. protected _rebuildInParallel: boolean;
  59387. /**
  59388. * Instantiates a new PBRMaterial instance.
  59389. *
  59390. * @param name The material name
  59391. * @param scene The scene the material will be use in.
  59392. */
  59393. constructor(name: string, scene: Scene);
  59394. /**
  59395. * Gets a boolean indicating that current material needs to register RTT
  59396. */
  59397. get hasRenderTargetTextures(): boolean;
  59398. /**
  59399. * Gets the name of the material class.
  59400. */
  59401. getClassName(): string;
  59402. /**
  59403. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  59404. */
  59405. get useLogarithmicDepth(): boolean;
  59406. /**
  59407. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  59408. */
  59409. set useLogarithmicDepth(value: boolean);
  59410. /**
  59411. * Returns true if alpha blending should be disabled.
  59412. */
  59413. protected get _disableAlphaBlending(): boolean;
  59414. /**
  59415. * Specifies whether or not this material should be rendered in alpha blend mode.
  59416. */
  59417. needAlphaBlending(): boolean;
  59418. /**
  59419. * Specifies whether or not this material should be rendered in alpha test mode.
  59420. */
  59421. needAlphaTesting(): boolean;
  59422. /**
  59423. * Specifies whether or not the alpha value of the albedo texture should be used for alpha blending.
  59424. */
  59425. protected _shouldUseAlphaFromAlbedoTexture(): boolean;
  59426. /**
  59427. * Gets the texture used for the alpha test.
  59428. */
  59429. getAlphaTestTexture(): Nullable<BaseTexture>;
  59430. /**
  59431. * Specifies that the submesh is ready to be used.
  59432. * @param mesh - BJS mesh.
  59433. * @param subMesh - A submesh of the BJS mesh. Used to check if it is ready.
  59434. * @param useInstances - Specifies that instances should be used.
  59435. * @returns - boolean indicating that the submesh is ready or not.
  59436. */
  59437. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  59438. /**
  59439. * Specifies if the material uses metallic roughness workflow.
  59440. * @returns boolean specifiying if the material uses metallic roughness workflow.
  59441. */
  59442. isMetallicWorkflow(): boolean;
  59443. private _prepareEffect;
  59444. private _prepareDefines;
  59445. /**
  59446. * Force shader compilation
  59447. */
  59448. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<IMaterialCompilationOptions>): void;
  59449. /**
  59450. * Initializes the uniform buffer layout for the shader.
  59451. */
  59452. buildUniformLayout(): void;
  59453. /**
  59454. * Unbinds the material from the mesh
  59455. */
  59456. unbind(): void;
  59457. /**
  59458. * Binds the submesh data.
  59459. * @param world - The world matrix.
  59460. * @param mesh - The BJS mesh.
  59461. * @param subMesh - A submesh of the BJS mesh.
  59462. */
  59463. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  59464. /**
  59465. * Returns the animatable textures.
  59466. * @returns - Array of animatable textures.
  59467. */
  59468. getAnimatables(): IAnimatable[];
  59469. /**
  59470. * Returns the texture used for reflections.
  59471. * @returns - Reflection texture if present. Otherwise, returns the environment texture.
  59472. */
  59473. private _getReflectionTexture;
  59474. /**
  59475. * Returns an array of the actively used textures.
  59476. * @returns - Array of BaseTextures
  59477. */
  59478. getActiveTextures(): BaseTexture[];
  59479. /**
  59480. * Checks to see if a texture is used in the material.
  59481. * @param texture - Base texture to use.
  59482. * @returns - Boolean specifying if a texture is used in the material.
  59483. */
  59484. hasTexture(texture: BaseTexture): boolean;
  59485. /**
  59486. * Sets the required values to the prepass renderer.
  59487. * @param prePassRenderer defines the prepass renderer to setup
  59488. */
  59489. setPrePassRenderer(prePassRenderer: PrePassRenderer): boolean;
  59490. /**
  59491. * Disposes the resources of the material.
  59492. * @param forceDisposeEffect - Forces the disposal of effects.
  59493. * @param forceDisposeTextures - Forces the disposal of all textures.
  59494. */
  59495. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  59496. }
  59497. }
  59498. declare module "babylonjs/Materials/PBR/pbrMaterial" {
  59499. import { Nullable } from "babylonjs/types";
  59500. import { Scene } from "babylonjs/scene";
  59501. import { Color3 } from "babylonjs/Maths/math.color";
  59502. import { ImageProcessingConfiguration } from "babylonjs/Materials/imageProcessingConfiguration";
  59503. import { ColorCurves } from "babylonjs/Materials/colorCurves";
  59504. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  59505. import { PBRBaseMaterial } from "babylonjs/Materials/PBR/pbrBaseMaterial";
  59506. /**
  59507. * The Physically based material of BJS.
  59508. *
  59509. * This offers the main features of a standard PBR material.
  59510. * For more information, please refer to the documentation :
  59511. * https://doc.babylonjs.com/how_to/physically_based_rendering
  59512. */
  59513. export class PBRMaterial extends PBRBaseMaterial {
  59514. /**
  59515. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  59516. */
  59517. static readonly PBRMATERIAL_OPAQUE: number;
  59518. /**
  59519. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  59520. */
  59521. static readonly PBRMATERIAL_ALPHATEST: number;
  59522. /**
  59523. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  59524. */
  59525. static readonly PBRMATERIAL_ALPHABLEND: number;
  59526. /**
  59527. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  59528. * They are also discarded below the alpha cutoff threshold to improve performances.
  59529. */
  59530. static readonly PBRMATERIAL_ALPHATESTANDBLEND: number;
  59531. /**
  59532. * Defines the default value of how much AO map is occluding the analytical lights
  59533. * (point spot...).
  59534. */
  59535. static DEFAULT_AO_ON_ANALYTICAL_LIGHTS: number;
  59536. /**
  59537. * Intensity of the direct lights e.g. the four lights available in your scene.
  59538. * This impacts both the direct diffuse and specular highlights.
  59539. */
  59540. directIntensity: number;
  59541. /**
  59542. * Intensity of the emissive part of the material.
  59543. * This helps controlling the emissive effect without modifying the emissive color.
  59544. */
  59545. emissiveIntensity: number;
  59546. /**
  59547. * Intensity of the environment e.g. how much the environment will light the object
  59548. * either through harmonics for rough material or through the refelction for shiny ones.
  59549. */
  59550. environmentIntensity: number;
  59551. /**
  59552. * This is a special control allowing the reduction of the specular highlights coming from the
  59553. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  59554. */
  59555. specularIntensity: number;
  59556. /**
  59557. * Debug Control allowing disabling the bump map on this material.
  59558. */
  59559. disableBumpMap: boolean;
  59560. /**
  59561. * AKA Diffuse Texture in standard nomenclature.
  59562. */
  59563. albedoTexture: BaseTexture;
  59564. /**
  59565. * AKA Occlusion Texture in other nomenclature.
  59566. */
  59567. ambientTexture: BaseTexture;
  59568. /**
  59569. * AKA Occlusion Texture Intensity in other nomenclature.
  59570. */
  59571. ambientTextureStrength: number;
  59572. /**
  59573. * Defines how much the AO map is occluding the analytical lights (point spot...).
  59574. * 1 means it completely occludes it
  59575. * 0 mean it has no impact
  59576. */
  59577. ambientTextureImpactOnAnalyticalLights: number;
  59578. /**
  59579. * Stores the alpha values in a texture. Use luminance if texture.getAlphaFromRGB is true.
  59580. */
  59581. opacityTexture: BaseTexture;
  59582. /**
  59583. * Stores the reflection values in a texture.
  59584. */
  59585. reflectionTexture: Nullable<BaseTexture>;
  59586. /**
  59587. * Stores the emissive values in a texture.
  59588. */
  59589. emissiveTexture: BaseTexture;
  59590. /**
  59591. * AKA Specular texture in other nomenclature.
  59592. */
  59593. reflectivityTexture: BaseTexture;
  59594. /**
  59595. * Used to switch from specular/glossiness to metallic/roughness workflow.
  59596. */
  59597. metallicTexture: BaseTexture;
  59598. /**
  59599. * Specifies the metallic scalar of the metallic/roughness workflow.
  59600. * Can also be used to scale the metalness values of the metallic texture.
  59601. */
  59602. metallic: Nullable<number>;
  59603. /**
  59604. * Specifies the roughness scalar of the metallic/roughness workflow.
  59605. * Can also be used to scale the roughness values of the metallic texture.
  59606. */
  59607. roughness: Nullable<number>;
  59608. /**
  59609. * In metallic workflow, specifies an F0 factor to help configuring the material F0.
  59610. * By default the indexOfrefraction is used to compute F0;
  59611. *
  59612. * This is used as a factor against the default reflectance at normal incidence to tweak it.
  59613. *
  59614. * F0 = defaultF0 * metallicF0Factor * metallicReflectanceColor;
  59615. * F90 = metallicReflectanceColor;
  59616. */
  59617. metallicF0Factor: number;
  59618. /**
  59619. * In metallic workflow, specifies an F90 color to help configuring the material F90.
  59620. * By default the F90 is always 1;
  59621. *
  59622. * Please note that this factor is also used as a factor against the default reflectance at normal incidence.
  59623. *
  59624. * F0 = defaultF0 * metallicF0Factor * metallicReflectanceColor
  59625. * F90 = metallicReflectanceColor;
  59626. */
  59627. metallicReflectanceColor: Color3;
  59628. /**
  59629. * Defines to store metallicReflectanceColor in RGB and metallicF0Factor in A
  59630. * This is multiply against the scalar values defined in the material.
  59631. */
  59632. metallicReflectanceTexture: Nullable<BaseTexture>;
  59633. /**
  59634. * Used to enable roughness/glossiness fetch from a separate channel depending on the current mode.
  59635. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  59636. */
  59637. microSurfaceTexture: BaseTexture;
  59638. /**
  59639. * Stores surface normal data used to displace a mesh in a texture.
  59640. */
  59641. bumpTexture: BaseTexture;
  59642. /**
  59643. * Stores the pre-calculated light information of a mesh in a texture.
  59644. */
  59645. lightmapTexture: BaseTexture;
  59646. /**
  59647. * Stores the refracted light information in a texture.
  59648. */
  59649. get refractionTexture(): Nullable<BaseTexture>;
  59650. set refractionTexture(value: Nullable<BaseTexture>);
  59651. /**
  59652. * The color of a material in ambient lighting.
  59653. */
  59654. ambientColor: Color3;
  59655. /**
  59656. * AKA Diffuse Color in other nomenclature.
  59657. */
  59658. albedoColor: Color3;
  59659. /**
  59660. * AKA Specular Color in other nomenclature.
  59661. */
  59662. reflectivityColor: Color3;
  59663. /**
  59664. * The color reflected from the material.
  59665. */
  59666. reflectionColor: Color3;
  59667. /**
  59668. * The color emitted from the material.
  59669. */
  59670. emissiveColor: Color3;
  59671. /**
  59672. * AKA Glossiness in other nomenclature.
  59673. */
  59674. microSurface: number;
  59675. /**
  59676. * Index of refraction of the material base layer.
  59677. * https://en.wikipedia.org/wiki/List_of_refractive_indices
  59678. *
  59679. * This does not only impact refraction but also the Base F0 of Dielectric Materials.
  59680. *
  59681. * From dielectric fresnel rules: F0 = square((iorT - iorI) / (iorT + iorI))
  59682. */
  59683. get indexOfRefraction(): number;
  59684. set indexOfRefraction(value: number);
  59685. /**
  59686. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  59687. */
  59688. get invertRefractionY(): boolean;
  59689. set invertRefractionY(value: boolean);
  59690. /**
  59691. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  59692. * Materials half opaque for instance using refraction could benefit from this control.
  59693. */
  59694. get linkRefractionWithTransparency(): boolean;
  59695. set linkRefractionWithTransparency(value: boolean);
  59696. /**
  59697. * If true, the light map contains occlusion information instead of lighting info.
  59698. */
  59699. useLightmapAsShadowmap: boolean;
  59700. /**
  59701. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  59702. */
  59703. useAlphaFromAlbedoTexture: boolean;
  59704. /**
  59705. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  59706. */
  59707. forceAlphaTest: boolean;
  59708. /**
  59709. * Defines the alpha limits in alpha test mode.
  59710. */
  59711. alphaCutOff: number;
  59712. /**
  59713. * Specifies that the material will keep the specular highlights over a transparent surface (only the most limunous ones).
  59714. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  59715. */
  59716. useSpecularOverAlpha: boolean;
  59717. /**
  59718. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  59719. */
  59720. useMicroSurfaceFromReflectivityMapAlpha: boolean;
  59721. /**
  59722. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  59723. */
  59724. useRoughnessFromMetallicTextureAlpha: boolean;
  59725. /**
  59726. * Specifies if the metallic texture contains the roughness information in its green channel.
  59727. */
  59728. useRoughnessFromMetallicTextureGreen: boolean;
  59729. /**
  59730. * Specifies if the metallic texture contains the metallness information in its blue channel.
  59731. */
  59732. useMetallnessFromMetallicTextureBlue: boolean;
  59733. /**
  59734. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  59735. */
  59736. useAmbientOcclusionFromMetallicTextureRed: boolean;
  59737. /**
  59738. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  59739. */
  59740. useAmbientInGrayScale: boolean;
  59741. /**
  59742. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  59743. * The material will try to infer what glossiness each pixel should be.
  59744. */
  59745. useAutoMicroSurfaceFromReflectivityMap: boolean;
  59746. /**
  59747. * BJS is using an harcoded light falloff based on a manually sets up range.
  59748. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  59749. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  59750. */
  59751. get usePhysicalLightFalloff(): boolean;
  59752. /**
  59753. * BJS is using an harcoded light falloff based on a manually sets up range.
  59754. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  59755. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  59756. */
  59757. set usePhysicalLightFalloff(value: boolean);
  59758. /**
  59759. * In order to support the falloff compatibility with gltf, a special mode has been added
  59760. * to reproduce the gltf light falloff.
  59761. */
  59762. get useGLTFLightFalloff(): boolean;
  59763. /**
  59764. * In order to support the falloff compatibility with gltf, a special mode has been added
  59765. * to reproduce the gltf light falloff.
  59766. */
  59767. set useGLTFLightFalloff(value: boolean);
  59768. /**
  59769. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  59770. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  59771. */
  59772. useRadianceOverAlpha: boolean;
  59773. /**
  59774. * Allows using an object space normal map (instead of tangent space).
  59775. */
  59776. useObjectSpaceNormalMap: boolean;
  59777. /**
  59778. * Allows using the bump map in parallax mode.
  59779. */
  59780. useParallax: boolean;
  59781. /**
  59782. * Allows using the bump map in parallax occlusion mode.
  59783. */
  59784. useParallaxOcclusion: boolean;
  59785. /**
  59786. * Controls the scale bias of the parallax mode.
  59787. */
  59788. parallaxScaleBias: number;
  59789. /**
  59790. * If sets to true, disables all the lights affecting the material.
  59791. */
  59792. disableLighting: boolean;
  59793. /**
  59794. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  59795. */
  59796. forceIrradianceInFragment: boolean;
  59797. /**
  59798. * Number of Simultaneous lights allowed on the material.
  59799. */
  59800. maxSimultaneousLights: number;
  59801. /**
  59802. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  59803. */
  59804. invertNormalMapX: boolean;
  59805. /**
  59806. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  59807. */
  59808. invertNormalMapY: boolean;
  59809. /**
  59810. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  59811. */
  59812. twoSidedLighting: boolean;
  59813. /**
  59814. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  59815. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  59816. */
  59817. useAlphaFresnel: boolean;
  59818. /**
  59819. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  59820. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  59821. */
  59822. useLinearAlphaFresnel: boolean;
  59823. /**
  59824. * Let user defines the brdf lookup texture used for IBL.
  59825. * A default 8bit version is embedded but you could point at :
  59826. * * Default texture: https://assets.babylonjs.com/environments/correlatedMSBRDF_RGBD.png
  59827. * * Default 16bit pixel depth texture: https://assets.babylonjs.com/environments/correlatedMSBRDF.dds
  59828. * * LEGACY Default None correlated https://assets.babylonjs.com/environments/uncorrelatedBRDF_RGBD.png
  59829. * * LEGACY Default None correlated 16bit pixel depth https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds
  59830. */
  59831. environmentBRDFTexture: Nullable<BaseTexture>;
  59832. /**
  59833. * Force normal to face away from face.
  59834. */
  59835. forceNormalForward: boolean;
  59836. /**
  59837. * Enables specular anti aliasing in the PBR shader.
  59838. * It will both interacts on the Geometry for analytical and IBL lighting.
  59839. * It also prefilter the roughness map based on the bump values.
  59840. */
  59841. enableSpecularAntiAliasing: boolean;
  59842. /**
  59843. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  59844. * makes the reflect vector face the model (under horizon).
  59845. */
  59846. useHorizonOcclusion: boolean;
  59847. /**
  59848. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  59849. * too much the area relying on ambient texture to define their ambient occlusion.
  59850. */
  59851. useRadianceOcclusion: boolean;
  59852. /**
  59853. * If set to true, no lighting calculations will be applied.
  59854. */
  59855. unlit: boolean;
  59856. /**
  59857. * Gets the image processing configuration used either in this material.
  59858. */
  59859. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  59860. /**
  59861. * Sets the Default image processing configuration used either in the this material.
  59862. *
  59863. * If sets to null, the scene one is in use.
  59864. */
  59865. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  59866. /**
  59867. * Gets wether the color curves effect is enabled.
  59868. */
  59869. get cameraColorCurvesEnabled(): boolean;
  59870. /**
  59871. * Sets wether the color curves effect is enabled.
  59872. */
  59873. set cameraColorCurvesEnabled(value: boolean);
  59874. /**
  59875. * Gets wether the color grading effect is enabled.
  59876. */
  59877. get cameraColorGradingEnabled(): boolean;
  59878. /**
  59879. * Gets wether the color grading effect is enabled.
  59880. */
  59881. set cameraColorGradingEnabled(value: boolean);
  59882. /**
  59883. * Gets wether tonemapping is enabled or not.
  59884. */
  59885. get cameraToneMappingEnabled(): boolean;
  59886. /**
  59887. * Sets wether tonemapping is enabled or not
  59888. */
  59889. set cameraToneMappingEnabled(value: boolean);
  59890. /**
  59891. * The camera exposure used on this material.
  59892. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  59893. * This corresponds to a photographic exposure.
  59894. */
  59895. get cameraExposure(): number;
  59896. /**
  59897. * The camera exposure used on this material.
  59898. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  59899. * This corresponds to a photographic exposure.
  59900. */
  59901. set cameraExposure(value: number);
  59902. /**
  59903. * Gets The camera contrast used on this material.
  59904. */
  59905. get cameraContrast(): number;
  59906. /**
  59907. * Sets The camera contrast used on this material.
  59908. */
  59909. set cameraContrast(value: number);
  59910. /**
  59911. * Gets the Color Grading 2D Lookup Texture.
  59912. */
  59913. get cameraColorGradingTexture(): Nullable<BaseTexture>;
  59914. /**
  59915. * Sets the Color Grading 2D Lookup Texture.
  59916. */
  59917. set cameraColorGradingTexture(value: Nullable<BaseTexture>);
  59918. /**
  59919. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  59920. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  59921. * 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;
  59922. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  59923. */
  59924. get cameraColorCurves(): Nullable<ColorCurves>;
  59925. /**
  59926. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  59927. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  59928. * 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;
  59929. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  59930. */
  59931. set cameraColorCurves(value: Nullable<ColorCurves>);
  59932. /**
  59933. * Instantiates a new PBRMaterial instance.
  59934. *
  59935. * @param name The material name
  59936. * @param scene The scene the material will be use in.
  59937. */
  59938. constructor(name: string, scene: Scene);
  59939. /**
  59940. * Returns the name of this material class.
  59941. */
  59942. getClassName(): string;
  59943. /**
  59944. * Makes a duplicate of the current material.
  59945. * @param name - name to use for the new material.
  59946. */
  59947. clone(name: string): PBRMaterial;
  59948. /**
  59949. * Serializes this PBR Material.
  59950. * @returns - An object with the serialized material.
  59951. */
  59952. serialize(): any;
  59953. /**
  59954. * Parses a PBR Material from a serialized object.
  59955. * @param source - Serialized object.
  59956. * @param scene - BJS scene instance.
  59957. * @param rootUrl - url for the scene object
  59958. * @returns - PBRMaterial
  59959. */
  59960. static Parse(source: any, scene: Scene, rootUrl: string): PBRMaterial;
  59961. }
  59962. }
  59963. declare module "babylonjs/Misc/dds" {
  59964. import { SphericalPolynomial } from "babylonjs/Maths/sphericalPolynomial";
  59965. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  59966. import { Nullable } from "babylonjs/types";
  59967. import { Scene } from "babylonjs/scene";
  59968. import "babylonjs/Engines/Extensions/engine.cubeTexture";
  59969. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  59970. /**
  59971. * Direct draw surface info
  59972. * @see https://docs.microsoft.com/en-us/windows/desktop/direct3ddds/dx-graphics-dds-pguide
  59973. */
  59974. export interface DDSInfo {
  59975. /**
  59976. * Width of the texture
  59977. */
  59978. width: number;
  59979. /**
  59980. * Width of the texture
  59981. */
  59982. height: number;
  59983. /**
  59984. * Number of Mipmaps for the texture
  59985. * @see https://en.wikipedia.org/wiki/Mipmap
  59986. */
  59987. mipmapCount: number;
  59988. /**
  59989. * If the textures format is a known fourCC format
  59990. * @see https://www.fourcc.org/
  59991. */
  59992. isFourCC: boolean;
  59993. /**
  59994. * If the texture is an RGB format eg. DXGI_FORMAT_B8G8R8X8_UNORM format
  59995. */
  59996. isRGB: boolean;
  59997. /**
  59998. * If the texture is a lumincance format
  59999. */
  60000. isLuminance: boolean;
  60001. /**
  60002. * If this is a cube texture
  60003. * @see https://docs.microsoft.com/en-us/windows/desktop/direct3ddds/dds-file-layout-for-cubic-environment-maps
  60004. */
  60005. isCube: boolean;
  60006. /**
  60007. * If the texture is a compressed format eg. FOURCC_DXT1
  60008. */
  60009. isCompressed: boolean;
  60010. /**
  60011. * The dxgiFormat of the texture
  60012. * @see https://docs.microsoft.com/en-us/windows/desktop/api/dxgiformat/ne-dxgiformat-dxgi_format
  60013. */
  60014. dxgiFormat: number;
  60015. /**
  60016. * Texture type eg. Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT
  60017. */
  60018. textureType: number;
  60019. /**
  60020. * Sphericle polynomial created for the dds texture
  60021. */
  60022. sphericalPolynomial?: SphericalPolynomial;
  60023. }
  60024. /**
  60025. * Class used to provide DDS decompression tools
  60026. */
  60027. export class DDSTools {
  60028. /**
  60029. * Gets or sets a boolean indicating that LOD info is stored in alpha channel (false by default)
  60030. */
  60031. static StoreLODInAlphaChannel: boolean;
  60032. /**
  60033. * Gets DDS information from an array buffer
  60034. * @param data defines the array buffer view to read data from
  60035. * @returns the DDS information
  60036. */
  60037. static GetDDSInfo(data: ArrayBufferView): DDSInfo;
  60038. private static _FloatView;
  60039. private static _Int32View;
  60040. private static _ToHalfFloat;
  60041. private static _FromHalfFloat;
  60042. private static _GetHalfFloatAsFloatRGBAArrayBuffer;
  60043. private static _GetHalfFloatRGBAArrayBuffer;
  60044. private static _GetFloatRGBAArrayBuffer;
  60045. private static _GetFloatAsUIntRGBAArrayBuffer;
  60046. private static _GetHalfFloatAsUIntRGBAArrayBuffer;
  60047. private static _GetRGBAArrayBuffer;
  60048. private static _ExtractLongWordOrder;
  60049. private static _GetRGBArrayBuffer;
  60050. private static _GetLuminanceArrayBuffer;
  60051. /**
  60052. * Uploads DDS Levels to a Babylon Texture
  60053. * @hidden
  60054. */
  60055. static UploadDDSLevels(engine: ThinEngine, texture: InternalTexture, data: ArrayBufferView, info: DDSInfo, loadMipmaps: boolean, faces: number, lodIndex?: number, currentFace?: number): void;
  60056. }
  60057. module "babylonjs/Engines/thinEngine" {
  60058. interface ThinEngine {
  60059. /**
  60060. * Create a cube texture from prefiltered data (ie. the mipmaps contain ready to use data for PBR reflection)
  60061. * @param rootUrl defines the url where the file to load is located
  60062. * @param scene defines the current scene
  60063. * @param lodScale defines scale to apply to the mip map selection
  60064. * @param lodOffset defines offset to apply to the mip map selection
  60065. * @param onLoad defines an optional callback raised when the texture is loaded
  60066. * @param onError defines an optional callback raised if there is an issue to load the texture
  60067. * @param format defines the format of the data
  60068. * @param forcedExtension defines the extension to use to pick the right loader
  60069. * @param createPolynomials defines wheter or not to create polynomails harmonics for the texture
  60070. * @returns the cube texture as an InternalTexture
  60071. */
  60072. 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;
  60073. }
  60074. }
  60075. }
  60076. declare module "babylonjs/Materials/Textures/Loaders/ddsTextureLoader" {
  60077. import { Nullable } from "babylonjs/types";
  60078. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  60079. import { IInternalTextureLoader } from "babylonjs/Materials/Textures/internalTextureLoader";
  60080. /**
  60081. * Implementation of the DDS Texture Loader.
  60082. * @hidden
  60083. */
  60084. export class _DDSTextureLoader implements IInternalTextureLoader {
  60085. /**
  60086. * Defines wether the loader supports cascade loading the different faces.
  60087. */
  60088. readonly supportCascades: boolean;
  60089. /**
  60090. * This returns if the loader support the current file information.
  60091. * @param extension defines the file extension of the file being loaded
  60092. * @returns true if the loader can load the specified file
  60093. */
  60094. canLoad(extension: string): boolean;
  60095. /**
  60096. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  60097. * @param data contains the texture data
  60098. * @param texture defines the BabylonJS internal texture
  60099. * @param createPolynomials will be true if polynomials have been requested
  60100. * @param onLoad defines the callback to trigger once the texture is ready
  60101. * @param onError defines the callback to trigger in case of error
  60102. */
  60103. loadCubeData(imgs: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  60104. /**
  60105. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  60106. * @param data contains the texture data
  60107. * @param texture defines the BabylonJS internal texture
  60108. * @param callback defines the method to call once ready to upload
  60109. */
  60110. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  60111. }
  60112. }
  60113. declare module "babylonjs/Materials/Textures/Loaders/envTextureLoader" {
  60114. import { Nullable } from "babylonjs/types";
  60115. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  60116. import { IInternalTextureLoader } from "babylonjs/Materials/Textures/internalTextureLoader";
  60117. /**
  60118. * Implementation of the ENV Texture Loader.
  60119. * @hidden
  60120. */
  60121. export class _ENVTextureLoader implements IInternalTextureLoader {
  60122. /**
  60123. * Defines wether the loader supports cascade loading the different faces.
  60124. */
  60125. readonly supportCascades: boolean;
  60126. /**
  60127. * This returns if the loader support the current file information.
  60128. * @param extension defines the file extension of the file being loaded
  60129. * @returns true if the loader can load the specified file
  60130. */
  60131. canLoad(extension: string): boolean;
  60132. /**
  60133. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  60134. * @param data contains the texture data
  60135. * @param texture defines the BabylonJS internal texture
  60136. * @param createPolynomials will be true if polynomials have been requested
  60137. * @param onLoad defines the callback to trigger once the texture is ready
  60138. * @param onError defines the callback to trigger in case of error
  60139. */
  60140. loadCubeData(data: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  60141. /**
  60142. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  60143. * @param data contains the texture data
  60144. * @param texture defines the BabylonJS internal texture
  60145. * @param callback defines the method to call once ready to upload
  60146. */
  60147. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  60148. }
  60149. }
  60150. declare module "babylonjs/Misc/khronosTextureContainer" {
  60151. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  60152. /**
  60153. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  60154. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  60155. */
  60156. export class KhronosTextureContainer {
  60157. /** contents of the KTX container file */
  60158. data: ArrayBufferView;
  60159. private static HEADER_LEN;
  60160. private static COMPRESSED_2D;
  60161. private static COMPRESSED_3D;
  60162. private static TEX_2D;
  60163. private static TEX_3D;
  60164. /**
  60165. * Gets the openGL type
  60166. */
  60167. glType: number;
  60168. /**
  60169. * Gets the openGL type size
  60170. */
  60171. glTypeSize: number;
  60172. /**
  60173. * Gets the openGL format
  60174. */
  60175. glFormat: number;
  60176. /**
  60177. * Gets the openGL internal format
  60178. */
  60179. glInternalFormat: number;
  60180. /**
  60181. * Gets the base internal format
  60182. */
  60183. glBaseInternalFormat: number;
  60184. /**
  60185. * Gets image width in pixel
  60186. */
  60187. pixelWidth: number;
  60188. /**
  60189. * Gets image height in pixel
  60190. */
  60191. pixelHeight: number;
  60192. /**
  60193. * Gets image depth in pixels
  60194. */
  60195. pixelDepth: number;
  60196. /**
  60197. * Gets the number of array elements
  60198. */
  60199. numberOfArrayElements: number;
  60200. /**
  60201. * Gets the number of faces
  60202. */
  60203. numberOfFaces: number;
  60204. /**
  60205. * Gets the number of mipmap levels
  60206. */
  60207. numberOfMipmapLevels: number;
  60208. /**
  60209. * Gets the bytes of key value data
  60210. */
  60211. bytesOfKeyValueData: number;
  60212. /**
  60213. * Gets the load type
  60214. */
  60215. loadType: number;
  60216. /**
  60217. * If the container has been made invalid (eg. constructor failed to correctly load array buffer)
  60218. */
  60219. isInvalid: boolean;
  60220. /**
  60221. * Creates a new KhronosTextureContainer
  60222. * @param data contents of the KTX container file
  60223. * @param facesExpected should be either 1 or 6, based whether a cube texture or or
  60224. * @param threeDExpected provision for indicating that data should be a 3D texture, not implemented
  60225. * @param textureArrayExpected provision for indicating that data should be a texture array, not implemented
  60226. */
  60227. constructor(
  60228. /** contents of the KTX container file */
  60229. data: ArrayBufferView, facesExpected: number, threeDExpected?: boolean, textureArrayExpected?: boolean);
  60230. /**
  60231. * Uploads KTX content to a Babylon Texture.
  60232. * It is assumed that the texture has already been created & is currently bound
  60233. * @hidden
  60234. */
  60235. uploadLevels(texture: InternalTexture, loadMipmaps: boolean): void;
  60236. private _upload2DCompressedLevels;
  60237. /**
  60238. * Checks if the given data starts with a KTX file identifier.
  60239. * @param data the data to check
  60240. * @returns true if the data is a KTX file or false otherwise
  60241. */
  60242. static IsValid(data: ArrayBufferView): boolean;
  60243. }
  60244. }
  60245. declare module "babylonjs/Misc/khronosTextureContainer2" {
  60246. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  60247. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  60248. /**
  60249. * Class for loading KTX2 files
  60250. * !!! Experimental Extension Subject to Changes !!!
  60251. * @hidden
  60252. */
  60253. export class KhronosTextureContainer2 {
  60254. private static _ModulePromise;
  60255. private static _TranscodeFormat;
  60256. constructor(engine: ThinEngine);
  60257. uploadAsync(data: ArrayBufferView, internalTexture: InternalTexture): Promise<void>;
  60258. private _determineTranscodeFormat;
  60259. /**
  60260. * Checks if the given data starts with a KTX2 file identifier.
  60261. * @param data the data to check
  60262. * @returns true if the data is a KTX2 file or false otherwise
  60263. */
  60264. static IsValid(data: ArrayBufferView): boolean;
  60265. }
  60266. }
  60267. declare module "babylonjs/Materials/Textures/Loaders/ktxTextureLoader" {
  60268. import { Nullable } from "babylonjs/types";
  60269. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  60270. import { IInternalTextureLoader } from "babylonjs/Materials/Textures/internalTextureLoader";
  60271. /**
  60272. * Implementation of the KTX Texture Loader.
  60273. * @hidden
  60274. */
  60275. export class _KTXTextureLoader implements IInternalTextureLoader {
  60276. /**
  60277. * Defines wether the loader supports cascade loading the different faces.
  60278. */
  60279. readonly supportCascades: boolean;
  60280. /**
  60281. * This returns if the loader support the current file information.
  60282. * @param extension defines the file extension of the file being loaded
  60283. * @param mimeType defines the optional mime type of the file being loaded
  60284. * @returns true if the loader can load the specified file
  60285. */
  60286. canLoad(extension: string, mimeType?: string): boolean;
  60287. /**
  60288. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  60289. * @param data contains the texture data
  60290. * @param texture defines the BabylonJS internal texture
  60291. * @param createPolynomials will be true if polynomials have been requested
  60292. * @param onLoad defines the callback to trigger once the texture is ready
  60293. * @param onError defines the callback to trigger in case of error
  60294. */
  60295. loadCubeData(data: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  60296. /**
  60297. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  60298. * @param data contains the texture data
  60299. * @param texture defines the BabylonJS internal texture
  60300. * @param callback defines the method to call once ready to upload
  60301. */
  60302. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void, loadFailed: boolean) => void): void;
  60303. }
  60304. }
  60305. declare module "babylonjs/Helpers/sceneHelpers" {
  60306. import { Nullable } from "babylonjs/types";
  60307. import { Mesh } from "babylonjs/Meshes/mesh";
  60308. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  60309. import { IEnvironmentHelperOptions, EnvironmentHelper } from "babylonjs/Helpers/environmentHelper";
  60310. import { VRExperienceHelperOptions, VRExperienceHelper } from "babylonjs/Cameras/VR/vrExperienceHelper";
  60311. import "babylonjs/Materials/Textures/Loaders/ddsTextureLoader";
  60312. import "babylonjs/Materials/Textures/Loaders/envTextureLoader";
  60313. import "babylonjs/Materials/Textures/Loaders/ktxTextureLoader";
  60314. import "babylonjs/Meshes/Builders/boxBuilder";
  60315. import { WebXRDefaultExperience, WebXRDefaultExperienceOptions } from "babylonjs/XR/webXRDefaultExperience";
  60316. /** @hidden */
  60317. export var _forceSceneHelpersToBundle: boolean;
  60318. module "babylonjs/scene" {
  60319. interface Scene {
  60320. /**
  60321. * Creates a default light for the scene.
  60322. * @see https://doc.babylonjs.com/How_To/Fast_Build#create-default-light
  60323. * @param replace has the default false, when true replaces the existing lights in the scene with a hemispheric light
  60324. */
  60325. createDefaultLight(replace?: boolean): void;
  60326. /**
  60327. * Creates a default camera for the scene.
  60328. * @see https://doc.babylonjs.com/How_To/Fast_Build#create-default-camera
  60329. * @param createArcRotateCamera has the default false which creates a free camera, when true creates an arc rotate camera
  60330. * @param replace has default false, when true replaces the active camera in the scene
  60331. * @param attachCameraControls has default false, when true attaches camera controls to the canvas.
  60332. */
  60333. createDefaultCamera(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  60334. /**
  60335. * Creates a default camera and a default light.
  60336. * @see https://doc.babylonjs.com/how_to/Fast_Build#create-default-camera-or-light
  60337. * @param createArcRotateCamera has the default false which creates a free camera, when true creates an arc rotate camera
  60338. * @param replace has the default false, when true replaces the active camera/light in the scene
  60339. * @param attachCameraControls has the default false, when true attaches camera controls to the canvas.
  60340. */
  60341. createDefaultCameraOrLight(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  60342. /**
  60343. * Creates a new sky box
  60344. * @see https://doc.babylonjs.com/how_to/Fast_Build#create-default-skybox
  60345. * @param environmentTexture defines the texture to use as environment texture
  60346. * @param pbr has default false which requires the StandardMaterial to be used, when true PBRMaterial must be used
  60347. * @param scale defines the overall scale of the skybox
  60348. * @param blur is only available when pbr is true, default is 0, no blur, maximum value is 1
  60349. * @param setGlobalEnvTexture has default true indicating that scene.environmentTexture must match the current skybox texture
  60350. * @returns a new mesh holding the sky box
  60351. */
  60352. createDefaultSkybox(environmentTexture?: BaseTexture, pbr?: boolean, scale?: number, blur?: number, setGlobalEnvTexture?: boolean): Nullable<Mesh>;
  60353. /**
  60354. * Creates a new environment
  60355. * @see https://doc.babylonjs.com/How_To/Fast_Build#create-default-environment
  60356. * @param options defines the options you can use to configure the environment
  60357. * @returns the new EnvironmentHelper
  60358. */
  60359. createDefaultEnvironment(options?: Partial<IEnvironmentHelperOptions>): Nullable<EnvironmentHelper>;
  60360. /**
  60361. * Creates a new VREXperienceHelper
  60362. * @see https://doc.babylonjs.com/how_to/webvr_helper
  60363. * @param webVROptions defines the options used to create the new VREXperienceHelper
  60364. * @returns a new VREXperienceHelper
  60365. */
  60366. createDefaultVRExperience(webVROptions?: VRExperienceHelperOptions): VRExperienceHelper;
  60367. /**
  60368. * Creates a new WebXRDefaultExperience
  60369. * @see https://doc.babylonjs.com/how_to/introduction_to_webxr
  60370. * @param options experience options
  60371. * @returns a promise for a new WebXRDefaultExperience
  60372. */
  60373. createDefaultXRExperienceAsync(options: WebXRDefaultExperienceOptions): Promise<WebXRDefaultExperience>;
  60374. }
  60375. }
  60376. }
  60377. declare module "babylonjs/Helpers/videoDome" {
  60378. import { Scene } from "babylonjs/scene";
  60379. import { VideoTexture } from "babylonjs/Materials/Textures/videoTexture";
  60380. import { TextureDome } from "babylonjs/Helpers/textureDome";
  60381. /**
  60382. * Display a 360/180 degree video on an approximately spherical surface, useful for VR applications or skyboxes.
  60383. * As a subclass of TransformNode, this allow parenting to the camera or multiple videos with different locations in the scene.
  60384. * This class achieves its effect with a VideoTexture and a correctly configured BackgroundMaterial on an inverted sphere.
  60385. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  60386. */
  60387. export class VideoDome extends TextureDome<VideoTexture> {
  60388. /**
  60389. * Define the video source as a Monoscopic panoramic 360 video.
  60390. */
  60391. static readonly MODE_MONOSCOPIC: number;
  60392. /**
  60393. * Define the video source as a Stereoscopic TopBottom/OverUnder panoramic 360 video.
  60394. */
  60395. static readonly MODE_TOPBOTTOM: number;
  60396. /**
  60397. * Define the video source as a Stereoscopic Side by Side panoramic 360 video.
  60398. */
  60399. static readonly MODE_SIDEBYSIDE: number;
  60400. /**
  60401. * Get the video texture associated with this video dome
  60402. */
  60403. get videoTexture(): VideoTexture;
  60404. /**
  60405. * Get the video mode of this dome
  60406. */
  60407. get videoMode(): number;
  60408. /**
  60409. * Set the video mode of this dome.
  60410. * @see textureMode
  60411. */
  60412. set videoMode(value: number);
  60413. protected _initTexture(urlsOrElement: string | string[] | HTMLVideoElement, scene: Scene, options: any): VideoTexture;
  60414. }
  60415. }
  60416. declare module "babylonjs/Helpers/index" {
  60417. export * from "babylonjs/Helpers/environmentHelper";
  60418. export * from "babylonjs/Helpers/photoDome";
  60419. export * from "babylonjs/Helpers/sceneHelpers";
  60420. export * from "babylonjs/Helpers/videoDome";
  60421. }
  60422. declare module "babylonjs/Instrumentation/engineInstrumentation" {
  60423. import { PerfCounter } from "babylonjs/Misc/perfCounter";
  60424. import { IDisposable } from "babylonjs/scene";
  60425. import { Engine } from "babylonjs/Engines/engine";
  60426. /**
  60427. * This class can be used to get instrumentation data from a Babylon engine
  60428. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  60429. */
  60430. export class EngineInstrumentation implements IDisposable {
  60431. /**
  60432. * Define the instrumented engine.
  60433. */
  60434. engine: Engine;
  60435. private _captureGPUFrameTime;
  60436. private _gpuFrameTimeToken;
  60437. private _gpuFrameTime;
  60438. private _captureShaderCompilationTime;
  60439. private _shaderCompilationTime;
  60440. private _onBeginFrameObserver;
  60441. private _onEndFrameObserver;
  60442. private _onBeforeShaderCompilationObserver;
  60443. private _onAfterShaderCompilationObserver;
  60444. /**
  60445. * Gets the perf counter used for GPU frame time
  60446. */
  60447. get gpuFrameTimeCounter(): PerfCounter;
  60448. /**
  60449. * Gets the GPU frame time capture status
  60450. */
  60451. get captureGPUFrameTime(): boolean;
  60452. /**
  60453. * Enable or disable the GPU frame time capture
  60454. */
  60455. set captureGPUFrameTime(value: boolean);
  60456. /**
  60457. * Gets the perf counter used for shader compilation time
  60458. */
  60459. get shaderCompilationTimeCounter(): PerfCounter;
  60460. /**
  60461. * Gets the shader compilation time capture status
  60462. */
  60463. get captureShaderCompilationTime(): boolean;
  60464. /**
  60465. * Enable or disable the shader compilation time capture
  60466. */
  60467. set captureShaderCompilationTime(value: boolean);
  60468. /**
  60469. * Instantiates a new engine instrumentation.
  60470. * This class can be used to get instrumentation data from a Babylon engine
  60471. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  60472. * @param engine Defines the engine to instrument
  60473. */
  60474. constructor(
  60475. /**
  60476. * Define the instrumented engine.
  60477. */
  60478. engine: Engine);
  60479. /**
  60480. * Dispose and release associated resources.
  60481. */
  60482. dispose(): void;
  60483. }
  60484. }
  60485. declare module "babylonjs/Instrumentation/sceneInstrumentation" {
  60486. import { Scene, IDisposable } from "babylonjs/scene";
  60487. import { PerfCounter } from "babylonjs/Misc/perfCounter";
  60488. /**
  60489. * This class can be used to get instrumentation data from a Babylon engine
  60490. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  60491. */
  60492. export class SceneInstrumentation implements IDisposable {
  60493. /**
  60494. * Defines the scene to instrument
  60495. */
  60496. scene: Scene;
  60497. private _captureActiveMeshesEvaluationTime;
  60498. private _activeMeshesEvaluationTime;
  60499. private _captureRenderTargetsRenderTime;
  60500. private _renderTargetsRenderTime;
  60501. private _captureFrameTime;
  60502. private _frameTime;
  60503. private _captureRenderTime;
  60504. private _renderTime;
  60505. private _captureInterFrameTime;
  60506. private _interFrameTime;
  60507. private _captureParticlesRenderTime;
  60508. private _particlesRenderTime;
  60509. private _captureSpritesRenderTime;
  60510. private _spritesRenderTime;
  60511. private _capturePhysicsTime;
  60512. private _physicsTime;
  60513. private _captureAnimationsTime;
  60514. private _animationsTime;
  60515. private _captureCameraRenderTime;
  60516. private _cameraRenderTime;
  60517. private _onBeforeActiveMeshesEvaluationObserver;
  60518. private _onAfterActiveMeshesEvaluationObserver;
  60519. private _onBeforeRenderTargetsRenderObserver;
  60520. private _onAfterRenderTargetsRenderObserver;
  60521. private _onAfterRenderObserver;
  60522. private _onBeforeDrawPhaseObserver;
  60523. private _onAfterDrawPhaseObserver;
  60524. private _onBeforeAnimationsObserver;
  60525. private _onBeforeParticlesRenderingObserver;
  60526. private _onAfterParticlesRenderingObserver;
  60527. private _onBeforeSpritesRenderingObserver;
  60528. private _onAfterSpritesRenderingObserver;
  60529. private _onBeforePhysicsObserver;
  60530. private _onAfterPhysicsObserver;
  60531. private _onAfterAnimationsObserver;
  60532. private _onBeforeCameraRenderObserver;
  60533. private _onAfterCameraRenderObserver;
  60534. /**
  60535. * Gets the perf counter used for active meshes evaluation time
  60536. */
  60537. get activeMeshesEvaluationTimeCounter(): PerfCounter;
  60538. /**
  60539. * Gets the active meshes evaluation time capture status
  60540. */
  60541. get captureActiveMeshesEvaluationTime(): boolean;
  60542. /**
  60543. * Enable or disable the active meshes evaluation time capture
  60544. */
  60545. set captureActiveMeshesEvaluationTime(value: boolean);
  60546. /**
  60547. * Gets the perf counter used for render targets render time
  60548. */
  60549. get renderTargetsRenderTimeCounter(): PerfCounter;
  60550. /**
  60551. * Gets the render targets render time capture status
  60552. */
  60553. get captureRenderTargetsRenderTime(): boolean;
  60554. /**
  60555. * Enable or disable the render targets render time capture
  60556. */
  60557. set captureRenderTargetsRenderTime(value: boolean);
  60558. /**
  60559. * Gets the perf counter used for particles render time
  60560. */
  60561. get particlesRenderTimeCounter(): PerfCounter;
  60562. /**
  60563. * Gets the particles render time capture status
  60564. */
  60565. get captureParticlesRenderTime(): boolean;
  60566. /**
  60567. * Enable or disable the particles render time capture
  60568. */
  60569. set captureParticlesRenderTime(value: boolean);
  60570. /**
  60571. * Gets the perf counter used for sprites render time
  60572. */
  60573. get spritesRenderTimeCounter(): PerfCounter;
  60574. /**
  60575. * Gets the sprites render time capture status
  60576. */
  60577. get captureSpritesRenderTime(): boolean;
  60578. /**
  60579. * Enable or disable the sprites render time capture
  60580. */
  60581. set captureSpritesRenderTime(value: boolean);
  60582. /**
  60583. * Gets the perf counter used for physics time
  60584. */
  60585. get physicsTimeCounter(): PerfCounter;
  60586. /**
  60587. * Gets the physics time capture status
  60588. */
  60589. get capturePhysicsTime(): boolean;
  60590. /**
  60591. * Enable or disable the physics time capture
  60592. */
  60593. set capturePhysicsTime(value: boolean);
  60594. /**
  60595. * Gets the perf counter used for animations time
  60596. */
  60597. get animationsTimeCounter(): PerfCounter;
  60598. /**
  60599. * Gets the animations time capture status
  60600. */
  60601. get captureAnimationsTime(): boolean;
  60602. /**
  60603. * Enable or disable the animations time capture
  60604. */
  60605. set captureAnimationsTime(value: boolean);
  60606. /**
  60607. * Gets the perf counter used for frame time capture
  60608. */
  60609. get frameTimeCounter(): PerfCounter;
  60610. /**
  60611. * Gets the frame time capture status
  60612. */
  60613. get captureFrameTime(): boolean;
  60614. /**
  60615. * Enable or disable the frame time capture
  60616. */
  60617. set captureFrameTime(value: boolean);
  60618. /**
  60619. * Gets the perf counter used for inter-frames time capture
  60620. */
  60621. get interFrameTimeCounter(): PerfCounter;
  60622. /**
  60623. * Gets the inter-frames time capture status
  60624. */
  60625. get captureInterFrameTime(): boolean;
  60626. /**
  60627. * Enable or disable the inter-frames time capture
  60628. */
  60629. set captureInterFrameTime(value: boolean);
  60630. /**
  60631. * Gets the perf counter used for render time capture
  60632. */
  60633. get renderTimeCounter(): PerfCounter;
  60634. /**
  60635. * Gets the render time capture status
  60636. */
  60637. get captureRenderTime(): boolean;
  60638. /**
  60639. * Enable or disable the render time capture
  60640. */
  60641. set captureRenderTime(value: boolean);
  60642. /**
  60643. * Gets the perf counter used for camera render time capture
  60644. */
  60645. get cameraRenderTimeCounter(): PerfCounter;
  60646. /**
  60647. * Gets the camera render time capture status
  60648. */
  60649. get captureCameraRenderTime(): boolean;
  60650. /**
  60651. * Enable or disable the camera render time capture
  60652. */
  60653. set captureCameraRenderTime(value: boolean);
  60654. /**
  60655. * Gets the perf counter used for draw calls
  60656. */
  60657. get drawCallsCounter(): PerfCounter;
  60658. /**
  60659. * Instantiates a new scene instrumentation.
  60660. * This class can be used to get instrumentation data from a Babylon engine
  60661. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  60662. * @param scene Defines the scene to instrument
  60663. */
  60664. constructor(
  60665. /**
  60666. * Defines the scene to instrument
  60667. */
  60668. scene: Scene);
  60669. /**
  60670. * Dispose and release associated resources.
  60671. */
  60672. dispose(): void;
  60673. }
  60674. }
  60675. declare module "babylonjs/Instrumentation/index" {
  60676. export * from "babylonjs/Instrumentation/engineInstrumentation";
  60677. export * from "babylonjs/Instrumentation/sceneInstrumentation";
  60678. export * from "babylonjs/Instrumentation/timeToken";
  60679. }
  60680. declare module "babylonjs/Shaders/glowMapGeneration.fragment" {
  60681. /** @hidden */
  60682. export var glowMapGenerationPixelShader: {
  60683. name: string;
  60684. shader: string;
  60685. };
  60686. }
  60687. declare module "babylonjs/Shaders/glowMapGeneration.vertex" {
  60688. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  60689. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  60690. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  60691. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  60692. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  60693. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  60694. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  60695. /** @hidden */
  60696. export var glowMapGenerationVertexShader: {
  60697. name: string;
  60698. shader: string;
  60699. };
  60700. }
  60701. declare module "babylonjs/Layers/effectLayer" {
  60702. import { Observable } from "babylonjs/Misc/observable";
  60703. import { Nullable } from "babylonjs/types";
  60704. import { Camera } from "babylonjs/Cameras/camera";
  60705. import { Scene } from "babylonjs/scene";
  60706. import { ISize } from "babylonjs/Maths/math.size";
  60707. import { Color4 } from "babylonjs/Maths/math.color";
  60708. import { Engine } from "babylonjs/Engines/engine";
  60709. import { SubMesh } from "babylonjs/Meshes/subMesh";
  60710. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  60711. import { Mesh } from "babylonjs/Meshes/mesh";
  60712. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  60713. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  60714. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  60715. import { Effect } from "babylonjs/Materials/effect";
  60716. import { Material } from "babylonjs/Materials/material";
  60717. import "babylonjs/Shaders/glowMapGeneration.fragment";
  60718. import "babylonjs/Shaders/glowMapGeneration.vertex";
  60719. /**
  60720. * Effect layer options. This helps customizing the behaviour
  60721. * of the effect layer.
  60722. */
  60723. export interface IEffectLayerOptions {
  60724. /**
  60725. * Multiplication factor apply to the canvas size to compute the render target size
  60726. * used to generated the objects (the smaller the faster).
  60727. */
  60728. mainTextureRatio: number;
  60729. /**
  60730. * Enforces a fixed size texture to ensure effect stability across devices.
  60731. */
  60732. mainTextureFixedSize?: number;
  60733. /**
  60734. * Alpha blending mode used to apply the blur. Default depends of the implementation.
  60735. */
  60736. alphaBlendingMode: number;
  60737. /**
  60738. * The camera attached to the layer.
  60739. */
  60740. camera: Nullable<Camera>;
  60741. /**
  60742. * The rendering group to draw the layer in.
  60743. */
  60744. renderingGroupId: number;
  60745. }
  60746. /**
  60747. * The effect layer Helps adding post process effect blended with the main pass.
  60748. *
  60749. * This can be for instance use to generate glow or higlight effects on the scene.
  60750. *
  60751. * The effect layer class can not be used directly and is intented to inherited from to be
  60752. * customized per effects.
  60753. */
  60754. export abstract class EffectLayer {
  60755. private _vertexBuffers;
  60756. private _indexBuffer;
  60757. private _cachedDefines;
  60758. private _effectLayerMapGenerationEffect;
  60759. private _effectLayerOptions;
  60760. private _mergeEffect;
  60761. protected _scene: Scene;
  60762. protected _engine: Engine;
  60763. protected _maxSize: number;
  60764. protected _mainTextureDesiredSize: ISize;
  60765. protected _mainTexture: RenderTargetTexture;
  60766. protected _shouldRender: boolean;
  60767. protected _postProcesses: PostProcess[];
  60768. protected _textures: BaseTexture[];
  60769. protected _emissiveTextureAndColor: {
  60770. texture: Nullable<BaseTexture>;
  60771. color: Color4;
  60772. };
  60773. /**
  60774. * The name of the layer
  60775. */
  60776. name: string;
  60777. /**
  60778. * The clear color of the texture used to generate the glow map.
  60779. */
  60780. neutralColor: Color4;
  60781. /**
  60782. * Specifies whether the highlight layer is enabled or not.
  60783. */
  60784. isEnabled: boolean;
  60785. /**
  60786. * Gets the camera attached to the layer.
  60787. */
  60788. get camera(): Nullable<Camera>;
  60789. /**
  60790. * Gets the rendering group id the layer should render in.
  60791. */
  60792. get renderingGroupId(): number;
  60793. set renderingGroupId(renderingGroupId: number);
  60794. /**
  60795. * An event triggered when the effect layer has been disposed.
  60796. */
  60797. onDisposeObservable: Observable<EffectLayer>;
  60798. /**
  60799. * An event triggered when the effect layer is about rendering the main texture with the glowy parts.
  60800. */
  60801. onBeforeRenderMainTextureObservable: Observable<EffectLayer>;
  60802. /**
  60803. * An event triggered when the generated texture is being merged in the scene.
  60804. */
  60805. onBeforeComposeObservable: Observable<EffectLayer>;
  60806. /**
  60807. * An event triggered when the mesh is rendered into the effect render target.
  60808. */
  60809. onBeforeRenderMeshToEffect: Observable<AbstractMesh>;
  60810. /**
  60811. * An event triggered after the mesh has been rendered into the effect render target.
  60812. */
  60813. onAfterRenderMeshToEffect: Observable<AbstractMesh>;
  60814. /**
  60815. * An event triggered when the generated texture has been merged in the scene.
  60816. */
  60817. onAfterComposeObservable: Observable<EffectLayer>;
  60818. /**
  60819. * An event triggered when the efffect layer changes its size.
  60820. */
  60821. onSizeChangedObservable: Observable<EffectLayer>;
  60822. /** @hidden */
  60823. static _SceneComponentInitialization: (scene: Scene) => void;
  60824. /**
  60825. * Instantiates a new effect Layer and references it in the scene.
  60826. * @param name The name of the layer
  60827. * @param scene The scene to use the layer in
  60828. */
  60829. constructor(
  60830. /** The Friendly of the effect in the scene */
  60831. name: string, scene: Scene);
  60832. /**
  60833. * Get the effect name of the layer.
  60834. * @return The effect name
  60835. */
  60836. abstract getEffectName(): string;
  60837. /**
  60838. * Checks for the readiness of the element composing the layer.
  60839. * @param subMesh the mesh to check for
  60840. * @param useInstances specify whether or not to use instances to render the mesh
  60841. * @return true if ready otherwise, false
  60842. */
  60843. abstract isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  60844. /**
  60845. * Returns whether or nood the layer needs stencil enabled during the mesh rendering.
  60846. * @returns true if the effect requires stencil during the main canvas render pass.
  60847. */
  60848. abstract needStencil(): boolean;
  60849. /**
  60850. * Create the merge effect. This is the shader use to blit the information back
  60851. * to the main canvas at the end of the scene rendering.
  60852. * @returns The effect containing the shader used to merge the effect on the main canvas
  60853. */
  60854. protected abstract _createMergeEffect(): Effect;
  60855. /**
  60856. * Creates the render target textures and post processes used in the effect layer.
  60857. */
  60858. protected abstract _createTextureAndPostProcesses(): void;
  60859. /**
  60860. * Implementation specific of rendering the generating effect on the main canvas.
  60861. * @param effect The effect used to render through
  60862. */
  60863. protected abstract _internalRender(effect: Effect): void;
  60864. /**
  60865. * Sets the required values for both the emissive texture and and the main color.
  60866. */
  60867. protected abstract _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  60868. /**
  60869. * Free any resources and references associated to a mesh.
  60870. * Internal use
  60871. * @param mesh The mesh to free.
  60872. */
  60873. abstract _disposeMesh(mesh: Mesh): void;
  60874. /**
  60875. * Serializes this layer (Glow or Highlight for example)
  60876. * @returns a serialized layer object
  60877. */
  60878. abstract serialize?(): any;
  60879. /**
  60880. * Initializes the effect layer with the required options.
  60881. * @param options Sets of none mandatory options to use with the layer (see IEffectLayerOptions for more information)
  60882. */
  60883. protected _init(options: Partial<IEffectLayerOptions>): void;
  60884. /**
  60885. * Generates the index buffer of the full screen quad blending to the main canvas.
  60886. */
  60887. private _generateIndexBuffer;
  60888. /**
  60889. * Generates the vertex buffer of the full screen quad blending to the main canvas.
  60890. */
  60891. private _generateVertexBuffer;
  60892. /**
  60893. * Sets the main texture desired size which is the closest power of two
  60894. * of the engine canvas size.
  60895. */
  60896. private _setMainTextureSize;
  60897. /**
  60898. * Creates the main texture for the effect layer.
  60899. */
  60900. protected _createMainTexture(): void;
  60901. /**
  60902. * Adds specific effects defines.
  60903. * @param defines The defines to add specifics to.
  60904. */
  60905. protected _addCustomEffectDefines(defines: string[]): void;
  60906. /**
  60907. * Checks for the readiness of the element composing the layer.
  60908. * @param subMesh the mesh to check for
  60909. * @param useInstances specify whether or not to use instances to render the mesh
  60910. * @param emissiveTexture the associated emissive texture used to generate the glow
  60911. * @return true if ready otherwise, false
  60912. */
  60913. protected _isReady(subMesh: SubMesh, useInstances: boolean, emissiveTexture: Nullable<BaseTexture>): boolean;
  60914. /**
  60915. * Renders the glowing part of the scene by blending the blurred glowing meshes on top of the rendered scene.
  60916. */
  60917. render(): void;
  60918. /**
  60919. * Determine if a given mesh will be used in the current effect.
  60920. * @param mesh mesh to test
  60921. * @returns true if the mesh will be used
  60922. */
  60923. hasMesh(mesh: AbstractMesh): boolean;
  60924. /**
  60925. * Returns true if the layer contains information to display, otherwise false.
  60926. * @returns true if the glow layer should be rendered
  60927. */
  60928. shouldRender(): boolean;
  60929. /**
  60930. * Returns true if the mesh should render, otherwise false.
  60931. * @param mesh The mesh to render
  60932. * @returns true if it should render otherwise false
  60933. */
  60934. protected _shouldRenderMesh(mesh: AbstractMesh): boolean;
  60935. /**
  60936. * Returns true if the mesh can be rendered, otherwise false.
  60937. * @param mesh The mesh to render
  60938. * @param material The material used on the mesh
  60939. * @returns true if it can be rendered otherwise false
  60940. */
  60941. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  60942. /**
  60943. * Returns true if the mesh should render, otherwise false.
  60944. * @param mesh The mesh to render
  60945. * @returns true if it should render otherwise false
  60946. */
  60947. protected _shouldRenderEmissiveTextureForMesh(): boolean;
  60948. /**
  60949. * Renders the submesh passed in parameter to the generation map.
  60950. */
  60951. protected _renderSubMesh(subMesh: SubMesh, enableAlphaMode?: boolean): void;
  60952. /**
  60953. * Defines whether the current material of the mesh should be use to render the effect.
  60954. * @param mesh defines the current mesh to render
  60955. */
  60956. protected _useMeshMaterial(mesh: AbstractMesh): boolean;
  60957. /**
  60958. * Rebuild the required buffers.
  60959. * @hidden Internal use only.
  60960. */
  60961. _rebuild(): void;
  60962. /**
  60963. * Dispose only the render target textures and post process.
  60964. */
  60965. private _disposeTextureAndPostProcesses;
  60966. /**
  60967. * Dispose the highlight layer and free resources.
  60968. */
  60969. dispose(): void;
  60970. /**
  60971. * Gets the class name of the effect layer
  60972. * @returns the string with the class name of the effect layer
  60973. */
  60974. getClassName(): string;
  60975. /**
  60976. * Creates an effect layer from parsed effect layer data
  60977. * @param parsedEffectLayer defines effect layer data
  60978. * @param scene defines the current scene
  60979. * @param rootUrl defines the root URL containing the effect layer information
  60980. * @returns a parsed effect Layer
  60981. */
  60982. static Parse(parsedEffectLayer: any, scene: Scene, rootUrl: string): EffectLayer;
  60983. }
  60984. }
  60985. declare module "babylonjs/Layers/effectLayerSceneComponent" {
  60986. import { Scene } from "babylonjs/scene";
  60987. import { ISceneSerializableComponent } from "babylonjs/sceneComponent";
  60988. import { EffectLayer } from "babylonjs/Layers/effectLayer";
  60989. import { AbstractScene } from "babylonjs/abstractScene";
  60990. module "babylonjs/abstractScene" {
  60991. interface AbstractScene {
  60992. /**
  60993. * The list of effect layers (highlights/glow) added to the scene
  60994. * @see https://doc.babylonjs.com/how_to/highlight_layer
  60995. * @see https://doc.babylonjs.com/how_to/glow_layer
  60996. */
  60997. effectLayers: Array<EffectLayer>;
  60998. /**
  60999. * Removes the given effect layer from this scene.
  61000. * @param toRemove defines the effect layer to remove
  61001. * @returns the index of the removed effect layer
  61002. */
  61003. removeEffectLayer(toRemove: EffectLayer): number;
  61004. /**
  61005. * Adds the given effect layer to this scene
  61006. * @param newEffectLayer defines the effect layer to add
  61007. */
  61008. addEffectLayer(newEffectLayer: EffectLayer): void;
  61009. }
  61010. }
  61011. /**
  61012. * Defines the layer scene component responsible to manage any effect layers
  61013. * in a given scene.
  61014. */
  61015. export class EffectLayerSceneComponent implements ISceneSerializableComponent {
  61016. /**
  61017. * The component name helpfull to identify the component in the list of scene components.
  61018. */
  61019. readonly name: string;
  61020. /**
  61021. * The scene the component belongs to.
  61022. */
  61023. scene: Scene;
  61024. private _engine;
  61025. private _renderEffects;
  61026. private _needStencil;
  61027. private _previousStencilState;
  61028. /**
  61029. * Creates a new instance of the component for the given scene
  61030. * @param scene Defines the scene to register the component in
  61031. */
  61032. constructor(scene: Scene);
  61033. /**
  61034. * Registers the component in a given scene
  61035. */
  61036. register(): void;
  61037. /**
  61038. * Rebuilds the elements related to this component in case of
  61039. * context lost for instance.
  61040. */
  61041. rebuild(): void;
  61042. /**
  61043. * Serializes the component data to the specified json object
  61044. * @param serializationObject The object to serialize to
  61045. */
  61046. serialize(serializationObject: any): void;
  61047. /**
  61048. * Adds all the elements from the container to the scene
  61049. * @param container the container holding the elements
  61050. */
  61051. addFromContainer(container: AbstractScene): void;
  61052. /**
  61053. * Removes all the elements in the container from the scene
  61054. * @param container contains the elements to remove
  61055. * @param dispose if the removed element should be disposed (default: false)
  61056. */
  61057. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  61058. /**
  61059. * Disposes the component and the associated ressources.
  61060. */
  61061. dispose(): void;
  61062. private _isReadyForMesh;
  61063. private _renderMainTexture;
  61064. private _setStencil;
  61065. private _setStencilBack;
  61066. private _draw;
  61067. private _drawCamera;
  61068. private _drawRenderingGroup;
  61069. }
  61070. }
  61071. declare module "babylonjs/Shaders/glowMapMerge.fragment" {
  61072. /** @hidden */
  61073. export var glowMapMergePixelShader: {
  61074. name: string;
  61075. shader: string;
  61076. };
  61077. }
  61078. declare module "babylonjs/Shaders/glowMapMerge.vertex" {
  61079. /** @hidden */
  61080. export var glowMapMergeVertexShader: {
  61081. name: string;
  61082. shader: string;
  61083. };
  61084. }
  61085. declare module "babylonjs/Layers/glowLayer" {
  61086. import { Nullable } from "babylonjs/types";
  61087. import { Camera } from "babylonjs/Cameras/camera";
  61088. import { Scene } from "babylonjs/scene";
  61089. import { SubMesh } from "babylonjs/Meshes/subMesh";
  61090. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  61091. import { Mesh } from "babylonjs/Meshes/mesh";
  61092. import { Texture } from "babylonjs/Materials/Textures/texture";
  61093. import { Effect } from "babylonjs/Materials/effect";
  61094. import { Material } from "babylonjs/Materials/material";
  61095. import { EffectLayer } from "babylonjs/Layers/effectLayer";
  61096. import { Color4 } from "babylonjs/Maths/math.color";
  61097. import "babylonjs/Shaders/glowMapMerge.fragment";
  61098. import "babylonjs/Shaders/glowMapMerge.vertex";
  61099. import "babylonjs/Layers/effectLayerSceneComponent";
  61100. module "babylonjs/abstractScene" {
  61101. interface AbstractScene {
  61102. /**
  61103. * Return a the first highlight layer of the scene with a given name.
  61104. * @param name The name of the highlight layer to look for.
  61105. * @return The highlight layer if found otherwise null.
  61106. */
  61107. getGlowLayerByName(name: string): Nullable<GlowLayer>;
  61108. }
  61109. }
  61110. /**
  61111. * Glow layer options. This helps customizing the behaviour
  61112. * of the glow layer.
  61113. */
  61114. export interface IGlowLayerOptions {
  61115. /**
  61116. * Multiplication factor apply to the canvas size to compute the render target size
  61117. * used to generated the glowing objects (the smaller the faster).
  61118. */
  61119. mainTextureRatio: number;
  61120. /**
  61121. * Enforces a fixed size texture to ensure resize independant blur.
  61122. */
  61123. mainTextureFixedSize?: number;
  61124. /**
  61125. * How big is the kernel of the blur texture.
  61126. */
  61127. blurKernelSize: number;
  61128. /**
  61129. * The camera attached to the layer.
  61130. */
  61131. camera: Nullable<Camera>;
  61132. /**
  61133. * Enable MSAA by chosing the number of samples.
  61134. */
  61135. mainTextureSamples?: number;
  61136. /**
  61137. * The rendering group to draw the layer in.
  61138. */
  61139. renderingGroupId: number;
  61140. }
  61141. /**
  61142. * The glow layer Helps adding a glow effect around the emissive parts of a mesh.
  61143. *
  61144. * Once instantiated in a scene, by default, all the emissive meshes will glow.
  61145. *
  61146. * Documentation: https://doc.babylonjs.com/how_to/glow_layer
  61147. */
  61148. export class GlowLayer extends EffectLayer {
  61149. /**
  61150. * Effect Name of the layer.
  61151. */
  61152. static readonly EffectName: string;
  61153. /**
  61154. * The default blur kernel size used for the glow.
  61155. */
  61156. static DefaultBlurKernelSize: number;
  61157. /**
  61158. * The default texture size ratio used for the glow.
  61159. */
  61160. static DefaultTextureRatio: number;
  61161. /**
  61162. * Sets the kernel size of the blur.
  61163. */
  61164. set blurKernelSize(value: number);
  61165. /**
  61166. * Gets the kernel size of the blur.
  61167. */
  61168. get blurKernelSize(): number;
  61169. /**
  61170. * Sets the glow intensity.
  61171. */
  61172. set intensity(value: number);
  61173. /**
  61174. * Gets the glow intensity.
  61175. */
  61176. get intensity(): number;
  61177. private _options;
  61178. private _intensity;
  61179. private _horizontalBlurPostprocess1;
  61180. private _verticalBlurPostprocess1;
  61181. private _horizontalBlurPostprocess2;
  61182. private _verticalBlurPostprocess2;
  61183. private _blurTexture1;
  61184. private _blurTexture2;
  61185. private _postProcesses1;
  61186. private _postProcesses2;
  61187. private _includedOnlyMeshes;
  61188. private _excludedMeshes;
  61189. private _meshesUsingTheirOwnMaterials;
  61190. /**
  61191. * Callback used to let the user override the color selection on a per mesh basis
  61192. */
  61193. customEmissiveColorSelector: (mesh: Mesh, subMesh: SubMesh, material: Material, result: Color4) => void;
  61194. /**
  61195. * Callback used to let the user override the texture selection on a per mesh basis
  61196. */
  61197. customEmissiveTextureSelector: (mesh: Mesh, subMesh: SubMesh, material: Material) => Texture;
  61198. /**
  61199. * Instantiates a new glow Layer and references it to the scene.
  61200. * @param name The name of the layer
  61201. * @param scene The scene to use the layer in
  61202. * @param options Sets of none mandatory options to use with the layer (see IGlowLayerOptions for more information)
  61203. */
  61204. constructor(name: string, scene: Scene, options?: Partial<IGlowLayerOptions>);
  61205. /**
  61206. * Get the effect name of the layer.
  61207. * @return The effect name
  61208. */
  61209. getEffectName(): string;
  61210. /**
  61211. * Create the merge effect. This is the shader use to blit the information back
  61212. * to the main canvas at the end of the scene rendering.
  61213. */
  61214. protected _createMergeEffect(): Effect;
  61215. /**
  61216. * Creates the render target textures and post processes used in the glow layer.
  61217. */
  61218. protected _createTextureAndPostProcesses(): void;
  61219. /**
  61220. * Checks for the readiness of the element composing the layer.
  61221. * @param subMesh the mesh to check for
  61222. * @param useInstances specify wether or not to use instances to render the mesh
  61223. * @param emissiveTexture the associated emissive texture used to generate the glow
  61224. * @return true if ready otherwise, false
  61225. */
  61226. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  61227. /**
  61228. * Returns whether or nood the layer needs stencil enabled during the mesh rendering.
  61229. */
  61230. needStencil(): boolean;
  61231. /**
  61232. * Returns true if the mesh can be rendered, otherwise false.
  61233. * @param mesh The mesh to render
  61234. * @param material The material used on the mesh
  61235. * @returns true if it can be rendered otherwise false
  61236. */
  61237. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  61238. /**
  61239. * Implementation specific of rendering the generating effect on the main canvas.
  61240. * @param effect The effect used to render through
  61241. */
  61242. protected _internalRender(effect: Effect): void;
  61243. /**
  61244. * Sets the required values for both the emissive texture and and the main color.
  61245. */
  61246. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  61247. /**
  61248. * Returns true if the mesh should render, otherwise false.
  61249. * @param mesh The mesh to render
  61250. * @returns true if it should render otherwise false
  61251. */
  61252. protected _shouldRenderMesh(mesh: Mesh): boolean;
  61253. /**
  61254. * Adds specific effects defines.
  61255. * @param defines The defines to add specifics to.
  61256. */
  61257. protected _addCustomEffectDefines(defines: string[]): void;
  61258. /**
  61259. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the glow layer.
  61260. * @param mesh The mesh to exclude from the glow layer
  61261. */
  61262. addExcludedMesh(mesh: Mesh): void;
  61263. /**
  61264. * Remove a mesh from the exclusion list to let it impact or being impacted by the glow layer.
  61265. * @param mesh The mesh to remove
  61266. */
  61267. removeExcludedMesh(mesh: Mesh): void;
  61268. /**
  61269. * Add a mesh in the inclusion list to impact or being impacted by the glow layer.
  61270. * @param mesh The mesh to include in the glow layer
  61271. */
  61272. addIncludedOnlyMesh(mesh: Mesh): void;
  61273. /**
  61274. * Remove a mesh from the Inclusion list to prevent it to impact or being impacted by the glow layer.
  61275. * @param mesh The mesh to remove
  61276. */
  61277. removeIncludedOnlyMesh(mesh: Mesh): void;
  61278. /**
  61279. * Determine if a given mesh will be used in the glow layer
  61280. * @param mesh The mesh to test
  61281. * @returns true if the mesh will be highlighted by the current glow layer
  61282. */
  61283. hasMesh(mesh: AbstractMesh): boolean;
  61284. /**
  61285. * Defines whether the current material of the mesh should be use to render the effect.
  61286. * @param mesh defines the current mesh to render
  61287. */
  61288. protected _useMeshMaterial(mesh: AbstractMesh): boolean;
  61289. /**
  61290. * Add a mesh to be rendered through its own material and not with emissive only.
  61291. * @param mesh The mesh for which we need to use its material
  61292. */
  61293. referenceMeshToUseItsOwnMaterial(mesh: AbstractMesh): void;
  61294. /**
  61295. * Remove a mesh from being rendered through its own material and not with emissive only.
  61296. * @param mesh The mesh for which we need to not use its material
  61297. */
  61298. unReferenceMeshFromUsingItsOwnMaterial(mesh: AbstractMesh): void;
  61299. /**
  61300. * Free any resources and references associated to a mesh.
  61301. * Internal use
  61302. * @param mesh The mesh to free.
  61303. * @hidden
  61304. */
  61305. _disposeMesh(mesh: Mesh): void;
  61306. /**
  61307. * Gets the class name of the effect layer
  61308. * @returns the string with the class name of the effect layer
  61309. */
  61310. getClassName(): string;
  61311. /**
  61312. * Serializes this glow layer
  61313. * @returns a serialized glow layer object
  61314. */
  61315. serialize(): any;
  61316. /**
  61317. * Creates a Glow Layer from parsed glow layer data
  61318. * @param parsedGlowLayer defines glow layer data
  61319. * @param scene defines the current scene
  61320. * @param rootUrl defines the root URL containing the glow layer information
  61321. * @returns a parsed Glow Layer
  61322. */
  61323. static Parse(parsedGlowLayer: any, scene: Scene, rootUrl: string): GlowLayer;
  61324. }
  61325. }
  61326. declare module "babylonjs/Shaders/glowBlurPostProcess.fragment" {
  61327. /** @hidden */
  61328. export var glowBlurPostProcessPixelShader: {
  61329. name: string;
  61330. shader: string;
  61331. };
  61332. }
  61333. declare module "babylonjs/Layers/highlightLayer" {
  61334. import { Observable } from "babylonjs/Misc/observable";
  61335. import { Nullable } from "babylonjs/types";
  61336. import { Camera } from "babylonjs/Cameras/camera";
  61337. import { Scene } from "babylonjs/scene";
  61338. import { SubMesh } from "babylonjs/Meshes/subMesh";
  61339. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  61340. import { Mesh } from "babylonjs/Meshes/mesh";
  61341. import { Effect } from "babylonjs/Materials/effect";
  61342. import { Material } from "babylonjs/Materials/material";
  61343. import { EffectLayer } from "babylonjs/Layers/effectLayer";
  61344. import { Color4, Color3 } from "babylonjs/Maths/math.color";
  61345. import "babylonjs/Shaders/glowMapMerge.fragment";
  61346. import "babylonjs/Shaders/glowMapMerge.vertex";
  61347. import "babylonjs/Shaders/glowBlurPostProcess.fragment";
  61348. module "babylonjs/abstractScene" {
  61349. interface AbstractScene {
  61350. /**
  61351. * Return a the first highlight layer of the scene with a given name.
  61352. * @param name The name of the highlight layer to look for.
  61353. * @return The highlight layer if found otherwise null.
  61354. */
  61355. getHighlightLayerByName(name: string): Nullable<HighlightLayer>;
  61356. }
  61357. }
  61358. /**
  61359. * Highlight layer options. This helps customizing the behaviour
  61360. * of the highlight layer.
  61361. */
  61362. export interface IHighlightLayerOptions {
  61363. /**
  61364. * Multiplication factor apply to the canvas size to compute the render target size
  61365. * used to generated the glowing objects (the smaller the faster).
  61366. */
  61367. mainTextureRatio: number;
  61368. /**
  61369. * Enforces a fixed size texture to ensure resize independant blur.
  61370. */
  61371. mainTextureFixedSize?: number;
  61372. /**
  61373. * Multiplication factor apply to the main texture size in the first step of the blur to reduce the size
  61374. * of the picture to blur (the smaller the faster).
  61375. */
  61376. blurTextureSizeRatio: number;
  61377. /**
  61378. * How big in texel of the blur texture is the vertical blur.
  61379. */
  61380. blurVerticalSize: number;
  61381. /**
  61382. * How big in texel of the blur texture is the horizontal blur.
  61383. */
  61384. blurHorizontalSize: number;
  61385. /**
  61386. * Alpha blending mode used to apply the blur. Default is combine.
  61387. */
  61388. alphaBlendingMode: number;
  61389. /**
  61390. * The camera attached to the layer.
  61391. */
  61392. camera: Nullable<Camera>;
  61393. /**
  61394. * Should we display highlight as a solid stroke?
  61395. */
  61396. isStroke?: boolean;
  61397. /**
  61398. * The rendering group to draw the layer in.
  61399. */
  61400. renderingGroupId: number;
  61401. }
  61402. /**
  61403. * The highlight layer Helps adding a glow effect around a mesh.
  61404. *
  61405. * Once instantiated in a scene, simply use the addMesh or removeMesh method to add or remove
  61406. * glowy meshes to your scene.
  61407. *
  61408. * !!! THIS REQUIRES AN ACTIVE STENCIL BUFFER ON THE CANVAS !!!
  61409. */
  61410. export class HighlightLayer extends EffectLayer {
  61411. name: string;
  61412. /**
  61413. * Effect Name of the highlight layer.
  61414. */
  61415. static readonly EffectName: string;
  61416. /**
  61417. * The neutral color used during the preparation of the glow effect.
  61418. * This is black by default as the blend operation is a blend operation.
  61419. */
  61420. static NeutralColor: Color4;
  61421. /**
  61422. * Stencil value used for glowing meshes.
  61423. */
  61424. static GlowingMeshStencilReference: number;
  61425. /**
  61426. * Stencil value used for the other meshes in the scene.
  61427. */
  61428. static NormalMeshStencilReference: number;
  61429. /**
  61430. * Specifies whether or not the inner glow is ACTIVE in the layer.
  61431. */
  61432. innerGlow: boolean;
  61433. /**
  61434. * Specifies whether or not the outer glow is ACTIVE in the layer.
  61435. */
  61436. outerGlow: boolean;
  61437. /**
  61438. * Specifies the horizontal size of the blur.
  61439. */
  61440. set blurHorizontalSize(value: number);
  61441. /**
  61442. * Specifies the vertical size of the blur.
  61443. */
  61444. set blurVerticalSize(value: number);
  61445. /**
  61446. * Gets the horizontal size of the blur.
  61447. */
  61448. get blurHorizontalSize(): number;
  61449. /**
  61450. * Gets the vertical size of the blur.
  61451. */
  61452. get blurVerticalSize(): number;
  61453. /**
  61454. * An event triggered when the highlight layer is being blurred.
  61455. */
  61456. onBeforeBlurObservable: Observable<HighlightLayer>;
  61457. /**
  61458. * An event triggered when the highlight layer has been blurred.
  61459. */
  61460. onAfterBlurObservable: Observable<HighlightLayer>;
  61461. private _instanceGlowingMeshStencilReference;
  61462. private _options;
  61463. private _downSamplePostprocess;
  61464. private _horizontalBlurPostprocess;
  61465. private _verticalBlurPostprocess;
  61466. private _blurTexture;
  61467. private _meshes;
  61468. private _excludedMeshes;
  61469. /**
  61470. * Instantiates a new highlight Layer and references it to the scene..
  61471. * @param name The name of the layer
  61472. * @param scene The scene to use the layer in
  61473. * @param options Sets of none mandatory options to use with the layer (see IHighlightLayerOptions for more information)
  61474. */
  61475. constructor(name: string, scene: Scene, options?: Partial<IHighlightLayerOptions>);
  61476. /**
  61477. * Get the effect name of the layer.
  61478. * @return The effect name
  61479. */
  61480. getEffectName(): string;
  61481. /**
  61482. * Create the merge effect. This is the shader use to blit the information back
  61483. * to the main canvas at the end of the scene rendering.
  61484. */
  61485. protected _createMergeEffect(): Effect;
  61486. /**
  61487. * Creates the render target textures and post processes used in the highlight layer.
  61488. */
  61489. protected _createTextureAndPostProcesses(): void;
  61490. /**
  61491. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  61492. */
  61493. needStencil(): boolean;
  61494. /**
  61495. * Checks for the readiness of the element composing the layer.
  61496. * @param subMesh the mesh to check for
  61497. * @param useInstances specify wether or not to use instances to render the mesh
  61498. * @param emissiveTexture the associated emissive texture used to generate the glow
  61499. * @return true if ready otherwise, false
  61500. */
  61501. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  61502. /**
  61503. * Implementation specific of rendering the generating effect on the main canvas.
  61504. * @param effect The effect used to render through
  61505. */
  61506. protected _internalRender(effect: Effect): void;
  61507. /**
  61508. * Returns true if the layer contains information to display, otherwise false.
  61509. */
  61510. shouldRender(): boolean;
  61511. /**
  61512. * Returns true if the mesh should render, otherwise false.
  61513. * @param mesh The mesh to render
  61514. * @returns true if it should render otherwise false
  61515. */
  61516. protected _shouldRenderMesh(mesh: Mesh): boolean;
  61517. /**
  61518. * Returns true if the mesh can be rendered, otherwise false.
  61519. * @param mesh The mesh to render
  61520. * @param material The material used on the mesh
  61521. * @returns true if it can be rendered otherwise false
  61522. */
  61523. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  61524. /**
  61525. * Adds specific effects defines.
  61526. * @param defines The defines to add specifics to.
  61527. */
  61528. protected _addCustomEffectDefines(defines: string[]): void;
  61529. /**
  61530. * Sets the required values for both the emissive texture and and the main color.
  61531. */
  61532. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  61533. /**
  61534. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the highlight layer.
  61535. * @param mesh The mesh to exclude from the highlight layer
  61536. */
  61537. addExcludedMesh(mesh: Mesh): void;
  61538. /**
  61539. * Remove a mesh from the exclusion list to let it impact or being impacted by the highlight layer.
  61540. * @param mesh The mesh to highlight
  61541. */
  61542. removeExcludedMesh(mesh: Mesh): void;
  61543. /**
  61544. * Determine if a given mesh will be highlighted by the current HighlightLayer
  61545. * @param mesh mesh to test
  61546. * @returns true if the mesh will be highlighted by the current HighlightLayer
  61547. */
  61548. hasMesh(mesh: AbstractMesh): boolean;
  61549. /**
  61550. * Add a mesh in the highlight layer in order to make it glow with the chosen color.
  61551. * @param mesh The mesh to highlight
  61552. * @param color The color of the highlight
  61553. * @param glowEmissiveOnly Extract the glow from the emissive texture
  61554. */
  61555. addMesh(mesh: Mesh, color: Color3, glowEmissiveOnly?: boolean): void;
  61556. /**
  61557. * Remove a mesh from the highlight layer in order to make it stop glowing.
  61558. * @param mesh The mesh to highlight
  61559. */
  61560. removeMesh(mesh: Mesh): void;
  61561. /**
  61562. * Remove all the meshes currently referenced in the highlight layer
  61563. */
  61564. removeAllMeshes(): void;
  61565. /**
  61566. * Force the stencil to the normal expected value for none glowing parts
  61567. */
  61568. private _defaultStencilReference;
  61569. /**
  61570. * Free any resources and references associated to a mesh.
  61571. * Internal use
  61572. * @param mesh The mesh to free.
  61573. * @hidden
  61574. */
  61575. _disposeMesh(mesh: Mesh): void;
  61576. /**
  61577. * Dispose the highlight layer and free resources.
  61578. */
  61579. dispose(): void;
  61580. /**
  61581. * Gets the class name of the effect layer
  61582. * @returns the string with the class name of the effect layer
  61583. */
  61584. getClassName(): string;
  61585. /**
  61586. * Serializes this Highlight layer
  61587. * @returns a serialized Highlight layer object
  61588. */
  61589. serialize(): any;
  61590. /**
  61591. * Creates a Highlight layer from parsed Highlight layer data
  61592. * @param parsedHightlightLayer defines the Highlight layer data
  61593. * @param scene defines the current scene
  61594. * @param rootUrl defines the root URL containing the Highlight layer information
  61595. * @returns a parsed Highlight layer
  61596. */
  61597. static Parse(parsedHightlightLayer: any, scene: Scene, rootUrl: string): HighlightLayer;
  61598. }
  61599. }
  61600. declare module "babylonjs/Layers/layerSceneComponent" {
  61601. import { Scene } from "babylonjs/scene";
  61602. import { ISceneComponent } from "babylonjs/sceneComponent";
  61603. import { Layer } from "babylonjs/Layers/layer";
  61604. import { AbstractScene } from "babylonjs/abstractScene";
  61605. module "babylonjs/abstractScene" {
  61606. interface AbstractScene {
  61607. /**
  61608. * The list of layers (background and foreground) of the scene
  61609. */
  61610. layers: Array<Layer>;
  61611. }
  61612. }
  61613. /**
  61614. * Defines the layer scene component responsible to manage any layers
  61615. * in a given scene.
  61616. */
  61617. export class LayerSceneComponent implements ISceneComponent {
  61618. /**
  61619. * The component name helpfull to identify the component in the list of scene components.
  61620. */
  61621. readonly name: string;
  61622. /**
  61623. * The scene the component belongs to.
  61624. */
  61625. scene: Scene;
  61626. private _engine;
  61627. /**
  61628. * Creates a new instance of the component for the given scene
  61629. * @param scene Defines the scene to register the component in
  61630. */
  61631. constructor(scene: Scene);
  61632. /**
  61633. * Registers the component in a given scene
  61634. */
  61635. register(): void;
  61636. /**
  61637. * Rebuilds the elements related to this component in case of
  61638. * context lost for instance.
  61639. */
  61640. rebuild(): void;
  61641. /**
  61642. * Disposes the component and the associated ressources.
  61643. */
  61644. dispose(): void;
  61645. private _draw;
  61646. private _drawCameraPredicate;
  61647. private _drawCameraBackground;
  61648. private _drawCameraForeground;
  61649. private _drawRenderTargetPredicate;
  61650. private _drawRenderTargetBackground;
  61651. private _drawRenderTargetForeground;
  61652. /**
  61653. * Adds all the elements from the container to the scene
  61654. * @param container the container holding the elements
  61655. */
  61656. addFromContainer(container: AbstractScene): void;
  61657. /**
  61658. * Removes all the elements in the container from the scene
  61659. * @param container contains the elements to remove
  61660. * @param dispose if the removed element should be disposed (default: false)
  61661. */
  61662. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  61663. }
  61664. }
  61665. declare module "babylonjs/Shaders/layer.fragment" {
  61666. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  61667. /** @hidden */
  61668. export var layerPixelShader: {
  61669. name: string;
  61670. shader: string;
  61671. };
  61672. }
  61673. declare module "babylonjs/Shaders/layer.vertex" {
  61674. /** @hidden */
  61675. export var layerVertexShader: {
  61676. name: string;
  61677. shader: string;
  61678. };
  61679. }
  61680. declare module "babylonjs/Layers/layer" {
  61681. import { Observable } from "babylonjs/Misc/observable";
  61682. import { Nullable } from "babylonjs/types";
  61683. import { Scene } from "babylonjs/scene";
  61684. import { Vector2 } from "babylonjs/Maths/math.vector";
  61685. import { Color4 } from "babylonjs/Maths/math.color";
  61686. import { Texture } from "babylonjs/Materials/Textures/texture";
  61687. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  61688. import "babylonjs/Shaders/layer.fragment";
  61689. import "babylonjs/Shaders/layer.vertex";
  61690. /**
  61691. * This represents a full screen 2d layer.
  61692. * This can be useful to display a picture in the background of your scene for instance.
  61693. * @see https://www.babylonjs-playground.com/#08A2BS#1
  61694. */
  61695. export class Layer {
  61696. /**
  61697. * Define the name of the layer.
  61698. */
  61699. name: string;
  61700. /**
  61701. * Define the texture the layer should display.
  61702. */
  61703. texture: Nullable<Texture>;
  61704. /**
  61705. * Is the layer in background or foreground.
  61706. */
  61707. isBackground: boolean;
  61708. /**
  61709. * Define the color of the layer (instead of texture).
  61710. */
  61711. color: Color4;
  61712. /**
  61713. * Define the scale of the layer in order to zoom in out of the texture.
  61714. */
  61715. scale: Vector2;
  61716. /**
  61717. * Define an offset for the layer in order to shift the texture.
  61718. */
  61719. offset: Vector2;
  61720. /**
  61721. * Define the alpha blending mode used in the layer in case the texture or color has an alpha.
  61722. */
  61723. alphaBlendingMode: number;
  61724. /**
  61725. * Define if the layer should alpha test or alpha blend with the rest of the scene.
  61726. * Alpha test will not mix with the background color in case of transparency.
  61727. * It will either use the texture color or the background depending on the alpha value of the current pixel.
  61728. */
  61729. alphaTest: boolean;
  61730. /**
  61731. * Define a mask to restrict the layer to only some of the scene cameras.
  61732. */
  61733. layerMask: number;
  61734. /**
  61735. * Define the list of render target the layer is visible into.
  61736. */
  61737. renderTargetTextures: RenderTargetTexture[];
  61738. /**
  61739. * Define if the layer is only used in renderTarget or if it also
  61740. * renders in the main frame buffer of the canvas.
  61741. */
  61742. renderOnlyInRenderTargetTextures: boolean;
  61743. private _scene;
  61744. private _vertexBuffers;
  61745. private _indexBuffer;
  61746. private _effect;
  61747. private _previousDefines;
  61748. /**
  61749. * An event triggered when the layer is disposed.
  61750. */
  61751. onDisposeObservable: Observable<Layer>;
  61752. private _onDisposeObserver;
  61753. /**
  61754. * Back compatibility with callback before the onDisposeObservable existed.
  61755. * The set callback will be triggered when the layer has been disposed.
  61756. */
  61757. set onDispose(callback: () => void);
  61758. /**
  61759. * An event triggered before rendering the scene
  61760. */
  61761. onBeforeRenderObservable: Observable<Layer>;
  61762. private _onBeforeRenderObserver;
  61763. /**
  61764. * Back compatibility with callback before the onBeforeRenderObservable existed.
  61765. * The set callback will be triggered just before rendering the layer.
  61766. */
  61767. set onBeforeRender(callback: () => void);
  61768. /**
  61769. * An event triggered after rendering the scene
  61770. */
  61771. onAfterRenderObservable: Observable<Layer>;
  61772. private _onAfterRenderObserver;
  61773. /**
  61774. * Back compatibility with callback before the onAfterRenderObservable existed.
  61775. * The set callback will be triggered just after rendering the layer.
  61776. */
  61777. set onAfterRender(callback: () => void);
  61778. /**
  61779. * Instantiates a new layer.
  61780. * This represents a full screen 2d layer.
  61781. * This can be useful to display a picture in the background of your scene for instance.
  61782. * @see https://www.babylonjs-playground.com/#08A2BS#1
  61783. * @param name Define the name of the layer in the scene
  61784. * @param imgUrl Define the url of the texture to display in the layer
  61785. * @param scene Define the scene the layer belongs to
  61786. * @param isBackground Defines whether the layer is displayed in front or behind the scene
  61787. * @param color Defines a color for the layer
  61788. */
  61789. constructor(
  61790. /**
  61791. * Define the name of the layer.
  61792. */
  61793. name: string, imgUrl: Nullable<string>, scene: Nullable<Scene>, isBackground?: boolean, color?: Color4);
  61794. private _createIndexBuffer;
  61795. /** @hidden */
  61796. _rebuild(): void;
  61797. /**
  61798. * Renders the layer in the scene.
  61799. */
  61800. render(): void;
  61801. /**
  61802. * Disposes and releases the associated ressources.
  61803. */
  61804. dispose(): void;
  61805. }
  61806. }
  61807. declare module "babylonjs/Layers/index" {
  61808. export * from "babylonjs/Layers/effectLayer";
  61809. export * from "babylonjs/Layers/effectLayerSceneComponent";
  61810. export * from "babylonjs/Layers/glowLayer";
  61811. export * from "babylonjs/Layers/highlightLayer";
  61812. export * from "babylonjs/Layers/layer";
  61813. export * from "babylonjs/Layers/layerSceneComponent";
  61814. }
  61815. declare module "babylonjs/Shaders/lensFlare.fragment" {
  61816. /** @hidden */
  61817. export var lensFlarePixelShader: {
  61818. name: string;
  61819. shader: string;
  61820. };
  61821. }
  61822. declare module "babylonjs/Shaders/lensFlare.vertex" {
  61823. /** @hidden */
  61824. export var lensFlareVertexShader: {
  61825. name: string;
  61826. shader: string;
  61827. };
  61828. }
  61829. declare module "babylonjs/LensFlares/lensFlareSystem" {
  61830. import { Scene } from "babylonjs/scene";
  61831. import { Vector3 } from "babylonjs/Maths/math.vector";
  61832. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  61833. import { LensFlare } from "babylonjs/LensFlares/lensFlare";
  61834. import "babylonjs/Shaders/lensFlare.fragment";
  61835. import "babylonjs/Shaders/lensFlare.vertex";
  61836. import { Viewport } from "babylonjs/Maths/math.viewport";
  61837. /**
  61838. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  61839. * It is usually composed of several `lensFlare`.
  61840. * @see https://doc.babylonjs.com/how_to/how_to_use_lens_flares
  61841. */
  61842. export class LensFlareSystem {
  61843. /**
  61844. * Define the name of the lens flare system
  61845. */
  61846. name: string;
  61847. /**
  61848. * List of lens flares used in this system.
  61849. */
  61850. lensFlares: LensFlare[];
  61851. /**
  61852. * Define a limit from the border the lens flare can be visible.
  61853. */
  61854. borderLimit: number;
  61855. /**
  61856. * Define a viewport border we do not want to see the lens flare in.
  61857. */
  61858. viewportBorder: number;
  61859. /**
  61860. * Define a predicate which could limit the list of meshes able to occlude the effect.
  61861. */
  61862. meshesSelectionPredicate: (mesh: AbstractMesh) => boolean;
  61863. /**
  61864. * Restricts the rendering of the effect to only the camera rendering this layer mask.
  61865. */
  61866. layerMask: number;
  61867. /**
  61868. * Define the id of the lens flare system in the scene.
  61869. * (equal to name by default)
  61870. */
  61871. id: string;
  61872. private _scene;
  61873. private _emitter;
  61874. private _vertexBuffers;
  61875. private _indexBuffer;
  61876. private _effect;
  61877. private _positionX;
  61878. private _positionY;
  61879. private _isEnabled;
  61880. /** @hidden */
  61881. static _SceneComponentInitialization: (scene: Scene) => void;
  61882. /**
  61883. * Instantiates a lens flare system.
  61884. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  61885. * It is usually composed of several `lensFlare`.
  61886. * @see https://doc.babylonjs.com/how_to/how_to_use_lens_flares
  61887. * @param name Define the name of the lens flare system in the scene
  61888. * @param emitter Define the source (the emitter) of the lens flares (it can be a camera, a light or a mesh).
  61889. * @param scene Define the scene the lens flare system belongs to
  61890. */
  61891. constructor(
  61892. /**
  61893. * Define the name of the lens flare system
  61894. */
  61895. name: string, emitter: any, scene: Scene);
  61896. /**
  61897. * Define if the lens flare system is enabled.
  61898. */
  61899. get isEnabled(): boolean;
  61900. set isEnabled(value: boolean);
  61901. /**
  61902. * Get the scene the effects belongs to.
  61903. * @returns the scene holding the lens flare system
  61904. */
  61905. getScene(): Scene;
  61906. /**
  61907. * Get the emitter of the lens flare system.
  61908. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  61909. * @returns the emitter of the lens flare system
  61910. */
  61911. getEmitter(): any;
  61912. /**
  61913. * Set the emitter of the lens flare system.
  61914. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  61915. * @param newEmitter Define the new emitter of the system
  61916. */
  61917. setEmitter(newEmitter: any): void;
  61918. /**
  61919. * Get the lens flare system emitter position.
  61920. * The emitter defines the source of the lens flares (it can be a camera, a light or a mesh).
  61921. * @returns the position
  61922. */
  61923. getEmitterPosition(): Vector3;
  61924. /**
  61925. * @hidden
  61926. */
  61927. computeEffectivePosition(globalViewport: Viewport): boolean;
  61928. /** @hidden */
  61929. _isVisible(): boolean;
  61930. /**
  61931. * @hidden
  61932. */
  61933. render(): boolean;
  61934. /**
  61935. * Dispose and release the lens flare with its associated resources.
  61936. */
  61937. dispose(): void;
  61938. /**
  61939. * Parse a lens flare system from a JSON repressentation
  61940. * @param parsedLensFlareSystem Define the JSON to parse
  61941. * @param scene Define the scene the parsed system should be instantiated in
  61942. * @param rootUrl Define the rootUrl of the load sequence to easily find a load relative dependencies such as textures
  61943. * @returns the parsed system
  61944. */
  61945. static Parse(parsedLensFlareSystem: any, scene: Scene, rootUrl: string): LensFlareSystem;
  61946. /**
  61947. * Serialize the current Lens Flare System into a JSON representation.
  61948. * @returns the serialized JSON
  61949. */
  61950. serialize(): any;
  61951. }
  61952. }
  61953. declare module "babylonjs/LensFlares/lensFlare" {
  61954. import { Nullable } from "babylonjs/types";
  61955. import { Color3 } from "babylonjs/Maths/math.color";
  61956. import { Texture } from "babylonjs/Materials/Textures/texture";
  61957. import { LensFlareSystem } from "babylonjs/LensFlares/lensFlareSystem";
  61958. /**
  61959. * This represents one of the lens effect in a `lensFlareSystem`.
  61960. * It controls one of the indiviual texture used in the effect.
  61961. * @see https://doc.babylonjs.com/how_to/how_to_use_lens_flares
  61962. */
  61963. export class LensFlare {
  61964. /**
  61965. * Define the size of the lens flare in the system (a floating value between 0 and 1)
  61966. */
  61967. size: number;
  61968. /**
  61969. * 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.
  61970. */
  61971. position: number;
  61972. /**
  61973. * Define the lens color.
  61974. */
  61975. color: Color3;
  61976. /**
  61977. * Define the lens texture.
  61978. */
  61979. texture: Nullable<Texture>;
  61980. /**
  61981. * Define the alpha mode to render this particular lens.
  61982. */
  61983. alphaMode: number;
  61984. private _system;
  61985. /**
  61986. * Creates a new Lens Flare.
  61987. * This represents one of the lens effect in a `lensFlareSystem`.
  61988. * It controls one of the indiviual texture used in the effect.
  61989. * @see https://doc.babylonjs.com/how_to/how_to_use_lens_flares
  61990. * @param size Define the size of the lens flare (a floating value between 0 and 1)
  61991. * @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.
  61992. * @param color Define the lens color
  61993. * @param imgUrl Define the lens texture url
  61994. * @param system Define the `lensFlareSystem` this flare is part of
  61995. * @returns The newly created Lens Flare
  61996. */
  61997. static AddFlare(size: number, position: number, color: Color3, imgUrl: string, system: LensFlareSystem): LensFlare;
  61998. /**
  61999. * Instantiates a new Lens Flare.
  62000. * This represents one of the lens effect in a `lensFlareSystem`.
  62001. * It controls one of the indiviual texture used in the effect.
  62002. * @see https://doc.babylonjs.com/how_to/how_to_use_lens_flares
  62003. * @param size Define the size of the lens flare in the system (a floating value between 0 and 1)
  62004. * @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.
  62005. * @param color Define the lens color
  62006. * @param imgUrl Define the lens texture url
  62007. * @param system Define the `lensFlareSystem` this flare is part of
  62008. */
  62009. constructor(
  62010. /**
  62011. * Define the size of the lens flare in the system (a floating value between 0 and 1)
  62012. */
  62013. size: number,
  62014. /**
  62015. * 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.
  62016. */
  62017. position: number, color: Color3, imgUrl: string, system: LensFlareSystem);
  62018. /**
  62019. * Dispose and release the lens flare with its associated resources.
  62020. */
  62021. dispose(): void;
  62022. }
  62023. }
  62024. declare module "babylonjs/LensFlares/lensFlareSystemSceneComponent" {
  62025. import { Nullable } from "babylonjs/types";
  62026. import { Scene } from "babylonjs/scene";
  62027. import { ISceneSerializableComponent } from "babylonjs/sceneComponent";
  62028. import { AbstractScene } from "babylonjs/abstractScene";
  62029. import { LensFlareSystem } from "babylonjs/LensFlares/lensFlareSystem";
  62030. module "babylonjs/abstractScene" {
  62031. interface AbstractScene {
  62032. /**
  62033. * The list of lens flare system added to the scene
  62034. * @see https://doc.babylonjs.com/how_to/how_to_use_lens_flares
  62035. */
  62036. lensFlareSystems: Array<LensFlareSystem>;
  62037. /**
  62038. * Removes the given lens flare system from this scene.
  62039. * @param toRemove The lens flare system to remove
  62040. * @returns The index of the removed lens flare system
  62041. */
  62042. removeLensFlareSystem(toRemove: LensFlareSystem): number;
  62043. /**
  62044. * Adds the given lens flare system to this scene
  62045. * @param newLensFlareSystem The lens flare system to add
  62046. */
  62047. addLensFlareSystem(newLensFlareSystem: LensFlareSystem): void;
  62048. /**
  62049. * Gets a lens flare system using its name
  62050. * @param name defines the name to look for
  62051. * @returns the lens flare system or null if not found
  62052. */
  62053. getLensFlareSystemByName(name: string): Nullable<LensFlareSystem>;
  62054. /**
  62055. * Gets a lens flare system using its id
  62056. * @param id defines the id to look for
  62057. * @returns the lens flare system or null if not found
  62058. */
  62059. getLensFlareSystemByID(id: string): Nullable<LensFlareSystem>;
  62060. }
  62061. }
  62062. /**
  62063. * Defines the lens flare scene component responsible to manage any lens flares
  62064. * in a given scene.
  62065. */
  62066. export class LensFlareSystemSceneComponent implements ISceneSerializableComponent {
  62067. /**
  62068. * The component name helpfull to identify the component in the list of scene components.
  62069. */
  62070. readonly name: string;
  62071. /**
  62072. * The scene the component belongs to.
  62073. */
  62074. scene: Scene;
  62075. /**
  62076. * Creates a new instance of the component for the given scene
  62077. * @param scene Defines the scene to register the component in
  62078. */
  62079. constructor(scene: Scene);
  62080. /**
  62081. * Registers the component in a given scene
  62082. */
  62083. register(): void;
  62084. /**
  62085. * Rebuilds the elements related to this component in case of
  62086. * context lost for instance.
  62087. */
  62088. rebuild(): void;
  62089. /**
  62090. * Adds all the elements from the container to the scene
  62091. * @param container the container holding the elements
  62092. */
  62093. addFromContainer(container: AbstractScene): void;
  62094. /**
  62095. * Removes all the elements in the container from the scene
  62096. * @param container contains the elements to remove
  62097. * @param dispose if the removed element should be disposed (default: false)
  62098. */
  62099. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  62100. /**
  62101. * Serializes the component data to the specified json object
  62102. * @param serializationObject The object to serialize to
  62103. */
  62104. serialize(serializationObject: any): void;
  62105. /**
  62106. * Disposes the component and the associated ressources.
  62107. */
  62108. dispose(): void;
  62109. private _draw;
  62110. }
  62111. }
  62112. declare module "babylonjs/LensFlares/index" {
  62113. export * from "babylonjs/LensFlares/lensFlare";
  62114. export * from "babylonjs/LensFlares/lensFlareSystem";
  62115. export * from "babylonjs/LensFlares/lensFlareSystemSceneComponent";
  62116. }
  62117. declare module "babylonjs/Shaders/depth.fragment" {
  62118. import "babylonjs/Shaders/ShadersInclude/packingFunctions";
  62119. /** @hidden */
  62120. export var depthPixelShader: {
  62121. name: string;
  62122. shader: string;
  62123. };
  62124. }
  62125. declare module "babylonjs/Shaders/depth.vertex" {
  62126. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  62127. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  62128. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  62129. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  62130. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  62131. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  62132. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  62133. /** @hidden */
  62134. export var depthVertexShader: {
  62135. name: string;
  62136. shader: string;
  62137. };
  62138. }
  62139. declare module "babylonjs/Rendering/depthRenderer" {
  62140. import { Nullable } from "babylonjs/types";
  62141. import { SubMesh } from "babylonjs/Meshes/subMesh";
  62142. import { Scene } from "babylonjs/scene";
  62143. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  62144. import { Camera } from "babylonjs/Cameras/camera";
  62145. import "babylonjs/Shaders/depth.fragment";
  62146. import "babylonjs/Shaders/depth.vertex";
  62147. /**
  62148. * This represents a depth renderer in Babylon.
  62149. * A depth renderer will render to it's depth map every frame which can be displayed or used in post processing
  62150. */
  62151. export class DepthRenderer {
  62152. private _scene;
  62153. private _depthMap;
  62154. private _effect;
  62155. private readonly _storeNonLinearDepth;
  62156. private readonly _clearColor;
  62157. /** Get if the depth renderer is using packed depth or not */
  62158. readonly isPacked: boolean;
  62159. private _cachedDefines;
  62160. private _camera;
  62161. /** Enable or disable the depth renderer. When disabled, the depth texture is not updated */
  62162. enabled: boolean;
  62163. /**
  62164. * Specifiess that the depth renderer will only be used within
  62165. * the camera it is created for.
  62166. * This can help forcing its rendering during the camera processing.
  62167. */
  62168. useOnlyInActiveCamera: boolean;
  62169. /** @hidden */
  62170. static _SceneComponentInitialization: (scene: Scene) => void;
  62171. /**
  62172. * Instantiates a depth renderer
  62173. * @param scene The scene the renderer belongs to
  62174. * @param type The texture type of the depth map (default: Engine.TEXTURETYPE_FLOAT)
  62175. * @param camera The camera to be used to render the depth map (default: scene's active camera)
  62176. * @param storeNonLinearDepth Defines whether the depth is stored linearly like in Babylon Shadows or directly like glFragCoord.z
  62177. */
  62178. constructor(scene: Scene, type?: number, camera?: Nullable<Camera>, storeNonLinearDepth?: boolean);
  62179. /**
  62180. * Creates the depth rendering effect and checks if the effect is ready.
  62181. * @param subMesh The submesh to be used to render the depth map of
  62182. * @param useInstances If multiple world instances should be used
  62183. * @returns if the depth renderer is ready to render the depth map
  62184. */
  62185. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  62186. /**
  62187. * Gets the texture which the depth map will be written to.
  62188. * @returns The depth map texture
  62189. */
  62190. getDepthMap(): RenderTargetTexture;
  62191. /**
  62192. * Disposes of the depth renderer.
  62193. */
  62194. dispose(): void;
  62195. }
  62196. }
  62197. declare module "babylonjs/Shaders/minmaxRedux.fragment" {
  62198. /** @hidden */
  62199. export var minmaxReduxPixelShader: {
  62200. name: string;
  62201. shader: string;
  62202. };
  62203. }
  62204. declare module "babylonjs/Misc/minMaxReducer" {
  62205. import { Nullable } from "babylonjs/types";
  62206. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  62207. import { Camera } from "babylonjs/Cameras/camera";
  62208. import { Observer } from "babylonjs/Misc/observable";
  62209. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  62210. import { PostProcessManager } from "babylonjs/PostProcesses/postProcessManager";
  62211. import { Observable } from "babylonjs/Misc/observable";
  62212. import "babylonjs/Shaders/minmaxRedux.fragment";
  62213. /**
  62214. * This class computes a min/max reduction from a texture: it means it computes the minimum
  62215. * and maximum values from all values of the texture.
  62216. * It is performed on the GPU for better performances, thanks to a succession of post processes.
  62217. * The source values are read from the red channel of the texture.
  62218. */
  62219. export class MinMaxReducer {
  62220. /**
  62221. * Observable triggered when the computation has been performed
  62222. */
  62223. onAfterReductionPerformed: Observable<{
  62224. min: number;
  62225. max: number;
  62226. }>;
  62227. protected _camera: Camera;
  62228. protected _sourceTexture: Nullable<RenderTargetTexture>;
  62229. protected _reductionSteps: Nullable<Array<PostProcess>>;
  62230. protected _postProcessManager: PostProcessManager;
  62231. protected _onAfterUnbindObserver: Nullable<Observer<RenderTargetTexture>>;
  62232. protected _forceFullscreenViewport: boolean;
  62233. /**
  62234. * Creates a min/max reducer
  62235. * @param camera The camera to use for the post processes
  62236. */
  62237. constructor(camera: Camera);
  62238. /**
  62239. * Gets the texture used to read the values from.
  62240. */
  62241. get sourceTexture(): Nullable<RenderTargetTexture>;
  62242. /**
  62243. * Sets the source texture to read the values from.
  62244. * One must indicate if the texture is a depth texture or not through the depthRedux parameter
  62245. * because in such textures '1' value must not be taken into account to compute the maximum
  62246. * as this value is used to clear the texture.
  62247. * Note that the computation is not activated by calling this function, you must call activate() for that!
  62248. * @param sourceTexture The texture to read the values from. The values should be in the red channel.
  62249. * @param depthRedux Indicates if the texture is a depth texture or not
  62250. * @param type The type of the textures created for the reduction (defaults to TEXTURETYPE_HALF_FLOAT)
  62251. * @param forceFullscreenViewport Forces the post processes used for the reduction to be applied without taking into account viewport (defaults to true)
  62252. */
  62253. setSourceTexture(sourceTexture: RenderTargetTexture, depthRedux: boolean, type?: number, forceFullscreenViewport?: boolean): void;
  62254. /**
  62255. * Defines the refresh rate of the computation.
  62256. * Use 0 to compute just once, 1 to compute on every frame, 2 to compute every two frames and so on...
  62257. */
  62258. get refreshRate(): number;
  62259. set refreshRate(value: number);
  62260. protected _activated: boolean;
  62261. /**
  62262. * Gets the activation status of the reducer
  62263. */
  62264. get activated(): boolean;
  62265. /**
  62266. * Activates the reduction computation.
  62267. * When activated, the observers registered in onAfterReductionPerformed are
  62268. * called after the compuation is performed
  62269. */
  62270. activate(): void;
  62271. /**
  62272. * Deactivates the reduction computation.
  62273. */
  62274. deactivate(): void;
  62275. /**
  62276. * Disposes the min/max reducer
  62277. * @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.
  62278. */
  62279. dispose(disposeAll?: boolean): void;
  62280. }
  62281. }
  62282. declare module "babylonjs/Misc/depthReducer" {
  62283. import { Nullable } from "babylonjs/types";
  62284. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  62285. import { Camera } from "babylonjs/Cameras/camera";
  62286. import { DepthRenderer } from "babylonjs/Rendering/depthRenderer";
  62287. import { MinMaxReducer } from "babylonjs/Misc/minMaxReducer";
  62288. /**
  62289. * This class is a small wrapper around the MinMaxReducer class to compute the min/max values of a depth texture
  62290. */
  62291. export class DepthReducer extends MinMaxReducer {
  62292. private _depthRenderer;
  62293. private _depthRendererId;
  62294. /**
  62295. * Gets the depth renderer used for the computation.
  62296. * Note that the result is null if you provide your own renderer when calling setDepthRenderer.
  62297. */
  62298. get depthRenderer(): Nullable<DepthRenderer>;
  62299. /**
  62300. * Creates a depth reducer
  62301. * @param camera The camera used to render the depth texture
  62302. */
  62303. constructor(camera: Camera);
  62304. /**
  62305. * Sets the depth renderer to use to generate the depth map
  62306. * @param depthRenderer The depth renderer to use. If not provided, a new one will be created automatically
  62307. * @param type The texture type of the depth map (default: TEXTURETYPE_HALF_FLOAT)
  62308. * @param forceFullscreenViewport Forces the post processes used for the reduction to be applied without taking into account viewport (defaults to true)
  62309. */
  62310. setDepthRenderer(depthRenderer?: Nullable<DepthRenderer>, type?: number, forceFullscreenViewport?: boolean): void;
  62311. /** @hidden */
  62312. setSourceTexture(sourceTexture: RenderTargetTexture, depthRedux: boolean, type?: number, forceFullscreenViewport?: boolean): void;
  62313. /**
  62314. * Activates the reduction computation.
  62315. * When activated, the observers registered in onAfterReductionPerformed are
  62316. * called after the compuation is performed
  62317. */
  62318. activate(): void;
  62319. /**
  62320. * Deactivates the reduction computation.
  62321. */
  62322. deactivate(): void;
  62323. /**
  62324. * Disposes the depth reducer
  62325. * @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.
  62326. */
  62327. dispose(disposeAll?: boolean): void;
  62328. }
  62329. }
  62330. declare module "babylonjs/Lights/Shadows/cascadedShadowGenerator" {
  62331. import { Nullable } from "babylonjs/types";
  62332. import { Scene } from "babylonjs/scene";
  62333. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  62334. import { SubMesh } from "babylonjs/Meshes/subMesh";
  62335. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  62336. import { Effect } from "babylonjs/Materials/effect";
  62337. import "babylonjs/Shaders/shadowMap.fragment";
  62338. import "babylonjs/Shaders/shadowMap.vertex";
  62339. import "babylonjs/Shaders/depthBoxBlur.fragment";
  62340. import { ShadowGenerator } from "babylonjs/Lights/Shadows/shadowGenerator";
  62341. import { DirectionalLight } from "babylonjs/Lights/directionalLight";
  62342. import { BoundingInfo } from "babylonjs/Culling/boundingInfo";
  62343. import { DepthRenderer } from "babylonjs/Rendering/depthRenderer";
  62344. /**
  62345. * A CSM implementation allowing casting shadows on large scenes.
  62346. * Documentation : https://doc.babylonjs.com/babylon101/cascadedShadows
  62347. * Based on: https://github.com/TheRealMJP/Shadows and https://johanmedestrom.wordpress.com/2016/03/18/opengl-cascaded-shadow-maps/
  62348. */
  62349. export class CascadedShadowGenerator extends ShadowGenerator {
  62350. private static readonly frustumCornersNDCSpace;
  62351. /**
  62352. * Name of the CSM class
  62353. */
  62354. static CLASSNAME: string;
  62355. /**
  62356. * Defines the default number of cascades used by the CSM.
  62357. */
  62358. static readonly DEFAULT_CASCADES_COUNT: number;
  62359. /**
  62360. * Defines the minimum number of cascades used by the CSM.
  62361. */
  62362. static readonly MIN_CASCADES_COUNT: number;
  62363. /**
  62364. * Defines the maximum number of cascades used by the CSM.
  62365. */
  62366. static readonly MAX_CASCADES_COUNT: number;
  62367. protected _validateFilter(filter: number): number;
  62368. /**
  62369. * Gets or sets the actual darkness of the soft shadows while using PCSS filtering (value between 0. and 1.)
  62370. */
  62371. penumbraDarkness: number;
  62372. private _numCascades;
  62373. /**
  62374. * Gets or set the number of cascades used by the CSM.
  62375. */
  62376. get numCascades(): number;
  62377. set numCascades(value: number);
  62378. /**
  62379. * Sets this to true if you want that the edges of the shadows don't "swimm" / "shimmer" when rotating the camera.
  62380. * The trade off is that you lose some precision in the shadow rendering when enabling this setting.
  62381. */
  62382. stabilizeCascades: boolean;
  62383. private _freezeShadowCastersBoundingInfo;
  62384. private _freezeShadowCastersBoundingInfoObservable;
  62385. /**
  62386. * Enables or disables the shadow casters bounding info computation.
  62387. * If your shadow casters don't move, you can disable this feature.
  62388. * If it is enabled, the bounding box computation is done every frame.
  62389. */
  62390. get freezeShadowCastersBoundingInfo(): boolean;
  62391. set freezeShadowCastersBoundingInfo(freeze: boolean);
  62392. private _scbiMin;
  62393. private _scbiMax;
  62394. protected _computeShadowCastersBoundingInfo(): void;
  62395. protected _shadowCastersBoundingInfo: BoundingInfo;
  62396. /**
  62397. * Gets or sets the shadow casters bounding info.
  62398. * If you provide your own shadow casters bounding info, first enable freezeShadowCastersBoundingInfo
  62399. * so that the system won't overwrite the bounds you provide
  62400. */
  62401. get shadowCastersBoundingInfo(): BoundingInfo;
  62402. set shadowCastersBoundingInfo(boundingInfo: BoundingInfo);
  62403. protected _breaksAreDirty: boolean;
  62404. protected _minDistance: number;
  62405. protected _maxDistance: number;
  62406. /**
  62407. * Sets the minimal and maximal distances to use when computing the cascade breaks.
  62408. *
  62409. * The values of min / max are typically the depth zmin and zmax values of your scene, for a given frame.
  62410. * If you don't know these values, simply leave them to their defaults and don't call this function.
  62411. * @param min minimal distance for the breaks (default to 0.)
  62412. * @param max maximal distance for the breaks (default to 1.)
  62413. */
  62414. setMinMaxDistance(min: number, max: number): void;
  62415. /** Gets the minimal distance used in the cascade break computation */
  62416. get minDistance(): number;
  62417. /** Gets the maximal distance used in the cascade break computation */
  62418. get maxDistance(): number;
  62419. /**
  62420. * Gets the class name of that object
  62421. * @returns "CascadedShadowGenerator"
  62422. */
  62423. getClassName(): string;
  62424. private _cascadeMinExtents;
  62425. private _cascadeMaxExtents;
  62426. /**
  62427. * Gets a cascade minimum extents
  62428. * @param cascadeIndex index of the cascade
  62429. * @returns the minimum cascade extents
  62430. */
  62431. getCascadeMinExtents(cascadeIndex: number): Nullable<Vector3>;
  62432. /**
  62433. * Gets a cascade maximum extents
  62434. * @param cascadeIndex index of the cascade
  62435. * @returns the maximum cascade extents
  62436. */
  62437. getCascadeMaxExtents(cascadeIndex: number): Nullable<Vector3>;
  62438. private _cascades;
  62439. private _currentLayer;
  62440. private _viewSpaceFrustumsZ;
  62441. private _viewMatrices;
  62442. private _projectionMatrices;
  62443. private _transformMatrices;
  62444. private _transformMatricesAsArray;
  62445. private _frustumLengths;
  62446. private _lightSizeUVCorrection;
  62447. private _depthCorrection;
  62448. private _frustumCornersWorldSpace;
  62449. private _frustumCenter;
  62450. private _shadowCameraPos;
  62451. private _shadowMaxZ;
  62452. /**
  62453. * Gets the shadow max z distance. It's the limit beyond which shadows are not displayed.
  62454. * It defaults to camera.maxZ
  62455. */
  62456. get shadowMaxZ(): number;
  62457. /**
  62458. * Sets the shadow max z distance.
  62459. */
  62460. set shadowMaxZ(value: number);
  62461. protected _debug: boolean;
  62462. /**
  62463. * Gets or sets the debug flag.
  62464. * When enabled, the cascades are materialized by different colors on the screen.
  62465. */
  62466. get debug(): boolean;
  62467. set debug(dbg: boolean);
  62468. private _depthClamp;
  62469. /**
  62470. * Gets or sets the depth clamping value.
  62471. *
  62472. * When enabled, it improves the shadow quality because the near z plane of the light frustum don't need to be adjusted
  62473. * to account for the shadow casters far away.
  62474. *
  62475. * Note that this property is incompatible with PCSS filtering, so it won't be used in that case.
  62476. */
  62477. get depthClamp(): boolean;
  62478. set depthClamp(value: boolean);
  62479. private _cascadeBlendPercentage;
  62480. /**
  62481. * Gets or sets the percentage of blending between two cascades (value between 0. and 1.).
  62482. * It defaults to 0.1 (10% blending).
  62483. */
  62484. get cascadeBlendPercentage(): number;
  62485. set cascadeBlendPercentage(value: number);
  62486. private _lambda;
  62487. /**
  62488. * Gets or set the lambda parameter.
  62489. * This parameter is used to split the camera frustum and create the cascades.
  62490. * 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.
  62491. * For all values in-between, it's a linear combination of the uniform and logarithm split algorithm.
  62492. */
  62493. get lambda(): number;
  62494. set lambda(value: number);
  62495. /**
  62496. * Gets the view matrix corresponding to a given cascade
  62497. * @param cascadeNum cascade to retrieve the view matrix from
  62498. * @returns the cascade view matrix
  62499. */
  62500. getCascadeViewMatrix(cascadeNum: number): Nullable<Matrix>;
  62501. /**
  62502. * Gets the projection matrix corresponding to a given cascade
  62503. * @param cascadeNum cascade to retrieve the projection matrix from
  62504. * @returns the cascade projection matrix
  62505. */
  62506. getCascadeProjectionMatrix(cascadeNum: number): Nullable<Matrix>;
  62507. /**
  62508. * Gets the transformation matrix corresponding to a given cascade
  62509. * @param cascadeNum cascade to retrieve the transformation matrix from
  62510. * @returns the cascade transformation matrix
  62511. */
  62512. getCascadeTransformMatrix(cascadeNum: number): Nullable<Matrix>;
  62513. private _depthRenderer;
  62514. /**
  62515. * Sets the depth renderer to use when autoCalcDepthBounds is enabled.
  62516. *
  62517. * Note that if no depth renderer is set, a new one will be automatically created internally when necessary.
  62518. *
  62519. * You should call this function if you already have a depth renderer enabled in your scene, to avoid
  62520. * doing multiple depth rendering each frame. If you provide your own depth renderer, make sure it stores linear depth!
  62521. * @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
  62522. */
  62523. setDepthRenderer(depthRenderer: Nullable<DepthRenderer>): void;
  62524. private _depthReducer;
  62525. private _autoCalcDepthBounds;
  62526. /**
  62527. * Gets or sets the autoCalcDepthBounds property.
  62528. *
  62529. * When enabled, a depth rendering pass is first performed (with an internally created depth renderer or with the one
  62530. * you provide by calling setDepthRenderer). Then, a min/max reducing is applied on the depth map to compute the
  62531. * minimal and maximal depth of the map and those values are used as inputs for the setMinMaxDistance() function.
  62532. * It can greatly enhance the shadow quality, at the expense of more GPU works.
  62533. * When using this option, you should increase the value of the lambda parameter, and even set it to 1 for best results.
  62534. */
  62535. get autoCalcDepthBounds(): boolean;
  62536. set autoCalcDepthBounds(value: boolean);
  62537. /**
  62538. * Defines the refresh rate of the min/max computation used when autoCalcDepthBounds is set to true
  62539. * Use 0 to compute just once, 1 to compute on every frame, 2 to compute every two frames and so on...
  62540. * Note that if you provided your own depth renderer through a call to setDepthRenderer, you are responsible
  62541. * for setting the refresh rate on the renderer yourself!
  62542. */
  62543. get autoCalcDepthBoundsRefreshRate(): number;
  62544. set autoCalcDepthBoundsRefreshRate(value: number);
  62545. /**
  62546. * Create the cascade breaks according to the lambda, shadowMaxZ and min/max distance properties, as well as the camera near and far planes.
  62547. * This function is automatically called when updating lambda, shadowMaxZ and min/max distances, however you should call it yourself if
  62548. * you change the camera near/far planes!
  62549. */
  62550. splitFrustum(): void;
  62551. private _splitFrustum;
  62552. private _computeMatrices;
  62553. private _computeFrustumInWorldSpace;
  62554. private _computeCascadeFrustum;
  62555. /**
  62556. * Support test.
  62557. */
  62558. static get IsSupported(): boolean;
  62559. /** @hidden */
  62560. static _SceneComponentInitialization: (scene: Scene) => void;
  62561. /**
  62562. * Creates a Cascaded Shadow Generator object.
  62563. * A ShadowGenerator is the required tool to use the shadows.
  62564. * Each directional light casting shadows needs to use its own ShadowGenerator.
  62565. * Documentation : https://doc.babylonjs.com/babylon101/cascadedShadows
  62566. * @param mapSize The size of the texture what stores the shadows. Example : 1024.
  62567. * @param light The directional light object generating the shadows.
  62568. * @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.
  62569. */
  62570. constructor(mapSize: number, light: DirectionalLight, usefulFloatFirst?: boolean);
  62571. protected _initializeGenerator(): void;
  62572. protected _createTargetRenderTexture(): void;
  62573. protected _initializeShadowMap(): void;
  62574. protected _bindCustomEffectForRenderSubMeshForShadowMap(subMesh: SubMesh, effect: Effect, matriceNames: any, mesh: AbstractMesh): void;
  62575. protected _isReadyCustomDefines(defines: any, subMesh: SubMesh, useInstances: boolean): void;
  62576. /**
  62577. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  62578. * @param defines Defines of the material we want to update
  62579. * @param lightIndex Index of the light in the enabled light list of the material
  62580. */
  62581. prepareDefines(defines: any, lightIndex: number): void;
  62582. /**
  62583. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  62584. * defined in the generator but impacting the effect).
  62585. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  62586. * @param effect The effect we are binfing the information for
  62587. */
  62588. bindShadowLight(lightIndex: string, effect: Effect): void;
  62589. /**
  62590. * Gets the transformation matrix of the first cascade used to project the meshes into the map from the light point of view.
  62591. * (eq to view projection * shadow projection matrices)
  62592. * @returns The transform matrix used to create the shadow map
  62593. */
  62594. getTransformMatrix(): Matrix;
  62595. /**
  62596. * Disposes the ShadowGenerator.
  62597. * Returns nothing.
  62598. */
  62599. dispose(): void;
  62600. /**
  62601. * Serializes the shadow generator setup to a json object.
  62602. * @returns The serialized JSON object
  62603. */
  62604. serialize(): any;
  62605. /**
  62606. * Parses a serialized ShadowGenerator and returns a new ShadowGenerator.
  62607. * @param parsedShadowGenerator The JSON object to parse
  62608. * @param scene The scene to create the shadow map for
  62609. * @returns The parsed shadow generator
  62610. */
  62611. static Parse(parsedShadowGenerator: any, scene: Scene): ShadowGenerator;
  62612. }
  62613. }
  62614. declare module "babylonjs/Lights/Shadows/shadowGeneratorSceneComponent" {
  62615. import { Scene } from "babylonjs/scene";
  62616. import { ISceneSerializableComponent } from "babylonjs/sceneComponent";
  62617. import { AbstractScene } from "babylonjs/abstractScene";
  62618. /**
  62619. * Defines the shadow generator component responsible to manage any shadow generators
  62620. * in a given scene.
  62621. */
  62622. export class ShadowGeneratorSceneComponent implements ISceneSerializableComponent {
  62623. /**
  62624. * The component name helpfull to identify the component in the list of scene components.
  62625. */
  62626. readonly name: string;
  62627. /**
  62628. * The scene the component belongs to.
  62629. */
  62630. scene: Scene;
  62631. /**
  62632. * Creates a new instance of the component for the given scene
  62633. * @param scene Defines the scene to register the component in
  62634. */
  62635. constructor(scene: Scene);
  62636. /**
  62637. * Registers the component in a given scene
  62638. */
  62639. register(): void;
  62640. /**
  62641. * Rebuilds the elements related to this component in case of
  62642. * context lost for instance.
  62643. */
  62644. rebuild(): void;
  62645. /**
  62646. * Serializes the component data to the specified json object
  62647. * @param serializationObject The object to serialize to
  62648. */
  62649. serialize(serializationObject: any): void;
  62650. /**
  62651. * Adds all the elements from the container to the scene
  62652. * @param container the container holding the elements
  62653. */
  62654. addFromContainer(container: AbstractScene): void;
  62655. /**
  62656. * Removes all the elements in the container from the scene
  62657. * @param container contains the elements to remove
  62658. * @param dispose if the removed element should be disposed (default: false)
  62659. */
  62660. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  62661. /**
  62662. * Rebuilds the elements related to this component in case of
  62663. * context lost for instance.
  62664. */
  62665. dispose(): void;
  62666. private _gatherRenderTargets;
  62667. }
  62668. }
  62669. declare module "babylonjs/Lights/Shadows/index" {
  62670. export * from "babylonjs/Lights/Shadows/shadowGenerator";
  62671. export * from "babylonjs/Lights/Shadows/cascadedShadowGenerator";
  62672. export * from "babylonjs/Lights/Shadows/shadowGeneratorSceneComponent";
  62673. }
  62674. declare module "babylonjs/Lights/pointLight" {
  62675. import { Scene } from "babylonjs/scene";
  62676. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  62677. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  62678. import { ShadowLight } from "babylonjs/Lights/shadowLight";
  62679. import { Effect } from "babylonjs/Materials/effect";
  62680. /**
  62681. * A point light is a light defined by an unique point in world space.
  62682. * The light is emitted in every direction from this point.
  62683. * A good example of a point light is a standard light bulb.
  62684. * Documentation: https://doc.babylonjs.com/babylon101/lights
  62685. */
  62686. export class PointLight extends ShadowLight {
  62687. private _shadowAngle;
  62688. /**
  62689. * Getter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  62690. * This specifies what angle the shadow will use to be created.
  62691. *
  62692. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  62693. */
  62694. get shadowAngle(): number;
  62695. /**
  62696. * Setter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  62697. * This specifies what angle the shadow will use to be created.
  62698. *
  62699. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  62700. */
  62701. set shadowAngle(value: number);
  62702. /**
  62703. * Gets the direction if it has been set.
  62704. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  62705. */
  62706. get direction(): Vector3;
  62707. /**
  62708. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  62709. */
  62710. set direction(value: Vector3);
  62711. /**
  62712. * Creates a PointLight object from the passed name and position (Vector3) and adds it in the scene.
  62713. * A PointLight emits the light in every direction.
  62714. * It can cast shadows.
  62715. * If the scene camera is already defined and you want to set your PointLight at the camera position, just set it :
  62716. * ```javascript
  62717. * var pointLight = new PointLight("pl", camera.position, scene);
  62718. * ```
  62719. * Documentation : https://doc.babylonjs.com/babylon101/lights
  62720. * @param name The light friendly name
  62721. * @param position The position of the point light in the scene
  62722. * @param scene The scene the lights belongs to
  62723. */
  62724. constructor(name: string, position: Vector3, scene: Scene);
  62725. /**
  62726. * Returns the string "PointLight"
  62727. * @returns the class name
  62728. */
  62729. getClassName(): string;
  62730. /**
  62731. * Returns the integer 0.
  62732. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  62733. */
  62734. getTypeID(): number;
  62735. /**
  62736. * Specifies wether or not the shadowmap should be a cube texture.
  62737. * @returns true if the shadowmap needs to be a cube texture.
  62738. */
  62739. needCube(): boolean;
  62740. /**
  62741. * Returns a new Vector3 aligned with the PointLight cube system according to the passed cube face index (integer).
  62742. * @param faceIndex The index of the face we are computed the direction to generate shadow
  62743. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  62744. */
  62745. getShadowDirection(faceIndex?: number): Vector3;
  62746. /**
  62747. * Sets the passed matrix "matrix" as a left-handed perspective projection matrix with the following settings :
  62748. * - fov = PI / 2
  62749. * - aspect ratio : 1.0
  62750. * - z-near and far equal to the active camera minZ and maxZ.
  62751. * Returns the PointLight.
  62752. */
  62753. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  62754. protected _buildUniformLayout(): void;
  62755. /**
  62756. * Sets the passed Effect "effect" with the PointLight transformed position (or position, if none) and passed name (string).
  62757. * @param effect The effect to update
  62758. * @param lightIndex The index of the light in the effect to update
  62759. * @returns The point light
  62760. */
  62761. transferToEffect(effect: Effect, lightIndex: string): PointLight;
  62762. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): this;
  62763. /**
  62764. * Prepares the list of defines specific to the light type.
  62765. * @param defines the list of defines
  62766. * @param lightIndex defines the index of the light for the effect
  62767. */
  62768. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  62769. }
  62770. }
  62771. declare module "babylonjs/Lights/index" {
  62772. export * from "babylonjs/Lights/light";
  62773. export * from "babylonjs/Lights/shadowLight";
  62774. export * from "babylonjs/Lights/Shadows/index";
  62775. export * from "babylonjs/Lights/directionalLight";
  62776. export * from "babylonjs/Lights/hemisphericLight";
  62777. export * from "babylonjs/Lights/pointLight";
  62778. export * from "babylonjs/Lights/spotLight";
  62779. }
  62780. declare module "babylonjs/Misc/HighDynamicRange/hdr" {
  62781. import { CubeMapInfo } from "babylonjs/Misc/HighDynamicRange/panoramaToCubemap";
  62782. /**
  62783. * Header information of HDR texture files.
  62784. */
  62785. export interface HDRInfo {
  62786. /**
  62787. * The height of the texture in pixels.
  62788. */
  62789. height: number;
  62790. /**
  62791. * The width of the texture in pixels.
  62792. */
  62793. width: number;
  62794. /**
  62795. * The index of the beginning of the data in the binary file.
  62796. */
  62797. dataPosition: number;
  62798. }
  62799. /**
  62800. * This groups tools to convert HDR texture to native colors array.
  62801. */
  62802. export class HDRTools {
  62803. private static Ldexp;
  62804. private static Rgbe2float;
  62805. private static readStringLine;
  62806. /**
  62807. * Reads header information from an RGBE texture stored in a native array.
  62808. * More information on this format are available here:
  62809. * https://en.wikipedia.org/wiki/RGBE_image_format
  62810. *
  62811. * @param uint8array The binary file stored in native array.
  62812. * @return The header information.
  62813. */
  62814. static RGBE_ReadHeader(uint8array: Uint8Array): HDRInfo;
  62815. /**
  62816. * Returns the cubemap information (each faces texture data) extracted from an RGBE texture.
  62817. * This RGBE texture needs to store the information as a panorama.
  62818. *
  62819. * More information on this format are available here:
  62820. * https://en.wikipedia.org/wiki/RGBE_image_format
  62821. *
  62822. * @param buffer The binary file stored in an array buffer.
  62823. * @param size The expected size of the extracted cubemap.
  62824. * @return The Cube Map information.
  62825. */
  62826. static GetCubeMapTextureData(buffer: ArrayBuffer, size: number): CubeMapInfo;
  62827. /**
  62828. * Returns the pixels data extracted from an RGBE texture.
  62829. * This pixels will be stored left to right up to down in the R G B order in one array.
  62830. *
  62831. * More information on this format are available here:
  62832. * https://en.wikipedia.org/wiki/RGBE_image_format
  62833. *
  62834. * @param uint8array The binary file stored in an array buffer.
  62835. * @param hdrInfo The header information of the file.
  62836. * @return The pixels data in RGB right to left up to down order.
  62837. */
  62838. static RGBE_ReadPixels(uint8array: Uint8Array, hdrInfo: HDRInfo): Float32Array;
  62839. private static RGBE_ReadPixels_RLE;
  62840. private static RGBE_ReadPixels_NOT_RLE;
  62841. }
  62842. }
  62843. declare module "babylonjs/Materials/effectRenderer" {
  62844. import { Nullable } from "babylonjs/types";
  62845. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  62846. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  62847. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  62848. import { Viewport } from "babylonjs/Maths/math.viewport";
  62849. import { Observable } from "babylonjs/Misc/observable";
  62850. import { Effect } from "babylonjs/Materials/effect";
  62851. import "babylonjs/Shaders/postprocess.vertex";
  62852. /**
  62853. * Effect Render Options
  62854. */
  62855. export interface IEffectRendererOptions {
  62856. /**
  62857. * Defines the vertices positions.
  62858. */
  62859. positions?: number[];
  62860. /**
  62861. * Defines the indices.
  62862. */
  62863. indices?: number[];
  62864. }
  62865. /**
  62866. * Helper class to render one or more effects.
  62867. * You can access the previous rendering in your shader by declaring a sampler named textureSampler
  62868. */
  62869. export class EffectRenderer {
  62870. private engine;
  62871. private static _DefaultOptions;
  62872. private _vertexBuffers;
  62873. private _indexBuffer;
  62874. private _fullscreenViewport;
  62875. /**
  62876. * Creates an effect renderer
  62877. * @param engine the engine to use for rendering
  62878. * @param options defines the options of the effect renderer
  62879. */
  62880. constructor(engine: ThinEngine, options?: IEffectRendererOptions);
  62881. /**
  62882. * Sets the current viewport in normalized coordinates 0-1
  62883. * @param viewport Defines the viewport to set (defaults to 0 0 1 1)
  62884. */
  62885. setViewport(viewport?: Viewport): void;
  62886. /**
  62887. * Binds the embedded attributes buffer to the effect.
  62888. * @param effect Defines the effect to bind the attributes for
  62889. */
  62890. bindBuffers(effect: Effect): void;
  62891. /**
  62892. * Sets the current effect wrapper to use during draw.
  62893. * The effect needs to be ready before calling this api.
  62894. * This also sets the default full screen position attribute.
  62895. * @param effectWrapper Defines the effect to draw with
  62896. */
  62897. applyEffectWrapper(effectWrapper: EffectWrapper): void;
  62898. /**
  62899. * Restores engine states
  62900. */
  62901. restoreStates(): void;
  62902. /**
  62903. * Draws a full screen quad.
  62904. */
  62905. draw(): void;
  62906. private isRenderTargetTexture;
  62907. /**
  62908. * renders one or more effects to a specified texture
  62909. * @param effectWrapper the effect to renderer
  62910. * @param outputTexture texture to draw to, if null it will render to the screen.
  62911. */
  62912. render(effectWrapper: EffectWrapper, outputTexture?: Nullable<InternalTexture | RenderTargetTexture>): void;
  62913. /**
  62914. * Disposes of the effect renderer
  62915. */
  62916. dispose(): void;
  62917. }
  62918. /**
  62919. * Options to create an EffectWrapper
  62920. */
  62921. interface EffectWrapperCreationOptions {
  62922. /**
  62923. * Engine to use to create the effect
  62924. */
  62925. engine: ThinEngine;
  62926. /**
  62927. * Fragment shader for the effect
  62928. */
  62929. fragmentShader: string;
  62930. /**
  62931. * Use the shader store instead of direct source code
  62932. */
  62933. useShaderStore?: boolean;
  62934. /**
  62935. * Vertex shader for the effect
  62936. */
  62937. vertexShader?: string;
  62938. /**
  62939. * Attributes to use in the shader
  62940. */
  62941. attributeNames?: Array<string>;
  62942. /**
  62943. * Uniforms to use in the shader
  62944. */
  62945. uniformNames?: Array<string>;
  62946. /**
  62947. * Texture sampler names to use in the shader
  62948. */
  62949. samplerNames?: Array<string>;
  62950. /**
  62951. * Defines to use in the shader
  62952. */
  62953. defines?: Array<string>;
  62954. /**
  62955. * Callback when effect is compiled
  62956. */
  62957. onCompiled?: Nullable<(effect: Effect) => void>;
  62958. /**
  62959. * The friendly name of the effect displayed in Spector.
  62960. */
  62961. name?: string;
  62962. }
  62963. /**
  62964. * Wraps an effect to be used for rendering
  62965. */
  62966. export class EffectWrapper {
  62967. /**
  62968. * Event that is fired right before the effect is drawn (should be used to update uniforms)
  62969. */
  62970. onApplyObservable: Observable<{}>;
  62971. /**
  62972. * The underlying effect
  62973. */
  62974. effect: Effect;
  62975. /**
  62976. * Creates an effect to be renderer
  62977. * @param creationOptions options to create the effect
  62978. */
  62979. constructor(creationOptions: EffectWrapperCreationOptions);
  62980. /**
  62981. * Disposes of the effect wrapper
  62982. */
  62983. dispose(): void;
  62984. }
  62985. }
  62986. declare module "babylonjs/Shaders/hdrFiltering.vertex" {
  62987. /** @hidden */
  62988. export var hdrFilteringVertexShader: {
  62989. name: string;
  62990. shader: string;
  62991. };
  62992. }
  62993. declare module "babylonjs/Shaders/hdrFiltering.fragment" {
  62994. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  62995. import "babylonjs/Shaders/ShadersInclude/importanceSampling";
  62996. import "babylonjs/Shaders/ShadersInclude/pbrBRDFFunctions";
  62997. import "babylonjs/Shaders/ShadersInclude/hdrFilteringFunctions";
  62998. /** @hidden */
  62999. export var hdrFilteringPixelShader: {
  63000. name: string;
  63001. shader: string;
  63002. };
  63003. }
  63004. declare module "babylonjs/Materials/Textures/Filtering/hdrFiltering" {
  63005. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  63006. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  63007. import { Nullable } from "babylonjs/types";
  63008. import "babylonjs/Shaders/hdrFiltering.vertex";
  63009. import "babylonjs/Shaders/hdrFiltering.fragment";
  63010. /**
  63011. * Options for texture filtering
  63012. */
  63013. interface IHDRFilteringOptions {
  63014. /**
  63015. * Scales pixel intensity for the input HDR map.
  63016. */
  63017. hdrScale?: number;
  63018. /**
  63019. * Quality of the filter. Should be `Constants.TEXTURE_FILTERING_QUALITY_OFFLINE` for prefiltering
  63020. */
  63021. quality?: number;
  63022. }
  63023. /**
  63024. * Filters HDR maps to get correct renderings of PBR reflections
  63025. */
  63026. export class HDRFiltering {
  63027. private _engine;
  63028. private _effectRenderer;
  63029. private _effectWrapper;
  63030. private _lodGenerationOffset;
  63031. private _lodGenerationScale;
  63032. /**
  63033. * Quality switch for prefiltering. Should be set to `Constants.TEXTURE_FILTERING_QUALITY_OFFLINE` unless
  63034. * you care about baking speed.
  63035. */
  63036. quality: number;
  63037. /**
  63038. * Scales pixel intensity for the input HDR map.
  63039. */
  63040. hdrScale: number;
  63041. /**
  63042. * Instantiates HDR filter for reflection maps
  63043. *
  63044. * @param engine Thin engine
  63045. * @param options Options
  63046. */
  63047. constructor(engine: ThinEngine, options?: IHDRFilteringOptions);
  63048. private _createRenderTarget;
  63049. private _prefilterInternal;
  63050. private _createEffect;
  63051. /**
  63052. * Get a value indicating if the filter is ready to be used
  63053. * @param texture Texture to filter
  63054. * @returns true if the filter is ready
  63055. */
  63056. isReady(texture: BaseTexture): boolean;
  63057. /**
  63058. * Prefilters a cube texture to have mipmap levels representing roughness values.
  63059. * Prefiltering will be invoked at the end of next rendering pass.
  63060. * This has to be done once the map is loaded, and has not been prefiltered by a third party software.
  63061. * See http://blog.selfshadow.com/publications/s2013-shading-course/karis/s2013_pbs_epic_notes_v2.pdf for more information
  63062. * @param texture Texture to filter
  63063. * @param onFinished Callback when filtering is done
  63064. * @return Promise called when prefiltering is done
  63065. */
  63066. prefilter(texture: BaseTexture, onFinished?: Nullable<() => void>): Promise<unknown> | undefined;
  63067. }
  63068. }
  63069. declare module "babylonjs/Materials/Textures/hdrCubeTexture" {
  63070. import { Nullable } from "babylonjs/types";
  63071. import { Scene } from "babylonjs/scene";
  63072. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  63073. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  63074. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  63075. import "babylonjs/Engines/Extensions/engine.rawTexture";
  63076. import "babylonjs/Materials/Textures/baseTexture.polynomial";
  63077. /**
  63078. * This represents a texture coming from an HDR input.
  63079. *
  63080. * The only supported format is currently panorama picture stored in RGBE format.
  63081. * Example of such files can be found on HDRLib: http://hdrlib.com/
  63082. */
  63083. export class HDRCubeTexture extends BaseTexture {
  63084. private static _facesMapping;
  63085. private _generateHarmonics;
  63086. private _noMipmap;
  63087. private _prefilterOnLoad;
  63088. private _textureMatrix;
  63089. private _size;
  63090. private _onLoad;
  63091. private _onError;
  63092. /**
  63093. * The texture URL.
  63094. */
  63095. url: string;
  63096. protected _isBlocking: boolean;
  63097. /**
  63098. * Sets wether or not the texture is blocking during loading.
  63099. */
  63100. set isBlocking(value: boolean);
  63101. /**
  63102. * Gets wether or not the texture is blocking during loading.
  63103. */
  63104. get isBlocking(): boolean;
  63105. protected _rotationY: number;
  63106. /**
  63107. * Sets texture matrix rotation angle around Y axis in radians.
  63108. */
  63109. set rotationY(value: number);
  63110. /**
  63111. * Gets texture matrix rotation angle around Y axis radians.
  63112. */
  63113. get rotationY(): number;
  63114. /**
  63115. * Gets or sets the center of the bounding box associated with the cube texture
  63116. * It must define where the camera used to render the texture was set
  63117. */
  63118. boundingBoxPosition: Vector3;
  63119. private _boundingBoxSize;
  63120. /**
  63121. * Gets or sets the size of the bounding box associated with the cube texture
  63122. * When defined, the cubemap will switch to local mode
  63123. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  63124. * @example https://www.babylonjs-playground.com/#RNASML
  63125. */
  63126. set boundingBoxSize(value: Vector3);
  63127. get boundingBoxSize(): Vector3;
  63128. /**
  63129. * Instantiates an HDRTexture from the following parameters.
  63130. *
  63131. * @param url The location of the HDR raw data (Panorama stored in RGBE format)
  63132. * @param sceneOrEngine The scene or engine the texture will be used in
  63133. * @param size The cubemap desired size (the more it increases the longer the generation will be)
  63134. * @param noMipmap Forces to not generate the mipmap if true
  63135. * @param generateHarmonics Specifies whether you want to extract the polynomial harmonics during the generation process
  63136. * @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)
  63137. * @param prefilterOnLoad Prefilters HDR texture to allow use of this texture as a PBR reflection texture.
  63138. */
  63139. 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>);
  63140. /**
  63141. * Get the current class name of the texture useful for serialization or dynamic coding.
  63142. * @returns "HDRCubeTexture"
  63143. */
  63144. getClassName(): string;
  63145. /**
  63146. * Occurs when the file is raw .hdr file.
  63147. */
  63148. private loadTexture;
  63149. clone(): HDRCubeTexture;
  63150. delayLoad(): void;
  63151. /**
  63152. * Get the texture reflection matrix used to rotate/transform the reflection.
  63153. * @returns the reflection matrix
  63154. */
  63155. getReflectionTextureMatrix(): Matrix;
  63156. /**
  63157. * Set the texture reflection matrix used to rotate/transform the reflection.
  63158. * @param value Define the reflection matrix to set
  63159. */
  63160. setReflectionTextureMatrix(value: Matrix): void;
  63161. /**
  63162. * Parses a JSON representation of an HDR Texture in order to create the texture
  63163. * @param parsedTexture Define the JSON representation
  63164. * @param scene Define the scene the texture should be created in
  63165. * @param rootUrl Define the root url in case we need to load relative dependencies
  63166. * @returns the newly created texture after parsing
  63167. */
  63168. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<HDRCubeTexture>;
  63169. serialize(): any;
  63170. }
  63171. }
  63172. declare module "babylonjs/Physics/physicsEngine" {
  63173. import { Nullable } from "babylonjs/types";
  63174. import { Vector3 } from "babylonjs/Maths/math.vector";
  63175. import { IPhysicsEngine, IPhysicsEnginePlugin } from "babylonjs/Physics/IPhysicsEngine";
  63176. import { PhysicsImpostor, IPhysicsEnabledObject } from "babylonjs/Physics/physicsImpostor";
  63177. import { PhysicsJoint } from "babylonjs/Physics/physicsJoint";
  63178. import { PhysicsRaycastResult } from "babylonjs/Physics/physicsRaycastResult";
  63179. /**
  63180. * Class used to control physics engine
  63181. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  63182. */
  63183. export class PhysicsEngine implements IPhysicsEngine {
  63184. private _physicsPlugin;
  63185. /**
  63186. * Global value used to control the smallest number supported by the simulation
  63187. */
  63188. static Epsilon: number;
  63189. private _impostors;
  63190. private _joints;
  63191. private _subTimeStep;
  63192. /**
  63193. * Gets the gravity vector used by the simulation
  63194. */
  63195. gravity: Vector3;
  63196. /**
  63197. * Factory used to create the default physics plugin.
  63198. * @returns The default physics plugin
  63199. */
  63200. static DefaultPluginFactory(): IPhysicsEnginePlugin;
  63201. /**
  63202. * Creates a new Physics Engine
  63203. * @param gravity defines the gravity vector used by the simulation
  63204. * @param _physicsPlugin defines the plugin to use (CannonJS by default)
  63205. */
  63206. constructor(gravity: Nullable<Vector3>, _physicsPlugin?: IPhysicsEnginePlugin);
  63207. /**
  63208. * Sets the gravity vector used by the simulation
  63209. * @param gravity defines the gravity vector to use
  63210. */
  63211. setGravity(gravity: Vector3): void;
  63212. /**
  63213. * Set the time step of the physics engine.
  63214. * Default is 1/60.
  63215. * To slow it down, enter 1/600 for example.
  63216. * To speed it up, 1/30
  63217. * @param newTimeStep defines the new timestep to apply to this world.
  63218. */
  63219. setTimeStep(newTimeStep?: number): void;
  63220. /**
  63221. * Get the time step of the physics engine.
  63222. * @returns the current time step
  63223. */
  63224. getTimeStep(): number;
  63225. /**
  63226. * Set the sub time step of the physics engine.
  63227. * Default is 0 meaning there is no sub steps
  63228. * To increase physics resolution precision, set a small value (like 1 ms)
  63229. * @param subTimeStep defines the new sub timestep used for physics resolution.
  63230. */
  63231. setSubTimeStep(subTimeStep?: number): void;
  63232. /**
  63233. * Get the sub time step of the physics engine.
  63234. * @returns the current sub time step
  63235. */
  63236. getSubTimeStep(): number;
  63237. /**
  63238. * Release all resources
  63239. */
  63240. dispose(): void;
  63241. /**
  63242. * Gets the name of the current physics plugin
  63243. * @returns the name of the plugin
  63244. */
  63245. getPhysicsPluginName(): string;
  63246. /**
  63247. * Adding a new impostor for the impostor tracking.
  63248. * This will be done by the impostor itself.
  63249. * @param impostor the impostor to add
  63250. */
  63251. addImpostor(impostor: PhysicsImpostor): void;
  63252. /**
  63253. * Remove an impostor from the engine.
  63254. * This impostor and its mesh will not longer be updated by the physics engine.
  63255. * @param impostor the impostor to remove
  63256. */
  63257. removeImpostor(impostor: PhysicsImpostor): void;
  63258. /**
  63259. * Add a joint to the physics engine
  63260. * @param mainImpostor defines the main impostor to which the joint is added.
  63261. * @param connectedImpostor defines the impostor that is connected to the main impostor using this joint
  63262. * @param joint defines the joint that will connect both impostors.
  63263. */
  63264. addJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  63265. /**
  63266. * Removes a joint from the simulation
  63267. * @param mainImpostor defines the impostor used with the joint
  63268. * @param connectedImpostor defines the other impostor connected to the main one by the joint
  63269. * @param joint defines the joint to remove
  63270. */
  63271. removeJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  63272. /**
  63273. * Called by the scene. No need to call it.
  63274. * @param delta defines the timespam between frames
  63275. */
  63276. _step(delta: number): void;
  63277. /**
  63278. * Gets the current plugin used to run the simulation
  63279. * @returns current plugin
  63280. */
  63281. getPhysicsPlugin(): IPhysicsEnginePlugin;
  63282. /**
  63283. * Gets the list of physic impostors
  63284. * @returns an array of PhysicsImpostor
  63285. */
  63286. getImpostors(): Array<PhysicsImpostor>;
  63287. /**
  63288. * Gets the impostor for a physics enabled object
  63289. * @param object defines the object impersonated by the impostor
  63290. * @returns the PhysicsImpostor or null if not found
  63291. */
  63292. getImpostorForPhysicsObject(object: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  63293. /**
  63294. * Gets the impostor for a physics body object
  63295. * @param body defines physics body used by the impostor
  63296. * @returns the PhysicsImpostor or null if not found
  63297. */
  63298. getImpostorWithPhysicsBody(body: any): Nullable<PhysicsImpostor>;
  63299. /**
  63300. * Does a raycast in the physics world
  63301. * @param from when should the ray start?
  63302. * @param to when should the ray end?
  63303. * @returns PhysicsRaycastResult
  63304. */
  63305. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  63306. }
  63307. }
  63308. declare module "babylonjs/Physics/Plugins/cannonJSPlugin" {
  63309. import { Nullable } from "babylonjs/types";
  63310. import { Vector3, Quaternion } from "babylonjs/Maths/math.vector";
  63311. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  63312. import { IPhysicsEnginePlugin, PhysicsImpostorJoint } from "babylonjs/Physics/IPhysicsEngine";
  63313. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  63314. import { PhysicsJoint, IMotorEnabledJoint } from "babylonjs/Physics/physicsJoint";
  63315. import { PhysicsRaycastResult } from "babylonjs/Physics/physicsRaycastResult";
  63316. /** @hidden */
  63317. export class CannonJSPlugin implements IPhysicsEnginePlugin {
  63318. private _useDeltaForWorldStep;
  63319. world: any;
  63320. name: string;
  63321. private _physicsMaterials;
  63322. private _fixedTimeStep;
  63323. private _cannonRaycastResult;
  63324. private _raycastResult;
  63325. private _physicsBodysToRemoveAfterStep;
  63326. private _firstFrame;
  63327. BJSCANNON: any;
  63328. constructor(_useDeltaForWorldStep?: boolean, iterations?: number, cannonInjection?: any);
  63329. setGravity(gravity: Vector3): void;
  63330. setTimeStep(timeStep: number): void;
  63331. getTimeStep(): number;
  63332. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  63333. private _removeMarkedPhysicsBodiesFromWorld;
  63334. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  63335. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  63336. generatePhysicsBody(impostor: PhysicsImpostor): void;
  63337. private _processChildMeshes;
  63338. removePhysicsBody(impostor: PhysicsImpostor): void;
  63339. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  63340. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  63341. private _addMaterial;
  63342. private _checkWithEpsilon;
  63343. private _createShape;
  63344. private _createHeightmap;
  63345. private _minus90X;
  63346. private _plus90X;
  63347. private _tmpPosition;
  63348. private _tmpDeltaPosition;
  63349. private _tmpUnityRotation;
  63350. private _updatePhysicsBodyTransformation;
  63351. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  63352. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  63353. isSupported(): boolean;
  63354. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  63355. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  63356. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  63357. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  63358. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  63359. getBodyMass(impostor: PhysicsImpostor): number;
  63360. getBodyFriction(impostor: PhysicsImpostor): number;
  63361. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  63362. getBodyRestitution(impostor: PhysicsImpostor): number;
  63363. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  63364. sleepBody(impostor: PhysicsImpostor): void;
  63365. wakeUpBody(impostor: PhysicsImpostor): void;
  63366. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number): void;
  63367. setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number): void;
  63368. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number): void;
  63369. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  63370. getRadius(impostor: PhysicsImpostor): number;
  63371. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  63372. dispose(): void;
  63373. private _extendNamespace;
  63374. /**
  63375. * Does a raycast in the physics world
  63376. * @param from when should the ray start?
  63377. * @param to when should the ray end?
  63378. * @returns PhysicsRaycastResult
  63379. */
  63380. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  63381. }
  63382. }
  63383. declare module "babylonjs/Physics/Plugins/oimoJSPlugin" {
  63384. import { IPhysicsEnginePlugin, PhysicsImpostorJoint } from "babylonjs/Physics/IPhysicsEngine";
  63385. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  63386. import { PhysicsJoint, IMotorEnabledJoint } from "babylonjs/Physics/physicsJoint";
  63387. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  63388. import { Vector3, Quaternion } from "babylonjs/Maths/math.vector";
  63389. import { Nullable } from "babylonjs/types";
  63390. import { PhysicsRaycastResult } from "babylonjs/Physics/physicsRaycastResult";
  63391. /** @hidden */
  63392. export class OimoJSPlugin implements IPhysicsEnginePlugin {
  63393. private _useDeltaForWorldStep;
  63394. world: any;
  63395. name: string;
  63396. BJSOIMO: any;
  63397. private _raycastResult;
  63398. private _fixedTimeStep;
  63399. constructor(_useDeltaForWorldStep?: boolean, iterations?: number, oimoInjection?: any);
  63400. setGravity(gravity: Vector3): void;
  63401. setTimeStep(timeStep: number): void;
  63402. getTimeStep(): number;
  63403. private _tmpImpostorsArray;
  63404. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  63405. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  63406. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  63407. generatePhysicsBody(impostor: PhysicsImpostor): void;
  63408. private _tmpPositionVector;
  63409. removePhysicsBody(impostor: PhysicsImpostor): void;
  63410. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  63411. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  63412. isSupported(): boolean;
  63413. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  63414. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  63415. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  63416. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  63417. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  63418. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  63419. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  63420. getBodyMass(impostor: PhysicsImpostor): number;
  63421. getBodyFriction(impostor: PhysicsImpostor): number;
  63422. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  63423. getBodyRestitution(impostor: PhysicsImpostor): number;
  63424. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  63425. sleepBody(impostor: PhysicsImpostor): void;
  63426. wakeUpBody(impostor: PhysicsImpostor): void;
  63427. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  63428. setMotor(joint: IMotorEnabledJoint, speed: number, force?: number, motorIndex?: number): void;
  63429. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  63430. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  63431. getRadius(impostor: PhysicsImpostor): number;
  63432. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  63433. dispose(): void;
  63434. /**
  63435. * Does a raycast in the physics world
  63436. * @param from when should the ray start?
  63437. * @param to when should the ray end?
  63438. * @returns PhysicsRaycastResult
  63439. */
  63440. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  63441. }
  63442. }
  63443. declare module "babylonjs/Physics/Plugins/ammoJSPlugin" {
  63444. import { Quaternion, Vector3 } from "babylonjs/Maths/math.vector";
  63445. import { IPhysicsEnginePlugin, PhysicsImpostorJoint } from "babylonjs/Physics/IPhysicsEngine";
  63446. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  63447. import { PhysicsJoint, IMotorEnabledJoint } from "babylonjs/Physics/physicsJoint";
  63448. import { Nullable } from "babylonjs/types";
  63449. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  63450. import { PhysicsRaycastResult } from "babylonjs/Physics/physicsRaycastResult";
  63451. /**
  63452. * AmmoJS Physics plugin
  63453. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  63454. * @see https://github.com/kripken/ammo.js/
  63455. */
  63456. export class AmmoJSPlugin implements IPhysicsEnginePlugin {
  63457. private _useDeltaForWorldStep;
  63458. /**
  63459. * Reference to the Ammo library
  63460. */
  63461. bjsAMMO: any;
  63462. /**
  63463. * Created ammoJS world which physics bodies are added to
  63464. */
  63465. world: any;
  63466. /**
  63467. * Name of the plugin
  63468. */
  63469. name: string;
  63470. private _timeStep;
  63471. private _fixedTimeStep;
  63472. private _maxSteps;
  63473. private _tmpQuaternion;
  63474. private _tmpAmmoTransform;
  63475. private _tmpAmmoQuaternion;
  63476. private _tmpAmmoConcreteContactResultCallback;
  63477. private _collisionConfiguration;
  63478. private _dispatcher;
  63479. private _overlappingPairCache;
  63480. private _solver;
  63481. private _softBodySolver;
  63482. private _tmpAmmoVectorA;
  63483. private _tmpAmmoVectorB;
  63484. private _tmpAmmoVectorC;
  63485. private _tmpAmmoVectorD;
  63486. private _tmpContactCallbackResult;
  63487. private _tmpAmmoVectorRCA;
  63488. private _tmpAmmoVectorRCB;
  63489. private _raycastResult;
  63490. private static readonly DISABLE_COLLISION_FLAG;
  63491. private static readonly KINEMATIC_FLAG;
  63492. private static readonly DISABLE_DEACTIVATION_FLAG;
  63493. /**
  63494. * Initializes the ammoJS plugin
  63495. * @param _useDeltaForWorldStep if the time between frames should be used when calculating physics steps (Default: true)
  63496. * @param ammoInjection can be used to inject your own ammo reference
  63497. * @param overlappingPairCache can be used to specify your own overlapping pair cache
  63498. */
  63499. constructor(_useDeltaForWorldStep?: boolean, ammoInjection?: any, overlappingPairCache?: any);
  63500. /**
  63501. * Sets the gravity of the physics world (m/(s^2))
  63502. * @param gravity Gravity to set
  63503. */
  63504. setGravity(gravity: Vector3): void;
  63505. /**
  63506. * Amount of time to step forward on each frame (only used if useDeltaForWorldStep is false in the constructor)
  63507. * @param timeStep timestep to use in seconds
  63508. */
  63509. setTimeStep(timeStep: number): void;
  63510. /**
  63511. * 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)
  63512. * @param fixedTimeStep fixedTimeStep to use in seconds
  63513. */
  63514. setFixedTimeStep(fixedTimeStep: number): void;
  63515. /**
  63516. * Sets the maximum number of steps by the physics engine per frame (Default: 5)
  63517. * @param maxSteps the maximum number of steps by the physics engine per frame
  63518. */
  63519. setMaxSteps(maxSteps: number): void;
  63520. /**
  63521. * Gets the current timestep (only used if useDeltaForWorldStep is false in the constructor)
  63522. * @returns the current timestep in seconds
  63523. */
  63524. getTimeStep(): number;
  63525. /**
  63526. * The create custom shape handler function to be called when using BABYLON.PhysicsImposter.CustomImpostor
  63527. */
  63528. onCreateCustomShape: (impostor: PhysicsImpostor) => any;
  63529. private _isImpostorInContact;
  63530. private _isImpostorPairInContact;
  63531. private _stepSimulation;
  63532. /**
  63533. * Moves the physics simulation forward delta seconds and updates the given physics imposters
  63534. * Prior to the step the imposters physics location is set to the position of the babylon meshes
  63535. * After the step the babylon meshes are set to the position of the physics imposters
  63536. * @param delta amount of time to step forward
  63537. * @param impostors array of imposters to update before/after the step
  63538. */
  63539. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  63540. /**
  63541. * Update babylon mesh to match physics world object
  63542. * @param impostor imposter to match
  63543. */
  63544. private _afterSoftStep;
  63545. /**
  63546. * Update babylon mesh vertices vertices to match physics world softbody or cloth
  63547. * @param impostor imposter to match
  63548. */
  63549. private _ropeStep;
  63550. /**
  63551. * Update babylon mesh vertices vertices to match physics world softbody or cloth
  63552. * @param impostor imposter to match
  63553. */
  63554. private _softbodyOrClothStep;
  63555. private _tmpMatrix;
  63556. /**
  63557. * Applies an impulse on the imposter
  63558. * @param impostor imposter to apply impulse to
  63559. * @param force amount of force to be applied to the imposter
  63560. * @param contactPoint the location to apply the impulse on the imposter
  63561. */
  63562. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  63563. /**
  63564. * Applies a force on the imposter
  63565. * @param impostor imposter to apply force
  63566. * @param force amount of force to be applied to the imposter
  63567. * @param contactPoint the location to apply the force on the imposter
  63568. */
  63569. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  63570. /**
  63571. * Creates a physics body using the plugin
  63572. * @param impostor the imposter to create the physics body on
  63573. */
  63574. generatePhysicsBody(impostor: PhysicsImpostor): void;
  63575. /**
  63576. * Removes the physics body from the imposter and disposes of the body's memory
  63577. * @param impostor imposter to remove the physics body from
  63578. */
  63579. removePhysicsBody(impostor: PhysicsImpostor): void;
  63580. /**
  63581. * Generates a joint
  63582. * @param impostorJoint the imposter joint to create the joint with
  63583. */
  63584. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  63585. /**
  63586. * Removes a joint
  63587. * @param impostorJoint the imposter joint to remove the joint from
  63588. */
  63589. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  63590. private _addMeshVerts;
  63591. /**
  63592. * Initialise the soft body vertices to match its object's (mesh) vertices
  63593. * Softbody vertices (nodes) are in world space and to match this
  63594. * The object's position and rotation is set to zero and so its vertices are also then set in world space
  63595. * @param impostor to create the softbody for
  63596. */
  63597. private _softVertexData;
  63598. /**
  63599. * Create an impostor's soft body
  63600. * @param impostor to create the softbody for
  63601. */
  63602. private _createSoftbody;
  63603. /**
  63604. * Create cloth for an impostor
  63605. * @param impostor to create the softbody for
  63606. */
  63607. private _createCloth;
  63608. /**
  63609. * Create rope for an impostor
  63610. * @param impostor to create the softbody for
  63611. */
  63612. private _createRope;
  63613. /**
  63614. * Create a custom physics impostor shape using the plugin's onCreateCustomShape handler
  63615. * @param impostor to create the custom physics shape for
  63616. */
  63617. private _createCustom;
  63618. private _addHullVerts;
  63619. private _createShape;
  63620. /**
  63621. * Sets the physics body position/rotation from the babylon mesh's position/rotation
  63622. * @param impostor imposter containing the physics body and babylon object
  63623. */
  63624. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  63625. /**
  63626. * Sets the babylon object's position/rotation from the physics body's position/rotation
  63627. * @param impostor imposter containing the physics body and babylon object
  63628. * @param newPosition new position
  63629. * @param newRotation new rotation
  63630. */
  63631. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  63632. /**
  63633. * If this plugin is supported
  63634. * @returns true if its supported
  63635. */
  63636. isSupported(): boolean;
  63637. /**
  63638. * Sets the linear velocity of the physics body
  63639. * @param impostor imposter to set the velocity on
  63640. * @param velocity velocity to set
  63641. */
  63642. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  63643. /**
  63644. * Sets the angular velocity of the physics body
  63645. * @param impostor imposter to set the velocity on
  63646. * @param velocity velocity to set
  63647. */
  63648. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  63649. /**
  63650. * gets the linear velocity
  63651. * @param impostor imposter to get linear velocity from
  63652. * @returns linear velocity
  63653. */
  63654. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  63655. /**
  63656. * gets the angular velocity
  63657. * @param impostor imposter to get angular velocity from
  63658. * @returns angular velocity
  63659. */
  63660. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  63661. /**
  63662. * Sets the mass of physics body
  63663. * @param impostor imposter to set the mass on
  63664. * @param mass mass to set
  63665. */
  63666. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  63667. /**
  63668. * Gets the mass of the physics body
  63669. * @param impostor imposter to get the mass from
  63670. * @returns mass
  63671. */
  63672. getBodyMass(impostor: PhysicsImpostor): number;
  63673. /**
  63674. * Gets friction of the impostor
  63675. * @param impostor impostor to get friction from
  63676. * @returns friction value
  63677. */
  63678. getBodyFriction(impostor: PhysicsImpostor): number;
  63679. /**
  63680. * Sets friction of the impostor
  63681. * @param impostor impostor to set friction on
  63682. * @param friction friction value
  63683. */
  63684. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  63685. /**
  63686. * Gets restitution of the impostor
  63687. * @param impostor impostor to get restitution from
  63688. * @returns restitution value
  63689. */
  63690. getBodyRestitution(impostor: PhysicsImpostor): number;
  63691. /**
  63692. * Sets resitution of the impostor
  63693. * @param impostor impostor to set resitution on
  63694. * @param restitution resitution value
  63695. */
  63696. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  63697. /**
  63698. * Gets pressure inside the impostor
  63699. * @param impostor impostor to get pressure from
  63700. * @returns pressure value
  63701. */
  63702. getBodyPressure(impostor: PhysicsImpostor): number;
  63703. /**
  63704. * Sets pressure inside a soft body impostor
  63705. * Cloth and rope must remain 0 pressure
  63706. * @param impostor impostor to set pressure on
  63707. * @param pressure pressure value
  63708. */
  63709. setBodyPressure(impostor: PhysicsImpostor, pressure: number): void;
  63710. /**
  63711. * Gets stiffness of the impostor
  63712. * @param impostor impostor to get stiffness from
  63713. * @returns pressure value
  63714. */
  63715. getBodyStiffness(impostor: PhysicsImpostor): number;
  63716. /**
  63717. * Sets stiffness of the impostor
  63718. * @param impostor impostor to set stiffness on
  63719. * @param stiffness stiffness value from 0 to 1
  63720. */
  63721. setBodyStiffness(impostor: PhysicsImpostor, stiffness: number): void;
  63722. /**
  63723. * Gets velocityIterations of the impostor
  63724. * @param impostor impostor to get velocity iterations from
  63725. * @returns velocityIterations value
  63726. */
  63727. getBodyVelocityIterations(impostor: PhysicsImpostor): number;
  63728. /**
  63729. * Sets velocityIterations of the impostor
  63730. * @param impostor impostor to set velocity iterations on
  63731. * @param velocityIterations velocityIterations value
  63732. */
  63733. setBodyVelocityIterations(impostor: PhysicsImpostor, velocityIterations: number): void;
  63734. /**
  63735. * Gets positionIterations of the impostor
  63736. * @param impostor impostor to get position iterations from
  63737. * @returns positionIterations value
  63738. */
  63739. getBodyPositionIterations(impostor: PhysicsImpostor): number;
  63740. /**
  63741. * Sets positionIterations of the impostor
  63742. * @param impostor impostor to set position on
  63743. * @param positionIterations positionIterations value
  63744. */
  63745. setBodyPositionIterations(impostor: PhysicsImpostor, positionIterations: number): void;
  63746. /**
  63747. * Append an anchor to a cloth object
  63748. * @param impostor is the cloth impostor to add anchor to
  63749. * @param otherImpostor is the rigid impostor to anchor to
  63750. * @param width ratio across width from 0 to 1
  63751. * @param height ratio up height from 0 to 1
  63752. * @param influence the elasticity between cloth impostor and anchor from 0, very stretchy to 1, little strech
  63753. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  63754. */
  63755. appendAnchor(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, width: number, height: number, influence?: number, noCollisionBetweenLinkedBodies?: boolean): void;
  63756. /**
  63757. * Append an hook to a rope object
  63758. * @param impostor is the rope impostor to add hook to
  63759. * @param otherImpostor is the rigid impostor to hook to
  63760. * @param length ratio along the rope from 0 to 1
  63761. * @param influence the elasticity between soft impostor and anchor from 0, very stretchy to 1, little strech
  63762. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  63763. */
  63764. appendHook(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, length: number, influence?: number, noCollisionBetweenLinkedBodies?: boolean): void;
  63765. /**
  63766. * Sleeps the physics body and stops it from being active
  63767. * @param impostor impostor to sleep
  63768. */
  63769. sleepBody(impostor: PhysicsImpostor): void;
  63770. /**
  63771. * Activates the physics body
  63772. * @param impostor impostor to activate
  63773. */
  63774. wakeUpBody(impostor: PhysicsImpostor): void;
  63775. /**
  63776. * Updates the distance parameters of the joint
  63777. * @param joint joint to update
  63778. * @param maxDistance maximum distance of the joint
  63779. * @param minDistance minimum distance of the joint
  63780. */
  63781. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  63782. /**
  63783. * Sets a motor on the joint
  63784. * @param joint joint to set motor on
  63785. * @param speed speed of the motor
  63786. * @param maxForce maximum force of the motor
  63787. * @param motorIndex index of the motor
  63788. */
  63789. setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number): void;
  63790. /**
  63791. * Sets the motors limit
  63792. * @param joint joint to set limit on
  63793. * @param upperLimit upper limit
  63794. * @param lowerLimit lower limit
  63795. */
  63796. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number): void;
  63797. /**
  63798. * Syncs the position and rotation of a mesh with the impostor
  63799. * @param mesh mesh to sync
  63800. * @param impostor impostor to update the mesh with
  63801. */
  63802. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  63803. /**
  63804. * Gets the radius of the impostor
  63805. * @param impostor impostor to get radius from
  63806. * @returns the radius
  63807. */
  63808. getRadius(impostor: PhysicsImpostor): number;
  63809. /**
  63810. * Gets the box size of the impostor
  63811. * @param impostor impostor to get box size from
  63812. * @param result the resulting box size
  63813. */
  63814. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  63815. /**
  63816. * Disposes of the impostor
  63817. */
  63818. dispose(): void;
  63819. /**
  63820. * Does a raycast in the physics world
  63821. * @param from when should the ray start?
  63822. * @param to when should the ray end?
  63823. * @returns PhysicsRaycastResult
  63824. */
  63825. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  63826. }
  63827. }
  63828. declare module "babylonjs/Probes/reflectionProbe" {
  63829. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  63830. import { Vector3 } from "babylonjs/Maths/math.vector";
  63831. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  63832. import { Nullable } from "babylonjs/types";
  63833. import { Scene } from "babylonjs/scene";
  63834. module "babylonjs/abstractScene" {
  63835. interface AbstractScene {
  63836. /**
  63837. * The list of reflection probes added to the scene
  63838. * @see https://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  63839. */
  63840. reflectionProbes: Array<ReflectionProbe>;
  63841. /**
  63842. * Removes the given reflection probe from this scene.
  63843. * @param toRemove The reflection probe to remove
  63844. * @returns The index of the removed reflection probe
  63845. */
  63846. removeReflectionProbe(toRemove: ReflectionProbe): number;
  63847. /**
  63848. * Adds the given reflection probe to this scene.
  63849. * @param newReflectionProbe The reflection probe to add
  63850. */
  63851. addReflectionProbe(newReflectionProbe: ReflectionProbe): void;
  63852. }
  63853. }
  63854. /**
  63855. * Class used to generate realtime reflection / refraction cube textures
  63856. * @see https://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  63857. */
  63858. export class ReflectionProbe {
  63859. /** defines the name of the probe */
  63860. name: string;
  63861. private _scene;
  63862. private _renderTargetTexture;
  63863. private _projectionMatrix;
  63864. private _viewMatrix;
  63865. private _target;
  63866. private _add;
  63867. private _attachedMesh;
  63868. private _invertYAxis;
  63869. /** Gets or sets probe position (center of the cube map) */
  63870. position: Vector3;
  63871. /**
  63872. * Creates a new reflection probe
  63873. * @param name defines the name of the probe
  63874. * @param size defines the texture resolution (for each face)
  63875. * @param scene defines the hosting scene
  63876. * @param generateMipMaps defines if mip maps should be generated automatically (true by default)
  63877. * @param useFloat defines if HDR data (flaot data) should be used to store colors (false by default)
  63878. */
  63879. constructor(
  63880. /** defines the name of the probe */
  63881. name: string, size: number, scene: Scene, generateMipMaps?: boolean, useFloat?: boolean);
  63882. /** Gets or sets the number of samples to use for multi-sampling (0 by default). Required WebGL2 */
  63883. get samples(): number;
  63884. set samples(value: number);
  63885. /** Gets or sets the refresh rate to use (on every frame by default) */
  63886. get refreshRate(): number;
  63887. set refreshRate(value: number);
  63888. /**
  63889. * Gets the hosting scene
  63890. * @returns a Scene
  63891. */
  63892. getScene(): Scene;
  63893. /** Gets the internal CubeTexture used to render to */
  63894. get cubeTexture(): RenderTargetTexture;
  63895. /** Gets the list of meshes to render */
  63896. get renderList(): Nullable<AbstractMesh[]>;
  63897. /**
  63898. * Attach the probe to a specific mesh (Rendering will be done from attached mesh's position)
  63899. * @param mesh defines the mesh to attach to
  63900. */
  63901. attachToMesh(mesh: Nullable<AbstractMesh>): void;
  63902. /**
  63903. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups
  63904. * @param renderingGroupId The rendering group id corresponding to its index
  63905. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  63906. */
  63907. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  63908. /**
  63909. * Clean all associated resources
  63910. */
  63911. dispose(): void;
  63912. /**
  63913. * Converts the reflection probe information to a readable string for debug purpose.
  63914. * @param fullDetails Supports for multiple levels of logging within scene loading
  63915. * @returns the human readable reflection probe info
  63916. */
  63917. toString(fullDetails?: boolean): string;
  63918. /**
  63919. * Get the class name of the relfection probe.
  63920. * @returns "ReflectionProbe"
  63921. */
  63922. getClassName(): string;
  63923. /**
  63924. * Serialize the reflection probe to a JSON representation we can easily use in the resepective Parse function.
  63925. * @returns The JSON representation of the texture
  63926. */
  63927. serialize(): any;
  63928. /**
  63929. * Parse the JSON representation of a reflection probe in order to recreate the reflection probe in the given scene.
  63930. * @param parsedReflectionProbe Define the JSON representation of the reflection probe
  63931. * @param scene Define the scene the parsed reflection probe should be instantiated in
  63932. * @param rootUrl Define the root url of the parsing sequence in the case of relative dependencies
  63933. * @returns The parsed reflection probe if successful
  63934. */
  63935. static Parse(parsedReflectionProbe: any, scene: Scene, rootUrl: string): Nullable<ReflectionProbe>;
  63936. }
  63937. }
  63938. declare module "babylonjs/Loading/Plugins/babylonFileLoader" {
  63939. /** @hidden */
  63940. export var _BabylonLoaderRegistered: boolean;
  63941. /**
  63942. * Helps setting up some configuration for the babylon file loader.
  63943. */
  63944. export class BabylonFileLoaderConfiguration {
  63945. /**
  63946. * The loader does not allow injecting custom physix engine into the plugins.
  63947. * Unfortunately in ES6, we need to manually inject them into the plugin.
  63948. * So you could set this variable to your engine import to make it work.
  63949. */
  63950. static LoaderInjectedPhysicsEngine: any;
  63951. }
  63952. }
  63953. declare module "babylonjs/Loading/Plugins/index" {
  63954. export * from "babylonjs/Loading/Plugins/babylonFileLoader";
  63955. }
  63956. declare module "babylonjs/Loading/index" {
  63957. export * from "babylonjs/Loading/loadingScreen";
  63958. export * from "babylonjs/Loading/Plugins/index";
  63959. export * from "babylonjs/Loading/sceneLoader";
  63960. export * from "babylonjs/Loading/sceneLoaderFlags";
  63961. }
  63962. declare module "babylonjs/Materials/Background/index" {
  63963. export * from "babylonjs/Materials/Background/backgroundMaterial";
  63964. }
  63965. declare module "babylonjs/Materials/PBR/pbrBaseSimpleMaterial" {
  63966. import { Scene } from "babylonjs/scene";
  63967. import { Color3 } from "babylonjs/Maths/math.color";
  63968. import { PBRBaseMaterial } from "babylonjs/Materials/PBR/pbrBaseMaterial";
  63969. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  63970. /**
  63971. * The Physically based simple base material of BJS.
  63972. *
  63973. * This enables better naming and convention enforcements on top of the pbrMaterial.
  63974. * It is used as the base class for both the specGloss and metalRough conventions.
  63975. */
  63976. export abstract class PBRBaseSimpleMaterial extends PBRBaseMaterial {
  63977. /**
  63978. * Number of Simultaneous lights allowed on the material.
  63979. */
  63980. maxSimultaneousLights: number;
  63981. /**
  63982. * If sets to true, disables all the lights affecting the material.
  63983. */
  63984. disableLighting: boolean;
  63985. /**
  63986. * Environment Texture used in the material (this is use for both reflection and environment lighting).
  63987. */
  63988. environmentTexture: BaseTexture;
  63989. /**
  63990. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  63991. */
  63992. invertNormalMapX: boolean;
  63993. /**
  63994. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  63995. */
  63996. invertNormalMapY: boolean;
  63997. /**
  63998. * Normal map used in the model.
  63999. */
  64000. normalTexture: BaseTexture;
  64001. /**
  64002. * Emissivie color used to self-illuminate the model.
  64003. */
  64004. emissiveColor: Color3;
  64005. /**
  64006. * Emissivie texture used to self-illuminate the model.
  64007. */
  64008. emissiveTexture: BaseTexture;
  64009. /**
  64010. * Occlusion Channel Strenght.
  64011. */
  64012. occlusionStrength: number;
  64013. /**
  64014. * Occlusion Texture of the material (adding extra occlusion effects).
  64015. */
  64016. occlusionTexture: BaseTexture;
  64017. /**
  64018. * Defines the alpha limits in alpha test mode.
  64019. */
  64020. alphaCutOff: number;
  64021. /**
  64022. * Gets the current double sided mode.
  64023. */
  64024. get doubleSided(): boolean;
  64025. /**
  64026. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  64027. */
  64028. set doubleSided(value: boolean);
  64029. /**
  64030. * Stores the pre-calculated light information of a mesh in a texture.
  64031. */
  64032. lightmapTexture: BaseTexture;
  64033. /**
  64034. * If true, the light map contains occlusion information instead of lighting info.
  64035. */
  64036. useLightmapAsShadowmap: boolean;
  64037. /**
  64038. * Instantiates a new PBRMaterial instance.
  64039. *
  64040. * @param name The material name
  64041. * @param scene The scene the material will be use in.
  64042. */
  64043. constructor(name: string, scene: Scene);
  64044. getClassName(): string;
  64045. }
  64046. }
  64047. declare module "babylonjs/Materials/PBR/pbrMetallicRoughnessMaterial" {
  64048. import { Scene } from "babylonjs/scene";
  64049. import { Color3 } from "babylonjs/Maths/math.color";
  64050. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  64051. import { PBRBaseSimpleMaterial } from "babylonjs/Materials/PBR/pbrBaseSimpleMaterial";
  64052. /**
  64053. * The PBR material of BJS following the metal roughness convention.
  64054. *
  64055. * This fits to the PBR convention in the GLTF definition:
  64056. * https://github.com/KhronosGroup/glTF/tree/2.0/specification/2.0
  64057. */
  64058. export class PBRMetallicRoughnessMaterial extends PBRBaseSimpleMaterial {
  64059. /**
  64060. * The base color has two different interpretations depending on the value of metalness.
  64061. * When the material is a metal, the base color is the specific measured reflectance value
  64062. * at normal incidence (F0). For a non-metal the base color represents the reflected diffuse color
  64063. * of the material.
  64064. */
  64065. baseColor: Color3;
  64066. /**
  64067. * Base texture of the metallic workflow. It contains both the baseColor information in RGB as
  64068. * well as opacity information in the alpha channel.
  64069. */
  64070. baseTexture: BaseTexture;
  64071. /**
  64072. * Specifies the metallic scalar value of the material.
  64073. * Can also be used to scale the metalness values of the metallic texture.
  64074. */
  64075. metallic: number;
  64076. /**
  64077. * Specifies the roughness scalar value of the material.
  64078. * Can also be used to scale the roughness values of the metallic texture.
  64079. */
  64080. roughness: number;
  64081. /**
  64082. * Texture containing both the metallic value in the B channel and the
  64083. * roughness value in the G channel to keep better precision.
  64084. */
  64085. metallicRoughnessTexture: BaseTexture;
  64086. /**
  64087. * Instantiates a new PBRMetalRoughnessMaterial instance.
  64088. *
  64089. * @param name The material name
  64090. * @param scene The scene the material will be use in.
  64091. */
  64092. constructor(name: string, scene: Scene);
  64093. /**
  64094. * Return the currrent class name of the material.
  64095. */
  64096. getClassName(): string;
  64097. /**
  64098. * Makes a duplicate of the current material.
  64099. * @param name - name to use for the new material.
  64100. */
  64101. clone(name: string): PBRMetallicRoughnessMaterial;
  64102. /**
  64103. * Serialize the material to a parsable JSON object.
  64104. */
  64105. serialize(): any;
  64106. /**
  64107. * Parses a JSON object correponding to the serialize function.
  64108. */
  64109. static Parse(source: any, scene: Scene, rootUrl: string): PBRMetallicRoughnessMaterial;
  64110. }
  64111. }
  64112. declare module "babylonjs/Materials/PBR/pbrSpecularGlossinessMaterial" {
  64113. import { Scene } from "babylonjs/scene";
  64114. import { Color3 } from "babylonjs/Maths/math.color";
  64115. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  64116. import { PBRBaseSimpleMaterial } from "babylonjs/Materials/PBR/pbrBaseSimpleMaterial";
  64117. /**
  64118. * The PBR material of BJS following the specular glossiness convention.
  64119. *
  64120. * This fits to the PBR convention in the GLTF definition:
  64121. * https://github.com/KhronosGroup/glTF/tree/2.0/extensions/Khronos/KHR_materials_pbrSpecularGlossiness
  64122. */
  64123. export class PBRSpecularGlossinessMaterial extends PBRBaseSimpleMaterial {
  64124. /**
  64125. * Specifies the diffuse color of the material.
  64126. */
  64127. diffuseColor: Color3;
  64128. /**
  64129. * Specifies the diffuse texture of the material. This can also contains the opcity value in its alpha
  64130. * channel.
  64131. */
  64132. diffuseTexture: BaseTexture;
  64133. /**
  64134. * Specifies the specular color of the material. This indicates how reflective is the material (none to mirror).
  64135. */
  64136. specularColor: Color3;
  64137. /**
  64138. * Specifies the glossiness of the material. This indicates "how sharp is the reflection".
  64139. */
  64140. glossiness: number;
  64141. /**
  64142. * Specifies both the specular color RGB and the glossiness A of the material per pixels.
  64143. */
  64144. specularGlossinessTexture: BaseTexture;
  64145. /**
  64146. * Instantiates a new PBRSpecularGlossinessMaterial instance.
  64147. *
  64148. * @param name The material name
  64149. * @param scene The scene the material will be use in.
  64150. */
  64151. constructor(name: string, scene: Scene);
  64152. /**
  64153. * Return the currrent class name of the material.
  64154. */
  64155. getClassName(): string;
  64156. /**
  64157. * Makes a duplicate of the current material.
  64158. * @param name - name to use for the new material.
  64159. */
  64160. clone(name: string): PBRSpecularGlossinessMaterial;
  64161. /**
  64162. * Serialize the material to a parsable JSON object.
  64163. */
  64164. serialize(): any;
  64165. /**
  64166. * Parses a JSON object correponding to the serialize function.
  64167. */
  64168. static Parse(source: any, scene: Scene, rootUrl: string): PBRSpecularGlossinessMaterial;
  64169. }
  64170. }
  64171. declare module "babylonjs/Materials/PBR/index" {
  64172. export * from "babylonjs/Materials/PBR/pbrBaseMaterial";
  64173. export * from "babylonjs/Materials/PBR/pbrBaseSimpleMaterial";
  64174. export * from "babylonjs/Materials/PBR/pbrMaterial";
  64175. export * from "babylonjs/Materials/PBR/pbrMetallicRoughnessMaterial";
  64176. export * from "babylonjs/Materials/PBR/pbrSpecularGlossinessMaterial";
  64177. }
  64178. declare module "babylonjs/Materials/Textures/colorGradingTexture" {
  64179. import { Nullable } from "babylonjs/types";
  64180. import { Scene } from "babylonjs/scene";
  64181. import { Matrix } from "babylonjs/Maths/math.vector";
  64182. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  64183. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  64184. import "babylonjs/Engines/Extensions/engine.rawTexture";
  64185. /**
  64186. * This represents a color grading texture. This acts as a lookup table LUT, useful during post process
  64187. * It can help converting any input color in a desired output one. This can then be used to create effects
  64188. * from sepia, black and white to sixties or futuristic rendering...
  64189. *
  64190. * The only supported format is currently 3dl.
  64191. * More information on LUT: https://en.wikipedia.org/wiki/3D_lookup_table
  64192. */
  64193. export class ColorGradingTexture extends BaseTexture {
  64194. /**
  64195. * The texture URL.
  64196. */
  64197. url: string;
  64198. /**
  64199. * Empty line regex stored for GC.
  64200. */
  64201. private static _noneEmptyLineRegex;
  64202. private _textureMatrix;
  64203. private _onLoad;
  64204. /**
  64205. * Instantiates a ColorGradingTexture from the following parameters.
  64206. *
  64207. * @param url The location of the color gradind data (currently only supporting 3dl)
  64208. * @param sceneOrEngine The scene or engine the texture will be used in
  64209. * @param onLoad defines a callback triggered when the texture has been loaded
  64210. */
  64211. constructor(url: string, sceneOrEngine: Scene | ThinEngine, onLoad?: Nullable<() => void>);
  64212. /**
  64213. * Fires the onload event from the constructor if requested.
  64214. */
  64215. private _triggerOnLoad;
  64216. /**
  64217. * Returns the texture matrix used in most of the material.
  64218. * This is not used in color grading but keep for troubleshooting purpose (easily swap diffuse by colorgrading to look in).
  64219. */
  64220. getTextureMatrix(): Matrix;
  64221. /**
  64222. * Occurs when the file being loaded is a .3dl LUT file.
  64223. */
  64224. private load3dlTexture;
  64225. /**
  64226. * Starts the loading process of the texture.
  64227. */
  64228. private loadTexture;
  64229. /**
  64230. * Clones the color gradind texture.
  64231. */
  64232. clone(): ColorGradingTexture;
  64233. /**
  64234. * Called during delayed load for textures.
  64235. */
  64236. delayLoad(): void;
  64237. /**
  64238. * Parses a color grading texture serialized by Babylon.
  64239. * @param parsedTexture The texture information being parsedTexture
  64240. * @param scene The scene to load the texture in
  64241. * @param rootUrl The root url of the data assets to load
  64242. * @return A color gradind texture
  64243. */
  64244. static Parse(parsedTexture: any, scene: Scene): Nullable<ColorGradingTexture>;
  64245. /**
  64246. * Serializes the LUT texture to json format.
  64247. */
  64248. serialize(): any;
  64249. }
  64250. }
  64251. declare module "babylonjs/Materials/Textures/equiRectangularCubeTexture" {
  64252. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  64253. import { Scene } from "babylonjs/scene";
  64254. import { Nullable } from "babylonjs/types";
  64255. import "babylonjs/Engines/Extensions/engine.rawTexture";
  64256. /**
  64257. * This represents a texture coming from an equirectangular image supported by the web browser canvas.
  64258. */
  64259. export class EquiRectangularCubeTexture extends BaseTexture {
  64260. /** The six faces of the cube. */
  64261. private static _FacesMapping;
  64262. private _noMipmap;
  64263. private _onLoad;
  64264. private _onError;
  64265. /** The size of the cubemap. */
  64266. private _size;
  64267. /** The buffer of the image. */
  64268. private _buffer;
  64269. /** The width of the input image. */
  64270. private _width;
  64271. /** The height of the input image. */
  64272. private _height;
  64273. /** The URL to the image. */
  64274. url: string;
  64275. /**
  64276. * Instantiates an EquiRectangularCubeTexture from the following parameters.
  64277. * @param url The location of the image
  64278. * @param scene The scene the texture will be used in
  64279. * @param size The cubemap desired size (the more it increases the longer the generation will be)
  64280. * @param noMipmap Forces to not generate the mipmap if true
  64281. * @param gammaSpace Specifies if the texture will be used in gamma or linear space
  64282. * (the PBR material requires those textures in linear space, but the standard material would require them in Gamma space)
  64283. * @param onLoad — defines a callback called when texture is loaded
  64284. * @param onError — defines a callback called if there is an error
  64285. */
  64286. constructor(url: string, scene: Scene, size: number, noMipmap?: boolean, gammaSpace?: boolean, onLoad?: Nullable<() => void>, onError?: Nullable<(message?: string, exception?: any) => void>);
  64287. /**
  64288. * Load the image data, by putting the image on a canvas and extracting its buffer.
  64289. */
  64290. private loadImage;
  64291. /**
  64292. * Convert the image buffer into a cubemap and create a CubeTexture.
  64293. */
  64294. private loadTexture;
  64295. /**
  64296. * Convert the ArrayBuffer into a Float32Array and drop the transparency channel.
  64297. * @param buffer The ArrayBuffer that should be converted.
  64298. * @returns The buffer as Float32Array.
  64299. */
  64300. private getFloat32ArrayFromArrayBuffer;
  64301. /**
  64302. * Get the current class name of the texture useful for serialization or dynamic coding.
  64303. * @returns "EquiRectangularCubeTexture"
  64304. */
  64305. getClassName(): string;
  64306. /**
  64307. * Create a clone of the current EquiRectangularCubeTexture and return it.
  64308. * @returns A clone of the current EquiRectangularCubeTexture.
  64309. */
  64310. clone(): EquiRectangularCubeTexture;
  64311. }
  64312. }
  64313. declare module "babylonjs/Materials/Textures/htmlElementTexture" {
  64314. import { Nullable } from "babylonjs/types";
  64315. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  64316. import { Matrix } from "babylonjs/Maths/math.vector";
  64317. import "babylonjs/Engines/Extensions/engine.dynamicTexture";
  64318. import "babylonjs/Engines/Extensions/engine.videoTexture";
  64319. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  64320. import { Scene } from "babylonjs/scene";
  64321. /**
  64322. * Defines the options related to the creation of an HtmlElementTexture
  64323. */
  64324. export interface IHtmlElementTextureOptions {
  64325. /**
  64326. * Defines wether mip maps should be created or not.
  64327. */
  64328. generateMipMaps?: boolean;
  64329. /**
  64330. * Defines the sampling mode of the texture.
  64331. */
  64332. samplingMode?: number;
  64333. /**
  64334. * Defines the engine instance to use the texture with. It is not mandatory if you define a scene.
  64335. */
  64336. engine: Nullable<ThinEngine>;
  64337. /**
  64338. * Defines the scene the texture belongs to. It is not mandatory if you define an engine.
  64339. */
  64340. scene: Nullable<Scene>;
  64341. }
  64342. /**
  64343. * This represents the smallest workload to use an already existing element (Canvas or Video) as a texture.
  64344. * To be as efficient as possible depending on your constraints nothing aside the first upload
  64345. * is automatically managed.
  64346. * It is a cheap VideoTexture or DynamicTexture if you prefer to keep full control of the elements
  64347. * in your application.
  64348. *
  64349. * As the update is not automatic, you need to call them manually.
  64350. */
  64351. export class HtmlElementTexture extends BaseTexture {
  64352. /**
  64353. * The texture URL.
  64354. */
  64355. element: HTMLVideoElement | HTMLCanvasElement;
  64356. private static readonly DefaultOptions;
  64357. private _textureMatrix;
  64358. private _isVideo;
  64359. private _generateMipMaps;
  64360. private _samplingMode;
  64361. /**
  64362. * Instantiates a HtmlElementTexture from the following parameters.
  64363. *
  64364. * @param name Defines the name of the texture
  64365. * @param element Defines the video or canvas the texture is filled with
  64366. * @param options Defines the other none mandatory texture creation options
  64367. */
  64368. constructor(name: string, element: HTMLVideoElement | HTMLCanvasElement, options: IHtmlElementTextureOptions);
  64369. private _createInternalTexture;
  64370. /**
  64371. * Returns the texture matrix used in most of the material.
  64372. */
  64373. getTextureMatrix(): Matrix;
  64374. /**
  64375. * Updates the content of the texture.
  64376. * @param invertY Defines wether the texture should be inverted on Y (false by default on video and true on canvas)
  64377. */
  64378. update(invertY?: Nullable<boolean>): void;
  64379. }
  64380. }
  64381. declare module "babylonjs/Misc/tga" {
  64382. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  64383. /**
  64384. * Based on jsTGALoader - Javascript loader for TGA file
  64385. * By Vincent Thibault
  64386. * @see http://blog.robrowser.com/javascript-tga-loader.html
  64387. */
  64388. export class TGATools {
  64389. private static _TYPE_INDEXED;
  64390. private static _TYPE_RGB;
  64391. private static _TYPE_GREY;
  64392. private static _TYPE_RLE_INDEXED;
  64393. private static _TYPE_RLE_RGB;
  64394. private static _TYPE_RLE_GREY;
  64395. private static _ORIGIN_MASK;
  64396. private static _ORIGIN_SHIFT;
  64397. private static _ORIGIN_BL;
  64398. private static _ORIGIN_BR;
  64399. private static _ORIGIN_UL;
  64400. private static _ORIGIN_UR;
  64401. /**
  64402. * Gets the header of a TGA file
  64403. * @param data defines the TGA data
  64404. * @returns the header
  64405. */
  64406. static GetTGAHeader(data: Uint8Array): any;
  64407. /**
  64408. * Uploads TGA content to a Babylon Texture
  64409. * @hidden
  64410. */
  64411. static UploadContent(texture: InternalTexture, data: Uint8Array): void;
  64412. /** @hidden */
  64413. 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;
  64414. /** @hidden */
  64415. 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;
  64416. /** @hidden */
  64417. 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;
  64418. /** @hidden */
  64419. 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;
  64420. /** @hidden */
  64421. 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;
  64422. /** @hidden */
  64423. 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;
  64424. }
  64425. }
  64426. declare module "babylonjs/Materials/Textures/Loaders/tgaTextureLoader" {
  64427. import { Nullable } from "babylonjs/types";
  64428. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  64429. import { IInternalTextureLoader } from "babylonjs/Materials/Textures/internalTextureLoader";
  64430. /**
  64431. * Implementation of the TGA Texture Loader.
  64432. * @hidden
  64433. */
  64434. export class _TGATextureLoader implements IInternalTextureLoader {
  64435. /**
  64436. * Defines wether the loader supports cascade loading the different faces.
  64437. */
  64438. readonly supportCascades: boolean;
  64439. /**
  64440. * This returns if the loader support the current file information.
  64441. * @param extension defines the file extension of the file being loaded
  64442. * @returns true if the loader can load the specified file
  64443. */
  64444. canLoad(extension: string): boolean;
  64445. /**
  64446. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  64447. * @param data contains the texture data
  64448. * @param texture defines the BabylonJS internal texture
  64449. * @param createPolynomials will be true if polynomials have been requested
  64450. * @param onLoad defines the callback to trigger once the texture is ready
  64451. * @param onError defines the callback to trigger in case of error
  64452. */
  64453. loadCubeData(data: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  64454. /**
  64455. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  64456. * @param data contains the texture data
  64457. * @param texture defines the BabylonJS internal texture
  64458. * @param callback defines the method to call once ready to upload
  64459. */
  64460. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  64461. }
  64462. }
  64463. declare module "babylonjs/Misc/basis" {
  64464. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  64465. /**
  64466. * Info about the .basis files
  64467. */
  64468. class BasisFileInfo {
  64469. /**
  64470. * If the file has alpha
  64471. */
  64472. hasAlpha: boolean;
  64473. /**
  64474. * Info about each image of the basis file
  64475. */
  64476. images: Array<{
  64477. levels: Array<{
  64478. width: number;
  64479. height: number;
  64480. transcodedPixels: ArrayBufferView;
  64481. }>;
  64482. }>;
  64483. }
  64484. /**
  64485. * Result of transcoding a basis file
  64486. */
  64487. class TranscodeResult {
  64488. /**
  64489. * Info about the .basis file
  64490. */
  64491. fileInfo: BasisFileInfo;
  64492. /**
  64493. * Format to use when loading the file
  64494. */
  64495. format: number;
  64496. }
  64497. /**
  64498. * Configuration options for the Basis transcoder
  64499. */
  64500. export class BasisTranscodeConfiguration {
  64501. /**
  64502. * Supported compression formats used to determine the supported output format of the transcoder
  64503. */
  64504. supportedCompressionFormats?: {
  64505. /**
  64506. * etc1 compression format
  64507. */
  64508. etc1?: boolean;
  64509. /**
  64510. * s3tc compression format
  64511. */
  64512. s3tc?: boolean;
  64513. /**
  64514. * pvrtc compression format
  64515. */
  64516. pvrtc?: boolean;
  64517. /**
  64518. * etc2 compression format
  64519. */
  64520. etc2?: boolean;
  64521. };
  64522. /**
  64523. * If mipmap levels should be loaded for transcoded images (Default: true)
  64524. */
  64525. loadMipmapLevels?: boolean;
  64526. /**
  64527. * Index of a single image to load (Default: all images)
  64528. */
  64529. loadSingleImage?: number;
  64530. }
  64531. /**
  64532. * Used to load .Basis files
  64533. * See https://github.com/BinomialLLC/basis_universal/tree/master/webgl
  64534. */
  64535. export class BasisTools {
  64536. private static _IgnoreSupportedFormats;
  64537. /**
  64538. * URL to use when loading the basis transcoder
  64539. */
  64540. static JSModuleURL: string;
  64541. /**
  64542. * URL to use when loading the wasm module for the transcoder
  64543. */
  64544. static WasmModuleURL: string;
  64545. /**
  64546. * Get the internal format to be passed to texImage2D corresponding to the .basis format value
  64547. * @param basisFormat format chosen from GetSupportedTranscodeFormat
  64548. * @returns internal format corresponding to the Basis format
  64549. */
  64550. static GetInternalFormatFromBasisFormat(basisFormat: number): number;
  64551. private static _WorkerPromise;
  64552. private static _Worker;
  64553. private static _actionId;
  64554. private static _CreateWorkerAsync;
  64555. /**
  64556. * Transcodes a loaded image file to compressed pixel data
  64557. * @param data image data to transcode
  64558. * @param config configuration options for the transcoding
  64559. * @returns a promise resulting in the transcoded image
  64560. */
  64561. static TranscodeAsync(data: ArrayBuffer | ArrayBufferView, config: BasisTranscodeConfiguration): Promise<TranscodeResult>;
  64562. /**
  64563. * Loads a texture from the transcode result
  64564. * @param texture texture load to
  64565. * @param transcodeResult the result of transcoding the basis file to load from
  64566. */
  64567. static LoadTextureFromTranscodeResult(texture: InternalTexture, transcodeResult: TranscodeResult): void;
  64568. }
  64569. }
  64570. declare module "babylonjs/Materials/Textures/Loaders/basisTextureLoader" {
  64571. import { Nullable } from "babylonjs/types";
  64572. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  64573. import { IInternalTextureLoader } from "babylonjs/Materials/Textures/internalTextureLoader";
  64574. /**
  64575. * Loader for .basis file format
  64576. */
  64577. export class _BasisTextureLoader implements IInternalTextureLoader {
  64578. /**
  64579. * Defines whether the loader supports cascade loading the different faces.
  64580. */
  64581. readonly supportCascades: boolean;
  64582. /**
  64583. * This returns if the loader support the current file information.
  64584. * @param extension defines the file extension of the file being loaded
  64585. * @returns true if the loader can load the specified file
  64586. */
  64587. canLoad(extension: string): boolean;
  64588. /**
  64589. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  64590. * @param data contains the texture data
  64591. * @param texture defines the BabylonJS internal texture
  64592. * @param createPolynomials will be true if polynomials have been requested
  64593. * @param onLoad defines the callback to trigger once the texture is ready
  64594. * @param onError defines the callback to trigger in case of error
  64595. */
  64596. loadCubeData(data: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  64597. /**
  64598. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  64599. * @param data contains the texture data
  64600. * @param texture defines the BabylonJS internal texture
  64601. * @param callback defines the method to call once ready to upload
  64602. */
  64603. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  64604. }
  64605. }
  64606. declare module "babylonjs/Materials/Textures/Loaders/index" {
  64607. export * from "babylonjs/Materials/Textures/Loaders/ddsTextureLoader";
  64608. export * from "babylonjs/Materials/Textures/Loaders/envTextureLoader";
  64609. export * from "babylonjs/Materials/Textures/Loaders/ktxTextureLoader";
  64610. export * from "babylonjs/Materials/Textures/Loaders/tgaTextureLoader";
  64611. export * from "babylonjs/Materials/Textures/Loaders/basisTextureLoader";
  64612. }
  64613. declare module "babylonjs/Materials/Textures/Packer/frame" {
  64614. import { Vector2 } from "babylonjs/Maths/math.vector";
  64615. /**
  64616. * Defines the basic options interface of a TexturePacker Frame
  64617. */
  64618. export interface ITexturePackerFrame {
  64619. /**
  64620. * The frame ID
  64621. */
  64622. id: number;
  64623. /**
  64624. * The frames Scale
  64625. */
  64626. scale: Vector2;
  64627. /**
  64628. * The Frames offset
  64629. */
  64630. offset: Vector2;
  64631. }
  64632. /**
  64633. * This is a support class for frame Data on texture packer sets.
  64634. */
  64635. export class TexturePackerFrame implements ITexturePackerFrame {
  64636. /**
  64637. * The frame ID
  64638. */
  64639. id: number;
  64640. /**
  64641. * The frames Scale
  64642. */
  64643. scale: Vector2;
  64644. /**
  64645. * The Frames offset
  64646. */
  64647. offset: Vector2;
  64648. /**
  64649. * Initializes a texture package frame.
  64650. * @param id The numerical frame identifier
  64651. * @param scale Scalar Vector2 for UV frame
  64652. * @param offset Vector2 for the frame position in UV units.
  64653. * @returns TexturePackerFrame
  64654. */
  64655. constructor(id: number, scale: Vector2, offset: Vector2);
  64656. }
  64657. }
  64658. declare module "babylonjs/Materials/Textures/Packer/packer" {
  64659. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  64660. import { Scene } from "babylonjs/scene";
  64661. import { Nullable } from "babylonjs/types";
  64662. import { Color3, Color4 } from "babylonjs/Maths/math.color";
  64663. import { TexturePackerFrame } from "babylonjs/Materials/Textures/Packer/frame";
  64664. /**
  64665. * Defines the basic options interface of a TexturePacker
  64666. */
  64667. export interface ITexturePackerOptions {
  64668. /**
  64669. * Custom targets for the channels of a texture packer. Default is all the channels of the Standard Material
  64670. */
  64671. map?: string[];
  64672. /**
  64673. * the UV input targets, as a single value for all meshes. Defaults to VertexBuffer.UVKind
  64674. */
  64675. uvsIn?: string;
  64676. /**
  64677. * the UV output targets, as a single value for all meshes. Defaults to VertexBuffer.UVKind
  64678. */
  64679. uvsOut?: string;
  64680. /**
  64681. * number representing the layout style. Defaults to LAYOUT_STRIP
  64682. */
  64683. layout?: number;
  64684. /**
  64685. * number of columns if using custom column count layout(2). This defaults to 4.
  64686. */
  64687. colnum?: number;
  64688. /**
  64689. * flag to update the input meshes to the new packed texture after compilation. Defaults to true.
  64690. */
  64691. updateInputMeshes?: boolean;
  64692. /**
  64693. * boolean flag to dispose all the source textures. Defaults to true.
  64694. */
  64695. disposeSources?: boolean;
  64696. /**
  64697. * Fills the blank cells in a set to the customFillColor. Defaults to true.
  64698. */
  64699. fillBlanks?: boolean;
  64700. /**
  64701. * string value representing the context fill style color. Defaults to 'black'.
  64702. */
  64703. customFillColor?: string;
  64704. /**
  64705. * Width and Height Value of each Frame in the TexturePacker Sets
  64706. */
  64707. frameSize?: number;
  64708. /**
  64709. * Ratio of the value to add padding wise to each cell. Defaults to 0.0115
  64710. */
  64711. paddingRatio?: number;
  64712. /**
  64713. * Number that declares the fill method for the padding gutter.
  64714. */
  64715. paddingMode?: number;
  64716. /**
  64717. * If in SUBUV_COLOR padding mode what color to use.
  64718. */
  64719. paddingColor?: Color3 | Color4;
  64720. }
  64721. /**
  64722. * Defines the basic interface of a TexturePacker JSON File
  64723. */
  64724. export interface ITexturePackerJSON {
  64725. /**
  64726. * The frame ID
  64727. */
  64728. name: string;
  64729. /**
  64730. * The base64 channel data
  64731. */
  64732. sets: any;
  64733. /**
  64734. * The options of the Packer
  64735. */
  64736. options: ITexturePackerOptions;
  64737. /**
  64738. * The frame data of the Packer
  64739. */
  64740. frames: Array<number>;
  64741. }
  64742. /**
  64743. * This is a support class that generates a series of packed texture sets.
  64744. * @see https://doc.babylonjs.com/babylon101/materials
  64745. */
  64746. export class TexturePacker {
  64747. /** Packer Layout Constant 0 */
  64748. static readonly LAYOUT_STRIP: number;
  64749. /** Packer Layout Constant 1 */
  64750. static readonly LAYOUT_POWER2: number;
  64751. /** Packer Layout Constant 2 */
  64752. static readonly LAYOUT_COLNUM: number;
  64753. /** Packer Layout Constant 0 */
  64754. static readonly SUBUV_WRAP: number;
  64755. /** Packer Layout Constant 1 */
  64756. static readonly SUBUV_EXTEND: number;
  64757. /** Packer Layout Constant 2 */
  64758. static readonly SUBUV_COLOR: number;
  64759. /** The Name of the Texture Package */
  64760. name: string;
  64761. /** The scene scope of the TexturePacker */
  64762. scene: Scene;
  64763. /** The Meshes to target */
  64764. meshes: AbstractMesh[];
  64765. /** Arguments passed with the Constructor */
  64766. options: ITexturePackerOptions;
  64767. /** The promise that is started upon initialization */
  64768. promise: Nullable<Promise<TexturePacker | string>>;
  64769. /** The Container object for the channel sets that are generated */
  64770. sets: object;
  64771. /** The Container array for the frames that are generated */
  64772. frames: TexturePackerFrame[];
  64773. /** The expected number of textures the system is parsing. */
  64774. private _expecting;
  64775. /** The padding value from Math.ceil(frameSize * paddingRatio) */
  64776. private _paddingValue;
  64777. /**
  64778. * Initializes a texture package series from an array of meshes or a single mesh.
  64779. * @param name The name of the package
  64780. * @param meshes The target meshes to compose the package from
  64781. * @param options The arguments that texture packer should follow while building.
  64782. * @param scene The scene which the textures are scoped to.
  64783. * @returns TexturePacker
  64784. */
  64785. constructor(name: string, meshes: AbstractMesh[], options: ITexturePackerOptions, scene: Scene);
  64786. /**
  64787. * Starts the package process
  64788. * @param resolve The promises resolution function
  64789. * @returns TexturePacker
  64790. */
  64791. private _createFrames;
  64792. /**
  64793. * Calculates the Size of the Channel Sets
  64794. * @returns Vector2
  64795. */
  64796. private _calculateSize;
  64797. /**
  64798. * Calculates the UV data for the frames.
  64799. * @param baseSize the base frameSize
  64800. * @param padding the base frame padding
  64801. * @param dtSize size of the Dynamic Texture for that channel
  64802. * @param dtUnits is 1/dtSize
  64803. * @param update flag to update the input meshes
  64804. */
  64805. private _calculateMeshUVFrames;
  64806. /**
  64807. * Calculates the frames Offset.
  64808. * @param index of the frame
  64809. * @returns Vector2
  64810. */
  64811. private _getFrameOffset;
  64812. /**
  64813. * Updates a Mesh to the frame data
  64814. * @param mesh that is the target
  64815. * @param frameID or the frame index
  64816. */
  64817. private _updateMeshUV;
  64818. /**
  64819. * Updates a Meshes materials to use the texture packer channels
  64820. * @param m is the mesh to target
  64821. * @param force all channels on the packer to be set.
  64822. */
  64823. private _updateTextureReferences;
  64824. /**
  64825. * Public method to set a Mesh to a frame
  64826. * @param m that is the target
  64827. * @param frameID or the frame index
  64828. * @param updateMaterial trigger for if the Meshes attached Material be updated?
  64829. */
  64830. setMeshToFrame(m: AbstractMesh, frameID: number, updateMaterial?: boolean): void;
  64831. /**
  64832. * Starts the async promise to compile the texture packer.
  64833. * @returns Promise<void>
  64834. */
  64835. processAsync(): Promise<void>;
  64836. /**
  64837. * Disposes all textures associated with this packer
  64838. */
  64839. dispose(): void;
  64840. /**
  64841. * Starts the download process for all the channels converting them to base64 data and embedding it all in a JSON file.
  64842. * @param imageType is the image type to use.
  64843. * @param quality of the image if downloading as jpeg, Ranges from >0 to 1.
  64844. */
  64845. download(imageType?: string, quality?: number): void;
  64846. /**
  64847. * Public method to load a texturePacker JSON file.
  64848. * @param data of the JSON file in string format.
  64849. */
  64850. updateFromJSON(data: string): void;
  64851. }
  64852. }
  64853. declare module "babylonjs/Materials/Textures/Packer/index" {
  64854. export * from "babylonjs/Materials/Textures/Packer/packer";
  64855. export * from "babylonjs/Materials/Textures/Packer/frame";
  64856. }
  64857. declare module "babylonjs/Materials/Textures/Procedurals/customProceduralTexture" {
  64858. import { Scene } from "babylonjs/scene";
  64859. import { Texture } from "babylonjs/Materials/Textures/texture";
  64860. import { ProceduralTexture } from "babylonjs/Materials/Textures/Procedurals/proceduralTexture";
  64861. /**
  64862. * 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.
  64863. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  64864. * @see https://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  64865. */
  64866. export class CustomProceduralTexture extends ProceduralTexture {
  64867. private _animate;
  64868. private _time;
  64869. private _config;
  64870. private _texturePath;
  64871. /**
  64872. * Instantiates a new Custom Procedural Texture.
  64873. * 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.
  64874. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  64875. * @see https://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  64876. * @param name Define the name of the texture
  64877. * @param texturePath Define the folder path containing all the cutom texture related files (config, shaders...)
  64878. * @param size Define the size of the texture to create
  64879. * @param scene Define the scene the texture belongs to
  64880. * @param fallbackTexture Define a fallback texture in case there were issues to create the custom texture
  64881. * @param generateMipMaps Define if the texture should creates mip maps or not
  64882. */
  64883. constructor(name: string, texturePath: string, size: number, scene: Scene, fallbackTexture?: Texture, generateMipMaps?: boolean);
  64884. private _loadJson;
  64885. /**
  64886. * Is the texture ready to be used ? (rendered at least once)
  64887. * @returns true if ready, otherwise, false.
  64888. */
  64889. isReady(): boolean;
  64890. /**
  64891. * Render the texture to its associated render target.
  64892. * @param useCameraPostProcess Define if camera post process should be applied to the texture
  64893. */
  64894. render(useCameraPostProcess?: boolean): void;
  64895. /**
  64896. * Update the list of dependant textures samplers in the shader.
  64897. */
  64898. updateTextures(): void;
  64899. /**
  64900. * Update the uniform values of the procedural texture in the shader.
  64901. */
  64902. updateShaderUniforms(): void;
  64903. /**
  64904. * Define if the texture animates or not.
  64905. */
  64906. get animate(): boolean;
  64907. set animate(value: boolean);
  64908. }
  64909. }
  64910. declare module "babylonjs/Shaders/noise.fragment" {
  64911. /** @hidden */
  64912. export var noisePixelShader: {
  64913. name: string;
  64914. shader: string;
  64915. };
  64916. }
  64917. declare module "babylonjs/Materials/Textures/Procedurals/noiseProceduralTexture" {
  64918. import { Nullable } from "babylonjs/types";
  64919. import { Scene } from "babylonjs/scene";
  64920. import { Texture } from "babylonjs/Materials/Textures/texture";
  64921. import { ProceduralTexture } from "babylonjs/Materials/Textures/Procedurals/proceduralTexture";
  64922. import "babylonjs/Shaders/noise.fragment";
  64923. /**
  64924. * Class used to generate noise procedural textures
  64925. */
  64926. export class NoiseProceduralTexture extends ProceduralTexture {
  64927. /** Gets or sets the start time (default is 0) */
  64928. time: number;
  64929. /** Gets or sets a value between 0 and 1 indicating the overall brightness of the texture (default is 0.2) */
  64930. brightness: number;
  64931. /** Defines the number of octaves to process */
  64932. octaves: number;
  64933. /** Defines the level of persistence (0.8 by default) */
  64934. persistence: number;
  64935. /** Gets or sets animation speed factor (default is 1) */
  64936. animationSpeedFactor: number;
  64937. /**
  64938. * Creates a new NoiseProceduralTexture
  64939. * @param name defines the name fo the texture
  64940. * @param size defines the size of the texture (default is 256)
  64941. * @param scene defines the hosting scene
  64942. * @param fallbackTexture defines the texture to use if the NoiseProceduralTexture can't be created
  64943. * @param generateMipMaps defines if mipmaps must be generated (true by default)
  64944. */
  64945. constructor(name: string, size?: number, scene?: Nullable<Scene>, fallbackTexture?: Texture, generateMipMaps?: boolean);
  64946. private _updateShaderUniforms;
  64947. protected _getDefines(): string;
  64948. /** Generate the current state of the procedural texture */
  64949. render(useCameraPostProcess?: boolean): void;
  64950. /**
  64951. * Serializes this noise procedural texture
  64952. * @returns a serialized noise procedural texture object
  64953. */
  64954. serialize(): any;
  64955. /**
  64956. * Clone the texture.
  64957. * @returns the cloned texture
  64958. */
  64959. clone(): NoiseProceduralTexture;
  64960. /**
  64961. * Creates a NoiseProceduralTexture from parsed noise procedural texture data
  64962. * @param parsedTexture defines parsed texture data
  64963. * @param scene defines the current scene
  64964. * @param rootUrl defines the root URL containing noise procedural texture information
  64965. * @returns a parsed NoiseProceduralTexture
  64966. */
  64967. static Parse(parsedTexture: any, scene: Scene): NoiseProceduralTexture;
  64968. }
  64969. }
  64970. declare module "babylonjs/Materials/Textures/Procedurals/index" {
  64971. export * from "babylonjs/Materials/Textures/Procedurals/customProceduralTexture";
  64972. export * from "babylonjs/Materials/Textures/Procedurals/noiseProceduralTexture";
  64973. export * from "babylonjs/Materials/Textures/Procedurals/proceduralTexture";
  64974. export * from "babylonjs/Materials/Textures/Procedurals/proceduralTextureSceneComponent";
  64975. }
  64976. declare module "babylonjs/Materials/Textures/rawCubeTexture" {
  64977. import { Nullable } from "babylonjs/types";
  64978. import { Scene } from "babylonjs/scene";
  64979. import { SphericalPolynomial } from "babylonjs/Maths/sphericalPolynomial";
  64980. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  64981. import { CubeTexture } from "babylonjs/Materials/Textures/cubeTexture";
  64982. import "babylonjs/Engines/Extensions/engine.rawTexture";
  64983. /**
  64984. * Raw cube texture where the raw buffers are passed in
  64985. */
  64986. export class RawCubeTexture extends CubeTexture {
  64987. /**
  64988. * Creates a cube texture where the raw buffers are passed in.
  64989. * @param scene defines the scene the texture is attached to
  64990. * @param data defines the array of data to use to create each face
  64991. * @param size defines the size of the textures
  64992. * @param format defines the format of the data
  64993. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  64994. * @param generateMipMaps defines if the engine should generate the mip levels
  64995. * @param invertY defines if data must be stored with Y axis inverted
  64996. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  64997. * @param compression defines the compression used (null by default)
  64998. */
  64999. constructor(scene: Scene, data: Nullable<ArrayBufferView[]>, size: number, format?: number, type?: number, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, compression?: Nullable<string>);
  65000. /**
  65001. * Updates the raw cube texture.
  65002. * @param data defines the data to store
  65003. * @param format defines the data format
  65004. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  65005. * @param invertY defines if data must be stored with Y axis inverted
  65006. * @param compression defines the compression used (null by default)
  65007. * @param level defines which level of the texture to update
  65008. */
  65009. update(data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression?: Nullable<string>): void;
  65010. /**
  65011. * Updates a raw cube texture with RGBD encoded data.
  65012. * @param data defines the array of data [mipmap][face] to use to create each face
  65013. * @param sphericalPolynomial defines the spherical polynomial for irradiance
  65014. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  65015. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  65016. * @returns a promsie that resolves when the operation is complete
  65017. */
  65018. updateRGBDAsync(data: ArrayBufferView[][], sphericalPolynomial?: Nullable<SphericalPolynomial>, lodScale?: number, lodOffset?: number): Promise<void>;
  65019. /**
  65020. * Clones the raw cube texture.
  65021. * @return a new cube texture
  65022. */
  65023. clone(): CubeTexture;
  65024. /** @hidden */
  65025. static _UpdateRGBDAsync(internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number): Promise<void>;
  65026. }
  65027. }
  65028. declare module "babylonjs/Materials/Textures/rawTexture2DArray" {
  65029. import { Scene } from "babylonjs/scene";
  65030. import { Texture } from "babylonjs/Materials/Textures/texture";
  65031. import "babylonjs/Engines/Extensions/engine.rawTexture";
  65032. /**
  65033. * Class used to store 2D array textures containing user data
  65034. */
  65035. export class RawTexture2DArray extends Texture {
  65036. /** Gets or sets the texture format to use */
  65037. format: number;
  65038. /**
  65039. * Create a new RawTexture2DArray
  65040. * @param data defines the data of the texture
  65041. * @param width defines the width of the texture
  65042. * @param height defines the height of the texture
  65043. * @param depth defines the number of layers of the texture
  65044. * @param format defines the texture format to use
  65045. * @param scene defines the hosting scene
  65046. * @param generateMipMaps defines a boolean indicating if mip levels should be generated (true by default)
  65047. * @param invertY defines if texture must be stored with Y axis inverted
  65048. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  65049. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  65050. */
  65051. constructor(data: ArrayBufferView, width: number, height: number, depth: number,
  65052. /** Gets or sets the texture format to use */
  65053. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, textureType?: number);
  65054. /**
  65055. * Update the texture with new data
  65056. * @param data defines the data to store in the texture
  65057. */
  65058. update(data: ArrayBufferView): void;
  65059. }
  65060. }
  65061. declare module "babylonjs/Materials/Textures/rawTexture3D" {
  65062. import { Scene } from "babylonjs/scene";
  65063. import { Texture } from "babylonjs/Materials/Textures/texture";
  65064. import "babylonjs/Engines/Extensions/engine.rawTexture";
  65065. /**
  65066. * Class used to store 3D textures containing user data
  65067. */
  65068. export class RawTexture3D extends Texture {
  65069. /** Gets or sets the texture format to use */
  65070. format: number;
  65071. /**
  65072. * Create a new RawTexture3D
  65073. * @param data defines the data of the texture
  65074. * @param width defines the width of the texture
  65075. * @param height defines the height of the texture
  65076. * @param depth defines the depth of the texture
  65077. * @param format defines the texture format to use
  65078. * @param scene defines the hosting scene
  65079. * @param generateMipMaps defines a boolean indicating if mip levels should be generated (true by default)
  65080. * @param invertY defines if texture must be stored with Y axis inverted
  65081. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  65082. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  65083. */
  65084. constructor(data: ArrayBufferView, width: number, height: number, depth: number,
  65085. /** Gets or sets the texture format to use */
  65086. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, textureType?: number);
  65087. /**
  65088. * Update the texture with new data
  65089. * @param data defines the data to store in the texture
  65090. */
  65091. update(data: ArrayBufferView): void;
  65092. }
  65093. }
  65094. declare module "babylonjs/Materials/Textures/refractionTexture" {
  65095. import { Scene } from "babylonjs/scene";
  65096. import { Plane } from "babylonjs/Maths/math.plane";
  65097. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  65098. /**
  65099. * Creates a refraction texture used by refraction channel of the standard material.
  65100. * It is like a mirror but to see through a material.
  65101. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  65102. */
  65103. export class RefractionTexture extends RenderTargetTexture {
  65104. /**
  65105. * Define the reflection plane we want to use. The refractionPlane is usually set to the constructed refractor.
  65106. * 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.
  65107. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  65108. */
  65109. refractionPlane: Plane;
  65110. /**
  65111. * Define how deep under the surface we should see.
  65112. */
  65113. depth: number;
  65114. /**
  65115. * Creates a refraction texture used by refraction channel of the standard material.
  65116. * It is like a mirror but to see through a material.
  65117. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  65118. * @param name Define the texture name
  65119. * @param size Define the size of the underlying texture
  65120. * @param scene Define the scene the refraction belongs to
  65121. * @param generateMipMaps Define if we need to generate mips level for the refraction
  65122. */
  65123. constructor(name: string, size: number, scene: Scene, generateMipMaps?: boolean);
  65124. /**
  65125. * Clone the refraction texture.
  65126. * @returns the cloned texture
  65127. */
  65128. clone(): RefractionTexture;
  65129. /**
  65130. * Serialize the texture to a JSON representation you could use in Parse later on
  65131. * @returns the serialized JSON representation
  65132. */
  65133. serialize(): any;
  65134. }
  65135. }
  65136. declare module "babylonjs/Materials/Textures/index" {
  65137. export * from "babylonjs/Materials/Textures/baseTexture";
  65138. export * from "babylonjs/Materials/Textures/baseTexture.polynomial";
  65139. export * from "babylonjs/Materials/Textures/colorGradingTexture";
  65140. export * from "babylonjs/Materials/Textures/cubeTexture";
  65141. export * from "babylonjs/Materials/Textures/dynamicTexture";
  65142. export * from "babylonjs/Materials/Textures/equiRectangularCubeTexture";
  65143. export * from "babylonjs/Materials/Textures/Filtering/hdrFiltering";
  65144. export * from "babylonjs/Materials/Textures/hdrCubeTexture";
  65145. export * from "babylonjs/Materials/Textures/htmlElementTexture";
  65146. export * from "babylonjs/Materials/Textures/internalTexture";
  65147. export * from "babylonjs/Materials/Textures/internalTextureLoader";
  65148. export * from "babylonjs/Materials/Textures/Loaders/index";
  65149. export * from "babylonjs/Materials/Textures/mirrorTexture";
  65150. export * from "babylonjs/Materials/Textures/multiRenderTarget";
  65151. export * from "babylonjs/Materials/Textures/Packer/index";
  65152. export * from "babylonjs/Materials/Textures/Procedurals/index";
  65153. export * from "babylonjs/Materials/Textures/rawCubeTexture";
  65154. export * from "babylonjs/Materials/Textures/rawTexture";
  65155. export * from "babylonjs/Materials/Textures/rawTexture2DArray";
  65156. export * from "babylonjs/Materials/Textures/rawTexture3D";
  65157. export * from "babylonjs/Materials/Textures/refractionTexture";
  65158. export * from "babylonjs/Materials/Textures/renderTargetTexture";
  65159. export * from "babylonjs/Materials/Textures/texture";
  65160. export * from "babylonjs/Materials/Textures/videoTexture";
  65161. }
  65162. declare module "babylonjs/Materials/Node/Enums/index" {
  65163. export * from "babylonjs/Materials/Node/Enums/nodeMaterialBlockTargets";
  65164. export * from "babylonjs/Materials/Node/Enums/nodeMaterialBlockConnectionPointTypes";
  65165. export * from "babylonjs/Materials/Node/Enums/nodeMaterialBlockConnectionPointMode";
  65166. export * from "babylonjs/Materials/Node/Enums/nodeMaterialSystemValues";
  65167. export * from "babylonjs/Materials/Node/Enums/nodeMaterialModes";
  65168. }
  65169. declare module "babylonjs/Materials/Node/Blocks/Vertex/bonesBlock" {
  65170. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  65171. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  65172. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  65173. import { Mesh } from "babylonjs/Meshes/mesh";
  65174. import { Effect } from "babylonjs/Materials/effect";
  65175. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  65176. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  65177. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  65178. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  65179. import { EffectFallbacks } from "babylonjs/Materials/effectFallbacks";
  65180. /**
  65181. * Block used to add support for vertex skinning (bones)
  65182. */
  65183. export class BonesBlock extends NodeMaterialBlock {
  65184. /**
  65185. * Creates a new BonesBlock
  65186. * @param name defines the block name
  65187. */
  65188. constructor(name: string);
  65189. /**
  65190. * Initialize the block and prepare the context for build
  65191. * @param state defines the state that will be used for the build
  65192. */
  65193. initialize(state: NodeMaterialBuildState): void;
  65194. /**
  65195. * Gets the current class name
  65196. * @returns the class name
  65197. */
  65198. getClassName(): string;
  65199. /**
  65200. * Gets the matrix indices input component
  65201. */
  65202. get matricesIndices(): NodeMaterialConnectionPoint;
  65203. /**
  65204. * Gets the matrix weights input component
  65205. */
  65206. get matricesWeights(): NodeMaterialConnectionPoint;
  65207. /**
  65208. * Gets the extra matrix indices input component
  65209. */
  65210. get matricesIndicesExtra(): NodeMaterialConnectionPoint;
  65211. /**
  65212. * Gets the extra matrix weights input component
  65213. */
  65214. get matricesWeightsExtra(): NodeMaterialConnectionPoint;
  65215. /**
  65216. * Gets the world input component
  65217. */
  65218. get world(): NodeMaterialConnectionPoint;
  65219. /**
  65220. * Gets the output component
  65221. */
  65222. get output(): NodeMaterialConnectionPoint;
  65223. autoConfigure(material: NodeMaterial): void;
  65224. provideFallbacks(mesh: AbstractMesh, fallbacks: EffectFallbacks): void;
  65225. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  65226. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  65227. protected _buildBlock(state: NodeMaterialBuildState): this;
  65228. }
  65229. }
  65230. declare module "babylonjs/Materials/Node/Blocks/Vertex/instancesBlock" {
  65231. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  65232. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  65233. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  65234. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  65235. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  65236. import { SubMesh } from "babylonjs/Meshes/subMesh";
  65237. /**
  65238. * Block used to add support for instances
  65239. * @see https://doc.babylonjs.com/how_to/how_to_use_instances
  65240. */
  65241. export class InstancesBlock extends NodeMaterialBlock {
  65242. /**
  65243. * Creates a new InstancesBlock
  65244. * @param name defines the block name
  65245. */
  65246. constructor(name: string);
  65247. /**
  65248. * Gets the current class name
  65249. * @returns the class name
  65250. */
  65251. getClassName(): string;
  65252. /**
  65253. * Gets the first world row input component
  65254. */
  65255. get world0(): NodeMaterialConnectionPoint;
  65256. /**
  65257. * Gets the second world row input component
  65258. */
  65259. get world1(): NodeMaterialConnectionPoint;
  65260. /**
  65261. * Gets the third world row input component
  65262. */
  65263. get world2(): NodeMaterialConnectionPoint;
  65264. /**
  65265. * Gets the forth world row input component
  65266. */
  65267. get world3(): NodeMaterialConnectionPoint;
  65268. /**
  65269. * Gets the world input component
  65270. */
  65271. get world(): NodeMaterialConnectionPoint;
  65272. /**
  65273. * Gets the output component
  65274. */
  65275. get output(): NodeMaterialConnectionPoint;
  65276. /**
  65277. * Gets the isntanceID component
  65278. */
  65279. get instanceID(): NodeMaterialConnectionPoint;
  65280. autoConfigure(material: NodeMaterial): void;
  65281. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean, subMesh?: SubMesh): void;
  65282. protected _buildBlock(state: NodeMaterialBuildState): this;
  65283. }
  65284. }
  65285. declare module "babylonjs/Materials/Node/Blocks/Vertex/morphTargetsBlock" {
  65286. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  65287. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  65288. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  65289. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  65290. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  65291. import { Effect } from "babylonjs/Materials/effect";
  65292. import { Mesh } from "babylonjs/Meshes/mesh";
  65293. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  65294. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  65295. /**
  65296. * Block used to add morph targets support to vertex shader
  65297. */
  65298. export class MorphTargetsBlock extends NodeMaterialBlock {
  65299. private _repeatableContentAnchor;
  65300. /**
  65301. * Create a new MorphTargetsBlock
  65302. * @param name defines the block name
  65303. */
  65304. constructor(name: string);
  65305. /**
  65306. * Gets the current class name
  65307. * @returns the class name
  65308. */
  65309. getClassName(): string;
  65310. /**
  65311. * Gets the position input component
  65312. */
  65313. get position(): NodeMaterialConnectionPoint;
  65314. /**
  65315. * Gets the normal input component
  65316. */
  65317. get normal(): NodeMaterialConnectionPoint;
  65318. /**
  65319. * Gets the tangent input component
  65320. */
  65321. get tangent(): NodeMaterialConnectionPoint;
  65322. /**
  65323. * Gets the tangent input component
  65324. */
  65325. get uv(): NodeMaterialConnectionPoint;
  65326. /**
  65327. * Gets the position output component
  65328. */
  65329. get positionOutput(): NodeMaterialConnectionPoint;
  65330. /**
  65331. * Gets the normal output component
  65332. */
  65333. get normalOutput(): NodeMaterialConnectionPoint;
  65334. /**
  65335. * Gets the tangent output component
  65336. */
  65337. get tangentOutput(): NodeMaterialConnectionPoint;
  65338. /**
  65339. * Gets the tangent output component
  65340. */
  65341. get uvOutput(): NodeMaterialConnectionPoint;
  65342. initialize(state: NodeMaterialBuildState): void;
  65343. autoConfigure(material: NodeMaterial): void;
  65344. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  65345. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  65346. replaceRepeatableContent(vertexShaderState: NodeMaterialBuildState, fragmentShaderState: NodeMaterialBuildState, mesh: AbstractMesh, defines: NodeMaterialDefines): void;
  65347. protected _buildBlock(state: NodeMaterialBuildState): this;
  65348. }
  65349. }
  65350. declare module "babylonjs/Materials/Node/Blocks/Vertex/lightInformationBlock" {
  65351. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  65352. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  65353. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  65354. import { Nullable } from "babylonjs/types";
  65355. import { Scene } from "babylonjs/scene";
  65356. import { Effect } from "babylonjs/Materials/effect";
  65357. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  65358. import { Mesh } from "babylonjs/Meshes/mesh";
  65359. import { Light } from "babylonjs/Lights/light";
  65360. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  65361. /**
  65362. * Block used to get data information from a light
  65363. */
  65364. export class LightInformationBlock extends NodeMaterialBlock {
  65365. private _lightDataUniformName;
  65366. private _lightColorUniformName;
  65367. private _lightTypeDefineName;
  65368. /**
  65369. * Gets or sets the light associated with this block
  65370. */
  65371. light: Nullable<Light>;
  65372. /**
  65373. * Creates a new LightInformationBlock
  65374. * @param name defines the block name
  65375. */
  65376. constructor(name: string);
  65377. /**
  65378. * Gets the current class name
  65379. * @returns the class name
  65380. */
  65381. getClassName(): string;
  65382. /**
  65383. * Gets the world position input component
  65384. */
  65385. get worldPosition(): NodeMaterialConnectionPoint;
  65386. /**
  65387. * Gets the direction output component
  65388. */
  65389. get direction(): NodeMaterialConnectionPoint;
  65390. /**
  65391. * Gets the direction output component
  65392. */
  65393. get color(): NodeMaterialConnectionPoint;
  65394. /**
  65395. * Gets the direction output component
  65396. */
  65397. get intensity(): NodeMaterialConnectionPoint;
  65398. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  65399. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  65400. protected _buildBlock(state: NodeMaterialBuildState): this;
  65401. serialize(): any;
  65402. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  65403. }
  65404. }
  65405. declare module "babylonjs/Materials/Node/Blocks/Vertex/index" {
  65406. export * from "babylonjs/Materials/Node/Blocks/Vertex/vertexOutputBlock";
  65407. export * from "babylonjs/Materials/Node/Blocks/Vertex/bonesBlock";
  65408. export * from "babylonjs/Materials/Node/Blocks/Vertex/instancesBlock";
  65409. export * from "babylonjs/Materials/Node/Blocks/Vertex/morphTargetsBlock";
  65410. export * from "babylonjs/Materials/Node/Blocks/Vertex/lightInformationBlock";
  65411. }
  65412. declare module "babylonjs/Materials/Node/Blocks/Fragment/imageProcessingBlock" {
  65413. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  65414. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  65415. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  65416. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  65417. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  65418. import { Effect } from "babylonjs/Materials/effect";
  65419. import { Mesh } from "babylonjs/Meshes/mesh";
  65420. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  65421. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  65422. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  65423. /**
  65424. * Block used to add image processing support to fragment shader
  65425. */
  65426. export class ImageProcessingBlock extends NodeMaterialBlock {
  65427. /**
  65428. * Create a new ImageProcessingBlock
  65429. * @param name defines the block name
  65430. */
  65431. constructor(name: string);
  65432. /**
  65433. * Gets the current class name
  65434. * @returns the class name
  65435. */
  65436. getClassName(): string;
  65437. /**
  65438. * Gets the color input component
  65439. */
  65440. get color(): NodeMaterialConnectionPoint;
  65441. /**
  65442. * Gets the output component
  65443. */
  65444. get output(): NodeMaterialConnectionPoint;
  65445. /**
  65446. * Initialize the block and prepare the context for build
  65447. * @param state defines the state that will be used for the build
  65448. */
  65449. initialize(state: NodeMaterialBuildState): void;
  65450. isReady(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): boolean;
  65451. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  65452. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  65453. protected _buildBlock(state: NodeMaterialBuildState): this;
  65454. }
  65455. }
  65456. declare module "babylonjs/Materials/Node/Blocks/Fragment/perturbNormalBlock" {
  65457. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  65458. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  65459. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  65460. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  65461. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  65462. import { Effect } from "babylonjs/Materials/effect";
  65463. import { Mesh } from "babylonjs/Meshes/mesh";
  65464. import { Scene } from "babylonjs/scene";
  65465. import "babylonjs/Shaders/ShadersInclude/bumpFragmentMainFunctions";
  65466. import "babylonjs/Shaders/ShadersInclude/bumpFragmentFunctions";
  65467. import "babylonjs/Shaders/ShadersInclude/bumpFragment";
  65468. /**
  65469. * Block used to pertub normals based on a normal map
  65470. */
  65471. export class PerturbNormalBlock extends NodeMaterialBlock {
  65472. private _tangentSpaceParameterName;
  65473. /** Gets or sets a boolean indicating that normal should be inverted on X axis */
  65474. invertX: boolean;
  65475. /** Gets or sets a boolean indicating that normal should be inverted on Y axis */
  65476. invertY: boolean;
  65477. /**
  65478. * Create a new PerturbNormalBlock
  65479. * @param name defines the block name
  65480. */
  65481. constructor(name: string);
  65482. /**
  65483. * Gets the current class name
  65484. * @returns the class name
  65485. */
  65486. getClassName(): string;
  65487. /**
  65488. * Gets the world position input component
  65489. */
  65490. get worldPosition(): NodeMaterialConnectionPoint;
  65491. /**
  65492. * Gets the world normal input component
  65493. */
  65494. get worldNormal(): NodeMaterialConnectionPoint;
  65495. /**
  65496. * Gets the world tangent input component
  65497. */
  65498. get worldTangent(): NodeMaterialConnectionPoint;
  65499. /**
  65500. * Gets the uv input component
  65501. */
  65502. get uv(): NodeMaterialConnectionPoint;
  65503. /**
  65504. * Gets the normal map color input component
  65505. */
  65506. get normalMapColor(): NodeMaterialConnectionPoint;
  65507. /**
  65508. * Gets the strength input component
  65509. */
  65510. get strength(): NodeMaterialConnectionPoint;
  65511. /**
  65512. * Gets the output component
  65513. */
  65514. get output(): NodeMaterialConnectionPoint;
  65515. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  65516. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  65517. autoConfigure(material: NodeMaterial): void;
  65518. protected _buildBlock(state: NodeMaterialBuildState): this;
  65519. protected _dumpPropertiesCode(): string;
  65520. serialize(): any;
  65521. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  65522. }
  65523. }
  65524. declare module "babylonjs/Materials/Node/Blocks/Fragment/discardBlock" {
  65525. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  65526. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  65527. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  65528. /**
  65529. * Block used to discard a pixel if a value is smaller than a cutoff
  65530. */
  65531. export class DiscardBlock extends NodeMaterialBlock {
  65532. /**
  65533. * Create a new DiscardBlock
  65534. * @param name defines the block name
  65535. */
  65536. constructor(name: string);
  65537. /**
  65538. * Gets the current class name
  65539. * @returns the class name
  65540. */
  65541. getClassName(): string;
  65542. /**
  65543. * Gets the color input component
  65544. */
  65545. get value(): NodeMaterialConnectionPoint;
  65546. /**
  65547. * Gets the cutoff input component
  65548. */
  65549. get cutoff(): NodeMaterialConnectionPoint;
  65550. protected _buildBlock(state: NodeMaterialBuildState): this;
  65551. }
  65552. }
  65553. declare module "babylonjs/Materials/Node/Blocks/Fragment/frontFacingBlock" {
  65554. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  65555. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  65556. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  65557. /**
  65558. * Block used to test if the fragment shader is front facing
  65559. */
  65560. export class FrontFacingBlock extends NodeMaterialBlock {
  65561. /**
  65562. * Creates a new FrontFacingBlock
  65563. * @param name defines the block name
  65564. */
  65565. constructor(name: string);
  65566. /**
  65567. * Gets the current class name
  65568. * @returns the class name
  65569. */
  65570. getClassName(): string;
  65571. /**
  65572. * Gets the output component
  65573. */
  65574. get output(): NodeMaterialConnectionPoint;
  65575. protected _buildBlock(state: NodeMaterialBuildState): this;
  65576. }
  65577. }
  65578. declare module "babylonjs/Materials/Node/Blocks/Fragment/derivativeBlock" {
  65579. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  65580. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  65581. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  65582. /**
  65583. * Block used to get the derivative value on x and y of a given input
  65584. */
  65585. export class DerivativeBlock extends NodeMaterialBlock {
  65586. /**
  65587. * Create a new DerivativeBlock
  65588. * @param name defines the block name
  65589. */
  65590. constructor(name: string);
  65591. /**
  65592. * Gets the current class name
  65593. * @returns the class name
  65594. */
  65595. getClassName(): string;
  65596. /**
  65597. * Gets the input component
  65598. */
  65599. get input(): NodeMaterialConnectionPoint;
  65600. /**
  65601. * Gets the derivative output on x
  65602. */
  65603. get dx(): NodeMaterialConnectionPoint;
  65604. /**
  65605. * Gets the derivative output on y
  65606. */
  65607. get dy(): NodeMaterialConnectionPoint;
  65608. protected _buildBlock(state: NodeMaterialBuildState): this;
  65609. }
  65610. }
  65611. declare module "babylonjs/Materials/Node/Blocks/Fragment/fragCoordBlock" {
  65612. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  65613. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  65614. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  65615. /**
  65616. * Block used to make gl_FragCoord available
  65617. */
  65618. export class FragCoordBlock extends NodeMaterialBlock {
  65619. /**
  65620. * Creates a new FragCoordBlock
  65621. * @param name defines the block name
  65622. */
  65623. constructor(name: string);
  65624. /**
  65625. * Gets the current class name
  65626. * @returns the class name
  65627. */
  65628. getClassName(): string;
  65629. /**
  65630. * Gets the xy component
  65631. */
  65632. get xy(): NodeMaterialConnectionPoint;
  65633. /**
  65634. * Gets the xyz component
  65635. */
  65636. get xyz(): NodeMaterialConnectionPoint;
  65637. /**
  65638. * Gets the xyzw component
  65639. */
  65640. get xyzw(): NodeMaterialConnectionPoint;
  65641. /**
  65642. * Gets the x component
  65643. */
  65644. get x(): NodeMaterialConnectionPoint;
  65645. /**
  65646. * Gets the y component
  65647. */
  65648. get y(): NodeMaterialConnectionPoint;
  65649. /**
  65650. * Gets the z component
  65651. */
  65652. get z(): NodeMaterialConnectionPoint;
  65653. /**
  65654. * Gets the w component
  65655. */
  65656. get output(): NodeMaterialConnectionPoint;
  65657. protected writeOutputs(state: NodeMaterialBuildState): string;
  65658. protected _buildBlock(state: NodeMaterialBuildState): this;
  65659. }
  65660. }
  65661. declare module "babylonjs/Materials/Node/Blocks/Fragment/screenSizeBlock" {
  65662. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  65663. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  65664. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  65665. import { Effect } from "babylonjs/Materials/effect";
  65666. import { NodeMaterial } from "babylonjs/Materials/Node/nodeMaterial";
  65667. import { Mesh } from "babylonjs/Meshes/mesh";
  65668. /**
  65669. * Block used to get the screen sizes
  65670. */
  65671. export class ScreenSizeBlock extends NodeMaterialBlock {
  65672. private _varName;
  65673. private _scene;
  65674. /**
  65675. * Creates a new ScreenSizeBlock
  65676. * @param name defines the block name
  65677. */
  65678. constructor(name: string);
  65679. /**
  65680. * Gets the current class name
  65681. * @returns the class name
  65682. */
  65683. getClassName(): string;
  65684. /**
  65685. * Gets the xy component
  65686. */
  65687. get xy(): NodeMaterialConnectionPoint;
  65688. /**
  65689. * Gets the x component
  65690. */
  65691. get x(): NodeMaterialConnectionPoint;
  65692. /**
  65693. * Gets the y component
  65694. */
  65695. get y(): NodeMaterialConnectionPoint;
  65696. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  65697. protected writeOutputs(state: NodeMaterialBuildState, varName: string): string;
  65698. protected _buildBlock(state: NodeMaterialBuildState): this;
  65699. }
  65700. }
  65701. declare module "babylonjs/Materials/Node/Blocks/Fragment/index" {
  65702. export * from "babylonjs/Materials/Node/Blocks/Fragment/fragmentOutputBlock";
  65703. export * from "babylonjs/Materials/Node/Blocks/Fragment/imageProcessingBlock";
  65704. export * from "babylonjs/Materials/Node/Blocks/Fragment/perturbNormalBlock";
  65705. export * from "babylonjs/Materials/Node/Blocks/Fragment/discardBlock";
  65706. export * from "babylonjs/Materials/Node/Blocks/Fragment/frontFacingBlock";
  65707. export * from "babylonjs/Materials/Node/Blocks/Fragment/derivativeBlock";
  65708. export * from "babylonjs/Materials/Node/Blocks/Fragment/fragCoordBlock";
  65709. export * from "babylonjs/Materials/Node/Blocks/Fragment/screenSizeBlock";
  65710. }
  65711. declare module "babylonjs/Materials/Node/Blocks/Dual/fogBlock" {
  65712. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  65713. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  65714. import { Mesh } from "babylonjs/Meshes/mesh";
  65715. import { Effect } from "babylonjs/Materials/effect";
  65716. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  65717. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  65718. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  65719. import "babylonjs/Shaders/ShadersInclude/fogFragmentDeclaration";
  65720. /**
  65721. * Block used to add support for scene fog
  65722. */
  65723. export class FogBlock extends NodeMaterialBlock {
  65724. private _fogDistanceName;
  65725. private _fogParameters;
  65726. /**
  65727. * Create a new FogBlock
  65728. * @param name defines the block name
  65729. */
  65730. constructor(name: string);
  65731. /**
  65732. * Gets the current class name
  65733. * @returns the class name
  65734. */
  65735. getClassName(): string;
  65736. /**
  65737. * Gets the world position input component
  65738. */
  65739. get worldPosition(): NodeMaterialConnectionPoint;
  65740. /**
  65741. * Gets the view input component
  65742. */
  65743. get view(): NodeMaterialConnectionPoint;
  65744. /**
  65745. * Gets the color input component
  65746. */
  65747. get input(): NodeMaterialConnectionPoint;
  65748. /**
  65749. * Gets the fog color input component
  65750. */
  65751. get fogColor(): NodeMaterialConnectionPoint;
  65752. /**
  65753. * Gets the output component
  65754. */
  65755. get output(): NodeMaterialConnectionPoint;
  65756. autoConfigure(material: NodeMaterial): void;
  65757. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  65758. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  65759. protected _buildBlock(state: NodeMaterialBuildState): this;
  65760. }
  65761. }
  65762. declare module "babylonjs/Materials/Node/Blocks/Dual/lightBlock" {
  65763. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  65764. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  65765. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  65766. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  65767. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  65768. import { Effect } from "babylonjs/Materials/effect";
  65769. import { Mesh } from "babylonjs/Meshes/mesh";
  65770. import { Light } from "babylonjs/Lights/light";
  65771. import { Nullable } from "babylonjs/types";
  65772. import { Scene } from "babylonjs/scene";
  65773. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  65774. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  65775. import "babylonjs/Shaders/ShadersInclude/lightFragment";
  65776. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  65777. import "babylonjs/Shaders/ShadersInclude/lightsFragmentFunctions";
  65778. import "babylonjs/Shaders/ShadersInclude/shadowsFragmentFunctions";
  65779. import "babylonjs/Shaders/ShadersInclude/shadowsVertex";
  65780. /**
  65781. * Block used to add light in the fragment shader
  65782. */
  65783. export class LightBlock extends NodeMaterialBlock {
  65784. private _lightId;
  65785. /**
  65786. * Gets or sets the light associated with this block
  65787. */
  65788. light: Nullable<Light>;
  65789. /**
  65790. * Create a new LightBlock
  65791. * @param name defines the block name
  65792. */
  65793. constructor(name: string);
  65794. /**
  65795. * Gets the current class name
  65796. * @returns the class name
  65797. */
  65798. getClassName(): string;
  65799. /**
  65800. * Gets the world position input component
  65801. */
  65802. get worldPosition(): NodeMaterialConnectionPoint;
  65803. /**
  65804. * Gets the world normal input component
  65805. */
  65806. get worldNormal(): NodeMaterialConnectionPoint;
  65807. /**
  65808. * Gets the camera (or eye) position component
  65809. */
  65810. get cameraPosition(): NodeMaterialConnectionPoint;
  65811. /**
  65812. * Gets the glossiness component
  65813. */
  65814. get glossiness(): NodeMaterialConnectionPoint;
  65815. /**
  65816. * Gets the glossinness power component
  65817. */
  65818. get glossPower(): NodeMaterialConnectionPoint;
  65819. /**
  65820. * Gets the diffuse color component
  65821. */
  65822. get diffuseColor(): NodeMaterialConnectionPoint;
  65823. /**
  65824. * Gets the specular color component
  65825. */
  65826. get specularColor(): NodeMaterialConnectionPoint;
  65827. /**
  65828. * Gets the diffuse output component
  65829. */
  65830. get diffuseOutput(): NodeMaterialConnectionPoint;
  65831. /**
  65832. * Gets the specular output component
  65833. */
  65834. get specularOutput(): NodeMaterialConnectionPoint;
  65835. /**
  65836. * Gets the shadow output component
  65837. */
  65838. get shadow(): NodeMaterialConnectionPoint;
  65839. autoConfigure(material: NodeMaterial): void;
  65840. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  65841. updateUniformsAndSamples(state: NodeMaterialBuildState, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, uniformBuffers: string[]): void;
  65842. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  65843. private _injectVertexCode;
  65844. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  65845. serialize(): any;
  65846. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  65847. }
  65848. }
  65849. declare module "babylonjs/Materials/Node/Blocks/Dual/reflectionTextureBlock" {
  65850. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  65851. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  65852. import { NodeMaterial } from "babylonjs/Materials/Node/nodeMaterial";
  65853. import { ReflectionTextureBaseBlock } from "babylonjs/Materials/Node/Blocks/Dual/reflectionTextureBaseBlock";
  65854. /**
  65855. * Block used to read a reflection texture from a sampler
  65856. */
  65857. export class ReflectionTextureBlock extends ReflectionTextureBaseBlock {
  65858. /**
  65859. * Create a new ReflectionTextureBlock
  65860. * @param name defines the block name
  65861. */
  65862. constructor(name: string);
  65863. /**
  65864. * Gets the current class name
  65865. * @returns the class name
  65866. */
  65867. getClassName(): string;
  65868. /**
  65869. * Gets the world position input component
  65870. */
  65871. get position(): NodeMaterialConnectionPoint;
  65872. /**
  65873. * Gets the world position input component
  65874. */
  65875. get worldPosition(): NodeMaterialConnectionPoint;
  65876. /**
  65877. * Gets the world normal input component
  65878. */
  65879. get worldNormal(): NodeMaterialConnectionPoint;
  65880. /**
  65881. * Gets the world input component
  65882. */
  65883. get world(): NodeMaterialConnectionPoint;
  65884. /**
  65885. * Gets the camera (or eye) position component
  65886. */
  65887. get cameraPosition(): NodeMaterialConnectionPoint;
  65888. /**
  65889. * Gets the view input component
  65890. */
  65891. get view(): NodeMaterialConnectionPoint;
  65892. /**
  65893. * Gets the rgb output component
  65894. */
  65895. get rgb(): NodeMaterialConnectionPoint;
  65896. /**
  65897. * Gets the rgba output component
  65898. */
  65899. get rgba(): NodeMaterialConnectionPoint;
  65900. /**
  65901. * Gets the r output component
  65902. */
  65903. get r(): NodeMaterialConnectionPoint;
  65904. /**
  65905. * Gets the g output component
  65906. */
  65907. get g(): NodeMaterialConnectionPoint;
  65908. /**
  65909. * Gets the b output component
  65910. */
  65911. get b(): NodeMaterialConnectionPoint;
  65912. /**
  65913. * Gets the a output component
  65914. */
  65915. get a(): NodeMaterialConnectionPoint;
  65916. autoConfigure(material: NodeMaterial): void;
  65917. protected _buildBlock(state: NodeMaterialBuildState): this;
  65918. }
  65919. }
  65920. declare module "babylonjs/Materials/Node/Blocks/Dual/index" {
  65921. export * from "babylonjs/Materials/Node/Blocks/Dual/fogBlock";
  65922. export * from "babylonjs/Materials/Node/Blocks/Dual/lightBlock";
  65923. export * from "babylonjs/Materials/Node/Blocks/Dual/textureBlock";
  65924. export * from "babylonjs/Materials/Node/Blocks/Dual/reflectionTextureBlock";
  65925. export * from "babylonjs/Materials/Node/Blocks/Dual/currentScreenBlock";
  65926. }
  65927. declare module "babylonjs/Materials/Node/Blocks/Input/index" {
  65928. export * from "babylonjs/Materials/Node/Blocks/Input/inputBlock";
  65929. export * from "babylonjs/Materials/Node/Blocks/Input/animatedInputBlockTypes";
  65930. }
  65931. declare module "babylonjs/Materials/Node/Blocks/addBlock" {
  65932. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  65933. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  65934. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  65935. /**
  65936. * Block used to add 2 vectors
  65937. */
  65938. export class AddBlock extends NodeMaterialBlock {
  65939. /**
  65940. * Creates a new AddBlock
  65941. * @param name defines the block name
  65942. */
  65943. constructor(name: string);
  65944. /**
  65945. * Gets the current class name
  65946. * @returns the class name
  65947. */
  65948. getClassName(): string;
  65949. /**
  65950. * Gets the left operand input component
  65951. */
  65952. get left(): NodeMaterialConnectionPoint;
  65953. /**
  65954. * Gets the right operand input component
  65955. */
  65956. get right(): NodeMaterialConnectionPoint;
  65957. /**
  65958. * Gets the output component
  65959. */
  65960. get output(): NodeMaterialConnectionPoint;
  65961. protected _buildBlock(state: NodeMaterialBuildState): this;
  65962. }
  65963. }
  65964. declare module "babylonjs/Materials/Node/Blocks/scaleBlock" {
  65965. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  65966. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  65967. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  65968. /**
  65969. * Block used to scale a vector by a float
  65970. */
  65971. export class ScaleBlock extends NodeMaterialBlock {
  65972. /**
  65973. * Creates a new ScaleBlock
  65974. * @param name defines the block name
  65975. */
  65976. constructor(name: string);
  65977. /**
  65978. * Gets the current class name
  65979. * @returns the class name
  65980. */
  65981. getClassName(): string;
  65982. /**
  65983. * Gets the input component
  65984. */
  65985. get input(): NodeMaterialConnectionPoint;
  65986. /**
  65987. * Gets the factor input component
  65988. */
  65989. get factor(): NodeMaterialConnectionPoint;
  65990. /**
  65991. * Gets the output component
  65992. */
  65993. get output(): NodeMaterialConnectionPoint;
  65994. protected _buildBlock(state: NodeMaterialBuildState): this;
  65995. }
  65996. }
  65997. declare module "babylonjs/Materials/Node/Blocks/clampBlock" {
  65998. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  65999. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  66000. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  66001. import { Scene } from "babylonjs/scene";
  66002. /**
  66003. * Block used to clamp a float
  66004. */
  66005. export class ClampBlock extends NodeMaterialBlock {
  66006. /** Gets or sets the minimum range */
  66007. minimum: number;
  66008. /** Gets or sets the maximum range */
  66009. maximum: number;
  66010. /**
  66011. * Creates a new ClampBlock
  66012. * @param name defines the block name
  66013. */
  66014. constructor(name: string);
  66015. /**
  66016. * Gets the current class name
  66017. * @returns the class name
  66018. */
  66019. getClassName(): string;
  66020. /**
  66021. * Gets the value input component
  66022. */
  66023. get value(): NodeMaterialConnectionPoint;
  66024. /**
  66025. * Gets the output component
  66026. */
  66027. get output(): NodeMaterialConnectionPoint;
  66028. protected _buildBlock(state: NodeMaterialBuildState): this;
  66029. protected _dumpPropertiesCode(): string;
  66030. serialize(): any;
  66031. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  66032. }
  66033. }
  66034. declare module "babylonjs/Materials/Node/Blocks/crossBlock" {
  66035. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  66036. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  66037. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  66038. /**
  66039. * Block used to apply a cross product between 2 vectors
  66040. */
  66041. export class CrossBlock extends NodeMaterialBlock {
  66042. /**
  66043. * Creates a new CrossBlock
  66044. * @param name defines the block name
  66045. */
  66046. constructor(name: string);
  66047. /**
  66048. * Gets the current class name
  66049. * @returns the class name
  66050. */
  66051. getClassName(): string;
  66052. /**
  66053. * Gets the left operand input component
  66054. */
  66055. get left(): NodeMaterialConnectionPoint;
  66056. /**
  66057. * Gets the right operand input component
  66058. */
  66059. get right(): NodeMaterialConnectionPoint;
  66060. /**
  66061. * Gets the output component
  66062. */
  66063. get output(): NodeMaterialConnectionPoint;
  66064. protected _buildBlock(state: NodeMaterialBuildState): this;
  66065. }
  66066. }
  66067. declare module "babylonjs/Materials/Node/Blocks/dotBlock" {
  66068. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  66069. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  66070. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  66071. /**
  66072. * Block used to apply a dot product between 2 vectors
  66073. */
  66074. export class DotBlock extends NodeMaterialBlock {
  66075. /**
  66076. * Creates a new DotBlock
  66077. * @param name defines the block name
  66078. */
  66079. constructor(name: string);
  66080. /**
  66081. * Gets the current class name
  66082. * @returns the class name
  66083. */
  66084. getClassName(): string;
  66085. /**
  66086. * Gets the left operand input component
  66087. */
  66088. get left(): NodeMaterialConnectionPoint;
  66089. /**
  66090. * Gets the right operand input component
  66091. */
  66092. get right(): NodeMaterialConnectionPoint;
  66093. /**
  66094. * Gets the output component
  66095. */
  66096. get output(): NodeMaterialConnectionPoint;
  66097. protected _buildBlock(state: NodeMaterialBuildState): this;
  66098. }
  66099. }
  66100. declare module "babylonjs/Materials/Node/Blocks/normalizeBlock" {
  66101. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  66102. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  66103. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  66104. /**
  66105. * Block used to normalize a vector
  66106. */
  66107. export class NormalizeBlock extends NodeMaterialBlock {
  66108. /**
  66109. * Creates a new NormalizeBlock
  66110. * @param name defines the block name
  66111. */
  66112. constructor(name: string);
  66113. /**
  66114. * Gets the current class name
  66115. * @returns the class name
  66116. */
  66117. getClassName(): string;
  66118. /**
  66119. * Gets the input component
  66120. */
  66121. get input(): NodeMaterialConnectionPoint;
  66122. /**
  66123. * Gets the output component
  66124. */
  66125. get output(): NodeMaterialConnectionPoint;
  66126. protected _buildBlock(state: NodeMaterialBuildState): this;
  66127. }
  66128. }
  66129. declare module "babylonjs/Materials/Node/Blocks/trigonometryBlock" {
  66130. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  66131. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  66132. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  66133. import { Scene } from "babylonjs/scene";
  66134. /**
  66135. * Operations supported by the Trigonometry block
  66136. */
  66137. export enum TrigonometryBlockOperations {
  66138. /** Cos */
  66139. Cos = 0,
  66140. /** Sin */
  66141. Sin = 1,
  66142. /** Abs */
  66143. Abs = 2,
  66144. /** Exp */
  66145. Exp = 3,
  66146. /** Exp2 */
  66147. Exp2 = 4,
  66148. /** Round */
  66149. Round = 5,
  66150. /** Floor */
  66151. Floor = 6,
  66152. /** Ceiling */
  66153. Ceiling = 7,
  66154. /** Square root */
  66155. Sqrt = 8,
  66156. /** Log */
  66157. Log = 9,
  66158. /** Tangent */
  66159. Tan = 10,
  66160. /** Arc tangent */
  66161. ArcTan = 11,
  66162. /** Arc cosinus */
  66163. ArcCos = 12,
  66164. /** Arc sinus */
  66165. ArcSin = 13,
  66166. /** Fraction */
  66167. Fract = 14,
  66168. /** Sign */
  66169. Sign = 15,
  66170. /** To radians (from degrees) */
  66171. Radians = 16,
  66172. /** To degrees (from radians) */
  66173. Degrees = 17
  66174. }
  66175. /**
  66176. * Block used to apply trigonometry operation to floats
  66177. */
  66178. export class TrigonometryBlock extends NodeMaterialBlock {
  66179. /**
  66180. * Gets or sets the operation applied by the block
  66181. */
  66182. operation: TrigonometryBlockOperations;
  66183. /**
  66184. * Creates a new TrigonometryBlock
  66185. * @param name defines the block name
  66186. */
  66187. constructor(name: string);
  66188. /**
  66189. * Gets the current class name
  66190. * @returns the class name
  66191. */
  66192. getClassName(): string;
  66193. /**
  66194. * Gets the input component
  66195. */
  66196. get input(): NodeMaterialConnectionPoint;
  66197. /**
  66198. * Gets the output component
  66199. */
  66200. get output(): NodeMaterialConnectionPoint;
  66201. protected _buildBlock(state: NodeMaterialBuildState): this;
  66202. serialize(): any;
  66203. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  66204. protected _dumpPropertiesCode(): string;
  66205. }
  66206. }
  66207. declare module "babylonjs/Materials/Node/Blocks/colorMergerBlock" {
  66208. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  66209. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  66210. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  66211. /**
  66212. * Block used to create a Color3/4 out of individual inputs (one for each component)
  66213. */
  66214. export class ColorMergerBlock extends NodeMaterialBlock {
  66215. /**
  66216. * Create a new ColorMergerBlock
  66217. * @param name defines the block name
  66218. */
  66219. constructor(name: string);
  66220. /**
  66221. * Gets the current class name
  66222. * @returns the class name
  66223. */
  66224. getClassName(): string;
  66225. /**
  66226. * Gets the rgb component (input)
  66227. */
  66228. get rgbIn(): NodeMaterialConnectionPoint;
  66229. /**
  66230. * Gets the r component (input)
  66231. */
  66232. get r(): NodeMaterialConnectionPoint;
  66233. /**
  66234. * Gets the g component (input)
  66235. */
  66236. get g(): NodeMaterialConnectionPoint;
  66237. /**
  66238. * Gets the b component (input)
  66239. */
  66240. get b(): NodeMaterialConnectionPoint;
  66241. /**
  66242. * Gets the a component (input)
  66243. */
  66244. get a(): NodeMaterialConnectionPoint;
  66245. /**
  66246. * Gets the rgba component (output)
  66247. */
  66248. get rgba(): NodeMaterialConnectionPoint;
  66249. /**
  66250. * Gets the rgb component (output)
  66251. */
  66252. get rgbOut(): NodeMaterialConnectionPoint;
  66253. /**
  66254. * Gets the rgb component (output)
  66255. * @deprecated Please use rgbOut instead.
  66256. */
  66257. get rgb(): NodeMaterialConnectionPoint;
  66258. protected _buildBlock(state: NodeMaterialBuildState): this;
  66259. }
  66260. }
  66261. declare module "babylonjs/Materials/Node/Blocks/vectorSplitterBlock" {
  66262. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  66263. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  66264. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  66265. /**
  66266. * Block used to expand a Vector3/4 into 4 outputs (one for each component)
  66267. */
  66268. export class VectorSplitterBlock extends NodeMaterialBlock {
  66269. /**
  66270. * Create a new VectorSplitterBlock
  66271. * @param name defines the block name
  66272. */
  66273. constructor(name: string);
  66274. /**
  66275. * Gets the current class name
  66276. * @returns the class name
  66277. */
  66278. getClassName(): string;
  66279. /**
  66280. * Gets the xyzw component (input)
  66281. */
  66282. get xyzw(): NodeMaterialConnectionPoint;
  66283. /**
  66284. * Gets the xyz component (input)
  66285. */
  66286. get xyzIn(): NodeMaterialConnectionPoint;
  66287. /**
  66288. * Gets the xy component (input)
  66289. */
  66290. get xyIn(): NodeMaterialConnectionPoint;
  66291. /**
  66292. * Gets the xyz component (output)
  66293. */
  66294. get xyzOut(): NodeMaterialConnectionPoint;
  66295. /**
  66296. * Gets the xy component (output)
  66297. */
  66298. get xyOut(): NodeMaterialConnectionPoint;
  66299. /**
  66300. * Gets the x component (output)
  66301. */
  66302. get x(): NodeMaterialConnectionPoint;
  66303. /**
  66304. * Gets the y component (output)
  66305. */
  66306. get y(): NodeMaterialConnectionPoint;
  66307. /**
  66308. * Gets the z component (output)
  66309. */
  66310. get z(): NodeMaterialConnectionPoint;
  66311. /**
  66312. * Gets the w component (output)
  66313. */
  66314. get w(): NodeMaterialConnectionPoint;
  66315. protected _inputRename(name: string): string;
  66316. protected _outputRename(name: string): string;
  66317. protected _buildBlock(state: NodeMaterialBuildState): this;
  66318. }
  66319. }
  66320. declare module "babylonjs/Materials/Node/Blocks/lerpBlock" {
  66321. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  66322. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  66323. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  66324. /**
  66325. * Block used to lerp between 2 values
  66326. */
  66327. export class LerpBlock extends NodeMaterialBlock {
  66328. /**
  66329. * Creates a new LerpBlock
  66330. * @param name defines the block name
  66331. */
  66332. constructor(name: string);
  66333. /**
  66334. * Gets the current class name
  66335. * @returns the class name
  66336. */
  66337. getClassName(): string;
  66338. /**
  66339. * Gets the left operand input component
  66340. */
  66341. get left(): NodeMaterialConnectionPoint;
  66342. /**
  66343. * Gets the right operand input component
  66344. */
  66345. get right(): NodeMaterialConnectionPoint;
  66346. /**
  66347. * Gets the gradient operand input component
  66348. */
  66349. get gradient(): NodeMaterialConnectionPoint;
  66350. /**
  66351. * Gets the output component
  66352. */
  66353. get output(): NodeMaterialConnectionPoint;
  66354. protected _buildBlock(state: NodeMaterialBuildState): this;
  66355. }
  66356. }
  66357. declare module "babylonjs/Materials/Node/Blocks/divideBlock" {
  66358. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  66359. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  66360. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  66361. /**
  66362. * Block used to divide 2 vectors
  66363. */
  66364. export class DivideBlock extends NodeMaterialBlock {
  66365. /**
  66366. * Creates a new DivideBlock
  66367. * @param name defines the block name
  66368. */
  66369. constructor(name: string);
  66370. /**
  66371. * Gets the current class name
  66372. * @returns the class name
  66373. */
  66374. getClassName(): string;
  66375. /**
  66376. * Gets the left operand input component
  66377. */
  66378. get left(): NodeMaterialConnectionPoint;
  66379. /**
  66380. * Gets the right operand input component
  66381. */
  66382. get right(): NodeMaterialConnectionPoint;
  66383. /**
  66384. * Gets the output component
  66385. */
  66386. get output(): NodeMaterialConnectionPoint;
  66387. protected _buildBlock(state: NodeMaterialBuildState): this;
  66388. }
  66389. }
  66390. declare module "babylonjs/Materials/Node/Blocks/subtractBlock" {
  66391. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  66392. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  66393. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  66394. /**
  66395. * Block used to subtract 2 vectors
  66396. */
  66397. export class SubtractBlock extends NodeMaterialBlock {
  66398. /**
  66399. * Creates a new SubtractBlock
  66400. * @param name defines the block name
  66401. */
  66402. constructor(name: string);
  66403. /**
  66404. * Gets the current class name
  66405. * @returns the class name
  66406. */
  66407. getClassName(): string;
  66408. /**
  66409. * Gets the left operand input component
  66410. */
  66411. get left(): NodeMaterialConnectionPoint;
  66412. /**
  66413. * Gets the right operand input component
  66414. */
  66415. get right(): NodeMaterialConnectionPoint;
  66416. /**
  66417. * Gets the output component
  66418. */
  66419. get output(): NodeMaterialConnectionPoint;
  66420. protected _buildBlock(state: NodeMaterialBuildState): this;
  66421. }
  66422. }
  66423. declare module "babylonjs/Materials/Node/Blocks/stepBlock" {
  66424. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  66425. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  66426. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  66427. /**
  66428. * Block used to step a value
  66429. */
  66430. export class StepBlock extends NodeMaterialBlock {
  66431. /**
  66432. * Creates a new StepBlock
  66433. * @param name defines the block name
  66434. */
  66435. constructor(name: string);
  66436. /**
  66437. * Gets the current class name
  66438. * @returns the class name
  66439. */
  66440. getClassName(): string;
  66441. /**
  66442. * Gets the value operand input component
  66443. */
  66444. get value(): NodeMaterialConnectionPoint;
  66445. /**
  66446. * Gets the edge operand input component
  66447. */
  66448. get edge(): NodeMaterialConnectionPoint;
  66449. /**
  66450. * Gets the output component
  66451. */
  66452. get output(): NodeMaterialConnectionPoint;
  66453. protected _buildBlock(state: NodeMaterialBuildState): this;
  66454. }
  66455. }
  66456. declare module "babylonjs/Materials/Node/Blocks/oneMinusBlock" {
  66457. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  66458. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  66459. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  66460. /**
  66461. * Block used to get the opposite (1 - x) of a value
  66462. */
  66463. export class OneMinusBlock extends NodeMaterialBlock {
  66464. /**
  66465. * Creates a new OneMinusBlock
  66466. * @param name defines the block name
  66467. */
  66468. constructor(name: string);
  66469. /**
  66470. * Gets the current class name
  66471. * @returns the class name
  66472. */
  66473. getClassName(): string;
  66474. /**
  66475. * Gets the input component
  66476. */
  66477. get input(): NodeMaterialConnectionPoint;
  66478. /**
  66479. * Gets the output component
  66480. */
  66481. get output(): NodeMaterialConnectionPoint;
  66482. protected _buildBlock(state: NodeMaterialBuildState): this;
  66483. }
  66484. }
  66485. declare module "babylonjs/Materials/Node/Blocks/viewDirectionBlock" {
  66486. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  66487. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  66488. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  66489. import { NodeMaterial } from "babylonjs/Materials/Node/nodeMaterial";
  66490. /**
  66491. * Block used to get the view direction
  66492. */
  66493. export class ViewDirectionBlock extends NodeMaterialBlock {
  66494. /**
  66495. * Creates a new ViewDirectionBlock
  66496. * @param name defines the block name
  66497. */
  66498. constructor(name: string);
  66499. /**
  66500. * Gets the current class name
  66501. * @returns the class name
  66502. */
  66503. getClassName(): string;
  66504. /**
  66505. * Gets the world position component
  66506. */
  66507. get worldPosition(): NodeMaterialConnectionPoint;
  66508. /**
  66509. * Gets the camera position component
  66510. */
  66511. get cameraPosition(): NodeMaterialConnectionPoint;
  66512. /**
  66513. * Gets the output component
  66514. */
  66515. get output(): NodeMaterialConnectionPoint;
  66516. autoConfigure(material: NodeMaterial): void;
  66517. protected _buildBlock(state: NodeMaterialBuildState): this;
  66518. }
  66519. }
  66520. declare module "babylonjs/Materials/Node/Blocks/fresnelBlock" {
  66521. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  66522. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  66523. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  66524. import { NodeMaterial } from "babylonjs/Materials/Node/nodeMaterial";
  66525. import "babylonjs/Shaders/ShadersInclude/fresnelFunction";
  66526. /**
  66527. * Block used to compute fresnel value
  66528. */
  66529. export class FresnelBlock extends NodeMaterialBlock {
  66530. /**
  66531. * Create a new FresnelBlock
  66532. * @param name defines the block name
  66533. */
  66534. constructor(name: string);
  66535. /**
  66536. * Gets the current class name
  66537. * @returns the class name
  66538. */
  66539. getClassName(): string;
  66540. /**
  66541. * Gets the world normal input component
  66542. */
  66543. get worldNormal(): NodeMaterialConnectionPoint;
  66544. /**
  66545. * Gets the view direction input component
  66546. */
  66547. get viewDirection(): NodeMaterialConnectionPoint;
  66548. /**
  66549. * Gets the bias input component
  66550. */
  66551. get bias(): NodeMaterialConnectionPoint;
  66552. /**
  66553. * Gets the camera (or eye) position component
  66554. */
  66555. get power(): NodeMaterialConnectionPoint;
  66556. /**
  66557. * Gets the fresnel output component
  66558. */
  66559. get fresnel(): NodeMaterialConnectionPoint;
  66560. autoConfigure(material: NodeMaterial): void;
  66561. protected _buildBlock(state: NodeMaterialBuildState): this;
  66562. }
  66563. }
  66564. declare module "babylonjs/Materials/Node/Blocks/maxBlock" {
  66565. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  66566. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  66567. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  66568. /**
  66569. * Block used to get the max of 2 values
  66570. */
  66571. export class MaxBlock extends NodeMaterialBlock {
  66572. /**
  66573. * Creates a new MaxBlock
  66574. * @param name defines the block name
  66575. */
  66576. constructor(name: string);
  66577. /**
  66578. * Gets the current class name
  66579. * @returns the class name
  66580. */
  66581. getClassName(): string;
  66582. /**
  66583. * Gets the left operand input component
  66584. */
  66585. get left(): NodeMaterialConnectionPoint;
  66586. /**
  66587. * Gets the right operand input component
  66588. */
  66589. get right(): NodeMaterialConnectionPoint;
  66590. /**
  66591. * Gets the output component
  66592. */
  66593. get output(): NodeMaterialConnectionPoint;
  66594. protected _buildBlock(state: NodeMaterialBuildState): this;
  66595. }
  66596. }
  66597. declare module "babylonjs/Materials/Node/Blocks/minBlock" {
  66598. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  66599. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  66600. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  66601. /**
  66602. * Block used to get the min of 2 values
  66603. */
  66604. export class MinBlock extends NodeMaterialBlock {
  66605. /**
  66606. * Creates a new MinBlock
  66607. * @param name defines the block name
  66608. */
  66609. constructor(name: string);
  66610. /**
  66611. * Gets the current class name
  66612. * @returns the class name
  66613. */
  66614. getClassName(): string;
  66615. /**
  66616. * Gets the left operand input component
  66617. */
  66618. get left(): NodeMaterialConnectionPoint;
  66619. /**
  66620. * Gets the right operand input component
  66621. */
  66622. get right(): NodeMaterialConnectionPoint;
  66623. /**
  66624. * Gets the output component
  66625. */
  66626. get output(): NodeMaterialConnectionPoint;
  66627. protected _buildBlock(state: NodeMaterialBuildState): this;
  66628. }
  66629. }
  66630. declare module "babylonjs/Materials/Node/Blocks/distanceBlock" {
  66631. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  66632. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  66633. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  66634. /**
  66635. * Block used to get the distance between 2 values
  66636. */
  66637. export class DistanceBlock extends NodeMaterialBlock {
  66638. /**
  66639. * Creates a new DistanceBlock
  66640. * @param name defines the block name
  66641. */
  66642. constructor(name: string);
  66643. /**
  66644. * Gets the current class name
  66645. * @returns the class name
  66646. */
  66647. getClassName(): string;
  66648. /**
  66649. * Gets the left operand input component
  66650. */
  66651. get left(): NodeMaterialConnectionPoint;
  66652. /**
  66653. * Gets the right operand input component
  66654. */
  66655. get right(): NodeMaterialConnectionPoint;
  66656. /**
  66657. * Gets the output component
  66658. */
  66659. get output(): NodeMaterialConnectionPoint;
  66660. protected _buildBlock(state: NodeMaterialBuildState): this;
  66661. }
  66662. }
  66663. declare module "babylonjs/Materials/Node/Blocks/lengthBlock" {
  66664. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  66665. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  66666. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  66667. /**
  66668. * Block used to get the length of a vector
  66669. */
  66670. export class LengthBlock extends NodeMaterialBlock {
  66671. /**
  66672. * Creates a new LengthBlock
  66673. * @param name defines the block name
  66674. */
  66675. constructor(name: string);
  66676. /**
  66677. * Gets the current class name
  66678. * @returns the class name
  66679. */
  66680. getClassName(): string;
  66681. /**
  66682. * Gets the value input component
  66683. */
  66684. get value(): NodeMaterialConnectionPoint;
  66685. /**
  66686. * Gets the output component
  66687. */
  66688. get output(): NodeMaterialConnectionPoint;
  66689. protected _buildBlock(state: NodeMaterialBuildState): this;
  66690. }
  66691. }
  66692. declare module "babylonjs/Materials/Node/Blocks/negateBlock" {
  66693. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  66694. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  66695. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  66696. /**
  66697. * Block used to get negative version of a value (i.e. x * -1)
  66698. */
  66699. export class NegateBlock extends NodeMaterialBlock {
  66700. /**
  66701. * Creates a new NegateBlock
  66702. * @param name defines the block name
  66703. */
  66704. constructor(name: string);
  66705. /**
  66706. * Gets the current class name
  66707. * @returns the class name
  66708. */
  66709. getClassName(): string;
  66710. /**
  66711. * Gets the value input component
  66712. */
  66713. get value(): NodeMaterialConnectionPoint;
  66714. /**
  66715. * Gets the output component
  66716. */
  66717. get output(): NodeMaterialConnectionPoint;
  66718. protected _buildBlock(state: NodeMaterialBuildState): this;
  66719. }
  66720. }
  66721. declare module "babylonjs/Materials/Node/Blocks/powBlock" {
  66722. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  66723. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  66724. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  66725. /**
  66726. * Block used to get the value of the first parameter raised to the power of the second
  66727. */
  66728. export class PowBlock extends NodeMaterialBlock {
  66729. /**
  66730. * Creates a new PowBlock
  66731. * @param name defines the block name
  66732. */
  66733. constructor(name: string);
  66734. /**
  66735. * Gets the current class name
  66736. * @returns the class name
  66737. */
  66738. getClassName(): string;
  66739. /**
  66740. * Gets the value operand input component
  66741. */
  66742. get value(): NodeMaterialConnectionPoint;
  66743. /**
  66744. * Gets the power operand input component
  66745. */
  66746. get power(): NodeMaterialConnectionPoint;
  66747. /**
  66748. * Gets the output component
  66749. */
  66750. get output(): NodeMaterialConnectionPoint;
  66751. protected _buildBlock(state: NodeMaterialBuildState): this;
  66752. }
  66753. }
  66754. declare module "babylonjs/Materials/Node/Blocks/randomNumberBlock" {
  66755. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  66756. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  66757. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  66758. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  66759. /**
  66760. * Block used to get a random number
  66761. */
  66762. export class RandomNumberBlock extends NodeMaterialBlock {
  66763. /**
  66764. * Creates a new RandomNumberBlock
  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 seed input component
  66775. */
  66776. get seed(): NodeMaterialConnectionPoint;
  66777. /**
  66778. * Gets the output component
  66779. */
  66780. get output(): NodeMaterialConnectionPoint;
  66781. protected _buildBlock(state: NodeMaterialBuildState): this;
  66782. }
  66783. }
  66784. declare module "babylonjs/Materials/Node/Blocks/arcTan2Block" {
  66785. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  66786. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  66787. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  66788. /**
  66789. * Block used to compute arc tangent of 2 values
  66790. */
  66791. export class ArcTan2Block extends NodeMaterialBlock {
  66792. /**
  66793. * Creates a new ArcTan2Block
  66794. * @param name defines the block name
  66795. */
  66796. constructor(name: string);
  66797. /**
  66798. * Gets the current class name
  66799. * @returns the class name
  66800. */
  66801. getClassName(): string;
  66802. /**
  66803. * Gets the x operand input component
  66804. */
  66805. get x(): NodeMaterialConnectionPoint;
  66806. /**
  66807. * Gets the y operand input component
  66808. */
  66809. get y(): 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/smoothStepBlock" {
  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 smooth step a value
  66823. */
  66824. export class SmoothStepBlock extends NodeMaterialBlock {
  66825. /**
  66826. * Creates a new SmoothStepBlock
  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 operand input component
  66837. */
  66838. get value(): NodeMaterialConnectionPoint;
  66839. /**
  66840. * Gets the first edge operand input component
  66841. */
  66842. get edge0(): NodeMaterialConnectionPoint;
  66843. /**
  66844. * Gets the second edge operand input component
  66845. */
  66846. get edge1(): NodeMaterialConnectionPoint;
  66847. /**
  66848. * Gets the output component
  66849. */
  66850. get output(): NodeMaterialConnectionPoint;
  66851. protected _buildBlock(state: NodeMaterialBuildState): this;
  66852. }
  66853. }
  66854. declare module "babylonjs/Materials/Node/Blocks/reciprocalBlock" {
  66855. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  66856. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  66857. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  66858. /**
  66859. * Block used to get the reciprocal (1 / x) of a value
  66860. */
  66861. export class ReciprocalBlock extends NodeMaterialBlock {
  66862. /**
  66863. * Creates a new ReciprocalBlock
  66864. * @param name defines the block name
  66865. */
  66866. constructor(name: string);
  66867. /**
  66868. * Gets the current class name
  66869. * @returns the class name
  66870. */
  66871. getClassName(): string;
  66872. /**
  66873. * Gets the input component
  66874. */
  66875. get input(): NodeMaterialConnectionPoint;
  66876. /**
  66877. * Gets the output component
  66878. */
  66879. get output(): NodeMaterialConnectionPoint;
  66880. protected _buildBlock(state: NodeMaterialBuildState): this;
  66881. }
  66882. }
  66883. declare module "babylonjs/Materials/Node/Blocks/replaceColorBlock" {
  66884. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  66885. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  66886. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  66887. /**
  66888. * Block used to replace a color by another one
  66889. */
  66890. export class ReplaceColorBlock extends NodeMaterialBlock {
  66891. /**
  66892. * Creates a new ReplaceColorBlock
  66893. * @param name defines the block name
  66894. */
  66895. constructor(name: string);
  66896. /**
  66897. * Gets the current class name
  66898. * @returns the class name
  66899. */
  66900. getClassName(): string;
  66901. /**
  66902. * Gets the value input component
  66903. */
  66904. get value(): NodeMaterialConnectionPoint;
  66905. /**
  66906. * Gets the reference input component
  66907. */
  66908. get reference(): NodeMaterialConnectionPoint;
  66909. /**
  66910. * Gets the distance input component
  66911. */
  66912. get distance(): NodeMaterialConnectionPoint;
  66913. /**
  66914. * Gets the replacement input component
  66915. */
  66916. get replacement(): NodeMaterialConnectionPoint;
  66917. /**
  66918. * Gets the output component
  66919. */
  66920. get output(): NodeMaterialConnectionPoint;
  66921. protected _buildBlock(state: NodeMaterialBuildState): this;
  66922. }
  66923. }
  66924. declare module "babylonjs/Materials/Node/Blocks/posterizeBlock" {
  66925. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  66926. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  66927. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  66928. /**
  66929. * Block used to posterize a value
  66930. * @see https://en.wikipedia.org/wiki/Posterization
  66931. */
  66932. export class PosterizeBlock extends NodeMaterialBlock {
  66933. /**
  66934. * Creates a new PosterizeBlock
  66935. * @param name defines the block name
  66936. */
  66937. constructor(name: string);
  66938. /**
  66939. * Gets the current class name
  66940. * @returns the class name
  66941. */
  66942. getClassName(): string;
  66943. /**
  66944. * Gets the value input component
  66945. */
  66946. get value(): NodeMaterialConnectionPoint;
  66947. /**
  66948. * Gets the steps input component
  66949. */
  66950. get steps(): NodeMaterialConnectionPoint;
  66951. /**
  66952. * Gets the output component
  66953. */
  66954. get output(): NodeMaterialConnectionPoint;
  66955. protected _buildBlock(state: NodeMaterialBuildState): this;
  66956. }
  66957. }
  66958. declare module "babylonjs/Materials/Node/Blocks/waveBlock" {
  66959. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  66960. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  66961. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  66962. import { Scene } from "babylonjs/scene";
  66963. /**
  66964. * Operations supported by the Wave block
  66965. */
  66966. export enum WaveBlockKind {
  66967. /** SawTooth */
  66968. SawTooth = 0,
  66969. /** Square */
  66970. Square = 1,
  66971. /** Triangle */
  66972. Triangle = 2
  66973. }
  66974. /**
  66975. * Block used to apply wave operation to floats
  66976. */
  66977. export class WaveBlock extends NodeMaterialBlock {
  66978. /**
  66979. * Gets or sets the kibnd of wave to be applied by the block
  66980. */
  66981. kind: WaveBlockKind;
  66982. /**
  66983. * Creates a new WaveBlock
  66984. * @param name defines the block name
  66985. */
  66986. constructor(name: string);
  66987. /**
  66988. * Gets the current class name
  66989. * @returns the class name
  66990. */
  66991. getClassName(): string;
  66992. /**
  66993. * Gets the input component
  66994. */
  66995. get input(): NodeMaterialConnectionPoint;
  66996. /**
  66997. * Gets the output component
  66998. */
  66999. get output(): NodeMaterialConnectionPoint;
  67000. protected _buildBlock(state: NodeMaterialBuildState): this;
  67001. serialize(): any;
  67002. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  67003. }
  67004. }
  67005. declare module "babylonjs/Materials/Node/Blocks/gradientBlock" {
  67006. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  67007. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  67008. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  67009. import { Color3 } from "babylonjs/Maths/math.color";
  67010. import { Scene } from "babylonjs/scene";
  67011. /**
  67012. * Class used to store a color step for the GradientBlock
  67013. */
  67014. export class GradientBlockColorStep {
  67015. /**
  67016. * Gets or sets a value indicating which step this color is associated with (between 0 and 1)
  67017. */
  67018. step: number;
  67019. /**
  67020. * Gets or sets the color associated with this step
  67021. */
  67022. color: Color3;
  67023. /**
  67024. * Creates a new GradientBlockColorStep
  67025. * @param step defines a value indicating which step this color is associated with (between 0 and 1)
  67026. * @param color defines the color associated with this step
  67027. */
  67028. constructor(
  67029. /**
  67030. * Gets or sets a value indicating which step this color is associated with (between 0 and 1)
  67031. */
  67032. step: number,
  67033. /**
  67034. * Gets or sets the color associated with this step
  67035. */
  67036. color: Color3);
  67037. }
  67038. /**
  67039. * Block used to return a color from a gradient based on an input value between 0 and 1
  67040. */
  67041. export class GradientBlock extends NodeMaterialBlock {
  67042. /**
  67043. * Gets or sets the list of color steps
  67044. */
  67045. colorSteps: GradientBlockColorStep[];
  67046. /**
  67047. * Creates a new GradientBlock
  67048. * @param name defines the block name
  67049. */
  67050. constructor(name: string);
  67051. /**
  67052. * Gets the current class name
  67053. * @returns the class name
  67054. */
  67055. getClassName(): string;
  67056. /**
  67057. * Gets the gradient input component
  67058. */
  67059. get gradient(): NodeMaterialConnectionPoint;
  67060. /**
  67061. * Gets the output component
  67062. */
  67063. get output(): NodeMaterialConnectionPoint;
  67064. private _writeColorConstant;
  67065. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  67066. serialize(): any;
  67067. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  67068. protected _dumpPropertiesCode(): string;
  67069. }
  67070. }
  67071. declare module "babylonjs/Materials/Node/Blocks/nLerpBlock" {
  67072. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  67073. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  67074. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  67075. /**
  67076. * Block used to normalize lerp between 2 values
  67077. */
  67078. export class NLerpBlock extends NodeMaterialBlock {
  67079. /**
  67080. * Creates a new NLerpBlock
  67081. * @param name defines the block name
  67082. */
  67083. constructor(name: string);
  67084. /**
  67085. * Gets the current class name
  67086. * @returns the class name
  67087. */
  67088. getClassName(): string;
  67089. /**
  67090. * Gets the left operand input component
  67091. */
  67092. get left(): NodeMaterialConnectionPoint;
  67093. /**
  67094. * Gets the right operand input component
  67095. */
  67096. get right(): NodeMaterialConnectionPoint;
  67097. /**
  67098. * Gets the gradient operand input component
  67099. */
  67100. get gradient(): NodeMaterialConnectionPoint;
  67101. /**
  67102. * Gets the output component
  67103. */
  67104. get output(): NodeMaterialConnectionPoint;
  67105. protected _buildBlock(state: NodeMaterialBuildState): this;
  67106. }
  67107. }
  67108. declare module "babylonjs/Materials/Node/Blocks/worleyNoise3DBlock" {
  67109. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  67110. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  67111. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  67112. import { Scene } from "babylonjs/scene";
  67113. /**
  67114. * block used to Generate a Worley Noise 3D Noise Pattern
  67115. */
  67116. export class WorleyNoise3DBlock extends NodeMaterialBlock {
  67117. /** Gets or sets a boolean indicating that normal should be inverted on X axis */
  67118. manhattanDistance: boolean;
  67119. /**
  67120. * Creates a new WorleyNoise3DBlock
  67121. * @param name defines the block name
  67122. */
  67123. constructor(name: string);
  67124. /**
  67125. * Gets the current class name
  67126. * @returns the class name
  67127. */
  67128. getClassName(): string;
  67129. /**
  67130. * Gets the seed input component
  67131. */
  67132. get seed(): NodeMaterialConnectionPoint;
  67133. /**
  67134. * Gets the jitter input component
  67135. */
  67136. get jitter(): NodeMaterialConnectionPoint;
  67137. /**
  67138. * Gets the output component
  67139. */
  67140. get output(): NodeMaterialConnectionPoint;
  67141. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  67142. /**
  67143. * Exposes the properties to the UI?
  67144. */
  67145. protected _dumpPropertiesCode(): string;
  67146. /**
  67147. * Exposes the properties to the Seralize?
  67148. */
  67149. serialize(): any;
  67150. /**
  67151. * Exposes the properties to the deseralize?
  67152. */
  67153. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  67154. }
  67155. }
  67156. declare module "babylonjs/Materials/Node/Blocks/simplexPerlin3DBlock" {
  67157. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  67158. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  67159. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  67160. /**
  67161. * block used to Generate a Simplex Perlin 3d Noise Pattern
  67162. */
  67163. export class SimplexPerlin3DBlock extends NodeMaterialBlock {
  67164. /**
  67165. * Creates a new SimplexPerlin3DBlock
  67166. * @param name defines the block name
  67167. */
  67168. constructor(name: string);
  67169. /**
  67170. * Gets the current class name
  67171. * @returns the class name
  67172. */
  67173. getClassName(): string;
  67174. /**
  67175. * Gets the seed operand input component
  67176. */
  67177. get seed(): NodeMaterialConnectionPoint;
  67178. /**
  67179. * Gets the output component
  67180. */
  67181. get output(): NodeMaterialConnectionPoint;
  67182. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  67183. }
  67184. }
  67185. declare module "babylonjs/Materials/Node/Blocks/normalBlendBlock" {
  67186. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  67187. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  67188. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  67189. /**
  67190. * Block used to blend normals
  67191. */
  67192. export class NormalBlendBlock extends NodeMaterialBlock {
  67193. /**
  67194. * Creates a new NormalBlendBlock
  67195. * @param name defines the block name
  67196. */
  67197. constructor(name: string);
  67198. /**
  67199. * Gets the current class name
  67200. * @returns the class name
  67201. */
  67202. getClassName(): string;
  67203. /**
  67204. * Gets the first input component
  67205. */
  67206. get normalMap0(): NodeMaterialConnectionPoint;
  67207. /**
  67208. * Gets the second input component
  67209. */
  67210. get normalMap1(): NodeMaterialConnectionPoint;
  67211. /**
  67212. * Gets the output component
  67213. */
  67214. get output(): NodeMaterialConnectionPoint;
  67215. protected _buildBlock(state: NodeMaterialBuildState): this;
  67216. }
  67217. }
  67218. declare module "babylonjs/Materials/Node/Blocks/rotate2dBlock" {
  67219. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  67220. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  67221. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  67222. import { NodeMaterial } from "babylonjs/Materials/Node/nodeMaterial";
  67223. /**
  67224. * Block used to rotate a 2d vector by a given angle
  67225. */
  67226. export class Rotate2dBlock extends NodeMaterialBlock {
  67227. /**
  67228. * Creates a new Rotate2dBlock
  67229. * @param name defines the block name
  67230. */
  67231. constructor(name: string);
  67232. /**
  67233. * Gets the current class name
  67234. * @returns the class name
  67235. */
  67236. getClassName(): string;
  67237. /**
  67238. * Gets the input vector
  67239. */
  67240. get input(): NodeMaterialConnectionPoint;
  67241. /**
  67242. * Gets the input angle
  67243. */
  67244. get angle(): NodeMaterialConnectionPoint;
  67245. /**
  67246. * Gets the output component
  67247. */
  67248. get output(): NodeMaterialConnectionPoint;
  67249. autoConfigure(material: NodeMaterial): void;
  67250. protected _buildBlock(state: NodeMaterialBuildState): this;
  67251. }
  67252. }
  67253. declare module "babylonjs/Materials/Node/Blocks/reflectBlock" {
  67254. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  67255. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  67256. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  67257. /**
  67258. * Block used to get the reflected vector from a direction and a normal
  67259. */
  67260. export class ReflectBlock extends NodeMaterialBlock {
  67261. /**
  67262. * Creates a new ReflectBlock
  67263. * @param name defines the block name
  67264. */
  67265. constructor(name: string);
  67266. /**
  67267. * Gets the current class name
  67268. * @returns the class name
  67269. */
  67270. getClassName(): string;
  67271. /**
  67272. * Gets the incident component
  67273. */
  67274. get incident(): NodeMaterialConnectionPoint;
  67275. /**
  67276. * Gets the normal component
  67277. */
  67278. get normal(): NodeMaterialConnectionPoint;
  67279. /**
  67280. * Gets the output component
  67281. */
  67282. get output(): NodeMaterialConnectionPoint;
  67283. protected _buildBlock(state: NodeMaterialBuildState): this;
  67284. }
  67285. }
  67286. declare module "babylonjs/Materials/Node/Blocks/refractBlock" {
  67287. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  67288. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  67289. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  67290. /**
  67291. * Block used to get the refracted vector from a direction and a normal
  67292. */
  67293. export class RefractBlock extends NodeMaterialBlock {
  67294. /**
  67295. * Creates a new RefractBlock
  67296. * @param name defines the block name
  67297. */
  67298. constructor(name: string);
  67299. /**
  67300. * Gets the current class name
  67301. * @returns the class name
  67302. */
  67303. getClassName(): string;
  67304. /**
  67305. * Gets the incident component
  67306. */
  67307. get incident(): NodeMaterialConnectionPoint;
  67308. /**
  67309. * Gets the normal component
  67310. */
  67311. get normal(): NodeMaterialConnectionPoint;
  67312. /**
  67313. * Gets the index of refraction component
  67314. */
  67315. get ior(): NodeMaterialConnectionPoint;
  67316. /**
  67317. * Gets the output component
  67318. */
  67319. get output(): NodeMaterialConnectionPoint;
  67320. protected _buildBlock(state: NodeMaterialBuildState): this;
  67321. }
  67322. }
  67323. declare module "babylonjs/Materials/Node/Blocks/desaturateBlock" {
  67324. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  67325. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  67326. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  67327. /**
  67328. * Block used to desaturate a color
  67329. */
  67330. export class DesaturateBlock extends NodeMaterialBlock {
  67331. /**
  67332. * Creates a new DesaturateBlock
  67333. * @param name defines the block name
  67334. */
  67335. constructor(name: string);
  67336. /**
  67337. * Gets the current class name
  67338. * @returns the class name
  67339. */
  67340. getClassName(): string;
  67341. /**
  67342. * Gets the color operand input component
  67343. */
  67344. get color(): NodeMaterialConnectionPoint;
  67345. /**
  67346. * Gets the level operand input component
  67347. */
  67348. get level(): NodeMaterialConnectionPoint;
  67349. /**
  67350. * Gets the output component
  67351. */
  67352. get output(): NodeMaterialConnectionPoint;
  67353. protected _buildBlock(state: NodeMaterialBuildState): this;
  67354. }
  67355. }
  67356. declare module "babylonjs/Materials/Node/Blocks/PBR/ambientOcclusionBlock" {
  67357. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  67358. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  67359. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  67360. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  67361. import { Nullable } from "babylonjs/types";
  67362. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  67363. import { Scene } from "babylonjs/scene";
  67364. /**
  67365. * Block used to implement the ambient occlusion module of the PBR material
  67366. */
  67367. export class AmbientOcclusionBlock extends NodeMaterialBlock {
  67368. /**
  67369. * Create a new AmbientOcclusionBlock
  67370. * @param name defines the block name
  67371. */
  67372. constructor(name: string);
  67373. /**
  67374. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  67375. */
  67376. useAmbientInGrayScale: boolean;
  67377. /**
  67378. * Initialize the block and prepare the context for build
  67379. * @param state defines the state that will be used for the build
  67380. */
  67381. initialize(state: NodeMaterialBuildState): void;
  67382. /**
  67383. * Gets the current class name
  67384. * @returns the class name
  67385. */
  67386. getClassName(): string;
  67387. /**
  67388. * Gets the texture input component
  67389. */
  67390. get texture(): NodeMaterialConnectionPoint;
  67391. /**
  67392. * Gets the texture intensity component
  67393. */
  67394. get intensity(): NodeMaterialConnectionPoint;
  67395. /**
  67396. * Gets the direct light intensity input component
  67397. */
  67398. get directLightIntensity(): NodeMaterialConnectionPoint;
  67399. /**
  67400. * Gets the ambient occlusion object output component
  67401. */
  67402. get ambientOcclusion(): NodeMaterialConnectionPoint;
  67403. /**
  67404. * Gets the main code of the block (fragment side)
  67405. * @param block instance of an AmbientOcclusionBlock or null if the code must be generated without an active ambient occlusion module
  67406. * @returns the shader code
  67407. */
  67408. static GetCode(block: Nullable<AmbientOcclusionBlock>): string;
  67409. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  67410. protected _buildBlock(state: NodeMaterialBuildState): this;
  67411. protected _dumpPropertiesCode(): string;
  67412. serialize(): any;
  67413. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  67414. }
  67415. }
  67416. declare module "babylonjs/Materials/Node/Blocks/PBR/reflectionBlock" {
  67417. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  67418. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  67419. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  67420. import { ReflectionTextureBaseBlock } from "babylonjs/Materials/Node/Blocks/Dual/reflectionTextureBaseBlock";
  67421. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  67422. import { Nullable } from "babylonjs/types";
  67423. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  67424. import { Mesh } from "babylonjs/Meshes/mesh";
  67425. import { SubMesh } from "babylonjs/Meshes/subMesh";
  67426. import { Effect } from "babylonjs/Materials/effect";
  67427. import { Scene } from "babylonjs/scene";
  67428. /**
  67429. * Block used to implement the reflection module of the PBR material
  67430. */
  67431. export class ReflectionBlock extends ReflectionTextureBaseBlock {
  67432. /** @hidden */
  67433. _defineLODReflectionAlpha: string;
  67434. /** @hidden */
  67435. _defineLinearSpecularReflection: string;
  67436. private _vEnvironmentIrradianceName;
  67437. /** @hidden */
  67438. _vReflectionMicrosurfaceInfosName: string;
  67439. /** @hidden */
  67440. _vReflectionInfosName: string;
  67441. /** @hidden */
  67442. _vReflectionFilteringInfoName: string;
  67443. private _scene;
  67444. /**
  67445. * The three properties below are set by the main PBR block prior to calling methods of this class.
  67446. * This is to avoid having to add them as inputs here whereas they are already inputs of the main block, so already known.
  67447. * It's less burden on the user side in the editor part.
  67448. */
  67449. /** @hidden */
  67450. worldPositionConnectionPoint: NodeMaterialConnectionPoint;
  67451. /** @hidden */
  67452. worldNormalConnectionPoint: NodeMaterialConnectionPoint;
  67453. /** @hidden */
  67454. cameraPositionConnectionPoint: NodeMaterialConnectionPoint;
  67455. /**
  67456. * Defines if the material uses spherical harmonics vs spherical polynomials for the
  67457. * diffuse part of the IBL.
  67458. */
  67459. useSphericalHarmonics: boolean;
  67460. /**
  67461. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  67462. */
  67463. forceIrradianceInFragment: boolean;
  67464. /**
  67465. * Create a new ReflectionBlock
  67466. * @param name defines the block name
  67467. */
  67468. constructor(name: string);
  67469. /**
  67470. * Gets the current class name
  67471. * @returns the class name
  67472. */
  67473. getClassName(): string;
  67474. /**
  67475. * Gets the position input component
  67476. */
  67477. get position(): NodeMaterialConnectionPoint;
  67478. /**
  67479. * Gets the world position input component
  67480. */
  67481. get worldPosition(): NodeMaterialConnectionPoint;
  67482. /**
  67483. * Gets the world normal input component
  67484. */
  67485. get worldNormal(): NodeMaterialConnectionPoint;
  67486. /**
  67487. * Gets the world input component
  67488. */
  67489. get world(): NodeMaterialConnectionPoint;
  67490. /**
  67491. * Gets the camera (or eye) position component
  67492. */
  67493. get cameraPosition(): NodeMaterialConnectionPoint;
  67494. /**
  67495. * Gets the view input component
  67496. */
  67497. get view(): NodeMaterialConnectionPoint;
  67498. /**
  67499. * Gets the color input component
  67500. */
  67501. get color(): NodeMaterialConnectionPoint;
  67502. /**
  67503. * Gets the reflection object output component
  67504. */
  67505. get reflection(): NodeMaterialConnectionPoint;
  67506. /**
  67507. * Returns true if the block has a texture (either its own texture or the environment texture from the scene, if set)
  67508. */
  67509. get hasTexture(): boolean;
  67510. /**
  67511. * Gets the reflection color (either the name of the variable if the color input is connected, else a default value)
  67512. */
  67513. get reflectionColor(): string;
  67514. protected _getTexture(): Nullable<BaseTexture>;
  67515. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  67516. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh, subMesh?: SubMesh): void;
  67517. /**
  67518. * Gets the code to inject in the vertex shader
  67519. * @param state current state of the node material building
  67520. * @returns the shader code
  67521. */
  67522. handleVertexSide(state: NodeMaterialBuildState): string;
  67523. /**
  67524. * Gets the main code of the block (fragment side)
  67525. * @param state current state of the node material building
  67526. * @param normalVarName name of the existing variable corresponding to the normal
  67527. * @returns the shader code
  67528. */
  67529. getCode(state: NodeMaterialBuildState, normalVarName: string): string;
  67530. protected _buildBlock(state: NodeMaterialBuildState): this;
  67531. protected _dumpPropertiesCode(): string;
  67532. serialize(): any;
  67533. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  67534. }
  67535. }
  67536. declare module "babylonjs/Materials/Node/Blocks/PBR/sheenBlock" {
  67537. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  67538. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  67539. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  67540. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  67541. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  67542. import { ReflectionBlock } from "babylonjs/Materials/Node/Blocks/PBR/reflectionBlock";
  67543. import { Scene } from "babylonjs/scene";
  67544. import { Nullable } from "babylonjs/types";
  67545. /**
  67546. * Block used to implement the sheen module of the PBR material
  67547. */
  67548. export class SheenBlock extends NodeMaterialBlock {
  67549. /**
  67550. * Create a new SheenBlock
  67551. * @param name defines the block name
  67552. */
  67553. constructor(name: string);
  67554. /**
  67555. * If true, the sheen effect is layered above the base BRDF with the albedo-scaling technique.
  67556. * It allows the strength of the sheen effect to not depend on the base color of the material,
  67557. * making it easier to setup and tweak the effect
  67558. */
  67559. albedoScaling: boolean;
  67560. /**
  67561. * Defines if the sheen is linked to the sheen color.
  67562. */
  67563. linkSheenWithAlbedo: boolean;
  67564. /**
  67565. * Initialize the block and prepare the context for build
  67566. * @param state defines the state that will be used for the build
  67567. */
  67568. initialize(state: NodeMaterialBuildState): void;
  67569. /**
  67570. * Gets the current class name
  67571. * @returns the class name
  67572. */
  67573. getClassName(): string;
  67574. /**
  67575. * Gets the intensity input component
  67576. */
  67577. get intensity(): NodeMaterialConnectionPoint;
  67578. /**
  67579. * Gets the color input component
  67580. */
  67581. get color(): NodeMaterialConnectionPoint;
  67582. /**
  67583. * Gets the roughness input component
  67584. */
  67585. get roughness(): NodeMaterialConnectionPoint;
  67586. /**
  67587. * Gets the sheen object output component
  67588. */
  67589. get sheen(): NodeMaterialConnectionPoint;
  67590. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  67591. /**
  67592. * Gets the main code of the block (fragment side)
  67593. * @param reflectionBlock instance of a ReflectionBlock null if the code must be generated without an active reflection module
  67594. * @returns the shader code
  67595. */
  67596. getCode(reflectionBlock: Nullable<ReflectionBlock>): string;
  67597. protected _buildBlock(state: NodeMaterialBuildState): this;
  67598. protected _dumpPropertiesCode(): string;
  67599. serialize(): any;
  67600. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  67601. }
  67602. }
  67603. declare module "babylonjs/Materials/Node/Blocks/PBR/reflectivityBlock" {
  67604. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  67605. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  67606. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  67607. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  67608. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  67609. import { Scene } from "babylonjs/scene";
  67610. import { Nullable } from "babylonjs/types";
  67611. import { Mesh } from "babylonjs/Meshes/mesh";
  67612. import { SubMesh } from "babylonjs/Meshes/subMesh";
  67613. import { Effect } from "babylonjs/Materials/effect";
  67614. /**
  67615. * Block used to implement the reflectivity module of the PBR material
  67616. */
  67617. export class ReflectivityBlock extends NodeMaterialBlock {
  67618. private _metallicReflectanceColor;
  67619. private _metallicF0Factor;
  67620. /** @hidden */
  67621. _vMetallicReflectanceFactorsName: string;
  67622. /**
  67623. * The property below is set by the main PBR block prior to calling methods of this class.
  67624. */
  67625. /** @hidden */
  67626. indexOfRefractionConnectionPoint: Nullable<NodeMaterialConnectionPoint>;
  67627. /**
  67628. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  67629. */
  67630. useAmbientOcclusionFromMetallicTextureRed: boolean;
  67631. /**
  67632. * Specifies if the metallic texture contains the metallness information in its blue channel.
  67633. */
  67634. useMetallnessFromMetallicTextureBlue: boolean;
  67635. /**
  67636. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  67637. */
  67638. useRoughnessFromMetallicTextureAlpha: boolean;
  67639. /**
  67640. * Specifies if the metallic texture contains the roughness information in its green channel.
  67641. */
  67642. useRoughnessFromMetallicTextureGreen: boolean;
  67643. /**
  67644. * Create a new ReflectivityBlock
  67645. * @param name defines the block name
  67646. */
  67647. constructor(name: string);
  67648. /**
  67649. * Initialize the block and prepare the context for build
  67650. * @param state defines the state that will be used for the build
  67651. */
  67652. initialize(state: NodeMaterialBuildState): void;
  67653. /**
  67654. * Gets the current class name
  67655. * @returns the class name
  67656. */
  67657. getClassName(): string;
  67658. /**
  67659. * Gets the metallic input component
  67660. */
  67661. get metallic(): NodeMaterialConnectionPoint;
  67662. /**
  67663. * Gets the roughness input component
  67664. */
  67665. get roughness(): NodeMaterialConnectionPoint;
  67666. /**
  67667. * Gets the texture input component
  67668. */
  67669. get texture(): NodeMaterialConnectionPoint;
  67670. /**
  67671. * Gets the reflectivity object output component
  67672. */
  67673. get reflectivity(): NodeMaterialConnectionPoint;
  67674. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh, subMesh?: SubMesh): void;
  67675. /**
  67676. * Gets the main code of the block (fragment side)
  67677. * @param state current state of the node material building
  67678. * @param aoIntensityVarName name of the variable with the ambient occlusion intensity
  67679. * @returns the shader code
  67680. */
  67681. getCode(state: NodeMaterialBuildState, aoIntensityVarName: string): string;
  67682. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  67683. protected _buildBlock(state: NodeMaterialBuildState): this;
  67684. protected _dumpPropertiesCode(): string;
  67685. serialize(): any;
  67686. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  67687. }
  67688. }
  67689. declare module "babylonjs/Materials/Node/Blocks/PBR/anisotropyBlock" {
  67690. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  67691. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  67692. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  67693. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  67694. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  67695. /**
  67696. * Block used to implement the anisotropy module of the PBR material
  67697. */
  67698. export class AnisotropyBlock extends NodeMaterialBlock {
  67699. /**
  67700. * The two properties below are set by the main PBR block prior to calling methods of this class.
  67701. * This is to avoid having to add them as inputs here whereas they are already inputs of the main block, so already known.
  67702. * It's less burden on the user side in the editor part.
  67703. */
  67704. /** @hidden */
  67705. worldPositionConnectionPoint: NodeMaterialConnectionPoint;
  67706. /** @hidden */
  67707. worldNormalConnectionPoint: NodeMaterialConnectionPoint;
  67708. /**
  67709. * Create a new AnisotropyBlock
  67710. * @param name defines the block name
  67711. */
  67712. constructor(name: string);
  67713. /**
  67714. * Initialize the block and prepare the context for build
  67715. * @param state defines the state that will be used for the build
  67716. */
  67717. initialize(state: NodeMaterialBuildState): void;
  67718. /**
  67719. * Gets the current class name
  67720. * @returns the class name
  67721. */
  67722. getClassName(): string;
  67723. /**
  67724. * Gets the intensity input component
  67725. */
  67726. get intensity(): NodeMaterialConnectionPoint;
  67727. /**
  67728. * Gets the direction input component
  67729. */
  67730. get direction(): NodeMaterialConnectionPoint;
  67731. /**
  67732. * Gets the texture input component
  67733. */
  67734. get texture(): NodeMaterialConnectionPoint;
  67735. /**
  67736. * Gets the uv input component
  67737. */
  67738. get uv(): NodeMaterialConnectionPoint;
  67739. /**
  67740. * Gets the worldTangent input component
  67741. */
  67742. get worldTangent(): NodeMaterialConnectionPoint;
  67743. /**
  67744. * Gets the anisotropy object output component
  67745. */
  67746. get anisotropy(): NodeMaterialConnectionPoint;
  67747. private _generateTBNSpace;
  67748. /**
  67749. * Gets the main code of the block (fragment side)
  67750. * @param state current state of the node material building
  67751. * @param generateTBNSpace if true, the code needed to create the TBN coordinate space is generated
  67752. * @returns the shader code
  67753. */
  67754. getCode(state: NodeMaterialBuildState, generateTBNSpace?: boolean): string;
  67755. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  67756. protected _buildBlock(state: NodeMaterialBuildState): this;
  67757. }
  67758. }
  67759. declare module "babylonjs/Materials/Node/Blocks/PBR/clearCoatBlock" {
  67760. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  67761. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  67762. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  67763. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  67764. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  67765. import { ReflectionBlock } from "babylonjs/Materials/Node/Blocks/PBR/reflectionBlock";
  67766. import { Nullable } from "babylonjs/types";
  67767. import { Mesh } from "babylonjs/Meshes/mesh";
  67768. import { SubMesh } from "babylonjs/Meshes/subMesh";
  67769. import { Effect } from "babylonjs/Materials/effect";
  67770. /**
  67771. * Block used to implement the clear coat module of the PBR material
  67772. */
  67773. export class ClearCoatBlock extends NodeMaterialBlock {
  67774. private _scene;
  67775. /**
  67776. * Create a new ClearCoatBlock
  67777. * @param name defines the block name
  67778. */
  67779. constructor(name: string);
  67780. /**
  67781. * Initialize the block and prepare the context for build
  67782. * @param state defines the state that will be used for the build
  67783. */
  67784. initialize(state: NodeMaterialBuildState): void;
  67785. /**
  67786. * Gets the current class name
  67787. * @returns the class name
  67788. */
  67789. getClassName(): string;
  67790. /**
  67791. * Gets the intensity input component
  67792. */
  67793. get intensity(): NodeMaterialConnectionPoint;
  67794. /**
  67795. * Gets the roughness input component
  67796. */
  67797. get roughness(): NodeMaterialConnectionPoint;
  67798. /**
  67799. * Gets the ior input component
  67800. */
  67801. get ior(): NodeMaterialConnectionPoint;
  67802. /**
  67803. * Gets the texture input component
  67804. */
  67805. get texture(): NodeMaterialConnectionPoint;
  67806. /**
  67807. * Gets the bump texture input component
  67808. */
  67809. get bumpTexture(): NodeMaterialConnectionPoint;
  67810. /**
  67811. * Gets the uv input component
  67812. */
  67813. get uv(): NodeMaterialConnectionPoint;
  67814. /**
  67815. * Gets the tint color input component
  67816. */
  67817. get tintColor(): NodeMaterialConnectionPoint;
  67818. /**
  67819. * Gets the tint "at distance" input component
  67820. */
  67821. get tintAtDistance(): NodeMaterialConnectionPoint;
  67822. /**
  67823. * Gets the tint thickness input component
  67824. */
  67825. get tintThickness(): NodeMaterialConnectionPoint;
  67826. /**
  67827. * Gets the world tangent input component
  67828. */
  67829. get worldTangent(): NodeMaterialConnectionPoint;
  67830. /**
  67831. * Gets the clear coat object output component
  67832. */
  67833. get clearcoat(): NodeMaterialConnectionPoint;
  67834. autoConfigure(material: NodeMaterial): void;
  67835. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  67836. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh, subMesh?: SubMesh): void;
  67837. private _generateTBNSpace;
  67838. /**
  67839. * Gets the main code of the block (fragment side)
  67840. * @param state current state of the node material building
  67841. * @param ccBlock instance of a ClearCoatBlock or null if the code must be generated without an active clear coat module
  67842. * @param reflectionBlock instance of a ReflectionBlock null if the code must be generated without an active reflection module
  67843. * @param worldPosVarName name of the variable holding the world position
  67844. * @param generateTBNSpace if true, the code needed to create the TBN coordinate space is generated
  67845. * @param vTBNAvailable indicate that the vTBN variable is already existing because it has already been generated by another block (PerturbNormal or Anisotropy)
  67846. * @param worldNormalVarName name of the variable holding the world normal
  67847. * @returns the shader code
  67848. */
  67849. static GetCode(state: NodeMaterialBuildState, ccBlock: Nullable<ClearCoatBlock>, reflectionBlock: Nullable<ReflectionBlock>, worldPosVarName: string, generateTBNSpace: boolean, vTBNAvailable: boolean, worldNormalVarName: string): string;
  67850. protected _buildBlock(state: NodeMaterialBuildState): this;
  67851. }
  67852. }
  67853. declare module "babylonjs/Materials/Node/Blocks/PBR/subSurfaceBlock" {
  67854. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  67855. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  67856. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  67857. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  67858. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  67859. import { ReflectionBlock } from "babylonjs/Materials/Node/Blocks/PBR/reflectionBlock";
  67860. import { Nullable } from "babylonjs/types";
  67861. /**
  67862. * Block used to implement the sub surface module of the PBR material
  67863. */
  67864. export class SubSurfaceBlock extends NodeMaterialBlock {
  67865. /**
  67866. * Create a new SubSurfaceBlock
  67867. * @param name defines the block name
  67868. */
  67869. constructor(name: string);
  67870. /**
  67871. * Stores the intensity of the different subsurface effects in the thickness texture.
  67872. * * the green channel is the translucency intensity.
  67873. * * the blue channel is the scattering intensity.
  67874. * * the alpha channel is the refraction intensity.
  67875. */
  67876. useMaskFromThicknessTexture: boolean;
  67877. /**
  67878. * Initialize the block and prepare the context for build
  67879. * @param state defines the state that will be used for the build
  67880. */
  67881. initialize(state: NodeMaterialBuildState): void;
  67882. /**
  67883. * Gets the current class name
  67884. * @returns the class name
  67885. */
  67886. getClassName(): string;
  67887. /**
  67888. * Gets the min thickness input component
  67889. */
  67890. get minThickness(): NodeMaterialConnectionPoint;
  67891. /**
  67892. * Gets the max thickness input component
  67893. */
  67894. get maxThickness(): NodeMaterialConnectionPoint;
  67895. /**
  67896. * Gets the thickness texture component
  67897. */
  67898. get thicknessTexture(): NodeMaterialConnectionPoint;
  67899. /**
  67900. * Gets the tint color input component
  67901. */
  67902. get tintColor(): NodeMaterialConnectionPoint;
  67903. /**
  67904. * Gets the translucency intensity input component
  67905. */
  67906. get translucencyIntensity(): NodeMaterialConnectionPoint;
  67907. /**
  67908. * Gets the translucency diffusion distance input component
  67909. */
  67910. get translucencyDiffusionDistance(): NodeMaterialConnectionPoint;
  67911. /**
  67912. * Gets the refraction object parameters
  67913. */
  67914. get refraction(): NodeMaterialConnectionPoint;
  67915. /**
  67916. * Gets the sub surface object output component
  67917. */
  67918. get subsurface(): NodeMaterialConnectionPoint;
  67919. autoConfigure(material: NodeMaterial): void;
  67920. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  67921. /**
  67922. * Gets the main code of the block (fragment side)
  67923. * @param state current state of the node material building
  67924. * @param ssBlock instance of a SubSurfaceBlock or null if the code must be generated without an active sub surface module
  67925. * @param reflectionBlock instance of a ReflectionBlock null if the code must be generated without an active reflection module
  67926. * @param worldPosVarName name of the variable holding the world position
  67927. * @returns the shader code
  67928. */
  67929. static GetCode(state: NodeMaterialBuildState, ssBlock: Nullable<SubSurfaceBlock>, reflectionBlock: Nullable<ReflectionBlock>, worldPosVarName: string): string;
  67930. protected _buildBlock(state: NodeMaterialBuildState): this;
  67931. }
  67932. }
  67933. declare module "babylonjs/Materials/Node/Blocks/PBR/pbrMetallicRoughnessBlock" {
  67934. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  67935. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  67936. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  67937. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  67938. import { Light } from "babylonjs/Lights/light";
  67939. import { Nullable } from "babylonjs/types";
  67940. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  67941. import { Effect } from "babylonjs/Materials/effect";
  67942. import { Mesh } from "babylonjs/Meshes/mesh";
  67943. import { Scene } from "babylonjs/scene";
  67944. /**
  67945. * Block used to implement the PBR metallic/roughness model
  67946. */
  67947. export class PBRMetallicRoughnessBlock extends NodeMaterialBlock {
  67948. /**
  67949. * Gets or sets the light associated with this block
  67950. */
  67951. light: Nullable<Light>;
  67952. private _lightId;
  67953. private _scene;
  67954. private _environmentBRDFTexture;
  67955. private _environmentBrdfSamplerName;
  67956. private _vNormalWName;
  67957. private _invertNormalName;
  67958. /**
  67959. * Create a new ReflectionBlock
  67960. * @param name defines the block name
  67961. */
  67962. constructor(name: string);
  67963. /**
  67964. * Intensity of the direct lights e.g. the four lights available in your scene.
  67965. * This impacts both the direct diffuse and specular highlights.
  67966. */
  67967. directIntensity: number;
  67968. /**
  67969. * Intensity of the environment e.g. how much the environment will light the object
  67970. * either through harmonics for rough material or through the refelction for shiny ones.
  67971. */
  67972. environmentIntensity: number;
  67973. /**
  67974. * This is a special control allowing the reduction of the specular highlights coming from the
  67975. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  67976. */
  67977. specularIntensity: number;
  67978. /**
  67979. * Defines the falloff type used in this material.
  67980. * It by default is Physical.
  67981. */
  67982. lightFalloff: number;
  67983. /**
  67984. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  67985. */
  67986. useAlphaFromAlbedoTexture: boolean;
  67987. /**
  67988. * Specifies that alpha test should be used
  67989. */
  67990. useAlphaTest: boolean;
  67991. /**
  67992. * Defines the alpha limits in alpha test mode.
  67993. */
  67994. alphaTestCutoff: number;
  67995. /**
  67996. * Specifies that alpha blending should be used
  67997. */
  67998. useAlphaBlending: boolean;
  67999. /**
  68000. * Defines if the alpha value should be determined via the rgb values.
  68001. * If true the luminance of the pixel might be used to find the corresponding alpha value.
  68002. */
  68003. opacityRGB: boolean;
  68004. /**
  68005. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most luminous ones).
  68006. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  68007. */
  68008. useRadianceOverAlpha: boolean;
  68009. /**
  68010. * Specifies that the material will keeps the specular highlights over a transparent surface (only the most luminous ones).
  68011. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  68012. */
  68013. useSpecularOverAlpha: boolean;
  68014. /**
  68015. * Enables specular anti aliasing in the PBR shader.
  68016. * It will both interacts on the Geometry for analytical and IBL lighting.
  68017. * It also prefilter the roughness map based on the bump values.
  68018. */
  68019. enableSpecularAntiAliasing: boolean;
  68020. /**
  68021. * Enables realtime filtering on the texture.
  68022. */
  68023. realTimeFiltering: boolean;
  68024. /**
  68025. * Quality switch for realtime filtering
  68026. */
  68027. realTimeFilteringQuality: number;
  68028. /**
  68029. * Defines if the material uses energy conservation.
  68030. */
  68031. useEnergyConservation: boolean;
  68032. /**
  68033. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  68034. * too much the area relying on ambient texture to define their ambient occlusion.
  68035. */
  68036. useRadianceOcclusion: boolean;
  68037. /**
  68038. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  68039. * makes the reflect vector face the model (under horizon).
  68040. */
  68041. useHorizonOcclusion: boolean;
  68042. /**
  68043. * If set to true, no lighting calculations will be applied.
  68044. */
  68045. unlit: boolean;
  68046. /**
  68047. * Force normal to face away from face.
  68048. */
  68049. forceNormalForward: boolean;
  68050. /**
  68051. * Defines the material debug mode.
  68052. * It helps seeing only some components of the material while troubleshooting.
  68053. */
  68054. debugMode: number;
  68055. /**
  68056. * Specify from where on screen the debug mode should start.
  68057. * The value goes from -1 (full screen) to 1 (not visible)
  68058. * It helps with side by side comparison against the final render
  68059. * This defaults to 0
  68060. */
  68061. debugLimit: number;
  68062. /**
  68063. * As the default viewing range might not be enough (if the ambient is really small for instance)
  68064. * You can use the factor to better multiply the final value.
  68065. */
  68066. debugFactor: number;
  68067. /**
  68068. * Initialize the block and prepare the context for build
  68069. * @param state defines the state that will be used for the build
  68070. */
  68071. initialize(state: NodeMaterialBuildState): void;
  68072. /**
  68073. * Gets the current class name
  68074. * @returns the class name
  68075. */
  68076. getClassName(): string;
  68077. /**
  68078. * Gets the world position input component
  68079. */
  68080. get worldPosition(): NodeMaterialConnectionPoint;
  68081. /**
  68082. * Gets the world normal input component
  68083. */
  68084. get worldNormal(): NodeMaterialConnectionPoint;
  68085. /**
  68086. * Gets the perturbed normal input component
  68087. */
  68088. get perturbedNormal(): NodeMaterialConnectionPoint;
  68089. /**
  68090. * Gets the camera position input component
  68091. */
  68092. get cameraPosition(): NodeMaterialConnectionPoint;
  68093. /**
  68094. * Gets the base color input component
  68095. */
  68096. get baseColor(): NodeMaterialConnectionPoint;
  68097. /**
  68098. * Gets the opacity texture input component
  68099. */
  68100. get opacityTexture(): NodeMaterialConnectionPoint;
  68101. /**
  68102. * Gets the ambient color input component
  68103. */
  68104. get ambientColor(): NodeMaterialConnectionPoint;
  68105. /**
  68106. * Gets the reflectivity object parameters
  68107. */
  68108. get reflectivity(): NodeMaterialConnectionPoint;
  68109. /**
  68110. * Gets the ambient occlusion object parameters
  68111. */
  68112. get ambientOcclusion(): NodeMaterialConnectionPoint;
  68113. /**
  68114. * Gets the reflection object parameters
  68115. */
  68116. get reflection(): NodeMaterialConnectionPoint;
  68117. /**
  68118. * Gets the sheen object parameters
  68119. */
  68120. get sheen(): NodeMaterialConnectionPoint;
  68121. /**
  68122. * Gets the clear coat object parameters
  68123. */
  68124. get clearcoat(): NodeMaterialConnectionPoint;
  68125. /**
  68126. * Gets the sub surface object parameters
  68127. */
  68128. get subsurface(): NodeMaterialConnectionPoint;
  68129. /**
  68130. * Gets the anisotropy object parameters
  68131. */
  68132. get anisotropy(): NodeMaterialConnectionPoint;
  68133. /**
  68134. * Gets the ambient output component
  68135. */
  68136. get ambient(): NodeMaterialConnectionPoint;
  68137. /**
  68138. * Gets the diffuse output component
  68139. */
  68140. get diffuse(): NodeMaterialConnectionPoint;
  68141. /**
  68142. * Gets the specular output component
  68143. */
  68144. get specular(): NodeMaterialConnectionPoint;
  68145. /**
  68146. * Gets the sheen output component
  68147. */
  68148. get sheenDir(): NodeMaterialConnectionPoint;
  68149. /**
  68150. * Gets the clear coat output component
  68151. */
  68152. get clearcoatDir(): NodeMaterialConnectionPoint;
  68153. /**
  68154. * Gets the indirect diffuse output component
  68155. */
  68156. get diffuseIndirect(): NodeMaterialConnectionPoint;
  68157. /**
  68158. * Gets the indirect specular output component
  68159. */
  68160. get specularIndirect(): NodeMaterialConnectionPoint;
  68161. /**
  68162. * Gets the indirect sheen output component
  68163. */
  68164. get sheenIndirect(): NodeMaterialConnectionPoint;
  68165. /**
  68166. * Gets the indirect clear coat output component
  68167. */
  68168. get clearcoatIndirect(): NodeMaterialConnectionPoint;
  68169. /**
  68170. * Gets the refraction output component
  68171. */
  68172. get refraction(): NodeMaterialConnectionPoint;
  68173. /**
  68174. * Gets the global lighting output component
  68175. */
  68176. get lighting(): NodeMaterialConnectionPoint;
  68177. /**
  68178. * Gets the shadow output component
  68179. */
  68180. get shadow(): NodeMaterialConnectionPoint;
  68181. /**
  68182. * Gets the alpha output component
  68183. */
  68184. get alpha(): NodeMaterialConnectionPoint;
  68185. autoConfigure(material: NodeMaterial): void;
  68186. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  68187. updateUniformsAndSamples(state: NodeMaterialBuildState, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, uniformBuffers: string[]): void;
  68188. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  68189. private _injectVertexCode;
  68190. /**
  68191. * Gets the code corresponding to the albedo/opacity module
  68192. * @returns the shader code
  68193. */
  68194. getAlbedoOpacityCode(): string;
  68195. protected _buildBlock(state: NodeMaterialBuildState): this;
  68196. protected _dumpPropertiesCode(): string;
  68197. serialize(): any;
  68198. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  68199. }
  68200. }
  68201. declare module "babylonjs/Materials/Node/Blocks/PBR/index" {
  68202. export * from "babylonjs/Materials/Node/Blocks/PBR/pbrMetallicRoughnessBlock";
  68203. export * from "babylonjs/Materials/Node/Blocks/PBR/sheenBlock";
  68204. export * from "babylonjs/Materials/Node/Blocks/PBR/ambientOcclusionBlock";
  68205. export * from "babylonjs/Materials/Node/Blocks/PBR/reflectivityBlock";
  68206. export * from "babylonjs/Materials/Node/Blocks/PBR/anisotropyBlock";
  68207. export * from "babylonjs/Materials/Node/Blocks/PBR/reflectionBlock";
  68208. export * from "babylonjs/Materials/Node/Blocks/PBR/clearCoatBlock";
  68209. export * from "babylonjs/Materials/Node/Blocks/PBR/refractionBlock";
  68210. export * from "babylonjs/Materials/Node/Blocks/PBR/subSurfaceBlock";
  68211. }
  68212. declare module "babylonjs/Materials/Node/Blocks/Particle/index" {
  68213. export * from "babylonjs/Materials/Node/Blocks/Particle/particleTextureBlock";
  68214. export * from "babylonjs/Materials/Node/Blocks/Particle/particleRampGradientBlock";
  68215. export * from "babylonjs/Materials/Node/Blocks/Particle/particleBlendMultiplyBlock";
  68216. }
  68217. declare module "babylonjs/Materials/Node/Blocks/modBlock" {
  68218. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  68219. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  68220. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  68221. /**
  68222. * Block used to compute value of one parameter modulo another
  68223. */
  68224. export class ModBlock extends NodeMaterialBlock {
  68225. /**
  68226. * Creates a new ModBlock
  68227. * @param name defines the block name
  68228. */
  68229. constructor(name: string);
  68230. /**
  68231. * Gets the current class name
  68232. * @returns the class name
  68233. */
  68234. getClassName(): string;
  68235. /**
  68236. * Gets the left operand input component
  68237. */
  68238. get left(): NodeMaterialConnectionPoint;
  68239. /**
  68240. * Gets the right operand input component
  68241. */
  68242. get right(): NodeMaterialConnectionPoint;
  68243. /**
  68244. * Gets the output component
  68245. */
  68246. get output(): NodeMaterialConnectionPoint;
  68247. protected _buildBlock(state: NodeMaterialBuildState): this;
  68248. }
  68249. }
  68250. declare module "babylonjs/Materials/Node/Blocks/index" {
  68251. export * from "babylonjs/Materials/Node/Blocks/Vertex/index";
  68252. export * from "babylonjs/Materials/Node/Blocks/Fragment/index";
  68253. export * from "babylonjs/Materials/Node/Blocks/Dual/index";
  68254. export * from "babylonjs/Materials/Node/Blocks/Input/index";
  68255. export * from "babylonjs/Materials/Node/Blocks/multiplyBlock";
  68256. export * from "babylonjs/Materials/Node/Blocks/addBlock";
  68257. export * from "babylonjs/Materials/Node/Blocks/scaleBlock";
  68258. export * from "babylonjs/Materials/Node/Blocks/clampBlock";
  68259. export * from "babylonjs/Materials/Node/Blocks/crossBlock";
  68260. export * from "babylonjs/Materials/Node/Blocks/dotBlock";
  68261. export * from "babylonjs/Materials/Node/Blocks/transformBlock";
  68262. export * from "babylonjs/Materials/Node/Blocks/remapBlock";
  68263. export * from "babylonjs/Materials/Node/Blocks/normalizeBlock";
  68264. export * from "babylonjs/Materials/Node/Blocks/trigonometryBlock";
  68265. export * from "babylonjs/Materials/Node/Blocks/colorMergerBlock";
  68266. export * from "babylonjs/Materials/Node/Blocks/vectorMergerBlock";
  68267. export * from "babylonjs/Materials/Node/Blocks/colorSplitterBlock";
  68268. export * from "babylonjs/Materials/Node/Blocks/vectorSplitterBlock";
  68269. export * from "babylonjs/Materials/Node/Blocks/lerpBlock";
  68270. export * from "babylonjs/Materials/Node/Blocks/divideBlock";
  68271. export * from "babylonjs/Materials/Node/Blocks/subtractBlock";
  68272. export * from "babylonjs/Materials/Node/Blocks/stepBlock";
  68273. export * from "babylonjs/Materials/Node/Blocks/oneMinusBlock";
  68274. export * from "babylonjs/Materials/Node/Blocks/viewDirectionBlock";
  68275. export * from "babylonjs/Materials/Node/Blocks/fresnelBlock";
  68276. export * from "babylonjs/Materials/Node/Blocks/maxBlock";
  68277. export * from "babylonjs/Materials/Node/Blocks/minBlock";
  68278. export * from "babylonjs/Materials/Node/Blocks/distanceBlock";
  68279. export * from "babylonjs/Materials/Node/Blocks/lengthBlock";
  68280. export * from "babylonjs/Materials/Node/Blocks/negateBlock";
  68281. export * from "babylonjs/Materials/Node/Blocks/powBlock";
  68282. export * from "babylonjs/Materials/Node/Blocks/randomNumberBlock";
  68283. export * from "babylonjs/Materials/Node/Blocks/arcTan2Block";
  68284. export * from "babylonjs/Materials/Node/Blocks/smoothStepBlock";
  68285. export * from "babylonjs/Materials/Node/Blocks/reciprocalBlock";
  68286. export * from "babylonjs/Materials/Node/Blocks/replaceColorBlock";
  68287. export * from "babylonjs/Materials/Node/Blocks/posterizeBlock";
  68288. export * from "babylonjs/Materials/Node/Blocks/waveBlock";
  68289. export * from "babylonjs/Materials/Node/Blocks/gradientBlock";
  68290. export * from "babylonjs/Materials/Node/Blocks/nLerpBlock";
  68291. export * from "babylonjs/Materials/Node/Blocks/worleyNoise3DBlock";
  68292. export * from "babylonjs/Materials/Node/Blocks/simplexPerlin3DBlock";
  68293. export * from "babylonjs/Materials/Node/Blocks/normalBlendBlock";
  68294. export * from "babylonjs/Materials/Node/Blocks/rotate2dBlock";
  68295. export * from "babylonjs/Materials/Node/Blocks/reflectBlock";
  68296. export * from "babylonjs/Materials/Node/Blocks/refractBlock";
  68297. export * from "babylonjs/Materials/Node/Blocks/desaturateBlock";
  68298. export * from "babylonjs/Materials/Node/Blocks/PBR/index";
  68299. export * from "babylonjs/Materials/Node/Blocks/Particle/index";
  68300. export * from "babylonjs/Materials/Node/Blocks/modBlock";
  68301. }
  68302. declare module "babylonjs/Materials/Node/Optimizers/index" {
  68303. export * from "babylonjs/Materials/Node/Optimizers/nodeMaterialOptimizer";
  68304. }
  68305. declare module "babylonjs/Materials/Node/index" {
  68306. export * from "babylonjs/Materials/Node/Enums/index";
  68307. export * from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  68308. export * from "babylonjs/Materials/Node/nodeMaterialBlock";
  68309. export * from "babylonjs/Materials/Node/nodeMaterial";
  68310. export * from "babylonjs/Materials/Node/Blocks/index";
  68311. export * from "babylonjs/Materials/Node/Optimizers/index";
  68312. export * from "babylonjs/Materials/Node/nodeMaterialDecorator";
  68313. }
  68314. declare module "babylonjs/Materials/index" {
  68315. export * from "babylonjs/Materials/Background/index";
  68316. export * from "babylonjs/Materials/colorCurves";
  68317. export * from "babylonjs/Materials/iEffectFallbacks";
  68318. export * from "babylonjs/Materials/effectFallbacks";
  68319. export * from "babylonjs/Materials/effect";
  68320. export * from "babylonjs/Materials/fresnelParameters";
  68321. export * from "babylonjs/Materials/imageProcessingConfiguration";
  68322. export * from "babylonjs/Materials/material";
  68323. export * from "babylonjs/Materials/materialDefines";
  68324. export * from "babylonjs/Materials/thinMaterialHelper";
  68325. export * from "babylonjs/Materials/materialHelper";
  68326. export * from "babylonjs/Materials/multiMaterial";
  68327. export * from "babylonjs/Materials/PBR/index";
  68328. export * from "babylonjs/Materials/pushMaterial";
  68329. export * from "babylonjs/Materials/shaderMaterial";
  68330. export * from "babylonjs/Materials/standardMaterial";
  68331. export * from "babylonjs/Materials/Textures/index";
  68332. export * from "babylonjs/Materials/uniformBuffer";
  68333. export * from "babylonjs/Materials/materialFlags";
  68334. export * from "babylonjs/Materials/Node/index";
  68335. export * from "babylonjs/Materials/effectRenderer";
  68336. export * from "babylonjs/Materials/shadowDepthWrapper";
  68337. }
  68338. declare module "babylonjs/Maths/index" {
  68339. export * from "babylonjs/Maths/math.scalar";
  68340. export * from "babylonjs/Maths/math";
  68341. export * from "babylonjs/Maths/sphericalPolynomial";
  68342. }
  68343. declare module "babylonjs/Misc/workerPool" {
  68344. import { IDisposable } from "babylonjs/scene";
  68345. /**
  68346. * Helper class to push actions to a pool of workers.
  68347. */
  68348. export class WorkerPool implements IDisposable {
  68349. private _workerInfos;
  68350. private _pendingActions;
  68351. /**
  68352. * Constructor
  68353. * @param workers Array of workers to use for actions
  68354. */
  68355. constructor(workers: Array<Worker>);
  68356. /**
  68357. * Terminates all workers and clears any pending actions.
  68358. */
  68359. dispose(): void;
  68360. /**
  68361. * Pushes an action to the worker pool. If all the workers are active, the action will be
  68362. * pended until a worker has completed its action.
  68363. * @param action The action to perform. Call onComplete when the action is complete.
  68364. */
  68365. push(action: (worker: Worker, onComplete: () => void) => void): void;
  68366. private _execute;
  68367. }
  68368. }
  68369. declare module "babylonjs/Meshes/Compression/dracoCompression" {
  68370. import { IDisposable } from "babylonjs/scene";
  68371. import { VertexData } from "babylonjs/Meshes/mesh.vertexData";
  68372. /**
  68373. * Configuration for Draco compression
  68374. */
  68375. export interface IDracoCompressionConfiguration {
  68376. /**
  68377. * Configuration for the decoder.
  68378. */
  68379. decoder: {
  68380. /**
  68381. * The url to the WebAssembly module.
  68382. */
  68383. wasmUrl?: string;
  68384. /**
  68385. * The url to the WebAssembly binary.
  68386. */
  68387. wasmBinaryUrl?: string;
  68388. /**
  68389. * The url to the fallback JavaScript module.
  68390. */
  68391. fallbackUrl?: string;
  68392. };
  68393. }
  68394. /**
  68395. * Draco compression (https://google.github.io/draco/)
  68396. *
  68397. * This class wraps the Draco module.
  68398. *
  68399. * **Encoder**
  68400. *
  68401. * The encoder is not currently implemented.
  68402. *
  68403. * **Decoder**
  68404. *
  68405. * 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.
  68406. *
  68407. * To update the configuration, use the following code:
  68408. * ```javascript
  68409. * DracoCompression.Configuration = {
  68410. * decoder: {
  68411. * wasmUrl: "<url to the WebAssembly library>",
  68412. * wasmBinaryUrl: "<url to the WebAssembly binary>",
  68413. * fallbackUrl: "<url to the fallback JavaScript library>",
  68414. * }
  68415. * };
  68416. * ```
  68417. *
  68418. * 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.
  68419. * Decoding will automatically fallback to the JavaScript version if WebAssembly version is not configured or if WebAssembly is not supported by the browser.
  68420. * Use `DracoCompression.DecoderAvailable` to determine if the decoder configuration is available for the current context.
  68421. *
  68422. * To decode Draco compressed data, get the default DracoCompression object and call decodeMeshAsync:
  68423. * ```javascript
  68424. * var vertexData = await DracoCompression.Default.decodeMeshAsync(data);
  68425. * ```
  68426. *
  68427. * @see https://www.babylonjs-playground.com/#N3EK4B#0
  68428. */
  68429. export class DracoCompression implements IDisposable {
  68430. private _workerPoolPromise?;
  68431. private _decoderModulePromise?;
  68432. /**
  68433. * The configuration. Defaults to the following urls:
  68434. * - wasmUrl: "https://preview.babylonjs.com/draco_wasm_wrapper_gltf.js"
  68435. * - wasmBinaryUrl: "https://preview.babylonjs.com/draco_decoder_gltf.wasm"
  68436. * - fallbackUrl: "https://preview.babylonjs.com/draco_decoder_gltf.js"
  68437. */
  68438. static Configuration: IDracoCompressionConfiguration;
  68439. /**
  68440. * Returns true if the decoder configuration is available.
  68441. */
  68442. static get DecoderAvailable(): boolean;
  68443. /**
  68444. * Default number of workers to create when creating the draco compression object.
  68445. */
  68446. static DefaultNumWorkers: number;
  68447. private static GetDefaultNumWorkers;
  68448. private static _Default;
  68449. /**
  68450. * Default instance for the draco compression object.
  68451. */
  68452. static get Default(): DracoCompression;
  68453. /**
  68454. * Constructor
  68455. * @param numWorkers The number of workers for async operations. Specify `0` to disable web workers and run synchronously in the current context.
  68456. */
  68457. constructor(numWorkers?: number);
  68458. /**
  68459. * Stop all async operations and release resources.
  68460. */
  68461. dispose(): void;
  68462. /**
  68463. * Returns a promise that resolves when ready. Call this manually to ensure draco compression is ready before use.
  68464. * @returns a promise that resolves when ready
  68465. */
  68466. whenReadyAsync(): Promise<void>;
  68467. /**
  68468. * Decode Draco compressed mesh data to vertex data.
  68469. * @param data The ArrayBuffer or ArrayBufferView for the Draco compression data
  68470. * @param attributes A map of attributes from vertex buffer kinds to Draco unique ids
  68471. * @returns A promise that resolves with the decoded vertex data
  68472. */
  68473. decodeMeshAsync(data: ArrayBuffer | ArrayBufferView, attributes?: {
  68474. [kind: string]: number;
  68475. }): Promise<VertexData>;
  68476. }
  68477. }
  68478. declare module "babylonjs/Meshes/Compression/index" {
  68479. export * from "babylonjs/Meshes/Compression/dracoCompression";
  68480. }
  68481. declare module "babylonjs/Meshes/csg" {
  68482. import { Nullable } from "babylonjs/types";
  68483. import { Scene } from "babylonjs/scene";
  68484. import { Quaternion, Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  68485. import { Mesh } from "babylonjs/Meshes/mesh";
  68486. import { Material } from "babylonjs/Materials/material";
  68487. /**
  68488. * Class for building Constructive Solid Geometry
  68489. */
  68490. export class CSG {
  68491. private polygons;
  68492. /**
  68493. * The world matrix
  68494. */
  68495. matrix: Matrix;
  68496. /**
  68497. * Stores the position
  68498. */
  68499. position: Vector3;
  68500. /**
  68501. * Stores the rotation
  68502. */
  68503. rotation: Vector3;
  68504. /**
  68505. * Stores the rotation quaternion
  68506. */
  68507. rotationQuaternion: Nullable<Quaternion>;
  68508. /**
  68509. * Stores the scaling vector
  68510. */
  68511. scaling: Vector3;
  68512. /**
  68513. * Convert the Mesh to CSG
  68514. * @param mesh The Mesh to convert to CSG
  68515. * @returns A new CSG from the Mesh
  68516. */
  68517. static FromMesh(mesh: Mesh): CSG;
  68518. /**
  68519. * Construct a CSG solid from a list of `CSG.Polygon` instances.
  68520. * @param polygons Polygons used to construct a CSG solid
  68521. */
  68522. private static FromPolygons;
  68523. /**
  68524. * Clones, or makes a deep copy, of the CSG
  68525. * @returns A new CSG
  68526. */
  68527. clone(): CSG;
  68528. /**
  68529. * Unions this CSG with another CSG
  68530. * @param csg The CSG to union against this CSG
  68531. * @returns The unioned CSG
  68532. */
  68533. union(csg: CSG): CSG;
  68534. /**
  68535. * Unions this CSG with another CSG in place
  68536. * @param csg The CSG to union against this CSG
  68537. */
  68538. unionInPlace(csg: CSG): void;
  68539. /**
  68540. * Subtracts this CSG with another CSG
  68541. * @param csg The CSG to subtract against this CSG
  68542. * @returns A new CSG
  68543. */
  68544. subtract(csg: CSG): CSG;
  68545. /**
  68546. * Subtracts this CSG with another CSG in place
  68547. * @param csg The CSG to subtact against this CSG
  68548. */
  68549. subtractInPlace(csg: CSG): void;
  68550. /**
  68551. * Intersect this CSG with another CSG
  68552. * @param csg The CSG to intersect against this CSG
  68553. * @returns A new CSG
  68554. */
  68555. intersect(csg: CSG): CSG;
  68556. /**
  68557. * Intersects this CSG with another CSG in place
  68558. * @param csg The CSG to intersect against this CSG
  68559. */
  68560. intersectInPlace(csg: CSG): void;
  68561. /**
  68562. * Return a new CSG solid with solid and empty space switched. This solid is
  68563. * not modified.
  68564. * @returns A new CSG solid with solid and empty space switched
  68565. */
  68566. inverse(): CSG;
  68567. /**
  68568. * Inverses the CSG in place
  68569. */
  68570. inverseInPlace(): void;
  68571. /**
  68572. * This is used to keep meshes transformations so they can be restored
  68573. * when we build back a Babylon Mesh
  68574. * NB : All CSG operations are performed in world coordinates
  68575. * @param csg The CSG to copy the transform attributes from
  68576. * @returns This CSG
  68577. */
  68578. copyTransformAttributes(csg: CSG): CSG;
  68579. /**
  68580. * Build Raw mesh from CSG
  68581. * Coordinates here are in world space
  68582. * @param name The name of the mesh geometry
  68583. * @param scene The Scene
  68584. * @param keepSubMeshes Specifies if the submeshes should be kept
  68585. * @returns A new Mesh
  68586. */
  68587. buildMeshGeometry(name: string, scene?: Scene, keepSubMeshes?: boolean): Mesh;
  68588. /**
  68589. * Build Mesh from CSG taking material and transforms into account
  68590. * @param name The name of the Mesh
  68591. * @param material The material of the Mesh
  68592. * @param scene The Scene
  68593. * @param keepSubMeshes Specifies if submeshes should be kept
  68594. * @returns The new Mesh
  68595. */
  68596. toMesh(name: string, material?: Nullable<Material>, scene?: Scene, keepSubMeshes?: boolean): Mesh;
  68597. }
  68598. }
  68599. declare module "babylonjs/Meshes/trailMesh" {
  68600. import { Mesh } from "babylonjs/Meshes/mesh";
  68601. import { Scene } from "babylonjs/scene";
  68602. import { TransformNode } from "babylonjs/Meshes/transformNode";
  68603. /**
  68604. * Class used to create a trail following a mesh
  68605. */
  68606. export class TrailMesh extends Mesh {
  68607. private _generator;
  68608. private _autoStart;
  68609. private _running;
  68610. private _diameter;
  68611. private _length;
  68612. private _sectionPolygonPointsCount;
  68613. private _sectionVectors;
  68614. private _sectionNormalVectors;
  68615. private _beforeRenderObserver;
  68616. /**
  68617. * @constructor
  68618. * @param name The value used by scene.getMeshByName() to do a lookup.
  68619. * @param generator The mesh or transform node to generate a trail.
  68620. * @param scene The scene to add this mesh to.
  68621. * @param diameter Diameter of trailing mesh. Default is 1.
  68622. * @param length Length of trailing mesh. Default is 60.
  68623. * @param autoStart Automatically start trailing mesh. Default true.
  68624. */
  68625. constructor(name: string, generator: TransformNode, scene: Scene, diameter?: number, length?: number, autoStart?: boolean);
  68626. /**
  68627. * "TrailMesh"
  68628. * @returns "TrailMesh"
  68629. */
  68630. getClassName(): string;
  68631. private _createMesh;
  68632. /**
  68633. * Start trailing mesh.
  68634. */
  68635. start(): void;
  68636. /**
  68637. * Stop trailing mesh.
  68638. */
  68639. stop(): void;
  68640. /**
  68641. * Update trailing mesh geometry.
  68642. */
  68643. update(): void;
  68644. /**
  68645. * Returns a new TrailMesh object.
  68646. * @param name is a string, the name given to the new mesh
  68647. * @param newGenerator use new generator object for cloned trail mesh
  68648. * @returns a new mesh
  68649. */
  68650. clone(name: string | undefined, newGenerator: TransformNode): TrailMesh;
  68651. /**
  68652. * Serializes this trail mesh
  68653. * @param serializationObject object to write serialization to
  68654. */
  68655. serialize(serializationObject: any): void;
  68656. /**
  68657. * Parses a serialized trail mesh
  68658. * @param parsedMesh the serialized mesh
  68659. * @param scene the scene to create the trail mesh in
  68660. * @returns the created trail mesh
  68661. */
  68662. static Parse(parsedMesh: any, scene: Scene): TrailMesh;
  68663. }
  68664. }
  68665. declare module "babylonjs/Meshes/Builders/tiledBoxBuilder" {
  68666. import { Nullable } from "babylonjs/types";
  68667. import { Scene } from "babylonjs/scene";
  68668. import { Vector4 } from "babylonjs/Maths/math.vector";
  68669. import { Color4 } from "babylonjs/Maths/math.color";
  68670. import { Mesh } from "babylonjs/Meshes/mesh";
  68671. /**
  68672. * Class containing static functions to help procedurally build meshes
  68673. */
  68674. export class TiledBoxBuilder {
  68675. /**
  68676. * Creates a box mesh
  68677. * 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)
  68678. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  68679. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  68680. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  68681. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  68682. * @param name defines the name of the mesh
  68683. * @param options defines the options used to create the mesh
  68684. * @param scene defines the hosting scene
  68685. * @returns the box mesh
  68686. */
  68687. static CreateTiledBox(name: string, options: {
  68688. pattern?: number;
  68689. width?: number;
  68690. height?: number;
  68691. depth?: number;
  68692. tileSize?: number;
  68693. tileWidth?: number;
  68694. tileHeight?: number;
  68695. alignHorizontal?: number;
  68696. alignVertical?: number;
  68697. faceUV?: Vector4[];
  68698. faceColors?: Color4[];
  68699. sideOrientation?: number;
  68700. updatable?: boolean;
  68701. }, scene?: Nullable<Scene>): Mesh;
  68702. }
  68703. }
  68704. declare module "babylonjs/Meshes/Builders/torusKnotBuilder" {
  68705. import { Vector4 } from "babylonjs/Maths/math.vector";
  68706. import { Mesh } from "babylonjs/Meshes/mesh";
  68707. /**
  68708. * Class containing static functions to help procedurally build meshes
  68709. */
  68710. export class TorusKnotBuilder {
  68711. /**
  68712. * Creates a torus knot mesh
  68713. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  68714. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  68715. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  68716. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  68717. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  68718. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  68719. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  68720. * @param name defines the name of the mesh
  68721. * @param options defines the options used to create the mesh
  68722. * @param scene defines the hosting scene
  68723. * @returns the torus knot mesh
  68724. * @see https://doc.babylonjs.com/how_to/set_shapes#torus-knot
  68725. */
  68726. static CreateTorusKnot(name: string, options: {
  68727. radius?: number;
  68728. tube?: number;
  68729. radialSegments?: number;
  68730. tubularSegments?: number;
  68731. p?: number;
  68732. q?: number;
  68733. updatable?: boolean;
  68734. sideOrientation?: number;
  68735. frontUVs?: Vector4;
  68736. backUVs?: Vector4;
  68737. }, scene: any): Mesh;
  68738. }
  68739. }
  68740. declare module "babylonjs/Meshes/polygonMesh" {
  68741. import { Scene } from "babylonjs/scene";
  68742. import { Vector2 } from "babylonjs/Maths/math.vector";
  68743. import { Mesh } from "babylonjs/Meshes/mesh";
  68744. import { VertexData } from "babylonjs/Meshes/mesh.vertexData";
  68745. import { Path2 } from "babylonjs/Maths/math.path";
  68746. /**
  68747. * Polygon
  68748. * @see https://doc.babylonjs.com/how_to/parametric_shapes#non-regular-polygon
  68749. */
  68750. export class Polygon {
  68751. /**
  68752. * Creates a rectangle
  68753. * @param xmin bottom X coord
  68754. * @param ymin bottom Y coord
  68755. * @param xmax top X coord
  68756. * @param ymax top Y coord
  68757. * @returns points that make the resulting rectation
  68758. */
  68759. static Rectangle(xmin: number, ymin: number, xmax: number, ymax: number): Vector2[];
  68760. /**
  68761. * Creates a circle
  68762. * @param radius radius of circle
  68763. * @param cx scale in x
  68764. * @param cy scale in y
  68765. * @param numberOfSides number of sides that make up the circle
  68766. * @returns points that make the resulting circle
  68767. */
  68768. static Circle(radius: number, cx?: number, cy?: number, numberOfSides?: number): Vector2[];
  68769. /**
  68770. * Creates a polygon from input string
  68771. * @param input Input polygon data
  68772. * @returns the parsed points
  68773. */
  68774. static Parse(input: string): Vector2[];
  68775. /**
  68776. * Starts building a polygon from x and y coordinates
  68777. * @param x x coordinate
  68778. * @param y y coordinate
  68779. * @returns the started path2
  68780. */
  68781. static StartingAt(x: number, y: number): Path2;
  68782. }
  68783. /**
  68784. * Builds a polygon
  68785. * @see https://doc.babylonjs.com/how_to/polygonmeshbuilder
  68786. */
  68787. export class PolygonMeshBuilder {
  68788. private _points;
  68789. private _outlinepoints;
  68790. private _holes;
  68791. private _name;
  68792. private _scene;
  68793. private _epoints;
  68794. private _eholes;
  68795. private _addToepoint;
  68796. /**
  68797. * Babylon reference to the earcut plugin.
  68798. */
  68799. bjsEarcut: any;
  68800. /**
  68801. * Creates a PolygonMeshBuilder
  68802. * @param name name of the builder
  68803. * @param contours Path of the polygon
  68804. * @param scene scene to add to when creating the mesh
  68805. * @param earcutInjection can be used to inject your own earcut reference
  68806. */
  68807. constructor(name: string, contours: Path2 | Vector2[] | any, scene?: Scene, earcutInjection?: any);
  68808. /**
  68809. * Adds a whole within the polygon
  68810. * @param hole Array of points defining the hole
  68811. * @returns this
  68812. */
  68813. addHole(hole: Vector2[]): PolygonMeshBuilder;
  68814. /**
  68815. * Creates the polygon
  68816. * @param updatable If the mesh should be updatable
  68817. * @param depth The depth of the mesh created
  68818. * @returns the created mesh
  68819. */
  68820. build(updatable?: boolean, depth?: number): Mesh;
  68821. /**
  68822. * Creates the polygon
  68823. * @param depth The depth of the mesh created
  68824. * @returns the created VertexData
  68825. */
  68826. buildVertexData(depth?: number): VertexData;
  68827. /**
  68828. * Adds a side to the polygon
  68829. * @param positions points that make the polygon
  68830. * @param normals normals of the polygon
  68831. * @param uvs uvs of the polygon
  68832. * @param indices indices of the polygon
  68833. * @param bounds bounds of the polygon
  68834. * @param points points of the polygon
  68835. * @param depth depth of the polygon
  68836. * @param flip flip of the polygon
  68837. */
  68838. private addSide;
  68839. }
  68840. }
  68841. declare module "babylonjs/Meshes/Builders/polygonBuilder" {
  68842. import { Scene } from "babylonjs/scene";
  68843. import { Vector3, Vector4 } from "babylonjs/Maths/math.vector";
  68844. import { Color4 } from "babylonjs/Maths/math.color";
  68845. import { Mesh } from "babylonjs/Meshes/mesh";
  68846. import { Nullable } from "babylonjs/types";
  68847. /**
  68848. * Class containing static functions to help procedurally build meshes
  68849. */
  68850. export class PolygonBuilder {
  68851. /**
  68852. * Creates a polygon mesh
  68853. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  68854. * * 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
  68855. * * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  68856. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  68857. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4)
  68858. * * Remember you can only change the shape positions, not their number when updating a polygon
  68859. * @param name defines the name of the mesh
  68860. * @param options defines the options used to create the mesh
  68861. * @param scene defines the hosting scene
  68862. * @param earcutInjection can be used to inject your own earcut reference
  68863. * @returns the polygon mesh
  68864. */
  68865. static CreatePolygon(name: string, options: {
  68866. shape: Vector3[];
  68867. holes?: Vector3[][];
  68868. depth?: number;
  68869. faceUV?: Vector4[];
  68870. faceColors?: Color4[];
  68871. updatable?: boolean;
  68872. sideOrientation?: number;
  68873. frontUVs?: Vector4;
  68874. backUVs?: Vector4;
  68875. wrap?: boolean;
  68876. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  68877. /**
  68878. * Creates an extruded polygon mesh, with depth in the Y direction.
  68879. * * 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)
  68880. * @see https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  68881. * @param name defines the name of the mesh
  68882. * @param options defines the options used to create the mesh
  68883. * @param scene defines the hosting scene
  68884. * @param earcutInjection can be used to inject your own earcut reference
  68885. * @returns the polygon mesh
  68886. */
  68887. static ExtrudePolygon(name: string, options: {
  68888. shape: Vector3[];
  68889. holes?: Vector3[][];
  68890. depth?: number;
  68891. faceUV?: Vector4[];
  68892. faceColors?: Color4[];
  68893. updatable?: boolean;
  68894. sideOrientation?: number;
  68895. frontUVs?: Vector4;
  68896. backUVs?: Vector4;
  68897. wrap?: boolean;
  68898. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  68899. }
  68900. }
  68901. declare module "babylonjs/Meshes/Builders/latheBuilder" {
  68902. import { Scene } from "babylonjs/scene";
  68903. import { Vector3, Vector4 } from "babylonjs/Maths/math.vector";
  68904. import { Mesh } from "babylonjs/Meshes/mesh";
  68905. import { Nullable } from "babylonjs/types";
  68906. /**
  68907. * Class containing static functions to help procedurally build meshes
  68908. */
  68909. export class LatheBuilder {
  68910. /**
  68911. * Creates lathe mesh.
  68912. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe
  68913. * * 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
  68914. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  68915. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  68916. * * The parameter `clip` (positive integer, default 0) is the number of sides to not create without effecting the general shape of the sides
  68917. * * 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
  68918. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  68919. * * 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
  68920. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  68921. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  68922. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  68923. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  68924. * @param name defines the name of the mesh
  68925. * @param options defines the options used to create the mesh
  68926. * @param scene defines the hosting scene
  68927. * @returns the lathe mesh
  68928. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lathe
  68929. */
  68930. static CreateLathe(name: string, options: {
  68931. shape: Vector3[];
  68932. radius?: number;
  68933. tessellation?: number;
  68934. clip?: number;
  68935. arc?: number;
  68936. closed?: boolean;
  68937. updatable?: boolean;
  68938. sideOrientation?: number;
  68939. frontUVs?: Vector4;
  68940. backUVs?: Vector4;
  68941. cap?: number;
  68942. invertUV?: boolean;
  68943. }, scene?: Nullable<Scene>): Mesh;
  68944. }
  68945. }
  68946. declare module "babylonjs/Meshes/Builders/tiledPlaneBuilder" {
  68947. import { Nullable } from "babylonjs/types";
  68948. import { Scene } from "babylonjs/scene";
  68949. import { Vector4 } from "babylonjs/Maths/math.vector";
  68950. import { Mesh } from "babylonjs/Meshes/mesh";
  68951. /**
  68952. * Class containing static functions to help procedurally build meshes
  68953. */
  68954. export class TiledPlaneBuilder {
  68955. /**
  68956. * Creates a tiled plane mesh
  68957. * * The parameter `pattern` will, depending on value, do nothing or
  68958. * * * flip (reflect about central vertical) alternate tiles across and up
  68959. * * * flip every tile on alternate rows
  68960. * * * rotate (180 degs) alternate tiles across and up
  68961. * * * rotate every tile on alternate rows
  68962. * * * flip and rotate alternate tiles across and up
  68963. * * * flip and rotate every tile on alternate rows
  68964. * * The parameter `tileSize` sets the size (float) of each tile side (default 1)
  68965. * * You can set some different tile dimensions by using the parameters `tileWidth` and `tileHeight` (both by default have the same value of `tileSize`)
  68966. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  68967. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  68968. * * 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)
  68969. * * 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)
  68970. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  68971. * @param name defines the name of the mesh
  68972. * @param options defines the options used to create the mesh
  68973. * @param scene defines the hosting scene
  68974. * @returns the box mesh
  68975. */
  68976. static CreateTiledPlane(name: string, options: {
  68977. pattern?: number;
  68978. tileSize?: number;
  68979. tileWidth?: number;
  68980. tileHeight?: number;
  68981. size?: number;
  68982. width?: number;
  68983. height?: number;
  68984. alignHorizontal?: number;
  68985. alignVertical?: number;
  68986. sideOrientation?: number;
  68987. frontUVs?: Vector4;
  68988. backUVs?: Vector4;
  68989. updatable?: boolean;
  68990. }, scene?: Nullable<Scene>): Mesh;
  68991. }
  68992. }
  68993. declare module "babylonjs/Meshes/Builders/tubeBuilder" {
  68994. import { Nullable } from "babylonjs/types";
  68995. import { Scene } from "babylonjs/scene";
  68996. import { Vector3, Vector4 } from "babylonjs/Maths/math.vector";
  68997. import { Mesh } from "babylonjs/Meshes/mesh";
  68998. /**
  68999. * Class containing static functions to help procedurally build meshes
  69000. */
  69001. export class TubeBuilder {
  69002. /**
  69003. * Creates a tube mesh.
  69004. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  69005. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  69006. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  69007. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  69008. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`
  69009. * * 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)
  69010. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  69011. * * 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
  69012. * * 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
  69013. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  69014. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  69015. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  69016. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  69017. * @param name defines the name of the mesh
  69018. * @param options defines the options used to create the mesh
  69019. * @param scene defines the hosting scene
  69020. * @returns the tube mesh
  69021. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  69022. * @see https://doc.babylonjs.com/how_to/set_shapes#tube
  69023. */
  69024. static CreateTube(name: string, options: {
  69025. path: Vector3[];
  69026. radius?: number;
  69027. tessellation?: number;
  69028. radiusFunction?: {
  69029. (i: number, distance: number): number;
  69030. };
  69031. cap?: number;
  69032. arc?: number;
  69033. updatable?: boolean;
  69034. sideOrientation?: number;
  69035. frontUVs?: Vector4;
  69036. backUVs?: Vector4;
  69037. instance?: Mesh;
  69038. invertUV?: boolean;
  69039. }, scene?: Nullable<Scene>): Mesh;
  69040. }
  69041. }
  69042. declare module "babylonjs/Meshes/Builders/icoSphereBuilder" {
  69043. import { Scene } from "babylonjs/scene";
  69044. import { Vector4 } from "babylonjs/Maths/math.vector";
  69045. import { Mesh } from "babylonjs/Meshes/mesh";
  69046. import { Nullable } from "babylonjs/types";
  69047. /**
  69048. * Class containing static functions to help procedurally build meshes
  69049. */
  69050. export class IcoSphereBuilder {
  69051. /**
  69052. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  69053. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  69054. * * 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`)
  69055. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  69056. * * 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
  69057. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  69058. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  69059. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  69060. * @param name defines the name of the mesh
  69061. * @param options defines the options used to create the mesh
  69062. * @param scene defines the hosting scene
  69063. * @returns the icosahedron mesh
  69064. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  69065. */
  69066. static CreateIcoSphere(name: string, options: {
  69067. radius?: number;
  69068. radiusX?: number;
  69069. radiusY?: number;
  69070. radiusZ?: number;
  69071. flat?: boolean;
  69072. subdivisions?: number;
  69073. sideOrientation?: number;
  69074. frontUVs?: Vector4;
  69075. backUVs?: Vector4;
  69076. updatable?: boolean;
  69077. }, scene?: Nullable<Scene>): Mesh;
  69078. }
  69079. }
  69080. declare module "babylonjs/Meshes/Builders/decalBuilder" {
  69081. import { Vector3 } from "babylonjs/Maths/math.vector";
  69082. import { Mesh } from "babylonjs/Meshes/mesh";
  69083. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  69084. /**
  69085. * Class containing static functions to help procedurally build meshes
  69086. */
  69087. export class DecalBuilder {
  69088. /**
  69089. * Creates a decal mesh.
  69090. * 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
  69091. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  69092. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  69093. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  69094. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  69095. * @param name defines the name of the mesh
  69096. * @param sourceMesh defines the mesh where the decal must be applied
  69097. * @param options defines the options used to create the mesh
  69098. * @param scene defines the hosting scene
  69099. * @returns the decal mesh
  69100. * @see https://doc.babylonjs.com/how_to/decals
  69101. */
  69102. static CreateDecal(name: string, sourceMesh: AbstractMesh, options: {
  69103. position?: Vector3;
  69104. normal?: Vector3;
  69105. size?: Vector3;
  69106. angle?: number;
  69107. }): Mesh;
  69108. }
  69109. }
  69110. declare module "babylonjs/Meshes/meshBuilder" {
  69111. import { Vector4, Vector3, Vector2 } from "babylonjs/Maths/math.vector";
  69112. import { Nullable } from "babylonjs/types";
  69113. import { Scene } from "babylonjs/scene";
  69114. import { Mesh } from "babylonjs/Meshes/mesh";
  69115. import { LinesMesh } from "babylonjs/Meshes/linesMesh";
  69116. import { GroundMesh } from "babylonjs/Meshes/groundMesh";
  69117. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  69118. import { Color4, Color3 } from "babylonjs/Maths/math.color";
  69119. import { Plane } from "babylonjs/Maths/math.plane";
  69120. /**
  69121. * Class containing static functions to help procedurally build meshes
  69122. */
  69123. export class MeshBuilder {
  69124. /**
  69125. * Creates a box mesh
  69126. * * The parameter `size` sets the size (float) of each box side (default 1)
  69127. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value of `size`)
  69128. * * 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)
  69129. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  69130. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  69131. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  69132. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  69133. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  69134. * @param name defines the name of the mesh
  69135. * @param options defines the options used to create the mesh
  69136. * @param scene defines the hosting scene
  69137. * @returns the box mesh
  69138. */
  69139. static CreateBox(name: string, options: {
  69140. size?: number;
  69141. width?: number;
  69142. height?: number;
  69143. depth?: number;
  69144. faceUV?: Vector4[];
  69145. faceColors?: Color4[];
  69146. sideOrientation?: number;
  69147. frontUVs?: Vector4;
  69148. backUVs?: Vector4;
  69149. wrap?: boolean;
  69150. topBaseAt?: number;
  69151. bottomBaseAt?: number;
  69152. updatable?: boolean;
  69153. }, scene?: Nullable<Scene>): Mesh;
  69154. /**
  69155. * Creates a tiled box mesh
  69156. * * faceTiles sets the pattern, tile size and number of tiles for a face
  69157. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  69158. * @param name defines the name of the mesh
  69159. * @param options defines the options used to create the mesh
  69160. * @param scene defines the hosting scene
  69161. * @returns the tiled box mesh
  69162. */
  69163. static CreateTiledBox(name: string, options: {
  69164. pattern?: number;
  69165. size?: number;
  69166. width?: number;
  69167. height?: number;
  69168. depth: number;
  69169. tileSize?: number;
  69170. tileWidth?: number;
  69171. tileHeight?: number;
  69172. faceUV?: Vector4[];
  69173. faceColors?: Color4[];
  69174. alignHorizontal?: number;
  69175. alignVertical?: number;
  69176. sideOrientation?: number;
  69177. updatable?: boolean;
  69178. }, scene?: Nullable<Scene>): Mesh;
  69179. /**
  69180. * Creates a sphere mesh
  69181. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  69182. * * 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`)
  69183. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  69184. * * 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
  69185. * * 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)
  69186. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  69187. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  69188. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  69189. * @param name defines the name of the mesh
  69190. * @param options defines the options used to create the mesh
  69191. * @param scene defines the hosting scene
  69192. * @returns the sphere mesh
  69193. * @see https://doc.babylonjs.com/how_to/set_shapes#sphere
  69194. */
  69195. static CreateSphere(name: string, options: {
  69196. segments?: number;
  69197. diameter?: number;
  69198. diameterX?: number;
  69199. diameterY?: number;
  69200. diameterZ?: number;
  69201. arc?: number;
  69202. slice?: number;
  69203. sideOrientation?: number;
  69204. frontUVs?: Vector4;
  69205. backUVs?: Vector4;
  69206. updatable?: boolean;
  69207. }, scene?: Nullable<Scene>): Mesh;
  69208. /**
  69209. * Creates a plane polygonal mesh. By default, this is a disc
  69210. * * The parameter `radius` sets the radius size (float) of the polygon (default 0.5)
  69211. * * 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
  69212. * * 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
  69213. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  69214. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  69215. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  69216. * @param name defines the name of the mesh
  69217. * @param options defines the options used to create the mesh
  69218. * @param scene defines the hosting scene
  69219. * @returns the plane polygonal mesh
  69220. * @see https://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  69221. */
  69222. static CreateDisc(name: string, options: {
  69223. radius?: number;
  69224. tessellation?: number;
  69225. arc?: number;
  69226. updatable?: boolean;
  69227. sideOrientation?: number;
  69228. frontUVs?: Vector4;
  69229. backUVs?: Vector4;
  69230. }, scene?: Nullable<Scene>): Mesh;
  69231. /**
  69232. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  69233. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  69234. * * 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`)
  69235. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  69236. * * 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
  69237. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  69238. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  69239. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  69240. * @param name defines the name of the mesh
  69241. * @param options defines the options used to create the mesh
  69242. * @param scene defines the hosting scene
  69243. * @returns the icosahedron mesh
  69244. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  69245. */
  69246. static CreateIcoSphere(name: string, options: {
  69247. radius?: number;
  69248. radiusX?: number;
  69249. radiusY?: number;
  69250. radiusZ?: number;
  69251. flat?: boolean;
  69252. subdivisions?: number;
  69253. sideOrientation?: number;
  69254. frontUVs?: Vector4;
  69255. backUVs?: Vector4;
  69256. updatable?: boolean;
  69257. }, scene?: Nullable<Scene>): Mesh;
  69258. /**
  69259. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  69260. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  69261. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  69262. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  69263. * * 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
  69264. * * 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
  69265. * * 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
  69266. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  69267. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  69268. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  69269. * * 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
  69270. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  69271. * * 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
  69272. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  69273. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  69274. * @param name defines the name of the mesh
  69275. * @param options defines the options used to create the mesh
  69276. * @param scene defines the hosting scene
  69277. * @returns the ribbon mesh
  69278. * @see https://doc.babylonjs.com/how_to/ribbon_tutorial
  69279. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  69280. */
  69281. static CreateRibbon(name: string, options: {
  69282. pathArray: Vector3[][];
  69283. closeArray?: boolean;
  69284. closePath?: boolean;
  69285. offset?: number;
  69286. updatable?: boolean;
  69287. sideOrientation?: number;
  69288. frontUVs?: Vector4;
  69289. backUVs?: Vector4;
  69290. instance?: Mesh;
  69291. invertUV?: boolean;
  69292. uvs?: Vector2[];
  69293. colors?: Color4[];
  69294. }, scene?: Nullable<Scene>): Mesh;
  69295. /**
  69296. * Creates a cylinder or a cone mesh
  69297. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  69298. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  69299. * * 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.
  69300. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  69301. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  69302. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  69303. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  69304. * * 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).
  69305. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  69306. * * 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).
  69307. * * 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
  69308. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  69309. * * 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
  69310. * * 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.
  69311. * * If `enclose` is false, a ring surface is one element.
  69312. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  69313. * * 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
  69314. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  69315. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  69316. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  69317. * @param name defines the name of the mesh
  69318. * @param options defines the options used to create the mesh
  69319. * @param scene defines the hosting scene
  69320. * @returns the cylinder mesh
  69321. * @see https://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  69322. */
  69323. static CreateCylinder(name: string, options: {
  69324. height?: number;
  69325. diameterTop?: number;
  69326. diameterBottom?: number;
  69327. diameter?: number;
  69328. tessellation?: number;
  69329. subdivisions?: number;
  69330. arc?: number;
  69331. faceColors?: Color4[];
  69332. faceUV?: Vector4[];
  69333. updatable?: boolean;
  69334. hasRings?: boolean;
  69335. enclose?: boolean;
  69336. cap?: number;
  69337. sideOrientation?: number;
  69338. frontUVs?: Vector4;
  69339. backUVs?: Vector4;
  69340. }, scene?: Nullable<Scene>): Mesh;
  69341. /**
  69342. * Creates a torus mesh
  69343. * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
  69344. * * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5)
  69345. * * The parameter `tessellation` sets the number of torus sides (postive integer, default 16)
  69346. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  69347. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  69348. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  69349. * @param name defines the name of the mesh
  69350. * @param options defines the options used to create the mesh
  69351. * @param scene defines the hosting scene
  69352. * @returns the torus mesh
  69353. * @see https://doc.babylonjs.com/how_to/set_shapes#torus
  69354. */
  69355. static CreateTorus(name: string, options: {
  69356. diameter?: number;
  69357. thickness?: number;
  69358. tessellation?: number;
  69359. updatable?: boolean;
  69360. sideOrientation?: number;
  69361. frontUVs?: Vector4;
  69362. backUVs?: Vector4;
  69363. }, scene?: Nullable<Scene>): Mesh;
  69364. /**
  69365. * Creates a torus knot mesh
  69366. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  69367. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  69368. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  69369. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  69370. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  69371. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  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 torus knot mesh
  69377. * @see https://doc.babylonjs.com/how_to/set_shapes#torus-knot
  69378. */
  69379. static CreateTorusKnot(name: string, options: {
  69380. radius?: number;
  69381. tube?: number;
  69382. radialSegments?: number;
  69383. tubularSegments?: number;
  69384. p?: number;
  69385. q?: number;
  69386. updatable?: boolean;
  69387. sideOrientation?: number;
  69388. frontUVs?: Vector4;
  69389. backUVs?: Vector4;
  69390. }, scene?: Nullable<Scene>): Mesh;
  69391. /**
  69392. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  69393. * * 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
  69394. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  69395. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  69396. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  69397. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  69398. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  69399. * * 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
  69400. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  69401. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  69402. * @see https://doc.babylonjs.com/how_to/parametric_shapes#line-system
  69403. * @param name defines the name of the new line system
  69404. * @param options defines the options used to create the line system
  69405. * @param scene defines the hosting scene
  69406. * @returns a new line system mesh
  69407. */
  69408. static CreateLineSystem(name: string, options: {
  69409. lines: Vector3[][];
  69410. updatable?: boolean;
  69411. instance?: Nullable<LinesMesh>;
  69412. colors?: Nullable<Color4[][]>;
  69413. useVertexAlpha?: boolean;
  69414. }, scene: Nullable<Scene>): LinesMesh;
  69415. /**
  69416. * Creates a line mesh
  69417. * 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
  69418. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  69419. * * The parameter `points` is an array successive Vector3
  69420. * * 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
  69421. * * The optional parameter `colors` is an array of successive Color4, one per line point
  69422. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  69423. * * When updating an instance, remember that only point positions can change, not the number of points
  69424. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  69425. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lines
  69426. * @param name defines the name of the new line system
  69427. * @param options defines the options used to create the line system
  69428. * @param scene defines the hosting scene
  69429. * @returns a new line mesh
  69430. */
  69431. static CreateLines(name: string, options: {
  69432. points: Vector3[];
  69433. updatable?: boolean;
  69434. instance?: Nullable<LinesMesh>;
  69435. colors?: Color4[];
  69436. useVertexAlpha?: boolean;
  69437. }, scene?: Nullable<Scene>): LinesMesh;
  69438. /**
  69439. * Creates a dashed line mesh
  69440. * * 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
  69441. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  69442. * * The parameter `points` is an array successive Vector3
  69443. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  69444. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  69445. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  69446. * * 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
  69447. * * When updating an instance, remember that only point positions can change, not the number of points
  69448. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  69449. * @param name defines the name of the mesh
  69450. * @param options defines the options used to create the mesh
  69451. * @param scene defines the hosting scene
  69452. * @returns the dashed line mesh
  69453. * @see https://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  69454. */
  69455. static CreateDashedLines(name: string, options: {
  69456. points: Vector3[];
  69457. dashSize?: number;
  69458. gapSize?: number;
  69459. dashNb?: number;
  69460. updatable?: boolean;
  69461. instance?: LinesMesh;
  69462. }, scene?: Nullable<Scene>): LinesMesh;
  69463. /**
  69464. * 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.
  69465. * * 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.
  69466. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  69467. * * 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.
  69468. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  69469. * * 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
  69470. * * 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
  69471. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  69472. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  69473. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  69474. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  69475. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  69476. * @param name defines the name of the mesh
  69477. * @param options defines the options used to create the mesh
  69478. * @param scene defines the hosting scene
  69479. * @returns the extruded shape mesh
  69480. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  69481. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  69482. */
  69483. static ExtrudeShape(name: string, options: {
  69484. shape: Vector3[];
  69485. path: Vector3[];
  69486. scale?: number;
  69487. rotation?: number;
  69488. cap?: number;
  69489. updatable?: boolean;
  69490. sideOrientation?: number;
  69491. frontUVs?: Vector4;
  69492. backUVs?: Vector4;
  69493. instance?: Mesh;
  69494. invertUV?: boolean;
  69495. }, scene?: Nullable<Scene>): Mesh;
  69496. /**
  69497. * Creates an custom extruded shape mesh.
  69498. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  69499. * * 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.
  69500. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  69501. * * 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
  69502. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  69503. * * 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
  69504. * * It must returns a float value that will be the scale value applied to the shape on each path point
  69505. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  69506. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  69507. * * 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
  69508. * * 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
  69509. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  69510. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  69511. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  69512. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  69513. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  69514. * @param name defines the name of the mesh
  69515. * @param options defines the options used to create the mesh
  69516. * @param scene defines the hosting scene
  69517. * @returns the custom extruded shape mesh
  69518. * @see https://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  69519. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  69520. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  69521. */
  69522. static ExtrudeShapeCustom(name: string, options: {
  69523. shape: Vector3[];
  69524. path: Vector3[];
  69525. scaleFunction?: any;
  69526. rotationFunction?: any;
  69527. ribbonCloseArray?: boolean;
  69528. ribbonClosePath?: boolean;
  69529. cap?: number;
  69530. updatable?: boolean;
  69531. sideOrientation?: number;
  69532. frontUVs?: Vector4;
  69533. backUVs?: Vector4;
  69534. instance?: Mesh;
  69535. invertUV?: boolean;
  69536. }, scene?: Nullable<Scene>): Mesh;
  69537. /**
  69538. * Creates lathe mesh.
  69539. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe
  69540. * * 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
  69541. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  69542. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  69543. * * The parameter `clip` (positive integer, default 0) is the number of sides to not create without effecting the general shape of the sides
  69544. * * 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
  69545. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  69546. * * 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
  69547. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  69548. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  69549. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  69550. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  69551. * @param name defines the name of the mesh
  69552. * @param options defines the options used to create the mesh
  69553. * @param scene defines the hosting scene
  69554. * @returns the lathe mesh
  69555. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lathe
  69556. */
  69557. static CreateLathe(name: string, options: {
  69558. shape: Vector3[];
  69559. radius?: number;
  69560. tessellation?: number;
  69561. clip?: number;
  69562. arc?: number;
  69563. closed?: boolean;
  69564. updatable?: boolean;
  69565. sideOrientation?: number;
  69566. frontUVs?: Vector4;
  69567. backUVs?: Vector4;
  69568. cap?: number;
  69569. invertUV?: boolean;
  69570. }, scene?: Nullable<Scene>): Mesh;
  69571. /**
  69572. * Creates a tiled plane mesh
  69573. * * You can set a limited pattern arrangement with the tiles
  69574. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  69575. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  69576. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  69577. * @param name defines the name of the mesh
  69578. * @param options defines the options used to create the mesh
  69579. * @param scene defines the hosting scene
  69580. * @returns the plane mesh
  69581. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  69582. */
  69583. static CreateTiledPlane(name: string, options: {
  69584. pattern?: number;
  69585. tileSize?: number;
  69586. tileWidth?: number;
  69587. tileHeight?: number;
  69588. size?: number;
  69589. width?: number;
  69590. height?: number;
  69591. alignHorizontal?: number;
  69592. alignVertical?: number;
  69593. sideOrientation?: number;
  69594. frontUVs?: Vector4;
  69595. backUVs?: Vector4;
  69596. updatable?: boolean;
  69597. }, scene?: Nullable<Scene>): Mesh;
  69598. /**
  69599. * Creates a plane mesh
  69600. * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
  69601. * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value of `size`)
  69602. * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane
  69603. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  69604. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  69605. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  69606. * @param name defines the name of the mesh
  69607. * @param options defines the options used to create the mesh
  69608. * @param scene defines the hosting scene
  69609. * @returns the plane mesh
  69610. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  69611. */
  69612. static CreatePlane(name: string, options: {
  69613. size?: number;
  69614. width?: number;
  69615. height?: number;
  69616. sideOrientation?: number;
  69617. frontUVs?: Vector4;
  69618. backUVs?: Vector4;
  69619. updatable?: boolean;
  69620. sourcePlane?: Plane;
  69621. }, scene?: Nullable<Scene>): Mesh;
  69622. /**
  69623. * Creates a ground mesh
  69624. * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
  69625. * * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side
  69626. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  69627. * @param name defines the name of the mesh
  69628. * @param options defines the options used to create the mesh
  69629. * @param scene defines the hosting scene
  69630. * @returns the ground mesh
  69631. * @see https://doc.babylonjs.com/how_to/set_shapes#ground
  69632. */
  69633. static CreateGround(name: string, options: {
  69634. width?: number;
  69635. height?: number;
  69636. subdivisions?: number;
  69637. subdivisionsX?: number;
  69638. subdivisionsY?: number;
  69639. updatable?: boolean;
  69640. }, scene?: Nullable<Scene>): Mesh;
  69641. /**
  69642. * Creates a tiled ground mesh
  69643. * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
  69644. * * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates
  69645. * * 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
  69646. * * 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
  69647. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  69648. * @param name defines the name of the mesh
  69649. * @param options defines the options used to create the mesh
  69650. * @param scene defines the hosting scene
  69651. * @returns the tiled ground mesh
  69652. * @see https://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  69653. */
  69654. static CreateTiledGround(name: string, options: {
  69655. xmin: number;
  69656. zmin: number;
  69657. xmax: number;
  69658. zmax: number;
  69659. subdivisions?: {
  69660. w: number;
  69661. h: number;
  69662. };
  69663. precision?: {
  69664. w: number;
  69665. h: number;
  69666. };
  69667. updatable?: boolean;
  69668. }, scene?: Nullable<Scene>): Mesh;
  69669. /**
  69670. * Creates a ground mesh from a height map
  69671. * * The parameter `url` sets the URL of the height map image resource.
  69672. * * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  69673. * * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  69674. * * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  69675. * * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  69676. * * 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.
  69677. * * 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).
  69678. * * The parameter `alphaFilter` will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  69679. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  69680. * @param name defines the name of the mesh
  69681. * @param url defines the url to the height map
  69682. * @param options defines the options used to create the mesh
  69683. * @param scene defines the hosting scene
  69684. * @returns the ground mesh
  69685. * @see https://doc.babylonjs.com/babylon101/height_map
  69686. * @see https://doc.babylonjs.com/how_to/set_shapes#ground-from-a-height-map
  69687. */
  69688. static CreateGroundFromHeightMap(name: string, url: string, options: {
  69689. width?: number;
  69690. height?: number;
  69691. subdivisions?: number;
  69692. minHeight?: number;
  69693. maxHeight?: number;
  69694. colorFilter?: Color3;
  69695. alphaFilter?: number;
  69696. updatable?: boolean;
  69697. onReady?: (mesh: GroundMesh) => void;
  69698. }, scene?: Nullable<Scene>): GroundMesh;
  69699. /**
  69700. * Creates a polygon mesh
  69701. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  69702. * * 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
  69703. * * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  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. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4)
  69706. * * Remember you can only change the shape positions, not their number when updating a polygon
  69707. * @param name defines the name of the mesh
  69708. * @param options defines the options used to create the mesh
  69709. * @param scene defines the hosting scene
  69710. * @param earcutInjection can be used to inject your own earcut reference
  69711. * @returns the polygon mesh
  69712. */
  69713. static CreatePolygon(name: string, options: {
  69714. shape: Vector3[];
  69715. holes?: Vector3[][];
  69716. depth?: number;
  69717. faceUV?: Vector4[];
  69718. faceColors?: Color4[];
  69719. updatable?: boolean;
  69720. sideOrientation?: number;
  69721. frontUVs?: Vector4;
  69722. backUVs?: Vector4;
  69723. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  69724. /**
  69725. * Creates an extruded polygon mesh, with depth in the Y direction.
  69726. * * 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)
  69727. * @see https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  69728. * @param name defines the name of the mesh
  69729. * @param options defines the options used to create the mesh
  69730. * @param scene defines the hosting scene
  69731. * @param earcutInjection can be used to inject your own earcut reference
  69732. * @returns the polygon mesh
  69733. */
  69734. static ExtrudePolygon(name: string, options: {
  69735. shape: Vector3[];
  69736. holes?: Vector3[][];
  69737. depth?: number;
  69738. faceUV?: Vector4[];
  69739. faceColors?: Color4[];
  69740. updatable?: boolean;
  69741. sideOrientation?: number;
  69742. frontUVs?: Vector4;
  69743. backUVs?: Vector4;
  69744. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  69745. /**
  69746. * Creates a tube mesh.
  69747. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  69748. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  69749. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  69750. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  69751. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`
  69752. * * 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)
  69753. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  69754. * * 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
  69755. * * 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
  69756. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  69757. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  69758. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  69759. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  69760. * @param name defines the name of the mesh
  69761. * @param options defines the options used to create the mesh
  69762. * @param scene defines the hosting scene
  69763. * @returns the tube mesh
  69764. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  69765. * @see https://doc.babylonjs.com/how_to/set_shapes#tube
  69766. */
  69767. static CreateTube(name: string, options: {
  69768. path: Vector3[];
  69769. radius?: number;
  69770. tessellation?: number;
  69771. radiusFunction?: {
  69772. (i: number, distance: number): number;
  69773. };
  69774. cap?: number;
  69775. arc?: number;
  69776. updatable?: boolean;
  69777. sideOrientation?: number;
  69778. frontUVs?: Vector4;
  69779. backUVs?: Vector4;
  69780. instance?: Mesh;
  69781. invertUV?: boolean;
  69782. }, scene?: Nullable<Scene>): Mesh;
  69783. /**
  69784. * Creates a polyhedron mesh
  69785. * * 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
  69786. * * The parameter `size` (positive float, default 1) sets the polygon size
  69787. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  69788. * * 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`
  69789. * * 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
  69790. * * 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)`)
  69791. * * 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
  69792. * * 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
  69793. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  69794. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  69795. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  69796. * @param name defines the name of the mesh
  69797. * @param options defines the options used to create the mesh
  69798. * @param scene defines the hosting scene
  69799. * @returns the polyhedron mesh
  69800. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes
  69801. */
  69802. static CreatePolyhedron(name: string, options: {
  69803. type?: number;
  69804. size?: number;
  69805. sizeX?: number;
  69806. sizeY?: number;
  69807. sizeZ?: number;
  69808. custom?: any;
  69809. faceUV?: Vector4[];
  69810. faceColors?: Color4[];
  69811. flat?: boolean;
  69812. updatable?: boolean;
  69813. sideOrientation?: number;
  69814. frontUVs?: Vector4;
  69815. backUVs?: Vector4;
  69816. }, scene?: Nullable<Scene>): Mesh;
  69817. /**
  69818. * Creates a decal mesh.
  69819. * 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
  69820. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  69821. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  69822. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  69823. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  69824. * @param name defines the name of the mesh
  69825. * @param sourceMesh defines the mesh where the decal must be applied
  69826. * @param options defines the options used to create the mesh
  69827. * @param scene defines the hosting scene
  69828. * @returns the decal mesh
  69829. * @see https://doc.babylonjs.com/how_to/decals
  69830. */
  69831. static CreateDecal(name: string, sourceMesh: AbstractMesh, options: {
  69832. position?: Vector3;
  69833. normal?: Vector3;
  69834. size?: Vector3;
  69835. angle?: number;
  69836. }): Mesh;
  69837. }
  69838. }
  69839. declare module "babylonjs/Meshes/meshSimplification" {
  69840. import { Mesh } from "babylonjs/Meshes/mesh";
  69841. /**
  69842. * A simplifier interface for future simplification implementations
  69843. * @see https://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  69844. */
  69845. export interface ISimplifier {
  69846. /**
  69847. * Simplification of a given mesh according to the given settings.
  69848. * Since this requires computation, it is assumed that the function runs async.
  69849. * @param settings The settings of the simplification, including quality and distance
  69850. * @param successCallback A callback that will be called after the mesh was simplified.
  69851. * @param errorCallback in case of an error, this callback will be called. optional.
  69852. */
  69853. simplify(settings: ISimplificationSettings, successCallback: (simplifiedMeshes: Mesh) => void, errorCallback?: () => void): void;
  69854. }
  69855. /**
  69856. * Expected simplification settings.
  69857. * Quality should be between 0 and 1 (1 being 100%, 0 being 0%)
  69858. * @see https://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  69859. */
  69860. export interface ISimplificationSettings {
  69861. /**
  69862. * Gets or sets the expected quality
  69863. */
  69864. quality: number;
  69865. /**
  69866. * Gets or sets the distance when this optimized version should be used
  69867. */
  69868. distance: number;
  69869. /**
  69870. * Gets an already optimized mesh
  69871. */
  69872. optimizeMesh?: boolean;
  69873. }
  69874. /**
  69875. * Class used to specify simplification options
  69876. * @see https://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  69877. */
  69878. export class SimplificationSettings implements ISimplificationSettings {
  69879. /** expected quality */
  69880. quality: number;
  69881. /** distance when this optimized version should be used */
  69882. distance: number;
  69883. /** already optimized mesh */
  69884. optimizeMesh?: boolean | undefined;
  69885. /**
  69886. * Creates a SimplificationSettings
  69887. * @param quality expected quality
  69888. * @param distance distance when this optimized version should be used
  69889. * @param optimizeMesh already optimized mesh
  69890. */
  69891. constructor(
  69892. /** expected quality */
  69893. quality: number,
  69894. /** distance when this optimized version should be used */
  69895. distance: number,
  69896. /** already optimized mesh */
  69897. optimizeMesh?: boolean | undefined);
  69898. }
  69899. /**
  69900. * Interface used to define a simplification task
  69901. */
  69902. export interface ISimplificationTask {
  69903. /**
  69904. * Array of settings
  69905. */
  69906. settings: Array<ISimplificationSettings>;
  69907. /**
  69908. * Simplification type
  69909. */
  69910. simplificationType: SimplificationType;
  69911. /**
  69912. * Mesh to simplify
  69913. */
  69914. mesh: Mesh;
  69915. /**
  69916. * Callback called on success
  69917. */
  69918. successCallback?: () => void;
  69919. /**
  69920. * Defines if parallel processing can be used
  69921. */
  69922. parallelProcessing: boolean;
  69923. }
  69924. /**
  69925. * Queue used to order the simplification tasks
  69926. * @see https://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  69927. */
  69928. export class SimplificationQueue {
  69929. private _simplificationArray;
  69930. /**
  69931. * Gets a boolean indicating that the process is still running
  69932. */
  69933. running: boolean;
  69934. /**
  69935. * Creates a new queue
  69936. */
  69937. constructor();
  69938. /**
  69939. * Adds a new simplification task
  69940. * @param task defines a task to add
  69941. */
  69942. addTask(task: ISimplificationTask): void;
  69943. /**
  69944. * Execute next task
  69945. */
  69946. executeNext(): void;
  69947. /**
  69948. * Execute a simplification task
  69949. * @param task defines the task to run
  69950. */
  69951. runSimplification(task: ISimplificationTask): void;
  69952. private getSimplifier;
  69953. }
  69954. /**
  69955. * The implemented types of simplification
  69956. * At the moment only Quadratic Error Decimation is implemented
  69957. * @see https://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  69958. */
  69959. export enum SimplificationType {
  69960. /** Quadratic error decimation */
  69961. QUADRATIC = 0
  69962. }
  69963. /**
  69964. * An implementation of the Quadratic Error simplification algorithm.
  69965. * Original paper : http://www1.cs.columbia.edu/~cs4162/html05s/garland97.pdf
  69966. * Ported mostly from QSlim and http://voxels.blogspot.de/2014/05/quadric-mesh-simplification-with-source.html to babylon JS
  69967. * @author RaananW
  69968. * @see https://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  69969. */
  69970. export class QuadraticErrorSimplification implements ISimplifier {
  69971. private _mesh;
  69972. private triangles;
  69973. private vertices;
  69974. private references;
  69975. private _reconstructedMesh;
  69976. /** Gets or sets the number pf sync interations */
  69977. syncIterations: number;
  69978. /** Gets or sets the aggressiveness of the simplifier */
  69979. aggressiveness: number;
  69980. /** Gets or sets the number of allowed iterations for decimation */
  69981. decimationIterations: number;
  69982. /** Gets or sets the espilon to use for bounding box computation */
  69983. boundingBoxEpsilon: number;
  69984. /**
  69985. * Creates a new QuadraticErrorSimplification
  69986. * @param _mesh defines the target mesh
  69987. */
  69988. constructor(_mesh: Mesh);
  69989. /**
  69990. * Simplification of a given mesh according to the given settings.
  69991. * Since this requires computation, it is assumed that the function runs async.
  69992. * @param settings The settings of the simplification, including quality and distance
  69993. * @param successCallback A callback that will be called after the mesh was simplified.
  69994. */
  69995. simplify(settings: ISimplificationSettings, successCallback: (simplifiedMesh: Mesh) => void): void;
  69996. private runDecimation;
  69997. private initWithMesh;
  69998. private init;
  69999. private reconstructMesh;
  70000. private initDecimatedMesh;
  70001. private isFlipped;
  70002. private updateTriangles;
  70003. private identifyBorder;
  70004. private updateMesh;
  70005. private vertexError;
  70006. private calculateError;
  70007. }
  70008. }
  70009. declare module "babylonjs/Meshes/meshSimplificationSceneComponent" {
  70010. import { Scene } from "babylonjs/scene";
  70011. import { SimplificationQueue, ISimplificationSettings, SimplificationType } from "babylonjs/Meshes/meshSimplification";
  70012. import { ISceneComponent } from "babylonjs/sceneComponent";
  70013. module "babylonjs/scene" {
  70014. interface Scene {
  70015. /** @hidden (Backing field) */
  70016. _simplificationQueue: SimplificationQueue;
  70017. /**
  70018. * Gets or sets the simplification queue attached to the scene
  70019. * @see https://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  70020. */
  70021. simplificationQueue: SimplificationQueue;
  70022. }
  70023. }
  70024. module "babylonjs/Meshes/mesh" {
  70025. interface Mesh {
  70026. /**
  70027. * Simplify the mesh according to the given array of settings.
  70028. * Function will return immediately and will simplify async
  70029. * @param settings a collection of simplification settings
  70030. * @param parallelProcessing should all levels calculate parallel or one after the other
  70031. * @param simplificationType the type of simplification to run
  70032. * @param successCallback optional success callback to be called after the simplification finished processing all settings
  70033. * @returns the current mesh
  70034. */
  70035. simplify(settings: Array<ISimplificationSettings>, parallelProcessing?: boolean, simplificationType?: SimplificationType, successCallback?: (mesh?: Mesh, submeshIndex?: number) => void): Mesh;
  70036. }
  70037. }
  70038. /**
  70039. * Defines the simplification queue scene component responsible to help scheduling the various simplification task
  70040. * created in a scene
  70041. */
  70042. export class SimplicationQueueSceneComponent implements ISceneComponent {
  70043. /**
  70044. * The component name helpfull to identify the component in the list of scene components.
  70045. */
  70046. readonly name: string;
  70047. /**
  70048. * The scene the component belongs to.
  70049. */
  70050. scene: Scene;
  70051. /**
  70052. * Creates a new instance of the component for the given scene
  70053. * @param scene Defines the scene to register the component in
  70054. */
  70055. constructor(scene: Scene);
  70056. /**
  70057. * Registers the component in a given scene
  70058. */
  70059. register(): void;
  70060. /**
  70061. * Rebuilds the elements related to this component in case of
  70062. * context lost for instance.
  70063. */
  70064. rebuild(): void;
  70065. /**
  70066. * Disposes the component and the associated ressources
  70067. */
  70068. dispose(): void;
  70069. private _beforeCameraUpdate;
  70070. }
  70071. }
  70072. declare module "babylonjs/Meshes/Builders/index" {
  70073. export * from "babylonjs/Meshes/Builders/boxBuilder";
  70074. export * from "babylonjs/Meshes/Builders/tiledBoxBuilder";
  70075. export * from "babylonjs/Meshes/Builders/discBuilder";
  70076. export * from "babylonjs/Meshes/Builders/ribbonBuilder";
  70077. export * from "babylonjs/Meshes/Builders/sphereBuilder";
  70078. export * from "babylonjs/Meshes/Builders/hemisphereBuilder";
  70079. export * from "babylonjs/Meshes/Builders/cylinderBuilder";
  70080. export * from "babylonjs/Meshes/Builders/torusBuilder";
  70081. export * from "babylonjs/Meshes/Builders/torusKnotBuilder";
  70082. export * from "babylonjs/Meshes/Builders/linesBuilder";
  70083. export * from "babylonjs/Meshes/Builders/polygonBuilder";
  70084. export * from "babylonjs/Meshes/Builders/shapeBuilder";
  70085. export * from "babylonjs/Meshes/Builders/latheBuilder";
  70086. export * from "babylonjs/Meshes/Builders/planeBuilder";
  70087. export * from "babylonjs/Meshes/Builders/tiledPlaneBuilder";
  70088. export * from "babylonjs/Meshes/Builders/groundBuilder";
  70089. export * from "babylonjs/Meshes/Builders/tubeBuilder";
  70090. export * from "babylonjs/Meshes/Builders/polyhedronBuilder";
  70091. export * from "babylonjs/Meshes/Builders/icoSphereBuilder";
  70092. export * from "babylonjs/Meshes/Builders/decalBuilder";
  70093. }
  70094. declare module "babylonjs/Meshes/thinInstanceMesh" {
  70095. import { Nullable, DeepImmutableObject } from "babylonjs/types";
  70096. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  70097. import { Matrix } from "babylonjs/Maths/math.vector";
  70098. module "babylonjs/Meshes/mesh" {
  70099. interface Mesh {
  70100. /**
  70101. * Gets or sets a boolean defining if we want picking to pick thin instances as well
  70102. */
  70103. thinInstanceEnablePicking: boolean;
  70104. /**
  70105. * Creates a new thin instance
  70106. * @param matrix the matrix or array of matrices (position, rotation, scale) of the thin instance(s) to create
  70107. * @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
  70108. * @returns the thin instance index number. If you pass an array of matrices, other instance indexes are index+1, index+2, etc
  70109. */
  70110. thinInstanceAdd(matrix: DeepImmutableObject<Matrix> | Array<DeepImmutableObject<Matrix>>, refresh: boolean): number;
  70111. /**
  70112. * Adds the transformation (matrix) of the current mesh as a thin instance
  70113. * @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
  70114. * @returns the thin instance index number
  70115. */
  70116. thinInstanceAddSelf(refresh: boolean): number;
  70117. /**
  70118. * Registers a custom attribute to be used with thin instances
  70119. * @param kind name of the attribute
  70120. * @param stride size in floats of the attribute
  70121. */
  70122. thinInstanceRegisterAttribute(kind: string, stride: number): void;
  70123. /**
  70124. * Sets the matrix of a thin instance
  70125. * @param index index of the thin instance
  70126. * @param matrix matrix to set
  70127. * @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
  70128. */
  70129. thinInstanceSetMatrixAt(index: number, matrix: DeepImmutableObject<Matrix>, refresh: boolean): void;
  70130. /**
  70131. * Sets the value of a custom attribute for a thin instance
  70132. * @param kind name of the attribute
  70133. * @param index index of the thin instance
  70134. * @param value value to set
  70135. * @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
  70136. */
  70137. thinInstanceSetAttributeAt(kind: string, index: number, value: Array<number>, refresh: boolean): void;
  70138. /**
  70139. * 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.
  70140. */
  70141. thinInstanceCount: number;
  70142. /**
  70143. * Sets a buffer to be used with thin instances. This method is a faster way to setup multiple instances than calling thinInstanceAdd repeatedly
  70144. * @param kind name of the attribute. Use "matrix" to setup the buffer of matrices
  70145. * @param buffer buffer to set
  70146. * @param stride size in floats of each value of the buffer
  70147. * @param staticBuffer indicates that the buffer is static, so that you won't change it after it is set (better performances - false by default)
  70148. */
  70149. thinInstanceSetBuffer(kind: string, buffer: Nullable<Float32Array>, stride: number, staticBuffer: boolean): void;
  70150. /**
  70151. * Gets the list of world matrices
  70152. * @return an array containing all the world matrices from the thin instances
  70153. */
  70154. thinInstanceGetWorldMatrices(): Matrix[];
  70155. /**
  70156. * Synchronize the gpu buffers with a thin instance buffer. Call this method if you update later on the buffers passed to thinInstanceSetBuffer
  70157. * @param kind name of the attribute to update. Use "matrix" to update the buffer of matrices
  70158. */
  70159. thinInstanceBufferUpdated(kind: string): void;
  70160. /**
  70161. * Applies a partial update to a buffer directly on the GPU
  70162. * 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
  70163. * @param kind name of the attribute to update. Use "matrix" to update the buffer of matrices
  70164. * @param data the data to set in the GPU buffer
  70165. * @param offset the offset in the GPU buffer where to update the data
  70166. */
  70167. thinInstancePartialBufferUpdate(kind: string, data: Float32Array, offset: number): void;
  70168. /**
  70169. * Refreshes the bounding info, taking into account all the thin instances defined
  70170. * @param forceRefreshParentInfo true to force recomputing the mesh bounding info and use it to compute the aggregated bounding info
  70171. */
  70172. thinInstanceRefreshBoundingInfo(forceRefreshParentInfo: boolean): void;
  70173. /** @hidden */
  70174. _thinInstanceInitializeUserStorage(): void;
  70175. /** @hidden */
  70176. _thinInstanceUpdateBufferSize(kind: string, numInstances: number): void;
  70177. /** @hidden */
  70178. _userThinInstanceBuffersStorage: {
  70179. data: {
  70180. [key: string]: Float32Array;
  70181. };
  70182. sizes: {
  70183. [key: string]: number;
  70184. };
  70185. vertexBuffers: {
  70186. [key: string]: Nullable<VertexBuffer>;
  70187. };
  70188. strides: {
  70189. [key: string]: number;
  70190. };
  70191. };
  70192. }
  70193. }
  70194. }
  70195. declare module "babylonjs/Meshes/index" {
  70196. export * from "babylonjs/Meshes/abstractMesh";
  70197. export * from "babylonjs/Meshes/buffer";
  70198. export * from "babylonjs/Meshes/Compression/index";
  70199. export * from "babylonjs/Meshes/csg";
  70200. export * from "babylonjs/Meshes/geometry";
  70201. export * from "babylonjs/Meshes/groundMesh";
  70202. export * from "babylonjs/Meshes/trailMesh";
  70203. export * from "babylonjs/Meshes/instancedMesh";
  70204. export * from "babylonjs/Meshes/linesMesh";
  70205. export * from "babylonjs/Meshes/mesh";
  70206. export * from "babylonjs/Meshes/mesh.vertexData";
  70207. export * from "babylonjs/Meshes/meshBuilder";
  70208. export * from "babylonjs/Meshes/meshSimplification";
  70209. export * from "babylonjs/Meshes/meshSimplificationSceneComponent";
  70210. export * from "babylonjs/Meshes/polygonMesh";
  70211. export * from "babylonjs/Meshes/subMesh";
  70212. export * from "babylonjs/Meshes/meshLODLevel";
  70213. export * from "babylonjs/Meshes/transformNode";
  70214. export * from "babylonjs/Meshes/Builders/index";
  70215. export * from "babylonjs/Meshes/dataBuffer";
  70216. export * from "babylonjs/Meshes/WebGL/webGLDataBuffer";
  70217. import "babylonjs/Meshes/thinInstanceMesh";
  70218. export * from "babylonjs/Meshes/thinInstanceMesh";
  70219. }
  70220. declare module "babylonjs/Morph/index" {
  70221. export * from "babylonjs/Morph/morphTarget";
  70222. export * from "babylonjs/Morph/morphTargetManager";
  70223. }
  70224. declare module "babylonjs/Navigation/INavigationEngine" {
  70225. import { TransformNode } from "babylonjs/Meshes/transformNode";
  70226. import { Vector3 } from "babylonjs/Maths/math";
  70227. import { Mesh } from "babylonjs/Meshes/mesh";
  70228. import { Scene } from "babylonjs/scene";
  70229. /**
  70230. * Navigation plugin interface to add navigation constrained by a navigation mesh
  70231. */
  70232. export interface INavigationEnginePlugin {
  70233. /**
  70234. * plugin name
  70235. */
  70236. name: string;
  70237. /**
  70238. * Creates a navigation mesh
  70239. * @param meshes array of all the geometry used to compute the navigatio mesh
  70240. * @param parameters bunch of parameters used to filter geometry
  70241. */
  70242. createNavMesh(meshes: Array<Mesh>, parameters: INavMeshParameters): void;
  70243. /**
  70244. * Create a navigation mesh debug mesh
  70245. * @param scene is where the mesh will be added
  70246. * @returns debug display mesh
  70247. */
  70248. createDebugNavMesh(scene: Scene): Mesh;
  70249. /**
  70250. * Get a navigation mesh constrained position, closest to the parameter position
  70251. * @param position world position
  70252. * @returns the closest point to position constrained by the navigation mesh
  70253. */
  70254. getClosestPoint(position: Vector3): Vector3;
  70255. /**
  70256. * Get a navigation mesh constrained position, closest to the parameter position
  70257. * @param position world position
  70258. * @param result output the closest point to position constrained by the navigation mesh
  70259. */
  70260. getClosestPointToRef(position: Vector3, result: Vector3): void;
  70261. /**
  70262. * Get a navigation mesh constrained position, within a particular radius
  70263. * @param position world position
  70264. * @param maxRadius the maximum distance to the constrained world position
  70265. * @returns the closest point to position constrained by the navigation mesh
  70266. */
  70267. getRandomPointAround(position: Vector3, maxRadius: number): Vector3;
  70268. /**
  70269. * Get a navigation mesh constrained position, within a particular radius
  70270. * @param position world position
  70271. * @param maxRadius the maximum distance to the constrained world position
  70272. * @param result output the closest point to position constrained by the navigation mesh
  70273. */
  70274. getRandomPointAroundToRef(position: Vector3, maxRadius: number, result: Vector3): void;
  70275. /**
  70276. * Compute the final position from a segment made of destination-position
  70277. * @param position world position
  70278. * @param destination world position
  70279. * @returns the resulting point along the navmesh
  70280. */
  70281. moveAlong(position: Vector3, destination: Vector3): Vector3;
  70282. /**
  70283. * Compute the final position from a segment made of destination-position
  70284. * @param position world position
  70285. * @param destination world position
  70286. * @param result output the resulting point along the navmesh
  70287. */
  70288. moveAlongToRef(position: Vector3, destination: Vector3, result: Vector3): void;
  70289. /**
  70290. * Compute a navigation path from start to end. Returns an empty array if no path can be computed
  70291. * @param start world position
  70292. * @param end world position
  70293. * @returns array containing world position composing the path
  70294. */
  70295. computePath(start: Vector3, end: Vector3): Vector3[];
  70296. /**
  70297. * If this plugin is supported
  70298. * @returns true if plugin is supported
  70299. */
  70300. isSupported(): boolean;
  70301. /**
  70302. * Create a new Crowd so you can add agents
  70303. * @param maxAgents the maximum agent count in the crowd
  70304. * @param maxAgentRadius the maximum radius an agent can have
  70305. * @param scene to attach the crowd to
  70306. * @returns the crowd you can add agents to
  70307. */
  70308. createCrowd(maxAgents: number, maxAgentRadius: number, scene: Scene): ICrowd;
  70309. /**
  70310. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  70311. * The queries will try to find a solution within those bounds
  70312. * default is (1,1,1)
  70313. * @param extent x,y,z value that define the extent around the queries point of reference
  70314. */
  70315. setDefaultQueryExtent(extent: Vector3): void;
  70316. /**
  70317. * Get the Bounding box extent specified by setDefaultQueryExtent
  70318. * @returns the box extent values
  70319. */
  70320. getDefaultQueryExtent(): Vector3;
  70321. /**
  70322. * build the navmesh from a previously saved state using getNavmeshData
  70323. * @param data the Uint8Array returned by getNavmeshData
  70324. */
  70325. buildFromNavmeshData(data: Uint8Array): void;
  70326. /**
  70327. * returns the navmesh data that can be used later. The navmesh must be built before retrieving the data
  70328. * @returns data the Uint8Array that can be saved and reused
  70329. */
  70330. getNavmeshData(): Uint8Array;
  70331. /**
  70332. * Get the Bounding box extent result specified by setDefaultQueryExtent
  70333. * @param result output the box extent values
  70334. */
  70335. getDefaultQueryExtentToRef(result: Vector3): void;
  70336. /**
  70337. * Release all resources
  70338. */
  70339. dispose(): void;
  70340. }
  70341. /**
  70342. * Crowd Interface. A Crowd is a collection of moving agents constrained by a navigation mesh
  70343. */
  70344. export interface ICrowd {
  70345. /**
  70346. * Add a new agent to the crowd with the specified parameter a corresponding transformNode.
  70347. * You can attach anything to that node. The node position is updated in the scene update tick.
  70348. * @param pos world position that will be constrained by the navigation mesh
  70349. * @param parameters agent parameters
  70350. * @param transform hooked to the agent that will be update by the scene
  70351. * @returns agent index
  70352. */
  70353. addAgent(pos: Vector3, parameters: IAgentParameters, transform: TransformNode): number;
  70354. /**
  70355. * Returns the agent position in world space
  70356. * @param index agent index returned by addAgent
  70357. * @returns world space position
  70358. */
  70359. getAgentPosition(index: number): Vector3;
  70360. /**
  70361. * Gets the agent position result in world space
  70362. * @param index agent index returned by addAgent
  70363. * @param result output world space position
  70364. */
  70365. getAgentPositionToRef(index: number, result: Vector3): void;
  70366. /**
  70367. * Gets the agent velocity in world space
  70368. * @param index agent index returned by addAgent
  70369. * @returns world space velocity
  70370. */
  70371. getAgentVelocity(index: number): Vector3;
  70372. /**
  70373. * Gets the agent velocity result in world space
  70374. * @param index agent index returned by addAgent
  70375. * @param result output world space velocity
  70376. */
  70377. getAgentVelocityToRef(index: number, result: Vector3): void;
  70378. /**
  70379. * remove a particular agent previously created
  70380. * @param index agent index returned by addAgent
  70381. */
  70382. removeAgent(index: number): void;
  70383. /**
  70384. * get the list of all agents attached to this crowd
  70385. * @returns list of agent indices
  70386. */
  70387. getAgents(): number[];
  70388. /**
  70389. * Tick update done by the Scene. Agent position/velocity/acceleration is updated by this function
  70390. * @param deltaTime in seconds
  70391. */
  70392. update(deltaTime: number): void;
  70393. /**
  70394. * Asks a particular agent to go to a destination. That destination is constrained by the navigation mesh
  70395. * @param index agent index returned by addAgent
  70396. * @param destination targeted world position
  70397. */
  70398. agentGoto(index: number, destination: Vector3): void;
  70399. /**
  70400. * Teleport the agent to a new position
  70401. * @param index agent index returned by addAgent
  70402. * @param destination targeted world position
  70403. */
  70404. agentTeleport(index: number, destination: Vector3): void;
  70405. /**
  70406. * Update agent parameters
  70407. * @param index agent index returned by addAgent
  70408. * @param parameters agent parameters
  70409. */
  70410. updateAgentParameters(index: number, parameters: IAgentParameters): void;
  70411. /**
  70412. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  70413. * The queries will try to find a solution within those bounds
  70414. * default is (1,1,1)
  70415. * @param extent x,y,z value that define the extent around the queries point of reference
  70416. */
  70417. setDefaultQueryExtent(extent: Vector3): void;
  70418. /**
  70419. * Get the Bounding box extent specified by setDefaultQueryExtent
  70420. * @returns the box extent values
  70421. */
  70422. getDefaultQueryExtent(): Vector3;
  70423. /**
  70424. * Get the Bounding box extent result specified by setDefaultQueryExtent
  70425. * @param result output the box extent values
  70426. */
  70427. getDefaultQueryExtentToRef(result: Vector3): void;
  70428. /**
  70429. * Release all resources
  70430. */
  70431. dispose(): void;
  70432. }
  70433. /**
  70434. * Configures an agent
  70435. */
  70436. export interface IAgentParameters {
  70437. /**
  70438. * Agent radius. [Limit: >= 0]
  70439. */
  70440. radius: number;
  70441. /**
  70442. * Agent height. [Limit: > 0]
  70443. */
  70444. height: number;
  70445. /**
  70446. * Maximum allowed acceleration. [Limit: >= 0]
  70447. */
  70448. maxAcceleration: number;
  70449. /**
  70450. * Maximum allowed speed. [Limit: >= 0]
  70451. */
  70452. maxSpeed: number;
  70453. /**
  70454. * Defines how close a collision element must be before it is considered for steering behaviors. [Limits: > 0]
  70455. */
  70456. collisionQueryRange: number;
  70457. /**
  70458. * The path visibility optimization range. [Limit: > 0]
  70459. */
  70460. pathOptimizationRange: number;
  70461. /**
  70462. * How aggresive the agent manager should be at avoiding collisions with this agent. [Limit: >= 0]
  70463. */
  70464. separationWeight: number;
  70465. }
  70466. /**
  70467. * Configures the navigation mesh creation
  70468. */
  70469. export interface INavMeshParameters {
  70470. /**
  70471. * The xz-plane cell size to use for fields. [Limit: > 0] [Units: wu]
  70472. */
  70473. cs: number;
  70474. /**
  70475. * The y-axis cell size to use for fields. [Limit: > 0] [Units: wu]
  70476. */
  70477. ch: number;
  70478. /**
  70479. * The maximum slope that is considered walkable. [Limits: 0 <= value < 90] [Units: Degrees]
  70480. */
  70481. walkableSlopeAngle: number;
  70482. /**
  70483. * Minimum floor to 'ceiling' height that will still allow the floor area to
  70484. * be considered walkable. [Limit: >= 3] [Units: vx]
  70485. */
  70486. walkableHeight: number;
  70487. /**
  70488. * Maximum ledge height that is considered to still be traversable. [Limit: >=0] [Units: vx]
  70489. */
  70490. walkableClimb: number;
  70491. /**
  70492. * The distance to erode/shrink the walkable area of the heightfield away from
  70493. * obstructions. [Limit: >=0] [Units: vx]
  70494. */
  70495. walkableRadius: number;
  70496. /**
  70497. * The maximum allowed length for contour edges along the border of the mesh. [Limit: >=0] [Units: vx]
  70498. */
  70499. maxEdgeLen: number;
  70500. /**
  70501. * The maximum distance a simplfied contour's border edges should deviate
  70502. * the original raw contour. [Limit: >=0] [Units: vx]
  70503. */
  70504. maxSimplificationError: number;
  70505. /**
  70506. * The minimum number of cells allowed to form isolated island areas. [Limit: >=0] [Units: vx]
  70507. */
  70508. minRegionArea: number;
  70509. /**
  70510. * Any regions with a span count smaller than this value will, if possible,
  70511. * be merged with larger regions. [Limit: >=0] [Units: vx]
  70512. */
  70513. mergeRegionArea: number;
  70514. /**
  70515. * The maximum number of vertices allowed for polygons generated during the
  70516. * contour to polygon conversion process. [Limit: >= 3]
  70517. */
  70518. maxVertsPerPoly: number;
  70519. /**
  70520. * Sets the sampling distance to use when generating the detail mesh.
  70521. * (For height detail only.) [Limits: 0 or >= 0.9] [Units: wu]
  70522. */
  70523. detailSampleDist: number;
  70524. /**
  70525. * The maximum distance the detail mesh surface should deviate from heightfield
  70526. * data. (For height detail only.) [Limit: >=0] [Units: wu]
  70527. */
  70528. detailSampleMaxError: number;
  70529. }
  70530. }
  70531. declare module "babylonjs/Navigation/Plugins/recastJSPlugin" {
  70532. import { INavigationEnginePlugin, ICrowd, IAgentParameters, INavMeshParameters } from "babylonjs/Navigation/INavigationEngine";
  70533. import { Mesh } from "babylonjs/Meshes/mesh";
  70534. import { Scene } from "babylonjs/scene";
  70535. import { Vector3 } from "babylonjs/Maths/math";
  70536. import { TransformNode } from "babylonjs/Meshes/transformNode";
  70537. /**
  70538. * RecastJS navigation plugin
  70539. */
  70540. export class RecastJSPlugin implements INavigationEnginePlugin {
  70541. /**
  70542. * Reference to the Recast library
  70543. */
  70544. bjsRECAST: any;
  70545. /**
  70546. * plugin name
  70547. */
  70548. name: string;
  70549. /**
  70550. * the first navmesh created. We might extend this to support multiple navmeshes
  70551. */
  70552. navMesh: any;
  70553. /**
  70554. * Initializes the recastJS plugin
  70555. * @param recastInjection can be used to inject your own recast reference
  70556. */
  70557. constructor(recastInjection?: any);
  70558. /**
  70559. * Creates a navigation mesh
  70560. * @param meshes array of all the geometry used to compute the navigatio mesh
  70561. * @param parameters bunch of parameters used to filter geometry
  70562. */
  70563. createNavMesh(meshes: Array<Mesh>, parameters: INavMeshParameters): void;
  70564. /**
  70565. * Create a navigation mesh debug mesh
  70566. * @param scene is where the mesh will be added
  70567. * @returns debug display mesh
  70568. */
  70569. createDebugNavMesh(scene: Scene): Mesh;
  70570. /**
  70571. * Get a navigation mesh constrained position, closest to the parameter position
  70572. * @param position world position
  70573. * @returns the closest point to position constrained by the navigation mesh
  70574. */
  70575. getClosestPoint(position: Vector3): Vector3;
  70576. /**
  70577. * Get a navigation mesh constrained position, closest to the parameter position
  70578. * @param position world position
  70579. * @param result output the closest point to position constrained by the navigation mesh
  70580. */
  70581. getClosestPointToRef(position: Vector3, result: Vector3): void;
  70582. /**
  70583. * Get a navigation mesh constrained position, within a particular radius
  70584. * @param position world position
  70585. * @param maxRadius the maximum distance to the constrained world position
  70586. * @returns the closest point to position constrained by the navigation mesh
  70587. */
  70588. getRandomPointAround(position: Vector3, maxRadius: number): Vector3;
  70589. /**
  70590. * Get a navigation mesh constrained position, within a particular radius
  70591. * @param position world position
  70592. * @param maxRadius the maximum distance to the constrained world position
  70593. * @param result output the closest point to position constrained by the navigation mesh
  70594. */
  70595. getRandomPointAroundToRef(position: Vector3, maxRadius: number, result: Vector3): void;
  70596. /**
  70597. * Compute the final position from a segment made of destination-position
  70598. * @param position world position
  70599. * @param destination world position
  70600. * @returns the resulting point along the navmesh
  70601. */
  70602. moveAlong(position: Vector3, destination: Vector3): Vector3;
  70603. /**
  70604. * Compute the final position from a segment made of destination-position
  70605. * @param position world position
  70606. * @param destination world position
  70607. * @param result output the resulting point along the navmesh
  70608. */
  70609. moveAlongToRef(position: Vector3, destination: Vector3, result: Vector3): void;
  70610. /**
  70611. * Compute a navigation path from start to end. Returns an empty array if no path can be computed
  70612. * @param start world position
  70613. * @param end world position
  70614. * @returns array containing world position composing the path
  70615. */
  70616. computePath(start: Vector3, end: Vector3): Vector3[];
  70617. /**
  70618. * Create a new Crowd so you can add agents
  70619. * @param maxAgents the maximum agent count in the crowd
  70620. * @param maxAgentRadius the maximum radius an agent can have
  70621. * @param scene to attach the crowd to
  70622. * @returns the crowd you can add agents to
  70623. */
  70624. createCrowd(maxAgents: number, maxAgentRadius: number, scene: Scene): ICrowd;
  70625. /**
  70626. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  70627. * The queries will try to find a solution within those bounds
  70628. * default is (1,1,1)
  70629. * @param extent x,y,z value that define the extent around the queries point of reference
  70630. */
  70631. setDefaultQueryExtent(extent: Vector3): void;
  70632. /**
  70633. * Get the Bounding box extent specified by setDefaultQueryExtent
  70634. * @returns the box extent values
  70635. */
  70636. getDefaultQueryExtent(): Vector3;
  70637. /**
  70638. * build the navmesh from a previously saved state using getNavmeshData
  70639. * @param data the Uint8Array returned by getNavmeshData
  70640. */
  70641. buildFromNavmeshData(data: Uint8Array): void;
  70642. /**
  70643. * returns the navmesh data that can be used later. The navmesh must be built before retrieving the data
  70644. * @returns data the Uint8Array that can be saved and reused
  70645. */
  70646. getNavmeshData(): Uint8Array;
  70647. /**
  70648. * Get the Bounding box extent result specified by setDefaultQueryExtent
  70649. * @param result output the box extent values
  70650. */
  70651. getDefaultQueryExtentToRef(result: Vector3): void;
  70652. /**
  70653. * Disposes
  70654. */
  70655. dispose(): void;
  70656. /**
  70657. * If this plugin is supported
  70658. * @returns true if plugin is supported
  70659. */
  70660. isSupported(): boolean;
  70661. }
  70662. /**
  70663. * Recast detour crowd implementation
  70664. */
  70665. export class RecastJSCrowd implements ICrowd {
  70666. /**
  70667. * Recast/detour plugin
  70668. */
  70669. bjsRECASTPlugin: RecastJSPlugin;
  70670. /**
  70671. * Link to the detour crowd
  70672. */
  70673. recastCrowd: any;
  70674. /**
  70675. * One transform per agent
  70676. */
  70677. transforms: TransformNode[];
  70678. /**
  70679. * All agents created
  70680. */
  70681. agents: number[];
  70682. /**
  70683. * Link to the scene is kept to unregister the crowd from the scene
  70684. */
  70685. private _scene;
  70686. /**
  70687. * Observer for crowd updates
  70688. */
  70689. private _onBeforeAnimationsObserver;
  70690. /**
  70691. * Constructor
  70692. * @param plugin recastJS plugin
  70693. * @param maxAgents the maximum agent count in the crowd
  70694. * @param maxAgentRadius the maximum radius an agent can have
  70695. * @param scene to attach the crowd to
  70696. * @returns the crowd you can add agents to
  70697. */
  70698. constructor(plugin: RecastJSPlugin, maxAgents: number, maxAgentRadius: number, scene: Scene);
  70699. /**
  70700. * Add a new agent to the crowd with the specified parameter a corresponding transformNode.
  70701. * You can attach anything to that node. The node position is updated in the scene update tick.
  70702. * @param pos world position that will be constrained by the navigation mesh
  70703. * @param parameters agent parameters
  70704. * @param transform hooked to the agent that will be update by the scene
  70705. * @returns agent index
  70706. */
  70707. addAgent(pos: Vector3, parameters: IAgentParameters, transform: TransformNode): number;
  70708. /**
  70709. * Returns the agent position in world space
  70710. * @param index agent index returned by addAgent
  70711. * @returns world space position
  70712. */
  70713. getAgentPosition(index: number): Vector3;
  70714. /**
  70715. * Returns the agent position result in world space
  70716. * @param index agent index returned by addAgent
  70717. * @param result output world space position
  70718. */
  70719. getAgentPositionToRef(index: number, result: Vector3): void;
  70720. /**
  70721. * Returns the agent velocity in world space
  70722. * @param index agent index returned by addAgent
  70723. * @returns world space velocity
  70724. */
  70725. getAgentVelocity(index: number): Vector3;
  70726. /**
  70727. * Returns the agent velocity result in world space
  70728. * @param index agent index returned by addAgent
  70729. * @param result output world space velocity
  70730. */
  70731. getAgentVelocityToRef(index: number, result: Vector3): void;
  70732. /**
  70733. * Asks a particular agent to go to a destination. That destination is constrained by the navigation mesh
  70734. * @param index agent index returned by addAgent
  70735. * @param destination targeted world position
  70736. */
  70737. agentGoto(index: number, destination: Vector3): void;
  70738. /**
  70739. * Teleport the agent to a new position
  70740. * @param index agent index returned by addAgent
  70741. * @param destination targeted world position
  70742. */
  70743. agentTeleport(index: number, destination: Vector3): void;
  70744. /**
  70745. * Update agent parameters
  70746. * @param index agent index returned by addAgent
  70747. * @param parameters agent parameters
  70748. */
  70749. updateAgentParameters(index: number, parameters: IAgentParameters): void;
  70750. /**
  70751. * remove a particular agent previously created
  70752. * @param index agent index returned by addAgent
  70753. */
  70754. removeAgent(index: number): void;
  70755. /**
  70756. * get the list of all agents attached to this crowd
  70757. * @returns list of agent indices
  70758. */
  70759. getAgents(): number[];
  70760. /**
  70761. * Tick update done by the Scene. Agent position/velocity/acceleration is updated by this function
  70762. * @param deltaTime in seconds
  70763. */
  70764. update(deltaTime: number): void;
  70765. /**
  70766. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  70767. * The queries will try to find a solution within those bounds
  70768. * default is (1,1,1)
  70769. * @param extent x,y,z value that define the extent around the queries point of reference
  70770. */
  70771. setDefaultQueryExtent(extent: Vector3): void;
  70772. /**
  70773. * Get the Bounding box extent specified by setDefaultQueryExtent
  70774. * @returns the box extent values
  70775. */
  70776. getDefaultQueryExtent(): Vector3;
  70777. /**
  70778. * Get the Bounding box extent result specified by setDefaultQueryExtent
  70779. * @param result output the box extent values
  70780. */
  70781. getDefaultQueryExtentToRef(result: Vector3): void;
  70782. /**
  70783. * Release all resources
  70784. */
  70785. dispose(): void;
  70786. }
  70787. }
  70788. declare module "babylonjs/Navigation/Plugins/index" {
  70789. export * from "babylonjs/Navigation/Plugins/recastJSPlugin";
  70790. }
  70791. declare module "babylonjs/Navigation/index" {
  70792. export * from "babylonjs/Navigation/INavigationEngine";
  70793. export * from "babylonjs/Navigation/Plugins/index";
  70794. }
  70795. declare module "babylonjs/Offline/database" {
  70796. import { IOfflineProvider } from "babylonjs/Offline/IOfflineProvider";
  70797. /**
  70798. * Class used to enable access to IndexedDB
  70799. * @see https://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  70800. */
  70801. export class Database implements IOfflineProvider {
  70802. private _callbackManifestChecked;
  70803. private _currentSceneUrl;
  70804. private _db;
  70805. private _enableSceneOffline;
  70806. private _enableTexturesOffline;
  70807. private _manifestVersionFound;
  70808. private _mustUpdateRessources;
  70809. private _hasReachedQuota;
  70810. private _isSupported;
  70811. private _idbFactory;
  70812. /** Gets a boolean indicating if the user agent supports blob storage (this value will be updated after creating the first Database object) */
  70813. private static IsUASupportingBlobStorage;
  70814. /**
  70815. * Gets a boolean indicating if Database storate is enabled (off by default)
  70816. */
  70817. static IDBStorageEnabled: boolean;
  70818. /**
  70819. * Gets a boolean indicating if scene must be saved in the database
  70820. */
  70821. get enableSceneOffline(): boolean;
  70822. /**
  70823. * Gets a boolean indicating if textures must be saved in the database
  70824. */
  70825. get enableTexturesOffline(): boolean;
  70826. /**
  70827. * Creates a new Database
  70828. * @param urlToScene defines the url to load the scene
  70829. * @param callbackManifestChecked defines the callback to use when manifest is checked
  70830. * @param disableManifestCheck defines a boolean indicating that we want to skip the manifest validation (it will be considered validated and up to date)
  70831. */
  70832. constructor(urlToScene: string, callbackManifestChecked: (checked: boolean) => any, disableManifestCheck?: boolean);
  70833. private static _ParseURL;
  70834. private static _ReturnFullUrlLocation;
  70835. private _checkManifestFile;
  70836. /**
  70837. * Open the database and make it available
  70838. * @param successCallback defines the callback to call on success
  70839. * @param errorCallback defines the callback to call on error
  70840. */
  70841. open(successCallback: () => void, errorCallback: () => void): void;
  70842. /**
  70843. * Loads an image from the database
  70844. * @param url defines the url to load from
  70845. * @param image defines the target DOM image
  70846. */
  70847. loadImage(url: string, image: HTMLImageElement): void;
  70848. private _loadImageFromDBAsync;
  70849. private _saveImageIntoDBAsync;
  70850. private _checkVersionFromDB;
  70851. private _loadVersionFromDBAsync;
  70852. private _saveVersionIntoDBAsync;
  70853. /**
  70854. * Loads a file from database
  70855. * @param url defines the URL to load from
  70856. * @param sceneLoaded defines a callback to call on success
  70857. * @param progressCallBack defines a callback to call when progress changed
  70858. * @param errorCallback defines a callback to call on error
  70859. * @param useArrayBuffer defines a boolean to use array buffer instead of text string
  70860. */
  70861. loadFile(url: string, sceneLoaded: (data: any) => void, progressCallBack?: (data: any) => void, errorCallback?: () => void, useArrayBuffer?: boolean): void;
  70862. private _loadFileAsync;
  70863. private _saveFileAsync;
  70864. /**
  70865. * Validates if xhr data is correct
  70866. * @param xhr defines the request to validate
  70867. * @param dataType defines the expected data type
  70868. * @returns true if data is correct
  70869. */
  70870. private static _ValidateXHRData;
  70871. }
  70872. }
  70873. declare module "babylonjs/Offline/index" {
  70874. export * from "babylonjs/Offline/database";
  70875. export * from "babylonjs/Offline/IOfflineProvider";
  70876. }
  70877. declare module "babylonjs/Shaders/gpuUpdateParticles.fragment" {
  70878. /** @hidden */
  70879. export var gpuUpdateParticlesPixelShader: {
  70880. name: string;
  70881. shader: string;
  70882. };
  70883. }
  70884. declare module "babylonjs/Shaders/gpuUpdateParticles.vertex" {
  70885. /** @hidden */
  70886. export var gpuUpdateParticlesVertexShader: {
  70887. name: string;
  70888. shader: string;
  70889. };
  70890. }
  70891. declare module "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration2" {
  70892. /** @hidden */
  70893. export var clipPlaneFragmentDeclaration2: {
  70894. name: string;
  70895. shader: string;
  70896. };
  70897. }
  70898. declare module "babylonjs/Shaders/gpuRenderParticles.fragment" {
  70899. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration2";
  70900. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  70901. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  70902. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  70903. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragment";
  70904. /** @hidden */
  70905. export var gpuRenderParticlesPixelShader: {
  70906. name: string;
  70907. shader: string;
  70908. };
  70909. }
  70910. declare module "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration2" {
  70911. /** @hidden */
  70912. export var clipPlaneVertexDeclaration2: {
  70913. name: string;
  70914. shader: string;
  70915. };
  70916. }
  70917. declare module "babylonjs/Shaders/gpuRenderParticles.vertex" {
  70918. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration2";
  70919. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertex";
  70920. /** @hidden */
  70921. export var gpuRenderParticlesVertexShader: {
  70922. name: string;
  70923. shader: string;
  70924. };
  70925. }
  70926. declare module "babylonjs/Particles/gpuParticleSystem" {
  70927. import { Nullable } from "babylonjs/types";
  70928. import { Color3Gradient, IValueGradient } from "babylonjs/Misc/gradients";
  70929. import { Observable } from "babylonjs/Misc/observable";
  70930. import { Matrix } from "babylonjs/Maths/math.vector";
  70931. import { Color4, Color3 } from "babylonjs/Maths/math.color";
  70932. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  70933. import { BaseParticleSystem } from "babylonjs/Particles/baseParticleSystem";
  70934. import { IDisposable } from "babylonjs/scene";
  70935. import { Effect } from "babylonjs/Materials/effect";
  70936. import { RawTexture } from "babylonjs/Materials/Textures/rawTexture";
  70937. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  70938. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  70939. import { Scene } from "babylonjs/scene";
  70940. import "babylonjs/Shaders/gpuUpdateParticles.fragment";
  70941. import "babylonjs/Shaders/gpuUpdateParticles.vertex";
  70942. import "babylonjs/Shaders/gpuRenderParticles.fragment";
  70943. import "babylonjs/Shaders/gpuRenderParticles.vertex";
  70944. /**
  70945. * This represents a GPU particle system in Babylon
  70946. * This is the fastest particle system in Babylon as it uses the GPU to update the individual particle data
  70947. * @see https://www.babylonjs-playground.com/#PU4WYI#4
  70948. */
  70949. export class GPUParticleSystem extends BaseParticleSystem implements IDisposable, IParticleSystem, IAnimatable {
  70950. /**
  70951. * The layer mask we are rendering the particles through.
  70952. */
  70953. layerMask: number;
  70954. private _capacity;
  70955. private _activeCount;
  70956. private _currentActiveCount;
  70957. private _accumulatedCount;
  70958. private _renderEffect;
  70959. private _updateEffect;
  70960. private _buffer0;
  70961. private _buffer1;
  70962. private _spriteBuffer;
  70963. private _updateVAO;
  70964. private _renderVAO;
  70965. private _targetIndex;
  70966. private _sourceBuffer;
  70967. private _targetBuffer;
  70968. private _currentRenderId;
  70969. private _started;
  70970. private _stopped;
  70971. private _timeDelta;
  70972. private _randomTexture;
  70973. private _randomTexture2;
  70974. private _attributesStrideSize;
  70975. private _updateEffectOptions;
  70976. private _randomTextureSize;
  70977. private _actualFrame;
  70978. private _customEffect;
  70979. private readonly _rawTextureWidth;
  70980. /**
  70981. * Gets a boolean indicating if the GPU particles can be rendered on current browser
  70982. */
  70983. static get IsSupported(): boolean;
  70984. /**
  70985. * An event triggered when the system is disposed.
  70986. */
  70987. onDisposeObservable: Observable<IParticleSystem>;
  70988. /**
  70989. * Gets the maximum number of particles active at the same time.
  70990. * @returns The max number of active particles.
  70991. */
  70992. getCapacity(): number;
  70993. /**
  70994. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  70995. * to override the particles.
  70996. */
  70997. forceDepthWrite: boolean;
  70998. /**
  70999. * Gets or set the number of active particles
  71000. */
  71001. get activeParticleCount(): number;
  71002. set activeParticleCount(value: number);
  71003. private _preWarmDone;
  71004. /**
  71005. * Specifies if the particles are updated in emitter local space or world space.
  71006. */
  71007. isLocal: boolean;
  71008. /** Gets or sets a matrix to use to compute projection */
  71009. defaultProjectionMatrix: Matrix;
  71010. /**
  71011. * Is this system ready to be used/rendered
  71012. * @return true if the system is ready
  71013. */
  71014. isReady(): boolean;
  71015. /**
  71016. * Gets if the system has been started. (Note: this will still be true after stop is called)
  71017. * @returns True if it has been started, otherwise false.
  71018. */
  71019. isStarted(): boolean;
  71020. /**
  71021. * Gets if the system has been stopped. (Note: rendering is still happening but the system is frozen)
  71022. * @returns True if it has been stopped, otherwise false.
  71023. */
  71024. isStopped(): boolean;
  71025. /**
  71026. * Gets a boolean indicating that the system is stopping
  71027. * @returns true if the system is currently stopping
  71028. */
  71029. isStopping(): boolean;
  71030. /**
  71031. * Gets the number of particles active at the same time.
  71032. * @returns The number of active particles.
  71033. */
  71034. getActiveCount(): number;
  71035. /**
  71036. * Starts the particle system and begins to emit
  71037. * @param delay defines the delay in milliseconds before starting the system (this.startDelay by default)
  71038. */
  71039. start(delay?: number): void;
  71040. /**
  71041. * Stops the particle system.
  71042. */
  71043. stop(): void;
  71044. /**
  71045. * Remove all active particles
  71046. */
  71047. reset(): void;
  71048. /**
  71049. * Returns the string "GPUParticleSystem"
  71050. * @returns a string containing the class name
  71051. */
  71052. getClassName(): string;
  71053. /**
  71054. * Gets the custom effect used to render the particles
  71055. * @param blendMode Blend mode for which the effect should be retrieved
  71056. * @returns The effect
  71057. */
  71058. getCustomEffect(blendMode?: number): Nullable<Effect>;
  71059. /**
  71060. * Sets the custom effect used to render the particles
  71061. * @param effect The effect to set
  71062. * @param blendMode Blend mode for which the effect should be set
  71063. */
  71064. setCustomEffect(effect: Nullable<Effect>, blendMode?: number): void;
  71065. /** @hidden */
  71066. protected _onBeforeDrawParticlesObservable: Nullable<Observable<Nullable<Effect>>>;
  71067. /**
  71068. * Observable that will be called just before the particles are drawn
  71069. */
  71070. get onBeforeDrawParticlesObservable(): Observable<Nullable<Effect>>;
  71071. /**
  71072. * Gets the name of the particle vertex shader
  71073. */
  71074. get vertexShaderName(): string;
  71075. private _colorGradientsTexture;
  71076. protected _removeGradientAndTexture(gradient: number, gradients: Nullable<IValueGradient[]>, texture: RawTexture): BaseParticleSystem;
  71077. /**
  71078. * Adds a new color gradient
  71079. * @param gradient defines the gradient to use (between 0 and 1)
  71080. * @param color1 defines the color to affect to the specified gradient
  71081. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  71082. * @returns the current particle system
  71083. */
  71084. addColorGradient(gradient: number, color1: Color4, color2?: Color4): GPUParticleSystem;
  71085. private _refreshColorGradient;
  71086. /** Force the system to rebuild all gradients that need to be resync */
  71087. forceRefreshGradients(): void;
  71088. /**
  71089. * Remove a specific color gradient
  71090. * @param gradient defines the gradient to remove
  71091. * @returns the current particle system
  71092. */
  71093. removeColorGradient(gradient: number): GPUParticleSystem;
  71094. private _angularSpeedGradientsTexture;
  71095. private _sizeGradientsTexture;
  71096. private _velocityGradientsTexture;
  71097. private _limitVelocityGradientsTexture;
  71098. private _dragGradientsTexture;
  71099. private _addFactorGradient;
  71100. /**
  71101. * Adds a new size gradient
  71102. * @param gradient defines the gradient to use (between 0 and 1)
  71103. * @param factor defines the size factor to affect to the specified gradient
  71104. * @returns the current particle system
  71105. */
  71106. addSizeGradient(gradient: number, factor: number): GPUParticleSystem;
  71107. /**
  71108. * Remove a specific size gradient
  71109. * @param gradient defines the gradient to remove
  71110. * @returns the current particle system
  71111. */
  71112. removeSizeGradient(gradient: number): GPUParticleSystem;
  71113. private _refreshFactorGradient;
  71114. /**
  71115. * Adds a new angular speed gradient
  71116. * @param gradient defines the gradient to use (between 0 and 1)
  71117. * @param factor defines the angular speed to affect to the specified gradient
  71118. * @returns the current particle system
  71119. */
  71120. addAngularSpeedGradient(gradient: number, factor: number): GPUParticleSystem;
  71121. /**
  71122. * Remove a specific angular speed gradient
  71123. * @param gradient defines the gradient to remove
  71124. * @returns the current particle system
  71125. */
  71126. removeAngularSpeedGradient(gradient: number): GPUParticleSystem;
  71127. /**
  71128. * Adds a new velocity gradient
  71129. * @param gradient defines the gradient to use (between 0 and 1)
  71130. * @param factor defines the velocity to affect to the specified gradient
  71131. * @returns the current particle system
  71132. */
  71133. addVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  71134. /**
  71135. * Remove a specific velocity gradient
  71136. * @param gradient defines the gradient to remove
  71137. * @returns the current particle system
  71138. */
  71139. removeVelocityGradient(gradient: number): GPUParticleSystem;
  71140. /**
  71141. * Adds a new limit velocity gradient
  71142. * @param gradient defines the gradient to use (between 0 and 1)
  71143. * @param factor defines the limit velocity value to affect to the specified gradient
  71144. * @returns the current particle system
  71145. */
  71146. addLimitVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  71147. /**
  71148. * Remove a specific limit velocity gradient
  71149. * @param gradient defines the gradient to remove
  71150. * @returns the current particle system
  71151. */
  71152. removeLimitVelocityGradient(gradient: number): GPUParticleSystem;
  71153. /**
  71154. * Adds a new drag gradient
  71155. * @param gradient defines the gradient to use (between 0 and 1)
  71156. * @param factor defines the drag value to affect to the specified gradient
  71157. * @returns the current particle system
  71158. */
  71159. addDragGradient(gradient: number, factor: number): GPUParticleSystem;
  71160. /**
  71161. * Remove a specific drag gradient
  71162. * @param gradient defines the gradient to remove
  71163. * @returns the current particle system
  71164. */
  71165. removeDragGradient(gradient: number): GPUParticleSystem;
  71166. /**
  71167. * Not supported by GPUParticleSystem
  71168. * @param gradient defines the gradient to use (between 0 and 1)
  71169. * @param factor defines the emit rate value to affect to the specified gradient
  71170. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  71171. * @returns the current particle system
  71172. */
  71173. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  71174. /**
  71175. * Not supported by GPUParticleSystem
  71176. * @param gradient defines the gradient to remove
  71177. * @returns the current particle system
  71178. */
  71179. removeEmitRateGradient(gradient: number): IParticleSystem;
  71180. /**
  71181. * Not supported by GPUParticleSystem
  71182. * @param gradient defines the gradient to use (between 0 and 1)
  71183. * @param factor defines the start size value to affect to the specified gradient
  71184. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  71185. * @returns the current particle system
  71186. */
  71187. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  71188. /**
  71189. * Not supported by GPUParticleSystem
  71190. * @param gradient defines the gradient to remove
  71191. * @returns the current particle system
  71192. */
  71193. removeStartSizeGradient(gradient: number): IParticleSystem;
  71194. /**
  71195. * Not supported by GPUParticleSystem
  71196. * @param gradient defines the gradient to use (between 0 and 1)
  71197. * @param min defines the color remap minimal range
  71198. * @param max defines the color remap maximal range
  71199. * @returns the current particle system
  71200. */
  71201. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  71202. /**
  71203. * Not supported by GPUParticleSystem
  71204. * @param gradient defines the gradient to remove
  71205. * @returns the current particle system
  71206. */
  71207. removeColorRemapGradient(): IParticleSystem;
  71208. /**
  71209. * Not supported by GPUParticleSystem
  71210. * @param gradient defines the gradient to use (between 0 and 1)
  71211. * @param min defines the alpha remap minimal range
  71212. * @param max defines the alpha remap maximal range
  71213. * @returns the current particle system
  71214. */
  71215. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  71216. /**
  71217. * Not supported by GPUParticleSystem
  71218. * @param gradient defines the gradient to remove
  71219. * @returns the current particle system
  71220. */
  71221. removeAlphaRemapGradient(): IParticleSystem;
  71222. /**
  71223. * Not supported by GPUParticleSystem
  71224. * @param gradient defines the gradient to use (between 0 and 1)
  71225. * @param color defines the color to affect to the specified gradient
  71226. * @returns the current particle system
  71227. */
  71228. addRampGradient(gradient: number, color: Color3): IParticleSystem;
  71229. /**
  71230. * Not supported by GPUParticleSystem
  71231. * @param gradient defines the gradient to remove
  71232. * @returns the current particle system
  71233. */
  71234. removeRampGradient(): IParticleSystem;
  71235. /**
  71236. * Not supported by GPUParticleSystem
  71237. * @returns the list of ramp gradients
  71238. */
  71239. getRampGradients(): Nullable<Array<Color3Gradient>>;
  71240. /**
  71241. * Not supported by GPUParticleSystem
  71242. * Gets or sets a boolean indicating that ramp gradients must be used
  71243. * @see https://doc.babylonjs.com/babylon101/particles#ramp-gradients
  71244. */
  71245. get useRampGradients(): boolean;
  71246. set useRampGradients(value: boolean);
  71247. /**
  71248. * Not supported by GPUParticleSystem
  71249. * @param gradient defines the gradient to use (between 0 and 1)
  71250. * @param factor defines the life time factor to affect to the specified gradient
  71251. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  71252. * @returns the current particle system
  71253. */
  71254. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  71255. /**
  71256. * Not supported by GPUParticleSystem
  71257. * @param gradient defines the gradient to remove
  71258. * @returns the current particle system
  71259. */
  71260. removeLifeTimeGradient(gradient: number): IParticleSystem;
  71261. /**
  71262. * Instantiates a GPU particle system.
  71263. * 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.
  71264. * @param name The name of the particle system
  71265. * @param options The options used to create the system
  71266. * @param sceneOrEngine The scene the particle system belongs to or the engine to use if no scene
  71267. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  71268. * @param customEffect a custom effect used to change the way particles are rendered by default
  71269. */
  71270. constructor(name: string, options: Partial<{
  71271. capacity: number;
  71272. randomTextureSize: number;
  71273. }>, sceneOrEngine: Scene | ThinEngine, isAnimationSheetEnabled?: boolean, customEffect?: Nullable<Effect>);
  71274. protected _reset(): void;
  71275. private _createUpdateVAO;
  71276. private _createRenderVAO;
  71277. private _initialize;
  71278. /** @hidden */
  71279. _recreateUpdateEffect(): void;
  71280. private _getEffect;
  71281. /**
  71282. * Fill the defines array according to the current settings of the particle system
  71283. * @param defines Array to be updated
  71284. * @param blendMode blend mode to take into account when updating the array
  71285. */
  71286. fillDefines(defines: Array<string>, blendMode?: number): void;
  71287. /**
  71288. * Fill the uniforms, attributes and samplers arrays according to the current settings of the particle system
  71289. * @param uniforms Uniforms array to fill
  71290. * @param attributes Attributes array to fill
  71291. * @param samplers Samplers array to fill
  71292. */
  71293. fillUniformsAttributesAndSamplerNames(uniforms: Array<string>, attributes: Array<string>, samplers: Array<string>): void;
  71294. /** @hidden */
  71295. _recreateRenderEffect(): Effect;
  71296. /**
  71297. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  71298. * @param preWarm defines if we are in the pre-warmimg phase
  71299. */
  71300. animate(preWarm?: boolean): void;
  71301. private _createFactorGradientTexture;
  71302. private _createSizeGradientTexture;
  71303. private _createAngularSpeedGradientTexture;
  71304. private _createVelocityGradientTexture;
  71305. private _createLimitVelocityGradientTexture;
  71306. private _createDragGradientTexture;
  71307. private _createColorGradientTexture;
  71308. /**
  71309. * Renders the particle system in its current state
  71310. * @param preWarm defines if the system should only update the particles but not render them
  71311. * @returns the current number of particles
  71312. */
  71313. render(preWarm?: boolean): number;
  71314. /**
  71315. * Rebuilds the particle system
  71316. */
  71317. rebuild(): void;
  71318. private _releaseBuffers;
  71319. private _releaseVAOs;
  71320. /**
  71321. * Disposes the particle system and free the associated resources
  71322. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  71323. */
  71324. dispose(disposeTexture?: boolean): void;
  71325. /**
  71326. * Clones the particle system.
  71327. * @param name The name of the cloned object
  71328. * @param newEmitter The new emitter to use
  71329. * @returns the cloned particle system
  71330. */
  71331. clone(name: string, newEmitter: any): GPUParticleSystem;
  71332. /**
  71333. * Serializes the particle system to a JSON object
  71334. * @param serializeTexture defines if the texture must be serialized as well
  71335. * @returns the JSON object
  71336. */
  71337. serialize(serializeTexture?: boolean): any;
  71338. /**
  71339. * Parses a JSON object to create a GPU particle system.
  71340. * @param parsedParticleSystem The JSON object to parse
  71341. * @param sceneOrEngine The scene or the engine to create the particle system in
  71342. * @param rootUrl The root url to use to load external dependencies like texture
  71343. * @param doNotStart Ignore the preventAutoStart attribute and does not start
  71344. * @returns the parsed GPU particle system
  71345. */
  71346. static Parse(parsedParticleSystem: any, sceneOrEngine: Scene | ThinEngine, rootUrl: string, doNotStart?: boolean): GPUParticleSystem;
  71347. }
  71348. }
  71349. declare module "babylonjs/Particles/particleSystemSet" {
  71350. import { Nullable } from "babylonjs/types";
  71351. import { Color3 } from "babylonjs/Maths/math.color";
  71352. import { TransformNode } from "babylonjs/Meshes/transformNode";
  71353. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  71354. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  71355. import { Scene, IDisposable } from "babylonjs/scene";
  71356. /**
  71357. * Represents a set of particle systems working together to create a specific effect
  71358. */
  71359. export class ParticleSystemSet implements IDisposable {
  71360. /**
  71361. * Gets or sets base Assets URL
  71362. */
  71363. static BaseAssetsUrl: string;
  71364. private _emitterCreationOptions;
  71365. private _emitterNode;
  71366. /**
  71367. * Gets the particle system list
  71368. */
  71369. systems: IParticleSystem[];
  71370. /**
  71371. * Gets the emitter node used with this set
  71372. */
  71373. get emitterNode(): Nullable<TransformNode>;
  71374. /**
  71375. * Creates a new emitter mesh as a sphere
  71376. * @param options defines the options used to create the sphere
  71377. * @param renderingGroupId defines the renderingGroupId to use for the sphere
  71378. * @param scene defines the hosting scene
  71379. */
  71380. setEmitterAsSphere(options: {
  71381. diameter: number;
  71382. segments: number;
  71383. color: Color3;
  71384. }, renderingGroupId: number, scene: Scene): void;
  71385. /**
  71386. * Starts all particle systems of the set
  71387. * @param emitter defines an optional mesh to use as emitter for the particle systems
  71388. */
  71389. start(emitter?: AbstractMesh): void;
  71390. /**
  71391. * Release all associated resources
  71392. */
  71393. dispose(): void;
  71394. /**
  71395. * Serialize the set into a JSON compatible object
  71396. * @param serializeTexture defines if the texture must be serialized as well
  71397. * @returns a JSON compatible representation of the set
  71398. */
  71399. serialize(serializeTexture?: boolean): any;
  71400. /**
  71401. * Parse a new ParticleSystemSet from a serialized source
  71402. * @param data defines a JSON compatible representation of the set
  71403. * @param scene defines the hosting scene
  71404. * @param gpu defines if we want GPU particles or CPU particles
  71405. * @returns a new ParticleSystemSet
  71406. */
  71407. static Parse(data: any, scene: Scene, gpu?: boolean): ParticleSystemSet;
  71408. }
  71409. }
  71410. declare module "babylonjs/Particles/particleHelper" {
  71411. import { Nullable } from "babylonjs/types";
  71412. import { Scene } from "babylonjs/scene";
  71413. import { Vector3 } from "babylonjs/Maths/math.vector";
  71414. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  71415. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  71416. import { ParticleSystemSet } from "babylonjs/Particles/particleSystemSet";
  71417. /**
  71418. * This class is made for on one-liner static method to help creating particle system set.
  71419. */
  71420. export class ParticleHelper {
  71421. /**
  71422. * Gets or sets base Assets URL
  71423. */
  71424. static BaseAssetsUrl: string;
  71425. /** Define the Url to load snippets */
  71426. static SnippetUrl: string;
  71427. /**
  71428. * Create a default particle system that you can tweak
  71429. * @param emitter defines the emitter to use
  71430. * @param capacity defines the system capacity (default is 500 particles)
  71431. * @param scene defines the hosting scene
  71432. * @param useGPU defines if a GPUParticleSystem must be created (default is false)
  71433. * @returns the new Particle system
  71434. */
  71435. static CreateDefault(emitter: Nullable<AbstractMesh | Vector3>, capacity?: number, scene?: Scene, useGPU?: boolean): IParticleSystem;
  71436. /**
  71437. * This is the main static method (one-liner) of this helper to create different particle systems
  71438. * @param type This string represents the type to the particle system to create
  71439. * @param scene The scene where the particle system should live
  71440. * @param gpu If the system will use gpu
  71441. * @returns the ParticleSystemSet created
  71442. */
  71443. static CreateAsync(type: string, scene: Nullable<Scene>, gpu?: boolean): Promise<ParticleSystemSet>;
  71444. /**
  71445. * Static function used to export a particle system to a ParticleSystemSet variable.
  71446. * Please note that the emitter shape is not exported
  71447. * @param systems defines the particle systems to export
  71448. * @returns the created particle system set
  71449. */
  71450. static ExportSet(systems: IParticleSystem[]): ParticleSystemSet;
  71451. /**
  71452. * Creates a particle system from a snippet saved in a remote file
  71453. * @param name defines the name of the particle system to create (can be null or empty to use the one from the json data)
  71454. * @param url defines the url to load from
  71455. * @param scene defines the hosting scene
  71456. * @param gpu If the system will use gpu
  71457. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  71458. * @returns a promise that will resolve to the new particle system
  71459. */
  71460. static ParseFromFileAsync(name: Nullable<string>, url: string, scene: Scene, gpu?: boolean, rootUrl?: string): Promise<IParticleSystem>;
  71461. /**
  71462. * Creates a particle system from a snippet saved by the particle system editor
  71463. * @param snippetId defines the snippet to load (can be set to _BLANK to create a default one)
  71464. * @param scene defines the hosting scene
  71465. * @param gpu If the system will use gpu
  71466. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  71467. * @returns a promise that will resolve to the new particle system
  71468. */
  71469. static CreateFromSnippetAsync(snippetId: string, scene: Scene, gpu?: boolean, rootUrl?: string): Promise<IParticleSystem>;
  71470. }
  71471. }
  71472. declare module "babylonjs/Particles/particleSystemComponent" {
  71473. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  71474. import { Effect } from "babylonjs/Materials/effect";
  71475. import "babylonjs/Shaders/particles.vertex";
  71476. import { EffectFallbacks } from "babylonjs/Materials/effectFallbacks";
  71477. module "babylonjs/Engines/engine" {
  71478. interface Engine {
  71479. /**
  71480. * Create an effect to use with particle systems.
  71481. * Please note that some parameters like animation sheets or not being billboard are not supported in this configuration, except if you pass
  71482. * the particle system for which you want to create a custom effect in the last parameter
  71483. * @param fragmentName defines the base name of the effect (The name of file without .fragment.fx)
  71484. * @param uniformsNames defines a list of attribute names
  71485. * @param samplers defines an array of string used to represent textures
  71486. * @param defines defines the string containing the defines to use to compile the shaders
  71487. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  71488. * @param onCompiled defines a function to call when the effect creation is successful
  71489. * @param onError defines a function to call when the effect creation has failed
  71490. * @param particleSystem the particle system you want to create the effect for
  71491. * @returns the new Effect
  71492. */
  71493. createEffectForParticles(fragmentName: string, uniformsNames: string[], samplers: string[], defines: string, fallbacks?: EffectFallbacks, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void, particleSystem?: IParticleSystem): Effect;
  71494. }
  71495. }
  71496. module "babylonjs/Meshes/mesh" {
  71497. interface Mesh {
  71498. /**
  71499. * Returns an array populated with IParticleSystem objects whose the mesh is the emitter
  71500. * @returns an array of IParticleSystem
  71501. */
  71502. getEmittedParticleSystems(): IParticleSystem[];
  71503. /**
  71504. * Returns an array populated with IParticleSystem objects whose the mesh or its children are the emitter
  71505. * @returns an array of IParticleSystem
  71506. */
  71507. getHierarchyEmittedParticleSystems(): IParticleSystem[];
  71508. }
  71509. }
  71510. }
  71511. declare module "babylonjs/Particles/pointsCloudSystem" {
  71512. import { Color4 } from "babylonjs/Maths/math";
  71513. import { Mesh } from "babylonjs/Meshes/mesh";
  71514. import { Scene, IDisposable } from "babylonjs/scene";
  71515. import { CloudPoint } from "babylonjs/Particles/cloudPoint";
  71516. /** Defines the 4 color options */
  71517. export enum PointColor {
  71518. /** color value */
  71519. Color = 2,
  71520. /** uv value */
  71521. UV = 1,
  71522. /** random value */
  71523. Random = 0,
  71524. /** stated value */
  71525. Stated = 3
  71526. }
  71527. /**
  71528. * The PointCloudSystem (PCS) is a single updatable mesh. The points corresponding to the vertices of this big mesh.
  71529. * 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.
  71530. * The PointCloudSytem is also a particle system, with each point being a particle. It provides some methods to manage the particles.
  71531. * However it is behavior agnostic. This means it has no emitter, no particle physics, no particle recycler. You have to implement your own behavior.
  71532. *
  71533. * Full documentation here : TO BE ENTERED
  71534. */
  71535. export class PointsCloudSystem implements IDisposable {
  71536. /**
  71537. * The PCS array of cloud point objects. Just access each particle as with any classic array.
  71538. * Example : var p = SPS.particles[i];
  71539. */
  71540. particles: CloudPoint[];
  71541. /**
  71542. * The PCS total number of particles. Read only. Use PCS.counter instead if you need to set your own value.
  71543. */
  71544. nbParticles: number;
  71545. /**
  71546. * This a counter for your own usage. It's not set by any SPS functions.
  71547. */
  71548. counter: number;
  71549. /**
  71550. * The PCS name. This name is also given to the underlying mesh.
  71551. */
  71552. name: string;
  71553. /**
  71554. * The PCS mesh. It's a standard BJS Mesh, so all the methods from the Mesh class are avalaible.
  71555. */
  71556. mesh: Mesh;
  71557. /**
  71558. * This empty object is intended to store some PCS specific or temporary values in order to lower the Garbage Collector activity.
  71559. * Please read :
  71560. */
  71561. vars: any;
  71562. /**
  71563. * @hidden
  71564. */
  71565. _size: number;
  71566. private _scene;
  71567. private _promises;
  71568. private _positions;
  71569. private _indices;
  71570. private _normals;
  71571. private _colors;
  71572. private _uvs;
  71573. private _indices32;
  71574. private _positions32;
  71575. private _colors32;
  71576. private _uvs32;
  71577. private _updatable;
  71578. private _isVisibilityBoxLocked;
  71579. private _alwaysVisible;
  71580. private _groups;
  71581. private _groupCounter;
  71582. private _computeParticleColor;
  71583. private _computeParticleTexture;
  71584. private _computeParticleRotation;
  71585. private _computeBoundingBox;
  71586. private _isReady;
  71587. /**
  71588. * Creates a PCS (Points Cloud System) object
  71589. * @param name (String) is the PCS name, this will be the underlying mesh name
  71590. * @param pointSize (number) is the size for each point
  71591. * @param scene (Scene) is the scene in which the PCS is added
  71592. * @param options defines the options of the PCS e.g.
  71593. * * updatable (optional boolean, default true) : if the PCS must be updatable or immutable
  71594. */
  71595. constructor(name: string, pointSize: number, scene: Scene, options?: {
  71596. updatable?: boolean;
  71597. });
  71598. /**
  71599. * Builds the PCS underlying mesh. Returns a standard Mesh.
  71600. * If no points were added to the PCS, the returned mesh is just a single point.
  71601. * @returns a promise for the created mesh
  71602. */
  71603. buildMeshAsync(): Promise<Mesh>;
  71604. /**
  71605. * @hidden
  71606. */
  71607. private _buildMesh;
  71608. private _addParticle;
  71609. private _randomUnitVector;
  71610. private _getColorIndicesForCoord;
  71611. private _setPointsColorOrUV;
  71612. private _colorFromTexture;
  71613. private _calculateDensity;
  71614. /**
  71615. * Adds points to the PCS in random positions within a unit sphere
  71616. * @param nb (positive integer) the number of particles to be created from this model
  71617. * @param pointFunction is an optional javascript function to be called for each particle on PCS creation
  71618. * @returns the number of groups in the system
  71619. */
  71620. addPoints(nb: number, pointFunction?: any): number;
  71621. /**
  71622. * Adds points to the PCS from the surface of the model shape
  71623. * @param mesh is any Mesh object that will be used as a surface model for the points
  71624. * @param nb (positive integer) the number of particles to be created from this model
  71625. * @param colorWith determines whether a point is colored using color (default), uv, random, stated or none (invisible)
  71626. * @param color (color4) to be used when colorWith is stated or color (number) when used to specify texture position
  71627. * @param range (number from 0 to 1) to determine the variation in shape and tone for a stated color
  71628. * @returns the number of groups in the system
  71629. */
  71630. addSurfacePoints(mesh: Mesh, nb: number, colorWith?: number, color?: Color4 | number, range?: number): number;
  71631. /**
  71632. * Adds points to the PCS inside the model shape
  71633. * @param mesh is any Mesh object that will be used as a surface model for the points
  71634. * @param nb (positive integer) the number of particles to be created from this model
  71635. * @param colorWith determines whether a point is colored using color (default), uv, random, stated or none (invisible)
  71636. * @param color (color4) to be used when colorWith is stated or color (number) when used to specify texture position
  71637. * @param range (number from 0 to 1) to determine the variation in shape and tone for a stated color
  71638. * @returns the number of groups in the system
  71639. */
  71640. addVolumePoints(mesh: Mesh, nb: number, colorWith?: number, color?: Color4 | number, range?: number): number;
  71641. /**
  71642. * Sets all the particles : this method actually really updates the mesh according to the particle positions, rotations, colors, textures, etc.
  71643. * This method calls `updateParticle()` for each particle of the SPS.
  71644. * For an animated SPS, it is usually called within the render loop.
  71645. * @param start The particle index in the particle array where to start to compute the particle property values _(default 0)_
  71646. * @param end The particle index in the particle array where to stop to compute the particle property values _(default nbParticle - 1)_
  71647. * @param update If the mesh must be finally updated on this call after all the particle computations _(default true)_
  71648. * @returns the PCS.
  71649. */
  71650. setParticles(start?: number, end?: number, update?: boolean): PointsCloudSystem;
  71651. /**
  71652. * Disposes the PCS.
  71653. */
  71654. dispose(): void;
  71655. /**
  71656. * Visibilty helper : Recomputes the visible size according to the mesh bounding box
  71657. * doc :
  71658. * @returns the PCS.
  71659. */
  71660. refreshVisibleSize(): PointsCloudSystem;
  71661. /**
  71662. * Visibility helper : Sets the size of a visibility box, this sets the underlying mesh bounding box.
  71663. * @param size the size (float) of the visibility box
  71664. * note : this doesn't lock the PCS mesh bounding box.
  71665. * doc :
  71666. */
  71667. setVisibilityBox(size: number): void;
  71668. /**
  71669. * Gets whether the PCS is always visible or not
  71670. * doc :
  71671. */
  71672. get isAlwaysVisible(): boolean;
  71673. /**
  71674. * Sets the PCS as always visible or not
  71675. * doc :
  71676. */
  71677. set isAlwaysVisible(val: boolean);
  71678. /**
  71679. * Tells to `setParticles()` to compute the particle rotations or not
  71680. * Default value : false. The PCS is faster when it's set to false
  71681. * Note : particle rotations are only applied to parent particles
  71682. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate
  71683. */
  71684. set computeParticleRotation(val: boolean);
  71685. /**
  71686. * Tells to `setParticles()` to compute the particle colors or not.
  71687. * Default value : true. The PCS is faster when it's set to false.
  71688. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  71689. */
  71690. set computeParticleColor(val: boolean);
  71691. set computeParticleTexture(val: boolean);
  71692. /**
  71693. * Gets if `setParticles()` computes the particle colors or not.
  71694. * Default value : false. The PCS is faster when it's set to false.
  71695. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  71696. */
  71697. get computeParticleColor(): boolean;
  71698. /**
  71699. * Gets if `setParticles()` computes the particle textures or not.
  71700. * Default value : false. The PCS is faster when it's set to false.
  71701. * Note : the particle textures are stored values, so setting `computeParticleTexture` to false will keep yet the last colors set.
  71702. */
  71703. get computeParticleTexture(): boolean;
  71704. /**
  71705. * Tells to `setParticles()` to compute or not the mesh bounding box when computing the particle positions.
  71706. */
  71707. set computeBoundingBox(val: boolean);
  71708. /**
  71709. * Gets if `setParticles()` computes or not the mesh bounding box when computing the particle positions.
  71710. */
  71711. get computeBoundingBox(): boolean;
  71712. /**
  71713. * This function does nothing. It may be overwritten to set all the particle first values.
  71714. * The PCS doesn't call this function, you may have to call it by your own.
  71715. * doc :
  71716. */
  71717. initParticles(): void;
  71718. /**
  71719. * This function does nothing. It may be overwritten to recycle a particle
  71720. * The PCS doesn't call this function, you can to call it
  71721. * doc :
  71722. * @param particle The particle to recycle
  71723. * @returns the recycled particle
  71724. */
  71725. recycleParticle(particle: CloudPoint): CloudPoint;
  71726. /**
  71727. * Updates a particle : this function should be overwritten by the user.
  71728. * It is called on each particle by `setParticles()`. This is the place to code each particle behavior.
  71729. * doc :
  71730. * @example : just set a particle position or velocity and recycle conditions
  71731. * @param particle The particle to update
  71732. * @returns the updated particle
  71733. */
  71734. updateParticle(particle: CloudPoint): CloudPoint;
  71735. /**
  71736. * This will be called before any other treatment by `setParticles()` and will be passed three parameters.
  71737. * This does nothing and may be overwritten by the user.
  71738. * @param start the particle index in the particle array where to start to iterate, same than the value passed to setParticle()
  71739. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  71740. * @param update the boolean update value actually passed to setParticles()
  71741. */
  71742. beforeUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  71743. /**
  71744. * This will be called by `setParticles()` after all the other treatments and just before the actual mesh update.
  71745. * This will be passed three parameters.
  71746. * This does nothing and may be overwritten by the user.
  71747. * @param start the particle index in the particle array where to start to iterate, same than the value passed to setParticle()
  71748. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  71749. * @param update the boolean update value actually passed to setParticles()
  71750. */
  71751. afterUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  71752. }
  71753. }
  71754. declare module "babylonjs/Particles/cloudPoint" {
  71755. import { Nullable } from "babylonjs/types";
  71756. import { Color4, Vector2, Vector3, Matrix, Quaternion } from "babylonjs/Maths/math";
  71757. import { Mesh } from "babylonjs/Meshes/mesh";
  71758. import { BoundingInfo } from "babylonjs/Culling/boundingInfo";
  71759. import { PointsCloudSystem } from "babylonjs/Particles/pointsCloudSystem";
  71760. /**
  71761. * Represents one particle of a points cloud system.
  71762. */
  71763. export class CloudPoint {
  71764. /**
  71765. * particle global index
  71766. */
  71767. idx: number;
  71768. /**
  71769. * The color of the particle
  71770. */
  71771. color: Nullable<Color4>;
  71772. /**
  71773. * The world space position of the particle.
  71774. */
  71775. position: Vector3;
  71776. /**
  71777. * The world space rotation of the particle. (Not use if rotationQuaternion is set)
  71778. */
  71779. rotation: Vector3;
  71780. /**
  71781. * The world space rotation quaternion of the particle.
  71782. */
  71783. rotationQuaternion: Nullable<Quaternion>;
  71784. /**
  71785. * The uv of the particle.
  71786. */
  71787. uv: Nullable<Vector2>;
  71788. /**
  71789. * The current speed of the particle.
  71790. */
  71791. velocity: Vector3;
  71792. /**
  71793. * The pivot point in the particle local space.
  71794. */
  71795. pivot: Vector3;
  71796. /**
  71797. * Must the particle be translated from its pivot point in its local space ?
  71798. * In this case, the pivot point is set at the origin of the particle local space and the particle is translated.
  71799. * Default : false
  71800. */
  71801. translateFromPivot: boolean;
  71802. /**
  71803. * Index of this particle in the global "positions" array (Internal use)
  71804. * @hidden
  71805. */
  71806. _pos: number;
  71807. /**
  71808. * @hidden Index of this particle in the global "indices" array (Internal use)
  71809. */
  71810. _ind: number;
  71811. /**
  71812. * Group this particle belongs to
  71813. */
  71814. _group: PointsGroup;
  71815. /**
  71816. * Group id of this particle
  71817. */
  71818. groupId: number;
  71819. /**
  71820. * Index of the particle in its group id (Internal use)
  71821. */
  71822. idxInGroup: number;
  71823. /**
  71824. * @hidden Particle BoundingInfo object (Internal use)
  71825. */
  71826. _boundingInfo: BoundingInfo;
  71827. /**
  71828. * @hidden Reference to the PCS that the particle belongs to (Internal use)
  71829. */
  71830. _pcs: PointsCloudSystem;
  71831. /**
  71832. * @hidden Still set as invisible in order to skip useless computations (Internal use)
  71833. */
  71834. _stillInvisible: boolean;
  71835. /**
  71836. * @hidden Last computed particle rotation matrix
  71837. */
  71838. _rotationMatrix: number[];
  71839. /**
  71840. * Parent particle Id, if any.
  71841. * Default null.
  71842. */
  71843. parentId: Nullable<number>;
  71844. /**
  71845. * @hidden Internal global position in the PCS.
  71846. */
  71847. _globalPosition: Vector3;
  71848. /**
  71849. * Creates a Point Cloud object.
  71850. * Don't create particles manually, use instead the PCS internal tools like _addParticle()
  71851. * @param particleIndex (integer) is the particle index in the PCS pool. It's also the particle identifier.
  71852. * @param group (PointsGroup) is the group the particle belongs to
  71853. * @param groupId (integer) is the group identifier in the PCS.
  71854. * @param idxInGroup (integer) is the index of the particle in the current point group (ex: the 10th point of addPoints(30))
  71855. * @param pcs defines the PCS it is associated to
  71856. */
  71857. constructor(particleIndex: number, group: PointsGroup, groupId: number, idxInGroup: number, pcs: PointsCloudSystem);
  71858. /**
  71859. * get point size
  71860. */
  71861. get size(): Vector3;
  71862. /**
  71863. * Set point size
  71864. */
  71865. set size(scale: Vector3);
  71866. /**
  71867. * Legacy support, changed quaternion to rotationQuaternion
  71868. */
  71869. get quaternion(): Nullable<Quaternion>;
  71870. /**
  71871. * Legacy support, changed quaternion to rotationQuaternion
  71872. */
  71873. set quaternion(q: Nullable<Quaternion>);
  71874. /**
  71875. * Returns a boolean. True if the particle intersects a mesh, else false
  71876. * The intersection is computed on the particle position and Axis Aligned Bounding Box (AABB) or Sphere
  71877. * @param target is the object (point or mesh) what the intersection is computed against
  71878. * @param isSphere is boolean flag when false (default) bounding box of mesh is used, when true the bouding sphere is used
  71879. * @returns true if it intersects
  71880. */
  71881. intersectsMesh(target: Mesh, isSphere: boolean): boolean;
  71882. /**
  71883. * get the rotation matrix of the particle
  71884. * @hidden
  71885. */
  71886. getRotationMatrix(m: Matrix): void;
  71887. }
  71888. /**
  71889. * Represents a group of points in a points cloud system
  71890. * * PCS internal tool, don't use it manually.
  71891. */
  71892. export class PointsGroup {
  71893. /**
  71894. * The group id
  71895. * @hidden
  71896. */
  71897. groupID: number;
  71898. /**
  71899. * image data for group (internal use)
  71900. * @hidden
  71901. */
  71902. _groupImageData: Nullable<ArrayBufferView>;
  71903. /**
  71904. * Image Width (internal use)
  71905. * @hidden
  71906. */
  71907. _groupImgWidth: number;
  71908. /**
  71909. * Image Height (internal use)
  71910. * @hidden
  71911. */
  71912. _groupImgHeight: number;
  71913. /**
  71914. * Custom position function (internal use)
  71915. * @hidden
  71916. */
  71917. _positionFunction: Nullable<(particle: CloudPoint, i?: number, s?: number) => void>;
  71918. /**
  71919. * density per facet for surface points
  71920. * @hidden
  71921. */
  71922. _groupDensity: number[];
  71923. /**
  71924. * Only when points are colored by texture carries pointer to texture list array
  71925. * @hidden
  71926. */
  71927. _textureNb: number;
  71928. /**
  71929. * Creates a points group object. This is an internal reference to produce particles for the PCS.
  71930. * PCS internal tool, don't use it manually.
  71931. * @hidden
  71932. */
  71933. constructor(id: number, posFunction: Nullable<(particle: CloudPoint, i?: number, s?: number) => void>);
  71934. }
  71935. }
  71936. declare module "babylonjs/Particles/index" {
  71937. export * from "babylonjs/Particles/baseParticleSystem";
  71938. export * from "babylonjs/Particles/EmitterTypes/index";
  71939. export * from "babylonjs/Particles/gpuParticleSystem";
  71940. export * from "babylonjs/Particles/IParticleSystem";
  71941. export * from "babylonjs/Particles/particle";
  71942. export * from "babylonjs/Particles/particleHelper";
  71943. export * from "babylonjs/Particles/particleSystem";
  71944. import "babylonjs/Particles/particleSystemComponent";
  71945. export * from "babylonjs/Particles/particleSystemComponent";
  71946. export * from "babylonjs/Particles/particleSystemSet";
  71947. export * from "babylonjs/Particles/solidParticle";
  71948. export * from "babylonjs/Particles/solidParticleSystem";
  71949. export * from "babylonjs/Particles/cloudPoint";
  71950. export * from "babylonjs/Particles/pointsCloudSystem";
  71951. export * from "babylonjs/Particles/subEmitter";
  71952. }
  71953. declare module "babylonjs/Physics/physicsEngineComponent" {
  71954. import { Nullable } from "babylonjs/types";
  71955. import { Observable, Observer } from "babylonjs/Misc/observable";
  71956. import { Vector3 } from "babylonjs/Maths/math.vector";
  71957. import { Mesh } from "babylonjs/Meshes/mesh";
  71958. import { ISceneComponent } from "babylonjs/sceneComponent";
  71959. import { Scene } from "babylonjs/scene";
  71960. import { Node } from "babylonjs/node";
  71961. import { IPhysicsEngine, IPhysicsEnginePlugin } from "babylonjs/Physics/IPhysicsEngine";
  71962. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  71963. module "babylonjs/scene" {
  71964. interface Scene {
  71965. /** @hidden (Backing field) */
  71966. _physicsEngine: Nullable<IPhysicsEngine>;
  71967. /** @hidden */
  71968. _physicsTimeAccumulator: number;
  71969. /**
  71970. * Gets the current physics engine
  71971. * @returns a IPhysicsEngine or null if none attached
  71972. */
  71973. getPhysicsEngine(): Nullable<IPhysicsEngine>;
  71974. /**
  71975. * Enables physics to the current scene
  71976. * @param gravity defines the scene's gravity for the physics engine
  71977. * @param plugin defines the physics engine to be used. defaults to OimoJS.
  71978. * @return a boolean indicating if the physics engine was initialized
  71979. */
  71980. enablePhysics(gravity: Nullable<Vector3>, plugin?: IPhysicsEnginePlugin): boolean;
  71981. /**
  71982. * Disables and disposes the physics engine associated with the scene
  71983. */
  71984. disablePhysicsEngine(): void;
  71985. /**
  71986. * Gets a boolean indicating if there is an active physics engine
  71987. * @returns a boolean indicating if there is an active physics engine
  71988. */
  71989. isPhysicsEnabled(): boolean;
  71990. /**
  71991. * Deletes a physics compound impostor
  71992. * @param compound defines the compound to delete
  71993. */
  71994. deleteCompoundImpostor(compound: any): void;
  71995. /**
  71996. * An event triggered when physic simulation is about to be run
  71997. */
  71998. onBeforePhysicsObservable: Observable<Scene>;
  71999. /**
  72000. * An event triggered when physic simulation has been done
  72001. */
  72002. onAfterPhysicsObservable: Observable<Scene>;
  72003. }
  72004. }
  72005. module "babylonjs/Meshes/abstractMesh" {
  72006. interface AbstractMesh {
  72007. /** @hidden */
  72008. _physicsImpostor: Nullable<PhysicsImpostor>;
  72009. /**
  72010. * Gets or sets impostor used for physic simulation
  72011. * @see https://doc.babylonjs.com/features/physics_engine
  72012. */
  72013. physicsImpostor: Nullable<PhysicsImpostor>;
  72014. /**
  72015. * Gets the current physics impostor
  72016. * @see https://doc.babylonjs.com/features/physics_engine
  72017. * @returns a physics impostor or null
  72018. */
  72019. getPhysicsImpostor(): Nullable<PhysicsImpostor>;
  72020. /** Apply a physic impulse to the mesh
  72021. * @param force defines the force to apply
  72022. * @param contactPoint defines where to apply the force
  72023. * @returns the current mesh
  72024. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  72025. */
  72026. applyImpulse(force: Vector3, contactPoint: Vector3): AbstractMesh;
  72027. /**
  72028. * Creates a physic joint between two meshes
  72029. * @param otherMesh defines the other mesh to use
  72030. * @param pivot1 defines the pivot to use on this mesh
  72031. * @param pivot2 defines the pivot to use on the other mesh
  72032. * @param options defines additional options (can be plugin dependent)
  72033. * @returns the current mesh
  72034. * @see https://www.babylonjs-playground.com/#0BS5U0#0
  72035. */
  72036. setPhysicsLinkWith(otherMesh: Mesh, pivot1: Vector3, pivot2: Vector3, options?: any): AbstractMesh;
  72037. /** @hidden */
  72038. _disposePhysicsObserver: Nullable<Observer<Node>>;
  72039. }
  72040. }
  72041. /**
  72042. * Defines the physics engine scene component responsible to manage a physics engine
  72043. */
  72044. export class PhysicsEngineSceneComponent implements ISceneComponent {
  72045. /**
  72046. * The component name helpful to identify the component in the list of scene components.
  72047. */
  72048. readonly name: string;
  72049. /**
  72050. * The scene the component belongs to.
  72051. */
  72052. scene: Scene;
  72053. /**
  72054. * Creates a new instance of the component for the given scene
  72055. * @param scene Defines the scene to register the component in
  72056. */
  72057. constructor(scene: Scene);
  72058. /**
  72059. * Registers the component in a given scene
  72060. */
  72061. register(): void;
  72062. /**
  72063. * Rebuilds the elements related to this component in case of
  72064. * context lost for instance.
  72065. */
  72066. rebuild(): void;
  72067. /**
  72068. * Disposes the component and the associated ressources
  72069. */
  72070. dispose(): void;
  72071. }
  72072. }
  72073. declare module "babylonjs/Physics/physicsHelper" {
  72074. import { Nullable } from "babylonjs/types";
  72075. import { Vector3 } from "babylonjs/Maths/math.vector";
  72076. import { Mesh } from "babylonjs/Meshes/mesh";
  72077. import { Scene } from "babylonjs/scene";
  72078. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  72079. /**
  72080. * A helper for physics simulations
  72081. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  72082. */
  72083. export class PhysicsHelper {
  72084. private _scene;
  72085. private _physicsEngine;
  72086. /**
  72087. * Initializes the Physics helper
  72088. * @param scene Babylon.js scene
  72089. */
  72090. constructor(scene: Scene);
  72091. /**
  72092. * Applies a radial explosion impulse
  72093. * @param origin the origin of the explosion
  72094. * @param radiusOrEventOptions the radius or the options of radial explosion
  72095. * @param strength the explosion strength
  72096. * @param falloff possible options: Constant & Linear. Defaults to Constant
  72097. * @returns A physics radial explosion event, or null
  72098. */
  72099. applyRadialExplosionImpulse(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  72100. /**
  72101. * Applies a radial explosion force
  72102. * @param origin the origin of the explosion
  72103. * @param radiusOrEventOptions the radius or the options of radial explosion
  72104. * @param strength the explosion strength
  72105. * @param falloff possible options: Constant & Linear. Defaults to Constant
  72106. * @returns A physics radial explosion event, or null
  72107. */
  72108. applyRadialExplosionForce(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  72109. /**
  72110. * Creates a gravitational field
  72111. * @param origin the origin of the explosion
  72112. * @param radiusOrEventOptions the radius or the options of radial explosion
  72113. * @param strength the explosion strength
  72114. * @param falloff possible options: Constant & Linear. Defaults to Constant
  72115. * @returns A physics gravitational field event, or null
  72116. */
  72117. gravitationalField(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsGravitationalFieldEvent>;
  72118. /**
  72119. * Creates a physics updraft event
  72120. * @param origin the origin of the updraft
  72121. * @param radiusOrEventOptions the radius or the options of the updraft
  72122. * @param strength the strength of the updraft
  72123. * @param height the height of the updraft
  72124. * @param updraftMode possible options: Center & Perpendicular. Defaults to Center
  72125. * @returns A physics updraft event, or null
  72126. */
  72127. updraft(origin: Vector3, radiusOrEventOptions: number | PhysicsUpdraftEventOptions, strength?: number, height?: number, updraftMode?: PhysicsUpdraftMode): Nullable<PhysicsUpdraftEvent>;
  72128. /**
  72129. * Creates a physics vortex event
  72130. * @param origin the of the vortex
  72131. * @param radiusOrEventOptions the radius or the options of the vortex
  72132. * @param strength the strength of the vortex
  72133. * @param height the height of the vortex
  72134. * @returns a Physics vortex event, or null
  72135. * A physics vortex event or null
  72136. */
  72137. vortex(origin: Vector3, radiusOrEventOptions: number | PhysicsVortexEventOptions, strength?: number, height?: number): Nullable<PhysicsVortexEvent>;
  72138. }
  72139. /**
  72140. * Represents a physics radial explosion event
  72141. */
  72142. class PhysicsRadialExplosionEvent {
  72143. private _scene;
  72144. private _options;
  72145. private _sphere;
  72146. private _dataFetched;
  72147. /**
  72148. * Initializes a radial explosioin event
  72149. * @param _scene BabylonJS scene
  72150. * @param _options The options for the vortex event
  72151. */
  72152. constructor(_scene: Scene, _options: PhysicsRadialExplosionEventOptions);
  72153. /**
  72154. * Returns the data related to the radial explosion event (sphere).
  72155. * @returns The radial explosion event data
  72156. */
  72157. getData(): PhysicsRadialExplosionEventData;
  72158. /**
  72159. * Returns the force and contact point of the impostor or false, if the impostor is not affected by the force/impulse.
  72160. * @param impostor A physics imposter
  72161. * @param origin the origin of the explosion
  72162. * @returns {Nullable<PhysicsHitData>} A physics force and contact point, or null
  72163. */
  72164. getImpostorHitData(impostor: PhysicsImpostor, origin: Vector3): Nullable<PhysicsHitData>;
  72165. /**
  72166. * Triggers affecterd impostors callbacks
  72167. * @param affectedImpostorsWithData defines the list of affected impostors (including associated data)
  72168. */
  72169. triggerAffectedImpostorsCallback(affectedImpostorsWithData: Array<PhysicsAffectedImpostorWithData>): void;
  72170. /**
  72171. * Disposes the sphere.
  72172. * @param force Specifies if the sphere should be disposed by force
  72173. */
  72174. dispose(force?: boolean): void;
  72175. /*** Helpers ***/
  72176. private _prepareSphere;
  72177. private _intersectsWithSphere;
  72178. }
  72179. /**
  72180. * Represents a gravitational field event
  72181. */
  72182. class PhysicsGravitationalFieldEvent {
  72183. private _physicsHelper;
  72184. private _scene;
  72185. private _origin;
  72186. private _options;
  72187. private _tickCallback;
  72188. private _sphere;
  72189. private _dataFetched;
  72190. /**
  72191. * Initializes the physics gravitational field event
  72192. * @param _physicsHelper A physics helper
  72193. * @param _scene BabylonJS scene
  72194. * @param _origin The origin position of the gravitational field event
  72195. * @param _options The options for the vortex event
  72196. */
  72197. constructor(_physicsHelper: PhysicsHelper, _scene: Scene, _origin: Vector3, _options: PhysicsRadialExplosionEventOptions);
  72198. /**
  72199. * Returns the data related to the gravitational field event (sphere).
  72200. * @returns A gravitational field event
  72201. */
  72202. getData(): PhysicsGravitationalFieldEventData;
  72203. /**
  72204. * Enables the gravitational field.
  72205. */
  72206. enable(): void;
  72207. /**
  72208. * Disables the gravitational field.
  72209. */
  72210. disable(): void;
  72211. /**
  72212. * Disposes the sphere.
  72213. * @param force The force to dispose from the gravitational field event
  72214. */
  72215. dispose(force?: boolean): void;
  72216. private _tick;
  72217. }
  72218. /**
  72219. * Represents a physics updraft event
  72220. */
  72221. class PhysicsUpdraftEvent {
  72222. private _scene;
  72223. private _origin;
  72224. private _options;
  72225. private _physicsEngine;
  72226. private _originTop;
  72227. private _originDirection;
  72228. private _tickCallback;
  72229. private _cylinder;
  72230. private _cylinderPosition;
  72231. private _dataFetched;
  72232. /**
  72233. * Initializes the physics updraft event
  72234. * @param _scene BabylonJS scene
  72235. * @param _origin The origin position of the updraft
  72236. * @param _options The options for the updraft event
  72237. */
  72238. constructor(_scene: Scene, _origin: Vector3, _options: PhysicsUpdraftEventOptions);
  72239. /**
  72240. * Returns the data related to the updraft event (cylinder).
  72241. * @returns A physics updraft event
  72242. */
  72243. getData(): PhysicsUpdraftEventData;
  72244. /**
  72245. * Enables the updraft.
  72246. */
  72247. enable(): void;
  72248. /**
  72249. * Disables the updraft.
  72250. */
  72251. disable(): void;
  72252. /**
  72253. * Disposes the cylinder.
  72254. * @param force Specifies if the updraft should be disposed by force
  72255. */
  72256. dispose(force?: boolean): void;
  72257. private getImpostorHitData;
  72258. private _tick;
  72259. /*** Helpers ***/
  72260. private _prepareCylinder;
  72261. private _intersectsWithCylinder;
  72262. }
  72263. /**
  72264. * Represents a physics vortex event
  72265. */
  72266. class PhysicsVortexEvent {
  72267. private _scene;
  72268. private _origin;
  72269. private _options;
  72270. private _physicsEngine;
  72271. private _originTop;
  72272. private _tickCallback;
  72273. private _cylinder;
  72274. private _cylinderPosition;
  72275. private _dataFetched;
  72276. /**
  72277. * Initializes the physics vortex event
  72278. * @param _scene The BabylonJS scene
  72279. * @param _origin The origin position of the vortex
  72280. * @param _options The options for the vortex event
  72281. */
  72282. constructor(_scene: Scene, _origin: Vector3, _options: PhysicsVortexEventOptions);
  72283. /**
  72284. * Returns the data related to the vortex event (cylinder).
  72285. * @returns The physics vortex event data
  72286. */
  72287. getData(): PhysicsVortexEventData;
  72288. /**
  72289. * Enables the vortex.
  72290. */
  72291. enable(): void;
  72292. /**
  72293. * Disables the cortex.
  72294. */
  72295. disable(): void;
  72296. /**
  72297. * Disposes the sphere.
  72298. * @param force
  72299. */
  72300. dispose(force?: boolean): void;
  72301. private getImpostorHitData;
  72302. private _tick;
  72303. /*** Helpers ***/
  72304. private _prepareCylinder;
  72305. private _intersectsWithCylinder;
  72306. }
  72307. /**
  72308. * Options fot the radial explosion event
  72309. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  72310. */
  72311. export class PhysicsRadialExplosionEventOptions {
  72312. /**
  72313. * The radius of the sphere for the radial explosion.
  72314. */
  72315. radius: number;
  72316. /**
  72317. * The strenth of the explosion.
  72318. */
  72319. strength: number;
  72320. /**
  72321. * The strenght of the force in correspondence to the distance of the affected object
  72322. */
  72323. falloff: PhysicsRadialImpulseFalloff;
  72324. /**
  72325. * Sphere options for the radial explosion.
  72326. */
  72327. sphere: {
  72328. segments: number;
  72329. diameter: number;
  72330. };
  72331. /**
  72332. * Sphere options for the radial explosion.
  72333. */
  72334. affectedImpostorsCallback: (affectedImpostorsWithData: Array<PhysicsAffectedImpostorWithData>) => void;
  72335. }
  72336. /**
  72337. * Options fot the updraft event
  72338. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  72339. */
  72340. export class PhysicsUpdraftEventOptions {
  72341. /**
  72342. * The radius of the cylinder for the vortex
  72343. */
  72344. radius: number;
  72345. /**
  72346. * The strenth of the updraft.
  72347. */
  72348. strength: number;
  72349. /**
  72350. * The height of the cylinder for the updraft.
  72351. */
  72352. height: number;
  72353. /**
  72354. * The mode for the the updraft.
  72355. */
  72356. updraftMode: PhysicsUpdraftMode;
  72357. }
  72358. /**
  72359. * Options fot the vortex event
  72360. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  72361. */
  72362. export class PhysicsVortexEventOptions {
  72363. /**
  72364. * The radius of the cylinder for the vortex
  72365. */
  72366. radius: number;
  72367. /**
  72368. * The strenth of the vortex.
  72369. */
  72370. strength: number;
  72371. /**
  72372. * The height of the cylinder for the vortex.
  72373. */
  72374. height: number;
  72375. /**
  72376. * At which distance, relative to the radius the centripetal forces should kick in? Range: 0-1
  72377. */
  72378. centripetalForceThreshold: number;
  72379. /**
  72380. * This multiplier determines with how much force the objects will be pushed sideways/around the vortex, when below the treshold.
  72381. */
  72382. centripetalForceMultiplier: number;
  72383. /**
  72384. * This multiplier determines with how much force the objects will be pushed sideways/around the vortex, when above the treshold.
  72385. */
  72386. centrifugalForceMultiplier: number;
  72387. /**
  72388. * This multiplier determines with how much force the objects will be pushed upwards, when in the vortex.
  72389. */
  72390. updraftForceMultiplier: number;
  72391. }
  72392. /**
  72393. * The strenght of the force in correspondence to the distance of the affected object
  72394. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  72395. */
  72396. export enum PhysicsRadialImpulseFalloff {
  72397. /** Defines that impulse is constant in strength across it's whole radius */
  72398. Constant = 0,
  72399. /** Defines that impulse gets weaker if it's further from the origin */
  72400. Linear = 1
  72401. }
  72402. /**
  72403. * The strength of the force in correspondence to the distance of the affected object
  72404. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  72405. */
  72406. export enum PhysicsUpdraftMode {
  72407. /** Defines that the upstream forces will pull towards the top center of the cylinder */
  72408. Center = 0,
  72409. /** Defines that once a impostor is inside the cylinder, it will shoot out perpendicular from the ground of the cylinder */
  72410. Perpendicular = 1
  72411. }
  72412. /**
  72413. * Interface for a physics hit data
  72414. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  72415. */
  72416. export interface PhysicsHitData {
  72417. /**
  72418. * The force applied at the contact point
  72419. */
  72420. force: Vector3;
  72421. /**
  72422. * The contact point
  72423. */
  72424. contactPoint: Vector3;
  72425. /**
  72426. * The distance from the origin to the contact point
  72427. */
  72428. distanceFromOrigin: number;
  72429. }
  72430. /**
  72431. * Interface for radial explosion event data
  72432. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  72433. */
  72434. export interface PhysicsRadialExplosionEventData {
  72435. /**
  72436. * A sphere used for the radial explosion event
  72437. */
  72438. sphere: Mesh;
  72439. }
  72440. /**
  72441. * Interface for gravitational field event data
  72442. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  72443. */
  72444. export interface PhysicsGravitationalFieldEventData {
  72445. /**
  72446. * A sphere mesh used for the gravitational field event
  72447. */
  72448. sphere: Mesh;
  72449. }
  72450. /**
  72451. * Interface for updraft event data
  72452. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  72453. */
  72454. export interface PhysicsUpdraftEventData {
  72455. /**
  72456. * A cylinder used for the updraft event
  72457. */
  72458. cylinder: Mesh;
  72459. }
  72460. /**
  72461. * Interface for vortex event data
  72462. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  72463. */
  72464. export interface PhysicsVortexEventData {
  72465. /**
  72466. * A cylinder used for the vortex event
  72467. */
  72468. cylinder: Mesh;
  72469. }
  72470. /**
  72471. * Interface for an affected physics impostor
  72472. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  72473. */
  72474. export interface PhysicsAffectedImpostorWithData {
  72475. /**
  72476. * The impostor affected by the effect
  72477. */
  72478. impostor: PhysicsImpostor;
  72479. /**
  72480. * The data about the hit/horce from the explosion
  72481. */
  72482. hitData: PhysicsHitData;
  72483. }
  72484. }
  72485. declare module "babylonjs/Physics/Plugins/index" {
  72486. export * from "babylonjs/Physics/Plugins/cannonJSPlugin";
  72487. export * from "babylonjs/Physics/Plugins/ammoJSPlugin";
  72488. export * from "babylonjs/Physics/Plugins/oimoJSPlugin";
  72489. }
  72490. declare module "babylonjs/Physics/index" {
  72491. export * from "babylonjs/Physics/IPhysicsEngine";
  72492. export * from "babylonjs/Physics/physicsEngine";
  72493. export * from "babylonjs/Physics/physicsEngineComponent";
  72494. export * from "babylonjs/Physics/physicsHelper";
  72495. export * from "babylonjs/Physics/physicsImpostor";
  72496. export * from "babylonjs/Physics/physicsJoint";
  72497. export * from "babylonjs/Physics/Plugins/index";
  72498. }
  72499. declare module "babylonjs/Shaders/blackAndWhite.fragment" {
  72500. /** @hidden */
  72501. export var blackAndWhitePixelShader: {
  72502. name: string;
  72503. shader: string;
  72504. };
  72505. }
  72506. declare module "babylonjs/PostProcesses/blackAndWhitePostProcess" {
  72507. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  72508. import { Camera } from "babylonjs/Cameras/camera";
  72509. import { Engine } from "babylonjs/Engines/engine";
  72510. import "babylonjs/Shaders/blackAndWhite.fragment";
  72511. import { Nullable } from "babylonjs/types";
  72512. import { Scene } from "babylonjs/scene";
  72513. /**
  72514. * Post process used to render in black and white
  72515. */
  72516. export class BlackAndWhitePostProcess extends PostProcess {
  72517. /**
  72518. * Linear about to convert he result to black and white (default: 1)
  72519. */
  72520. degree: number;
  72521. /**
  72522. * Gets a string identifying the name of the class
  72523. * @returns "BlackAndWhitePostProcess" string
  72524. */
  72525. getClassName(): string;
  72526. /**
  72527. * Creates a black and white post process
  72528. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#black-and-white
  72529. * @param name The name of the effect.
  72530. * @param options The required width/height ratio to downsize to before computing the render pass.
  72531. * @param camera The camera to apply the render pass to.
  72532. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  72533. * @param engine The engine which the post process will be applied. (default: current engine)
  72534. * @param reusable If the post process can be reused on the same frame. (default: false)
  72535. */
  72536. constructor(name: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  72537. /** @hidden */
  72538. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): Nullable<BlackAndWhitePostProcess>;
  72539. }
  72540. }
  72541. declare module "babylonjs/PostProcesses/RenderPipeline/postProcessRenderEffect" {
  72542. import { Nullable } from "babylonjs/types";
  72543. import { Camera } from "babylonjs/Cameras/camera";
  72544. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  72545. import { Engine } from "babylonjs/Engines/engine";
  72546. /**
  72547. * This represents a set of one or more post processes in Babylon.
  72548. * A post process can be used to apply a shader to a texture after it is rendered.
  72549. * @example https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  72550. */
  72551. export class PostProcessRenderEffect {
  72552. private _postProcesses;
  72553. private _getPostProcesses;
  72554. private _singleInstance;
  72555. private _cameras;
  72556. private _indicesForCamera;
  72557. /**
  72558. * Name of the effect
  72559. * @hidden
  72560. */
  72561. _name: string;
  72562. /**
  72563. * Instantiates a post process render effect.
  72564. * A post process can be used to apply a shader to a texture after it is rendered.
  72565. * @param engine The engine the effect is tied to
  72566. * @param name The name of the effect
  72567. * @param getPostProcesses A function that returns a set of post processes which the effect will run in order to be run.
  72568. * @param singleInstance False if this post process can be run on multiple cameras. (default: true)
  72569. */
  72570. constructor(engine: Engine, name: string, getPostProcesses: () => Nullable<PostProcess | Array<PostProcess>>, singleInstance?: boolean);
  72571. /**
  72572. * Checks if all the post processes in the effect are supported.
  72573. */
  72574. get isSupported(): boolean;
  72575. /**
  72576. * Updates the current state of the effect
  72577. * @hidden
  72578. */
  72579. _update(): void;
  72580. /**
  72581. * Attaches the effect on cameras
  72582. * @param cameras The camera to attach to.
  72583. * @hidden
  72584. */
  72585. _attachCameras(cameras: Camera): void;
  72586. /**
  72587. * Attaches the effect on cameras
  72588. * @param cameras The camera to attach to.
  72589. * @hidden
  72590. */
  72591. _attachCameras(cameras: Camera[]): void;
  72592. /**
  72593. * Detaches the effect on cameras
  72594. * @param cameras The camera to detatch from.
  72595. * @hidden
  72596. */
  72597. _detachCameras(cameras: Camera): void;
  72598. /**
  72599. * Detatches the effect on cameras
  72600. * @param cameras The camera to detatch from.
  72601. * @hidden
  72602. */
  72603. _detachCameras(cameras: Camera[]): void;
  72604. /**
  72605. * Enables the effect on given cameras
  72606. * @param cameras The camera to enable.
  72607. * @hidden
  72608. */
  72609. _enable(cameras: Camera): void;
  72610. /**
  72611. * Enables the effect on given cameras
  72612. * @param cameras The camera to enable.
  72613. * @hidden
  72614. */
  72615. _enable(cameras: Nullable<Camera[]>): void;
  72616. /**
  72617. * Disables the effect on the given cameras
  72618. * @param cameras The camera to disable.
  72619. * @hidden
  72620. */
  72621. _disable(cameras: Camera): void;
  72622. /**
  72623. * Disables the effect on the given cameras
  72624. * @param cameras The camera to disable.
  72625. * @hidden
  72626. */
  72627. _disable(cameras: Nullable<Camera[]>): void;
  72628. /**
  72629. * Gets a list of the post processes contained in the effect.
  72630. * @param camera The camera to get the post processes on.
  72631. * @returns The list of the post processes in the effect.
  72632. */
  72633. getPostProcesses(camera?: Camera): Nullable<Array<PostProcess>>;
  72634. }
  72635. }
  72636. declare module "babylonjs/Shaders/extractHighlights.fragment" {
  72637. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  72638. /** @hidden */
  72639. export var extractHighlightsPixelShader: {
  72640. name: string;
  72641. shader: string;
  72642. };
  72643. }
  72644. declare module "babylonjs/PostProcesses/extractHighlightsPostProcess" {
  72645. import { Nullable } from "babylonjs/types";
  72646. import { Camera } from "babylonjs/Cameras/camera";
  72647. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  72648. import { Engine } from "babylonjs/Engines/engine";
  72649. import "babylonjs/Shaders/extractHighlights.fragment";
  72650. /**
  72651. * 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.
  72652. */
  72653. export class ExtractHighlightsPostProcess extends PostProcess {
  72654. /**
  72655. * The luminance threshold, pixels below this value will be set to black.
  72656. */
  72657. threshold: number;
  72658. /** @hidden */
  72659. _exposure: number;
  72660. /**
  72661. * Post process which has the input texture to be used when performing highlight extraction
  72662. * @hidden
  72663. */
  72664. _inputPostProcess: Nullable<PostProcess>;
  72665. /**
  72666. * Gets a string identifying the name of the class
  72667. * @returns "ExtractHighlightsPostProcess" string
  72668. */
  72669. getClassName(): string;
  72670. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  72671. }
  72672. }
  72673. declare module "babylonjs/Shaders/bloomMerge.fragment" {
  72674. /** @hidden */
  72675. export var bloomMergePixelShader: {
  72676. name: string;
  72677. shader: string;
  72678. };
  72679. }
  72680. declare module "babylonjs/PostProcesses/bloomMergePostProcess" {
  72681. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  72682. import { Nullable } from "babylonjs/types";
  72683. import { Engine } from "babylonjs/Engines/engine";
  72684. import { Camera } from "babylonjs/Cameras/camera";
  72685. import "babylonjs/Shaders/bloomMerge.fragment";
  72686. /**
  72687. * The BloomMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  72688. */
  72689. export class BloomMergePostProcess extends PostProcess {
  72690. /** Weight of the bloom to be added to the original input. */
  72691. weight: number;
  72692. /**
  72693. * Gets a string identifying the name of the class
  72694. * @returns "BloomMergePostProcess" string
  72695. */
  72696. getClassName(): string;
  72697. /**
  72698. * Creates a new instance of @see BloomMergePostProcess
  72699. * @param name The name of the effect.
  72700. * @param originalFromInput Post process which's input will be used for the merge.
  72701. * @param blurred Blurred highlights post process which's output will be used.
  72702. * @param weight Weight of the bloom to be added to the original input.
  72703. * @param options The required width/height ratio to downsize to before computing the render pass.
  72704. * @param camera The camera to apply the render pass to.
  72705. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  72706. * @param engine The engine which the post process will be applied. (default: current engine)
  72707. * @param reusable If the post process can be reused on the same frame. (default: false)
  72708. * @param textureType Type of textures used when performing the post process. (default: 0)
  72709. * @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)
  72710. */
  72711. constructor(name: string, originalFromInput: PostProcess, blurred: PostProcess,
  72712. /** Weight of the bloom to be added to the original input. */
  72713. weight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  72714. }
  72715. }
  72716. declare module "babylonjs/PostProcesses/bloomEffect" {
  72717. import { PostProcessRenderEffect } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderEffect";
  72718. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  72719. import { ExtractHighlightsPostProcess } from "babylonjs/PostProcesses/extractHighlightsPostProcess";
  72720. import { Camera } from "babylonjs/Cameras/camera";
  72721. import { Scene } from "babylonjs/scene";
  72722. /**
  72723. * The bloom effect spreads bright areas of an image to simulate artifacts seen in cameras
  72724. */
  72725. export class BloomEffect extends PostProcessRenderEffect {
  72726. private bloomScale;
  72727. /**
  72728. * @hidden Internal
  72729. */
  72730. _effects: Array<PostProcess>;
  72731. /**
  72732. * @hidden Internal
  72733. */
  72734. _downscale: ExtractHighlightsPostProcess;
  72735. private _blurX;
  72736. private _blurY;
  72737. private _merge;
  72738. /**
  72739. * The luminance threshold to find bright areas of the image to bloom.
  72740. */
  72741. get threshold(): number;
  72742. set threshold(value: number);
  72743. /**
  72744. * The strength of the bloom.
  72745. */
  72746. get weight(): number;
  72747. set weight(value: number);
  72748. /**
  72749. * Specifies the size of the bloom blur kernel, relative to the final output size
  72750. */
  72751. get kernel(): number;
  72752. set kernel(value: number);
  72753. /**
  72754. * Creates a new instance of @see BloomEffect
  72755. * @param scene The scene the effect belongs to.
  72756. * @param bloomScale The ratio of the blur texture to the input texture that should be used to compute the bloom.
  72757. * @param bloomKernel The size of the kernel to be used when applying the blur.
  72758. * @param bloomWeight The the strength of bloom.
  72759. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  72760. * @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)
  72761. */
  72762. constructor(scene: Scene, bloomScale: number, bloomWeight: number, bloomKernel: number, pipelineTextureType?: number, blockCompilation?: boolean);
  72763. /**
  72764. * Disposes each of the internal effects for a given camera.
  72765. * @param camera The camera to dispose the effect on.
  72766. */
  72767. disposeEffects(camera: Camera): void;
  72768. /**
  72769. * @hidden Internal
  72770. */
  72771. _updateEffects(): void;
  72772. /**
  72773. * Internal
  72774. * @returns if all the contained post processes are ready.
  72775. * @hidden
  72776. */
  72777. _isReady(): boolean;
  72778. }
  72779. }
  72780. declare module "babylonjs/Shaders/chromaticAberration.fragment" {
  72781. /** @hidden */
  72782. export var chromaticAberrationPixelShader: {
  72783. name: string;
  72784. shader: string;
  72785. };
  72786. }
  72787. declare module "babylonjs/PostProcesses/chromaticAberrationPostProcess" {
  72788. import { Vector2 } from "babylonjs/Maths/math.vector";
  72789. import { Nullable } from "babylonjs/types";
  72790. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  72791. import { Camera } from "babylonjs/Cameras/camera";
  72792. import { Engine } from "babylonjs/Engines/engine";
  72793. import "babylonjs/Shaders/chromaticAberration.fragment";
  72794. import { Scene } from "babylonjs/scene";
  72795. /**
  72796. * The ChromaticAberrationPostProcess separates the rgb channels in an image to produce chromatic distortion around the edges of the screen
  72797. */
  72798. export class ChromaticAberrationPostProcess extends PostProcess {
  72799. /**
  72800. * The amount of seperation of rgb channels (default: 30)
  72801. */
  72802. aberrationAmount: number;
  72803. /**
  72804. * The amount the effect will increase for pixels closer to the edge of the screen. (default: 0)
  72805. */
  72806. radialIntensity: number;
  72807. /**
  72808. * 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))
  72809. */
  72810. direction: Vector2;
  72811. /**
  72812. * 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))
  72813. */
  72814. centerPosition: Vector2;
  72815. /** The width of the screen to apply the effect on */
  72816. screenWidth: number;
  72817. /** The height of the screen to apply the effect on */
  72818. screenHeight: number;
  72819. /**
  72820. * Gets a string identifying the name of the class
  72821. * @returns "ChromaticAberrationPostProcess" string
  72822. */
  72823. getClassName(): string;
  72824. /**
  72825. * Creates a new instance ChromaticAberrationPostProcess
  72826. * @param name The name of the effect.
  72827. * @param screenWidth The width of the screen to apply the effect on.
  72828. * @param screenHeight The height of the screen to apply the effect on.
  72829. * @param options The required width/height ratio to downsize to before computing the render pass.
  72830. * @param camera The camera to apply the render pass to.
  72831. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  72832. * @param engine The engine which the post process will be applied. (default: current engine)
  72833. * @param reusable If the post process can be reused on the same frame. (default: false)
  72834. * @param textureType Type of textures used when performing the post process. (default: 0)
  72835. * @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)
  72836. */
  72837. constructor(name: string, screenWidth: number, screenHeight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  72838. /** @hidden */
  72839. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): Nullable<ChromaticAberrationPostProcess>;
  72840. }
  72841. }
  72842. declare module "babylonjs/Shaders/circleOfConfusion.fragment" {
  72843. /** @hidden */
  72844. export var circleOfConfusionPixelShader: {
  72845. name: string;
  72846. shader: string;
  72847. };
  72848. }
  72849. declare module "babylonjs/PostProcesses/circleOfConfusionPostProcess" {
  72850. import { Nullable } from "babylonjs/types";
  72851. import { Engine } from "babylonjs/Engines/engine";
  72852. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  72853. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  72854. import { Camera } from "babylonjs/Cameras/camera";
  72855. import "babylonjs/Shaders/circleOfConfusion.fragment";
  72856. /**
  72857. * The CircleOfConfusionPostProcess computes the circle of confusion value for each pixel given required lens parameters. See https://en.wikipedia.org/wiki/Circle_of_confusion
  72858. */
  72859. export class CircleOfConfusionPostProcess extends PostProcess {
  72860. /**
  72861. * 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.
  72862. */
  72863. lensSize: number;
  72864. /**
  72865. * F-Stop of the effect's camera. The diamater of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  72866. */
  72867. fStop: number;
  72868. /**
  72869. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  72870. */
  72871. focusDistance: number;
  72872. /**
  72873. * Focal length of the effect's camera in scene units/1000 (eg. millimeter). (default: 50)
  72874. */
  72875. focalLength: number;
  72876. /**
  72877. * Gets a string identifying the name of the class
  72878. * @returns "CircleOfConfusionPostProcess" string
  72879. */
  72880. getClassName(): string;
  72881. private _depthTexture;
  72882. /**
  72883. * Creates a new instance CircleOfConfusionPostProcess
  72884. * @param name The name of the effect.
  72885. * @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.
  72886. * @param options The required width/height ratio to downsize to before computing the render pass.
  72887. * @param camera The camera to apply the render pass to.
  72888. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  72889. * @param engine The engine which the post process will be applied. (default: current engine)
  72890. * @param reusable If the post process can be reused on the same frame. (default: false)
  72891. * @param textureType Type of textures used when performing the post process. (default: 0)
  72892. * @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)
  72893. */
  72894. constructor(name: string, depthTexture: Nullable<RenderTargetTexture>, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  72895. /**
  72896. * 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.
  72897. */
  72898. set depthTexture(value: RenderTargetTexture);
  72899. }
  72900. }
  72901. declare module "babylonjs/Shaders/colorCorrection.fragment" {
  72902. /** @hidden */
  72903. export var colorCorrectionPixelShader: {
  72904. name: string;
  72905. shader: string;
  72906. };
  72907. }
  72908. declare module "babylonjs/PostProcesses/colorCorrectionPostProcess" {
  72909. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  72910. import { Engine } from "babylonjs/Engines/engine";
  72911. import { Camera } from "babylonjs/Cameras/camera";
  72912. import "babylonjs/Shaders/colorCorrection.fragment";
  72913. import { Nullable } from "babylonjs/types";
  72914. import { Scene } from "babylonjs/scene";
  72915. /**
  72916. *
  72917. * This post-process allows the modification of rendered colors by using
  72918. * a 'look-up table' (LUT). This effect is also called Color Grading.
  72919. *
  72920. * The object needs to be provided an url to a texture containing the color
  72921. * look-up table: the texture must be 256 pixels wide and 16 pixels high.
  72922. * Use an image editing software to tweak the LUT to match your needs.
  72923. *
  72924. * For an example of a color LUT, see here:
  72925. * @see http://udn.epicgames.com/Three/rsrc/Three/ColorGrading/RGBTable16x1.png
  72926. * For explanations on color grading, see here:
  72927. * @see http://udn.epicgames.com/Three/ColorGrading.html
  72928. *
  72929. */
  72930. export class ColorCorrectionPostProcess extends PostProcess {
  72931. private _colorTableTexture;
  72932. /**
  72933. * Gets the color table url used to create the LUT texture
  72934. */
  72935. colorTableUrl: string;
  72936. /**
  72937. * Gets a string identifying the name of the class
  72938. * @returns "ColorCorrectionPostProcess" string
  72939. */
  72940. getClassName(): string;
  72941. constructor(name: string, colorTableUrl: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  72942. /** @hidden */
  72943. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): Nullable<ColorCorrectionPostProcess>;
  72944. }
  72945. }
  72946. declare module "babylonjs/Shaders/convolution.fragment" {
  72947. /** @hidden */
  72948. export var convolutionPixelShader: {
  72949. name: string;
  72950. shader: string;
  72951. };
  72952. }
  72953. declare module "babylonjs/PostProcesses/convolutionPostProcess" {
  72954. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  72955. import { Nullable } from "babylonjs/types";
  72956. import { Camera } from "babylonjs/Cameras/camera";
  72957. import { Engine } from "babylonjs/Engines/engine";
  72958. import "babylonjs/Shaders/convolution.fragment";
  72959. import { Scene } from "babylonjs/scene";
  72960. /**
  72961. * The ConvolutionPostProcess applies a 3x3 kernel to every pixel of the
  72962. * input texture to perform effects such as edge detection or sharpening
  72963. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  72964. */
  72965. export class ConvolutionPostProcess extends PostProcess {
  72966. /** Array of 9 values corresponding to the 3x3 kernel to be applied */
  72967. kernel: number[];
  72968. /**
  72969. * Gets a string identifying the name of the class
  72970. * @returns "ConvolutionPostProcess" string
  72971. */
  72972. getClassName(): string;
  72973. /**
  72974. * Creates a new instance ConvolutionPostProcess
  72975. * @param name The name of the effect.
  72976. * @param kernel Array of 9 values corresponding to the 3x3 kernel to be applied
  72977. * @param options The required width/height ratio to downsize to before computing the render pass.
  72978. * @param camera The camera to apply the render pass to.
  72979. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  72980. * @param engine The engine which the post process will be applied. (default: current engine)
  72981. * @param reusable If the post process can be reused on the same frame. (default: false)
  72982. * @param textureType Type of textures used when performing the post process. (default: 0)
  72983. */
  72984. constructor(name: string, kernel: number[], options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  72985. /** @hidden */
  72986. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): Nullable<ConvolutionPostProcess>;
  72987. /**
  72988. * Edge detection 0 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  72989. */
  72990. static EdgeDetect0Kernel: number[];
  72991. /**
  72992. * Edge detection 1 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  72993. */
  72994. static EdgeDetect1Kernel: number[];
  72995. /**
  72996. * Edge detection 2 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  72997. */
  72998. static EdgeDetect2Kernel: number[];
  72999. /**
  73000. * Kernel to sharpen an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  73001. */
  73002. static SharpenKernel: number[];
  73003. /**
  73004. * Kernel to emboss an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  73005. */
  73006. static EmbossKernel: number[];
  73007. /**
  73008. * Kernel to blur an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  73009. */
  73010. static GaussianKernel: number[];
  73011. }
  73012. }
  73013. declare module "babylonjs/PostProcesses/depthOfFieldBlurPostProcess" {
  73014. import { Nullable } from "babylonjs/types";
  73015. import { Vector2 } from "babylonjs/Maths/math.vector";
  73016. import { Camera } from "babylonjs/Cameras/camera";
  73017. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  73018. import { BlurPostProcess } from "babylonjs/PostProcesses/blurPostProcess";
  73019. import { Engine } from "babylonjs/Engines/engine";
  73020. import { Scene } from "babylonjs/scene";
  73021. /**
  73022. * The DepthOfFieldBlurPostProcess applied a blur in a give direction.
  73023. * This blur differs from the standard BlurPostProcess as it attempts to avoid blurring pixels
  73024. * based on samples that have a large difference in distance than the center pixel.
  73025. * See section 2.6.2 http://fileadmin.cs.lth.se/cs/education/edan35/lectures/12dof.pdf
  73026. */
  73027. export class DepthOfFieldBlurPostProcess extends BlurPostProcess {
  73028. /**
  73029. * The direction the blur should be applied
  73030. */
  73031. direction: Vector2;
  73032. /**
  73033. * Gets a string identifying the name of the class
  73034. * @returns "DepthOfFieldBlurPostProcess" string
  73035. */
  73036. getClassName(): string;
  73037. /**
  73038. * Creates a new instance CircleOfConfusionPostProcess
  73039. * @param name The name of the effect.
  73040. * @param scene The scene the effect belongs to.
  73041. * @param direction The direction the blur should be applied.
  73042. * @param kernel The size of the kernel used to blur.
  73043. * @param options The required width/height ratio to downsize to before computing the render pass.
  73044. * @param camera The camera to apply the render pass to.
  73045. * @param circleOfConfusion The circle of confusion + depth map to be used to avoid blurring accross edges
  73046. * @param imageToBlur The image to apply the blur to (default: Current rendered frame)
  73047. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  73048. * @param engine The engine which the post process will be applied. (default: current engine)
  73049. * @param reusable If the post process can be reused on the same frame. (default: false)
  73050. * @param textureType Type of textures used when performing the post process. (default: 0)
  73051. * @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)
  73052. */
  73053. 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);
  73054. }
  73055. }
  73056. declare module "babylonjs/Shaders/depthOfFieldMerge.fragment" {
  73057. /** @hidden */
  73058. export var depthOfFieldMergePixelShader: {
  73059. name: string;
  73060. shader: string;
  73061. };
  73062. }
  73063. declare module "babylonjs/PostProcesses/depthOfFieldMergePostProcess" {
  73064. import { Nullable } from "babylonjs/types";
  73065. import { Camera } from "babylonjs/Cameras/camera";
  73066. import { Effect } from "babylonjs/Materials/effect";
  73067. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  73068. import { Engine } from "babylonjs/Engines/engine";
  73069. import "babylonjs/Shaders/depthOfFieldMerge.fragment";
  73070. /**
  73071. * Options to be set when merging outputs from the default pipeline.
  73072. */
  73073. export class DepthOfFieldMergePostProcessOptions {
  73074. /**
  73075. * The original image to merge on top of
  73076. */
  73077. originalFromInput: PostProcess;
  73078. /**
  73079. * Parameters to perform the merge of the depth of field effect
  73080. */
  73081. depthOfField?: {
  73082. circleOfConfusion: PostProcess;
  73083. blurSteps: Array<PostProcess>;
  73084. };
  73085. /**
  73086. * Parameters to perform the merge of bloom effect
  73087. */
  73088. bloom?: {
  73089. blurred: PostProcess;
  73090. weight: number;
  73091. };
  73092. }
  73093. /**
  73094. * The DepthOfFieldMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  73095. */
  73096. export class DepthOfFieldMergePostProcess extends PostProcess {
  73097. private blurSteps;
  73098. /**
  73099. * Gets a string identifying the name of the class
  73100. * @returns "DepthOfFieldMergePostProcess" string
  73101. */
  73102. getClassName(): string;
  73103. /**
  73104. * Creates a new instance of DepthOfFieldMergePostProcess
  73105. * @param name The name of the effect.
  73106. * @param originalFromInput Post process which's input will be used for the merge.
  73107. * @param circleOfConfusion Circle of confusion post process which's output will be used to blur each pixel.
  73108. * @param blurSteps Blur post processes from low to high which will be mixed with the original image.
  73109. * @param options The required width/height ratio to downsize to before computing the render pass.
  73110. * @param camera The camera to apply the render pass to.
  73111. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  73112. * @param engine The engine which the post process will be applied. (default: current engine)
  73113. * @param reusable If the post process can be reused on the same frame. (default: false)
  73114. * @param textureType Type of textures used when performing the post process. (default: 0)
  73115. * @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)
  73116. */
  73117. 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);
  73118. /**
  73119. * Updates the effect with the current post process compile time values and recompiles the shader.
  73120. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  73121. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  73122. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  73123. * @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
  73124. * @param onCompiled Called when the shader has been compiled.
  73125. * @param onError Called if there is an error when compiling a shader.
  73126. */
  73127. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  73128. }
  73129. }
  73130. declare module "babylonjs/PostProcesses/depthOfFieldEffect" {
  73131. import { Nullable } from "babylonjs/types";
  73132. import { Camera } from "babylonjs/Cameras/camera";
  73133. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  73134. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  73135. import { PostProcessRenderEffect } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderEffect";
  73136. import { DepthOfFieldBlurPostProcess } from "babylonjs/PostProcesses/depthOfFieldBlurPostProcess";
  73137. import { Scene } from "babylonjs/scene";
  73138. /**
  73139. * Specifies the level of max blur that should be applied when using the depth of field effect
  73140. */
  73141. export enum DepthOfFieldEffectBlurLevel {
  73142. /**
  73143. * Subtle blur
  73144. */
  73145. Low = 0,
  73146. /**
  73147. * Medium blur
  73148. */
  73149. Medium = 1,
  73150. /**
  73151. * Large blur
  73152. */
  73153. High = 2
  73154. }
  73155. /**
  73156. * The depth of field effect applies a blur to objects that are closer or further from where the camera is focusing.
  73157. */
  73158. export class DepthOfFieldEffect extends PostProcessRenderEffect {
  73159. private _circleOfConfusion;
  73160. /**
  73161. * @hidden Internal, blurs from high to low
  73162. */
  73163. _depthOfFieldBlurX: Array<DepthOfFieldBlurPostProcess>;
  73164. private _depthOfFieldBlurY;
  73165. private _dofMerge;
  73166. /**
  73167. * @hidden Internal post processes in depth of field effect
  73168. */
  73169. _effects: Array<PostProcess>;
  73170. /**
  73171. * The focal the length of the camera used in the effect in scene units/1000 (eg. millimeter)
  73172. */
  73173. set focalLength(value: number);
  73174. get focalLength(): number;
  73175. /**
  73176. * F-Stop of the effect's camera. The diameter of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  73177. */
  73178. set fStop(value: number);
  73179. get fStop(): number;
  73180. /**
  73181. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  73182. */
  73183. set focusDistance(value: number);
  73184. get focusDistance(): number;
  73185. /**
  73186. * 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.
  73187. */
  73188. set lensSize(value: number);
  73189. get lensSize(): number;
  73190. /**
  73191. * Creates a new instance DepthOfFieldEffect
  73192. * @param scene The scene the effect belongs to.
  73193. * @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.
  73194. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  73195. * @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)
  73196. */
  73197. constructor(scene: Scene, depthTexture: Nullable<RenderTargetTexture>, blurLevel?: DepthOfFieldEffectBlurLevel, pipelineTextureType?: number, blockCompilation?: boolean);
  73198. /**
  73199. * Get the current class name of the current effet
  73200. * @returns "DepthOfFieldEffect"
  73201. */
  73202. getClassName(): string;
  73203. /**
  73204. * 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.
  73205. */
  73206. set depthTexture(value: RenderTargetTexture);
  73207. /**
  73208. * Disposes each of the internal effects for a given camera.
  73209. * @param camera The camera to dispose the effect on.
  73210. */
  73211. disposeEffects(camera: Camera): void;
  73212. /**
  73213. * @hidden Internal
  73214. */
  73215. _updateEffects(): void;
  73216. /**
  73217. * Internal
  73218. * @returns if all the contained post processes are ready.
  73219. * @hidden
  73220. */
  73221. _isReady(): boolean;
  73222. }
  73223. }
  73224. declare module "babylonjs/Shaders/displayPass.fragment" {
  73225. /** @hidden */
  73226. export var displayPassPixelShader: {
  73227. name: string;
  73228. shader: string;
  73229. };
  73230. }
  73231. declare module "babylonjs/PostProcesses/displayPassPostProcess" {
  73232. import { Nullable } from "babylonjs/types";
  73233. import { Camera } from "babylonjs/Cameras/camera";
  73234. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  73235. import { Engine } from "babylonjs/Engines/engine";
  73236. import "babylonjs/Shaders/displayPass.fragment";
  73237. import { Scene } from "babylonjs/scene";
  73238. /**
  73239. * DisplayPassPostProcess which produces an output the same as it's input
  73240. */
  73241. export class DisplayPassPostProcess extends PostProcess {
  73242. /**
  73243. * Gets a string identifying the name of the class
  73244. * @returns "DisplayPassPostProcess" string
  73245. */
  73246. getClassName(): string;
  73247. /**
  73248. * Creates the DisplayPassPostProcess
  73249. * @param name The name of the effect.
  73250. * @param options The required width/height ratio to downsize to before computing the render pass.
  73251. * @param camera The camera to apply the render pass to.
  73252. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  73253. * @param engine The engine which the post process will be applied. (default: current engine)
  73254. * @param reusable If the post process can be reused on the same frame. (default: false)
  73255. */
  73256. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  73257. /** @hidden */
  73258. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): Nullable<DisplayPassPostProcess>;
  73259. }
  73260. }
  73261. declare module "babylonjs/Shaders/filter.fragment" {
  73262. /** @hidden */
  73263. export var filterPixelShader: {
  73264. name: string;
  73265. shader: string;
  73266. };
  73267. }
  73268. declare module "babylonjs/PostProcesses/filterPostProcess" {
  73269. import { Nullable } from "babylonjs/types";
  73270. import { Matrix } from "babylonjs/Maths/math.vector";
  73271. import { Camera } from "babylonjs/Cameras/camera";
  73272. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  73273. import { Engine } from "babylonjs/Engines/engine";
  73274. import "babylonjs/Shaders/filter.fragment";
  73275. import { Scene } from "babylonjs/scene";
  73276. /**
  73277. * Applies a kernel filter to the image
  73278. */
  73279. export class FilterPostProcess extends PostProcess {
  73280. /** The matrix to be applied to the image */
  73281. kernelMatrix: Matrix;
  73282. /**
  73283. * Gets a string identifying the name of the class
  73284. * @returns "FilterPostProcess" string
  73285. */
  73286. getClassName(): string;
  73287. /**
  73288. *
  73289. * @param name The name of the effect.
  73290. * @param kernelMatrix The matrix to be applied to the image
  73291. * @param options The required width/height ratio to downsize to before computing the render pass.
  73292. * @param camera The camera to apply the render pass to.
  73293. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  73294. * @param engine The engine which the post process will be applied. (default: current engine)
  73295. * @param reusable If the post process can be reused on the same frame. (default: false)
  73296. */
  73297. constructor(name: string, kernelMatrix: Matrix, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  73298. /** @hidden */
  73299. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): Nullable<FilterPostProcess>;
  73300. }
  73301. }
  73302. declare module "babylonjs/Shaders/fxaa.fragment" {
  73303. /** @hidden */
  73304. export var fxaaPixelShader: {
  73305. name: string;
  73306. shader: string;
  73307. };
  73308. }
  73309. declare module "babylonjs/Shaders/fxaa.vertex" {
  73310. /** @hidden */
  73311. export var fxaaVertexShader: {
  73312. name: string;
  73313. shader: string;
  73314. };
  73315. }
  73316. declare module "babylonjs/PostProcesses/fxaaPostProcess" {
  73317. import { Nullable } from "babylonjs/types";
  73318. import { Camera } from "babylonjs/Cameras/camera";
  73319. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  73320. import { Engine } from "babylonjs/Engines/engine";
  73321. import "babylonjs/Shaders/fxaa.fragment";
  73322. import "babylonjs/Shaders/fxaa.vertex";
  73323. import { Scene } from "babylonjs/scene";
  73324. /**
  73325. * Fxaa post process
  73326. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#fxaa
  73327. */
  73328. export class FxaaPostProcess extends PostProcess {
  73329. /**
  73330. * Gets a string identifying the name of the class
  73331. * @returns "FxaaPostProcess" string
  73332. */
  73333. getClassName(): string;
  73334. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  73335. private _getDefines;
  73336. /** @hidden */
  73337. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): FxaaPostProcess;
  73338. }
  73339. }
  73340. declare module "babylonjs/Shaders/grain.fragment" {
  73341. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  73342. /** @hidden */
  73343. export var grainPixelShader: {
  73344. name: string;
  73345. shader: string;
  73346. };
  73347. }
  73348. declare module "babylonjs/PostProcesses/grainPostProcess" {
  73349. import { Nullable } from "babylonjs/types";
  73350. import { Camera } from "babylonjs/Cameras/camera";
  73351. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  73352. import { Engine } from "babylonjs/Engines/engine";
  73353. import "babylonjs/Shaders/grain.fragment";
  73354. import { Scene } from "babylonjs/scene";
  73355. /**
  73356. * The GrainPostProcess adds noise to the image at mid luminance levels
  73357. */
  73358. export class GrainPostProcess extends PostProcess {
  73359. /**
  73360. * The intensity of the grain added (default: 30)
  73361. */
  73362. intensity: number;
  73363. /**
  73364. * If the grain should be randomized on every frame
  73365. */
  73366. animated: boolean;
  73367. /**
  73368. * Gets a string identifying the name of the class
  73369. * @returns "GrainPostProcess" string
  73370. */
  73371. getClassName(): string;
  73372. /**
  73373. * Creates a new instance of @see GrainPostProcess
  73374. * @param name The name of the effect.
  73375. * @param options The required width/height ratio to downsize to before computing the render pass.
  73376. * @param camera The camera to apply the render pass to.
  73377. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  73378. * @param engine The engine which the post process will be applied. (default: current engine)
  73379. * @param reusable If the post process can be reused on the same frame. (default: false)
  73380. * @param textureType Type of textures used when performing the post process. (default: 0)
  73381. * @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)
  73382. */
  73383. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  73384. /** @hidden */
  73385. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): GrainPostProcess;
  73386. }
  73387. }
  73388. declare module "babylonjs/Shaders/highlights.fragment" {
  73389. /** @hidden */
  73390. export var highlightsPixelShader: {
  73391. name: string;
  73392. shader: string;
  73393. };
  73394. }
  73395. declare module "babylonjs/PostProcesses/highlightsPostProcess" {
  73396. import { Nullable } from "babylonjs/types";
  73397. import { Camera } from "babylonjs/Cameras/camera";
  73398. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  73399. import { Engine } from "babylonjs/Engines/engine";
  73400. import "babylonjs/Shaders/highlights.fragment";
  73401. /**
  73402. * Extracts highlights from the image
  73403. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  73404. */
  73405. export class HighlightsPostProcess extends PostProcess {
  73406. /**
  73407. * Gets a string identifying the name of the class
  73408. * @returns "HighlightsPostProcess" string
  73409. */
  73410. getClassName(): string;
  73411. /**
  73412. * Extracts highlights from the image
  73413. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  73414. * @param name The name of the effect.
  73415. * @param options The required width/height ratio to downsize to before computing the render pass.
  73416. * @param camera The camera to apply the render pass to.
  73417. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  73418. * @param engine The engine which the post process will be applied. (default: current engine)
  73419. * @param reusable If the post process can be reused on the same frame. (default: false)
  73420. * @param textureType Type of texture for the post process (default: Engine.TEXTURETYPE_UNSIGNED_INT)
  73421. */
  73422. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  73423. }
  73424. }
  73425. declare module "babylonjs/Shaders/ShadersInclude/mrtFragmentDeclaration" {
  73426. /** @hidden */
  73427. export var mrtFragmentDeclaration: {
  73428. name: string;
  73429. shader: string;
  73430. };
  73431. }
  73432. declare module "babylonjs/Shaders/geometry.fragment" {
  73433. import "babylonjs/Shaders/ShadersInclude/mrtFragmentDeclaration";
  73434. import "babylonjs/Shaders/ShadersInclude/bumpFragmentMainFunctions";
  73435. import "babylonjs/Shaders/ShadersInclude/bumpFragmentFunctions";
  73436. import "babylonjs/Shaders/ShadersInclude/bumpFragment";
  73437. /** @hidden */
  73438. export var geometryPixelShader: {
  73439. name: string;
  73440. shader: string;
  73441. };
  73442. }
  73443. declare module "babylonjs/Shaders/geometry.vertex" {
  73444. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  73445. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  73446. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  73447. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  73448. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  73449. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  73450. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  73451. import "babylonjs/Shaders/ShadersInclude/bumpVertex";
  73452. /** @hidden */
  73453. export var geometryVertexShader: {
  73454. name: string;
  73455. shader: string;
  73456. };
  73457. }
  73458. declare module "babylonjs/Rendering/geometryBufferRenderer" {
  73459. import { Matrix } from "babylonjs/Maths/math.vector";
  73460. import { SubMesh } from "babylonjs/Meshes/subMesh";
  73461. import { Mesh } from "babylonjs/Meshes/mesh";
  73462. import { MultiRenderTarget } from "babylonjs/Materials/Textures/multiRenderTarget";
  73463. import { Effect } from "babylonjs/Materials/effect";
  73464. import { Scene } from "babylonjs/scene";
  73465. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  73466. import "babylonjs/Shaders/geometry.fragment";
  73467. import "babylonjs/Shaders/geometry.vertex";
  73468. /** @hidden */
  73469. interface ISavedTransformationMatrix {
  73470. world: Matrix;
  73471. viewProjection: Matrix;
  73472. }
  73473. /**
  73474. * This renderer is helpfull to fill one of the render target with a geometry buffer.
  73475. */
  73476. export class GeometryBufferRenderer {
  73477. /**
  73478. * Constant used to retrieve the position texture index in the G-Buffer textures array
  73479. * using getIndex(GeometryBufferRenderer.POSITION_TEXTURE_INDEX)
  73480. */
  73481. static readonly POSITION_TEXTURE_TYPE: number;
  73482. /**
  73483. * Constant used to retrieve the velocity texture index in the G-Buffer textures array
  73484. * using getIndex(GeometryBufferRenderer.VELOCITY_TEXTURE_INDEX)
  73485. */
  73486. static readonly VELOCITY_TEXTURE_TYPE: number;
  73487. /**
  73488. * Constant used to retrieve the reflectivity texture index in the G-Buffer textures array
  73489. * using the getIndex(GeometryBufferRenderer.REFLECTIVITY_TEXTURE_TYPE)
  73490. */
  73491. static readonly REFLECTIVITY_TEXTURE_TYPE: number;
  73492. /**
  73493. * Dictionary used to store the previous transformation matrices of each rendered mesh
  73494. * in order to compute objects velocities when enableVelocity is set to "true"
  73495. * @hidden
  73496. */
  73497. _previousTransformationMatrices: {
  73498. [index: number]: ISavedTransformationMatrix;
  73499. };
  73500. /**
  73501. * Dictionary used to store the previous bones transformation matrices of each rendered mesh
  73502. * in order to compute objects velocities when enableVelocity is set to "true"
  73503. * @hidden
  73504. */
  73505. _previousBonesTransformationMatrices: {
  73506. [index: number]: Float32Array;
  73507. };
  73508. /**
  73509. * Array used to store the ignored skinned meshes while computing velocity map (typically used by the motion blur post-process).
  73510. * Avoids computing bones velocities and computes only mesh's velocity itself (position, rotation, scaling).
  73511. */
  73512. excludedSkinnedMeshesFromVelocity: AbstractMesh[];
  73513. /** Gets or sets a boolean indicating if transparent meshes should be rendered */
  73514. renderTransparentMeshes: boolean;
  73515. private _scene;
  73516. private _resizeObserver;
  73517. private _multiRenderTarget;
  73518. private _ratio;
  73519. private _enablePosition;
  73520. private _enableVelocity;
  73521. private _enableReflectivity;
  73522. private _positionIndex;
  73523. private _velocityIndex;
  73524. private _reflectivityIndex;
  73525. protected _effect: Effect;
  73526. protected _cachedDefines: string;
  73527. /**
  73528. * Set the render list (meshes to be rendered) used in the G buffer.
  73529. */
  73530. set renderList(meshes: Mesh[]);
  73531. /**
  73532. * Gets wether or not G buffer are supported by the running hardware.
  73533. * This requires draw buffer supports
  73534. */
  73535. get isSupported(): boolean;
  73536. /**
  73537. * Returns the index of the given texture type in the G-Buffer textures array
  73538. * @param textureType The texture type constant. For example GeometryBufferRenderer.POSITION_TEXTURE_INDEX
  73539. * @returns the index of the given texture type in the G-Buffer textures array
  73540. */
  73541. getTextureIndex(textureType: number): number;
  73542. /**
  73543. * Gets a boolean indicating if objects positions are enabled for the G buffer.
  73544. */
  73545. get enablePosition(): boolean;
  73546. /**
  73547. * Sets whether or not objects positions are enabled for the G buffer.
  73548. */
  73549. set enablePosition(enable: boolean);
  73550. /**
  73551. * Gets a boolean indicating if objects velocities are enabled for the G buffer.
  73552. */
  73553. get enableVelocity(): boolean;
  73554. /**
  73555. * Sets wether or not objects velocities are enabled for the G buffer.
  73556. */
  73557. set enableVelocity(enable: boolean);
  73558. /**
  73559. * Gets a boolean indicating if objects roughness are enabled in the G buffer.
  73560. */
  73561. get enableReflectivity(): boolean;
  73562. /**
  73563. * Sets wether or not objects roughness are enabled for the G buffer.
  73564. */
  73565. set enableReflectivity(enable: boolean);
  73566. /**
  73567. * Gets the scene associated with the buffer.
  73568. */
  73569. get scene(): Scene;
  73570. /**
  73571. * Gets the ratio used by the buffer during its creation.
  73572. * How big is the buffer related to the main canvas.
  73573. */
  73574. get ratio(): number;
  73575. /** @hidden */
  73576. static _SceneComponentInitialization: (scene: Scene) => void;
  73577. /**
  73578. * Creates a new G Buffer for the scene
  73579. * @param scene The scene the buffer belongs to
  73580. * @param ratio How big is the buffer related to the main canvas.
  73581. */
  73582. constructor(scene: Scene, ratio?: number);
  73583. /**
  73584. * Checks wether everything is ready to render a submesh to the G buffer.
  73585. * @param subMesh the submesh to check readiness for
  73586. * @param useInstances is the mesh drawn using instance or not
  73587. * @returns true if ready otherwise false
  73588. */
  73589. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  73590. /**
  73591. * Gets the current underlying G Buffer.
  73592. * @returns the buffer
  73593. */
  73594. getGBuffer(): MultiRenderTarget;
  73595. /**
  73596. * Gets the number of samples used to render the buffer (anti aliasing).
  73597. */
  73598. get samples(): number;
  73599. /**
  73600. * Sets the number of samples used to render the buffer (anti aliasing).
  73601. */
  73602. set samples(value: number);
  73603. /**
  73604. * Disposes the renderer and frees up associated resources.
  73605. */
  73606. dispose(): void;
  73607. protected _createRenderTargets(): void;
  73608. private _copyBonesTransformationMatrices;
  73609. }
  73610. }
  73611. declare module "babylonjs/Rendering/geometryBufferRendererSceneComponent" {
  73612. import { Nullable } from "babylonjs/types";
  73613. import { Scene } from "babylonjs/scene";
  73614. import { ISceneComponent } from "babylonjs/sceneComponent";
  73615. import { GeometryBufferRenderer } from "babylonjs/Rendering/geometryBufferRenderer";
  73616. module "babylonjs/scene" {
  73617. interface Scene {
  73618. /** @hidden (Backing field) */
  73619. _geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  73620. /**
  73621. * Gets or Sets the current geometry buffer associated to the scene.
  73622. */
  73623. geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  73624. /**
  73625. * Enables a GeometryBufferRender and associates it with the scene
  73626. * @param ratio defines the scaling ratio to apply to the renderer (1 by default which means same resolution)
  73627. * @returns the GeometryBufferRenderer
  73628. */
  73629. enableGeometryBufferRenderer(ratio?: number): Nullable<GeometryBufferRenderer>;
  73630. /**
  73631. * Disables the GeometryBufferRender associated with the scene
  73632. */
  73633. disableGeometryBufferRenderer(): void;
  73634. }
  73635. }
  73636. /**
  73637. * Defines the Geometry Buffer scene component responsible to manage a G-Buffer useful
  73638. * in several rendering techniques.
  73639. */
  73640. export class GeometryBufferRendererSceneComponent implements ISceneComponent {
  73641. /**
  73642. * The component name helpful to identify the component in the list of scene components.
  73643. */
  73644. readonly name: string;
  73645. /**
  73646. * The scene the component belongs to.
  73647. */
  73648. scene: Scene;
  73649. /**
  73650. * Creates a new instance of the component for the given scene
  73651. * @param scene Defines the scene to register the component in
  73652. */
  73653. constructor(scene: Scene);
  73654. /**
  73655. * Registers the component in a given scene
  73656. */
  73657. register(): void;
  73658. /**
  73659. * Rebuilds the elements related to this component in case of
  73660. * context lost for instance.
  73661. */
  73662. rebuild(): void;
  73663. /**
  73664. * Disposes the component and the associated ressources
  73665. */
  73666. dispose(): void;
  73667. private _gatherRenderTargets;
  73668. }
  73669. }
  73670. declare module "babylonjs/Shaders/motionBlur.fragment" {
  73671. /** @hidden */
  73672. export var motionBlurPixelShader: {
  73673. name: string;
  73674. shader: string;
  73675. };
  73676. }
  73677. declare module "babylonjs/PostProcesses/motionBlurPostProcess" {
  73678. import { Nullable } from "babylonjs/types";
  73679. import { Camera } from "babylonjs/Cameras/camera";
  73680. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  73681. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  73682. import "babylonjs/Animations/animatable";
  73683. import "babylonjs/Rendering/geometryBufferRendererSceneComponent";
  73684. import "babylonjs/Shaders/motionBlur.fragment";
  73685. import { Engine } from "babylonjs/Engines/engine";
  73686. import { Scene } from "babylonjs/scene";
  73687. /**
  73688. * The Motion Blur Post Process which blurs an image based on the objects velocity in scene.
  73689. * Velocity can be affected by each object's rotation, position and scale depending on the transformation speed.
  73690. * As an example, all you have to do is to create the post-process:
  73691. * var mb = new BABYLON.MotionBlurPostProcess(
  73692. * 'mb', // The name of the effect.
  73693. * scene, // The scene containing the objects to blur according to their velocity.
  73694. * 1.0, // The required width/height ratio to downsize to before computing the render pass.
  73695. * camera // The camera to apply the render pass to.
  73696. * );
  73697. * Then, all objects moving, rotating and/or scaling will be blurred depending on the transformation speed.
  73698. */
  73699. export class MotionBlurPostProcess extends PostProcess {
  73700. /**
  73701. * Defines how much the image is blurred by the movement. Default value is equal to 1
  73702. */
  73703. motionStrength: number;
  73704. /**
  73705. * Gets the number of iterations are used for motion blur quality. Default value is equal to 32
  73706. */
  73707. get motionBlurSamples(): number;
  73708. /**
  73709. * Sets the number of iterations to be used for motion blur quality
  73710. */
  73711. set motionBlurSamples(samples: number);
  73712. private _motionBlurSamples;
  73713. private _geometryBufferRenderer;
  73714. /**
  73715. * Gets a string identifying the name of the class
  73716. * @returns "MotionBlurPostProcess" string
  73717. */
  73718. getClassName(): string;
  73719. /**
  73720. * Creates a new instance MotionBlurPostProcess
  73721. * @param name The name of the effect.
  73722. * @param scene The scene containing the objects to blur according to their velocity.
  73723. * @param options The required width/height ratio to downsize to before computing the render pass.
  73724. * @param camera The camera to apply the render pass to.
  73725. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  73726. * @param engine The engine which the post process will be applied. (default: current engine)
  73727. * @param reusable If the post process can be reused on the same frame. (default: false)
  73728. * @param textureType Type of textures used when performing the post process. (default: 0)
  73729. * @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)
  73730. */
  73731. constructor(name: string, scene: Scene, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  73732. /**
  73733. * Excludes the given skinned mesh from computing bones velocities.
  73734. * 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.
  73735. * @param skinnedMesh The mesh containing the skeleton to ignore when computing the velocity map.
  73736. */
  73737. excludeSkinnedMesh(skinnedMesh: AbstractMesh): void;
  73738. /**
  73739. * Removes the given skinned mesh from the excluded meshes to integrate bones velocities while rendering the velocity map.
  73740. * @param skinnedMesh The mesh containing the skeleton that has been ignored previously.
  73741. * @see excludeSkinnedMesh to exclude a skinned mesh from bones velocity computation.
  73742. */
  73743. removeExcludedSkinnedMesh(skinnedMesh: AbstractMesh): void;
  73744. /**
  73745. * Disposes the post process.
  73746. * @param camera The camera to dispose the post process on.
  73747. */
  73748. dispose(camera?: Camera): void;
  73749. /** @hidden */
  73750. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): Nullable<MotionBlurPostProcess>;
  73751. }
  73752. }
  73753. declare module "babylonjs/Shaders/refraction.fragment" {
  73754. /** @hidden */
  73755. export var refractionPixelShader: {
  73756. name: string;
  73757. shader: string;
  73758. };
  73759. }
  73760. declare module "babylonjs/PostProcesses/refractionPostProcess" {
  73761. import { Color3 } from "babylonjs/Maths/math.color";
  73762. import { Camera } from "babylonjs/Cameras/camera";
  73763. import { Texture } from "babylonjs/Materials/Textures/texture";
  73764. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  73765. import { Engine } from "babylonjs/Engines/engine";
  73766. import "babylonjs/Shaders/refraction.fragment";
  73767. import { Scene } from "babylonjs/scene";
  73768. /**
  73769. * Post process which applies a refractin texture
  73770. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  73771. */
  73772. export class RefractionPostProcess extends PostProcess {
  73773. private _refTexture;
  73774. private _ownRefractionTexture;
  73775. /** the base color of the refraction (used to taint the rendering) */
  73776. color: Color3;
  73777. /** simulated refraction depth */
  73778. depth: number;
  73779. /** the coefficient of the base color (0 to remove base color tainting) */
  73780. colorLevel: number;
  73781. /** Gets the url used to load the refraction texture */
  73782. refractionTextureUrl: string;
  73783. /**
  73784. * Gets or sets the refraction texture
  73785. * Please note that you are responsible for disposing the texture if you set it manually
  73786. */
  73787. get refractionTexture(): Texture;
  73788. set refractionTexture(value: Texture);
  73789. /**
  73790. * Gets a string identifying the name of the class
  73791. * @returns "RefractionPostProcess" string
  73792. */
  73793. getClassName(): string;
  73794. /**
  73795. * Initializes the RefractionPostProcess
  73796. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  73797. * @param name The name of the effect.
  73798. * @param refractionTextureUrl Url of the refraction texture to use
  73799. * @param color the base color of the refraction (used to taint the rendering)
  73800. * @param depth simulated refraction depth
  73801. * @param colorLevel the coefficient of the base color (0 to remove base color tainting)
  73802. * @param camera The camera to apply the render pass to.
  73803. * @param options The required width/height ratio to downsize to before computing the render pass.
  73804. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  73805. * @param engine The engine which the post process will be applied. (default: current engine)
  73806. * @param reusable If the post process can be reused on the same frame. (default: false)
  73807. */
  73808. constructor(name: string, refractionTextureUrl: string, color: Color3, depth: number, colorLevel: number, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  73809. /**
  73810. * Disposes of the post process
  73811. * @param camera Camera to dispose post process on
  73812. */
  73813. dispose(camera: Camera): void;
  73814. /** @hidden */
  73815. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): RefractionPostProcess;
  73816. }
  73817. }
  73818. declare module "babylonjs/Shaders/sharpen.fragment" {
  73819. /** @hidden */
  73820. export var sharpenPixelShader: {
  73821. name: string;
  73822. shader: string;
  73823. };
  73824. }
  73825. declare module "babylonjs/PostProcesses/sharpenPostProcess" {
  73826. import { Nullable } from "babylonjs/types";
  73827. import { Camera } from "babylonjs/Cameras/camera";
  73828. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  73829. import "babylonjs/Shaders/sharpen.fragment";
  73830. import { Engine } from "babylonjs/Engines/engine";
  73831. import { Scene } from "babylonjs/scene";
  73832. /**
  73833. * The SharpenPostProcess applies a sharpen kernel to every pixel
  73834. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  73835. */
  73836. export class SharpenPostProcess extends PostProcess {
  73837. /**
  73838. * How much of the original color should be applied. Setting this to 0 will display edge detection. (default: 1)
  73839. */
  73840. colorAmount: number;
  73841. /**
  73842. * How much sharpness should be applied (default: 0.3)
  73843. */
  73844. edgeAmount: number;
  73845. /**
  73846. * Gets a string identifying the name of the class
  73847. * @returns "SharpenPostProcess" string
  73848. */
  73849. getClassName(): string;
  73850. /**
  73851. * Creates a new instance ConvolutionPostProcess
  73852. * @param name The name of the effect.
  73853. * @param options The required width/height ratio to downsize to before computing the render pass.
  73854. * @param camera The camera to apply the render pass to.
  73855. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  73856. * @param engine The engine which the post process will be applied. (default: current engine)
  73857. * @param reusable If the post process can be reused on the same frame. (default: false)
  73858. * @param textureType Type of textures used when performing the post process. (default: 0)
  73859. * @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)
  73860. */
  73861. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  73862. /** @hidden */
  73863. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): SharpenPostProcess;
  73864. }
  73865. }
  73866. declare module "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline" {
  73867. import { Nullable } from "babylonjs/types";
  73868. import { Camera } from "babylonjs/Cameras/camera";
  73869. import { Engine } from "babylonjs/Engines/engine";
  73870. import { PostProcessRenderEffect } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderEffect";
  73871. import { IInspectable } from "babylonjs/Misc/iInspectable";
  73872. import { PrePassRenderer } from "babylonjs/Rendering/prePassRenderer";
  73873. /**
  73874. * PostProcessRenderPipeline
  73875. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  73876. */
  73877. export class PostProcessRenderPipeline {
  73878. private engine;
  73879. private _renderEffects;
  73880. private _renderEffectsForIsolatedPass;
  73881. /**
  73882. * List of inspectable custom properties (used by the Inspector)
  73883. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  73884. */
  73885. inspectableCustomProperties: IInspectable[];
  73886. /**
  73887. * @hidden
  73888. */
  73889. protected _cameras: Camera[];
  73890. /** @hidden */
  73891. _name: string;
  73892. /**
  73893. * Gets pipeline name
  73894. */
  73895. get name(): string;
  73896. /** Gets the list of attached cameras */
  73897. get cameras(): Camera[];
  73898. /**
  73899. * Initializes a PostProcessRenderPipeline
  73900. * @param engine engine to add the pipeline to
  73901. * @param name name of the pipeline
  73902. */
  73903. constructor(engine: Engine, name: string);
  73904. /**
  73905. * Gets the class name
  73906. * @returns "PostProcessRenderPipeline"
  73907. */
  73908. getClassName(): string;
  73909. /**
  73910. * If all the render effects in the pipeline are supported
  73911. */
  73912. get isSupported(): boolean;
  73913. /**
  73914. * Adds an effect to the pipeline
  73915. * @param renderEffect the effect to add
  73916. */
  73917. addEffect(renderEffect: PostProcessRenderEffect): void;
  73918. /** @hidden */
  73919. _rebuild(): void;
  73920. /** @hidden */
  73921. _enableEffect(renderEffectName: string, cameras: Camera): void;
  73922. /** @hidden */
  73923. _enableEffect(renderEffectName: string, cameras: Camera[]): void;
  73924. /** @hidden */
  73925. _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  73926. /** @hidden */
  73927. _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  73928. /** @hidden */
  73929. _attachCameras(cameras: Camera, unique: boolean): void;
  73930. /** @hidden */
  73931. _attachCameras(cameras: Camera[], unique: boolean): void;
  73932. /** @hidden */
  73933. _detachCameras(cameras: Camera): void;
  73934. /** @hidden */
  73935. _detachCameras(cameras: Nullable<Camera[]>): void;
  73936. /** @hidden */
  73937. _update(): void;
  73938. /** @hidden */
  73939. _reset(): void;
  73940. protected _enableMSAAOnFirstPostProcess(sampleCount: number): boolean;
  73941. /**
  73942. * Sets the required values to the prepass renderer.
  73943. * @param prePassRenderer defines the prepass renderer to setup.
  73944. * @returns true if the pre pass is needed.
  73945. */
  73946. setPrePassRenderer(prePassRenderer: PrePassRenderer): boolean;
  73947. /**
  73948. * Disposes of the pipeline
  73949. */
  73950. dispose(): void;
  73951. }
  73952. }
  73953. declare module "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManager" {
  73954. import { Camera } from "babylonjs/Cameras/camera";
  73955. import { PostProcessRenderPipeline } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  73956. /**
  73957. * PostProcessRenderPipelineManager class
  73958. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  73959. */
  73960. export class PostProcessRenderPipelineManager {
  73961. private _renderPipelines;
  73962. /**
  73963. * Initializes a PostProcessRenderPipelineManager
  73964. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  73965. */
  73966. constructor();
  73967. /**
  73968. * Gets the list of supported render pipelines
  73969. */
  73970. get supportedPipelines(): PostProcessRenderPipeline[];
  73971. /**
  73972. * Adds a pipeline to the manager
  73973. * @param renderPipeline The pipeline to add
  73974. */
  73975. addPipeline(renderPipeline: PostProcessRenderPipeline): void;
  73976. /**
  73977. * Attaches a camera to the pipeline
  73978. * @param renderPipelineName The name of the pipeline to attach to
  73979. * @param cameras the camera to attach
  73980. * @param unique if the camera can be attached multiple times to the pipeline
  73981. */
  73982. attachCamerasToRenderPipeline(renderPipelineName: string, cameras: any | Camera[] | Camera, unique?: boolean): void;
  73983. /**
  73984. * Detaches a camera from the pipeline
  73985. * @param renderPipelineName The name of the pipeline to detach from
  73986. * @param cameras the camera to detach
  73987. */
  73988. detachCamerasFromRenderPipeline(renderPipelineName: string, cameras: any | Camera[] | Camera): void;
  73989. /**
  73990. * Enables an effect by name on a pipeline
  73991. * @param renderPipelineName the name of the pipeline to enable the effect in
  73992. * @param renderEffectName the name of the effect to enable
  73993. * @param cameras the cameras that the effect should be enabled on
  73994. */
  73995. enableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: any | Camera[] | Camera): void;
  73996. /**
  73997. * Disables an effect by name on a pipeline
  73998. * @param renderPipelineName the name of the pipeline to disable the effect in
  73999. * @param renderEffectName the name of the effect to disable
  74000. * @param cameras the cameras that the effect should be disabled on
  74001. */
  74002. disableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: any | Camera[] | Camera): void;
  74003. /**
  74004. * Updates the state of all contained render pipelines and disposes of any non supported pipelines
  74005. */
  74006. update(): void;
  74007. /** @hidden */
  74008. _rebuild(): void;
  74009. /**
  74010. * Disposes of the manager and pipelines
  74011. */
  74012. dispose(): void;
  74013. }
  74014. }
  74015. declare module "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManagerSceneComponent" {
  74016. import { ISceneComponent } from "babylonjs/sceneComponent";
  74017. import { PostProcessRenderPipelineManager } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManager";
  74018. import { Scene } from "babylonjs/scene";
  74019. module "babylonjs/scene" {
  74020. interface Scene {
  74021. /** @hidden (Backing field) */
  74022. _postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  74023. /**
  74024. * Gets the postprocess render pipeline manager
  74025. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  74026. * @see https://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  74027. */
  74028. readonly postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  74029. }
  74030. }
  74031. /**
  74032. * Defines the Render Pipeline scene component responsible to rendering pipelines
  74033. */
  74034. export class PostProcessRenderPipelineManagerSceneComponent implements ISceneComponent {
  74035. /**
  74036. * The component name helpfull to identify the component in the list of scene components.
  74037. */
  74038. readonly name: string;
  74039. /**
  74040. * The scene the component belongs to.
  74041. */
  74042. scene: Scene;
  74043. /**
  74044. * Creates a new instance of the component for the given scene
  74045. * @param scene Defines the scene to register the component in
  74046. */
  74047. constructor(scene: Scene);
  74048. /**
  74049. * Registers the component in a given scene
  74050. */
  74051. register(): void;
  74052. /**
  74053. * Rebuilds the elements related to this component in case of
  74054. * context lost for instance.
  74055. */
  74056. rebuild(): void;
  74057. /**
  74058. * Disposes the component and the associated ressources
  74059. */
  74060. dispose(): void;
  74061. private _gatherRenderTargets;
  74062. }
  74063. }
  74064. declare module "babylonjs/PostProcesses/RenderPipeline/Pipelines/defaultRenderingPipeline" {
  74065. import { Nullable } from "babylonjs/types";
  74066. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  74067. import { Camera } from "babylonjs/Cameras/camera";
  74068. import { IDisposable } from "babylonjs/scene";
  74069. import { GlowLayer } from "babylonjs/Layers/glowLayer";
  74070. import { Scene } from "babylonjs/scene";
  74071. import { SharpenPostProcess } from "babylonjs/PostProcesses/sharpenPostProcess";
  74072. import { ImageProcessingPostProcess } from "babylonjs/PostProcesses/imageProcessingPostProcess";
  74073. import { ChromaticAberrationPostProcess } from "babylonjs/PostProcesses/chromaticAberrationPostProcess";
  74074. import { GrainPostProcess } from "babylonjs/PostProcesses/grainPostProcess";
  74075. import { FxaaPostProcess } from "babylonjs/PostProcesses/fxaaPostProcess";
  74076. import { PostProcessRenderPipeline } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  74077. import { DepthOfFieldEffect, DepthOfFieldEffectBlurLevel } from "babylonjs/PostProcesses/depthOfFieldEffect";
  74078. import "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManagerSceneComponent";
  74079. import { Animation } from "babylonjs/Animations/animation";
  74080. /**
  74081. * The default rendering pipeline can be added to a scene to apply common post processing effects such as anti-aliasing or depth of field.
  74082. * See https://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  74083. */
  74084. export class DefaultRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  74085. private _scene;
  74086. private _camerasToBeAttached;
  74087. /**
  74088. * ID of the sharpen post process,
  74089. */
  74090. private readonly SharpenPostProcessId;
  74091. /**
  74092. * @ignore
  74093. * ID of the image processing post process;
  74094. */
  74095. readonly ImageProcessingPostProcessId: string;
  74096. /**
  74097. * @ignore
  74098. * ID of the Fast Approximate Anti-Aliasing post process;
  74099. */
  74100. readonly FxaaPostProcessId: string;
  74101. /**
  74102. * ID of the chromatic aberration post process,
  74103. */
  74104. private readonly ChromaticAberrationPostProcessId;
  74105. /**
  74106. * ID of the grain post process
  74107. */
  74108. private readonly GrainPostProcessId;
  74109. /**
  74110. * Sharpen post process which will apply a sharpen convolution to enhance edges
  74111. */
  74112. sharpen: SharpenPostProcess;
  74113. private _sharpenEffect;
  74114. private bloom;
  74115. /**
  74116. * Depth of field effect, applies a blur based on how far away objects are from the focus distance.
  74117. */
  74118. depthOfField: DepthOfFieldEffect;
  74119. /**
  74120. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  74121. */
  74122. fxaa: FxaaPostProcess;
  74123. /**
  74124. * Image post processing pass used to perform operations such as tone mapping or color grading.
  74125. */
  74126. imageProcessing: ImageProcessingPostProcess;
  74127. /**
  74128. * Chromatic aberration post process which will shift rgb colors in the image
  74129. */
  74130. chromaticAberration: ChromaticAberrationPostProcess;
  74131. private _chromaticAberrationEffect;
  74132. /**
  74133. * Grain post process which add noise to the image
  74134. */
  74135. grain: GrainPostProcess;
  74136. private _grainEffect;
  74137. /**
  74138. * Glow post process which adds a glow to emissive areas of the image
  74139. */
  74140. private _glowLayer;
  74141. /**
  74142. * Animations which can be used to tweak settings over a period of time
  74143. */
  74144. animations: Animation[];
  74145. private _imageProcessingConfigurationObserver;
  74146. private _sharpenEnabled;
  74147. private _bloomEnabled;
  74148. private _depthOfFieldEnabled;
  74149. private _depthOfFieldBlurLevel;
  74150. private _fxaaEnabled;
  74151. private _imageProcessingEnabled;
  74152. private _defaultPipelineTextureType;
  74153. private _bloomScale;
  74154. private _chromaticAberrationEnabled;
  74155. private _grainEnabled;
  74156. private _buildAllowed;
  74157. /**
  74158. * Gets active scene
  74159. */
  74160. get scene(): Scene;
  74161. /**
  74162. * Enable or disable the sharpen process from the pipeline
  74163. */
  74164. set sharpenEnabled(enabled: boolean);
  74165. get sharpenEnabled(): boolean;
  74166. private _resizeObserver;
  74167. private _hardwareScaleLevel;
  74168. private _bloomKernel;
  74169. /**
  74170. * Specifies the size of the bloom blur kernel, relative to the final output size
  74171. */
  74172. get bloomKernel(): number;
  74173. set bloomKernel(value: number);
  74174. /**
  74175. * Specifies the weight of the bloom in the final rendering
  74176. */
  74177. private _bloomWeight;
  74178. /**
  74179. * Specifies the luma threshold for the area that will be blurred by the bloom
  74180. */
  74181. private _bloomThreshold;
  74182. private _hdr;
  74183. /**
  74184. * The strength of the bloom.
  74185. */
  74186. set bloomWeight(value: number);
  74187. get bloomWeight(): number;
  74188. /**
  74189. * The strength of the bloom.
  74190. */
  74191. set bloomThreshold(value: number);
  74192. get bloomThreshold(): number;
  74193. /**
  74194. * The scale of the bloom, lower value will provide better performance.
  74195. */
  74196. set bloomScale(value: number);
  74197. get bloomScale(): number;
  74198. /**
  74199. * Enable or disable the bloom from the pipeline
  74200. */
  74201. set bloomEnabled(enabled: boolean);
  74202. get bloomEnabled(): boolean;
  74203. private _rebuildBloom;
  74204. /**
  74205. * If the depth of field is enabled.
  74206. */
  74207. get depthOfFieldEnabled(): boolean;
  74208. set depthOfFieldEnabled(enabled: boolean);
  74209. /**
  74210. * Blur level of the depth of field effect. (Higher blur will effect performance)
  74211. */
  74212. get depthOfFieldBlurLevel(): DepthOfFieldEffectBlurLevel;
  74213. set depthOfFieldBlurLevel(value: DepthOfFieldEffectBlurLevel);
  74214. /**
  74215. * If the anti aliasing is enabled.
  74216. */
  74217. set fxaaEnabled(enabled: boolean);
  74218. get fxaaEnabled(): boolean;
  74219. private _samples;
  74220. /**
  74221. * MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  74222. */
  74223. set samples(sampleCount: number);
  74224. get samples(): number;
  74225. /**
  74226. * If image processing is enabled.
  74227. */
  74228. set imageProcessingEnabled(enabled: boolean);
  74229. get imageProcessingEnabled(): boolean;
  74230. /**
  74231. * If glow layer is enabled. (Adds a glow effect to emmissive materials)
  74232. */
  74233. set glowLayerEnabled(enabled: boolean);
  74234. get glowLayerEnabled(): boolean;
  74235. /**
  74236. * Gets the glow layer (or null if not defined)
  74237. */
  74238. get glowLayer(): Nullable<GlowLayer>;
  74239. /**
  74240. * Enable or disable the chromaticAberration process from the pipeline
  74241. */
  74242. set chromaticAberrationEnabled(enabled: boolean);
  74243. get chromaticAberrationEnabled(): boolean;
  74244. /**
  74245. * Enable or disable the grain process from the pipeline
  74246. */
  74247. set grainEnabled(enabled: boolean);
  74248. get grainEnabled(): boolean;
  74249. /**
  74250. * @constructor
  74251. * @param name - The rendering pipeline name (default: "")
  74252. * @param hdr - If high dynamic range textures should be used (default: true)
  74253. * @param scene - The scene linked to this pipeline (default: the last created scene)
  74254. * @param cameras - The array of cameras that the rendering pipeline will be attached to (default: scene.cameras)
  74255. * @param automaticBuild - if false, you will have to manually call prepare() to update the pipeline (default: true)
  74256. */
  74257. constructor(name?: string, hdr?: boolean, scene?: Scene, cameras?: Camera[], automaticBuild?: boolean);
  74258. /**
  74259. * Get the class name
  74260. * @returns "DefaultRenderingPipeline"
  74261. */
  74262. getClassName(): string;
  74263. /**
  74264. * Force the compilation of the entire pipeline.
  74265. */
  74266. prepare(): void;
  74267. private _hasCleared;
  74268. private _prevPostProcess;
  74269. private _prevPrevPostProcess;
  74270. private _setAutoClearAndTextureSharing;
  74271. private _depthOfFieldSceneObserver;
  74272. private _buildPipeline;
  74273. private _disposePostProcesses;
  74274. /**
  74275. * Adds a camera to the pipeline
  74276. * @param camera the camera to be added
  74277. */
  74278. addCamera(camera: Camera): void;
  74279. /**
  74280. * Removes a camera from the pipeline
  74281. * @param camera the camera to remove
  74282. */
  74283. removeCamera(camera: Camera): void;
  74284. /**
  74285. * Dispose of the pipeline and stop all post processes
  74286. */
  74287. dispose(): void;
  74288. /**
  74289. * Serialize the rendering pipeline (Used when exporting)
  74290. * @returns the serialized object
  74291. */
  74292. serialize(): any;
  74293. /**
  74294. * Parse the serialized pipeline
  74295. * @param source Source pipeline.
  74296. * @param scene The scene to load the pipeline to.
  74297. * @param rootUrl The URL of the serialized pipeline.
  74298. * @returns An instantiated pipeline from the serialized object.
  74299. */
  74300. static Parse(source: any, scene: Scene, rootUrl: string): DefaultRenderingPipeline;
  74301. }
  74302. }
  74303. declare module "babylonjs/Shaders/lensHighlights.fragment" {
  74304. /** @hidden */
  74305. export var lensHighlightsPixelShader: {
  74306. name: string;
  74307. shader: string;
  74308. };
  74309. }
  74310. declare module "babylonjs/Shaders/depthOfField.fragment" {
  74311. /** @hidden */
  74312. export var depthOfFieldPixelShader: {
  74313. name: string;
  74314. shader: string;
  74315. };
  74316. }
  74317. declare module "babylonjs/PostProcesses/RenderPipeline/Pipelines/lensRenderingPipeline" {
  74318. import { Camera } from "babylonjs/Cameras/camera";
  74319. import { PostProcessRenderPipeline } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  74320. import { Scene } from "babylonjs/scene";
  74321. import "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManagerSceneComponent";
  74322. import "babylonjs/Shaders/chromaticAberration.fragment";
  74323. import "babylonjs/Shaders/lensHighlights.fragment";
  74324. import "babylonjs/Shaders/depthOfField.fragment";
  74325. /**
  74326. * BABYLON.JS Chromatic Aberration GLSL Shader
  74327. * Author: Olivier Guyot
  74328. * Separates very slightly R, G and B colors on the edges of the screen
  74329. * Inspired by Francois Tarlier & Martins Upitis
  74330. */
  74331. export class LensRenderingPipeline extends PostProcessRenderPipeline {
  74332. /**
  74333. * @ignore
  74334. * The chromatic aberration PostProcess id in the pipeline
  74335. */
  74336. LensChromaticAberrationEffect: string;
  74337. /**
  74338. * @ignore
  74339. * The highlights enhancing PostProcess id in the pipeline
  74340. */
  74341. HighlightsEnhancingEffect: string;
  74342. /**
  74343. * @ignore
  74344. * The depth-of-field PostProcess id in the pipeline
  74345. */
  74346. LensDepthOfFieldEffect: string;
  74347. private _scene;
  74348. private _depthTexture;
  74349. private _grainTexture;
  74350. private _chromaticAberrationPostProcess;
  74351. private _highlightsPostProcess;
  74352. private _depthOfFieldPostProcess;
  74353. private _edgeBlur;
  74354. private _grainAmount;
  74355. private _chromaticAberration;
  74356. private _distortion;
  74357. private _highlightsGain;
  74358. private _highlightsThreshold;
  74359. private _dofDistance;
  74360. private _dofAperture;
  74361. private _dofDarken;
  74362. private _dofPentagon;
  74363. private _blurNoise;
  74364. /**
  74365. * @constructor
  74366. *
  74367. * Effect parameters are as follow:
  74368. * {
  74369. * chromatic_aberration: number; // from 0 to x (1 for realism)
  74370. * edge_blur: number; // from 0 to x (1 for realism)
  74371. * distortion: number; // from 0 to x (1 for realism)
  74372. * grain_amount: number; // from 0 to 1
  74373. * grain_texture: BABYLON.Texture; // texture to use for grain effect; if unset, use random B&W noise
  74374. * dof_focus_distance: number; // depth-of-field: focus distance; unset to disable (disabled by default)
  74375. * dof_aperture: number; // depth-of-field: focus blur bias (default: 1)
  74376. * dof_darken: number; // depth-of-field: darken that which is out of focus (from 0 to 1, disabled by default)
  74377. * dof_pentagon: boolean; // depth-of-field: makes a pentagon-like "bokeh" effect
  74378. * dof_gain: number; // depth-of-field: highlights gain; unset to disable (disabled by default)
  74379. * dof_threshold: number; // depth-of-field: highlights threshold (default: 1)
  74380. * blur_noise: boolean; // add a little bit of noise to the blur (default: true)
  74381. * }
  74382. * Note: if an effect parameter is unset, effect is disabled
  74383. *
  74384. * @param name The rendering pipeline name
  74385. * @param parameters - An object containing all parameters (see above)
  74386. * @param scene The scene linked to this pipeline
  74387. * @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)
  74388. * @param cameras The array of cameras that the rendering pipeline will be attached to
  74389. */
  74390. constructor(name: string, parameters: any, scene: Scene, ratio?: number, cameras?: Camera[]);
  74391. /**
  74392. * Get the class name
  74393. * @returns "LensRenderingPipeline"
  74394. */
  74395. getClassName(): string;
  74396. /**
  74397. * Gets associated scene
  74398. */
  74399. get scene(): Scene;
  74400. /**
  74401. * Gets or sets the edge blur
  74402. */
  74403. get edgeBlur(): number;
  74404. set edgeBlur(value: number);
  74405. /**
  74406. * Gets or sets the grain amount
  74407. */
  74408. get grainAmount(): number;
  74409. set grainAmount(value: number);
  74410. /**
  74411. * Gets or sets the chromatic aberration amount
  74412. */
  74413. get chromaticAberration(): number;
  74414. set chromaticAberration(value: number);
  74415. /**
  74416. * Gets or sets the depth of field aperture
  74417. */
  74418. get dofAperture(): number;
  74419. set dofAperture(value: number);
  74420. /**
  74421. * Gets or sets the edge distortion
  74422. */
  74423. get edgeDistortion(): number;
  74424. set edgeDistortion(value: number);
  74425. /**
  74426. * Gets or sets the depth of field distortion
  74427. */
  74428. get dofDistortion(): number;
  74429. set dofDistortion(value: number);
  74430. /**
  74431. * Gets or sets the darken out of focus amount
  74432. */
  74433. get darkenOutOfFocus(): number;
  74434. set darkenOutOfFocus(value: number);
  74435. /**
  74436. * Gets or sets a boolean indicating if blur noise is enabled
  74437. */
  74438. get blurNoise(): boolean;
  74439. set blurNoise(value: boolean);
  74440. /**
  74441. * Gets or sets a boolean indicating if pentagon bokeh is enabled
  74442. */
  74443. get pentagonBokeh(): boolean;
  74444. set pentagonBokeh(value: boolean);
  74445. /**
  74446. * Gets or sets the highlight grain amount
  74447. */
  74448. get highlightsGain(): number;
  74449. set highlightsGain(value: number);
  74450. /**
  74451. * Gets or sets the highlight threshold
  74452. */
  74453. get highlightsThreshold(): number;
  74454. set highlightsThreshold(value: number);
  74455. /**
  74456. * Sets the amount of blur at the edges
  74457. * @param amount blur amount
  74458. */
  74459. setEdgeBlur(amount: number): void;
  74460. /**
  74461. * Sets edge blur to 0
  74462. */
  74463. disableEdgeBlur(): void;
  74464. /**
  74465. * Sets the amout of grain
  74466. * @param amount Amount of grain
  74467. */
  74468. setGrainAmount(amount: number): void;
  74469. /**
  74470. * Set grain amount to 0
  74471. */
  74472. disableGrain(): void;
  74473. /**
  74474. * Sets the chromatic aberration amount
  74475. * @param amount amount of chromatic aberration
  74476. */
  74477. setChromaticAberration(amount: number): void;
  74478. /**
  74479. * Sets chromatic aberration amount to 0
  74480. */
  74481. disableChromaticAberration(): void;
  74482. /**
  74483. * Sets the EdgeDistortion amount
  74484. * @param amount amount of EdgeDistortion
  74485. */
  74486. setEdgeDistortion(amount: number): void;
  74487. /**
  74488. * Sets edge distortion to 0
  74489. */
  74490. disableEdgeDistortion(): void;
  74491. /**
  74492. * Sets the FocusDistance amount
  74493. * @param amount amount of FocusDistance
  74494. */
  74495. setFocusDistance(amount: number): void;
  74496. /**
  74497. * Disables depth of field
  74498. */
  74499. disableDepthOfField(): void;
  74500. /**
  74501. * Sets the Aperture amount
  74502. * @param amount amount of Aperture
  74503. */
  74504. setAperture(amount: number): void;
  74505. /**
  74506. * Sets the DarkenOutOfFocus amount
  74507. * @param amount amount of DarkenOutOfFocus
  74508. */
  74509. setDarkenOutOfFocus(amount: number): void;
  74510. private _pentagonBokehIsEnabled;
  74511. /**
  74512. * Creates a pentagon bokeh effect
  74513. */
  74514. enablePentagonBokeh(): void;
  74515. /**
  74516. * Disables the pentagon bokeh effect
  74517. */
  74518. disablePentagonBokeh(): void;
  74519. /**
  74520. * Enables noise blur
  74521. */
  74522. enableNoiseBlur(): void;
  74523. /**
  74524. * Disables noise blur
  74525. */
  74526. disableNoiseBlur(): void;
  74527. /**
  74528. * Sets the HighlightsGain amount
  74529. * @param amount amount of HighlightsGain
  74530. */
  74531. setHighlightsGain(amount: number): void;
  74532. /**
  74533. * Sets the HighlightsThreshold amount
  74534. * @param amount amount of HighlightsThreshold
  74535. */
  74536. setHighlightsThreshold(amount: number): void;
  74537. /**
  74538. * Disables highlights
  74539. */
  74540. disableHighlights(): void;
  74541. /**
  74542. * Removes the internal pipeline assets and detaches the pipeline from the scene cameras
  74543. * @param disableDepthRender If the scens depth rendering should be disabled (default: false)
  74544. */
  74545. dispose(disableDepthRender?: boolean): void;
  74546. private _createChromaticAberrationPostProcess;
  74547. private _createHighlightsPostProcess;
  74548. private _createDepthOfFieldPostProcess;
  74549. private _createGrainTexture;
  74550. }
  74551. }
  74552. declare module "babylonjs/Shaders/ssao2.fragment" {
  74553. /** @hidden */
  74554. export var ssao2PixelShader: {
  74555. name: string;
  74556. shader: string;
  74557. };
  74558. }
  74559. declare module "babylonjs/Shaders/ssaoCombine.fragment" {
  74560. /** @hidden */
  74561. export var ssaoCombinePixelShader: {
  74562. name: string;
  74563. shader: string;
  74564. };
  74565. }
  74566. declare module "babylonjs/PostProcesses/RenderPipeline/Pipelines/ssao2RenderingPipeline" {
  74567. import { Camera } from "babylonjs/Cameras/camera";
  74568. import { PostProcessRenderPipeline } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  74569. import { Scene } from "babylonjs/scene";
  74570. import "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManagerSceneComponent";
  74571. import "babylonjs/Shaders/ssao2.fragment";
  74572. import "babylonjs/Shaders/ssaoCombine.fragment";
  74573. import { PrePassRenderer } from "babylonjs/Rendering/prePassRenderer";
  74574. /**
  74575. * Render pipeline to produce ssao effect
  74576. */
  74577. export class SSAO2RenderingPipeline extends PostProcessRenderPipeline {
  74578. /**
  74579. * @ignore
  74580. * The PassPostProcess id in the pipeline that contains the original scene color
  74581. */
  74582. SSAOOriginalSceneColorEffect: string;
  74583. /**
  74584. * @ignore
  74585. * The SSAO PostProcess id in the pipeline
  74586. */
  74587. SSAORenderEffect: string;
  74588. /**
  74589. * @ignore
  74590. * The horizontal blur PostProcess id in the pipeline
  74591. */
  74592. SSAOBlurHRenderEffect: string;
  74593. /**
  74594. * @ignore
  74595. * The vertical blur PostProcess id in the pipeline
  74596. */
  74597. SSAOBlurVRenderEffect: string;
  74598. /**
  74599. * @ignore
  74600. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  74601. */
  74602. SSAOCombineRenderEffect: string;
  74603. /**
  74604. * The output strength of the SSAO post-process. Default value is 1.0.
  74605. */
  74606. totalStrength: number;
  74607. /**
  74608. * Maximum depth value to still render AO. A smooth falloff makes the dimming more natural, so there will be no abrupt shading change.
  74609. */
  74610. maxZ: number;
  74611. /**
  74612. * In order to save performances, SSAO radius is clamped on close geometry. This ratio changes by how much
  74613. */
  74614. minZAspect: number;
  74615. private _samples;
  74616. /**
  74617. * Number of samples used for the SSAO calculations. Default value is 8
  74618. */
  74619. set samples(n: number);
  74620. get samples(): number;
  74621. private _textureSamples;
  74622. /**
  74623. * Number of samples to use for antialiasing
  74624. */
  74625. set textureSamples(n: number);
  74626. get textureSamples(): number;
  74627. /**
  74628. * Force rendering the geometry through geometry buffer
  74629. */
  74630. private _forceGeometryBuffer;
  74631. /**
  74632. * Ratio object used for SSAO ratio and blur ratio
  74633. */
  74634. private _ratio;
  74635. /**
  74636. * Dynamically generated sphere sampler.
  74637. */
  74638. private _sampleSphere;
  74639. /**
  74640. * Blur filter offsets
  74641. */
  74642. private _samplerOffsets;
  74643. private _expensiveBlur;
  74644. /**
  74645. * If bilateral blur should be used
  74646. */
  74647. set expensiveBlur(b: boolean);
  74648. get expensiveBlur(): boolean;
  74649. /**
  74650. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 2.0
  74651. */
  74652. radius: number;
  74653. /**
  74654. * The base color of the SSAO post-process
  74655. * The final result is "base + ssao" between [0, 1]
  74656. */
  74657. base: number;
  74658. /**
  74659. * Support test.
  74660. */
  74661. static get IsSupported(): boolean;
  74662. private _scene;
  74663. private _randomTexture;
  74664. private _originalColorPostProcess;
  74665. private _ssaoPostProcess;
  74666. private _blurHPostProcess;
  74667. private _blurVPostProcess;
  74668. private _ssaoCombinePostProcess;
  74669. private _prePassRenderer;
  74670. /**
  74671. * Gets active scene
  74672. */
  74673. get scene(): Scene;
  74674. /**
  74675. * @constructor
  74676. * @param name The rendering pipeline name
  74677. * @param scene The scene linked to this pipeline
  74678. * @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 }
  74679. * @param cameras The array of cameras that the rendering pipeline will be attached to
  74680. * @param forceGeometryBuffer Set to true if you want to use the legacy geometry buffer renderer
  74681. */
  74682. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[], forceGeometryBuffer?: boolean);
  74683. /**
  74684. * Get the class name
  74685. * @returns "SSAO2RenderingPipeline"
  74686. */
  74687. getClassName(): string;
  74688. /**
  74689. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  74690. */
  74691. dispose(disableGeometryBufferRenderer?: boolean): void;
  74692. private _createBlurPostProcess;
  74693. /** @hidden */
  74694. _rebuild(): void;
  74695. private _bits;
  74696. private _radicalInverse_VdC;
  74697. private _hammersley;
  74698. private _hemisphereSample_uniform;
  74699. private _generateHemisphere;
  74700. private _getDefinesForSSAO;
  74701. private _createSSAOPostProcess;
  74702. private _createSSAOCombinePostProcess;
  74703. private _createRandomTexture;
  74704. /**
  74705. * Serialize the rendering pipeline (Used when exporting)
  74706. * @returns the serialized object
  74707. */
  74708. serialize(): any;
  74709. /**
  74710. * Parse the serialized pipeline
  74711. * @param source Source pipeline.
  74712. * @param scene The scene to load the pipeline to.
  74713. * @param rootUrl The URL of the serialized pipeline.
  74714. * @returns An instantiated pipeline from the serialized object.
  74715. */
  74716. static Parse(source: any, scene: Scene, rootUrl: string): SSAO2RenderingPipeline;
  74717. /**
  74718. * Sets the required values to the prepass renderer.
  74719. * @param prePassRenderer defines the prepass renderer to setup
  74720. * @returns true if the pre pass is needed.
  74721. */
  74722. setPrePassRenderer(prePassRenderer: PrePassRenderer): boolean;
  74723. }
  74724. }
  74725. declare module "babylonjs/Shaders/ssao.fragment" {
  74726. /** @hidden */
  74727. export var ssaoPixelShader: {
  74728. name: string;
  74729. shader: string;
  74730. };
  74731. }
  74732. declare module "babylonjs/PostProcesses/RenderPipeline/Pipelines/ssaoRenderingPipeline" {
  74733. import { Camera } from "babylonjs/Cameras/camera";
  74734. import { PostProcessRenderPipeline } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  74735. import { Scene } from "babylonjs/scene";
  74736. import "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManagerSceneComponent";
  74737. import "babylonjs/Shaders/ssao.fragment";
  74738. import "babylonjs/Shaders/ssaoCombine.fragment";
  74739. /**
  74740. * Render pipeline to produce ssao effect
  74741. */
  74742. export class SSAORenderingPipeline extends PostProcessRenderPipeline {
  74743. /**
  74744. * @ignore
  74745. * The PassPostProcess id in the pipeline that contains the original scene color
  74746. */
  74747. SSAOOriginalSceneColorEffect: string;
  74748. /**
  74749. * @ignore
  74750. * The SSAO PostProcess id in the pipeline
  74751. */
  74752. SSAORenderEffect: string;
  74753. /**
  74754. * @ignore
  74755. * The horizontal blur PostProcess id in the pipeline
  74756. */
  74757. SSAOBlurHRenderEffect: string;
  74758. /**
  74759. * @ignore
  74760. * The vertical blur PostProcess id in the pipeline
  74761. */
  74762. SSAOBlurVRenderEffect: string;
  74763. /**
  74764. * @ignore
  74765. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  74766. */
  74767. SSAOCombineRenderEffect: string;
  74768. /**
  74769. * The output strength of the SSAO post-process. Default value is 1.0.
  74770. */
  74771. totalStrength: number;
  74772. /**
  74773. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 0.0006
  74774. */
  74775. radius: number;
  74776. /**
  74777. * Related to fallOff, used to interpolate SSAO samples (first interpolate function input) based on the occlusion difference of each pixel
  74778. * Must not be equal to fallOff and superior to fallOff.
  74779. * Default value is 0.0075
  74780. */
  74781. area: number;
  74782. /**
  74783. * Related to area, used to interpolate SSAO samples (second interpolate function input) based on the occlusion difference of each pixel
  74784. * Must not be equal to area and inferior to area.
  74785. * Default value is 0.000001
  74786. */
  74787. fallOff: number;
  74788. /**
  74789. * The base color of the SSAO post-process
  74790. * The final result is "base + ssao" between [0, 1]
  74791. */
  74792. base: number;
  74793. private _scene;
  74794. private _depthTexture;
  74795. private _randomTexture;
  74796. private _originalColorPostProcess;
  74797. private _ssaoPostProcess;
  74798. private _blurHPostProcess;
  74799. private _blurVPostProcess;
  74800. private _ssaoCombinePostProcess;
  74801. private _firstUpdate;
  74802. /**
  74803. * Gets active scene
  74804. */
  74805. get scene(): Scene;
  74806. /**
  74807. * @constructor
  74808. * @param name - The rendering pipeline name
  74809. * @param scene - The scene linked to this pipeline
  74810. * @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 }
  74811. * @param cameras - The array of cameras that the rendering pipeline will be attached to
  74812. */
  74813. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[]);
  74814. /**
  74815. * Get the class name
  74816. * @returns "SSAORenderingPipeline"
  74817. */
  74818. getClassName(): string;
  74819. /**
  74820. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  74821. */
  74822. dispose(disableDepthRender?: boolean): void;
  74823. private _createBlurPostProcess;
  74824. /** @hidden */
  74825. _rebuild(): void;
  74826. private _createSSAOPostProcess;
  74827. private _createSSAOCombinePostProcess;
  74828. private _createRandomTexture;
  74829. }
  74830. }
  74831. declare module "babylonjs/Shaders/screenSpaceReflection.fragment" {
  74832. /** @hidden */
  74833. export var screenSpaceReflectionPixelShader: {
  74834. name: string;
  74835. shader: string;
  74836. };
  74837. }
  74838. declare module "babylonjs/PostProcesses/screenSpaceReflectionPostProcess" {
  74839. import { Nullable } from "babylonjs/types";
  74840. import { Camera } from "babylonjs/Cameras/camera";
  74841. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  74842. import "babylonjs/Shaders/screenSpaceReflection.fragment";
  74843. import { Engine } from "babylonjs/Engines/engine";
  74844. import { Scene } from "babylonjs/scene";
  74845. /**
  74846. * The ScreenSpaceReflectionPostProcess performs realtime reflections using only and only the available informations on the screen (positions and normals).
  74847. * Basically, the screen space reflection post-process will compute reflections according the material's reflectivity.
  74848. */
  74849. export class ScreenSpaceReflectionPostProcess extends PostProcess {
  74850. /**
  74851. * Gets or sets a reflection threshold mainly used to adjust the reflection's height.
  74852. */
  74853. threshold: number;
  74854. /**
  74855. * Gets or sets the current reflection strength. 1.0 is an ideal value but can be increased/decreased for particular results.
  74856. */
  74857. strength: number;
  74858. /**
  74859. * Gets or sets the falloff exponent used while computing fresnel. More the exponent is high, more the reflections will be discrete.
  74860. */
  74861. reflectionSpecularFalloffExponent: number;
  74862. /**
  74863. * 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]
  74864. */
  74865. step: number;
  74866. /**
  74867. * Gets or sets the factor applied when computing roughness. Default value is 0.2.
  74868. */
  74869. roughnessFactor: number;
  74870. private _geometryBufferRenderer;
  74871. private _enableSmoothReflections;
  74872. private _reflectionSamples;
  74873. private _smoothSteps;
  74874. /**
  74875. * Gets a string identifying the name of the class
  74876. * @returns "ScreenSpaceReflectionPostProcess" string
  74877. */
  74878. getClassName(): string;
  74879. /**
  74880. * Creates a new instance of ScreenSpaceReflectionPostProcess.
  74881. * @param name The name of the effect.
  74882. * @param scene The scene containing the objects to calculate reflections.
  74883. * @param options The required width/height ratio to downsize to before computing the render pass.
  74884. * @param camera The camera to apply the render pass to.
  74885. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  74886. * @param engine The engine which the post process will be applied. (default: current engine)
  74887. * @param reusable If the post process can be reused on the same frame. (default: false)
  74888. * @param textureType Type of textures used when performing the post process. (default: 0)
  74889. * @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)
  74890. */
  74891. constructor(name: string, scene: Scene, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  74892. /**
  74893. * Gets wether or not smoothing reflections is enabled.
  74894. * Enabling smoothing will require more GPU power and can generate a drop in FPS.
  74895. */
  74896. get enableSmoothReflections(): boolean;
  74897. /**
  74898. * Sets wether or not smoothing reflections is enabled.
  74899. * Enabling smoothing will require more GPU power and can generate a drop in FPS.
  74900. */
  74901. set enableSmoothReflections(enabled: boolean);
  74902. /**
  74903. * Gets the number of samples taken while computing reflections. More samples count is high,
  74904. * more the post-process wil require GPU power and can generate a drop in FPS. Basically in interval [25, 100].
  74905. */
  74906. get reflectionSamples(): number;
  74907. /**
  74908. * Sets the number of samples taken while computing reflections. More samples count is high,
  74909. * more the post-process wil require GPU power and can generate a drop in FPS. Basically in interval [25, 100].
  74910. */
  74911. set reflectionSamples(samples: number);
  74912. /**
  74913. * Gets the number of samples taken while smoothing reflections. More samples count is high,
  74914. * more the post-process will require GPU power and can generate a drop in FPS.
  74915. * Default value (5.0) work pretty well in all cases but can be adjusted.
  74916. */
  74917. get smoothSteps(): number;
  74918. set smoothSteps(steps: number);
  74919. private _updateEffectDefines;
  74920. /** @hidden */
  74921. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): ScreenSpaceReflectionPostProcess;
  74922. }
  74923. }
  74924. declare module "babylonjs/Shaders/standard.fragment" {
  74925. import "babylonjs/Shaders/ShadersInclude/packingFunctions";
  74926. /** @hidden */
  74927. export var standardPixelShader: {
  74928. name: string;
  74929. shader: string;
  74930. };
  74931. }
  74932. declare module "babylonjs/PostProcesses/RenderPipeline/Pipelines/standardRenderingPipeline" {
  74933. import { Nullable } from "babylonjs/types";
  74934. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  74935. import { Camera } from "babylonjs/Cameras/camera";
  74936. import { Texture } from "babylonjs/Materials/Textures/texture";
  74937. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  74938. import { PostProcessRenderPipeline } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  74939. import { BlurPostProcess } from "babylonjs/PostProcesses/blurPostProcess";
  74940. import { FxaaPostProcess } from "babylonjs/PostProcesses/fxaaPostProcess";
  74941. import { IDisposable } from "babylonjs/scene";
  74942. import { SpotLight } from "babylonjs/Lights/spotLight";
  74943. import { DirectionalLight } from "babylonjs/Lights/directionalLight";
  74944. import { Scene } from "babylonjs/scene";
  74945. import { ScreenSpaceReflectionPostProcess } from "babylonjs/PostProcesses/screenSpaceReflectionPostProcess";
  74946. import { Animation } from "babylonjs/Animations/animation";
  74947. import "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManagerSceneComponent";
  74948. import "babylonjs/Shaders/standard.fragment";
  74949. /**
  74950. * Standard rendering pipeline
  74951. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  74952. * @see https://doc.babylonjs.com/how_to/using_standard_rendering_pipeline
  74953. */
  74954. export class StandardRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  74955. /**
  74956. * Public members
  74957. */
  74958. /**
  74959. * Post-process which contains the original scene color before the pipeline applies all the effects
  74960. */
  74961. originalPostProcess: Nullable<PostProcess>;
  74962. /**
  74963. * Post-process used to down scale an image x4
  74964. */
  74965. downSampleX4PostProcess: Nullable<PostProcess>;
  74966. /**
  74967. * Post-process used to calculate the illuminated surfaces controlled by a threshold
  74968. */
  74969. brightPassPostProcess: Nullable<PostProcess>;
  74970. /**
  74971. * Post-process array storing all the horizontal blur post-processes used by the pipeline
  74972. */
  74973. blurHPostProcesses: PostProcess[];
  74974. /**
  74975. * Post-process array storing all the vertical blur post-processes used by the pipeline
  74976. */
  74977. blurVPostProcesses: PostProcess[];
  74978. /**
  74979. * Post-process used to add colors of 2 textures (typically brightness + real scene color)
  74980. */
  74981. textureAdderPostProcess: Nullable<PostProcess>;
  74982. /**
  74983. * Post-process used to create volumetric lighting effect
  74984. */
  74985. volumetricLightPostProcess: Nullable<PostProcess>;
  74986. /**
  74987. * Post-process used to smooth the previous volumetric light post-process on the X axis
  74988. */
  74989. volumetricLightSmoothXPostProcess: Nullable<BlurPostProcess>;
  74990. /**
  74991. * Post-process used to smooth the previous volumetric light post-process on the Y axis
  74992. */
  74993. volumetricLightSmoothYPostProcess: Nullable<BlurPostProcess>;
  74994. /**
  74995. * Post-process used to merge the volumetric light effect and the real scene color
  74996. */
  74997. volumetricLightMergePostProces: Nullable<PostProcess>;
  74998. /**
  74999. * Post-process used to store the final volumetric light post-process (attach/detach for debug purpose)
  75000. */
  75001. volumetricLightFinalPostProcess: Nullable<PostProcess>;
  75002. /**
  75003. * Base post-process used to calculate the average luminance of the final image for HDR
  75004. */
  75005. luminancePostProcess: Nullable<PostProcess>;
  75006. /**
  75007. * Post-processes used to create down sample post-processes in order to get
  75008. * the average luminance of the final image for HDR
  75009. * Array of length "StandardRenderingPipeline.LuminanceSteps"
  75010. */
  75011. luminanceDownSamplePostProcesses: PostProcess[];
  75012. /**
  75013. * Post-process used to create a HDR effect (light adaptation)
  75014. */
  75015. hdrPostProcess: Nullable<PostProcess>;
  75016. /**
  75017. * Post-process used to store the final texture adder post-process (attach/detach for debug purpose)
  75018. */
  75019. textureAdderFinalPostProcess: Nullable<PostProcess>;
  75020. /**
  75021. * Post-process used to store the final lens flare post-process (attach/detach for debug purpose)
  75022. */
  75023. lensFlareFinalPostProcess: Nullable<PostProcess>;
  75024. /**
  75025. * Post-process used to merge the final HDR post-process and the real scene color
  75026. */
  75027. hdrFinalPostProcess: Nullable<PostProcess>;
  75028. /**
  75029. * Post-process used to create a lens flare effect
  75030. */
  75031. lensFlarePostProcess: Nullable<PostProcess>;
  75032. /**
  75033. * Post-process that merges the result of the lens flare post-process and the real scene color
  75034. */
  75035. lensFlareComposePostProcess: Nullable<PostProcess>;
  75036. /**
  75037. * Post-process used to create a motion blur effect
  75038. */
  75039. motionBlurPostProcess: Nullable<PostProcess>;
  75040. /**
  75041. * Post-process used to create a depth of field effect
  75042. */
  75043. depthOfFieldPostProcess: Nullable<PostProcess>;
  75044. /**
  75045. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  75046. */
  75047. fxaaPostProcess: Nullable<FxaaPostProcess>;
  75048. /**
  75049. * Post-process used to simulate realtime reflections using the screen space and geometry renderer.
  75050. */
  75051. screenSpaceReflectionPostProcess: Nullable<ScreenSpaceReflectionPostProcess>;
  75052. /**
  75053. * Represents the brightness threshold in order to configure the illuminated surfaces
  75054. */
  75055. brightThreshold: number;
  75056. /**
  75057. * Configures the blur intensity used for surexposed surfaces are highlighted surfaces (light halo)
  75058. */
  75059. blurWidth: number;
  75060. /**
  75061. * Sets if the blur for highlighted surfaces must be only horizontal
  75062. */
  75063. horizontalBlur: boolean;
  75064. /**
  75065. * Gets the overall exposure used by the pipeline
  75066. */
  75067. get exposure(): number;
  75068. /**
  75069. * Sets the overall exposure used by the pipeline
  75070. */
  75071. set exposure(value: number);
  75072. /**
  75073. * Texture used typically to simulate "dirty" on camera lens
  75074. */
  75075. lensTexture: Nullable<Texture>;
  75076. /**
  75077. * Represents the offset coefficient based on Rayleigh principle. Typically in interval [-0.2, 0.2]
  75078. */
  75079. volumetricLightCoefficient: number;
  75080. /**
  75081. * The overall power of volumetric lights, typically in interval [0, 10] maximum
  75082. */
  75083. volumetricLightPower: number;
  75084. /**
  75085. * Used the set the blur intensity to smooth the volumetric lights
  75086. */
  75087. volumetricLightBlurScale: number;
  75088. /**
  75089. * Light (spot or directional) used to generate the volumetric lights rays
  75090. * The source light must have a shadow generate so the pipeline can get its
  75091. * depth map
  75092. */
  75093. sourceLight: Nullable<SpotLight | DirectionalLight>;
  75094. /**
  75095. * For eye adaptation, represents the minimum luminance the eye can see
  75096. */
  75097. hdrMinimumLuminance: number;
  75098. /**
  75099. * For eye adaptation, represents the decrease luminance speed
  75100. */
  75101. hdrDecreaseRate: number;
  75102. /**
  75103. * For eye adaptation, represents the increase luminance speed
  75104. */
  75105. hdrIncreaseRate: number;
  75106. /**
  75107. * Gets wether or not the exposure of the overall pipeline should be automatically adjusted by the HDR post-process
  75108. */
  75109. get hdrAutoExposure(): boolean;
  75110. /**
  75111. * Sets wether or not the exposure of the overall pipeline should be automatically adjusted by the HDR post-process
  75112. */
  75113. set hdrAutoExposure(value: boolean);
  75114. /**
  75115. * Lens color texture used by the lens flare effect. Mandatory if lens flare effect enabled
  75116. */
  75117. lensColorTexture: Nullable<Texture>;
  75118. /**
  75119. * The overall strengh for the lens flare effect
  75120. */
  75121. lensFlareStrength: number;
  75122. /**
  75123. * Dispersion coefficient for lens flare ghosts
  75124. */
  75125. lensFlareGhostDispersal: number;
  75126. /**
  75127. * Main lens flare halo width
  75128. */
  75129. lensFlareHaloWidth: number;
  75130. /**
  75131. * Based on the lens distortion effect, defines how much the lens flare result
  75132. * is distorted
  75133. */
  75134. lensFlareDistortionStrength: number;
  75135. /**
  75136. * Configures the blur intensity used for for lens flare (halo)
  75137. */
  75138. lensFlareBlurWidth: number;
  75139. /**
  75140. * Lens star texture must be used to simulate rays on the flares and is available
  75141. * in the documentation
  75142. */
  75143. lensStarTexture: Nullable<Texture>;
  75144. /**
  75145. * As the "lensTexture" (can be the same texture or different), it is used to apply the lens
  75146. * flare effect by taking account of the dirt texture
  75147. */
  75148. lensFlareDirtTexture: Nullable<Texture>;
  75149. /**
  75150. * Represents the focal length for the depth of field effect
  75151. */
  75152. depthOfFieldDistance: number;
  75153. /**
  75154. * Represents the blur intensity for the blurred part of the depth of field effect
  75155. */
  75156. depthOfFieldBlurWidth: number;
  75157. /**
  75158. * Gets how much the image is blurred by the movement while using the motion blur post-process
  75159. */
  75160. get motionStrength(): number;
  75161. /**
  75162. * Sets how much the image is blurred by the movement while using the motion blur post-process
  75163. */
  75164. set motionStrength(strength: number);
  75165. /**
  75166. * Gets wether or not the motion blur post-process is object based or screen based.
  75167. */
  75168. get objectBasedMotionBlur(): boolean;
  75169. /**
  75170. * Sets wether or not the motion blur post-process should be object based or screen based
  75171. */
  75172. set objectBasedMotionBlur(value: boolean);
  75173. /**
  75174. * List of animations for the pipeline (IAnimatable implementation)
  75175. */
  75176. animations: Animation[];
  75177. /**
  75178. * Private members
  75179. */
  75180. private _scene;
  75181. private _currentDepthOfFieldSource;
  75182. private _basePostProcess;
  75183. private _fixedExposure;
  75184. private _currentExposure;
  75185. private _hdrAutoExposure;
  75186. private _hdrCurrentLuminance;
  75187. private _motionStrength;
  75188. private _isObjectBasedMotionBlur;
  75189. private _floatTextureType;
  75190. private _camerasToBeAttached;
  75191. private _ratio;
  75192. private _bloomEnabled;
  75193. private _depthOfFieldEnabled;
  75194. private _vlsEnabled;
  75195. private _lensFlareEnabled;
  75196. private _hdrEnabled;
  75197. private _motionBlurEnabled;
  75198. private _fxaaEnabled;
  75199. private _screenSpaceReflectionsEnabled;
  75200. private _motionBlurSamples;
  75201. private _volumetricLightStepsCount;
  75202. private _samples;
  75203. /**
  75204. * @ignore
  75205. * Specifies if the bloom pipeline is enabled
  75206. */
  75207. get BloomEnabled(): boolean;
  75208. set BloomEnabled(enabled: boolean);
  75209. /**
  75210. * @ignore
  75211. * Specifies if the depth of field pipeline is enabed
  75212. */
  75213. get DepthOfFieldEnabled(): boolean;
  75214. set DepthOfFieldEnabled(enabled: boolean);
  75215. /**
  75216. * @ignore
  75217. * Specifies if the lens flare pipeline is enabed
  75218. */
  75219. get LensFlareEnabled(): boolean;
  75220. set LensFlareEnabled(enabled: boolean);
  75221. /**
  75222. * @ignore
  75223. * Specifies if the HDR pipeline is enabled
  75224. */
  75225. get HDREnabled(): boolean;
  75226. set HDREnabled(enabled: boolean);
  75227. /**
  75228. * @ignore
  75229. * Specifies if the volumetric lights scattering effect is enabled
  75230. */
  75231. get VLSEnabled(): boolean;
  75232. set VLSEnabled(enabled: boolean);
  75233. /**
  75234. * @ignore
  75235. * Specifies if the motion blur effect is enabled
  75236. */
  75237. get MotionBlurEnabled(): boolean;
  75238. set MotionBlurEnabled(enabled: boolean);
  75239. /**
  75240. * Specifies if anti-aliasing is enabled
  75241. */
  75242. get fxaaEnabled(): boolean;
  75243. set fxaaEnabled(enabled: boolean);
  75244. /**
  75245. * Specifies if screen space reflections are enabled.
  75246. */
  75247. get screenSpaceReflectionsEnabled(): boolean;
  75248. set screenSpaceReflectionsEnabled(enabled: boolean);
  75249. /**
  75250. * Specifies the number of steps used to calculate the volumetric lights
  75251. * Typically in interval [50, 200]
  75252. */
  75253. get volumetricLightStepsCount(): number;
  75254. set volumetricLightStepsCount(count: number);
  75255. /**
  75256. * Specifies the number of samples used for the motion blur effect
  75257. * Typically in interval [16, 64]
  75258. */
  75259. get motionBlurSamples(): number;
  75260. set motionBlurSamples(samples: number);
  75261. /**
  75262. * Specifies MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  75263. */
  75264. get samples(): number;
  75265. set samples(sampleCount: number);
  75266. /**
  75267. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  75268. * @constructor
  75269. * @param name The rendering pipeline name
  75270. * @param scene The scene linked to this pipeline
  75271. * @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)
  75272. * @param originalPostProcess the custom original color post-process. Must be "reusable". Can be null.
  75273. * @param cameras The array of cameras that the rendering pipeline will be attached to
  75274. */
  75275. constructor(name: string, scene: Scene, ratio: number, originalPostProcess?: Nullable<PostProcess>, cameras?: Camera[]);
  75276. private _buildPipeline;
  75277. private _createDownSampleX4PostProcess;
  75278. private _createBrightPassPostProcess;
  75279. private _createBlurPostProcesses;
  75280. private _createTextureAdderPostProcess;
  75281. private _createVolumetricLightPostProcess;
  75282. private _createLuminancePostProcesses;
  75283. private _createHdrPostProcess;
  75284. private _createLensFlarePostProcess;
  75285. private _createDepthOfFieldPostProcess;
  75286. private _createMotionBlurPostProcess;
  75287. private _getDepthTexture;
  75288. private _disposePostProcesses;
  75289. /**
  75290. * Dispose of the pipeline and stop all post processes
  75291. */
  75292. dispose(): void;
  75293. /**
  75294. * Serialize the rendering pipeline (Used when exporting)
  75295. * @returns the serialized object
  75296. */
  75297. serialize(): any;
  75298. /**
  75299. * Parse the serialized pipeline
  75300. * @param source Source pipeline.
  75301. * @param scene The scene to load the pipeline to.
  75302. * @param rootUrl The URL of the serialized pipeline.
  75303. * @returns An instantiated pipeline from the serialized object.
  75304. */
  75305. static Parse(source: any, scene: Scene, rootUrl: string): StandardRenderingPipeline;
  75306. /**
  75307. * Luminance steps
  75308. */
  75309. static LuminanceSteps: number;
  75310. }
  75311. }
  75312. declare module "babylonjs/PostProcesses/RenderPipeline/Pipelines/index" {
  75313. export * from "babylonjs/PostProcesses/RenderPipeline/Pipelines/defaultRenderingPipeline";
  75314. export * from "babylonjs/PostProcesses/RenderPipeline/Pipelines/lensRenderingPipeline";
  75315. export * from "babylonjs/PostProcesses/RenderPipeline/Pipelines/ssao2RenderingPipeline";
  75316. export * from "babylonjs/PostProcesses/RenderPipeline/Pipelines/ssaoRenderingPipeline";
  75317. export * from "babylonjs/PostProcesses/RenderPipeline/Pipelines/standardRenderingPipeline";
  75318. }
  75319. declare module "babylonjs/PostProcesses/RenderPipeline/index" {
  75320. export * from "babylonjs/PostProcesses/RenderPipeline/Pipelines/index";
  75321. export * from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderEffect";
  75322. export * from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  75323. export * from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManager";
  75324. export * from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManagerSceneComponent";
  75325. }
  75326. declare module "babylonjs/Shaders/stereoscopicInterlace.fragment" {
  75327. /** @hidden */
  75328. export var stereoscopicInterlacePixelShader: {
  75329. name: string;
  75330. shader: string;
  75331. };
  75332. }
  75333. declare module "babylonjs/PostProcesses/stereoscopicInterlacePostProcess" {
  75334. import { Camera } from "babylonjs/Cameras/camera";
  75335. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  75336. import { Engine } from "babylonjs/Engines/engine";
  75337. import "babylonjs/Shaders/stereoscopicInterlace.fragment";
  75338. /**
  75339. * StereoscopicInterlacePostProcessI used to render stereo views from a rigged camera with support for alternate line interlacing
  75340. */
  75341. export class StereoscopicInterlacePostProcessI extends PostProcess {
  75342. private _stepSize;
  75343. private _passedProcess;
  75344. /**
  75345. * Gets a string identifying the name of the class
  75346. * @returns "StereoscopicInterlacePostProcessI" string
  75347. */
  75348. getClassName(): string;
  75349. /**
  75350. * Initializes a StereoscopicInterlacePostProcessI
  75351. * @param name The name of the effect.
  75352. * @param rigCameras The rig cameras to be appled to the post process
  75353. * @param isStereoscopicHoriz If the rendered results are horizontal or vertical
  75354. * @param isStereoscopicInterlaced If the rendered results are alternate line interlaced
  75355. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  75356. * @param engine The engine which the post process will be applied. (default: current engine)
  75357. * @param reusable If the post process can be reused on the same frame. (default: false)
  75358. */
  75359. constructor(name: string, rigCameras: Camera[], isStereoscopicHoriz: boolean, isStereoscopicInterlaced: boolean, samplingMode?: number, engine?: Engine, reusable?: boolean);
  75360. }
  75361. /**
  75362. * StereoscopicInterlacePostProcess used to render stereo views from a rigged camera
  75363. */
  75364. export class StereoscopicInterlacePostProcess extends PostProcess {
  75365. private _stepSize;
  75366. private _passedProcess;
  75367. /**
  75368. * Gets a string identifying the name of the class
  75369. * @returns "StereoscopicInterlacePostProcess" string
  75370. */
  75371. getClassName(): string;
  75372. /**
  75373. * Initializes a StereoscopicInterlacePostProcess
  75374. * @param name The name of the effect.
  75375. * @param rigCameras The rig cameras to be appled to the post process
  75376. * @param isStereoscopicHoriz If the rendered results are horizontal or verticle
  75377. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  75378. * @param engine The engine which the post process will be applied. (default: current engine)
  75379. * @param reusable If the post process can be reused on the same frame. (default: false)
  75380. */
  75381. constructor(name: string, rigCameras: Camera[], isStereoscopicHoriz: boolean, samplingMode?: number, engine?: Engine, reusable?: boolean);
  75382. }
  75383. }
  75384. declare module "babylonjs/Shaders/tonemap.fragment" {
  75385. /** @hidden */
  75386. export var tonemapPixelShader: {
  75387. name: string;
  75388. shader: string;
  75389. };
  75390. }
  75391. declare module "babylonjs/PostProcesses/tonemapPostProcess" {
  75392. import { Camera } from "babylonjs/Cameras/camera";
  75393. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  75394. import "babylonjs/Shaders/tonemap.fragment";
  75395. import { Engine } from "babylonjs/Engines/engine";
  75396. /** Defines operator used for tonemapping */
  75397. export enum TonemappingOperator {
  75398. /** Hable */
  75399. Hable = 0,
  75400. /** Reinhard */
  75401. Reinhard = 1,
  75402. /** HejiDawson */
  75403. HejiDawson = 2,
  75404. /** Photographic */
  75405. Photographic = 3
  75406. }
  75407. /**
  75408. * Defines a post process to apply tone mapping
  75409. */
  75410. export class TonemapPostProcess extends PostProcess {
  75411. private _operator;
  75412. /** Defines the required exposure adjustement */
  75413. exposureAdjustment: number;
  75414. /**
  75415. * Gets a string identifying the name of the class
  75416. * @returns "TonemapPostProcess" string
  75417. */
  75418. getClassName(): string;
  75419. /**
  75420. * Creates a new TonemapPostProcess
  75421. * @param name defines the name of the postprocess
  75422. * @param _operator defines the operator to use
  75423. * @param exposureAdjustment defines the required exposure adjustement
  75424. * @param camera defines the camera to use (can be null)
  75425. * @param samplingMode defines the required sampling mode (BABYLON.Texture.BILINEAR_SAMPLINGMODE by default)
  75426. * @param engine defines the hosting engine (can be ignore if camera is set)
  75427. * @param textureFormat defines the texture format to use (BABYLON.Engine.TEXTURETYPE_UNSIGNED_INT by default)
  75428. */
  75429. constructor(name: string, _operator: TonemappingOperator,
  75430. /** Defines the required exposure adjustement */
  75431. exposureAdjustment: number, camera: Camera, samplingMode?: number, engine?: Engine, textureFormat?: number);
  75432. }
  75433. }
  75434. declare module "babylonjs/Shaders/volumetricLightScattering.fragment" {
  75435. /** @hidden */
  75436. export var volumetricLightScatteringPixelShader: {
  75437. name: string;
  75438. shader: string;
  75439. };
  75440. }
  75441. declare module "babylonjs/Shaders/volumetricLightScatteringPass.vertex" {
  75442. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  75443. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  75444. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  75445. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  75446. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  75447. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  75448. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  75449. /** @hidden */
  75450. export var volumetricLightScatteringPassVertexShader: {
  75451. name: string;
  75452. shader: string;
  75453. };
  75454. }
  75455. declare module "babylonjs/Shaders/volumetricLightScatteringPass.fragment" {
  75456. /** @hidden */
  75457. export var volumetricLightScatteringPassPixelShader: {
  75458. name: string;
  75459. shader: string;
  75460. };
  75461. }
  75462. declare module "babylonjs/PostProcesses/volumetricLightScatteringPostProcess" {
  75463. import { Vector3 } from "babylonjs/Maths/math.vector";
  75464. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  75465. import { Mesh } from "babylonjs/Meshes/mesh";
  75466. import { Camera } from "babylonjs/Cameras/camera";
  75467. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  75468. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  75469. import { Scene } from "babylonjs/scene";
  75470. import "babylonjs/Meshes/Builders/planeBuilder";
  75471. import "babylonjs/Shaders/depth.vertex";
  75472. import "babylonjs/Shaders/volumetricLightScattering.fragment";
  75473. import "babylonjs/Shaders/volumetricLightScatteringPass.vertex";
  75474. import "babylonjs/Shaders/volumetricLightScatteringPass.fragment";
  75475. import { Engine } from "babylonjs/Engines/engine";
  75476. /**
  75477. * Inspired by http://http.developer.nvidia.com/GPUGems3/gpugems3_ch13.html
  75478. */
  75479. export class VolumetricLightScatteringPostProcess extends PostProcess {
  75480. private _volumetricLightScatteringPass;
  75481. private _volumetricLightScatteringRTT;
  75482. private _viewPort;
  75483. private _screenCoordinates;
  75484. private _cachedDefines;
  75485. /**
  75486. * If not undefined, the mesh position is computed from the attached node position
  75487. */
  75488. attachedNode: {
  75489. position: Vector3;
  75490. };
  75491. /**
  75492. * Custom position of the mesh. Used if "useCustomMeshPosition" is set to "true"
  75493. */
  75494. customMeshPosition: Vector3;
  75495. /**
  75496. * Set if the post-process should use a custom position for the light source (true) or the internal mesh position (false)
  75497. */
  75498. useCustomMeshPosition: boolean;
  75499. /**
  75500. * If the post-process should inverse the light scattering direction
  75501. */
  75502. invert: boolean;
  75503. /**
  75504. * The internal mesh used by the post-process
  75505. */
  75506. mesh: Mesh;
  75507. /**
  75508. * @hidden
  75509. * VolumetricLightScatteringPostProcess.useDiffuseColor is no longer used, use the mesh material directly instead
  75510. */
  75511. get useDiffuseColor(): boolean;
  75512. set useDiffuseColor(useDiffuseColor: boolean);
  75513. /**
  75514. * Array containing the excluded meshes not rendered in the internal pass
  75515. */
  75516. excludedMeshes: AbstractMesh[];
  75517. /**
  75518. * Controls the overall intensity of the post-process
  75519. */
  75520. exposure: number;
  75521. /**
  75522. * Dissipates each sample's contribution in range [0, 1]
  75523. */
  75524. decay: number;
  75525. /**
  75526. * Controls the overall intensity of each sample
  75527. */
  75528. weight: number;
  75529. /**
  75530. * Controls the density of each sample
  75531. */
  75532. density: number;
  75533. /**
  75534. * @constructor
  75535. * @param name The post-process name
  75536. * @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)
  75537. * @param camera The camera that the post-process will be attached to
  75538. * @param mesh The mesh used to create the light scattering
  75539. * @param samples The post-process quality, default 100
  75540. * @param samplingModeThe post-process filtering mode
  75541. * @param engine The babylon engine
  75542. * @param reusable If the post-process is reusable
  75543. * @param scene The constructor needs a scene reference to initialize internal components. If "camera" is null a "scene" must be provided
  75544. */
  75545. constructor(name: string, ratio: any, camera: Camera, mesh?: Mesh, samples?: number, samplingMode?: number, engine?: Engine, reusable?: boolean, scene?: Scene);
  75546. /**
  75547. * Returns the string "VolumetricLightScatteringPostProcess"
  75548. * @returns "VolumetricLightScatteringPostProcess"
  75549. */
  75550. getClassName(): string;
  75551. private _isReady;
  75552. /**
  75553. * Sets the new light position for light scattering effect
  75554. * @param position The new custom light position
  75555. */
  75556. setCustomMeshPosition(position: Vector3): void;
  75557. /**
  75558. * Returns the light position for light scattering effect
  75559. * @return Vector3 The custom light position
  75560. */
  75561. getCustomMeshPosition(): Vector3;
  75562. /**
  75563. * Disposes the internal assets and detaches the post-process from the camera
  75564. */
  75565. dispose(camera: Camera): void;
  75566. /**
  75567. * Returns the render target texture used by the post-process
  75568. * @return the render target texture used by the post-process
  75569. */
  75570. getPass(): RenderTargetTexture;
  75571. private _meshExcluded;
  75572. private _createPass;
  75573. private _updateMeshScreenCoordinates;
  75574. /**
  75575. * Creates a default mesh for the Volumeric Light Scattering post-process
  75576. * @param name The mesh name
  75577. * @param scene The scene where to create the mesh
  75578. * @return the default mesh
  75579. */
  75580. static CreateDefaultMesh(name: string, scene: Scene): Mesh;
  75581. }
  75582. }
  75583. declare module "babylonjs/Shaders/screenSpaceCurvature.fragment" {
  75584. /** @hidden */
  75585. export var screenSpaceCurvaturePixelShader: {
  75586. name: string;
  75587. shader: string;
  75588. };
  75589. }
  75590. declare module "babylonjs/PostProcesses/screenSpaceCurvaturePostProcess" {
  75591. import { Nullable } from "babylonjs/types";
  75592. import { Camera } from "babylonjs/Cameras/camera";
  75593. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  75594. import "babylonjs/Rendering/geometryBufferRendererSceneComponent";
  75595. import "babylonjs/Shaders/screenSpaceCurvature.fragment";
  75596. import { Engine } from "babylonjs/Engines/engine";
  75597. import { Scene } from "babylonjs/scene";
  75598. /**
  75599. * The Screen Space curvature effect can help highlighting ridge and valley of a model.
  75600. */
  75601. export class ScreenSpaceCurvaturePostProcess extends PostProcess {
  75602. /**
  75603. * Defines how much ridge the curvature effect displays.
  75604. */
  75605. ridge: number;
  75606. /**
  75607. * Defines how much valley the curvature effect displays.
  75608. */
  75609. valley: number;
  75610. private _geometryBufferRenderer;
  75611. /**
  75612. * Gets a string identifying the name of the class
  75613. * @returns "ScreenSpaceCurvaturePostProcess" string
  75614. */
  75615. getClassName(): string;
  75616. /**
  75617. * Creates a new instance ScreenSpaceCurvaturePostProcess
  75618. * @param name The name of the effect.
  75619. * @param scene The scene containing the objects to blur according to their velocity.
  75620. * @param options The required width/height ratio to downsize to before computing the render pass.
  75621. * @param camera The camera to apply the render pass to.
  75622. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  75623. * @param engine The engine which the post process will be applied. (default: current engine)
  75624. * @param reusable If the post process can be reused on the same frame. (default: false)
  75625. * @param textureType Type of textures used when performing the post process. (default: 0)
  75626. * @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)
  75627. */
  75628. constructor(name: string, scene: Scene, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  75629. /**
  75630. * Support test.
  75631. */
  75632. static get IsSupported(): boolean;
  75633. /** @hidden */
  75634. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): ScreenSpaceCurvaturePostProcess;
  75635. }
  75636. }
  75637. declare module "babylonjs/PostProcesses/index" {
  75638. export * from "babylonjs/PostProcesses/anaglyphPostProcess";
  75639. export * from "babylonjs/PostProcesses/blackAndWhitePostProcess";
  75640. export * from "babylonjs/PostProcesses/bloomEffect";
  75641. export * from "babylonjs/PostProcesses/bloomMergePostProcess";
  75642. export * from "babylonjs/PostProcesses/blurPostProcess";
  75643. export * from "babylonjs/PostProcesses/chromaticAberrationPostProcess";
  75644. export * from "babylonjs/PostProcesses/circleOfConfusionPostProcess";
  75645. export * from "babylonjs/PostProcesses/colorCorrectionPostProcess";
  75646. export * from "babylonjs/PostProcesses/convolutionPostProcess";
  75647. export * from "babylonjs/PostProcesses/depthOfFieldBlurPostProcess";
  75648. export * from "babylonjs/PostProcesses/depthOfFieldEffect";
  75649. export * from "babylonjs/PostProcesses/depthOfFieldMergePostProcess";
  75650. export * from "babylonjs/PostProcesses/displayPassPostProcess";
  75651. export * from "babylonjs/PostProcesses/extractHighlightsPostProcess";
  75652. export * from "babylonjs/PostProcesses/filterPostProcess";
  75653. export * from "babylonjs/PostProcesses/fxaaPostProcess";
  75654. export * from "babylonjs/PostProcesses/grainPostProcess";
  75655. export * from "babylonjs/PostProcesses/highlightsPostProcess";
  75656. export * from "babylonjs/PostProcesses/imageProcessingPostProcess";
  75657. export * from "babylonjs/PostProcesses/motionBlurPostProcess";
  75658. export * from "babylonjs/PostProcesses/passPostProcess";
  75659. export * from "babylonjs/PostProcesses/postProcess";
  75660. export * from "babylonjs/PostProcesses/postProcessManager";
  75661. export * from "babylonjs/PostProcesses/refractionPostProcess";
  75662. export * from "babylonjs/PostProcesses/RenderPipeline/index";
  75663. export * from "babylonjs/PostProcesses/sharpenPostProcess";
  75664. export * from "babylonjs/PostProcesses/stereoscopicInterlacePostProcess";
  75665. export * from "babylonjs/PostProcesses/tonemapPostProcess";
  75666. export * from "babylonjs/PostProcesses/volumetricLightScatteringPostProcess";
  75667. export * from "babylonjs/PostProcesses/vrDistortionCorrectionPostProcess";
  75668. export * from "babylonjs/PostProcesses/vrMultiviewToSingleviewPostProcess";
  75669. export * from "babylonjs/PostProcesses/screenSpaceReflectionPostProcess";
  75670. export * from "babylonjs/PostProcesses/screenSpaceCurvaturePostProcess";
  75671. }
  75672. declare module "babylonjs/Probes/index" {
  75673. export * from "babylonjs/Probes/reflectionProbe";
  75674. }
  75675. declare module "babylonjs/Rendering/boundingBoxRenderer" {
  75676. import { Scene } from "babylonjs/scene";
  75677. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  75678. import { SmartArray } from "babylonjs/Misc/smartArray";
  75679. import { ISceneComponent } from "babylonjs/sceneComponent";
  75680. import { BoundingBox } from "babylonjs/Culling/boundingBox";
  75681. import "babylonjs/Meshes/Builders/boxBuilder";
  75682. import "babylonjs/Shaders/color.fragment";
  75683. import "babylonjs/Shaders/color.vertex";
  75684. import { Color3 } from "babylonjs/Maths/math.color";
  75685. import { Observable } from "babylonjs/Misc/observable";
  75686. module "babylonjs/scene" {
  75687. interface Scene {
  75688. /** @hidden (Backing field) */
  75689. _boundingBoxRenderer: BoundingBoxRenderer;
  75690. /** @hidden (Backing field) */
  75691. _forceShowBoundingBoxes: boolean;
  75692. /**
  75693. * Gets or sets a boolean indicating if all bounding boxes must be rendered
  75694. */
  75695. forceShowBoundingBoxes: boolean;
  75696. /**
  75697. * Gets the bounding box renderer associated with the scene
  75698. * @returns a BoundingBoxRenderer
  75699. */
  75700. getBoundingBoxRenderer(): BoundingBoxRenderer;
  75701. }
  75702. }
  75703. module "babylonjs/Meshes/abstractMesh" {
  75704. interface AbstractMesh {
  75705. /** @hidden (Backing field) */
  75706. _showBoundingBox: boolean;
  75707. /**
  75708. * Gets or sets a boolean indicating if the bounding box must be rendered as well (false by default)
  75709. */
  75710. showBoundingBox: boolean;
  75711. }
  75712. }
  75713. /**
  75714. * Component responsible of rendering the bounding box of the meshes in a scene.
  75715. * This is usually used through the mesh.showBoundingBox or the scene.forceShowBoundingBoxes properties
  75716. */
  75717. export class BoundingBoxRenderer implements ISceneComponent {
  75718. /**
  75719. * The component name helpfull to identify the component in the list of scene components.
  75720. */
  75721. readonly name: string;
  75722. /**
  75723. * The scene the component belongs to.
  75724. */
  75725. scene: Scene;
  75726. /**
  75727. * Color of the bounding box lines placed in front of an object
  75728. */
  75729. frontColor: Color3;
  75730. /**
  75731. * Color of the bounding box lines placed behind an object
  75732. */
  75733. backColor: Color3;
  75734. /**
  75735. * Defines if the renderer should show the back lines or not
  75736. */
  75737. showBackLines: boolean;
  75738. /**
  75739. * Observable raised before rendering a bounding box
  75740. */
  75741. onBeforeBoxRenderingObservable: Observable<BoundingBox>;
  75742. /**
  75743. * Observable raised after rendering a bounding box
  75744. */
  75745. onAfterBoxRenderingObservable: Observable<BoundingBox>;
  75746. /**
  75747. * @hidden
  75748. */
  75749. renderList: SmartArray<BoundingBox>;
  75750. private _colorShader;
  75751. private _vertexBuffers;
  75752. private _indexBuffer;
  75753. private _fillIndexBuffer;
  75754. private _fillIndexData;
  75755. /**
  75756. * Instantiates a new bounding box renderer in a scene.
  75757. * @param scene the scene the renderer renders in
  75758. */
  75759. constructor(scene: Scene);
  75760. /**
  75761. * Registers the component in a given scene
  75762. */
  75763. register(): void;
  75764. private _evaluateSubMesh;
  75765. private _activeMesh;
  75766. private _prepareRessources;
  75767. private _createIndexBuffer;
  75768. /**
  75769. * Rebuilds the elements related to this component in case of
  75770. * context lost for instance.
  75771. */
  75772. rebuild(): void;
  75773. /**
  75774. * @hidden
  75775. */
  75776. reset(): void;
  75777. /**
  75778. * Render the bounding boxes of a specific rendering group
  75779. * @param renderingGroupId defines the rendering group to render
  75780. */
  75781. render(renderingGroupId: number): void;
  75782. /**
  75783. * In case of occlusion queries, we can render the occlusion bounding box through this method
  75784. * @param mesh Define the mesh to render the occlusion bounding box for
  75785. */
  75786. renderOcclusionBoundingBox(mesh: AbstractMesh): void;
  75787. /**
  75788. * Dispose and release the resources attached to this renderer.
  75789. */
  75790. dispose(): void;
  75791. }
  75792. }
  75793. declare module "babylonjs/Rendering/depthRendererSceneComponent" {
  75794. import { Nullable } from "babylonjs/types";
  75795. import { Scene } from "babylonjs/scene";
  75796. import { DepthRenderer } from "babylonjs/Rendering/depthRenderer";
  75797. import { Camera } from "babylonjs/Cameras/camera";
  75798. import { ISceneComponent } from "babylonjs/sceneComponent";
  75799. module "babylonjs/scene" {
  75800. interface Scene {
  75801. /** @hidden (Backing field) */
  75802. _depthRenderer: {
  75803. [id: string]: DepthRenderer;
  75804. };
  75805. /**
  75806. * Creates a depth renderer a given camera which contains a depth map which can be used for post processing.
  75807. * @param camera The camera to create the depth renderer on (default: scene's active camera)
  75808. * @param storeNonLinearDepth Defines whether the depth is stored linearly like in Babylon Shadows or directly like glFragCoord.z
  75809. * @returns the created depth renderer
  75810. */
  75811. enableDepthRenderer(camera?: Nullable<Camera>, storeNonLinearDepth?: boolean): DepthRenderer;
  75812. /**
  75813. * Disables a depth renderer for a given camera
  75814. * @param camera The camera to disable the depth renderer on (default: scene's active camera)
  75815. */
  75816. disableDepthRenderer(camera?: Nullable<Camera>): void;
  75817. }
  75818. }
  75819. /**
  75820. * Defines the Depth Renderer scene component responsible to manage a depth buffer useful
  75821. * in several rendering techniques.
  75822. */
  75823. export class DepthRendererSceneComponent implements ISceneComponent {
  75824. /**
  75825. * The component name helpfull to identify the component in the list of scene components.
  75826. */
  75827. readonly name: string;
  75828. /**
  75829. * The scene the component belongs to.
  75830. */
  75831. scene: Scene;
  75832. /**
  75833. * Creates a new instance of the component for the given scene
  75834. * @param scene Defines the scene to register the component in
  75835. */
  75836. constructor(scene: Scene);
  75837. /**
  75838. * Registers the component in a given scene
  75839. */
  75840. register(): void;
  75841. /**
  75842. * Rebuilds the elements related to this component in case of
  75843. * context lost for instance.
  75844. */
  75845. rebuild(): void;
  75846. /**
  75847. * Disposes the component and the associated ressources
  75848. */
  75849. dispose(): void;
  75850. private _gatherRenderTargets;
  75851. private _gatherActiveCameraRenderTargets;
  75852. }
  75853. }
  75854. declare module "babylonjs/Rendering/prePassRendererSceneComponent" {
  75855. import { Nullable } from "babylonjs/types";
  75856. import { Scene } from "babylonjs/scene";
  75857. import { ISceneSerializableComponent } from "babylonjs/sceneComponent";
  75858. import { PrePassRenderer } from "babylonjs/Rendering/prePassRenderer";
  75859. import { AbstractScene } from "babylonjs/abstractScene";
  75860. module "babylonjs/abstractScene" {
  75861. interface AbstractScene {
  75862. /** @hidden (Backing field) */
  75863. _prePassRenderer: Nullable<PrePassRenderer>;
  75864. /**
  75865. * Gets or Sets the current prepass renderer associated to the scene.
  75866. */
  75867. prePassRenderer: Nullable<PrePassRenderer>;
  75868. /**
  75869. * Enables the prepass and associates it with the scene
  75870. * @returns the PrePassRenderer
  75871. */
  75872. enablePrePassRenderer(): Nullable<PrePassRenderer>;
  75873. /**
  75874. * Disables the prepass associated with the scene
  75875. */
  75876. disablePrePassRenderer(): void;
  75877. }
  75878. }
  75879. /**
  75880. * Defines the Geometry Buffer scene component responsible to manage a G-Buffer useful
  75881. * in several rendering techniques.
  75882. */
  75883. export class PrePassRendererSceneComponent implements ISceneSerializableComponent {
  75884. /**
  75885. * The component name helpful to identify the component in the list of scene components.
  75886. */
  75887. readonly name: string;
  75888. /**
  75889. * The scene the component belongs to.
  75890. */
  75891. scene: Scene;
  75892. /**
  75893. * Creates a new instance of the component for the given scene
  75894. * @param scene Defines the scene to register the component in
  75895. */
  75896. constructor(scene: Scene);
  75897. /**
  75898. * Registers the component in a given scene
  75899. */
  75900. register(): void;
  75901. private _beforeCameraDraw;
  75902. private _afterCameraDraw;
  75903. private _beforeClearStage;
  75904. /**
  75905. * Serializes the component data to the specified json object
  75906. * @param serializationObject The object to serialize to
  75907. */
  75908. serialize(serializationObject: any): void;
  75909. /**
  75910. * Adds all the elements from the container to the scene
  75911. * @param container the container holding the elements
  75912. */
  75913. addFromContainer(container: AbstractScene): void;
  75914. /**
  75915. * Removes all the elements in the container from the scene
  75916. * @param container contains the elements to remove
  75917. * @param dispose if the removed element should be disposed (default: false)
  75918. */
  75919. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  75920. /**
  75921. * Rebuilds the elements related to this component in case of
  75922. * context lost for instance.
  75923. */
  75924. rebuild(): void;
  75925. /**
  75926. * Disposes the component and the associated ressources
  75927. */
  75928. dispose(): void;
  75929. }
  75930. }
  75931. declare module "babylonjs/Shaders/outline.fragment" {
  75932. import "babylonjs/Shaders/ShadersInclude/logDepthDeclaration";
  75933. import "babylonjs/Shaders/ShadersInclude/logDepthFragment";
  75934. /** @hidden */
  75935. export var outlinePixelShader: {
  75936. name: string;
  75937. shader: string;
  75938. };
  75939. }
  75940. declare module "babylonjs/Shaders/outline.vertex" {
  75941. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  75942. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  75943. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  75944. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  75945. import "babylonjs/Shaders/ShadersInclude/logDepthDeclaration";
  75946. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  75947. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  75948. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  75949. import "babylonjs/Shaders/ShadersInclude/logDepthVertex";
  75950. /** @hidden */
  75951. export var outlineVertexShader: {
  75952. name: string;
  75953. shader: string;
  75954. };
  75955. }
  75956. declare module "babylonjs/Rendering/outlineRenderer" {
  75957. import { SubMesh } from "babylonjs/Meshes/subMesh";
  75958. import { _InstancesBatch } from "babylonjs/Meshes/mesh";
  75959. import { Scene } from "babylonjs/scene";
  75960. import { ISceneComponent } from "babylonjs/sceneComponent";
  75961. import "babylonjs/Shaders/outline.fragment";
  75962. import "babylonjs/Shaders/outline.vertex";
  75963. module "babylonjs/scene" {
  75964. interface Scene {
  75965. /** @hidden */
  75966. _outlineRenderer: OutlineRenderer;
  75967. /**
  75968. * Gets the outline renderer associated with the scene
  75969. * @returns a OutlineRenderer
  75970. */
  75971. getOutlineRenderer(): OutlineRenderer;
  75972. }
  75973. }
  75974. module "babylonjs/Meshes/abstractMesh" {
  75975. interface AbstractMesh {
  75976. /** @hidden (Backing field) */
  75977. _renderOutline: boolean;
  75978. /**
  75979. * Gets or sets a boolean indicating if the outline must be rendered as well
  75980. * @see https://www.babylonjs-playground.com/#10WJ5S#3
  75981. */
  75982. renderOutline: boolean;
  75983. /** @hidden (Backing field) */
  75984. _renderOverlay: boolean;
  75985. /**
  75986. * Gets or sets a boolean indicating if the overlay must be rendered as well
  75987. * @see https://www.babylonjs-playground.com/#10WJ5S#2
  75988. */
  75989. renderOverlay: boolean;
  75990. }
  75991. }
  75992. /**
  75993. * This class is responsible to draw bothe outline/overlay of meshes.
  75994. * It should not be used directly but through the available method on mesh.
  75995. */
  75996. export class OutlineRenderer implements ISceneComponent {
  75997. /**
  75998. * Stencil value used to avoid outline being seen within the mesh when the mesh is transparent
  75999. */
  76000. private static _StencilReference;
  76001. /**
  76002. * The name of the component. Each component must have a unique name.
  76003. */
  76004. name: string;
  76005. /**
  76006. * The scene the component belongs to.
  76007. */
  76008. scene: Scene;
  76009. /**
  76010. * Defines a zOffset to prevent zFighting between the overlay and the mesh.
  76011. */
  76012. zOffset: number;
  76013. private _engine;
  76014. private _effect;
  76015. private _cachedDefines;
  76016. private _savedDepthWrite;
  76017. /**
  76018. * Instantiates a new outline renderer. (There could be only one per scene).
  76019. * @param scene Defines the scene it belongs to
  76020. */
  76021. constructor(scene: Scene);
  76022. /**
  76023. * Register the component to one instance of a scene.
  76024. */
  76025. register(): void;
  76026. /**
  76027. * Rebuilds the elements related to this component in case of
  76028. * context lost for instance.
  76029. */
  76030. rebuild(): void;
  76031. /**
  76032. * Disposes the component and the associated ressources.
  76033. */
  76034. dispose(): void;
  76035. /**
  76036. * Renders the outline in the canvas.
  76037. * @param subMesh Defines the sumesh to render
  76038. * @param batch Defines the batch of meshes in case of instances
  76039. * @param useOverlay Defines if the rendering is for the overlay or the outline
  76040. */
  76041. render(subMesh: SubMesh, batch: _InstancesBatch, useOverlay?: boolean): void;
  76042. /**
  76043. * Returns whether or not the outline renderer is ready for a given submesh.
  76044. * All the dependencies e.g. submeshes, texture, effect... mus be ready
  76045. * @param subMesh Defines the submesh to check readyness for
  76046. * @param useInstances Defines wheter wee are trying to render instances or not
  76047. * @returns true if ready otherwise false
  76048. */
  76049. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  76050. private _beforeRenderingMesh;
  76051. private _afterRenderingMesh;
  76052. }
  76053. }
  76054. declare module "babylonjs/Rendering/index" {
  76055. export * from "babylonjs/Rendering/boundingBoxRenderer";
  76056. export * from "babylonjs/Rendering/depthRenderer";
  76057. export * from "babylonjs/Rendering/depthRendererSceneComponent";
  76058. export * from "babylonjs/Rendering/edgesRenderer";
  76059. export * from "babylonjs/Rendering/geometryBufferRenderer";
  76060. export * from "babylonjs/Rendering/geometryBufferRendererSceneComponent";
  76061. export * from "babylonjs/Rendering/prePassRenderer";
  76062. export * from "babylonjs/Rendering/prePassRendererSceneComponent";
  76063. export * from "babylonjs/Rendering/outlineRenderer";
  76064. export * from "babylonjs/Rendering/renderingGroup";
  76065. export * from "babylonjs/Rendering/renderingManager";
  76066. export * from "babylonjs/Rendering/utilityLayerRenderer";
  76067. }
  76068. declare module "babylonjs/Sprites/ISprites" {
  76069. /**
  76070. * Defines the basic options interface of a Sprite Frame Source Size.
  76071. */
  76072. export interface ISpriteJSONSpriteSourceSize {
  76073. /**
  76074. * number of the original width of the Frame
  76075. */
  76076. w: number;
  76077. /**
  76078. * number of the original height of the Frame
  76079. */
  76080. h: number;
  76081. }
  76082. /**
  76083. * Defines the basic options interface of a Sprite Frame Data.
  76084. */
  76085. export interface ISpriteJSONSpriteFrameData {
  76086. /**
  76087. * number of the x offset of the Frame
  76088. */
  76089. x: number;
  76090. /**
  76091. * number of the y offset of the Frame
  76092. */
  76093. y: number;
  76094. /**
  76095. * number of the width of the Frame
  76096. */
  76097. w: number;
  76098. /**
  76099. * number of the height of the Frame
  76100. */
  76101. h: number;
  76102. }
  76103. /**
  76104. * Defines the basic options interface of a JSON Sprite.
  76105. */
  76106. export interface ISpriteJSONSprite {
  76107. /**
  76108. * string name of the Frame
  76109. */
  76110. filename: string;
  76111. /**
  76112. * ISpriteJSONSpriteFrame basic object of the frame data
  76113. */
  76114. frame: ISpriteJSONSpriteFrameData;
  76115. /**
  76116. * boolean to flag is the frame was rotated.
  76117. */
  76118. rotated: boolean;
  76119. /**
  76120. * boolean to flag is the frame was trimmed.
  76121. */
  76122. trimmed: boolean;
  76123. /**
  76124. * ISpriteJSONSpriteFrame basic object of the source data
  76125. */
  76126. spriteSourceSize: ISpriteJSONSpriteFrameData;
  76127. /**
  76128. * ISpriteJSONSpriteFrame basic object of the source data
  76129. */
  76130. sourceSize: ISpriteJSONSpriteSourceSize;
  76131. }
  76132. /**
  76133. * Defines the basic options interface of a JSON atlas.
  76134. */
  76135. export interface ISpriteJSONAtlas {
  76136. /**
  76137. * Array of objects that contain the frame data.
  76138. */
  76139. frames: Array<ISpriteJSONSprite>;
  76140. /**
  76141. * object basic object containing the sprite meta data.
  76142. */
  76143. meta?: object;
  76144. }
  76145. }
  76146. declare module "babylonjs/Shaders/spriteMap.fragment" {
  76147. /** @hidden */
  76148. export var spriteMapPixelShader: {
  76149. name: string;
  76150. shader: string;
  76151. };
  76152. }
  76153. declare module "babylonjs/Shaders/spriteMap.vertex" {
  76154. /** @hidden */
  76155. export var spriteMapVertexShader: {
  76156. name: string;
  76157. shader: string;
  76158. };
  76159. }
  76160. declare module "babylonjs/Sprites/spriteMap" {
  76161. import { IDisposable, Scene } from "babylonjs/scene";
  76162. import { Vector2, Vector3 } from "babylonjs/Maths/math.vector";
  76163. import { Texture } from "babylonjs/Materials/Textures/texture";
  76164. import { RawTexture } from "babylonjs/Materials/Textures/rawTexture";
  76165. import { ISpriteJSONSprite, ISpriteJSONAtlas } from "babylonjs/Sprites/ISprites";
  76166. import "babylonjs/Meshes/Builders/planeBuilder";
  76167. import "babylonjs/Shaders/spriteMap.fragment";
  76168. import "babylonjs/Shaders/spriteMap.vertex";
  76169. /**
  76170. * Defines the basic options interface of a SpriteMap
  76171. */
  76172. export interface ISpriteMapOptions {
  76173. /**
  76174. * Vector2 of the number of cells in the grid.
  76175. */
  76176. stageSize?: Vector2;
  76177. /**
  76178. * Vector2 of the size of the output plane in World Units.
  76179. */
  76180. outputSize?: Vector2;
  76181. /**
  76182. * Vector3 of the position of the output plane in World Units.
  76183. */
  76184. outputPosition?: Vector3;
  76185. /**
  76186. * Vector3 of the rotation of the output plane.
  76187. */
  76188. outputRotation?: Vector3;
  76189. /**
  76190. * number of layers that the system will reserve in resources.
  76191. */
  76192. layerCount?: number;
  76193. /**
  76194. * number of max animation frames a single cell will reserve in resources.
  76195. */
  76196. maxAnimationFrames?: number;
  76197. /**
  76198. * number cell index of the base tile when the system compiles.
  76199. */
  76200. baseTile?: number;
  76201. /**
  76202. * boolean flip the sprite after its been repositioned by the framing data.
  76203. */
  76204. flipU?: boolean;
  76205. /**
  76206. * Vector3 scalar of the global RGB values of the SpriteMap.
  76207. */
  76208. colorMultiply?: Vector3;
  76209. }
  76210. /**
  76211. * Defines the IDisposable interface in order to be cleanable from resources.
  76212. */
  76213. export interface ISpriteMap extends IDisposable {
  76214. /**
  76215. * String name of the SpriteMap.
  76216. */
  76217. name: string;
  76218. /**
  76219. * The JSON Array file from a https://www.codeandweb.com/texturepacker export. Or similar structure.
  76220. */
  76221. atlasJSON: ISpriteJSONAtlas;
  76222. /**
  76223. * Texture of the SpriteMap.
  76224. */
  76225. spriteSheet: Texture;
  76226. /**
  76227. * The parameters to initialize the SpriteMap with.
  76228. */
  76229. options: ISpriteMapOptions;
  76230. }
  76231. /**
  76232. * Class used to manage a grid restricted sprite deployment on an Output plane.
  76233. */
  76234. export class SpriteMap implements ISpriteMap {
  76235. /** The Name of the spriteMap */
  76236. name: string;
  76237. /** The JSON file with the frame and meta data */
  76238. atlasJSON: ISpriteJSONAtlas;
  76239. /** The systems Sprite Sheet Texture */
  76240. spriteSheet: Texture;
  76241. /** Arguments passed with the Constructor */
  76242. options: ISpriteMapOptions;
  76243. /** Public Sprite Storage array, parsed from atlasJSON */
  76244. sprites: Array<ISpriteJSONSprite>;
  76245. /** Returns the Number of Sprites in the System */
  76246. get spriteCount(): number;
  76247. /** Returns the Position of Output Plane*/
  76248. get position(): Vector3;
  76249. /** Returns the Position of Output Plane*/
  76250. set position(v: Vector3);
  76251. /** Returns the Rotation of Output Plane*/
  76252. get rotation(): Vector3;
  76253. /** Returns the Rotation of Output Plane*/
  76254. set rotation(v: Vector3);
  76255. /** Sets the AnimationMap*/
  76256. get animationMap(): RawTexture;
  76257. /** Sets the AnimationMap*/
  76258. set animationMap(v: RawTexture);
  76259. /** Scene that the SpriteMap was created in */
  76260. private _scene;
  76261. /** Texture Buffer of Float32 that holds tile frame data*/
  76262. private _frameMap;
  76263. /** Texture Buffers of Float32 that holds tileMap data*/
  76264. private _tileMaps;
  76265. /** Texture Buffer of Float32 that holds Animation Data*/
  76266. private _animationMap;
  76267. /** Custom ShaderMaterial Central to the System*/
  76268. private _material;
  76269. /** Custom ShaderMaterial Central to the System*/
  76270. private _output;
  76271. /** Systems Time Ticker*/
  76272. private _time;
  76273. /**
  76274. * Creates a new SpriteMap
  76275. * @param name defines the SpriteMaps Name
  76276. * @param atlasJSON is the JSON file that controls the Sprites Frames and Meta
  76277. * @param spriteSheet is the Texture that the Sprites are on.
  76278. * @param options a basic deployment configuration
  76279. * @param scene The Scene that the map is deployed on
  76280. */
  76281. constructor(name: string, atlasJSON: ISpriteJSONAtlas, spriteSheet: Texture, options: ISpriteMapOptions, scene: Scene);
  76282. /**
  76283. * Returns tileID location
  76284. * @returns Vector2 the cell position ID
  76285. */
  76286. getTileID(): Vector2;
  76287. /**
  76288. * Gets the UV location of the mouse over the SpriteMap.
  76289. * @returns Vector2 the UV position of the mouse interaction
  76290. */
  76291. getMousePosition(): Vector2;
  76292. /**
  76293. * Creates the "frame" texture Buffer
  76294. * -------------------------------------
  76295. * Structure of frames
  76296. * "filename": "Falling-Water-2.png",
  76297. * "frame": {"x":69,"y":103,"w":24,"h":32},
  76298. * "rotated": true,
  76299. * "trimmed": true,
  76300. * "spriteSourceSize": {"x":4,"y":0,"w":24,"h":32},
  76301. * "sourceSize": {"w":32,"h":32}
  76302. * @returns RawTexture of the frameMap
  76303. */
  76304. private _createFrameBuffer;
  76305. /**
  76306. * Creates the tileMap texture Buffer
  76307. * @param buffer normally and array of numbers, or a false to generate from scratch
  76308. * @param _layer indicates what layer for a logic trigger dealing with the baseTile. The system uses this
  76309. * @returns RawTexture of the tileMap
  76310. */
  76311. private _createTileBuffer;
  76312. /**
  76313. * Modifies the data of the tileMaps
  76314. * @param _layer is the ID of the layer you want to edit on the SpriteMap
  76315. * @param pos is the iVector2 Coordinates of the Tile
  76316. * @param tile The SpriteIndex of the new Tile
  76317. */
  76318. changeTiles(_layer: number | undefined, pos: Vector2 | Vector2[], tile?: number): void;
  76319. /**
  76320. * Creates the animationMap texture Buffer
  76321. * @param buffer normally and array of numbers, or a false to generate from scratch
  76322. * @returns RawTexture of the animationMap
  76323. */
  76324. private _createTileAnimationBuffer;
  76325. /**
  76326. * Modifies the data of the animationMap
  76327. * @param cellID is the Index of the Sprite
  76328. * @param _frame is the target Animation frame
  76329. * @param toCell is the Target Index of the next frame of the animation
  76330. * @param time is a value between 0-1 that is the trigger for when the frame should change tiles
  76331. * @param speed is a global scalar of the time variable on the map.
  76332. */
  76333. addAnimationToTile(cellID?: number, _frame?: number, toCell?: number, time?: number, speed?: number): void;
  76334. /**
  76335. * Exports the .tilemaps file
  76336. */
  76337. saveTileMaps(): void;
  76338. /**
  76339. * Imports the .tilemaps file
  76340. * @param url of the .tilemaps file
  76341. */
  76342. loadTileMaps(url: string): void;
  76343. /**
  76344. * Release associated resources
  76345. */
  76346. dispose(): void;
  76347. }
  76348. }
  76349. declare module "babylonjs/Sprites/spritePackedManager" {
  76350. import { SpriteManager } from "babylonjs/Sprites/spriteManager";
  76351. import { Scene } from "babylonjs/scene";
  76352. /**
  76353. * Class used to manage multiple sprites of different sizes on the same spritesheet
  76354. * @see https://doc.babylonjs.com/babylon101/sprites
  76355. */
  76356. export class SpritePackedManager extends SpriteManager {
  76357. /** defines the packed manager's name */
  76358. name: string;
  76359. /**
  76360. * Creates a new sprite manager from a packed sprite sheet
  76361. * @param name defines the manager's name
  76362. * @param imgUrl defines the sprite sheet url
  76363. * @param capacity defines the maximum allowed number of sprites
  76364. * @param scene defines the hosting scene
  76365. * @param spriteJSON null otherwise a JSON object defining sprite sheet data
  76366. * @param epsilon defines the epsilon value to align texture (0.01 by default)
  76367. * @param samplingMode defines the smapling mode to use with spritesheet
  76368. * @param fromPacked set to true; do not alter
  76369. */
  76370. constructor(
  76371. /** defines the packed manager's name */
  76372. name: string, imgUrl: string, capacity: number, scene: Scene, spriteJSON?: string | null, epsilon?: number, samplingMode?: number);
  76373. }
  76374. }
  76375. declare module "babylonjs/Sprites/index" {
  76376. export * from "babylonjs/Sprites/sprite";
  76377. export * from "babylonjs/Sprites/ISprites";
  76378. export * from "babylonjs/Sprites/spriteManager";
  76379. export * from "babylonjs/Sprites/spriteMap";
  76380. export * from "babylonjs/Sprites/spritePackedManager";
  76381. export * from "babylonjs/Sprites/spriteSceneComponent";
  76382. }
  76383. declare module "babylonjs/States/index" {
  76384. export * from "babylonjs/States/alphaCullingState";
  76385. export * from "babylonjs/States/depthCullingState";
  76386. export * from "babylonjs/States/stencilState";
  76387. }
  76388. declare module "babylonjs/Misc/assetsManager" {
  76389. import { Scene } from "babylonjs/scene";
  76390. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  76391. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  76392. import { Skeleton } from "babylonjs/Bones/skeleton";
  76393. import { Observable } from "babylonjs/Misc/observable";
  76394. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  76395. import { Texture } from "babylonjs/Materials/Textures/texture";
  76396. import { CubeTexture } from "babylonjs/Materials/Textures/cubeTexture";
  76397. import { HDRCubeTexture } from "babylonjs/Materials/Textures/hdrCubeTexture";
  76398. import { EquiRectangularCubeTexture } from "babylonjs/Materials/Textures/equiRectangularCubeTexture";
  76399. import { AnimationGroup } from "babylonjs/Animations/animationGroup";
  76400. import { AssetContainer } from "babylonjs/assetContainer";
  76401. /**
  76402. * Defines the list of states available for a task inside a AssetsManager
  76403. */
  76404. export enum AssetTaskState {
  76405. /**
  76406. * Initialization
  76407. */
  76408. INIT = 0,
  76409. /**
  76410. * Running
  76411. */
  76412. RUNNING = 1,
  76413. /**
  76414. * Done
  76415. */
  76416. DONE = 2,
  76417. /**
  76418. * Error
  76419. */
  76420. ERROR = 3
  76421. }
  76422. /**
  76423. * Define an abstract asset task used with a AssetsManager class to load assets into a scene
  76424. */
  76425. export abstract class AbstractAssetTask {
  76426. /**
  76427. * Task name
  76428. */ name: string;
  76429. /**
  76430. * Callback called when the task is successful
  76431. */
  76432. onSuccess: (task: any) => void;
  76433. /**
  76434. * Callback called when the task is not successful
  76435. */
  76436. onError: (task: any, message?: string, exception?: any) => void;
  76437. /**
  76438. * Creates a new AssetsManager
  76439. * @param name defines the name of the task
  76440. */
  76441. constructor(
  76442. /**
  76443. * Task name
  76444. */ name: string);
  76445. private _isCompleted;
  76446. private _taskState;
  76447. private _errorObject;
  76448. /**
  76449. * Get if the task is completed
  76450. */
  76451. get isCompleted(): boolean;
  76452. /**
  76453. * Gets the current state of the task
  76454. */
  76455. get taskState(): AssetTaskState;
  76456. /**
  76457. * Gets the current error object (if task is in error)
  76458. */
  76459. get errorObject(): {
  76460. message?: string;
  76461. exception?: any;
  76462. };
  76463. /**
  76464. * Internal only
  76465. * @hidden
  76466. */
  76467. _setErrorObject(message?: string, exception?: any): void;
  76468. /**
  76469. * Execute the current task
  76470. * @param scene defines the scene where you want your assets to be loaded
  76471. * @param onSuccess is a callback called when the task is successfully executed
  76472. * @param onError is a callback called if an error occurs
  76473. */
  76474. run(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  76475. /**
  76476. * Execute the current task
  76477. * @param scene defines the scene where you want your assets to be loaded
  76478. * @param onSuccess is a callback called when the task is successfully executed
  76479. * @param onError is a callback called if an error occurs
  76480. */
  76481. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  76482. /**
  76483. * Reset will set the task state back to INIT, so the next load call of the assets manager will execute this task again.
  76484. * This can be used with failed tasks that have the reason for failure fixed.
  76485. */
  76486. reset(): void;
  76487. private onErrorCallback;
  76488. private onDoneCallback;
  76489. }
  76490. /**
  76491. * Define the interface used by progress events raised during assets loading
  76492. */
  76493. export interface IAssetsProgressEvent {
  76494. /**
  76495. * Defines the number of remaining tasks to process
  76496. */
  76497. remainingCount: number;
  76498. /**
  76499. * Defines the total number of tasks
  76500. */
  76501. totalCount: number;
  76502. /**
  76503. * Defines the task that was just processed
  76504. */
  76505. task: AbstractAssetTask;
  76506. }
  76507. /**
  76508. * Class used to share progress information about assets loading
  76509. */
  76510. export class AssetsProgressEvent implements IAssetsProgressEvent {
  76511. /**
  76512. * Defines the number of remaining tasks to process
  76513. */
  76514. remainingCount: number;
  76515. /**
  76516. * Defines the total number of tasks
  76517. */
  76518. totalCount: number;
  76519. /**
  76520. * Defines the task that was just processed
  76521. */
  76522. task: AbstractAssetTask;
  76523. /**
  76524. * Creates a AssetsProgressEvent
  76525. * @param remainingCount defines the number of remaining tasks to process
  76526. * @param totalCount defines the total number of tasks
  76527. * @param task defines the task that was just processed
  76528. */
  76529. constructor(remainingCount: number, totalCount: number, task: AbstractAssetTask);
  76530. }
  76531. /**
  76532. * Define a task used by AssetsManager to load assets into a container
  76533. */
  76534. export class ContainerAssetTask extends AbstractAssetTask {
  76535. /**
  76536. * Defines the name of the task
  76537. */
  76538. name: string;
  76539. /**
  76540. * Defines the list of mesh's names you want to load
  76541. */
  76542. meshesNames: any;
  76543. /**
  76544. * Defines the root url to use as a base to load your meshes and associated resources
  76545. */
  76546. rootUrl: string;
  76547. /**
  76548. * Defines the filename or File of the scene to load from
  76549. */
  76550. sceneFilename: string | File;
  76551. /**
  76552. * Get the loaded asset container
  76553. */
  76554. loadedContainer: AssetContainer;
  76555. /**
  76556. * Gets the list of loaded meshes
  76557. */
  76558. loadedMeshes: Array<AbstractMesh>;
  76559. /**
  76560. * Gets the list of loaded particle systems
  76561. */
  76562. loadedParticleSystems: Array<IParticleSystem>;
  76563. /**
  76564. * Gets the list of loaded skeletons
  76565. */
  76566. loadedSkeletons: Array<Skeleton>;
  76567. /**
  76568. * Gets the list of loaded animation groups
  76569. */
  76570. loadedAnimationGroups: Array<AnimationGroup>;
  76571. /**
  76572. * Callback called when the task is successful
  76573. */
  76574. onSuccess: (task: ContainerAssetTask) => void;
  76575. /**
  76576. * Callback called when the task is successful
  76577. */
  76578. onError: (task: ContainerAssetTask, message?: string, exception?: any) => void;
  76579. /**
  76580. * Creates a new ContainerAssetTask
  76581. * @param name defines the name of the task
  76582. * @param meshesNames defines the list of mesh's names you want to load
  76583. * @param rootUrl defines the root url to use as a base to load your meshes and associated resources
  76584. * @param sceneFilename defines the filename or File of the scene to load from
  76585. */
  76586. constructor(
  76587. /**
  76588. * Defines the name of the task
  76589. */
  76590. name: string,
  76591. /**
  76592. * Defines the list of mesh's names you want to load
  76593. */
  76594. meshesNames: any,
  76595. /**
  76596. * Defines the root url to use as a base to load your meshes and associated resources
  76597. */
  76598. rootUrl: string,
  76599. /**
  76600. * Defines the filename or File of the scene to load from
  76601. */
  76602. sceneFilename: string | File);
  76603. /**
  76604. * Execute the current task
  76605. * @param scene defines the scene where you want your assets to be loaded
  76606. * @param onSuccess is a callback called when the task is successfully executed
  76607. * @param onError is a callback called if an error occurs
  76608. */
  76609. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  76610. }
  76611. /**
  76612. * Define a task used by AssetsManager to load meshes
  76613. */
  76614. export class MeshAssetTask extends AbstractAssetTask {
  76615. /**
  76616. * Defines the name of the task
  76617. */
  76618. name: string;
  76619. /**
  76620. * Defines the list of mesh's names you want to load
  76621. */
  76622. meshesNames: any;
  76623. /**
  76624. * Defines the root url to use as a base to load your meshes and associated resources
  76625. */
  76626. rootUrl: string;
  76627. /**
  76628. * Defines the filename or File of the scene to load from
  76629. */
  76630. sceneFilename: string | File;
  76631. /**
  76632. * Gets the list of loaded meshes
  76633. */
  76634. loadedMeshes: Array<AbstractMesh>;
  76635. /**
  76636. * Gets the list of loaded particle systems
  76637. */
  76638. loadedParticleSystems: Array<IParticleSystem>;
  76639. /**
  76640. * Gets the list of loaded skeletons
  76641. */
  76642. loadedSkeletons: Array<Skeleton>;
  76643. /**
  76644. * Gets the list of loaded animation groups
  76645. */
  76646. loadedAnimationGroups: Array<AnimationGroup>;
  76647. /**
  76648. * Callback called when the task is successful
  76649. */
  76650. onSuccess: (task: MeshAssetTask) => void;
  76651. /**
  76652. * Callback called when the task is successful
  76653. */
  76654. onError: (task: MeshAssetTask, message?: string, exception?: any) => void;
  76655. /**
  76656. * Creates a new MeshAssetTask
  76657. * @param name defines the name of the task
  76658. * @param meshesNames defines the list of mesh's names you want to load
  76659. * @param rootUrl defines the root url to use as a base to load your meshes and associated resources
  76660. * @param sceneFilename defines the filename or File of the scene to load from
  76661. */
  76662. constructor(
  76663. /**
  76664. * Defines the name of the task
  76665. */
  76666. name: string,
  76667. /**
  76668. * Defines the list of mesh's names you want to load
  76669. */
  76670. meshesNames: any,
  76671. /**
  76672. * Defines the root url to use as a base to load your meshes and associated resources
  76673. */
  76674. rootUrl: string,
  76675. /**
  76676. * Defines the filename or File of the scene to load from
  76677. */
  76678. sceneFilename: string | File);
  76679. /**
  76680. * Execute the current task
  76681. * @param scene defines the scene where you want your assets to be loaded
  76682. * @param onSuccess is a callback called when the task is successfully executed
  76683. * @param onError is a callback called if an error occurs
  76684. */
  76685. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  76686. }
  76687. /**
  76688. * Define a task used by AssetsManager to load text content
  76689. */
  76690. export class TextFileAssetTask extends AbstractAssetTask {
  76691. /**
  76692. * Defines the name of the task
  76693. */
  76694. name: string;
  76695. /**
  76696. * Defines the location of the file to load
  76697. */
  76698. url: string;
  76699. /**
  76700. * Gets the loaded text string
  76701. */
  76702. text: string;
  76703. /**
  76704. * Callback called when the task is successful
  76705. */
  76706. onSuccess: (task: TextFileAssetTask) => void;
  76707. /**
  76708. * Callback called when the task is successful
  76709. */
  76710. onError: (task: TextFileAssetTask, message?: string, exception?: any) => void;
  76711. /**
  76712. * Creates a new TextFileAssetTask object
  76713. * @param name defines the name of the task
  76714. * @param url defines the location of the file to load
  76715. */
  76716. constructor(
  76717. /**
  76718. * Defines the name of the task
  76719. */
  76720. name: string,
  76721. /**
  76722. * Defines the location of the file to load
  76723. */
  76724. url: string);
  76725. /**
  76726. * Execute the current task
  76727. * @param scene defines the scene where you want your assets to be loaded
  76728. * @param onSuccess is a callback called when the task is successfully executed
  76729. * @param onError is a callback called if an error occurs
  76730. */
  76731. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  76732. }
  76733. /**
  76734. * Define a task used by AssetsManager to load binary data
  76735. */
  76736. export class BinaryFileAssetTask extends AbstractAssetTask {
  76737. /**
  76738. * Defines the name of the task
  76739. */
  76740. name: string;
  76741. /**
  76742. * Defines the location of the file to load
  76743. */
  76744. url: string;
  76745. /**
  76746. * Gets the lodaded data (as an array buffer)
  76747. */
  76748. data: ArrayBuffer;
  76749. /**
  76750. * Callback called when the task is successful
  76751. */
  76752. onSuccess: (task: BinaryFileAssetTask) => void;
  76753. /**
  76754. * Callback called when the task is successful
  76755. */
  76756. onError: (task: BinaryFileAssetTask, message?: string, exception?: any) => void;
  76757. /**
  76758. * Creates a new BinaryFileAssetTask object
  76759. * @param name defines the name of the new task
  76760. * @param url defines the location of the file to load
  76761. */
  76762. constructor(
  76763. /**
  76764. * Defines the name of the task
  76765. */
  76766. name: string,
  76767. /**
  76768. * Defines the location of the file to load
  76769. */
  76770. url: string);
  76771. /**
  76772. * Execute the current task
  76773. * @param scene defines the scene where you want your assets to be loaded
  76774. * @param onSuccess is a callback called when the task is successfully executed
  76775. * @param onError is a callback called if an error occurs
  76776. */
  76777. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  76778. }
  76779. /**
  76780. * Define a task used by AssetsManager to load images
  76781. */
  76782. export class ImageAssetTask extends AbstractAssetTask {
  76783. /**
  76784. * Defines the name of the task
  76785. */
  76786. name: string;
  76787. /**
  76788. * Defines the location of the image to load
  76789. */
  76790. url: string;
  76791. /**
  76792. * Gets the loaded images
  76793. */
  76794. image: HTMLImageElement;
  76795. /**
  76796. * Callback called when the task is successful
  76797. */
  76798. onSuccess: (task: ImageAssetTask) => void;
  76799. /**
  76800. * Callback called when the task is successful
  76801. */
  76802. onError: (task: ImageAssetTask, message?: string, exception?: any) => void;
  76803. /**
  76804. * Creates a new ImageAssetTask
  76805. * @param name defines the name of the task
  76806. * @param url defines the location of the image to load
  76807. */
  76808. constructor(
  76809. /**
  76810. * Defines the name of the task
  76811. */
  76812. name: string,
  76813. /**
  76814. * Defines the location of the image to load
  76815. */
  76816. url: string);
  76817. /**
  76818. * Execute the current task
  76819. * @param scene defines the scene where you want your assets to be loaded
  76820. * @param onSuccess is a callback called when the task is successfully executed
  76821. * @param onError is a callback called if an error occurs
  76822. */
  76823. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  76824. }
  76825. /**
  76826. * Defines the interface used by texture loading tasks
  76827. */
  76828. export interface ITextureAssetTask<TEX extends BaseTexture> {
  76829. /**
  76830. * Gets the loaded texture
  76831. */
  76832. texture: TEX;
  76833. }
  76834. /**
  76835. * Define a task used by AssetsManager to load 2D textures
  76836. */
  76837. export class TextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<Texture> {
  76838. /**
  76839. * Defines the name of the task
  76840. */
  76841. name: string;
  76842. /**
  76843. * Defines the location of the file to load
  76844. */
  76845. url: string;
  76846. /**
  76847. * Defines if mipmap should not be generated (default is false)
  76848. */
  76849. noMipmap?: boolean | undefined;
  76850. /**
  76851. * Defines if texture must be inverted on Y axis (default is true)
  76852. */
  76853. invertY: boolean;
  76854. /**
  76855. * Defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  76856. */
  76857. samplingMode: number;
  76858. /**
  76859. * Gets the loaded texture
  76860. */
  76861. texture: Texture;
  76862. /**
  76863. * Callback called when the task is successful
  76864. */
  76865. onSuccess: (task: TextureAssetTask) => void;
  76866. /**
  76867. * Callback called when the task is successful
  76868. */
  76869. onError: (task: TextureAssetTask, message?: string, exception?: any) => void;
  76870. /**
  76871. * Creates a new TextureAssetTask object
  76872. * @param name defines the name of the task
  76873. * @param url defines the location of the file to load
  76874. * @param noMipmap defines if mipmap should not be generated (default is false)
  76875. * @param invertY defines if texture must be inverted on Y axis (default is true)
  76876. * @param samplingMode defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  76877. */
  76878. constructor(
  76879. /**
  76880. * Defines the name of the task
  76881. */
  76882. name: string,
  76883. /**
  76884. * Defines the location of the file to load
  76885. */
  76886. url: string,
  76887. /**
  76888. * Defines if mipmap should not be generated (default is false)
  76889. */
  76890. noMipmap?: boolean | undefined,
  76891. /**
  76892. * Defines if texture must be inverted on Y axis (default is true)
  76893. */
  76894. invertY?: boolean,
  76895. /**
  76896. * Defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  76897. */
  76898. samplingMode?: number);
  76899. /**
  76900. * Execute the current task
  76901. * @param scene defines the scene where you want your assets to be loaded
  76902. * @param onSuccess is a callback called when the task is successfully executed
  76903. * @param onError is a callback called if an error occurs
  76904. */
  76905. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  76906. }
  76907. /**
  76908. * Define a task used by AssetsManager to load cube textures
  76909. */
  76910. export class CubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<CubeTexture> {
  76911. /**
  76912. * Defines the name of the task
  76913. */
  76914. name: string;
  76915. /**
  76916. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  76917. */
  76918. url: string;
  76919. /**
  76920. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  76921. */
  76922. extensions?: string[] | undefined;
  76923. /**
  76924. * Defines if mipmaps should not be generated (default is false)
  76925. */
  76926. noMipmap?: boolean | undefined;
  76927. /**
  76928. * Defines the explicit list of files (undefined by default)
  76929. */
  76930. files?: string[] | undefined;
  76931. /**
  76932. * Gets the loaded texture
  76933. */
  76934. texture: CubeTexture;
  76935. /**
  76936. * Callback called when the task is successful
  76937. */
  76938. onSuccess: (task: CubeTextureAssetTask) => void;
  76939. /**
  76940. * Callback called when the task is successful
  76941. */
  76942. onError: (task: CubeTextureAssetTask, message?: string, exception?: any) => void;
  76943. /**
  76944. * Creates a new CubeTextureAssetTask
  76945. * @param name defines the name of the task
  76946. * @param url defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  76947. * @param extensions defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  76948. * @param noMipmap defines if mipmaps should not be generated (default is false)
  76949. * @param files defines the explicit list of files (undefined by default)
  76950. */
  76951. constructor(
  76952. /**
  76953. * Defines the name of the task
  76954. */
  76955. name: string,
  76956. /**
  76957. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  76958. */
  76959. url: string,
  76960. /**
  76961. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  76962. */
  76963. extensions?: string[] | undefined,
  76964. /**
  76965. * Defines if mipmaps should not be generated (default is false)
  76966. */
  76967. noMipmap?: boolean | undefined,
  76968. /**
  76969. * Defines the explicit list of files (undefined by default)
  76970. */
  76971. files?: string[] | undefined);
  76972. /**
  76973. * Execute the current task
  76974. * @param scene defines the scene where you want your assets to be loaded
  76975. * @param onSuccess is a callback called when the task is successfully executed
  76976. * @param onError is a callback called if an error occurs
  76977. */
  76978. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  76979. }
  76980. /**
  76981. * Define a task used by AssetsManager to load HDR cube textures
  76982. */
  76983. export class HDRCubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<HDRCubeTexture> {
  76984. /**
  76985. * Defines the name of the task
  76986. */
  76987. name: string;
  76988. /**
  76989. * Defines the location of the file to load
  76990. */
  76991. url: string;
  76992. /**
  76993. * Defines the desired size (the more it increases the longer the generation will be)
  76994. */
  76995. size: number;
  76996. /**
  76997. * Defines if mipmaps should not be generated (default is false)
  76998. */
  76999. noMipmap: boolean;
  77000. /**
  77001. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  77002. */
  77003. generateHarmonics: boolean;
  77004. /**
  77005. * 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)
  77006. */
  77007. gammaSpace: boolean;
  77008. /**
  77009. * Internal Use Only
  77010. */
  77011. reserved: boolean;
  77012. /**
  77013. * Gets the loaded texture
  77014. */
  77015. texture: HDRCubeTexture;
  77016. /**
  77017. * Callback called when the task is successful
  77018. */
  77019. onSuccess: (task: HDRCubeTextureAssetTask) => void;
  77020. /**
  77021. * Callback called when the task is successful
  77022. */
  77023. onError: (task: HDRCubeTextureAssetTask, message?: string, exception?: any) => void;
  77024. /**
  77025. * Creates a new HDRCubeTextureAssetTask object
  77026. * @param name defines the name of the task
  77027. * @param url defines the location of the file to load
  77028. * @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.
  77029. * @param noMipmap defines if mipmaps should not be generated (default is false)
  77030. * @param generateHarmonics specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  77031. * @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)
  77032. * @param reserved Internal use only
  77033. */
  77034. constructor(
  77035. /**
  77036. * Defines the name of the task
  77037. */
  77038. name: string,
  77039. /**
  77040. * Defines the location of the file to load
  77041. */
  77042. url: string,
  77043. /**
  77044. * Defines the desired size (the more it increases the longer the generation will be)
  77045. */
  77046. size: number,
  77047. /**
  77048. * Defines if mipmaps should not be generated (default is false)
  77049. */
  77050. noMipmap?: boolean,
  77051. /**
  77052. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  77053. */
  77054. generateHarmonics?: boolean,
  77055. /**
  77056. * 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)
  77057. */
  77058. gammaSpace?: boolean,
  77059. /**
  77060. * Internal Use Only
  77061. */
  77062. reserved?: boolean);
  77063. /**
  77064. * Execute the current task
  77065. * @param scene defines the scene where you want your assets to be loaded
  77066. * @param onSuccess is a callback called when the task is successfully executed
  77067. * @param onError is a callback called if an error occurs
  77068. */
  77069. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  77070. }
  77071. /**
  77072. * Define a task used by AssetsManager to load Equirectangular cube textures
  77073. */
  77074. export class EquiRectangularCubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<EquiRectangularCubeTexture> {
  77075. /**
  77076. * Defines the name of the task
  77077. */
  77078. name: string;
  77079. /**
  77080. * Defines the location of the file to load
  77081. */
  77082. url: string;
  77083. /**
  77084. * Defines the desired size (the more it increases the longer the generation will be)
  77085. */
  77086. size: number;
  77087. /**
  77088. * Defines if mipmaps should not be generated (default is false)
  77089. */
  77090. noMipmap: boolean;
  77091. /**
  77092. * Specifies if the texture will be use in gamma or linear space (the PBR material requires those texture in linear space,
  77093. * but the standard material would require them in Gamma space) (default is true)
  77094. */
  77095. gammaSpace: boolean;
  77096. /**
  77097. * Gets the loaded texture
  77098. */
  77099. texture: EquiRectangularCubeTexture;
  77100. /**
  77101. * Callback called when the task is successful
  77102. */
  77103. onSuccess: (task: EquiRectangularCubeTextureAssetTask) => void;
  77104. /**
  77105. * Callback called when the task is successful
  77106. */
  77107. onError: (task: EquiRectangularCubeTextureAssetTask, message?: string, exception?: any) => void;
  77108. /**
  77109. * Creates a new EquiRectangularCubeTextureAssetTask object
  77110. * @param name defines the name of the task
  77111. * @param url defines the location of the file to load
  77112. * @param size defines the desired size (the more it increases the longer the generation will be)
  77113. * If the size is omitted this implies you are using a preprocessed cubemap.
  77114. * @param noMipmap defines if mipmaps should not be generated (default is false)
  77115. * @param gammaSpace specifies if the texture will be used in gamma or linear space
  77116. * (the PBR material requires those texture in linear space, but the standard material would require them in Gamma space)
  77117. * (default is true)
  77118. */
  77119. constructor(
  77120. /**
  77121. * Defines the name of the task
  77122. */
  77123. name: string,
  77124. /**
  77125. * Defines the location of the file to load
  77126. */
  77127. url: string,
  77128. /**
  77129. * Defines the desired size (the more it increases the longer the generation will be)
  77130. */
  77131. size: number,
  77132. /**
  77133. * Defines if mipmaps should not be generated (default is false)
  77134. */
  77135. noMipmap?: boolean,
  77136. /**
  77137. * Specifies if the texture will be use in gamma or linear space (the PBR material requires those texture in linear space,
  77138. * but the standard material would require them in Gamma space) (default is true)
  77139. */
  77140. gammaSpace?: boolean);
  77141. /**
  77142. * Execute the current task
  77143. * @param scene defines the scene where you want your assets to be loaded
  77144. * @param onSuccess is a callback called when the task is successfully executed
  77145. * @param onError is a callback called if an error occurs
  77146. */
  77147. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  77148. }
  77149. /**
  77150. * This class can be used to easily import assets into a scene
  77151. * @see https://doc.babylonjs.com/how_to/how_to_use_assetsmanager
  77152. */
  77153. export class AssetsManager {
  77154. private _scene;
  77155. private _isLoading;
  77156. protected _tasks: AbstractAssetTask[];
  77157. protected _waitingTasksCount: number;
  77158. protected _totalTasksCount: number;
  77159. /**
  77160. * Callback called when all tasks are processed
  77161. */
  77162. onFinish: (tasks: AbstractAssetTask[]) => void;
  77163. /**
  77164. * Callback called when a task is successful
  77165. */
  77166. onTaskSuccess: (task: AbstractAssetTask) => void;
  77167. /**
  77168. * Callback called when a task had an error
  77169. */
  77170. onTaskError: (task: AbstractAssetTask) => void;
  77171. /**
  77172. * Callback called when a task is done (whatever the result is)
  77173. */
  77174. onProgress: (remainingCount: number, totalCount: number, task: AbstractAssetTask) => void;
  77175. /**
  77176. * Observable called when all tasks are processed
  77177. */
  77178. onTaskSuccessObservable: Observable<AbstractAssetTask>;
  77179. /**
  77180. * Observable called when a task had an error
  77181. */
  77182. onTaskErrorObservable: Observable<AbstractAssetTask>;
  77183. /**
  77184. * Observable called when all tasks were executed
  77185. */
  77186. onTasksDoneObservable: Observable<AbstractAssetTask[]>;
  77187. /**
  77188. * Observable called when a task is done (whatever the result is)
  77189. */
  77190. onProgressObservable: Observable<IAssetsProgressEvent>;
  77191. /**
  77192. * Gets or sets a boolean defining if the AssetsManager should use the default loading screen
  77193. * @see https://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  77194. */
  77195. useDefaultLoadingScreen: boolean;
  77196. /**
  77197. * Gets or sets a boolean defining if the AssetsManager should automatically hide the loading screen
  77198. * when all assets have been downloaded.
  77199. * If set to false, you need to manually call in hideLoadingUI() once your scene is ready.
  77200. */
  77201. autoHideLoadingUI: boolean;
  77202. /**
  77203. * Creates a new AssetsManager
  77204. * @param scene defines the scene to work on
  77205. */
  77206. constructor(scene: Scene);
  77207. /**
  77208. * Add a ContainerAssetTask to the list of active tasks
  77209. * @param taskName defines the name of the new task
  77210. * @param meshesNames defines the name of meshes to load
  77211. * @param rootUrl defines the root url to use to locate files
  77212. * @param sceneFilename defines the filename of the scene file
  77213. * @returns a new ContainerAssetTask object
  77214. */
  77215. addContainerTask(taskName: string, meshesNames: any, rootUrl: string, sceneFilename: string): ContainerAssetTask;
  77216. /**
  77217. * Add a MeshAssetTask to the list of active tasks
  77218. * @param taskName defines the name of the new task
  77219. * @param meshesNames defines the name of meshes to load
  77220. * @param rootUrl defines the root url to use to locate files
  77221. * @param sceneFilename defines the filename of the scene file
  77222. * @returns a new MeshAssetTask object
  77223. */
  77224. addMeshTask(taskName: string, meshesNames: any, rootUrl: string, sceneFilename: string): MeshAssetTask;
  77225. /**
  77226. * Add a TextFileAssetTask to the list of active tasks
  77227. * @param taskName defines the name of the new task
  77228. * @param url defines the url of the file to load
  77229. * @returns a new TextFileAssetTask object
  77230. */
  77231. addTextFileTask(taskName: string, url: string): TextFileAssetTask;
  77232. /**
  77233. * Add a BinaryFileAssetTask to the list of active tasks
  77234. * @param taskName defines the name of the new task
  77235. * @param url defines the url of the file to load
  77236. * @returns a new BinaryFileAssetTask object
  77237. */
  77238. addBinaryFileTask(taskName: string, url: string): BinaryFileAssetTask;
  77239. /**
  77240. * Add a ImageAssetTask to the list of active tasks
  77241. * @param taskName defines the name of the new task
  77242. * @param url defines the url of the file to load
  77243. * @returns a new ImageAssetTask object
  77244. */
  77245. addImageTask(taskName: string, url: string): ImageAssetTask;
  77246. /**
  77247. * Add a TextureAssetTask to the list of active tasks
  77248. * @param taskName defines the name of the new task
  77249. * @param url defines the url of the file to load
  77250. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  77251. * @param invertY defines if you want to invert Y axis of the loaded texture (false by default)
  77252. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  77253. * @returns a new TextureAssetTask object
  77254. */
  77255. addTextureTask(taskName: string, url: string, noMipmap?: boolean, invertY?: boolean, samplingMode?: number): TextureAssetTask;
  77256. /**
  77257. * Add a CubeTextureAssetTask to the list of active tasks
  77258. * @param taskName defines the name of the new task
  77259. * @param url defines the url of the file to load
  77260. * @param extensions defines the extension to use to load the cube map (can be null)
  77261. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  77262. * @param files defines the list of files to load (can be null)
  77263. * @returns a new CubeTextureAssetTask object
  77264. */
  77265. addCubeTextureTask(taskName: string, url: string, extensions?: string[], noMipmap?: boolean, files?: string[]): CubeTextureAssetTask;
  77266. /**
  77267. *
  77268. * Add a HDRCubeTextureAssetTask to the list of active tasks
  77269. * @param taskName defines the name of the new task
  77270. * @param url defines the url of the file to load
  77271. * @param size defines the size you want for the cubemap (can be null)
  77272. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  77273. * @param generateHarmonics defines if you want to automatically generate (true by default)
  77274. * @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)
  77275. * @param reserved Internal use only
  77276. * @returns a new HDRCubeTextureAssetTask object
  77277. */
  77278. addHDRCubeTextureTask(taskName: string, url: string, size: number, noMipmap?: boolean, generateHarmonics?: boolean, gammaSpace?: boolean, reserved?: boolean): HDRCubeTextureAssetTask;
  77279. /**
  77280. *
  77281. * Add a EquiRectangularCubeTextureAssetTask to the list of active tasks
  77282. * @param taskName defines the name of the new task
  77283. * @param url defines the url of the file to load
  77284. * @param size defines the size you want for the cubemap (can be null)
  77285. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  77286. * @param gammaSpace Specifies if the texture will be used in gamma or linear space
  77287. * (the PBR material requires those textures in linear space, but the standard material would require them in Gamma space)
  77288. * @returns a new EquiRectangularCubeTextureAssetTask object
  77289. */
  77290. addEquiRectangularCubeTextureAssetTask(taskName: string, url: string, size: number, noMipmap?: boolean, gammaSpace?: boolean): EquiRectangularCubeTextureAssetTask;
  77291. /**
  77292. * Remove a task from the assets manager.
  77293. * @param task the task to remove
  77294. */
  77295. removeTask(task: AbstractAssetTask): void;
  77296. private _decreaseWaitingTasksCount;
  77297. private _runTask;
  77298. /**
  77299. * Reset the AssetsManager and remove all tasks
  77300. * @return the current instance of the AssetsManager
  77301. */
  77302. reset(): AssetsManager;
  77303. /**
  77304. * Start the loading process
  77305. * @return the current instance of the AssetsManager
  77306. */
  77307. load(): AssetsManager;
  77308. /**
  77309. * Start the loading process as an async operation
  77310. * @return a promise returning the list of failed tasks
  77311. */
  77312. loadAsync(): Promise<void>;
  77313. }
  77314. }
  77315. declare module "babylonjs/Misc/deferred" {
  77316. /**
  77317. * Wrapper class for promise with external resolve and reject.
  77318. */
  77319. export class Deferred<T> {
  77320. /**
  77321. * The promise associated with this deferred object.
  77322. */
  77323. readonly promise: Promise<T>;
  77324. private _resolve;
  77325. private _reject;
  77326. /**
  77327. * The resolve method of the promise associated with this deferred object.
  77328. */
  77329. get resolve(): (value?: T | PromiseLike<T> | undefined) => void;
  77330. /**
  77331. * The reject method of the promise associated with this deferred object.
  77332. */
  77333. get reject(): (reason?: any) => void;
  77334. /**
  77335. * Constructor for this deferred object.
  77336. */
  77337. constructor();
  77338. }
  77339. }
  77340. declare module "babylonjs/Misc/meshExploder" {
  77341. import { Mesh } from "babylonjs/Meshes/mesh";
  77342. /**
  77343. * Class used to explode meshes (ie. to have a center and move them away from that center to better see the overall organization)
  77344. */
  77345. export class MeshExploder {
  77346. private _centerMesh;
  77347. private _meshes;
  77348. private _meshesOrigins;
  77349. private _toCenterVectors;
  77350. private _scaledDirection;
  77351. private _newPosition;
  77352. private _centerPosition;
  77353. /**
  77354. * Explodes meshes from a center mesh.
  77355. * @param meshes The meshes to explode.
  77356. * @param centerMesh The mesh to be center of explosion.
  77357. */
  77358. constructor(meshes: Array<Mesh>, centerMesh?: Mesh);
  77359. private _setCenterMesh;
  77360. /**
  77361. * Get class name
  77362. * @returns "MeshExploder"
  77363. */
  77364. getClassName(): string;
  77365. /**
  77366. * "Exploded meshes"
  77367. * @returns Array of meshes with the centerMesh at index 0.
  77368. */
  77369. getMeshes(): Array<Mesh>;
  77370. /**
  77371. * Explodes meshes giving a specific direction
  77372. * @param direction Number to multiply distance of each mesh's origin from center. Use a negative number to implode, or zero to reset.
  77373. */
  77374. explode(direction?: number): void;
  77375. }
  77376. }
  77377. declare module "babylonjs/Misc/filesInput" {
  77378. import { Engine } from "babylonjs/Engines/engine";
  77379. import { Scene } from "babylonjs/scene";
  77380. import { ISceneLoaderProgressEvent } from "babylonjs/Loading/sceneLoader";
  77381. import { Nullable } from "babylonjs/types";
  77382. /**
  77383. * Class used to help managing file picking and drag'n'drop
  77384. */
  77385. export class FilesInput {
  77386. /**
  77387. * List of files ready to be loaded
  77388. */
  77389. static get FilesToLoad(): {
  77390. [key: string]: File;
  77391. };
  77392. /**
  77393. * Callback called when a file is processed
  77394. */
  77395. onProcessFileCallback: (file: File, name: string, extension: string) => boolean;
  77396. private _engine;
  77397. private _currentScene;
  77398. private _sceneLoadedCallback;
  77399. private _progressCallback;
  77400. private _additionalRenderLoopLogicCallback;
  77401. private _textureLoadingCallback;
  77402. private _startingProcessingFilesCallback;
  77403. private _onReloadCallback;
  77404. private _errorCallback;
  77405. private _elementToMonitor;
  77406. private _sceneFileToLoad;
  77407. private _filesToLoad;
  77408. /**
  77409. * Creates a new FilesInput
  77410. * @param engine defines the rendering engine
  77411. * @param scene defines the hosting scene
  77412. * @param sceneLoadedCallback callback called when scene is loaded
  77413. * @param progressCallback callback called to track progress
  77414. * @param additionalRenderLoopLogicCallback callback called to add user logic to the rendering loop
  77415. * @param textureLoadingCallback callback called when a texture is loading
  77416. * @param startingProcessingFilesCallback callback called when the system is about to process all files
  77417. * @param onReloadCallback callback called when a reload is requested
  77418. * @param errorCallback callback call if an error occurs
  77419. */
  77420. 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>);
  77421. private _dragEnterHandler;
  77422. private _dragOverHandler;
  77423. private _dropHandler;
  77424. /**
  77425. * Calls this function to listen to drag'n'drop events on a specific DOM element
  77426. * @param elementToMonitor defines the DOM element to track
  77427. */
  77428. monitorElementForDragNDrop(elementToMonitor: HTMLElement): void;
  77429. /** Gets the current list of files to load */
  77430. get filesToLoad(): File[];
  77431. /**
  77432. * Release all associated resources
  77433. */
  77434. dispose(): void;
  77435. private renderFunction;
  77436. private drag;
  77437. private drop;
  77438. private _traverseFolder;
  77439. private _processFiles;
  77440. /**
  77441. * Load files from a drop event
  77442. * @param event defines the drop event to use as source
  77443. */
  77444. loadFiles(event: any): void;
  77445. private _processReload;
  77446. /**
  77447. * Reload the current scene from the loaded files
  77448. */
  77449. reload(): void;
  77450. }
  77451. }
  77452. declare module "babylonjs/Misc/HighDynamicRange/index" {
  77453. export * from "babylonjs/Misc/HighDynamicRange/cubemapToSphericalPolynomial";
  77454. export * from "babylonjs/Misc/HighDynamicRange/hdr";
  77455. export * from "babylonjs/Misc/HighDynamicRange/panoramaToCubemap";
  77456. }
  77457. declare module "babylonjs/Misc/sceneOptimizer" {
  77458. import { Scene, IDisposable } from "babylonjs/scene";
  77459. import { Observable } from "babylonjs/Misc/observable";
  77460. /**
  77461. * Defines the root class used to create scene optimization to use with SceneOptimizer
  77462. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  77463. */
  77464. export class SceneOptimization {
  77465. /**
  77466. * Defines the priority of this optimization (0 by default which means first in the list)
  77467. */
  77468. priority: number;
  77469. /**
  77470. * Gets a string describing the action executed by the current optimization
  77471. * @returns description string
  77472. */
  77473. getDescription(): string;
  77474. /**
  77475. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  77476. * @param scene defines the current scene where to apply this optimization
  77477. * @param optimizer defines the current optimizer
  77478. * @returns true if everything that can be done was applied
  77479. */
  77480. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  77481. /**
  77482. * Creates the SceneOptimization object
  77483. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  77484. * @param desc defines the description associated with the optimization
  77485. */
  77486. constructor(
  77487. /**
  77488. * Defines the priority of this optimization (0 by default which means first in the list)
  77489. */
  77490. priority?: number);
  77491. }
  77492. /**
  77493. * Defines an optimization used to reduce the size of render target textures
  77494. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  77495. */
  77496. export class TextureOptimization extends SceneOptimization {
  77497. /**
  77498. * Defines the priority of this optimization (0 by default which means first in the list)
  77499. */
  77500. priority: number;
  77501. /**
  77502. * 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
  77503. */
  77504. maximumSize: number;
  77505. /**
  77506. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  77507. */
  77508. step: number;
  77509. /**
  77510. * Gets a string describing the action executed by the current optimization
  77511. * @returns description string
  77512. */
  77513. getDescription(): string;
  77514. /**
  77515. * Creates the TextureOptimization object
  77516. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  77517. * @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
  77518. * @param step defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  77519. */
  77520. constructor(
  77521. /**
  77522. * Defines the priority of this optimization (0 by default which means first in the list)
  77523. */
  77524. priority?: number,
  77525. /**
  77526. * 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
  77527. */
  77528. maximumSize?: number,
  77529. /**
  77530. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  77531. */
  77532. step?: number);
  77533. /**
  77534. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  77535. * @param scene defines the current scene where to apply this optimization
  77536. * @param optimizer defines the current optimizer
  77537. * @returns true if everything that can be done was applied
  77538. */
  77539. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  77540. }
  77541. /**
  77542. * Defines an optimization used to increase or decrease the rendering resolution
  77543. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  77544. */
  77545. export class HardwareScalingOptimization extends SceneOptimization {
  77546. /**
  77547. * Defines the priority of this optimization (0 by default which means first in the list)
  77548. */
  77549. priority: number;
  77550. /**
  77551. * Defines the maximum scale to use (2 by default)
  77552. */
  77553. maximumScale: number;
  77554. /**
  77555. * Defines the step to use between two passes (0.5 by default)
  77556. */
  77557. step: number;
  77558. private _currentScale;
  77559. private _directionOffset;
  77560. /**
  77561. * Gets a string describing the action executed by the current optimization
  77562. * @return description string
  77563. */
  77564. getDescription(): string;
  77565. /**
  77566. * Creates the HardwareScalingOptimization object
  77567. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  77568. * @param maximumScale defines the maximum scale to use (2 by default)
  77569. * @param step defines the step to use between two passes (0.5 by default)
  77570. */
  77571. constructor(
  77572. /**
  77573. * Defines the priority of this optimization (0 by default which means first in the list)
  77574. */
  77575. priority?: number,
  77576. /**
  77577. * Defines the maximum scale to use (2 by default)
  77578. */
  77579. maximumScale?: number,
  77580. /**
  77581. * Defines the step to use between two passes (0.5 by default)
  77582. */
  77583. step?: number);
  77584. /**
  77585. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  77586. * @param scene defines the current scene where to apply this optimization
  77587. * @param optimizer defines the current optimizer
  77588. * @returns true if everything that can be done was applied
  77589. */
  77590. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  77591. }
  77592. /**
  77593. * Defines an optimization used to remove shadows
  77594. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  77595. */
  77596. export class ShadowsOptimization extends SceneOptimization {
  77597. /**
  77598. * Gets a string describing the action executed by the current optimization
  77599. * @return description string
  77600. */
  77601. getDescription(): string;
  77602. /**
  77603. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  77604. * @param scene defines the current scene where to apply this optimization
  77605. * @param optimizer defines the current optimizer
  77606. * @returns true if everything that can be done was applied
  77607. */
  77608. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  77609. }
  77610. /**
  77611. * Defines an optimization used to turn post-processes off
  77612. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  77613. */
  77614. export class PostProcessesOptimization extends SceneOptimization {
  77615. /**
  77616. * Gets a string describing the action executed by the current optimization
  77617. * @return description string
  77618. */
  77619. getDescription(): string;
  77620. /**
  77621. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  77622. * @param scene defines the current scene where to apply this optimization
  77623. * @param optimizer defines the current optimizer
  77624. * @returns true if everything that can be done was applied
  77625. */
  77626. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  77627. }
  77628. /**
  77629. * Defines an optimization used to turn lens flares off
  77630. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  77631. */
  77632. export class LensFlaresOptimization extends SceneOptimization {
  77633. /**
  77634. * Gets a string describing the action executed by the current optimization
  77635. * @return description string
  77636. */
  77637. getDescription(): string;
  77638. /**
  77639. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  77640. * @param scene defines the current scene where to apply this optimization
  77641. * @param optimizer defines the current optimizer
  77642. * @returns true if everything that can be done was applied
  77643. */
  77644. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  77645. }
  77646. /**
  77647. * Defines an optimization based on user defined callback.
  77648. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  77649. */
  77650. export class CustomOptimization extends SceneOptimization {
  77651. /**
  77652. * Callback called to apply the custom optimization.
  77653. */
  77654. onApply: (scene: Scene, optimizer: SceneOptimizer) => boolean;
  77655. /**
  77656. * Callback called to get custom description
  77657. */
  77658. onGetDescription: () => string;
  77659. /**
  77660. * Gets a string describing the action executed by the current optimization
  77661. * @returns description string
  77662. */
  77663. getDescription(): string;
  77664. /**
  77665. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  77666. * @param scene defines the current scene where to apply this optimization
  77667. * @param optimizer defines the current optimizer
  77668. * @returns true if everything that can be done was applied
  77669. */
  77670. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  77671. }
  77672. /**
  77673. * Defines an optimization used to turn particles off
  77674. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  77675. */
  77676. export class ParticlesOptimization extends SceneOptimization {
  77677. /**
  77678. * Gets a string describing the action executed by the current optimization
  77679. * @return description string
  77680. */
  77681. getDescription(): string;
  77682. /**
  77683. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  77684. * @param scene defines the current scene where to apply this optimization
  77685. * @param optimizer defines the current optimizer
  77686. * @returns true if everything that can be done was applied
  77687. */
  77688. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  77689. }
  77690. /**
  77691. * Defines an optimization used to turn render targets off
  77692. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  77693. */
  77694. export class RenderTargetsOptimization extends SceneOptimization {
  77695. /**
  77696. * Gets a string describing the action executed by the current optimization
  77697. * @return description string
  77698. */
  77699. getDescription(): string;
  77700. /**
  77701. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  77702. * @param scene defines the current scene where to apply this optimization
  77703. * @param optimizer defines the current optimizer
  77704. * @returns true if everything that can be done was applied
  77705. */
  77706. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  77707. }
  77708. /**
  77709. * Defines an optimization used to merge meshes with compatible materials
  77710. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  77711. */
  77712. export class MergeMeshesOptimization extends SceneOptimization {
  77713. private static _UpdateSelectionTree;
  77714. /**
  77715. * Gets or sets a boolean which defines if optimization octree has to be updated
  77716. */
  77717. static get UpdateSelectionTree(): boolean;
  77718. /**
  77719. * Gets or sets a boolean which defines if optimization octree has to be updated
  77720. */
  77721. static set UpdateSelectionTree(value: boolean);
  77722. /**
  77723. * Gets a string describing the action executed by the current optimization
  77724. * @return description string
  77725. */
  77726. getDescription(): string;
  77727. private _canBeMerged;
  77728. /**
  77729. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  77730. * @param scene defines the current scene where to apply this optimization
  77731. * @param optimizer defines the current optimizer
  77732. * @param updateSelectionTree defines that the selection octree has to be updated (false by default)
  77733. * @returns true if everything that can be done was applied
  77734. */
  77735. apply(scene: Scene, optimizer: SceneOptimizer, updateSelectionTree?: boolean): boolean;
  77736. }
  77737. /**
  77738. * Defines a list of options used by SceneOptimizer
  77739. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  77740. */
  77741. export class SceneOptimizerOptions {
  77742. /**
  77743. * Defines the target frame rate to reach (60 by default)
  77744. */
  77745. targetFrameRate: number;
  77746. /**
  77747. * Defines the interval between two checkes (2000ms by default)
  77748. */
  77749. trackerDuration: number;
  77750. /**
  77751. * Gets the list of optimizations to apply
  77752. */
  77753. optimizations: SceneOptimization[];
  77754. /**
  77755. * Creates a new list of options used by SceneOptimizer
  77756. * @param targetFrameRate defines the target frame rate to reach (60 by default)
  77757. * @param trackerDuration defines the interval between two checkes (2000ms by default)
  77758. */
  77759. constructor(
  77760. /**
  77761. * Defines the target frame rate to reach (60 by default)
  77762. */
  77763. targetFrameRate?: number,
  77764. /**
  77765. * Defines the interval between two checkes (2000ms by default)
  77766. */
  77767. trackerDuration?: number);
  77768. /**
  77769. * Add a new optimization
  77770. * @param optimization defines the SceneOptimization to add to the list of active optimizations
  77771. * @returns the current SceneOptimizerOptions
  77772. */
  77773. addOptimization(optimization: SceneOptimization): SceneOptimizerOptions;
  77774. /**
  77775. * Add a new custom optimization
  77776. * @param onApply defines the callback called to apply the custom optimization (true if everything that can be done was applied)
  77777. * @param onGetDescription defines the callback called to get the description attached with the optimization.
  77778. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  77779. * @returns the current SceneOptimizerOptions
  77780. */
  77781. addCustomOptimization(onApply: (scene: Scene) => boolean, onGetDescription: () => string, priority?: number): SceneOptimizerOptions;
  77782. /**
  77783. * Creates a list of pre-defined optimizations aimed to reduce the visual impact on the scene
  77784. * @param targetFrameRate defines the target frame rate (60 by default)
  77785. * @returns a SceneOptimizerOptions object
  77786. */
  77787. static LowDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  77788. /**
  77789. * Creates a list of pre-defined optimizations aimed to have a moderate impact on the scene visual
  77790. * @param targetFrameRate defines the target frame rate (60 by default)
  77791. * @returns a SceneOptimizerOptions object
  77792. */
  77793. static ModerateDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  77794. /**
  77795. * Creates a list of pre-defined optimizations aimed to have a big impact on the scene visual
  77796. * @param targetFrameRate defines the target frame rate (60 by default)
  77797. * @returns a SceneOptimizerOptions object
  77798. */
  77799. static HighDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  77800. }
  77801. /**
  77802. * Class used to run optimizations in order to reach a target frame rate
  77803. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  77804. */
  77805. export class SceneOptimizer implements IDisposable {
  77806. private _isRunning;
  77807. private _options;
  77808. private _scene;
  77809. private _currentPriorityLevel;
  77810. private _targetFrameRate;
  77811. private _trackerDuration;
  77812. private _currentFrameRate;
  77813. private _sceneDisposeObserver;
  77814. private _improvementMode;
  77815. /**
  77816. * Defines an observable called when the optimizer reaches the target frame rate
  77817. */
  77818. onSuccessObservable: Observable<SceneOptimizer>;
  77819. /**
  77820. * Defines an observable called when the optimizer enables an optimization
  77821. */
  77822. onNewOptimizationAppliedObservable: Observable<SceneOptimization>;
  77823. /**
  77824. * Defines an observable called when the optimizer is not able to reach the target frame rate
  77825. */
  77826. onFailureObservable: Observable<SceneOptimizer>;
  77827. /**
  77828. * Gets a boolean indicating if the optimizer is in improvement mode
  77829. */
  77830. get isInImprovementMode(): boolean;
  77831. /**
  77832. * Gets the current priority level (0 at start)
  77833. */
  77834. get currentPriorityLevel(): number;
  77835. /**
  77836. * Gets the current frame rate checked by the SceneOptimizer
  77837. */
  77838. get currentFrameRate(): number;
  77839. /**
  77840. * Gets or sets the current target frame rate (60 by default)
  77841. */
  77842. get targetFrameRate(): number;
  77843. /**
  77844. * Gets or sets the current target frame rate (60 by default)
  77845. */
  77846. set targetFrameRate(value: number);
  77847. /**
  77848. * Gets or sets the current interval between two checks (every 2000ms by default)
  77849. */
  77850. get trackerDuration(): number;
  77851. /**
  77852. * Gets or sets the current interval between two checks (every 2000ms by default)
  77853. */
  77854. set trackerDuration(value: number);
  77855. /**
  77856. * Gets the list of active optimizations
  77857. */
  77858. get optimizations(): SceneOptimization[];
  77859. /**
  77860. * Creates a new SceneOptimizer
  77861. * @param scene defines the scene to work on
  77862. * @param options defines the options to use with the SceneOptimizer
  77863. * @param autoGeneratePriorities defines if priorities must be generated and not read from SceneOptimization property (true by default)
  77864. * @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)
  77865. */
  77866. constructor(scene: Scene, options?: SceneOptimizerOptions, autoGeneratePriorities?: boolean, improvementMode?: boolean);
  77867. /**
  77868. * Stops the current optimizer
  77869. */
  77870. stop(): void;
  77871. /**
  77872. * Reset the optimizer to initial step (current priority level = 0)
  77873. */
  77874. reset(): void;
  77875. /**
  77876. * Start the optimizer. By default it will try to reach a specific framerate
  77877. * but if the optimizer is set with improvementMode === true then it will run all optimiatiation while frame rate is above the target frame rate
  77878. */
  77879. start(): void;
  77880. private _checkCurrentState;
  77881. /**
  77882. * Release all resources
  77883. */
  77884. dispose(): void;
  77885. /**
  77886. * Helper function to create a SceneOptimizer with one single line of code
  77887. * @param scene defines the scene to work on
  77888. * @param options defines the options to use with the SceneOptimizer
  77889. * @param onSuccess defines a callback to call on success
  77890. * @param onFailure defines a callback to call on failure
  77891. * @returns the new SceneOptimizer object
  77892. */
  77893. static OptimizeAsync(scene: Scene, options?: SceneOptimizerOptions, onSuccess?: () => void, onFailure?: () => void): SceneOptimizer;
  77894. }
  77895. }
  77896. declare module "babylonjs/Misc/sceneSerializer" {
  77897. import { Scene } from "babylonjs/scene";
  77898. /**
  77899. * Class used to serialize a scene into a string
  77900. */
  77901. export class SceneSerializer {
  77902. /**
  77903. * Clear cache used by a previous serialization
  77904. */
  77905. static ClearCache(): void;
  77906. /**
  77907. * Serialize a scene into a JSON compatible object
  77908. * @param scene defines the scene to serialize
  77909. * @returns a JSON compatible object
  77910. */
  77911. static Serialize(scene: Scene): any;
  77912. /**
  77913. * Serialize a mesh into a JSON compatible object
  77914. * @param toSerialize defines the mesh to serialize
  77915. * @param withParents defines if parents must be serialized as well
  77916. * @param withChildren defines if children must be serialized as well
  77917. * @returns a JSON compatible object
  77918. */
  77919. static SerializeMesh(toSerialize: any, withParents?: boolean, withChildren?: boolean): any;
  77920. }
  77921. }
  77922. declare module "babylonjs/Misc/textureTools" {
  77923. import { Texture } from "babylonjs/Materials/Textures/texture";
  77924. /**
  77925. * Class used to host texture specific utilities
  77926. */
  77927. export class TextureTools {
  77928. /**
  77929. * Uses the GPU to create a copy texture rescaled at a given size
  77930. * @param texture Texture to copy from
  77931. * @param width defines the desired width
  77932. * @param height defines the desired height
  77933. * @param useBilinearMode defines if bilinear mode has to be used
  77934. * @return the generated texture
  77935. */
  77936. static CreateResizedCopy(texture: Texture, width: number, height: number, useBilinearMode?: boolean): Texture;
  77937. }
  77938. }
  77939. declare module "babylonjs/Misc/videoRecorder" {
  77940. import { Nullable } from "babylonjs/types";
  77941. import { Engine } from "babylonjs/Engines/engine";
  77942. /**
  77943. * This represents the different options available for the video capture.
  77944. */
  77945. export interface VideoRecorderOptions {
  77946. /** Defines the mime type of the video. */
  77947. mimeType: string;
  77948. /** Defines the FPS the video should be recorded at. */
  77949. fps: number;
  77950. /** Defines the chunk size for the recording data. */
  77951. recordChunckSize: number;
  77952. /** The audio tracks to attach to the recording. */
  77953. audioTracks?: MediaStreamTrack[];
  77954. }
  77955. /**
  77956. * This can help with recording videos from BabylonJS.
  77957. * This is based on the available WebRTC functionalities of the browser.
  77958. *
  77959. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_video
  77960. */
  77961. export class VideoRecorder {
  77962. private static readonly _defaultOptions;
  77963. /**
  77964. * Returns whether or not the VideoRecorder is available in your browser.
  77965. * @param engine Defines the Babylon Engine.
  77966. * @returns true if supported otherwise false.
  77967. */
  77968. static IsSupported(engine: Engine): boolean;
  77969. private readonly _options;
  77970. private _canvas;
  77971. private _mediaRecorder;
  77972. private _recordedChunks;
  77973. private _fileName;
  77974. private _resolve;
  77975. private _reject;
  77976. /**
  77977. * True when a recording is already in progress.
  77978. */
  77979. get isRecording(): boolean;
  77980. /**
  77981. * Create a new VideoCapture object which can help converting what you see in Babylon to a video file.
  77982. * @param engine Defines the BabylonJS Engine you wish to record.
  77983. * @param options Defines options that can be used to customize the capture.
  77984. */
  77985. constructor(engine: Engine, options?: Nullable<VideoRecorderOptions>);
  77986. /**
  77987. * Stops the current recording before the default capture timeout passed in the startRecording function.
  77988. */
  77989. stopRecording(): void;
  77990. /**
  77991. * Starts recording the canvas for a max duration specified in parameters.
  77992. * @param fileName Defines the name of the file to be downloaded when the recording stop.
  77993. * If null no automatic download will start and you can rely on the promise to get the data back.
  77994. * @param maxDuration Defines the maximum recording time in seconds.
  77995. * It defaults to 7 seconds. A value of zero will not stop automatically, you would need to call stopRecording manually.
  77996. * @return A promise callback at the end of the recording with the video data in Blob.
  77997. */
  77998. startRecording(fileName?: Nullable<string>, maxDuration?: number): Promise<Blob>;
  77999. /**
  78000. * Releases internal resources used during the recording.
  78001. */
  78002. dispose(): void;
  78003. private _handleDataAvailable;
  78004. private _handleError;
  78005. private _handleStop;
  78006. }
  78007. }
  78008. declare module "babylonjs/Misc/screenshotTools" {
  78009. import { Camera } from "babylonjs/Cameras/camera";
  78010. import { IScreenshotSize } from "babylonjs/Misc/interfaces/screenshotSize";
  78011. import { Engine } from "babylonjs/Engines/engine";
  78012. /**
  78013. * Class containing a set of static utilities functions for screenshots
  78014. */
  78015. export class ScreenshotTools {
  78016. /**
  78017. * Captures a screenshot of the current rendering
  78018. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_png
  78019. * @param engine defines the rendering engine
  78020. * @param camera defines the source camera
  78021. * @param size This parameter can be set to a single number or to an object with the
  78022. * following (optional) properties: precision, width, height. If a single number is passed,
  78023. * it will be used for both width and height. If an object is passed, the screenshot size
  78024. * will be derived from the parameters. The precision property is a multiplier allowing
  78025. * rendering at a higher or lower resolution
  78026. * @param successCallback defines the callback receives a single parameter which contains the
  78027. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  78028. * src parameter of an <img> to display it
  78029. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  78030. * Check your browser for supported MIME types
  78031. */
  78032. static CreateScreenshot(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string): void;
  78033. /**
  78034. * Captures a screenshot of the current rendering
  78035. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_png
  78036. * @param engine defines the rendering engine
  78037. * @param camera defines the source camera
  78038. * @param size This parameter can be set to a single number or to an object with the
  78039. * following (optional) properties: precision, width, height. If a single number is passed,
  78040. * it will be used for both width and height. If an object is passed, the screenshot size
  78041. * will be derived from the parameters. The precision property is a multiplier allowing
  78042. * rendering at a higher or lower resolution
  78043. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  78044. * Check your browser for supported MIME types
  78045. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  78046. * to the src parameter of an <img> to display it
  78047. */
  78048. static CreateScreenshotAsync(engine: Engine, camera: Camera, size: any, mimeType?: string): Promise<string>;
  78049. /**
  78050. * Generates an image screenshot from the specified camera.
  78051. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_png
  78052. * @param engine The engine to use for rendering
  78053. * @param camera The camera to use for rendering
  78054. * @param size This parameter can be set to a single number or to an object with the
  78055. * following (optional) properties: precision, width, height. If a single number is passed,
  78056. * it will be used for both width and height. If an object is passed, the screenshot size
  78057. * will be derived from the parameters. The precision property is a multiplier allowing
  78058. * rendering at a higher or lower resolution
  78059. * @param successCallback The callback receives a single parameter which contains the
  78060. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  78061. * src parameter of an <img> to display it
  78062. * @param mimeType The MIME type of the screenshot image (default: image/png).
  78063. * Check your browser for supported MIME types
  78064. * @param samples Texture samples (default: 1)
  78065. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  78066. * @param fileName A name for for the downloaded file.
  78067. * @param renderSprites Whether the sprites should be rendered or not (default: false)
  78068. * @param enableStencilBuffer Whether the stencil buffer should be enabled or not (default: false)
  78069. */
  78070. 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;
  78071. /**
  78072. * Generates an image screenshot from the specified camera.
  78073. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_png
  78074. * @param engine The engine to use for rendering
  78075. * @param camera The camera to use for rendering
  78076. * @param size This parameter can be set to a single number or to an object with the
  78077. * following (optional) properties: precision, width, height. If a single number is passed,
  78078. * it will be used for both width and height. If an object is passed, the screenshot size
  78079. * will be derived from the parameters. The precision property is a multiplier allowing
  78080. * rendering at a higher or lower resolution
  78081. * @param mimeType The MIME type of the screenshot image (default: image/png).
  78082. * Check your browser for supported MIME types
  78083. * @param samples Texture samples (default: 1)
  78084. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  78085. * @param fileName A name for for the downloaded file.
  78086. * @param renderSprites Whether the sprites should be rendered or not (default: false)
  78087. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  78088. * to the src parameter of an <img> to display it
  78089. */
  78090. static CreateScreenshotUsingRenderTargetAsync(engine: Engine, camera: Camera, size: any, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string, renderSprites?: boolean): Promise<string>;
  78091. /**
  78092. * Gets height and width for screenshot size
  78093. * @private
  78094. */
  78095. private static _getScreenshotSize;
  78096. }
  78097. }
  78098. declare module "babylonjs/Misc/dataReader" {
  78099. /**
  78100. * Interface for a data buffer
  78101. */
  78102. export interface IDataBuffer {
  78103. /**
  78104. * Reads bytes from the data buffer.
  78105. * @param byteOffset The byte offset to read
  78106. * @param byteLength The byte length to read
  78107. * @returns A promise that resolves when the bytes are read
  78108. */
  78109. readAsync(byteOffset: number, byteLength: number): Promise<ArrayBufferView>;
  78110. /**
  78111. * The byte length of the buffer.
  78112. */
  78113. readonly byteLength: number;
  78114. }
  78115. /**
  78116. * Utility class for reading from a data buffer
  78117. */
  78118. export class DataReader {
  78119. /**
  78120. * The data buffer associated with this data reader.
  78121. */
  78122. readonly buffer: IDataBuffer;
  78123. /**
  78124. * The current byte offset from the beginning of the data buffer.
  78125. */
  78126. byteOffset: number;
  78127. private _dataView;
  78128. private _dataByteOffset;
  78129. /**
  78130. * Constructor
  78131. * @param buffer The buffer to read
  78132. */
  78133. constructor(buffer: IDataBuffer);
  78134. /**
  78135. * Loads the given byte length.
  78136. * @param byteLength The byte length to load
  78137. * @returns A promise that resolves when the load is complete
  78138. */
  78139. loadAsync(byteLength: number): Promise<void>;
  78140. /**
  78141. * Read a unsigned 32-bit integer from the currently loaded data range.
  78142. * @returns The 32-bit integer read
  78143. */
  78144. readUint32(): number;
  78145. /**
  78146. * Read a byte array from the currently loaded data range.
  78147. * @param byteLength The byte length to read
  78148. * @returns The byte array read
  78149. */
  78150. readUint8Array(byteLength: number): Uint8Array;
  78151. /**
  78152. * Read a string from the currently loaded data range.
  78153. * @param byteLength The byte length to read
  78154. * @returns The string read
  78155. */
  78156. readString(byteLength: number): string;
  78157. /**
  78158. * Skips the given byte length the currently loaded data range.
  78159. * @param byteLength The byte length to skip
  78160. */
  78161. skipBytes(byteLength: number): void;
  78162. }
  78163. }
  78164. declare module "babylonjs/Misc/dataStorage" {
  78165. /**
  78166. * Class for storing data to local storage if available or in-memory storage otherwise
  78167. */
  78168. export class DataStorage {
  78169. private static _Storage;
  78170. private static _GetStorage;
  78171. /**
  78172. * Reads a string from the data storage
  78173. * @param key The key to read
  78174. * @param defaultValue The value if the key doesn't exist
  78175. * @returns The string value
  78176. */
  78177. static ReadString(key: string, defaultValue: string): string;
  78178. /**
  78179. * Writes a string to the data storage
  78180. * @param key The key to write
  78181. * @param value The value to write
  78182. */
  78183. static WriteString(key: string, value: string): void;
  78184. /**
  78185. * Reads a boolean from the data storage
  78186. * @param key The key to read
  78187. * @param defaultValue The value if the key doesn't exist
  78188. * @returns The boolean value
  78189. */
  78190. static ReadBoolean(key: string, defaultValue: boolean): boolean;
  78191. /**
  78192. * Writes a boolean to the data storage
  78193. * @param key The key to write
  78194. * @param value The value to write
  78195. */
  78196. static WriteBoolean(key: string, value: boolean): void;
  78197. /**
  78198. * Reads a number from the data storage
  78199. * @param key The key to read
  78200. * @param defaultValue The value if the key doesn't exist
  78201. * @returns The number value
  78202. */
  78203. static ReadNumber(key: string, defaultValue: number): number;
  78204. /**
  78205. * Writes a number to the data storage
  78206. * @param key The key to write
  78207. * @param value The value to write
  78208. */
  78209. static WriteNumber(key: string, value: number): void;
  78210. }
  78211. }
  78212. declare module "babylonjs/Misc/sceneRecorder" {
  78213. import { Scene } from "babylonjs/scene";
  78214. /**
  78215. * Class used to record delta files between 2 scene states
  78216. */
  78217. export class SceneRecorder {
  78218. private _trackedScene;
  78219. private _savedJSON;
  78220. /**
  78221. * Track a given scene. This means the current scene state will be considered the original state
  78222. * @param scene defines the scene to track
  78223. */
  78224. track(scene: Scene): void;
  78225. /**
  78226. * Get the delta between current state and original state
  78227. * @returns a string containing the delta
  78228. */
  78229. getDelta(): any;
  78230. private _compareArray;
  78231. private _compareObjects;
  78232. private _compareCollections;
  78233. private static GetShadowGeneratorById;
  78234. /**
  78235. * Apply a given delta to a given scene
  78236. * @param deltaJSON defines the JSON containing the delta
  78237. * @param scene defines the scene to apply the delta to
  78238. */
  78239. static ApplyDelta(deltaJSON: any | string, scene: Scene): void;
  78240. private static _ApplyPropertiesToEntity;
  78241. private static _ApplyDeltaForEntity;
  78242. }
  78243. }
  78244. declare module "babylonjs/Misc/index" {
  78245. export * from "babylonjs/Misc/andOrNotEvaluator";
  78246. export * from "babylonjs/Misc/assetsManager";
  78247. export * from "babylonjs/Misc/basis";
  78248. export * from "babylonjs/Misc/dds";
  78249. export * from "babylonjs/Misc/decorators";
  78250. export * from "babylonjs/Misc/deferred";
  78251. export * from "babylonjs/Misc/environmentTextureTools";
  78252. export * from "babylonjs/Misc/meshExploder";
  78253. export * from "babylonjs/Misc/filesInput";
  78254. export * from "babylonjs/Misc/HighDynamicRange/index";
  78255. export * from "babylonjs/Misc/khronosTextureContainer";
  78256. export * from "babylonjs/Misc/observable";
  78257. export * from "babylonjs/Misc/performanceMonitor";
  78258. export * from "babylonjs/Misc/promise";
  78259. export * from "babylonjs/Misc/sceneOptimizer";
  78260. export * from "babylonjs/Misc/sceneSerializer";
  78261. export * from "babylonjs/Misc/smartArray";
  78262. export * from "babylonjs/Misc/stringDictionary";
  78263. export * from "babylonjs/Misc/tags";
  78264. export * from "babylonjs/Misc/textureTools";
  78265. export * from "babylonjs/Misc/tga";
  78266. export * from "babylonjs/Misc/tools";
  78267. export * from "babylonjs/Misc/videoRecorder";
  78268. export * from "babylonjs/Misc/virtualJoystick";
  78269. export * from "babylonjs/Misc/workerPool";
  78270. export * from "babylonjs/Misc/logger";
  78271. export * from "babylonjs/Misc/typeStore";
  78272. export * from "babylonjs/Misc/filesInputStore";
  78273. export * from "babylonjs/Misc/deepCopier";
  78274. export * from "babylonjs/Misc/pivotTools";
  78275. export * from "babylonjs/Misc/precisionDate";
  78276. export * from "babylonjs/Misc/screenshotTools";
  78277. export * from "babylonjs/Misc/typeStore";
  78278. export * from "babylonjs/Misc/webRequest";
  78279. export * from "babylonjs/Misc/iInspectable";
  78280. export * from "babylonjs/Misc/brdfTextureTools";
  78281. export * from "babylonjs/Misc/rgbdTextureTools";
  78282. export * from "babylonjs/Misc/gradients";
  78283. export * from "babylonjs/Misc/perfCounter";
  78284. export * from "babylonjs/Misc/fileRequest";
  78285. export * from "babylonjs/Misc/customAnimationFrameRequester";
  78286. export * from "babylonjs/Misc/retryStrategy";
  78287. export * from "babylonjs/Misc/interfaces/screenshotSize";
  78288. export * from "babylonjs/Misc/canvasGenerator";
  78289. export * from "babylonjs/Misc/fileTools";
  78290. export * from "babylonjs/Misc/stringTools";
  78291. export * from "babylonjs/Misc/dataReader";
  78292. export * from "babylonjs/Misc/minMaxReducer";
  78293. export * from "babylonjs/Misc/depthReducer";
  78294. export * from "babylonjs/Misc/dataStorage";
  78295. export * from "babylonjs/Misc/sceneRecorder";
  78296. }
  78297. declare module "babylonjs/XR/features/WebXRHitTestLegacy" {
  78298. import { IWebXRFeature } from "babylonjs/XR/webXRFeaturesManager";
  78299. import { WebXRSessionManager } from "babylonjs/XR/webXRSessionManager";
  78300. import { Observable } from "babylonjs/Misc/observable";
  78301. import { Matrix } from "babylonjs/Maths/math.vector";
  78302. import { TransformNode } from "babylonjs/Meshes/transformNode";
  78303. import { WebXRAbstractFeature } from "babylonjs/XR/features/WebXRAbstractFeature";
  78304. /**
  78305. * An interface for all Hit test features
  78306. */
  78307. export interface IWebXRHitTestFeature<T extends IWebXRLegacyHitResult> extends IWebXRFeature {
  78308. /**
  78309. * Triggered when new babylon (transformed) hit test results are available
  78310. */
  78311. onHitTestResultObservable: Observable<T[]>;
  78312. }
  78313. /**
  78314. * Options used for hit testing
  78315. */
  78316. export interface IWebXRLegacyHitTestOptions {
  78317. /**
  78318. * Only test when user interacted with the scene. Default - hit test every frame
  78319. */
  78320. testOnPointerDownOnly?: boolean;
  78321. /**
  78322. * The node to use to transform the local results to world coordinates
  78323. */
  78324. worldParentNode?: TransformNode;
  78325. }
  78326. /**
  78327. * Interface defining the babylon result of raycasting/hit-test
  78328. */
  78329. export interface IWebXRLegacyHitResult {
  78330. /**
  78331. * Transformation matrix that can be applied to a node that will put it in the hit point location
  78332. */
  78333. transformationMatrix: Matrix;
  78334. /**
  78335. * The native hit test result
  78336. */
  78337. xrHitResult: XRHitResult | XRHitTestResult;
  78338. }
  78339. /**
  78340. * The currently-working hit-test module.
  78341. * Hit test (or Ray-casting) is used to interact with the real world.
  78342. * For further information read here - https://github.com/immersive-web/hit-test
  78343. */
  78344. export class WebXRHitTestLegacy extends WebXRAbstractFeature implements IWebXRHitTestFeature<IWebXRLegacyHitResult> {
  78345. /**
  78346. * options to use when constructing this feature
  78347. */
  78348. readonly options: IWebXRLegacyHitTestOptions;
  78349. private _direction;
  78350. private _mat;
  78351. private _onSelectEnabled;
  78352. private _origin;
  78353. /**
  78354. * The module's name
  78355. */
  78356. static readonly Name: string;
  78357. /**
  78358. * The (Babylon) version of this module.
  78359. * This is an integer representing the implementation version.
  78360. * This number does not correspond to the WebXR specs version
  78361. */
  78362. static readonly Version: number;
  78363. /**
  78364. * Populated with the last native XR Hit Results
  78365. */
  78366. lastNativeXRHitResults: XRHitResult[];
  78367. /**
  78368. * Triggered when new babylon (transformed) hit test results are available
  78369. */
  78370. onHitTestResultObservable: Observable<IWebXRLegacyHitResult[]>;
  78371. /**
  78372. * Creates a new instance of the (legacy version) hit test feature
  78373. * @param _xrSessionManager an instance of WebXRSessionManager
  78374. * @param options options to use when constructing this feature
  78375. */
  78376. constructor(_xrSessionManager: WebXRSessionManager,
  78377. /**
  78378. * options to use when constructing this feature
  78379. */
  78380. options?: IWebXRLegacyHitTestOptions);
  78381. /**
  78382. * execute a hit test with an XR Ray
  78383. *
  78384. * @param xrSession a native xrSession that will execute this hit test
  78385. * @param xrRay the ray (position and direction) to use for ray-casting
  78386. * @param referenceSpace native XR reference space to use for the hit-test
  78387. * @param filter filter function that will filter the results
  78388. * @returns a promise that resolves with an array of native XR hit result in xr coordinates system
  78389. */
  78390. static XRHitTestWithRay(xrSession: XRSession, xrRay: XRRay, referenceSpace: XRReferenceSpace, filter?: (result: XRHitResult) => boolean): Promise<XRHitResult[]>;
  78391. /**
  78392. * Execute a hit test on the current running session using a select event returned from a transient input (such as touch)
  78393. * @param event the (select) event to use to select with
  78394. * @param referenceSpace the reference space to use for this hit test
  78395. * @returns a promise that resolves with an array of native XR hit result in xr coordinates system
  78396. */
  78397. static XRHitTestWithSelectEvent(event: XRInputSourceEvent, referenceSpace: XRReferenceSpace): Promise<XRHitResult[]>;
  78398. /**
  78399. * attach this feature
  78400. * Will usually be called by the features manager
  78401. *
  78402. * @returns true if successful.
  78403. */
  78404. attach(): boolean;
  78405. /**
  78406. * detach this feature.
  78407. * Will usually be called by the features manager
  78408. *
  78409. * @returns true if successful.
  78410. */
  78411. detach(): boolean;
  78412. /**
  78413. * Dispose this feature and all of the resources attached
  78414. */
  78415. dispose(): void;
  78416. protected _onXRFrame(frame: XRFrame): void;
  78417. private _onHitTestResults;
  78418. private _onSelect;
  78419. }
  78420. }
  78421. declare module "babylonjs/XR/features/WebXRHitTest" {
  78422. import { WebXRSessionManager } from "babylonjs/XR/webXRSessionManager";
  78423. import { Observable } from "babylonjs/Misc/observable";
  78424. import { Vector3, Quaternion } from "babylonjs/Maths/math.vector";
  78425. import { WebXRAbstractFeature } from "babylonjs/XR/features/WebXRAbstractFeature";
  78426. import { IWebXRLegacyHitTestOptions, IWebXRLegacyHitResult, IWebXRHitTestFeature } from "babylonjs/XR/features/WebXRHitTestLegacy";
  78427. /**
  78428. * Options used for hit testing (version 2)
  78429. */
  78430. export interface IWebXRHitTestOptions extends IWebXRLegacyHitTestOptions {
  78431. /**
  78432. * Do not create a permanent hit test. Will usually be used when only
  78433. * transient inputs are needed.
  78434. */
  78435. disablePermanentHitTest?: boolean;
  78436. /**
  78437. * Enable transient (for example touch-based) hit test inspections
  78438. */
  78439. enableTransientHitTest?: boolean;
  78440. /**
  78441. * Offset ray for the permanent hit test
  78442. */
  78443. offsetRay?: Vector3;
  78444. /**
  78445. * Offset ray for the transient hit test
  78446. */
  78447. transientOffsetRay?: Vector3;
  78448. /**
  78449. * Instead of using viewer space for hit tests, use the reference space defined in the session manager
  78450. */
  78451. useReferenceSpace?: boolean;
  78452. /**
  78453. * Override the default entity type(s) of the hit-test result
  78454. */
  78455. entityTypes?: XRHitTestTrackableType[];
  78456. }
  78457. /**
  78458. * Interface defining the babylon result of hit-test
  78459. */
  78460. export interface IWebXRHitResult extends IWebXRLegacyHitResult {
  78461. /**
  78462. * The input source that generated this hit test (if transient)
  78463. */
  78464. inputSource?: XRInputSource;
  78465. /**
  78466. * Is this a transient hit test
  78467. */
  78468. isTransient?: boolean;
  78469. /**
  78470. * Position of the hit test result
  78471. */
  78472. position: Vector3;
  78473. /**
  78474. * Rotation of the hit test result
  78475. */
  78476. rotationQuaternion: Quaternion;
  78477. /**
  78478. * The native hit test result
  78479. */
  78480. xrHitResult: XRHitTestResult;
  78481. }
  78482. /**
  78483. * The currently-working hit-test module.
  78484. * Hit test (or Ray-casting) is used to interact with the real world.
  78485. * For further information read here - https://github.com/immersive-web/hit-test
  78486. *
  78487. * Tested on chrome (mobile) 80.
  78488. */
  78489. export class WebXRHitTest extends WebXRAbstractFeature implements IWebXRHitTestFeature<IWebXRHitResult> {
  78490. /**
  78491. * options to use when constructing this feature
  78492. */
  78493. readonly options: IWebXRHitTestOptions;
  78494. private _tmpMat;
  78495. private _tmpPos;
  78496. private _tmpQuat;
  78497. private _transientXrHitTestSource;
  78498. private _xrHitTestSource;
  78499. private initHitTestSource;
  78500. /**
  78501. * The module's name
  78502. */
  78503. static readonly Name: string;
  78504. /**
  78505. * The (Babylon) version of this module.
  78506. * This is an integer representing the implementation version.
  78507. * This number does not correspond to the WebXR specs version
  78508. */
  78509. static readonly Version: number;
  78510. /**
  78511. * When set to true, each hit test will have its own position/rotation objects
  78512. * When set to false, position and rotation objects will be reused for each hit test. It is expected that
  78513. * the developers will clone them or copy them as they see fit.
  78514. */
  78515. autoCloneTransformation: boolean;
  78516. /**
  78517. * Triggered when new babylon (transformed) hit test results are available
  78518. */
  78519. onHitTestResultObservable: Observable<IWebXRHitResult[]>;
  78520. /**
  78521. * Use this to temporarily pause hit test checks.
  78522. */
  78523. paused: boolean;
  78524. /**
  78525. * Creates a new instance of the hit test feature
  78526. * @param _xrSessionManager an instance of WebXRSessionManager
  78527. * @param options options to use when constructing this feature
  78528. */
  78529. constructor(_xrSessionManager: WebXRSessionManager,
  78530. /**
  78531. * options to use when constructing this feature
  78532. */
  78533. options?: IWebXRHitTestOptions);
  78534. /**
  78535. * attach this feature
  78536. * Will usually be called by the features manager
  78537. *
  78538. * @returns true if successful.
  78539. */
  78540. attach(): boolean;
  78541. /**
  78542. * detach this feature.
  78543. * Will usually be called by the features manager
  78544. *
  78545. * @returns true if successful.
  78546. */
  78547. detach(): boolean;
  78548. /**
  78549. * Dispose this feature and all of the resources attached
  78550. */
  78551. dispose(): void;
  78552. protected _onXRFrame(frame: XRFrame): void;
  78553. private _processWebXRHitTestResult;
  78554. }
  78555. }
  78556. declare module "babylonjs/XR/features/WebXRAnchorSystem" {
  78557. import { WebXRSessionManager } from "babylonjs/XR/webXRSessionManager";
  78558. import { Observable } from "babylonjs/Misc/observable";
  78559. import { Matrix, Vector3, Quaternion } from "babylonjs/Maths/math.vector";
  78560. import { TransformNode } from "babylonjs/Meshes/transformNode";
  78561. import { WebXRAbstractFeature } from "babylonjs/XR/features/WebXRAbstractFeature";
  78562. import { IWebXRHitResult } from "babylonjs/XR/features/WebXRHitTest";
  78563. /**
  78564. * Configuration options of the anchor system
  78565. */
  78566. export interface IWebXRAnchorSystemOptions {
  78567. /**
  78568. * a node that will be used to convert local to world coordinates
  78569. */
  78570. worldParentNode?: TransformNode;
  78571. /**
  78572. * If set to true a reference of the created anchors will be kept until the next session starts
  78573. * If not defined, anchors will be removed from the array when the feature is detached or the session ended.
  78574. */
  78575. doNotRemoveAnchorsOnSessionEnded?: boolean;
  78576. }
  78577. /**
  78578. * A babylon container for an XR Anchor
  78579. */
  78580. export interface IWebXRAnchor {
  78581. /**
  78582. * A babylon-assigned ID for this anchor
  78583. */
  78584. id: number;
  78585. /**
  78586. * Transformation matrix to apply to an object attached to this anchor
  78587. */
  78588. transformationMatrix: Matrix;
  78589. /**
  78590. * The native anchor object
  78591. */
  78592. xrAnchor: XRAnchor;
  78593. /**
  78594. * if defined, this object will be constantly updated by the anchor's position and rotation
  78595. */
  78596. attachedNode?: TransformNode;
  78597. }
  78598. /**
  78599. * An implementation of the anchor system for WebXR.
  78600. * For further information see https://github.com/immersive-web/anchors/
  78601. */
  78602. export class WebXRAnchorSystem extends WebXRAbstractFeature {
  78603. private _options;
  78604. private _lastFrameDetected;
  78605. private _trackedAnchors;
  78606. private _referenceSpaceForFrameAnchors;
  78607. private _futureAnchors;
  78608. /**
  78609. * The module's name
  78610. */
  78611. static readonly Name: string;
  78612. /**
  78613. * The (Babylon) version of this module.
  78614. * This is an integer representing the implementation version.
  78615. * This number does not correspond to the WebXR specs version
  78616. */
  78617. static readonly Version: number;
  78618. /**
  78619. * Observers registered here will be executed when a new anchor was added to the session
  78620. */
  78621. onAnchorAddedObservable: Observable<IWebXRAnchor>;
  78622. /**
  78623. * Observers registered here will be executed when an anchor was removed from the session
  78624. */
  78625. onAnchorRemovedObservable: Observable<IWebXRAnchor>;
  78626. /**
  78627. * Observers registered here will be executed when an existing anchor updates
  78628. * This can execute N times every frame
  78629. */
  78630. onAnchorUpdatedObservable: Observable<IWebXRAnchor>;
  78631. /**
  78632. * Set the reference space to use for anchor creation, when not using a hit test.
  78633. * Will default to the session's reference space if not defined
  78634. */
  78635. set referenceSpaceForFrameAnchors(referenceSpace: XRReferenceSpace);
  78636. /**
  78637. * constructs a new anchor system
  78638. * @param _xrSessionManager an instance of WebXRSessionManager
  78639. * @param _options configuration object for this feature
  78640. */
  78641. constructor(_xrSessionManager: WebXRSessionManager, _options?: IWebXRAnchorSystemOptions);
  78642. private _tmpVector;
  78643. private _tmpQuaternion;
  78644. private _populateTmpTransformation;
  78645. /**
  78646. * Create a new anchor point using a hit test result at a specific point in the scene
  78647. * An anchor is tracked only after it is added to the trackerAnchors in xrFrame. The promise returned here does not yet guaranty that.
  78648. * Use onAnchorAddedObservable to get newly added anchors if you require tracking guaranty.
  78649. *
  78650. * @param hitTestResult The hit test result to use for this anchor creation
  78651. * @param position an optional position offset for this anchor
  78652. * @param rotationQuaternion an optional rotation offset for this anchor
  78653. * @returns A promise that fulfills when the XR anchor was registered in the system (but not necessarily added to the tracked anchors)
  78654. */
  78655. addAnchorPointUsingHitTestResultAsync(hitTestResult: IWebXRHitResult, position?: Vector3, rotationQuaternion?: Quaternion): Promise<XRAnchor>;
  78656. /**
  78657. * Add a new anchor at a specific position and rotation
  78658. * This function will add a new anchor per default in the next available frame. Unless forced, the createAnchor function
  78659. * will be called in the next xrFrame loop to make sure that the anchor can be created correctly.
  78660. * An anchor is tracked only after it is added to the trackerAnchors in xrFrame. The promise returned here does not yet guaranty that.
  78661. * Use onAnchorAddedObservable to get newly added anchors if you require tracking guaranty.
  78662. *
  78663. * @param position the position in which to add an anchor
  78664. * @param rotationQuaternion an optional rotation for the anchor transformation
  78665. * @param forceCreateInCurrentFrame force the creation of this anchor in the current frame. Must be called inside xrFrame loop!
  78666. * @returns A promise that fulfills when the XR anchor was registered in the system (but not necessarily added to the tracked anchors)
  78667. */
  78668. addAnchorAtPositionAndRotationAsync(position: Vector3, rotationQuaternion?: Quaternion, forceCreateInCurrentFrame?: boolean): Promise<XRAnchor>;
  78669. /**
  78670. * detach this feature.
  78671. * Will usually be called by the features manager
  78672. *
  78673. * @returns true if successful.
  78674. */
  78675. detach(): boolean;
  78676. /**
  78677. * Dispose this feature and all of the resources attached
  78678. */
  78679. dispose(): void;
  78680. protected _onXRFrame(frame: XRFrame): void;
  78681. /**
  78682. * avoiding using Array.find for global support.
  78683. * @param xrAnchor the plane to find in the array
  78684. */
  78685. private _findIndexInAnchorArray;
  78686. private _updateAnchorWithXRFrame;
  78687. private _createAnchorAtTransformation;
  78688. }
  78689. }
  78690. declare module "babylonjs/XR/features/WebXRPlaneDetector" {
  78691. import { TransformNode } from "babylonjs/Meshes/transformNode";
  78692. import { WebXRSessionManager } from "babylonjs/XR/webXRSessionManager";
  78693. import { Observable } from "babylonjs/Misc/observable";
  78694. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  78695. import { WebXRAbstractFeature } from "babylonjs/XR/features/WebXRAbstractFeature";
  78696. /**
  78697. * Options used in the plane detector module
  78698. */
  78699. export interface IWebXRPlaneDetectorOptions {
  78700. /**
  78701. * The node to use to transform the local results to world coordinates
  78702. */
  78703. worldParentNode?: TransformNode;
  78704. /**
  78705. * If set to true a reference of the created planes will be kept until the next session starts
  78706. * If not defined, planes will be removed from the array when the feature is detached or the session ended.
  78707. */
  78708. doNotRemovePlanesOnSessionEnded?: boolean;
  78709. }
  78710. /**
  78711. * A babylon interface for a WebXR plane.
  78712. * A Plane is actually a polygon, built from N points in space
  78713. *
  78714. * Supported in chrome 79, not supported in canary 81 ATM
  78715. */
  78716. export interface IWebXRPlane {
  78717. /**
  78718. * a babylon-assigned ID for this polygon
  78719. */
  78720. id: number;
  78721. /**
  78722. * an array of vector3 points in babylon space. right/left hand system is taken into account.
  78723. */
  78724. polygonDefinition: Array<Vector3>;
  78725. /**
  78726. * A transformation matrix to apply on the mesh that will be built using the polygonDefinition
  78727. * Local vs. World are decided if worldParentNode was provided or not in the options when constructing the module
  78728. */
  78729. transformationMatrix: Matrix;
  78730. /**
  78731. * the native xr-plane object
  78732. */
  78733. xrPlane: XRPlane;
  78734. }
  78735. /**
  78736. * The plane detector is used to detect planes in the real world when in AR
  78737. * For more information see https://github.com/immersive-web/real-world-geometry/
  78738. */
  78739. export class WebXRPlaneDetector extends WebXRAbstractFeature {
  78740. private _options;
  78741. private _detectedPlanes;
  78742. private _enabled;
  78743. private _lastFrameDetected;
  78744. /**
  78745. * The module's name
  78746. */
  78747. static readonly Name: string;
  78748. /**
  78749. * The (Babylon) version of this module.
  78750. * This is an integer representing the implementation version.
  78751. * This number does not correspond to the WebXR specs version
  78752. */
  78753. static readonly Version: number;
  78754. /**
  78755. * Observers registered here will be executed when a new plane was added to the session
  78756. */
  78757. onPlaneAddedObservable: Observable<IWebXRPlane>;
  78758. /**
  78759. * Observers registered here will be executed when a plane is no longer detected in the session
  78760. */
  78761. onPlaneRemovedObservable: Observable<IWebXRPlane>;
  78762. /**
  78763. * Observers registered here will be executed when an existing plane updates (for example - expanded)
  78764. * This can execute N times every frame
  78765. */
  78766. onPlaneUpdatedObservable: Observable<IWebXRPlane>;
  78767. /**
  78768. * construct a new Plane Detector
  78769. * @param _xrSessionManager an instance of xr Session manager
  78770. * @param _options configuration to use when constructing this feature
  78771. */
  78772. constructor(_xrSessionManager: WebXRSessionManager, _options?: IWebXRPlaneDetectorOptions);
  78773. /**
  78774. * detach this feature.
  78775. * Will usually be called by the features manager
  78776. *
  78777. * @returns true if successful.
  78778. */
  78779. detach(): boolean;
  78780. /**
  78781. * Dispose this feature and all of the resources attached
  78782. */
  78783. dispose(): void;
  78784. protected _onXRFrame(frame: XRFrame): void;
  78785. private _init;
  78786. private _updatePlaneWithXRPlane;
  78787. /**
  78788. * avoiding using Array.find for global support.
  78789. * @param xrPlane the plane to find in the array
  78790. */
  78791. private findIndexInPlaneArray;
  78792. }
  78793. }
  78794. declare module "babylonjs/XR/features/WebXRBackgroundRemover" {
  78795. import { WebXRSessionManager } from "babylonjs/XR/webXRSessionManager";
  78796. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  78797. import { Observable } from "babylonjs/Misc/observable";
  78798. import { WebXRAbstractFeature } from "babylonjs/XR/features/WebXRAbstractFeature";
  78799. /**
  78800. * Options interface for the background remover plugin
  78801. */
  78802. export interface IWebXRBackgroundRemoverOptions {
  78803. /**
  78804. * Further background meshes to disable when entering AR
  78805. */
  78806. backgroundMeshes?: AbstractMesh[];
  78807. /**
  78808. * flags to configure the removal of the environment helper.
  78809. * If not set, the entire background will be removed. If set, flags should be set as well.
  78810. */
  78811. environmentHelperRemovalFlags?: {
  78812. /**
  78813. * Should the skybox be removed (default false)
  78814. */
  78815. skyBox?: boolean;
  78816. /**
  78817. * Should the ground be removed (default false)
  78818. */
  78819. ground?: boolean;
  78820. };
  78821. /**
  78822. * don't disable the environment helper
  78823. */
  78824. ignoreEnvironmentHelper?: boolean;
  78825. }
  78826. /**
  78827. * A module that will automatically disable background meshes when entering AR and will enable them when leaving AR.
  78828. */
  78829. export class WebXRBackgroundRemover extends WebXRAbstractFeature {
  78830. /**
  78831. * read-only options to be used in this module
  78832. */
  78833. readonly options: IWebXRBackgroundRemoverOptions;
  78834. /**
  78835. * The module's name
  78836. */
  78837. static readonly Name: string;
  78838. /**
  78839. * The (Babylon) version of this module.
  78840. * This is an integer representing the implementation version.
  78841. * This number does not correspond to the WebXR specs version
  78842. */
  78843. static readonly Version: number;
  78844. /**
  78845. * registered observers will be triggered when the background state changes
  78846. */
  78847. onBackgroundStateChangedObservable: Observable<boolean>;
  78848. /**
  78849. * constructs a new background remover module
  78850. * @param _xrSessionManager the session manager for this module
  78851. * @param options read-only options to be used in this module
  78852. */
  78853. constructor(_xrSessionManager: WebXRSessionManager,
  78854. /**
  78855. * read-only options to be used in this module
  78856. */
  78857. options?: IWebXRBackgroundRemoverOptions);
  78858. /**
  78859. * attach this feature
  78860. * Will usually be called by the features manager
  78861. *
  78862. * @returns true if successful.
  78863. */
  78864. attach(): boolean;
  78865. /**
  78866. * detach this feature.
  78867. * Will usually be called by the features manager
  78868. *
  78869. * @returns true if successful.
  78870. */
  78871. detach(): boolean;
  78872. /**
  78873. * Dispose this feature and all of the resources attached
  78874. */
  78875. dispose(): void;
  78876. protected _onXRFrame(_xrFrame: XRFrame): void;
  78877. private _setBackgroundState;
  78878. }
  78879. }
  78880. declare module "babylonjs/XR/features/WebXRControllerPhysics" {
  78881. import { WebXRAbstractFeature } from "babylonjs/XR/features/WebXRAbstractFeature";
  78882. import { WebXRInputSource } from "babylonjs/XR/webXRInputSource";
  78883. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  78884. import { WebXRInput } from "babylonjs/XR/webXRInput";
  78885. import { WebXRSessionManager } from "babylonjs/XR/webXRSessionManager";
  78886. import { Nullable } from "babylonjs/types";
  78887. /**
  78888. * Options for the controller physics feature
  78889. */
  78890. export class IWebXRControllerPhysicsOptions {
  78891. /**
  78892. * Should the headset get its own impostor
  78893. */
  78894. enableHeadsetImpostor?: boolean;
  78895. /**
  78896. * Optional parameters for the headset impostor
  78897. */
  78898. headsetImpostorParams?: {
  78899. /**
  78900. * The type of impostor to create. Default is sphere
  78901. */
  78902. impostorType: number;
  78903. /**
  78904. * the size of the impostor. Defaults to 10cm
  78905. */
  78906. impostorSize?: number | {
  78907. width: number;
  78908. height: number;
  78909. depth: number;
  78910. };
  78911. /**
  78912. * Friction definitions
  78913. */
  78914. friction?: number;
  78915. /**
  78916. * Restitution
  78917. */
  78918. restitution?: number;
  78919. };
  78920. /**
  78921. * The physics properties of the future impostors
  78922. */
  78923. physicsProperties?: {
  78924. /**
  78925. * If set to true, a mesh impostor will be created when the controller mesh was loaded
  78926. * Note that this requires a physics engine that supports mesh impostors!
  78927. */
  78928. useControllerMesh?: boolean;
  78929. /**
  78930. * The type of impostor to create. Default is sphere
  78931. */
  78932. impostorType?: number;
  78933. /**
  78934. * the size of the impostor. Defaults to 10cm
  78935. */
  78936. impostorSize?: number | {
  78937. width: number;
  78938. height: number;
  78939. depth: number;
  78940. };
  78941. /**
  78942. * Friction definitions
  78943. */
  78944. friction?: number;
  78945. /**
  78946. * Restitution
  78947. */
  78948. restitution?: number;
  78949. };
  78950. /**
  78951. * the xr input to use with this pointer selection
  78952. */
  78953. xrInput: WebXRInput;
  78954. }
  78955. /**
  78956. * Add physics impostor to your webxr controllers,
  78957. * including naive calculation of their linear and angular velocity
  78958. */
  78959. export class WebXRControllerPhysics extends WebXRAbstractFeature {
  78960. private readonly _options;
  78961. private _attachController;
  78962. private _controllers;
  78963. private _debugMode;
  78964. private _delta;
  78965. private _headsetImpostor?;
  78966. private _headsetMesh?;
  78967. private _lastTimestamp;
  78968. private _tmpQuaternion;
  78969. private _tmpVector;
  78970. /**
  78971. * The module's name
  78972. */
  78973. static readonly Name: string;
  78974. /**
  78975. * The (Babylon) version of this module.
  78976. * This is an integer representing the implementation version.
  78977. * This number does not correspond to the webxr specs version
  78978. */
  78979. static readonly Version: number;
  78980. /**
  78981. * Construct a new Controller Physics Feature
  78982. * @param _xrSessionManager the corresponding xr session manager
  78983. * @param _options options to create this feature with
  78984. */
  78985. constructor(_xrSessionManager: WebXRSessionManager, _options: IWebXRControllerPhysicsOptions);
  78986. /**
  78987. * @hidden
  78988. * enable debugging - will show console outputs and the impostor mesh
  78989. */
  78990. _enablePhysicsDebug(): void;
  78991. /**
  78992. * Manually add a controller (if no xrInput was provided or physics engine was not enabled)
  78993. * @param xrController the controller to add
  78994. */
  78995. addController(xrController: WebXRInputSource): void;
  78996. /**
  78997. * attach this feature
  78998. * Will usually be called by the features manager
  78999. *
  79000. * @returns true if successful.
  79001. */
  79002. attach(): boolean;
  79003. /**
  79004. * detach this feature.
  79005. * Will usually be called by the features manager
  79006. *
  79007. * @returns true if successful.
  79008. */
  79009. detach(): boolean;
  79010. /**
  79011. * Get the headset impostor, if enabled
  79012. * @returns the impostor
  79013. */
  79014. getHeadsetImpostor(): PhysicsImpostor | undefined;
  79015. /**
  79016. * Get the physics impostor of a specific controller.
  79017. * The impostor is not attached to a mesh because a mesh for each controller is not obligatory
  79018. * @param controller the controller or the controller id of which to get the impostor
  79019. * @returns the impostor or null
  79020. */
  79021. getImpostorForController(controller: WebXRInputSource | string): Nullable<PhysicsImpostor>;
  79022. /**
  79023. * Update the physics properties provided in the constructor
  79024. * @param newProperties the new properties object
  79025. */
  79026. setPhysicsProperties(newProperties: {
  79027. impostorType?: number;
  79028. impostorSize?: number | {
  79029. width: number;
  79030. height: number;
  79031. depth: number;
  79032. };
  79033. friction?: number;
  79034. restitution?: number;
  79035. }): void;
  79036. protected _onXRFrame(_xrFrame: any): void;
  79037. private _detachController;
  79038. }
  79039. }
  79040. declare module "babylonjs/XR/features/WebXRFeaturePointSystem" {
  79041. import { WebXRSessionManager } from "babylonjs/XR/webXRSessionManager";
  79042. import { Observable } from "babylonjs/Misc/observable";
  79043. import { Vector3 } from "babylonjs/Maths/math.vector";
  79044. import { WebXRAbstractFeature } from "babylonjs/XR/features/WebXRAbstractFeature";
  79045. /**
  79046. * A babylon interface for a "WebXR" feature point.
  79047. * Represents the position and confidence value of a given feature point.
  79048. */
  79049. export interface IWebXRFeaturePoint {
  79050. /**
  79051. * Represents the position of the feature point in world space.
  79052. */
  79053. position: Vector3;
  79054. /**
  79055. * Represents the confidence value of the feature point in world space. 0 being least confident, and 1 being most confident.
  79056. */
  79057. confidenceValue: number;
  79058. }
  79059. /**
  79060. * The feature point system is used to detect feature points from real world geometry.
  79061. * This feature is currently experimental and only supported on BabylonNative, and should not be used in the browser.
  79062. * The newly introduced API can be seen in webxr.nativeextensions.d.ts and described in FeaturePoints.md.
  79063. */
  79064. export class WebXRFeaturePointSystem extends WebXRAbstractFeature {
  79065. private _enabled;
  79066. private _featurePointCloud;
  79067. /**
  79068. * The module's name
  79069. */
  79070. static readonly Name: string;
  79071. /**
  79072. * The (Babylon) version of this module.
  79073. * This is an integer representing the implementation version.
  79074. * This number does not correspond to the WebXR specs version
  79075. */
  79076. static readonly Version: number;
  79077. /**
  79078. * Observers registered here will be executed whenever new feature points are added (on XRFrame while the session is tracking).
  79079. * Will notify the observers about which feature points have been added.
  79080. */
  79081. readonly onFeaturePointsAddedObservable: Observable<number[]>;
  79082. /**
  79083. * Observers registered here will be executed whenever a feature point has been updated (on XRFrame while the session is tracking).
  79084. * Will notify the observers about which feature points have been updated.
  79085. */
  79086. readonly onFeaturePointsUpdatedObservable: Observable<number[]>;
  79087. /**
  79088. * The current feature point cloud maintained across frames.
  79089. */
  79090. get featurePointCloud(): Array<IWebXRFeaturePoint>;
  79091. /**
  79092. * construct the feature point system
  79093. * @param _xrSessionManager an instance of xr Session manager
  79094. */
  79095. constructor(_xrSessionManager: WebXRSessionManager);
  79096. /**
  79097. * Detach this feature.
  79098. * Will usually be called by the features manager
  79099. *
  79100. * @returns true if successful.
  79101. */
  79102. detach(): boolean;
  79103. /**
  79104. * Dispose this feature and all of the resources attached
  79105. */
  79106. dispose(): void;
  79107. /**
  79108. * On receiving a new XR frame if this feature is attached notify observers new feature point data is available.
  79109. */
  79110. protected _onXRFrame(frame: XRFrame): void;
  79111. /**
  79112. * Initializes the feature. If the feature point feature is not available for this environment do not mark the feature as enabled.
  79113. */
  79114. private _init;
  79115. }
  79116. }
  79117. declare module "babylonjs/XR/features/WebXRHandTracking" {
  79118. import { WebXRAbstractFeature } from "babylonjs/XR/features/WebXRAbstractFeature";
  79119. import { WebXRSessionManager } from "babylonjs/XR/webXRSessionManager";
  79120. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  79121. import { Mesh } from "babylonjs/Meshes/mesh";
  79122. import { WebXRInput } from "babylonjs/XR/webXRInput";
  79123. import { WebXRInputSource } from "babylonjs/XR/webXRInputSource";
  79124. import { Nullable } from "babylonjs/types";
  79125. import { IDisposable } from "babylonjs/scene";
  79126. import { Observable } from "babylonjs/Misc/observable";
  79127. /**
  79128. * Configuration interface for the hand tracking feature
  79129. */
  79130. export interface IWebXRHandTrackingOptions {
  79131. /**
  79132. * The xrInput that will be used as source for new hands
  79133. */
  79134. xrInput: WebXRInput;
  79135. /**
  79136. * Configuration object for the joint meshes
  79137. */
  79138. jointMeshes?: {
  79139. /**
  79140. * Should the meshes created be invisible (defaults to false)
  79141. */
  79142. invisible?: boolean;
  79143. /**
  79144. * A source mesh to be used to create instances. Defaults to a sphere.
  79145. * This mesh will be the source for all other (25) meshes.
  79146. * It should have the general size of a single unit, as the instances will be scaled according to the provided radius
  79147. */
  79148. sourceMesh?: Mesh;
  79149. /**
  79150. * Should the source mesh stay visible. Defaults to false
  79151. */
  79152. keepOriginalVisible?: boolean;
  79153. /**
  79154. * Scale factor for all instances (defaults to 2)
  79155. */
  79156. scaleFactor?: number;
  79157. /**
  79158. * Should each instance have its own physics impostor
  79159. */
  79160. enablePhysics?: boolean;
  79161. /**
  79162. * If enabled, override default physics properties
  79163. */
  79164. physicsProps?: {
  79165. friction?: number;
  79166. restitution?: number;
  79167. impostorType?: number;
  79168. };
  79169. /**
  79170. * For future use - a single hand-mesh that will be updated according to the XRHand data provided
  79171. */
  79172. handMesh?: AbstractMesh;
  79173. };
  79174. }
  79175. /**
  79176. * Parts of the hands divided to writs and finger names
  79177. */
  79178. export const enum HandPart {
  79179. /**
  79180. * HandPart - Wrist
  79181. */
  79182. WRIST = "wrist",
  79183. /**
  79184. * HandPart - The THumb
  79185. */
  79186. THUMB = "thumb",
  79187. /**
  79188. * HandPart - Index finger
  79189. */
  79190. INDEX = "index",
  79191. /**
  79192. * HandPart - Middle finger
  79193. */
  79194. MIDDLE = "middle",
  79195. /**
  79196. * HandPart - Ring finger
  79197. */
  79198. RING = "ring",
  79199. /**
  79200. * HandPart - Little finger
  79201. */
  79202. LITTLE = "little"
  79203. }
  79204. /**
  79205. * Representing a single hand (with its corresponding native XRHand object)
  79206. */
  79207. export class WebXRHand implements IDisposable {
  79208. /** the controller to which the hand correlates */
  79209. readonly xrController: WebXRInputSource;
  79210. /** the meshes to be used to track the hand joints */
  79211. readonly trackedMeshes: AbstractMesh[];
  79212. /**
  79213. * Hand-parts definition (key is HandPart)
  79214. */
  79215. static HandPartsDefinition: {
  79216. [key: string]: number[];
  79217. };
  79218. /**
  79219. * Populate the HandPartsDefinition object.
  79220. * This is called as a side effect since certain browsers don't have XRHand defined.
  79221. */
  79222. static _PopulateHandPartsDefinition(): void;
  79223. /**
  79224. * Construct a new hand object
  79225. * @param xrController the controller to which the hand correlates
  79226. * @param trackedMeshes the meshes to be used to track the hand joints
  79227. */
  79228. constructor(
  79229. /** the controller to which the hand correlates */
  79230. xrController: WebXRInputSource,
  79231. /** the meshes to be used to track the hand joints */
  79232. trackedMeshes: AbstractMesh[]);
  79233. /**
  79234. * Update this hand from the latest xr frame
  79235. * @param xrFrame xrFrame to update from
  79236. * @param referenceSpace The current viewer reference space
  79237. * @param scaleFactor optional scale factor for the meshes
  79238. */
  79239. updateFromXRFrame(xrFrame: XRFrame, referenceSpace: XRReferenceSpace, scaleFactor?: number): void;
  79240. /**
  79241. * Get meshes of part of the hand
  79242. * @param part the part of hand to get
  79243. * @returns An array of meshes that correlate to the hand part requested
  79244. */
  79245. getHandPartMeshes(part: HandPart): AbstractMesh[];
  79246. /**
  79247. * Dispose this Hand object
  79248. */
  79249. dispose(): void;
  79250. }
  79251. /**
  79252. * WebXR Hand Joint tracking feature, available for selected browsers and devices
  79253. */
  79254. export class WebXRHandTracking extends WebXRAbstractFeature {
  79255. /**
  79256. * options to use when constructing this feature
  79257. */
  79258. readonly options: IWebXRHandTrackingOptions;
  79259. private static _idCounter;
  79260. /**
  79261. * The module's name
  79262. */
  79263. static readonly Name: string;
  79264. /**
  79265. * The (Babylon) version of this module.
  79266. * This is an integer representing the implementation version.
  79267. * This number does not correspond to the WebXR specs version
  79268. */
  79269. static readonly Version: number;
  79270. /**
  79271. * This observable will notify registered observers when a new hand object was added and initialized
  79272. */
  79273. onHandAddedObservable: Observable<WebXRHand>;
  79274. /**
  79275. * This observable will notify its observers right before the hand object is disposed
  79276. */
  79277. onHandRemovedObservable: Observable<WebXRHand>;
  79278. private _hands;
  79279. /**
  79280. * Creates a new instance of the hit test feature
  79281. * @param _xrSessionManager an instance of WebXRSessionManager
  79282. * @param options options to use when constructing this feature
  79283. */
  79284. constructor(_xrSessionManager: WebXRSessionManager,
  79285. /**
  79286. * options to use when constructing this feature
  79287. */
  79288. options: IWebXRHandTrackingOptions);
  79289. /**
  79290. * Check if the needed objects are defined.
  79291. * This does not mean that the feature is enabled, but that the objects needed are well defined.
  79292. */
  79293. isCompatible(): boolean;
  79294. /**
  79295. * attach this feature
  79296. * Will usually be called by the features manager
  79297. *
  79298. * @returns true if successful.
  79299. */
  79300. attach(): boolean;
  79301. /**
  79302. * detach this feature.
  79303. * Will usually be called by the features manager
  79304. *
  79305. * @returns true if successful.
  79306. */
  79307. detach(): boolean;
  79308. /**
  79309. * Dispose this feature and all of the resources attached
  79310. */
  79311. dispose(): void;
  79312. /**
  79313. * Get the hand object according to the controller id
  79314. * @param controllerId the controller id to which we want to get the hand
  79315. * @returns null if not found or the WebXRHand object if found
  79316. */
  79317. getHandByControllerId(controllerId: string): Nullable<WebXRHand>;
  79318. /**
  79319. * Get a hand object according to the requested handedness
  79320. * @param handedness the handedness to request
  79321. * @returns null if not found or the WebXRHand object if found
  79322. */
  79323. getHandByHandedness(handedness: XRHandedness): Nullable<WebXRHand>;
  79324. protected _onXRFrame(_xrFrame: XRFrame): void;
  79325. private _attachHand;
  79326. private _detachHand;
  79327. }
  79328. }
  79329. declare module "babylonjs/XR/features/index" {
  79330. export * from "babylonjs/XR/features/WebXRHitTestLegacy";
  79331. export * from "babylonjs/XR/features/WebXRAnchorSystem";
  79332. export * from "babylonjs/XR/features/WebXRPlaneDetector";
  79333. export * from "babylonjs/XR/features/WebXRBackgroundRemover";
  79334. export * from "babylonjs/XR/features/WebXRControllerTeleportation";
  79335. export * from "babylonjs/XR/features/WebXRControllerPointerSelection";
  79336. export * from "babylonjs/XR/features/WebXRControllerPhysics";
  79337. export * from "babylonjs/XR/features/WebXRHitTest";
  79338. export * from "babylonjs/XR/features/WebXRFeaturePointSystem";
  79339. export * from "babylonjs/XR/features/WebXRHandTracking";
  79340. }
  79341. declare module "babylonjs/XR/motionController/webXRMicrosoftMixedRealityController" {
  79342. import { WebXRAbstractMotionController, IMinimalMotionControllerObject, MotionControllerHandedness } from "babylonjs/XR/motionController/webXRAbstractMotionController";
  79343. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  79344. import { Scene } from "babylonjs/scene";
  79345. /**
  79346. * The motion controller class for all microsoft mixed reality controllers
  79347. */
  79348. export class WebXRMicrosoftMixedRealityController extends WebXRAbstractMotionController {
  79349. protected readonly _mapping: {
  79350. defaultButton: {
  79351. valueNodeName: string;
  79352. unpressedNodeName: string;
  79353. pressedNodeName: string;
  79354. };
  79355. defaultAxis: {
  79356. valueNodeName: string;
  79357. minNodeName: string;
  79358. maxNodeName: string;
  79359. };
  79360. buttons: {
  79361. "xr-standard-trigger": {
  79362. rootNodeName: string;
  79363. componentProperty: string;
  79364. states: string[];
  79365. };
  79366. "xr-standard-squeeze": {
  79367. rootNodeName: string;
  79368. componentProperty: string;
  79369. states: string[];
  79370. };
  79371. "xr-standard-touchpad": {
  79372. rootNodeName: string;
  79373. labelAnchorNodeName: string;
  79374. touchPointNodeName: string;
  79375. };
  79376. "xr-standard-thumbstick": {
  79377. rootNodeName: string;
  79378. componentProperty: string;
  79379. states: string[];
  79380. };
  79381. };
  79382. axes: {
  79383. "xr-standard-touchpad": {
  79384. "x-axis": {
  79385. rootNodeName: string;
  79386. };
  79387. "y-axis": {
  79388. rootNodeName: string;
  79389. };
  79390. };
  79391. "xr-standard-thumbstick": {
  79392. "x-axis": {
  79393. rootNodeName: string;
  79394. };
  79395. "y-axis": {
  79396. rootNodeName: string;
  79397. };
  79398. };
  79399. };
  79400. };
  79401. /**
  79402. * The base url used to load the left and right controller models
  79403. */
  79404. static MODEL_BASE_URL: string;
  79405. /**
  79406. * The name of the left controller model file
  79407. */
  79408. static MODEL_LEFT_FILENAME: string;
  79409. /**
  79410. * The name of the right controller model file
  79411. */
  79412. static MODEL_RIGHT_FILENAME: string;
  79413. profileId: string;
  79414. constructor(scene: Scene, gamepadObject: IMinimalMotionControllerObject, handedness: MotionControllerHandedness);
  79415. protected _getFilenameAndPath(): {
  79416. filename: string;
  79417. path: string;
  79418. };
  79419. protected _getModelLoadingConstraints(): boolean;
  79420. protected _processLoadedModel(_meshes: AbstractMesh[]): void;
  79421. protected _setRootMesh(meshes: AbstractMesh[]): void;
  79422. protected _updateModel(): void;
  79423. }
  79424. }
  79425. declare module "babylonjs/XR/motionController/webXROculusTouchMotionController" {
  79426. import { WebXRAbstractMotionController, IMinimalMotionControllerObject, MotionControllerHandedness } from "babylonjs/XR/motionController/webXRAbstractMotionController";
  79427. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  79428. import { Scene } from "babylonjs/scene";
  79429. /**
  79430. * The motion controller class for oculus touch (quest, rift).
  79431. * This class supports legacy mapping as well the standard xr mapping
  79432. */
  79433. export class WebXROculusTouchMotionController extends WebXRAbstractMotionController {
  79434. private _forceLegacyControllers;
  79435. private _modelRootNode;
  79436. /**
  79437. * The base url used to load the left and right controller models
  79438. */
  79439. static MODEL_BASE_URL: string;
  79440. /**
  79441. * The name of the left controller model file
  79442. */
  79443. static MODEL_LEFT_FILENAME: string;
  79444. /**
  79445. * The name of the right controller model file
  79446. */
  79447. static MODEL_RIGHT_FILENAME: string;
  79448. /**
  79449. * Base Url for the Quest controller model.
  79450. */
  79451. static QUEST_MODEL_BASE_URL: string;
  79452. profileId: string;
  79453. constructor(scene: Scene, gamepadObject: IMinimalMotionControllerObject, handedness: MotionControllerHandedness, legacyMapping?: boolean, _forceLegacyControllers?: boolean);
  79454. protected _getFilenameAndPath(): {
  79455. filename: string;
  79456. path: string;
  79457. };
  79458. protected _getModelLoadingConstraints(): boolean;
  79459. protected _processLoadedModel(_meshes: AbstractMesh[]): void;
  79460. protected _setRootMesh(meshes: AbstractMesh[]): void;
  79461. protected _updateModel(): void;
  79462. /**
  79463. * Is this the new type of oculus touch. At the moment both have the same profile and it is impossible to differentiate
  79464. * between the touch and touch 2.
  79465. */
  79466. private _isQuest;
  79467. }
  79468. }
  79469. declare module "babylonjs/XR/motionController/webXRHTCViveMotionController" {
  79470. import { IMinimalMotionControllerObject, MotionControllerHandedness, WebXRAbstractMotionController } from "babylonjs/XR/motionController/webXRAbstractMotionController";
  79471. import { Scene } from "babylonjs/scene";
  79472. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  79473. /**
  79474. * The motion controller class for the standard HTC-Vive controllers
  79475. */
  79476. export class WebXRHTCViveMotionController extends WebXRAbstractMotionController {
  79477. private _modelRootNode;
  79478. /**
  79479. * The base url used to load the left and right controller models
  79480. */
  79481. static MODEL_BASE_URL: string;
  79482. /**
  79483. * File name for the controller model.
  79484. */
  79485. static MODEL_FILENAME: string;
  79486. profileId: string;
  79487. /**
  79488. * Create a new Vive motion controller object
  79489. * @param scene the scene to use to create this controller
  79490. * @param gamepadObject the corresponding gamepad object
  79491. * @param handedness the handedness of the controller
  79492. */
  79493. constructor(scene: Scene, gamepadObject: IMinimalMotionControllerObject, handedness: MotionControllerHandedness);
  79494. protected _getFilenameAndPath(): {
  79495. filename: string;
  79496. path: string;
  79497. };
  79498. protected _getModelLoadingConstraints(): boolean;
  79499. protected _processLoadedModel(_meshes: AbstractMesh[]): void;
  79500. protected _setRootMesh(meshes: AbstractMesh[]): void;
  79501. protected _updateModel(): void;
  79502. }
  79503. }
  79504. declare module "babylonjs/XR/motionController/index" {
  79505. export * from "babylonjs/XR/motionController/webXRAbstractMotionController";
  79506. export * from "babylonjs/XR/motionController/webXRControllerComponent";
  79507. export * from "babylonjs/XR/motionController/webXRGenericMotionController";
  79508. export * from "babylonjs/XR/motionController/webXRMicrosoftMixedRealityController";
  79509. export * from "babylonjs/XR/motionController/webXRMotionControllerManager";
  79510. export * from "babylonjs/XR/motionController/webXROculusTouchMotionController";
  79511. export * from "babylonjs/XR/motionController/webXRHTCViveMotionController";
  79512. export * from "babylonjs/XR/motionController/webXRProfiledMotionController";
  79513. }
  79514. declare module "babylonjs/XR/index" {
  79515. export * from "babylonjs/XR/webXRCamera";
  79516. export * from "babylonjs/XR/webXREnterExitUI";
  79517. export * from "babylonjs/XR/webXRExperienceHelper";
  79518. export * from "babylonjs/XR/webXRInput";
  79519. export * from "babylonjs/XR/webXRInputSource";
  79520. export * from "babylonjs/XR/webXRManagedOutputCanvas";
  79521. export * from "babylonjs/XR/webXRTypes";
  79522. export * from "babylonjs/XR/webXRSessionManager";
  79523. export * from "babylonjs/XR/webXRDefaultExperience";
  79524. export * from "babylonjs/XR/webXRFeaturesManager";
  79525. export * from "babylonjs/XR/features/index";
  79526. export * from "babylonjs/XR/motionController/index";
  79527. }
  79528. declare module "babylonjs/index" {
  79529. export * from "babylonjs/abstractScene";
  79530. export * from "babylonjs/Actions/index";
  79531. export * from "babylonjs/Animations/index";
  79532. export * from "babylonjs/assetContainer";
  79533. export * from "babylonjs/Audio/index";
  79534. export * from "babylonjs/Behaviors/index";
  79535. export * from "babylonjs/Bones/index";
  79536. export * from "babylonjs/Cameras/index";
  79537. export * from "babylonjs/Collisions/index";
  79538. export * from "babylonjs/Culling/index";
  79539. export * from "babylonjs/Debug/index";
  79540. export * from "babylonjs/DeviceInput/index";
  79541. export * from "babylonjs/Engines/index";
  79542. export * from "babylonjs/Events/index";
  79543. export * from "babylonjs/Gamepads/index";
  79544. export * from "babylonjs/Gizmos/index";
  79545. export * from "babylonjs/Helpers/index";
  79546. export * from "babylonjs/Instrumentation/index";
  79547. export * from "babylonjs/Layers/index";
  79548. export * from "babylonjs/LensFlares/index";
  79549. export * from "babylonjs/Lights/index";
  79550. export * from "babylonjs/Loading/index";
  79551. export * from "babylonjs/Materials/index";
  79552. export * from "babylonjs/Maths/index";
  79553. export * from "babylonjs/Meshes/index";
  79554. export * from "babylonjs/Morph/index";
  79555. export * from "babylonjs/Navigation/index";
  79556. export * from "babylonjs/node";
  79557. export * from "babylonjs/Offline/index";
  79558. export * from "babylonjs/Particles/index";
  79559. export * from "babylonjs/Physics/index";
  79560. export * from "babylonjs/PostProcesses/index";
  79561. export * from "babylonjs/Probes/index";
  79562. export * from "babylonjs/Rendering/index";
  79563. export * from "babylonjs/scene";
  79564. export * from "babylonjs/sceneComponent";
  79565. export * from "babylonjs/Sprites/index";
  79566. export * from "babylonjs/States/index";
  79567. export * from "babylonjs/Misc/index";
  79568. export * from "babylonjs/XR/index";
  79569. export * from "babylonjs/types";
  79570. }
  79571. declare module "babylonjs/Animations/pathCursor" {
  79572. import { Vector3 } from "babylonjs/Maths/math.vector";
  79573. import { Path2 } from "babylonjs/Maths/math.path";
  79574. /**
  79575. * A cursor which tracks a point on a path
  79576. */
  79577. export class PathCursor {
  79578. private path;
  79579. /**
  79580. * Stores path cursor callbacks for when an onchange event is triggered
  79581. */
  79582. private _onchange;
  79583. /**
  79584. * The value of the path cursor
  79585. */
  79586. value: number;
  79587. /**
  79588. * The animation array of the path cursor
  79589. */
  79590. animations: Animation[];
  79591. /**
  79592. * Initializes the path cursor
  79593. * @param path The path to track
  79594. */
  79595. constructor(path: Path2);
  79596. /**
  79597. * Gets the cursor point on the path
  79598. * @returns A point on the path cursor at the cursor location
  79599. */
  79600. getPoint(): Vector3;
  79601. /**
  79602. * Moves the cursor ahead by the step amount
  79603. * @param step The amount to move the cursor forward
  79604. * @returns This path cursor
  79605. */
  79606. moveAhead(step?: number): PathCursor;
  79607. /**
  79608. * Moves the cursor behind by the step amount
  79609. * @param step The amount to move the cursor back
  79610. * @returns This path cursor
  79611. */
  79612. moveBack(step?: number): PathCursor;
  79613. /**
  79614. * Moves the cursor by the step amount
  79615. * If the step amount is greater than one, an exception is thrown
  79616. * @param step The amount to move the cursor
  79617. * @returns This path cursor
  79618. */
  79619. move(step: number): PathCursor;
  79620. /**
  79621. * Ensures that the value is limited between zero and one
  79622. * @returns This path cursor
  79623. */
  79624. private ensureLimits;
  79625. /**
  79626. * Runs onchange callbacks on change (used by the animation engine)
  79627. * @returns This path cursor
  79628. */
  79629. private raiseOnChange;
  79630. /**
  79631. * Executes a function on change
  79632. * @param f A path cursor onchange callback
  79633. * @returns This path cursor
  79634. */
  79635. onchange(f: (cursor: PathCursor) => void): PathCursor;
  79636. }
  79637. }
  79638. declare module "babylonjs/Engines/Processors/Expressions/Operators/index" {
  79639. export * from "babylonjs/Engines/Processors/Expressions/Operators/shaderDefineAndOperator";
  79640. export * from "babylonjs/Engines/Processors/Expressions/Operators/shaderDefineArithmeticOperator";
  79641. export * from "babylonjs/Engines/Processors/Expressions/Operators/shaderDefineIsDefinedOperator";
  79642. export * from "babylonjs/Engines/Processors/Expressions/Operators/shaderDefineOrOperator";
  79643. }
  79644. declare module "babylonjs/Engines/Processors/Expressions/index" {
  79645. export * from "babylonjs/Engines/Processors/Expressions/shaderDefineExpression";
  79646. export * from "babylonjs/Engines/Processors/Expressions/Operators/index";
  79647. }
  79648. declare module "babylonjs/Engines/Processors/index" {
  79649. export * from "babylonjs/Engines/Processors/iShaderProcessor";
  79650. export * from "babylonjs/Engines/Processors/Expressions/index";
  79651. export * from "babylonjs/Engines/Processors/shaderCodeConditionNode";
  79652. export * from "babylonjs/Engines/Processors/shaderCodeCursor";
  79653. export * from "babylonjs/Engines/Processors/shaderCodeNode";
  79654. export * from "babylonjs/Engines/Processors/shaderCodeTestNode";
  79655. export * from "babylonjs/Engines/Processors/shaderProcessingOptions";
  79656. export * from "babylonjs/Engines/Processors/shaderProcessor";
  79657. export * from "babylonjs/Engines/Processors/shaderCodeInliner";
  79658. }
  79659. declare module "babylonjs/Legacy/legacy" {
  79660. import * as Babylon from "babylonjs/index";
  79661. export * from "babylonjs/index";
  79662. }
  79663. declare module "babylonjs/Shaders/blur.fragment" {
  79664. /** @hidden */
  79665. export var blurPixelShader: {
  79666. name: string;
  79667. shader: string;
  79668. };
  79669. }
  79670. declare module "babylonjs/Shaders/ShadersInclude/pointCloudVertexDeclaration" {
  79671. /** @hidden */
  79672. export var pointCloudVertexDeclaration: {
  79673. name: string;
  79674. shader: string;
  79675. };
  79676. }
  79677. declare module "babylonjs" {
  79678. export * from "babylonjs/Legacy/legacy";
  79679. }
  79680. declare module BABYLON {
  79681. /** Alias type for value that can be null */
  79682. export type Nullable<T> = T | null;
  79683. /**
  79684. * Alias type for number that are floats
  79685. * @ignorenaming
  79686. */
  79687. export type float = number;
  79688. /**
  79689. * Alias type for number that are doubles.
  79690. * @ignorenaming
  79691. */
  79692. export type double = number;
  79693. /**
  79694. * Alias type for number that are integer
  79695. * @ignorenaming
  79696. */
  79697. export type int = number;
  79698. /** Alias type for number array or Float32Array */
  79699. export type FloatArray = number[] | Float32Array;
  79700. /** Alias type for number array or Float32Array or Int32Array or Uint32Array or Uint16Array */
  79701. export type IndicesArray = number[] | Int32Array | Uint32Array | Uint16Array;
  79702. /**
  79703. * Alias for types that can be used by a Buffer or VertexBuffer.
  79704. */
  79705. export type DataArray = number[] | ArrayBuffer | ArrayBufferView;
  79706. /**
  79707. * Alias type for primitive types
  79708. * @ignorenaming
  79709. */
  79710. type Primitive = undefined | null | boolean | string | number | Function;
  79711. /**
  79712. * Type modifier to make all the properties of an object Readonly
  79713. */
  79714. export type Immutable<T> = T extends Primitive ? T : T extends Array<infer U> ? ReadonlyArray<U> : DeepImmutable<T>;
  79715. /**
  79716. * Type modifier to make all the properties of an object Readonly recursively
  79717. */
  79718. export type DeepImmutable<T> = T extends Primitive ? T : T extends Array<infer U> ? DeepImmutableArray<U> : DeepImmutableObject<T>;
  79719. /**
  79720. * Type modifier to make object properties readonly.
  79721. */
  79722. export type DeepImmutableObject<T> = {
  79723. readonly [K in keyof T]: DeepImmutable<T[K]>;
  79724. };
  79725. /** @hidden */
  79726. interface DeepImmutableArray<T> extends ReadonlyArray<DeepImmutable<T>> {
  79727. }
  79728. }
  79729. declare module BABYLON {
  79730. /**
  79731. * A class serves as a medium between the observable and its observers
  79732. */
  79733. export class EventState {
  79734. /**
  79735. * Create a new EventState
  79736. * @param mask defines the mask associated with this state
  79737. * @param skipNextObservers defines a flag which will instruct the observable to skip following observers when set to true
  79738. * @param target defines the original target of the state
  79739. * @param currentTarget defines the current target of the state
  79740. */
  79741. constructor(mask: number, skipNextObservers?: boolean, target?: any, currentTarget?: any);
  79742. /**
  79743. * Initialize the current event state
  79744. * @param mask defines the mask associated with this state
  79745. * @param skipNextObservers defines a flag which will instruct the observable to skip following observers when set to true
  79746. * @param target defines the original target of the state
  79747. * @param currentTarget defines the current target of the state
  79748. * @returns the current event state
  79749. */
  79750. initalize(mask: number, skipNextObservers?: boolean, target?: any, currentTarget?: any): EventState;
  79751. /**
  79752. * An Observer can set this property to true to prevent subsequent observers of being notified
  79753. */
  79754. skipNextObservers: boolean;
  79755. /**
  79756. * Get the mask value that were used to trigger the event corresponding to this EventState object
  79757. */
  79758. mask: number;
  79759. /**
  79760. * The object that originally notified the event
  79761. */
  79762. target?: any;
  79763. /**
  79764. * The current object in the bubbling phase
  79765. */
  79766. currentTarget?: any;
  79767. /**
  79768. * This will be populated with the return value of the last function that was executed.
  79769. * If it is the first function in the callback chain it will be the event data.
  79770. */
  79771. lastReturnValue?: any;
  79772. }
  79773. /**
  79774. * Represent an Observer registered to a given Observable object.
  79775. */
  79776. export class Observer<T> {
  79777. /**
  79778. * Defines the callback to call when the observer is notified
  79779. */
  79780. callback: (eventData: T, eventState: EventState) => void;
  79781. /**
  79782. * Defines the mask of the observer (used to filter notifications)
  79783. */
  79784. mask: number;
  79785. /**
  79786. * Defines the current scope used to restore the JS context
  79787. */
  79788. scope: any;
  79789. /** @hidden */
  79790. _willBeUnregistered: boolean;
  79791. /**
  79792. * Gets or sets a property defining that the observer as to be unregistered after the next notification
  79793. */
  79794. unregisterOnNextCall: boolean;
  79795. /**
  79796. * Creates a new observer
  79797. * @param callback defines the callback to call when the observer is notified
  79798. * @param mask defines the mask of the observer (used to filter notifications)
  79799. * @param scope defines the current scope used to restore the JS context
  79800. */
  79801. constructor(
  79802. /**
  79803. * Defines the callback to call when the observer is notified
  79804. */
  79805. callback: (eventData: T, eventState: EventState) => void,
  79806. /**
  79807. * Defines the mask of the observer (used to filter notifications)
  79808. */
  79809. mask: number,
  79810. /**
  79811. * Defines the current scope used to restore the JS context
  79812. */
  79813. scope?: any);
  79814. }
  79815. /**
  79816. * Represent a list of observers registered to multiple Observables object.
  79817. */
  79818. export class MultiObserver<T> {
  79819. private _observers;
  79820. private _observables;
  79821. /**
  79822. * Release associated resources
  79823. */
  79824. dispose(): void;
  79825. /**
  79826. * Raise a callback when one of the observable will notify
  79827. * @param observables defines a list of observables to watch
  79828. * @param callback defines the callback to call on notification
  79829. * @param mask defines the mask used to filter notifications
  79830. * @param scope defines the current scope used to restore the JS context
  79831. * @returns the new MultiObserver
  79832. */
  79833. static Watch<T>(observables: Observable<T>[], callback: (eventData: T, eventState: EventState) => void, mask?: number, scope?: any): MultiObserver<T>;
  79834. }
  79835. /**
  79836. * The Observable class is a simple implementation of the Observable pattern.
  79837. *
  79838. * 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.
  79839. * This enable a more fine grained execution without having to rely on multiple different Observable objects.
  79840. * 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).
  79841. * 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.
  79842. */
  79843. export class Observable<T> {
  79844. private _observers;
  79845. private _eventState;
  79846. private _onObserverAdded;
  79847. /**
  79848. * Gets the list of observers
  79849. */
  79850. get observers(): Array<Observer<T>>;
  79851. /**
  79852. * Creates a new observable
  79853. * @param onObserverAdded defines a callback to call when a new observer is added
  79854. */
  79855. constructor(onObserverAdded?: (observer: Observer<T>) => void);
  79856. /**
  79857. * Create a new Observer with the specified callback
  79858. * @param callback the callback that will be executed for that Observer
  79859. * @param mask the mask used to filter observers
  79860. * @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.
  79861. * @param scope optional scope for the callback to be called from
  79862. * @param unregisterOnFirstCall defines if the observer as to be unregistered after the next notification
  79863. * @returns the new observer created for the callback
  79864. */
  79865. add(callback: (eventData: T, eventState: EventState) => void, mask?: number, insertFirst?: boolean, scope?: any, unregisterOnFirstCall?: boolean): Nullable<Observer<T>>;
  79866. /**
  79867. * Create a new Observer with the specified callback and unregisters after the next notification
  79868. * @param callback the callback that will be executed for that Observer
  79869. * @returns the new observer created for the callback
  79870. */
  79871. addOnce(callback: (eventData: T, eventState: EventState) => void): Nullable<Observer<T>>;
  79872. /**
  79873. * Remove an Observer from the Observable object
  79874. * @param observer the instance of the Observer to remove
  79875. * @returns false if it doesn't belong to this Observable
  79876. */
  79877. remove(observer: Nullable<Observer<T>>): boolean;
  79878. /**
  79879. * Remove a callback from the Observable object
  79880. * @param callback the callback to remove
  79881. * @param scope optional scope. If used only the callbacks with this scope will be removed
  79882. * @returns false if it doesn't belong to this Observable
  79883. */
  79884. removeCallback(callback: (eventData: T, eventState: EventState) => void, scope?: any): boolean;
  79885. private _deferUnregister;
  79886. private _remove;
  79887. /**
  79888. * Moves the observable to the top of the observer list making it get called first when notified
  79889. * @param observer the observer to move
  79890. */
  79891. makeObserverTopPriority(observer: Observer<T>): void;
  79892. /**
  79893. * Moves the observable to the bottom of the observer list making it get called last when notified
  79894. * @param observer the observer to move
  79895. */
  79896. makeObserverBottomPriority(observer: Observer<T>): void;
  79897. /**
  79898. * Notify all Observers by calling their respective callback with the given data
  79899. * Will return true if all observers were executed, false if an observer set skipNextObservers to true, then prevent the subsequent ones to execute
  79900. * @param eventData defines the data to send to all observers
  79901. * @param mask defines the mask of the current notification (observers with incompatible mask (ie mask & observer.mask === 0) will not be notified)
  79902. * @param target defines the original target of the state
  79903. * @param currentTarget defines the current target of the state
  79904. * @returns false if the complete observer chain was not processed (because one observer set the skipNextObservers to true)
  79905. */
  79906. notifyObservers(eventData: T, mask?: number, target?: any, currentTarget?: any): boolean;
  79907. /**
  79908. * Calling this will execute each callback, expecting it to be a promise or return a value.
  79909. * If at any point in the chain one function fails, the promise will fail and the execution will not continue.
  79910. * This is useful when a chain of events (sometimes async events) is needed to initialize a certain object
  79911. * and it is crucial that all callbacks will be executed.
  79912. * The order of the callbacks is kept, callbacks are not executed parallel.
  79913. *
  79914. * @param eventData The data to be sent to each callback
  79915. * @param mask is used to filter observers defaults to -1
  79916. * @param target defines the callback target (see EventState)
  79917. * @param currentTarget defines he current object in the bubbling phase
  79918. * @returns {Promise<T>} will return a Promise than resolves when all callbacks executed successfully.
  79919. */
  79920. notifyObserversWithPromise(eventData: T, mask?: number, target?: any, currentTarget?: any): Promise<T>;
  79921. /**
  79922. * Notify a specific observer
  79923. * @param observer defines the observer to notify
  79924. * @param eventData defines the data to be sent to each callback
  79925. * @param mask is used to filter observers defaults to -1
  79926. */
  79927. notifyObserver(observer: Observer<T>, eventData: T, mask?: number): void;
  79928. /**
  79929. * Gets a boolean indicating if the observable has at least one observer
  79930. * @returns true is the Observable has at least one Observer registered
  79931. */
  79932. hasObservers(): boolean;
  79933. /**
  79934. * Clear the list of observers
  79935. */
  79936. clear(): void;
  79937. /**
  79938. * Clone the current observable
  79939. * @returns a new observable
  79940. */
  79941. clone(): Observable<T>;
  79942. /**
  79943. * Does this observable handles observer registered with a given mask
  79944. * @param mask defines the mask to be tested
  79945. * @return whether or not one observer registered with the given mask is handeled
  79946. **/
  79947. hasSpecificMask(mask?: number): boolean;
  79948. }
  79949. }
  79950. declare module BABYLON {
  79951. /**
  79952. * Sets of helpers dealing with the DOM and some of the recurrent functions needed in
  79953. * Babylon.js
  79954. */
  79955. export class DomManagement {
  79956. /**
  79957. * Checks if the window object exists
  79958. * @returns true if the window object exists
  79959. */
  79960. static IsWindowObjectExist(): boolean;
  79961. /**
  79962. * Checks if the navigator object exists
  79963. * @returns true if the navigator object exists
  79964. */
  79965. static IsNavigatorAvailable(): boolean;
  79966. /**
  79967. * Check if the document object exists
  79968. * @returns true if the document object exists
  79969. */
  79970. static IsDocumentAvailable(): boolean;
  79971. /**
  79972. * Extracts text content from a DOM element hierarchy
  79973. * @param element defines the root element
  79974. * @returns a string
  79975. */
  79976. static GetDOMTextContent(element: HTMLElement): string;
  79977. }
  79978. }
  79979. declare module BABYLON {
  79980. /**
  79981. * Logger used througouht the application to allow configuration of
  79982. * the log level required for the messages.
  79983. */
  79984. export class Logger {
  79985. /**
  79986. * No log
  79987. */
  79988. static readonly NoneLogLevel: number;
  79989. /**
  79990. * Only message logs
  79991. */
  79992. static readonly MessageLogLevel: number;
  79993. /**
  79994. * Only warning logs
  79995. */
  79996. static readonly WarningLogLevel: number;
  79997. /**
  79998. * Only error logs
  79999. */
  80000. static readonly ErrorLogLevel: number;
  80001. /**
  80002. * All logs
  80003. */
  80004. static readonly AllLogLevel: number;
  80005. private static _LogCache;
  80006. /**
  80007. * Gets a value indicating the number of loading errors
  80008. * @ignorenaming
  80009. */
  80010. static errorsCount: number;
  80011. /**
  80012. * Callback called when a new log is added
  80013. */
  80014. static OnNewCacheEntry: (entry: string) => void;
  80015. private static _AddLogEntry;
  80016. private static _FormatMessage;
  80017. private static _LogDisabled;
  80018. private static _LogEnabled;
  80019. private static _WarnDisabled;
  80020. private static _WarnEnabled;
  80021. private static _ErrorDisabled;
  80022. private static _ErrorEnabled;
  80023. /**
  80024. * Log a message to the console
  80025. */
  80026. static Log: (message: string) => void;
  80027. /**
  80028. * Write a warning message to the console
  80029. */
  80030. static Warn: (message: string) => void;
  80031. /**
  80032. * Write an error message to the console
  80033. */
  80034. static Error: (message: string) => void;
  80035. /**
  80036. * Gets current log cache (list of logs)
  80037. */
  80038. static get LogCache(): string;
  80039. /**
  80040. * Clears the log cache
  80041. */
  80042. static ClearLogCache(): void;
  80043. /**
  80044. * Sets the current log level (MessageLogLevel / WarningLogLevel / ErrorLogLevel)
  80045. */
  80046. static set LogLevels(level: number);
  80047. }
  80048. }
  80049. declare module BABYLON {
  80050. /** @hidden */
  80051. export class _TypeStore {
  80052. /** @hidden */
  80053. static RegisteredTypes: {
  80054. [key: string]: Object;
  80055. };
  80056. /** @hidden */
  80057. static GetClass(fqdn: string): any;
  80058. }
  80059. }
  80060. declare module BABYLON {
  80061. /**
  80062. * Helper to manipulate strings
  80063. */
  80064. export class StringTools {
  80065. /**
  80066. * Checks for a matching suffix at the end of a string (for ES5 and lower)
  80067. * @param str Source string
  80068. * @param suffix Suffix to search for in the source string
  80069. * @returns Boolean indicating whether the suffix was found (true) or not (false)
  80070. */
  80071. static EndsWith(str: string, suffix: string): boolean;
  80072. /**
  80073. * Checks for a matching suffix at the beginning of a string (for ES5 and lower)
  80074. * @param str Source string
  80075. * @param suffix Suffix to search for in the source string
  80076. * @returns Boolean indicating whether the suffix was found (true) or not (false)
  80077. */
  80078. static StartsWith(str: string, suffix: string): boolean;
  80079. /**
  80080. * Decodes a buffer into a string
  80081. * @param buffer The buffer to decode
  80082. * @returns The decoded string
  80083. */
  80084. static Decode(buffer: Uint8Array | Uint16Array): string;
  80085. /**
  80086. * Encode a buffer to a base64 string
  80087. * @param buffer defines the buffer to encode
  80088. * @returns the encoded string
  80089. */
  80090. static EncodeArrayBufferToBase64(buffer: ArrayBuffer | ArrayBufferView): string;
  80091. /**
  80092. * Converts a number to string and pads with preceeding zeroes until it is of specified length.
  80093. * @param num the number to convert and pad
  80094. * @param length the expected length of the string
  80095. * @returns the padded string
  80096. */
  80097. static PadNumber(num: number, length: number): string;
  80098. }
  80099. }
  80100. declare module BABYLON {
  80101. /**
  80102. * Class containing a set of static utilities functions for deep copy.
  80103. */
  80104. export class DeepCopier {
  80105. /**
  80106. * Tries to copy an object by duplicating every property
  80107. * @param source defines the source object
  80108. * @param destination defines the target object
  80109. * @param doNotCopyList defines a list of properties to avoid
  80110. * @param mustCopyList defines a list of properties to copy (even if they start with _)
  80111. */
  80112. static DeepCopy(source: any, destination: any, doNotCopyList?: string[], mustCopyList?: string[]): void;
  80113. }
  80114. }
  80115. declare module BABYLON {
  80116. /**
  80117. * Class containing a set of static utilities functions for precision date
  80118. */
  80119. export class PrecisionDate {
  80120. /**
  80121. * Gets either window.performance.now() if supported or Date.now() else
  80122. */
  80123. static get Now(): number;
  80124. }
  80125. }
  80126. declare module BABYLON {
  80127. /** @hidden */
  80128. export class _DevTools {
  80129. static WarnImport(name: string): string;
  80130. }
  80131. }
  80132. declare module BABYLON {
  80133. /**
  80134. * Interface used to define the mechanism to get data from the network
  80135. */
  80136. export interface IWebRequest {
  80137. /**
  80138. * Returns client's response url
  80139. */
  80140. responseURL: string;
  80141. /**
  80142. * Returns client's status
  80143. */
  80144. status: number;
  80145. /**
  80146. * Returns client's status as a text
  80147. */
  80148. statusText: string;
  80149. }
  80150. }
  80151. declare module BABYLON {
  80152. /**
  80153. * Extended version of XMLHttpRequest with support for customizations (headers, ...)
  80154. */
  80155. export class WebRequest implements IWebRequest {
  80156. private _xhr;
  80157. /**
  80158. * Custom HTTP Request Headers to be sent with XMLHttpRequests
  80159. * i.e. when loading files, where the server/service expects an Authorization header
  80160. */
  80161. static CustomRequestHeaders: {
  80162. [key: string]: string;
  80163. };
  80164. /**
  80165. * Add callback functions in this array to update all the requests before they get sent to the network
  80166. */
  80167. static CustomRequestModifiers: ((request: XMLHttpRequest, url: string) => void)[];
  80168. private _injectCustomRequestHeaders;
  80169. /**
  80170. * Gets or sets a function to be called when loading progress changes
  80171. */
  80172. get onprogress(): ((this: XMLHttpRequest, ev: ProgressEvent) => any) | null;
  80173. set onprogress(value: ((this: XMLHttpRequest, ev: ProgressEvent) => any) | null);
  80174. /**
  80175. * Returns client's state
  80176. */
  80177. get readyState(): number;
  80178. /**
  80179. * Returns client's status
  80180. */
  80181. get status(): number;
  80182. /**
  80183. * Returns client's status as a text
  80184. */
  80185. get statusText(): string;
  80186. /**
  80187. * Returns client's response
  80188. */
  80189. get response(): any;
  80190. /**
  80191. * Returns client's response url
  80192. */
  80193. get responseURL(): string;
  80194. /**
  80195. * Returns client's response as text
  80196. */
  80197. get responseText(): string;
  80198. /**
  80199. * Gets or sets the expected response type
  80200. */
  80201. get responseType(): XMLHttpRequestResponseType;
  80202. set responseType(value: XMLHttpRequestResponseType);
  80203. /** @hidden */
  80204. addEventListener<K extends keyof XMLHttpRequestEventMap>(type: K, listener: (this: XMLHttpRequest, ev: XMLHttpRequestEventMap[K]) => any, options?: boolean | AddEventListenerOptions): void;
  80205. /** @hidden */
  80206. removeEventListener<K extends keyof XMLHttpRequestEventMap>(type: K, listener: (this: XMLHttpRequest, ev: XMLHttpRequestEventMap[K]) => any, options?: boolean | EventListenerOptions): void;
  80207. /**
  80208. * Cancels any network activity
  80209. */
  80210. abort(): void;
  80211. /**
  80212. * Initiates the request. The optional argument provides the request body. The argument is ignored if request method is GET or HEAD
  80213. * @param body defines an optional request body
  80214. */
  80215. send(body?: Document | BodyInit | null): void;
  80216. /**
  80217. * Sets the request method, request URL
  80218. * @param method defines the method to use (GET, POST, etc..)
  80219. * @param url defines the url to connect with
  80220. */
  80221. open(method: string, url: string): void;
  80222. /**
  80223. * Sets the value of a request header.
  80224. * @param name The name of the header whose value is to be set
  80225. * @param value The value to set as the body of the header
  80226. */
  80227. setRequestHeader(name: string, value: string): void;
  80228. /**
  80229. * Get the string containing the text of a particular header's value.
  80230. * @param name The name of the header
  80231. * @returns The string containing the text of the given header name
  80232. */
  80233. getResponseHeader(name: string): Nullable<string>;
  80234. }
  80235. }
  80236. declare module BABYLON {
  80237. /**
  80238. * File request interface
  80239. */
  80240. export interface IFileRequest {
  80241. /**
  80242. * Raised when the request is complete (success or error).
  80243. */
  80244. onCompleteObservable: Observable<IFileRequest>;
  80245. /**
  80246. * Aborts the request for a file.
  80247. */
  80248. abort: () => void;
  80249. }
  80250. }
  80251. declare module BABYLON {
  80252. /**
  80253. * Define options used to create a render target texture
  80254. */
  80255. export class RenderTargetCreationOptions {
  80256. /**
  80257. * Specifies is mipmaps must be generated
  80258. */
  80259. generateMipMaps?: boolean;
  80260. /** Specifies whether or not a depth should be allocated in the texture (true by default) */
  80261. generateDepthBuffer?: boolean;
  80262. /** Specifies whether or not a stencil should be allocated in the texture (false by default)*/
  80263. generateStencilBuffer?: boolean;
  80264. /** Defines texture type (int by default) */
  80265. type?: number;
  80266. /** Defines sampling mode (trilinear by default) */
  80267. samplingMode?: number;
  80268. /** Defines format (RGBA by default) */
  80269. format?: number;
  80270. }
  80271. }
  80272. declare module BABYLON {
  80273. /** Defines the cross module used constants to avoid circular dependncies */
  80274. export class Constants {
  80275. /** Defines that alpha blending is disabled */
  80276. static readonly ALPHA_DISABLE: number;
  80277. /** Defines that alpha blending is SRC ALPHA * SRC + DEST */
  80278. static readonly ALPHA_ADD: number;
  80279. /** Defines that alpha blending is SRC ALPHA * SRC + (1 - SRC ALPHA) * DEST */
  80280. static readonly ALPHA_COMBINE: number;
  80281. /** Defines that alpha blending is DEST - SRC * DEST */
  80282. static readonly ALPHA_SUBTRACT: number;
  80283. /** Defines that alpha blending is SRC * DEST */
  80284. static readonly ALPHA_MULTIPLY: number;
  80285. /** Defines that alpha blending is SRC ALPHA * SRC + (1 - SRC) * DEST */
  80286. static readonly ALPHA_MAXIMIZED: number;
  80287. /** Defines that alpha blending is SRC + DEST */
  80288. static readonly ALPHA_ONEONE: number;
  80289. /** Defines that alpha blending is SRC + (1 - SRC ALPHA) * DEST */
  80290. static readonly ALPHA_PREMULTIPLIED: number;
  80291. /**
  80292. * Defines that alpha blending is SRC + (1 - SRC ALPHA) * DEST
  80293. * Alpha will be set to (1 - SRC ALPHA) * DEST ALPHA
  80294. */
  80295. static readonly ALPHA_PREMULTIPLIED_PORTERDUFF: number;
  80296. /** Defines that alpha blending is CST * SRC + (1 - CST) * DEST */
  80297. static readonly ALPHA_INTERPOLATE: number;
  80298. /**
  80299. * Defines that alpha blending is SRC + (1 - SRC) * DEST
  80300. * Alpha will be set to SRC ALPHA + (1 - SRC ALPHA) * DEST ALPHA
  80301. */
  80302. static readonly ALPHA_SCREENMODE: number;
  80303. /**
  80304. * Defines that alpha blending is SRC + DST
  80305. * Alpha will be set to SRC ALPHA + DST ALPHA
  80306. */
  80307. static readonly ALPHA_ONEONE_ONEONE: number;
  80308. /**
  80309. * Defines that alpha blending is SRC * DST ALPHA + DST
  80310. * Alpha will be set to 0
  80311. */
  80312. static readonly ALPHA_ALPHATOCOLOR: number;
  80313. /**
  80314. * Defines that alpha blending is SRC * (1 - DST) + DST * (1 - SRC)
  80315. */
  80316. static readonly ALPHA_REVERSEONEMINUS: number;
  80317. /**
  80318. * Defines that alpha blending is SRC + DST * (1 - SRC ALPHA)
  80319. * Alpha will be set to SRC ALPHA + DST ALPHA * (1 - SRC ALPHA)
  80320. */
  80321. static readonly ALPHA_SRC_DSTONEMINUSSRCALPHA: number;
  80322. /**
  80323. * Defines that alpha blending is SRC + DST
  80324. * Alpha will be set to SRC ALPHA
  80325. */
  80326. static readonly ALPHA_ONEONE_ONEZERO: number;
  80327. /**
  80328. * Defines that alpha blending is SRC * (1 - DST) + DST * (1 - SRC)
  80329. * Alpha will be set to DST ALPHA
  80330. */
  80331. static readonly ALPHA_EXCLUSION: number;
  80332. /** Defines that alpha blending equation a SUM */
  80333. static readonly ALPHA_EQUATION_ADD: number;
  80334. /** Defines that alpha blending equation a SUBSTRACTION */
  80335. static readonly ALPHA_EQUATION_SUBSTRACT: number;
  80336. /** Defines that alpha blending equation a REVERSE SUBSTRACTION */
  80337. static readonly ALPHA_EQUATION_REVERSE_SUBTRACT: number;
  80338. /** Defines that alpha blending equation a MAX operation */
  80339. static readonly ALPHA_EQUATION_MAX: number;
  80340. /** Defines that alpha blending equation a MIN operation */
  80341. static readonly ALPHA_EQUATION_MIN: number;
  80342. /**
  80343. * Defines that alpha blending equation a DARKEN operation:
  80344. * It takes the min of the src and sums the alpha channels.
  80345. */
  80346. static readonly ALPHA_EQUATION_DARKEN: number;
  80347. /** Defines that the ressource is not delayed*/
  80348. static readonly DELAYLOADSTATE_NONE: number;
  80349. /** Defines that the ressource was successfully delay loaded */
  80350. static readonly DELAYLOADSTATE_LOADED: number;
  80351. /** Defines that the ressource is currently delay loading */
  80352. static readonly DELAYLOADSTATE_LOADING: number;
  80353. /** Defines that the ressource is delayed and has not started loading */
  80354. static readonly DELAYLOADSTATE_NOTLOADED: number;
  80355. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will never pass. i.e. Nothing will be drawn */
  80356. static readonly NEVER: number;
  80357. /** 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 */
  80358. static readonly ALWAYS: number;
  80359. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is less than the stored value */
  80360. static readonly LESS: number;
  80361. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is equals to the stored value */
  80362. static readonly EQUAL: number;
  80363. /** 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 */
  80364. static readonly LEQUAL: number;
  80365. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is greater than the stored value */
  80366. static readonly GREATER: number;
  80367. /** 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 */
  80368. static readonly GEQUAL: number;
  80369. /** 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 */
  80370. static readonly NOTEQUAL: number;
  80371. /** Passed to stencilOperation to specify that stencil value must be kept */
  80372. static readonly KEEP: number;
  80373. /** Passed to stencilOperation to specify that stencil value must be replaced */
  80374. static readonly REPLACE: number;
  80375. /** Passed to stencilOperation to specify that stencil value must be incremented */
  80376. static readonly INCR: number;
  80377. /** Passed to stencilOperation to specify that stencil value must be decremented */
  80378. static readonly DECR: number;
  80379. /** Passed to stencilOperation to specify that stencil value must be inverted */
  80380. static readonly INVERT: number;
  80381. /** Passed to stencilOperation to specify that stencil value must be incremented with wrapping */
  80382. static readonly INCR_WRAP: number;
  80383. /** Passed to stencilOperation to specify that stencil value must be decremented with wrapping */
  80384. static readonly DECR_WRAP: number;
  80385. /** Texture is not repeating outside of 0..1 UVs */
  80386. static readonly TEXTURE_CLAMP_ADDRESSMODE: number;
  80387. /** Texture is repeating outside of 0..1 UVs */
  80388. static readonly TEXTURE_WRAP_ADDRESSMODE: number;
  80389. /** Texture is repeating and mirrored */
  80390. static readonly TEXTURE_MIRROR_ADDRESSMODE: number;
  80391. /** ALPHA */
  80392. static readonly TEXTUREFORMAT_ALPHA: number;
  80393. /** LUMINANCE */
  80394. static readonly TEXTUREFORMAT_LUMINANCE: number;
  80395. /** LUMINANCE_ALPHA */
  80396. static readonly TEXTUREFORMAT_LUMINANCE_ALPHA: number;
  80397. /** RGB */
  80398. static readonly TEXTUREFORMAT_RGB: number;
  80399. /** RGBA */
  80400. static readonly TEXTUREFORMAT_RGBA: number;
  80401. /** RED */
  80402. static readonly TEXTUREFORMAT_RED: number;
  80403. /** RED (2nd reference) */
  80404. static readonly TEXTUREFORMAT_R: number;
  80405. /** RG */
  80406. static readonly TEXTUREFORMAT_RG: number;
  80407. /** RED_INTEGER */
  80408. static readonly TEXTUREFORMAT_RED_INTEGER: number;
  80409. /** RED_INTEGER (2nd reference) */
  80410. static readonly TEXTUREFORMAT_R_INTEGER: number;
  80411. /** RG_INTEGER */
  80412. static readonly TEXTUREFORMAT_RG_INTEGER: number;
  80413. /** RGB_INTEGER */
  80414. static readonly TEXTUREFORMAT_RGB_INTEGER: number;
  80415. /** RGBA_INTEGER */
  80416. static readonly TEXTUREFORMAT_RGBA_INTEGER: number;
  80417. /** UNSIGNED_BYTE */
  80418. static readonly TEXTURETYPE_UNSIGNED_BYTE: number;
  80419. /** UNSIGNED_BYTE (2nd reference) */
  80420. static readonly TEXTURETYPE_UNSIGNED_INT: number;
  80421. /** FLOAT */
  80422. static readonly TEXTURETYPE_FLOAT: number;
  80423. /** HALF_FLOAT */
  80424. static readonly TEXTURETYPE_HALF_FLOAT: number;
  80425. /** BYTE */
  80426. static readonly TEXTURETYPE_BYTE: number;
  80427. /** SHORT */
  80428. static readonly TEXTURETYPE_SHORT: number;
  80429. /** UNSIGNED_SHORT */
  80430. static readonly TEXTURETYPE_UNSIGNED_SHORT: number;
  80431. /** INT */
  80432. static readonly TEXTURETYPE_INT: number;
  80433. /** UNSIGNED_INT */
  80434. static readonly TEXTURETYPE_UNSIGNED_INTEGER: number;
  80435. /** UNSIGNED_SHORT_4_4_4_4 */
  80436. static readonly TEXTURETYPE_UNSIGNED_SHORT_4_4_4_4: number;
  80437. /** UNSIGNED_SHORT_5_5_5_1 */
  80438. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_5_5_1: number;
  80439. /** UNSIGNED_SHORT_5_6_5 */
  80440. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_6_5: number;
  80441. /** UNSIGNED_INT_2_10_10_10_REV */
  80442. static readonly TEXTURETYPE_UNSIGNED_INT_2_10_10_10_REV: number;
  80443. /** UNSIGNED_INT_24_8 */
  80444. static readonly TEXTURETYPE_UNSIGNED_INT_24_8: number;
  80445. /** UNSIGNED_INT_10F_11F_11F_REV */
  80446. static readonly TEXTURETYPE_UNSIGNED_INT_10F_11F_11F_REV: number;
  80447. /** UNSIGNED_INT_5_9_9_9_REV */
  80448. static readonly TEXTURETYPE_UNSIGNED_INT_5_9_9_9_REV: number;
  80449. /** FLOAT_32_UNSIGNED_INT_24_8_REV */
  80450. static readonly TEXTURETYPE_FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  80451. /** nearest is mag = nearest and min = nearest and no mip */
  80452. static readonly TEXTURE_NEAREST_SAMPLINGMODE: number;
  80453. /** mag = nearest and min = nearest and mip = none */
  80454. static readonly TEXTURE_NEAREST_NEAREST: number;
  80455. /** Bilinear is mag = linear and min = linear and no mip */
  80456. static readonly TEXTURE_BILINEAR_SAMPLINGMODE: number;
  80457. /** mag = linear and min = linear and mip = none */
  80458. static readonly TEXTURE_LINEAR_LINEAR: number;
  80459. /** Trilinear is mag = linear and min = linear and mip = linear */
  80460. static readonly TEXTURE_TRILINEAR_SAMPLINGMODE: number;
  80461. /** Trilinear is mag = linear and min = linear and mip = linear */
  80462. static readonly TEXTURE_LINEAR_LINEAR_MIPLINEAR: number;
  80463. /** mag = nearest and min = nearest and mip = nearest */
  80464. static readonly TEXTURE_NEAREST_NEAREST_MIPNEAREST: number;
  80465. /** mag = nearest and min = linear and mip = nearest */
  80466. static readonly TEXTURE_NEAREST_LINEAR_MIPNEAREST: number;
  80467. /** mag = nearest and min = linear and mip = linear */
  80468. static readonly TEXTURE_NEAREST_LINEAR_MIPLINEAR: number;
  80469. /** mag = nearest and min = linear and mip = none */
  80470. static readonly TEXTURE_NEAREST_LINEAR: number;
  80471. /** nearest is mag = nearest and min = nearest and mip = linear */
  80472. static readonly TEXTURE_NEAREST_NEAREST_MIPLINEAR: number;
  80473. /** mag = linear and min = nearest and mip = nearest */
  80474. static readonly TEXTURE_LINEAR_NEAREST_MIPNEAREST: number;
  80475. /** mag = linear and min = nearest and mip = linear */
  80476. static readonly TEXTURE_LINEAR_NEAREST_MIPLINEAR: number;
  80477. /** Bilinear is mag = linear and min = linear and mip = nearest */
  80478. static readonly TEXTURE_LINEAR_LINEAR_MIPNEAREST: number;
  80479. /** mag = linear and min = nearest and mip = none */
  80480. static readonly TEXTURE_LINEAR_NEAREST: number;
  80481. /** Explicit coordinates mode */
  80482. static readonly TEXTURE_EXPLICIT_MODE: number;
  80483. /** Spherical coordinates mode */
  80484. static readonly TEXTURE_SPHERICAL_MODE: number;
  80485. /** Planar coordinates mode */
  80486. static readonly TEXTURE_PLANAR_MODE: number;
  80487. /** Cubic coordinates mode */
  80488. static readonly TEXTURE_CUBIC_MODE: number;
  80489. /** Projection coordinates mode */
  80490. static readonly TEXTURE_PROJECTION_MODE: number;
  80491. /** Skybox coordinates mode */
  80492. static readonly TEXTURE_SKYBOX_MODE: number;
  80493. /** Inverse Cubic coordinates mode */
  80494. static readonly TEXTURE_INVCUBIC_MODE: number;
  80495. /** Equirectangular coordinates mode */
  80496. static readonly TEXTURE_EQUIRECTANGULAR_MODE: number;
  80497. /** Equirectangular Fixed coordinates mode */
  80498. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MODE: number;
  80499. /** Equirectangular Fixed Mirrored coordinates mode */
  80500. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  80501. /** Offline (baking) quality for texture filtering */
  80502. static readonly TEXTURE_FILTERING_QUALITY_OFFLINE: number;
  80503. /** High quality for texture filtering */
  80504. static readonly TEXTURE_FILTERING_QUALITY_HIGH: number;
  80505. /** Medium quality for texture filtering */
  80506. static readonly TEXTURE_FILTERING_QUALITY_MEDIUM: number;
  80507. /** Low quality for texture filtering */
  80508. static readonly TEXTURE_FILTERING_QUALITY_LOW: number;
  80509. /** Defines that texture rescaling will use a floor to find the closer power of 2 size */
  80510. static readonly SCALEMODE_FLOOR: number;
  80511. /** Defines that texture rescaling will look for the nearest power of 2 size */
  80512. static readonly SCALEMODE_NEAREST: number;
  80513. /** Defines that texture rescaling will use a ceil to find the closer power of 2 size */
  80514. static readonly SCALEMODE_CEILING: number;
  80515. /**
  80516. * The dirty texture flag value
  80517. */
  80518. static readonly MATERIAL_TextureDirtyFlag: number;
  80519. /**
  80520. * The dirty light flag value
  80521. */
  80522. static readonly MATERIAL_LightDirtyFlag: number;
  80523. /**
  80524. * The dirty fresnel flag value
  80525. */
  80526. static readonly MATERIAL_FresnelDirtyFlag: number;
  80527. /**
  80528. * The dirty attribute flag value
  80529. */
  80530. static readonly MATERIAL_AttributesDirtyFlag: number;
  80531. /**
  80532. * The dirty misc flag value
  80533. */
  80534. static readonly MATERIAL_MiscDirtyFlag: number;
  80535. /**
  80536. * The all dirty flag value
  80537. */
  80538. static readonly MATERIAL_AllDirtyFlag: number;
  80539. /**
  80540. * Returns the triangle fill mode
  80541. */
  80542. static readonly MATERIAL_TriangleFillMode: number;
  80543. /**
  80544. * Returns the wireframe mode
  80545. */
  80546. static readonly MATERIAL_WireFrameFillMode: number;
  80547. /**
  80548. * Returns the point fill mode
  80549. */
  80550. static readonly MATERIAL_PointFillMode: number;
  80551. /**
  80552. * Returns the point list draw mode
  80553. */
  80554. static readonly MATERIAL_PointListDrawMode: number;
  80555. /**
  80556. * Returns the line list draw mode
  80557. */
  80558. static readonly MATERIAL_LineListDrawMode: number;
  80559. /**
  80560. * Returns the line loop draw mode
  80561. */
  80562. static readonly MATERIAL_LineLoopDrawMode: number;
  80563. /**
  80564. * Returns the line strip draw mode
  80565. */
  80566. static readonly MATERIAL_LineStripDrawMode: number;
  80567. /**
  80568. * Returns the triangle strip draw mode
  80569. */
  80570. static readonly MATERIAL_TriangleStripDrawMode: number;
  80571. /**
  80572. * Returns the triangle fan draw mode
  80573. */
  80574. static readonly MATERIAL_TriangleFanDrawMode: number;
  80575. /**
  80576. * Stores the clock-wise side orientation
  80577. */
  80578. static readonly MATERIAL_ClockWiseSideOrientation: number;
  80579. /**
  80580. * Stores the counter clock-wise side orientation
  80581. */
  80582. static readonly MATERIAL_CounterClockWiseSideOrientation: number;
  80583. /**
  80584. * Nothing
  80585. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  80586. */
  80587. static readonly ACTION_NothingTrigger: number;
  80588. /**
  80589. * On pick
  80590. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  80591. */
  80592. static readonly ACTION_OnPickTrigger: number;
  80593. /**
  80594. * On left pick
  80595. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  80596. */
  80597. static readonly ACTION_OnLeftPickTrigger: number;
  80598. /**
  80599. * On right pick
  80600. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  80601. */
  80602. static readonly ACTION_OnRightPickTrigger: number;
  80603. /**
  80604. * On center pick
  80605. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  80606. */
  80607. static readonly ACTION_OnCenterPickTrigger: number;
  80608. /**
  80609. * On pick down
  80610. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  80611. */
  80612. static readonly ACTION_OnPickDownTrigger: number;
  80613. /**
  80614. * On double pick
  80615. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  80616. */
  80617. static readonly ACTION_OnDoublePickTrigger: number;
  80618. /**
  80619. * On pick up
  80620. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  80621. */
  80622. static readonly ACTION_OnPickUpTrigger: number;
  80623. /**
  80624. * On pick out.
  80625. * This trigger will only be raised if you also declared a OnPickDown
  80626. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  80627. */
  80628. static readonly ACTION_OnPickOutTrigger: number;
  80629. /**
  80630. * On long press
  80631. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  80632. */
  80633. static readonly ACTION_OnLongPressTrigger: number;
  80634. /**
  80635. * On pointer over
  80636. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  80637. */
  80638. static readonly ACTION_OnPointerOverTrigger: number;
  80639. /**
  80640. * On pointer out
  80641. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  80642. */
  80643. static readonly ACTION_OnPointerOutTrigger: number;
  80644. /**
  80645. * On every frame
  80646. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  80647. */
  80648. static readonly ACTION_OnEveryFrameTrigger: number;
  80649. /**
  80650. * On intersection enter
  80651. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  80652. */
  80653. static readonly ACTION_OnIntersectionEnterTrigger: number;
  80654. /**
  80655. * On intersection exit
  80656. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  80657. */
  80658. static readonly ACTION_OnIntersectionExitTrigger: number;
  80659. /**
  80660. * On key down
  80661. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  80662. */
  80663. static readonly ACTION_OnKeyDownTrigger: number;
  80664. /**
  80665. * On key up
  80666. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  80667. */
  80668. static readonly ACTION_OnKeyUpTrigger: number;
  80669. /**
  80670. * Billboard mode will only apply to Y axis
  80671. */
  80672. static readonly PARTICLES_BILLBOARDMODE_Y: number;
  80673. /**
  80674. * Billboard mode will apply to all axes
  80675. */
  80676. static readonly PARTICLES_BILLBOARDMODE_ALL: number;
  80677. /**
  80678. * Special billboard mode where the particle will be biilboard to the camera but rotated to align with direction
  80679. */
  80680. static readonly PARTICLES_BILLBOARDMODE_STRETCHED: number;
  80681. /** Default culling strategy : this is an exclusion test and it's the more accurate.
  80682. * Test order :
  80683. * Is the bounding sphere outside the frustum ?
  80684. * If not, are the bounding box vertices outside the frustum ?
  80685. * It not, then the cullable object is in the frustum.
  80686. */
  80687. static readonly MESHES_CULLINGSTRATEGY_STANDARD: number;
  80688. /** Culling strategy : Bounding Sphere Only.
  80689. * This is an exclusion test. It's faster than the standard strategy because the bounding box is not tested.
  80690. * It's also less accurate than the standard because some not visible objects can still be selected.
  80691. * Test : is the bounding sphere outside the frustum ?
  80692. * If not, then the cullable object is in the frustum.
  80693. */
  80694. static readonly MESHES_CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY: number;
  80695. /** Culling strategy : Optimistic Inclusion.
  80696. * This in an inclusion test first, then the standard exclusion test.
  80697. * This can be faster when a cullable object is expected to be almost always in the camera frustum.
  80698. * 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.
  80699. * Anyway, it's as accurate as the standard strategy.
  80700. * Test :
  80701. * Is the cullable object bounding sphere center in the frustum ?
  80702. * If not, apply the default culling strategy.
  80703. */
  80704. static readonly MESHES_CULLINGSTRATEGY_OPTIMISTIC_INCLUSION: number;
  80705. /** Culling strategy : Optimistic Inclusion then Bounding Sphere Only.
  80706. * This in an inclusion test first, then the bounding sphere only exclusion test.
  80707. * This can be the fastest test when a cullable object is expected to be almost always in the camera frustum.
  80708. * 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.
  80709. * It's less accurate than the standard strategy and as accurate as the BoundingSphereOnly strategy.
  80710. * Test :
  80711. * Is the cullable object bounding sphere center in the frustum ?
  80712. * If not, apply the Bounding Sphere Only strategy. No Bounding Box is tested here.
  80713. */
  80714. static readonly MESHES_CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY: number;
  80715. /**
  80716. * No logging while loading
  80717. */
  80718. static readonly SCENELOADER_NO_LOGGING: number;
  80719. /**
  80720. * Minimal logging while loading
  80721. */
  80722. static readonly SCENELOADER_MINIMAL_LOGGING: number;
  80723. /**
  80724. * Summary logging while loading
  80725. */
  80726. static readonly SCENELOADER_SUMMARY_LOGGING: number;
  80727. /**
  80728. * Detailled logging while loading
  80729. */
  80730. static readonly SCENELOADER_DETAILED_LOGGING: number;
  80731. /**
  80732. * Prepass texture index for color
  80733. */
  80734. static readonly PREPASS_COLOR_INDEX: number;
  80735. /**
  80736. * Prepass texture index for irradiance
  80737. */
  80738. static readonly PREPASS_IRRADIANCE_INDEX: number;
  80739. /**
  80740. * Prepass texture index for depth + normal
  80741. */
  80742. static readonly PREPASS_DEPTHNORMAL_INDEX: number;
  80743. /**
  80744. * Prepass texture index for albedo
  80745. */
  80746. static readonly PREPASS_ALBEDO_INDEX: number;
  80747. }
  80748. }
  80749. declare module BABYLON {
  80750. /**
  80751. * This represents the required contract to create a new type of texture loader.
  80752. */
  80753. export interface IInternalTextureLoader {
  80754. /**
  80755. * Defines wether the loader supports cascade loading the different faces.
  80756. */
  80757. supportCascades: boolean;
  80758. /**
  80759. * This returns if the loader support the current file information.
  80760. * @param extension defines the file extension of the file being loaded
  80761. * @param mimeType defines the optional mime type of the file being loaded
  80762. * @returns true if the loader can load the specified file
  80763. */
  80764. canLoad(extension: string, mimeType?: string): boolean;
  80765. /**
  80766. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  80767. * @param data contains the texture data
  80768. * @param texture defines the BabylonJS internal texture
  80769. * @param createPolynomials will be true if polynomials have been requested
  80770. * @param onLoad defines the callback to trigger once the texture is ready
  80771. * @param onError defines the callback to trigger in case of error
  80772. */
  80773. loadCubeData(data: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  80774. /**
  80775. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  80776. * @param data contains the texture data
  80777. * @param texture defines the BabylonJS internal texture
  80778. * @param callback defines the method to call once ready to upload
  80779. */
  80780. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void, loadFailed?: boolean) => void): void;
  80781. }
  80782. }
  80783. declare module BABYLON {
  80784. /**
  80785. * Class used to store and describe the pipeline context associated with an effect
  80786. */
  80787. export interface IPipelineContext {
  80788. /**
  80789. * Gets a boolean indicating that this pipeline context is supporting asynchronous creating
  80790. */
  80791. isAsync: boolean;
  80792. /**
  80793. * Gets a boolean indicating that the context is ready to be used (like shaders / pipelines are compiled and ready for instance)
  80794. */
  80795. isReady: boolean;
  80796. /** @hidden */
  80797. _getVertexShaderCode(): string | null;
  80798. /** @hidden */
  80799. _getFragmentShaderCode(): string | null;
  80800. /** @hidden */
  80801. _handlesSpectorRebuildCallback(onCompiled: (compiledObject: any) => void): void;
  80802. }
  80803. }
  80804. declare module BABYLON {
  80805. /**
  80806. * Class used to store gfx data (like WebGLBuffer)
  80807. */
  80808. export class DataBuffer {
  80809. /**
  80810. * Gets or sets the number of objects referencing this buffer
  80811. */
  80812. references: number;
  80813. /** Gets or sets the size of the underlying buffer */
  80814. capacity: number;
  80815. /**
  80816. * Gets or sets a boolean indicating if the buffer contains 32bits indices
  80817. */
  80818. is32Bits: boolean;
  80819. /**
  80820. * Gets the underlying buffer
  80821. */
  80822. get underlyingResource(): any;
  80823. }
  80824. }
  80825. declare module BABYLON {
  80826. /** @hidden */
  80827. export interface IShaderProcessor {
  80828. attributeProcessor?: (attribute: string) => string;
  80829. varyingProcessor?: (varying: string, isFragment: boolean) => string;
  80830. uniformProcessor?: (uniform: string, isFragment: boolean) => string;
  80831. uniformBufferProcessor?: (uniformBuffer: string, isFragment: boolean) => string;
  80832. endOfUniformBufferProcessor?: (closingBracketLine: string, isFragment: boolean) => string;
  80833. lineProcessor?: (line: string, isFragment: boolean) => string;
  80834. preProcessor?: (code: string, defines: string[], isFragment: boolean) => string;
  80835. postProcessor?: (code: string, defines: string[], isFragment: boolean) => string;
  80836. }
  80837. }
  80838. declare module BABYLON {
  80839. /** @hidden */
  80840. export interface ProcessingOptions {
  80841. defines: string[];
  80842. indexParameters: any;
  80843. isFragment: boolean;
  80844. shouldUseHighPrecisionShader: boolean;
  80845. supportsUniformBuffers: boolean;
  80846. shadersRepository: string;
  80847. includesShadersStore: {
  80848. [key: string]: string;
  80849. };
  80850. processor?: IShaderProcessor;
  80851. version: string;
  80852. platformName: string;
  80853. lookForClosingBracketForUniformBuffer?: boolean;
  80854. }
  80855. }
  80856. declare module BABYLON {
  80857. /** @hidden */
  80858. export class ShaderCodeNode {
  80859. line: string;
  80860. children: ShaderCodeNode[];
  80861. additionalDefineKey?: string;
  80862. additionalDefineValue?: string;
  80863. isValid(preprocessors: {
  80864. [key: string]: string;
  80865. }): boolean;
  80866. process(preprocessors: {
  80867. [key: string]: string;
  80868. }, options: ProcessingOptions): string;
  80869. }
  80870. }
  80871. declare module BABYLON {
  80872. /** @hidden */
  80873. export class ShaderCodeCursor {
  80874. private _lines;
  80875. lineIndex: number;
  80876. get currentLine(): string;
  80877. get canRead(): boolean;
  80878. set lines(value: string[]);
  80879. }
  80880. }
  80881. declare module BABYLON {
  80882. /** @hidden */
  80883. export class ShaderCodeConditionNode extends ShaderCodeNode {
  80884. process(preprocessors: {
  80885. [key: string]: string;
  80886. }, options: ProcessingOptions): string;
  80887. }
  80888. }
  80889. declare module BABYLON {
  80890. /** @hidden */
  80891. export class ShaderDefineExpression {
  80892. isTrue(preprocessors: {
  80893. [key: string]: string;
  80894. }): boolean;
  80895. private static _OperatorPriority;
  80896. private static _Stack;
  80897. static postfixToInfix(postfix: string[]): string;
  80898. static infixToPostfix(infix: string): string[];
  80899. }
  80900. }
  80901. declare module BABYLON {
  80902. /** @hidden */
  80903. export class ShaderCodeTestNode extends ShaderCodeNode {
  80904. testExpression: ShaderDefineExpression;
  80905. isValid(preprocessors: {
  80906. [key: string]: string;
  80907. }): boolean;
  80908. }
  80909. }
  80910. declare module BABYLON {
  80911. /** @hidden */
  80912. export class ShaderDefineIsDefinedOperator extends ShaderDefineExpression {
  80913. define: string;
  80914. not: boolean;
  80915. constructor(define: string, not?: boolean);
  80916. isTrue(preprocessors: {
  80917. [key: string]: string;
  80918. }): boolean;
  80919. }
  80920. }
  80921. declare module BABYLON {
  80922. /** @hidden */
  80923. export class ShaderDefineOrOperator extends ShaderDefineExpression {
  80924. leftOperand: ShaderDefineExpression;
  80925. rightOperand: ShaderDefineExpression;
  80926. isTrue(preprocessors: {
  80927. [key: string]: string;
  80928. }): boolean;
  80929. }
  80930. }
  80931. declare module BABYLON {
  80932. /** @hidden */
  80933. export class ShaderDefineAndOperator extends ShaderDefineExpression {
  80934. leftOperand: ShaderDefineExpression;
  80935. rightOperand: ShaderDefineExpression;
  80936. isTrue(preprocessors: {
  80937. [key: string]: string;
  80938. }): boolean;
  80939. }
  80940. }
  80941. declare module BABYLON {
  80942. /** @hidden */
  80943. export class ShaderDefineArithmeticOperator extends ShaderDefineExpression {
  80944. define: string;
  80945. operand: string;
  80946. testValue: string;
  80947. constructor(define: string, operand: string, testValue: string);
  80948. isTrue(preprocessors: {
  80949. [key: string]: string;
  80950. }): boolean;
  80951. }
  80952. }
  80953. declare module BABYLON {
  80954. /**
  80955. * Class used to enable access to offline support
  80956. * @see https://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  80957. */
  80958. export interface IOfflineProvider {
  80959. /**
  80960. * Gets a boolean indicating if scene must be saved in the database
  80961. */
  80962. enableSceneOffline: boolean;
  80963. /**
  80964. * Gets a boolean indicating if textures must be saved in the database
  80965. */
  80966. enableTexturesOffline: boolean;
  80967. /**
  80968. * Open the offline support and make it available
  80969. * @param successCallback defines the callback to call on success
  80970. * @param errorCallback defines the callback to call on error
  80971. */
  80972. open(successCallback: () => void, errorCallback: () => void): void;
  80973. /**
  80974. * Loads an image from the offline support
  80975. * @param url defines the url to load from
  80976. * @param image defines the target DOM image
  80977. */
  80978. loadImage(url: string, image: HTMLImageElement): void;
  80979. /**
  80980. * Loads a file from offline support
  80981. * @param url defines the URL to load from
  80982. * @param sceneLoaded defines a callback to call on success
  80983. * @param progressCallBack defines a callback to call when progress changed
  80984. * @param errorCallback defines a callback to call on error
  80985. * @param useArrayBuffer defines a boolean to use array buffer instead of text string
  80986. */
  80987. loadFile(url: string, sceneLoaded: (data: any) => void, progressCallBack?: (data: any) => void, errorCallback?: () => void, useArrayBuffer?: boolean): void;
  80988. }
  80989. }
  80990. declare module BABYLON {
  80991. /**
  80992. * Class used to help managing file picking and drag'n'drop
  80993. * File Storage
  80994. */
  80995. export class FilesInputStore {
  80996. /**
  80997. * List of files ready to be loaded
  80998. */
  80999. static FilesToLoad: {
  81000. [key: string]: File;
  81001. };
  81002. }
  81003. }
  81004. declare module BABYLON {
  81005. /**
  81006. * Class used to define a retry strategy when error happens while loading assets
  81007. */
  81008. export class RetryStrategy {
  81009. /**
  81010. * Function used to defines an exponential back off strategy
  81011. * @param maxRetries defines the maximum number of retries (3 by default)
  81012. * @param baseInterval defines the interval between retries
  81013. * @returns the strategy function to use
  81014. */
  81015. static ExponentialBackoff(maxRetries?: number, baseInterval?: number): (url: string, request: WebRequest, retryIndex: number) => number;
  81016. }
  81017. }
  81018. declare module BABYLON {
  81019. /**
  81020. * @ignore
  81021. * Application error to support additional information when loading a file
  81022. */
  81023. export abstract class BaseError extends Error {
  81024. protected static _setPrototypeOf: (o: any, proto: object | null) => any;
  81025. }
  81026. }
  81027. declare module BABYLON {
  81028. /** @ignore */
  81029. export class LoadFileError extends BaseError {
  81030. request?: WebRequest;
  81031. file?: File;
  81032. /**
  81033. * Creates a new LoadFileError
  81034. * @param message defines the message of the error
  81035. * @param request defines the optional web request
  81036. * @param file defines the optional file
  81037. */
  81038. constructor(message: string, object?: WebRequest | File);
  81039. }
  81040. /** @ignore */
  81041. export class RequestFileError extends BaseError {
  81042. request: WebRequest;
  81043. /**
  81044. * Creates a new LoadFileError
  81045. * @param message defines the message of the error
  81046. * @param request defines the optional web request
  81047. */
  81048. constructor(message: string, request: WebRequest);
  81049. }
  81050. /** @ignore */
  81051. export class ReadFileError extends BaseError {
  81052. file: File;
  81053. /**
  81054. * Creates a new ReadFileError
  81055. * @param message defines the message of the error
  81056. * @param file defines the optional file
  81057. */
  81058. constructor(message: string, file: File);
  81059. }
  81060. /**
  81061. * @hidden
  81062. */
  81063. export class FileTools {
  81064. /**
  81065. * Gets or sets the retry strategy to apply when an error happens while loading an asset
  81066. */
  81067. static DefaultRetryStrategy: (url: string, request: WebRequest, retryIndex: number) => number;
  81068. /**
  81069. * Gets or sets the base URL to use to load assets
  81070. */
  81071. static BaseUrl: string;
  81072. /**
  81073. * Default behaviour for cors in the application.
  81074. * It can be a string if the expected behavior is identical in the entire app.
  81075. * Or a callback to be able to set it per url or on a group of them (in case of Video source for instance)
  81076. */
  81077. static CorsBehavior: string | ((url: string | string[]) => string);
  81078. /**
  81079. * Gets or sets a function used to pre-process url before using them to load assets
  81080. */
  81081. static PreprocessUrl: (url: string) => string;
  81082. /**
  81083. * Removes unwanted characters from an url
  81084. * @param url defines the url to clean
  81085. * @returns the cleaned url
  81086. */
  81087. private static _CleanUrl;
  81088. /**
  81089. * Sets the cors behavior on a dom element. This will add the required Tools.CorsBehavior to the element.
  81090. * @param url define the url we are trying
  81091. * @param element define the dom element where to configure the cors policy
  81092. */
  81093. static SetCorsBehavior(url: string | string[], element: {
  81094. crossOrigin: string | null;
  81095. }): void;
  81096. /**
  81097. * Loads an image as an HTMLImageElement.
  81098. * @param input url string, ArrayBuffer, or Blob to load
  81099. * @param onLoad callback called when the image successfully loads
  81100. * @param onError callback called when the image fails to load
  81101. * @param offlineProvider offline provider for caching
  81102. * @param mimeType optional mime type
  81103. * @returns the HTMLImageElement of the loaded image
  81104. */
  81105. 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>;
  81106. /**
  81107. * Reads a file from a File object
  81108. * @param file defines the file to load
  81109. * @param onSuccess defines the callback to call when data is loaded
  81110. * @param onProgress defines the callback to call during loading process
  81111. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  81112. * @param onError defines the callback to call when an error occurs
  81113. * @returns a file request object
  81114. */
  81115. static ReadFile(file: File, onSuccess: (data: any) => void, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: ReadFileError) => void): IFileRequest;
  81116. /**
  81117. * Loads a file from a url
  81118. * @param url url to load
  81119. * @param onSuccess callback called when the file successfully loads
  81120. * @param onProgress callback called while file is loading (if the server supports this mode)
  81121. * @param offlineProvider defines the offline provider for caching
  81122. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  81123. * @param onError callback called when the file fails to load
  81124. * @returns a file request object
  81125. */
  81126. 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;
  81127. /**
  81128. * Loads a file
  81129. * @param url url to load
  81130. * @param onSuccess callback called when the file successfully loads
  81131. * @param onProgress callback called while file is loading (if the server supports this mode)
  81132. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  81133. * @param onError callback called when the file fails to load
  81134. * @param onOpened callback called when the web request is opened
  81135. * @returns a file request object
  81136. */
  81137. 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;
  81138. /**
  81139. * Checks if the loaded document was accessed via `file:`-Protocol.
  81140. * @returns boolean
  81141. */
  81142. static IsFileURL(): boolean;
  81143. }
  81144. }
  81145. declare module BABYLON {
  81146. /** @hidden */
  81147. export class ShaderProcessor {
  81148. static Process(sourceCode: string, options: ProcessingOptions, callback: (migratedCode: string) => void): void;
  81149. private static _ProcessPrecision;
  81150. private static _ExtractOperation;
  81151. private static _BuildSubExpression;
  81152. private static _BuildExpression;
  81153. private static _MoveCursorWithinIf;
  81154. private static _MoveCursor;
  81155. private static _EvaluatePreProcessors;
  81156. private static _PreparePreProcessors;
  81157. private static _ProcessShaderConversion;
  81158. private static _ProcessIncludes;
  81159. /**
  81160. * Loads a file from a url
  81161. * @param url url to load
  81162. * @param onSuccess callback called when the file successfully loads
  81163. * @param onProgress callback called while file is loading (if the server supports this mode)
  81164. * @param offlineProvider defines the offline provider for caching
  81165. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  81166. * @param onError callback called when the file fails to load
  81167. * @returns a file request object
  81168. * @hidden
  81169. */
  81170. 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;
  81171. }
  81172. }
  81173. declare module BABYLON {
  81174. /**
  81175. * @hidden
  81176. */
  81177. export interface IColor4Like {
  81178. r: float;
  81179. g: float;
  81180. b: float;
  81181. a: float;
  81182. }
  81183. /**
  81184. * @hidden
  81185. */
  81186. export interface IColor3Like {
  81187. r: float;
  81188. g: float;
  81189. b: float;
  81190. }
  81191. /**
  81192. * @hidden
  81193. */
  81194. export interface IVector4Like {
  81195. x: float;
  81196. y: float;
  81197. z: float;
  81198. w: float;
  81199. }
  81200. /**
  81201. * @hidden
  81202. */
  81203. export interface IVector3Like {
  81204. x: float;
  81205. y: float;
  81206. z: float;
  81207. }
  81208. /**
  81209. * @hidden
  81210. */
  81211. export interface IVector2Like {
  81212. x: float;
  81213. y: float;
  81214. }
  81215. /**
  81216. * @hidden
  81217. */
  81218. export interface IMatrixLike {
  81219. toArray(): DeepImmutable<Float32Array | Array<number>>;
  81220. updateFlag: int;
  81221. }
  81222. /**
  81223. * @hidden
  81224. */
  81225. export interface IViewportLike {
  81226. x: float;
  81227. y: float;
  81228. width: float;
  81229. height: float;
  81230. }
  81231. /**
  81232. * @hidden
  81233. */
  81234. export interface IPlaneLike {
  81235. normal: IVector3Like;
  81236. d: float;
  81237. normalize(): void;
  81238. }
  81239. }
  81240. declare module BABYLON {
  81241. /**
  81242. * Interface used to define common properties for effect fallbacks
  81243. */
  81244. export interface IEffectFallbacks {
  81245. /**
  81246. * Removes the defines that should be removed when falling back.
  81247. * @param currentDefines defines the current define statements for the shader.
  81248. * @param effect defines the current effect we try to compile
  81249. * @returns The resulting defines with defines of the current rank removed.
  81250. */
  81251. reduce(currentDefines: string, effect: Effect): string;
  81252. /**
  81253. * Removes the fallback from the bound mesh.
  81254. */
  81255. unBindMesh(): void;
  81256. /**
  81257. * Checks to see if more fallbacks are still availible.
  81258. */
  81259. hasMoreFallbacks: boolean;
  81260. }
  81261. }
  81262. declare module BABYLON {
  81263. /**
  81264. * Class used to evalaute queries containing `and` and `or` operators
  81265. */
  81266. export class AndOrNotEvaluator {
  81267. /**
  81268. * Evaluate a query
  81269. * @param query defines the query to evaluate
  81270. * @param evaluateCallback defines the callback used to filter result
  81271. * @returns true if the query matches
  81272. */
  81273. static Eval(query: string, evaluateCallback: (val: any) => boolean): boolean;
  81274. private static _HandleParenthesisContent;
  81275. private static _SimplifyNegation;
  81276. }
  81277. }
  81278. declare module BABYLON {
  81279. /**
  81280. * Class used to store custom tags
  81281. */
  81282. export class Tags {
  81283. /**
  81284. * Adds support for tags on the given object
  81285. * @param obj defines the object to use
  81286. */
  81287. static EnableFor(obj: any): void;
  81288. /**
  81289. * Removes tags support
  81290. * @param obj defines the object to use
  81291. */
  81292. static DisableFor(obj: any): void;
  81293. /**
  81294. * Gets a boolean indicating if the given object has tags
  81295. * @param obj defines the object to use
  81296. * @returns a boolean
  81297. */
  81298. static HasTags(obj: any): boolean;
  81299. /**
  81300. * Gets the tags available on a given object
  81301. * @param obj defines the object to use
  81302. * @param asString defines if the tags must be returned as a string instead of an array of strings
  81303. * @returns the tags
  81304. */
  81305. static GetTags(obj: any, asString?: boolean): any;
  81306. /**
  81307. * Adds tags to an object
  81308. * @param obj defines the object to use
  81309. * @param tagsString defines the tag string. The tags 'true' and 'false' are reserved and cannot be used as tags.
  81310. * A tag cannot start with '||', '&&', and '!'. It cannot contain whitespaces
  81311. */
  81312. static AddTagsTo(obj: any, tagsString: string): void;
  81313. /**
  81314. * @hidden
  81315. */
  81316. static _AddTagTo(obj: any, tag: string): void;
  81317. /**
  81318. * Removes specific tags from a specific object
  81319. * @param obj defines the object to use
  81320. * @param tagsString defines the tags to remove
  81321. */
  81322. static RemoveTagsFrom(obj: any, tagsString: string): void;
  81323. /**
  81324. * @hidden
  81325. */
  81326. static _RemoveTagFrom(obj: any, tag: string): void;
  81327. /**
  81328. * Defines if tags hosted on an object match a given query
  81329. * @param obj defines the object to use
  81330. * @param tagsQuery defines the tag query
  81331. * @returns a boolean
  81332. */
  81333. static MatchesQuery(obj: any, tagsQuery: string): boolean;
  81334. }
  81335. }
  81336. declare module BABYLON {
  81337. /**
  81338. * Scalar computation library
  81339. */
  81340. export class Scalar {
  81341. /**
  81342. * Two pi constants convenient for computation.
  81343. */
  81344. static TwoPi: number;
  81345. /**
  81346. * Boolean : true if the absolute difference between a and b is lower than epsilon (default = 1.401298E-45)
  81347. * @param a number
  81348. * @param b number
  81349. * @param epsilon (default = 1.401298E-45)
  81350. * @returns true if the absolute difference between a and b is lower than epsilon (default = 1.401298E-45)
  81351. */
  81352. static WithinEpsilon(a: number, b: number, epsilon?: number): boolean;
  81353. /**
  81354. * Returns a string : the upper case translation of the number i to hexadecimal.
  81355. * @param i number
  81356. * @returns the upper case translation of the number i to hexadecimal.
  81357. */
  81358. static ToHex(i: number): string;
  81359. /**
  81360. * Returns -1 if value is negative and +1 is value is positive.
  81361. * @param value the value
  81362. * @returns the value itself if it's equal to zero.
  81363. */
  81364. static Sign(value: number): number;
  81365. /**
  81366. * Returns the value itself if it's between min and max.
  81367. * Returns min if the value is lower than min.
  81368. * Returns max if the value is greater than max.
  81369. * @param value the value to clmap
  81370. * @param min the min value to clamp to (default: 0)
  81371. * @param max the max value to clamp to (default: 1)
  81372. * @returns the clamped value
  81373. */
  81374. static Clamp(value: number, min?: number, max?: number): number;
  81375. /**
  81376. * the log2 of value.
  81377. * @param value the value to compute log2 of
  81378. * @returns the log2 of value.
  81379. */
  81380. static Log2(value: number): number;
  81381. /**
  81382. * Loops the value, so that it is never larger than length and never smaller than 0.
  81383. *
  81384. * This is similar to the modulo operator but it works with floating point numbers.
  81385. * For example, using 3.0 for t and 2.5 for length, the result would be 0.5.
  81386. * With t = 5 and length = 2.5, the result would be 0.0.
  81387. * Note, however, that the behaviour is not defined for negative numbers as it is for the modulo operator
  81388. * @param value the value
  81389. * @param length the length
  81390. * @returns the looped value
  81391. */
  81392. static Repeat(value: number, length: number): number;
  81393. /**
  81394. * Normalize the value between 0.0 and 1.0 using min and max values
  81395. * @param value value to normalize
  81396. * @param min max to normalize between
  81397. * @param max min to normalize between
  81398. * @returns the normalized value
  81399. */
  81400. static Normalize(value: number, min: number, max: number): number;
  81401. /**
  81402. * Denormalize the value from 0.0 and 1.0 using min and max values
  81403. * @param normalized value to denormalize
  81404. * @param min max to denormalize between
  81405. * @param max min to denormalize between
  81406. * @returns the denormalized value
  81407. */
  81408. static Denormalize(normalized: number, min: number, max: number): number;
  81409. /**
  81410. * Calculates the shortest difference between two given angles given in degrees.
  81411. * @param current current angle in degrees
  81412. * @param target target angle in degrees
  81413. * @returns the delta
  81414. */
  81415. static DeltaAngle(current: number, target: number): number;
  81416. /**
  81417. * PingPongs the value t, so that it is never larger than length and never smaller than 0.
  81418. * @param tx value
  81419. * @param length length
  81420. * @returns The returned value will move back and forth between 0 and length
  81421. */
  81422. static PingPong(tx: number, length: number): number;
  81423. /**
  81424. * Interpolates between min and max with smoothing at the limits.
  81425. *
  81426. * This function interpolates between min and max in a similar way to Lerp. However, the interpolation will gradually speed up
  81427. * from the start and slow down toward the end. This is useful for creating natural-looking animation, fading and other transitions.
  81428. * @param from from
  81429. * @param to to
  81430. * @param tx value
  81431. * @returns the smooth stepped value
  81432. */
  81433. static SmoothStep(from: number, to: number, tx: number): number;
  81434. /**
  81435. * Moves a value current towards target.
  81436. *
  81437. * This is essentially the same as Mathf.Lerp but instead the function will ensure that the speed never exceeds maxDelta.
  81438. * Negative values of maxDelta pushes the value away from target.
  81439. * @param current current value
  81440. * @param target target value
  81441. * @param maxDelta max distance to move
  81442. * @returns resulting value
  81443. */
  81444. static MoveTowards(current: number, target: number, maxDelta: number): number;
  81445. /**
  81446. * Same as MoveTowards but makes sure the values interpolate correctly when they wrap around 360 degrees.
  81447. *
  81448. * Variables current and target are assumed to be in degrees. For optimization reasons, negative values of maxDelta
  81449. * are not supported and may cause oscillation. To push current away from a target angle, add 180 to that angle instead.
  81450. * @param current current value
  81451. * @param target target value
  81452. * @param maxDelta max distance to move
  81453. * @returns resulting angle
  81454. */
  81455. static MoveTowardsAngle(current: number, target: number, maxDelta: number): number;
  81456. /**
  81457. * Creates a new scalar with values linearly interpolated of "amount" between the start scalar and the end scalar.
  81458. * @param start start value
  81459. * @param end target value
  81460. * @param amount amount to lerp between
  81461. * @returns the lerped value
  81462. */
  81463. static Lerp(start: number, end: number, amount: number): number;
  81464. /**
  81465. * Same as Lerp but makes sure the values interpolate correctly when they wrap around 360 degrees.
  81466. * The parameter t is clamped to the range [0, 1]. Variables a and b are assumed to be in degrees.
  81467. * @param start start value
  81468. * @param end target value
  81469. * @param amount amount to lerp between
  81470. * @returns the lerped value
  81471. */
  81472. static LerpAngle(start: number, end: number, amount: number): number;
  81473. /**
  81474. * Calculates the linear parameter t that produces the interpolant value within the range [a, b].
  81475. * @param a start value
  81476. * @param b target value
  81477. * @param value value between a and b
  81478. * @returns the inverseLerp value
  81479. */
  81480. static InverseLerp(a: number, b: number, value: number): number;
  81481. /**
  81482. * Returns a new scalar located for "amount" (float) on the Hermite spline defined by the scalars "value1", "value3", "tangent1", "tangent2".
  81483. * @see http://mathworld.wolfram.com/HermitePolynomial.html
  81484. * @param value1 spline value
  81485. * @param tangent1 spline value
  81486. * @param value2 spline value
  81487. * @param tangent2 spline value
  81488. * @param amount input value
  81489. * @returns hermite result
  81490. */
  81491. static Hermite(value1: number, tangent1: number, value2: number, tangent2: number, amount: number): number;
  81492. /**
  81493. * Returns a random float number between and min and max values
  81494. * @param min min value of random
  81495. * @param max max value of random
  81496. * @returns random value
  81497. */
  81498. static RandomRange(min: number, max: number): number;
  81499. /**
  81500. * This function returns percentage of a number in a given range.
  81501. *
  81502. * RangeToPercent(40,20,60) will return 0.5 (50%)
  81503. * RangeToPercent(34,0,100) will return 0.34 (34%)
  81504. * @param number to convert to percentage
  81505. * @param min min range
  81506. * @param max max range
  81507. * @returns the percentage
  81508. */
  81509. static RangeToPercent(number: number, min: number, max: number): number;
  81510. /**
  81511. * This function returns number that corresponds to the percentage in a given range.
  81512. *
  81513. * PercentToRange(0.34,0,100) will return 34.
  81514. * @param percent to convert to number
  81515. * @param min min range
  81516. * @param max max range
  81517. * @returns the number
  81518. */
  81519. static PercentToRange(percent: number, min: number, max: number): number;
  81520. /**
  81521. * Returns the angle converted to equivalent value between -Math.PI and Math.PI radians.
  81522. * @param angle The angle to normalize in radian.
  81523. * @return The converted angle.
  81524. */
  81525. static NormalizeRadians(angle: number): number;
  81526. }
  81527. }
  81528. declare module BABYLON {
  81529. /**
  81530. * Constant used to convert a value to gamma space
  81531. * @ignorenaming
  81532. */
  81533. export const ToGammaSpace: number;
  81534. /**
  81535. * Constant used to convert a value to linear space
  81536. * @ignorenaming
  81537. */
  81538. export const ToLinearSpace = 2.2;
  81539. /**
  81540. * Constant used to define the minimal number value in Babylon.js
  81541. * @ignorenaming
  81542. */
  81543. let Epsilon: number;
  81544. }
  81545. declare module BABYLON {
  81546. /**
  81547. * Class used to represent a viewport on screen
  81548. */
  81549. export class Viewport {
  81550. /** viewport left coordinate */
  81551. x: number;
  81552. /** viewport top coordinate */
  81553. y: number;
  81554. /**viewport width */
  81555. width: number;
  81556. /** viewport height */
  81557. height: number;
  81558. /**
  81559. * Creates a Viewport object located at (x, y) and sized (width, height)
  81560. * @param x defines viewport left coordinate
  81561. * @param y defines viewport top coordinate
  81562. * @param width defines the viewport width
  81563. * @param height defines the viewport height
  81564. */
  81565. constructor(
  81566. /** viewport left coordinate */
  81567. x: number,
  81568. /** viewport top coordinate */
  81569. y: number,
  81570. /**viewport width */
  81571. width: number,
  81572. /** viewport height */
  81573. height: number);
  81574. /**
  81575. * Creates a new viewport using absolute sizing (from 0-> width, 0-> height instead of 0->1)
  81576. * @param renderWidth defines the rendering width
  81577. * @param renderHeight defines the rendering height
  81578. * @returns a new Viewport
  81579. */
  81580. toGlobal(renderWidth: number, renderHeight: number): Viewport;
  81581. /**
  81582. * Stores absolute viewport value into a target viewport (from 0-> width, 0-> height instead of 0->1)
  81583. * @param renderWidth defines the rendering width
  81584. * @param renderHeight defines the rendering height
  81585. * @param ref defines the target viewport
  81586. * @returns the current viewport
  81587. */
  81588. toGlobalToRef(renderWidth: number, renderHeight: number, ref: Viewport): Viewport;
  81589. /**
  81590. * Returns a new Viewport copied from the current one
  81591. * @returns a new Viewport
  81592. */
  81593. clone(): Viewport;
  81594. }
  81595. }
  81596. declare module BABYLON {
  81597. /**
  81598. * Class containing a set of static utilities functions for arrays.
  81599. */
  81600. export class ArrayTools {
  81601. /**
  81602. * Returns an array of the given size filled with element built from the given constructor and the paramters
  81603. * @param size the number of element to construct and put in the array
  81604. * @param itemBuilder a callback responsible for creating new instance of item. Called once per array entry.
  81605. * @returns a new array filled with new objects
  81606. */
  81607. static BuildArray<T>(size: number, itemBuilder: () => T): Array<T>;
  81608. }
  81609. }
  81610. declare module BABYLON {
  81611. /**
  81612. * Represents a plane by the equation ax + by + cz + d = 0
  81613. */
  81614. export class Plane {
  81615. private static _TmpMatrix;
  81616. /**
  81617. * Normal of the plane (a,b,c)
  81618. */
  81619. normal: Vector3;
  81620. /**
  81621. * d component of the plane
  81622. */
  81623. d: number;
  81624. /**
  81625. * Creates a Plane object according to the given floats a, b, c, d and the plane equation : ax + by + cz + d = 0
  81626. * @param a a component of the plane
  81627. * @param b b component of the plane
  81628. * @param c c component of the plane
  81629. * @param d d component of the plane
  81630. */
  81631. constructor(a: number, b: number, c: number, d: number);
  81632. /**
  81633. * @returns the plane coordinates as a new array of 4 elements [a, b, c, d].
  81634. */
  81635. asArray(): number[];
  81636. /**
  81637. * @returns a new plane copied from the current Plane.
  81638. */
  81639. clone(): Plane;
  81640. /**
  81641. * @returns the string "Plane".
  81642. */
  81643. getClassName(): string;
  81644. /**
  81645. * @returns the Plane hash code.
  81646. */
  81647. getHashCode(): number;
  81648. /**
  81649. * Normalize the current Plane in place.
  81650. * @returns the updated Plane.
  81651. */
  81652. normalize(): Plane;
  81653. /**
  81654. * Applies a transformation the plane and returns the result
  81655. * @param transformation the transformation matrix to be applied to the plane
  81656. * @returns a new Plane as the result of the transformation of the current Plane by the given matrix.
  81657. */
  81658. transform(transformation: DeepImmutable<Matrix>): Plane;
  81659. /**
  81660. * Compute the dot product between the point and the plane normal
  81661. * @param point point to calculate the dot product with
  81662. * @returns the dot product (float) of the point coordinates and the plane normal.
  81663. */
  81664. dotCoordinate(point: DeepImmutable<Vector3>): number;
  81665. /**
  81666. * Updates the current Plane from the plane defined by the three given points.
  81667. * @param point1 one of the points used to contruct the plane
  81668. * @param point2 one of the points used to contruct the plane
  81669. * @param point3 one of the points used to contruct the plane
  81670. * @returns the updated Plane.
  81671. */
  81672. copyFromPoints(point1: DeepImmutable<Vector3>, point2: DeepImmutable<Vector3>, point3: DeepImmutable<Vector3>): Plane;
  81673. /**
  81674. * Checks if the plane is facing a given direction
  81675. * @param direction the direction to check if the plane is facing
  81676. * @param epsilon value the dot product is compared against (returns true if dot <= epsilon)
  81677. * @returns True is the vector "direction" is the same side than the plane normal.
  81678. */
  81679. isFrontFacingTo(direction: DeepImmutable<Vector3>, epsilon: number): boolean;
  81680. /**
  81681. * Calculates the distance to a point
  81682. * @param point point to calculate distance to
  81683. * @returns the signed distance (float) from the given point to the Plane.
  81684. */
  81685. signedDistanceTo(point: DeepImmutable<Vector3>): number;
  81686. /**
  81687. * Creates a plane from an array
  81688. * @param array the array to create a plane from
  81689. * @returns a new Plane from the given array.
  81690. */
  81691. static FromArray(array: DeepImmutable<ArrayLike<number>>): Plane;
  81692. /**
  81693. * Creates a plane from three points
  81694. * @param point1 point used to create the plane
  81695. * @param point2 point used to create the plane
  81696. * @param point3 point used to create the plane
  81697. * @returns a new Plane defined by the three given points.
  81698. */
  81699. static FromPoints(point1: DeepImmutable<Vector3>, point2: DeepImmutable<Vector3>, point3: DeepImmutable<Vector3>): Plane;
  81700. /**
  81701. * Creates a plane from an origin point and a normal
  81702. * @param origin origin of the plane to be constructed
  81703. * @param normal normal of the plane to be constructed
  81704. * @returns a new Plane the normal vector to this plane at the given origin point.
  81705. * Note : the vector "normal" is updated because normalized.
  81706. */
  81707. static FromPositionAndNormal(origin: DeepImmutable<Vector3>, normal: Vector3): Plane;
  81708. /**
  81709. * Calculates the distance from a plane and a point
  81710. * @param origin origin of the plane to be constructed
  81711. * @param normal normal of the plane to be constructed
  81712. * @param point point to calculate distance to
  81713. * @returns the signed distance between the plane defined by the normal vector at the "origin"" point and the given other point.
  81714. */
  81715. static SignedDistanceToPlaneFromPositionAndNormal(origin: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>, point: DeepImmutable<Vector3>): number;
  81716. }
  81717. }
  81718. declare module BABYLON {
  81719. /** @hidden */
  81720. export class PerformanceConfigurator {
  81721. /** @hidden */
  81722. static MatrixUse64Bits: boolean;
  81723. /** @hidden */
  81724. static MatrixTrackPrecisionChange: boolean;
  81725. /** @hidden */
  81726. static MatrixCurrentType: any;
  81727. /** @hidden */
  81728. static MatrixTrackedMatrices: Array<any> | null;
  81729. /** @hidden */
  81730. static SetMatrixPrecision(use64bits: boolean): void;
  81731. }
  81732. }
  81733. declare module BABYLON {
  81734. /**
  81735. * Class representing a vector containing 2 coordinates
  81736. */
  81737. export class Vector2 {
  81738. /** defines the first coordinate */
  81739. x: number;
  81740. /** defines the second coordinate */
  81741. y: number;
  81742. /**
  81743. * Creates a new Vector2 from the given x and y coordinates
  81744. * @param x defines the first coordinate
  81745. * @param y defines the second coordinate
  81746. */
  81747. constructor(
  81748. /** defines the first coordinate */
  81749. x?: number,
  81750. /** defines the second coordinate */
  81751. y?: number);
  81752. /**
  81753. * Gets a string with the Vector2 coordinates
  81754. * @returns a string with the Vector2 coordinates
  81755. */
  81756. toString(): string;
  81757. /**
  81758. * Gets class name
  81759. * @returns the string "Vector2"
  81760. */
  81761. getClassName(): string;
  81762. /**
  81763. * Gets current vector hash code
  81764. * @returns the Vector2 hash code as a number
  81765. */
  81766. getHashCode(): number;
  81767. /**
  81768. * Sets the Vector2 coordinates in the given array or Float32Array from the given index.
  81769. * @param array defines the source array
  81770. * @param index defines the offset in source array
  81771. * @returns the current Vector2
  81772. */
  81773. toArray(array: FloatArray, index?: number): Vector2;
  81774. /**
  81775. * Update the current vector from an array
  81776. * @param array defines the destination array
  81777. * @param index defines the offset in the destination array
  81778. * @returns the current Vector3
  81779. */
  81780. fromArray(array: FloatArray, index?: number): Vector2;
  81781. /**
  81782. * Copy the current vector to an array
  81783. * @returns a new array with 2 elements: the Vector2 coordinates.
  81784. */
  81785. asArray(): number[];
  81786. /**
  81787. * Sets the Vector2 coordinates with the given Vector2 coordinates
  81788. * @param source defines the source Vector2
  81789. * @returns the current updated Vector2
  81790. */
  81791. copyFrom(source: DeepImmutable<Vector2>): Vector2;
  81792. /**
  81793. * Sets the Vector2 coordinates with the given floats
  81794. * @param x defines the first coordinate
  81795. * @param y defines the second coordinate
  81796. * @returns the current updated Vector2
  81797. */
  81798. copyFromFloats(x: number, y: number): Vector2;
  81799. /**
  81800. * Sets the Vector2 coordinates with the given floats
  81801. * @param x defines the first coordinate
  81802. * @param y defines the second coordinate
  81803. * @returns the current updated Vector2
  81804. */
  81805. set(x: number, y: number): Vector2;
  81806. /**
  81807. * Add another vector with the current one
  81808. * @param otherVector defines the other vector
  81809. * @returns a new Vector2 set with the addition of the current Vector2 and the given one coordinates
  81810. */
  81811. add(otherVector: DeepImmutable<Vector2>): Vector2;
  81812. /**
  81813. * Sets the "result" coordinates with the addition of the current Vector2 and the given one coordinates
  81814. * @param otherVector defines the other vector
  81815. * @param result defines the target vector
  81816. * @returns the unmodified current Vector2
  81817. */
  81818. addToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  81819. /**
  81820. * Set the Vector2 coordinates by adding the given Vector2 coordinates
  81821. * @param otherVector defines the other vector
  81822. * @returns the current updated Vector2
  81823. */
  81824. addInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  81825. /**
  81826. * Gets a new Vector2 by adding the current Vector2 coordinates to the given Vector3 x, y coordinates
  81827. * @param otherVector defines the other vector
  81828. * @returns a new Vector2
  81829. */
  81830. addVector3(otherVector: Vector3): Vector2;
  81831. /**
  81832. * Gets a new Vector2 set with the subtracted coordinates of the given one from the current Vector2
  81833. * @param otherVector defines the other vector
  81834. * @returns a new Vector2
  81835. */
  81836. subtract(otherVector: Vector2): Vector2;
  81837. /**
  81838. * Sets the "result" coordinates with the subtraction of the given one from the current Vector2 coordinates.
  81839. * @param otherVector defines the other vector
  81840. * @param result defines the target vector
  81841. * @returns the unmodified current Vector2
  81842. */
  81843. subtractToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  81844. /**
  81845. * Sets the current Vector2 coordinates by subtracting from it the given one coordinates
  81846. * @param otherVector defines the other vector
  81847. * @returns the current updated Vector2
  81848. */
  81849. subtractInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  81850. /**
  81851. * Multiplies in place the current Vector2 coordinates by the given ones
  81852. * @param otherVector defines the other vector
  81853. * @returns the current updated Vector2
  81854. */
  81855. multiplyInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  81856. /**
  81857. * Returns a new Vector2 set with the multiplication of the current Vector2 and the given one coordinates
  81858. * @param otherVector defines the other vector
  81859. * @returns a new Vector2
  81860. */
  81861. multiply(otherVector: DeepImmutable<Vector2>): Vector2;
  81862. /**
  81863. * Sets "result" coordinates with the multiplication of the current Vector2 and the given one coordinates
  81864. * @param otherVector defines the other vector
  81865. * @param result defines the target vector
  81866. * @returns the unmodified current Vector2
  81867. */
  81868. multiplyToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  81869. /**
  81870. * Gets a new Vector2 set with the Vector2 coordinates multiplied by the given floats
  81871. * @param x defines the first coordinate
  81872. * @param y defines the second coordinate
  81873. * @returns a new Vector2
  81874. */
  81875. multiplyByFloats(x: number, y: number): Vector2;
  81876. /**
  81877. * Returns a new Vector2 set with the Vector2 coordinates divided by the given one coordinates
  81878. * @param otherVector defines the other vector
  81879. * @returns a new Vector2
  81880. */
  81881. divide(otherVector: Vector2): Vector2;
  81882. /**
  81883. * Sets the "result" coordinates with the Vector2 divided by the given one coordinates
  81884. * @param otherVector defines the other vector
  81885. * @param result defines the target vector
  81886. * @returns the unmodified current Vector2
  81887. */
  81888. divideToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  81889. /**
  81890. * Divides the current Vector2 coordinates by the given ones
  81891. * @param otherVector defines the other vector
  81892. * @returns the current updated Vector2
  81893. */
  81894. divideInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  81895. /**
  81896. * Gets a new Vector2 with current Vector2 negated coordinates
  81897. * @returns a new Vector2
  81898. */
  81899. negate(): Vector2;
  81900. /**
  81901. * Negate this vector in place
  81902. * @returns this
  81903. */
  81904. negateInPlace(): Vector2;
  81905. /**
  81906. * Negate the current Vector2 and stores the result in the given vector "result" coordinates
  81907. * @param result defines the Vector3 object where to store the result
  81908. * @returns the current Vector2
  81909. */
  81910. negateToRef(result: Vector2): Vector2;
  81911. /**
  81912. * Multiply the Vector2 coordinates by scale
  81913. * @param scale defines the scaling factor
  81914. * @returns the current updated Vector2
  81915. */
  81916. scaleInPlace(scale: number): Vector2;
  81917. /**
  81918. * Returns a new Vector2 scaled by "scale" from the current Vector2
  81919. * @param scale defines the scaling factor
  81920. * @returns a new Vector2
  81921. */
  81922. scale(scale: number): Vector2;
  81923. /**
  81924. * Scale the current Vector2 values by a factor to a given Vector2
  81925. * @param scale defines the scale factor
  81926. * @param result defines the Vector2 object where to store the result
  81927. * @returns the unmodified current Vector2
  81928. */
  81929. scaleToRef(scale: number, result: Vector2): Vector2;
  81930. /**
  81931. * Scale the current Vector2 values by a factor and add the result to a given Vector2
  81932. * @param scale defines the scale factor
  81933. * @param result defines the Vector2 object where to store the result
  81934. * @returns the unmodified current Vector2
  81935. */
  81936. scaleAndAddToRef(scale: number, result: Vector2): Vector2;
  81937. /**
  81938. * Gets a boolean if two vectors are equals
  81939. * @param otherVector defines the other vector
  81940. * @returns true if the given vector coordinates strictly equal the current Vector2 ones
  81941. */
  81942. equals(otherVector: DeepImmutable<Vector2>): boolean;
  81943. /**
  81944. * Gets a boolean if two vectors are equals (using an epsilon value)
  81945. * @param otherVector defines the other vector
  81946. * @param epsilon defines the minimal distance to consider equality
  81947. * @returns true if the given vector coordinates are close to the current ones by a distance of epsilon.
  81948. */
  81949. equalsWithEpsilon(otherVector: DeepImmutable<Vector2>, epsilon?: number): boolean;
  81950. /**
  81951. * Gets a new Vector2 from current Vector2 floored values
  81952. * @returns a new Vector2
  81953. */
  81954. floor(): Vector2;
  81955. /**
  81956. * Gets a new Vector2 from current Vector2 floored values
  81957. * @returns a new Vector2
  81958. */
  81959. fract(): Vector2;
  81960. /**
  81961. * Gets the length of the vector
  81962. * @returns the vector length (float)
  81963. */
  81964. length(): number;
  81965. /**
  81966. * Gets the vector squared length
  81967. * @returns the vector squared length (float)
  81968. */
  81969. lengthSquared(): number;
  81970. /**
  81971. * Normalize the vector
  81972. * @returns the current updated Vector2
  81973. */
  81974. normalize(): Vector2;
  81975. /**
  81976. * Gets a new Vector2 copied from the Vector2
  81977. * @returns a new Vector2
  81978. */
  81979. clone(): Vector2;
  81980. /**
  81981. * Gets a new Vector2(0, 0)
  81982. * @returns a new Vector2
  81983. */
  81984. static Zero(): Vector2;
  81985. /**
  81986. * Gets a new Vector2(1, 1)
  81987. * @returns a new Vector2
  81988. */
  81989. static One(): Vector2;
  81990. /**
  81991. * Gets a new Vector2 set from the given index element of the given array
  81992. * @param array defines the data source
  81993. * @param offset defines the offset in the data source
  81994. * @returns a new Vector2
  81995. */
  81996. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector2;
  81997. /**
  81998. * Sets "result" from the given index element of the given array
  81999. * @param array defines the data source
  82000. * @param offset defines the offset in the data source
  82001. * @param result defines the target vector
  82002. */
  82003. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector2): void;
  82004. /**
  82005. * Gets a new Vector2 located for "amount" (float) on the CatmullRom spline defined by the given four Vector2
  82006. * @param value1 defines 1st point of control
  82007. * @param value2 defines 2nd point of control
  82008. * @param value3 defines 3rd point of control
  82009. * @param value4 defines 4th point of control
  82010. * @param amount defines the interpolation factor
  82011. * @returns a new Vector2
  82012. */
  82013. static CatmullRom(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>, value3: DeepImmutable<Vector2>, value4: DeepImmutable<Vector2>, amount: number): Vector2;
  82014. /**
  82015. * 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".
  82016. * If a coordinate of "value" is lower than "min" coordinates, the returned Vector2 is given this "min" coordinate.
  82017. * If a coordinate of "value" is greater than "max" coordinates, the returned Vector2 is given this "max" coordinate
  82018. * @param value defines the value to clamp
  82019. * @param min defines the lower limit
  82020. * @param max defines the upper limit
  82021. * @returns a new Vector2
  82022. */
  82023. static Clamp(value: DeepImmutable<Vector2>, min: DeepImmutable<Vector2>, max: DeepImmutable<Vector2>): Vector2;
  82024. /**
  82025. * Returns a new Vector2 located for "amount" (float) on the Hermite spline defined by the vectors "value1", "value3", "tangent1", "tangent2"
  82026. * @param value1 defines the 1st control point
  82027. * @param tangent1 defines the outgoing tangent
  82028. * @param value2 defines the 2nd control point
  82029. * @param tangent2 defines the incoming tangent
  82030. * @param amount defines the interpolation factor
  82031. * @returns a new Vector2
  82032. */
  82033. static Hermite(value1: DeepImmutable<Vector2>, tangent1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>, tangent2: DeepImmutable<Vector2>, amount: number): Vector2;
  82034. /**
  82035. * Returns a new Vector2 located for "amount" (float) on the linear interpolation between the vector "start" adn the vector "end".
  82036. * @param start defines the start vector
  82037. * @param end defines the end vector
  82038. * @param amount defines the interpolation factor
  82039. * @returns a new Vector2
  82040. */
  82041. static Lerp(start: DeepImmutable<Vector2>, end: DeepImmutable<Vector2>, amount: number): Vector2;
  82042. /**
  82043. * Gets the dot product of the vector "left" and the vector "right"
  82044. * @param left defines first vector
  82045. * @param right defines second vector
  82046. * @returns the dot product (float)
  82047. */
  82048. static Dot(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): number;
  82049. /**
  82050. * Returns a new Vector2 equal to the normalized given vector
  82051. * @param vector defines the vector to normalize
  82052. * @returns a new Vector2
  82053. */
  82054. static Normalize(vector: DeepImmutable<Vector2>): Vector2;
  82055. /**
  82056. * Gets a new Vector2 set with the minimal coordinate values from the "left" and "right" vectors
  82057. * @param left defines 1st vector
  82058. * @param right defines 2nd vector
  82059. * @returns a new Vector2
  82060. */
  82061. static Minimize(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): Vector2;
  82062. /**
  82063. * Gets a new Vecto2 set with the maximal coordinate values from the "left" and "right" vectors
  82064. * @param left defines 1st vector
  82065. * @param right defines 2nd vector
  82066. * @returns a new Vector2
  82067. */
  82068. static Maximize(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): Vector2;
  82069. /**
  82070. * Gets a new Vector2 set with the transformed coordinates of the given vector by the given transformation matrix
  82071. * @param vector defines the vector to transform
  82072. * @param transformation defines the matrix to apply
  82073. * @returns a new Vector2
  82074. */
  82075. static Transform(vector: DeepImmutable<Vector2>, transformation: DeepImmutable<Matrix>): Vector2;
  82076. /**
  82077. * Transforms the given vector coordinates by the given transformation matrix and stores the result in the vector "result" coordinates
  82078. * @param vector defines the vector to transform
  82079. * @param transformation defines the matrix to apply
  82080. * @param result defines the target vector
  82081. */
  82082. static TransformToRef(vector: DeepImmutable<Vector2>, transformation: DeepImmutable<Matrix>, result: Vector2): void;
  82083. /**
  82084. * Determines if a given vector is included in a triangle
  82085. * @param p defines the vector to test
  82086. * @param p0 defines 1st triangle point
  82087. * @param p1 defines 2nd triangle point
  82088. * @param p2 defines 3rd triangle point
  82089. * @returns true if the point "p" is in the triangle defined by the vertors "p0", "p1", "p2"
  82090. */
  82091. static PointInTriangle(p: DeepImmutable<Vector2>, p0: DeepImmutable<Vector2>, p1: DeepImmutable<Vector2>, p2: DeepImmutable<Vector2>): boolean;
  82092. /**
  82093. * Gets the distance between the vectors "value1" and "value2"
  82094. * @param value1 defines first vector
  82095. * @param value2 defines second vector
  82096. * @returns the distance between vectors
  82097. */
  82098. static Distance(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): number;
  82099. /**
  82100. * Returns the squared distance between the vectors "value1" and "value2"
  82101. * @param value1 defines first vector
  82102. * @param value2 defines second vector
  82103. * @returns the squared distance between vectors
  82104. */
  82105. static DistanceSquared(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): number;
  82106. /**
  82107. * Gets a new Vector2 located at the center of the vectors "value1" and "value2"
  82108. * @param value1 defines first vector
  82109. * @param value2 defines second vector
  82110. * @returns a new Vector2
  82111. */
  82112. static Center(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): Vector2;
  82113. /**
  82114. * Gets the shortest distance (float) between the point "p" and the segment defined by the two points "segA" and "segB".
  82115. * @param p defines the middle point
  82116. * @param segA defines one point of the segment
  82117. * @param segB defines the other point of the segment
  82118. * @returns the shortest distance
  82119. */
  82120. static DistanceOfPointFromSegment(p: DeepImmutable<Vector2>, segA: DeepImmutable<Vector2>, segB: DeepImmutable<Vector2>): number;
  82121. }
  82122. /**
  82123. * Class used to store (x,y,z) vector representation
  82124. * A Vector3 is the main object used in 3D geometry
  82125. * It can represent etiher the coordinates of a point the space, either a direction
  82126. * Reminder: js uses a left handed forward facing system
  82127. */
  82128. export class Vector3 {
  82129. private static _UpReadOnly;
  82130. private static _ZeroReadOnly;
  82131. /** @hidden */
  82132. _x: number;
  82133. /** @hidden */
  82134. _y: number;
  82135. /** @hidden */
  82136. _z: number;
  82137. /** @hidden */
  82138. _isDirty: boolean;
  82139. /** Gets or sets the x coordinate */
  82140. get x(): number;
  82141. set x(value: number);
  82142. /** Gets or sets the y coordinate */
  82143. get y(): number;
  82144. set y(value: number);
  82145. /** Gets or sets the z coordinate */
  82146. get z(): number;
  82147. set z(value: number);
  82148. /**
  82149. * Creates a new Vector3 object from the given x, y, z (floats) coordinates.
  82150. * @param x defines the first coordinates (on X axis)
  82151. * @param y defines the second coordinates (on Y axis)
  82152. * @param z defines the third coordinates (on Z axis)
  82153. */
  82154. constructor(x?: number, y?: number, z?: number);
  82155. /**
  82156. * Creates a string representation of the Vector3
  82157. * @returns a string with the Vector3 coordinates.
  82158. */
  82159. toString(): string;
  82160. /**
  82161. * Gets the class name
  82162. * @returns the string "Vector3"
  82163. */
  82164. getClassName(): string;
  82165. /**
  82166. * Creates the Vector3 hash code
  82167. * @returns a number which tends to be unique between Vector3 instances
  82168. */
  82169. getHashCode(): number;
  82170. /**
  82171. * Creates an array containing three elements : the coordinates of the Vector3
  82172. * @returns a new array of numbers
  82173. */
  82174. asArray(): number[];
  82175. /**
  82176. * Populates the given array or Float32Array from the given index with the successive coordinates of the Vector3
  82177. * @param array defines the destination array
  82178. * @param index defines the offset in the destination array
  82179. * @returns the current Vector3
  82180. */
  82181. toArray(array: FloatArray, index?: number): Vector3;
  82182. /**
  82183. * Update the current vector from an array
  82184. * @param array defines the destination array
  82185. * @param index defines the offset in the destination array
  82186. * @returns the current Vector3
  82187. */
  82188. fromArray(array: FloatArray, index?: number): Vector3;
  82189. /**
  82190. * Converts the current Vector3 into a quaternion (considering that the Vector3 contains Euler angles representation of a rotation)
  82191. * @returns a new Quaternion object, computed from the Vector3 coordinates
  82192. */
  82193. toQuaternion(): Quaternion;
  82194. /**
  82195. * Adds the given vector to the current Vector3
  82196. * @param otherVector defines the second operand
  82197. * @returns the current updated Vector3
  82198. */
  82199. addInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  82200. /**
  82201. * Adds the given coordinates to the current Vector3
  82202. * @param x defines the x coordinate of the operand
  82203. * @param y defines the y coordinate of the operand
  82204. * @param z defines the z coordinate of the operand
  82205. * @returns the current updated Vector3
  82206. */
  82207. addInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  82208. /**
  82209. * Gets a new Vector3, result of the addition the current Vector3 and the given vector
  82210. * @param otherVector defines the second operand
  82211. * @returns the resulting Vector3
  82212. */
  82213. add(otherVector: DeepImmutable<Vector3>): Vector3;
  82214. /**
  82215. * Adds the current Vector3 to the given one and stores the result in the vector "result"
  82216. * @param otherVector defines the second operand
  82217. * @param result defines the Vector3 object where to store the result
  82218. * @returns the current Vector3
  82219. */
  82220. addToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  82221. /**
  82222. * Subtract the given vector from the current Vector3
  82223. * @param otherVector defines the second operand
  82224. * @returns the current updated Vector3
  82225. */
  82226. subtractInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  82227. /**
  82228. * Returns a new Vector3, result of the subtraction of the given vector from the current Vector3
  82229. * @param otherVector defines the second operand
  82230. * @returns the resulting Vector3
  82231. */
  82232. subtract(otherVector: DeepImmutable<Vector3>): Vector3;
  82233. /**
  82234. * Subtracts the given vector from the current Vector3 and stores the result in the vector "result".
  82235. * @param otherVector defines the second operand
  82236. * @param result defines the Vector3 object where to store the result
  82237. * @returns the current Vector3
  82238. */
  82239. subtractToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  82240. /**
  82241. * Returns a new Vector3 set with the subtraction of the given floats from the current Vector3 coordinates
  82242. * @param x defines the x coordinate of the operand
  82243. * @param y defines the y coordinate of the operand
  82244. * @param z defines the z coordinate of the operand
  82245. * @returns the resulting Vector3
  82246. */
  82247. subtractFromFloats(x: number, y: number, z: number): Vector3;
  82248. /**
  82249. * Subtracts the given floats from the current Vector3 coordinates and set the given vector "result" with this result
  82250. * @param x defines the x coordinate of the operand
  82251. * @param y defines the y coordinate of the operand
  82252. * @param z defines the z coordinate of the operand
  82253. * @param result defines the Vector3 object where to store the result
  82254. * @returns the current Vector3
  82255. */
  82256. subtractFromFloatsToRef(x: number, y: number, z: number, result: Vector3): Vector3;
  82257. /**
  82258. * Gets a new Vector3 set with the current Vector3 negated coordinates
  82259. * @returns a new Vector3
  82260. */
  82261. negate(): Vector3;
  82262. /**
  82263. * Negate this vector in place
  82264. * @returns this
  82265. */
  82266. negateInPlace(): Vector3;
  82267. /**
  82268. * Negate the current Vector3 and stores the result in the given vector "result" coordinates
  82269. * @param result defines the Vector3 object where to store the result
  82270. * @returns the current Vector3
  82271. */
  82272. negateToRef(result: Vector3): Vector3;
  82273. /**
  82274. * Multiplies the Vector3 coordinates by the float "scale"
  82275. * @param scale defines the multiplier factor
  82276. * @returns the current updated Vector3
  82277. */
  82278. scaleInPlace(scale: number): Vector3;
  82279. /**
  82280. * Returns a new Vector3 set with the current Vector3 coordinates multiplied by the float "scale"
  82281. * @param scale defines the multiplier factor
  82282. * @returns a new Vector3
  82283. */
  82284. scale(scale: number): Vector3;
  82285. /**
  82286. * Multiplies the current Vector3 coordinates by the float "scale" and stores the result in the given vector "result" coordinates
  82287. * @param scale defines the multiplier factor
  82288. * @param result defines the Vector3 object where to store the result
  82289. * @returns the current Vector3
  82290. */
  82291. scaleToRef(scale: number, result: Vector3): Vector3;
  82292. /**
  82293. * Scale the current Vector3 values by a factor and add the result to a given Vector3
  82294. * @param scale defines the scale factor
  82295. * @param result defines the Vector3 object where to store the result
  82296. * @returns the unmodified current Vector3
  82297. */
  82298. scaleAndAddToRef(scale: number, result: Vector3): Vector3;
  82299. /**
  82300. * Projects the current vector3 to a plane along a ray starting from a specified origin and directed towards the point.
  82301. * @param origin defines the origin of the projection ray
  82302. * @param plane defines the plane to project to
  82303. * @returns the projected vector3
  82304. */
  82305. projectOnPlane(plane: Plane, origin: Vector3): Vector3;
  82306. /**
  82307. * Projects the current vector3 to a plane along a ray starting from a specified origin and directed towards the point.
  82308. * @param origin defines the origin of the projection ray
  82309. * @param plane defines the plane to project to
  82310. * @param result defines the Vector3 where to store the result
  82311. */
  82312. projectOnPlaneToRef(plane: Plane, origin: Vector3, result: Vector3): void;
  82313. /**
  82314. * Returns true if the current Vector3 and the given vector coordinates are strictly equal
  82315. * @param otherVector defines the second operand
  82316. * @returns true if both vectors are equals
  82317. */
  82318. equals(otherVector: DeepImmutable<Vector3>): boolean;
  82319. /**
  82320. * Returns true if the current Vector3 and the given vector coordinates are distant less than epsilon
  82321. * @param otherVector defines the second operand
  82322. * @param epsilon defines the minimal distance to define values as equals
  82323. * @returns true if both vectors are distant less than epsilon
  82324. */
  82325. equalsWithEpsilon(otherVector: DeepImmutable<Vector3>, epsilon?: number): boolean;
  82326. /**
  82327. * Returns true if the current Vector3 coordinates equals the given floats
  82328. * @param x defines the x coordinate of the operand
  82329. * @param y defines the y coordinate of the operand
  82330. * @param z defines the z coordinate of the operand
  82331. * @returns true if both vectors are equals
  82332. */
  82333. equalsToFloats(x: number, y: number, z: number): boolean;
  82334. /**
  82335. * Multiplies the current Vector3 coordinates by the given ones
  82336. * @param otherVector defines the second operand
  82337. * @returns the current updated Vector3
  82338. */
  82339. multiplyInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  82340. /**
  82341. * Returns a new Vector3, result of the multiplication of the current Vector3 by the given vector
  82342. * @param otherVector defines the second operand
  82343. * @returns the new Vector3
  82344. */
  82345. multiply(otherVector: DeepImmutable<Vector3>): Vector3;
  82346. /**
  82347. * Multiplies the current Vector3 by the given one and stores the result in the given vector "result"
  82348. * @param otherVector defines the second operand
  82349. * @param result defines the Vector3 object where to store the result
  82350. * @returns the current Vector3
  82351. */
  82352. multiplyToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  82353. /**
  82354. * Returns a new Vector3 set with the result of the mulliplication of the current Vector3 coordinates by the given floats
  82355. * @param x defines the x coordinate of the operand
  82356. * @param y defines the y coordinate of the operand
  82357. * @param z defines the z coordinate of the operand
  82358. * @returns the new Vector3
  82359. */
  82360. multiplyByFloats(x: number, y: number, z: number): Vector3;
  82361. /**
  82362. * Returns a new Vector3 set with the result of the division of the current Vector3 coordinates by the given ones
  82363. * @param otherVector defines the second operand
  82364. * @returns the new Vector3
  82365. */
  82366. divide(otherVector: DeepImmutable<Vector3>): Vector3;
  82367. /**
  82368. * Divides the current Vector3 coordinates by the given ones and stores the result in the given vector "result"
  82369. * @param otherVector defines the second operand
  82370. * @param result defines the Vector3 object where to store the result
  82371. * @returns the current Vector3
  82372. */
  82373. divideToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  82374. /**
  82375. * Divides the current Vector3 coordinates by the given ones.
  82376. * @param otherVector defines the second operand
  82377. * @returns the current updated Vector3
  82378. */
  82379. divideInPlace(otherVector: Vector3): Vector3;
  82380. /**
  82381. * Updates the current Vector3 with the minimal coordinate values between its and the given vector ones
  82382. * @param other defines the second operand
  82383. * @returns the current updated Vector3
  82384. */
  82385. minimizeInPlace(other: DeepImmutable<Vector3>): Vector3;
  82386. /**
  82387. * Updates the current Vector3 with the maximal coordinate values between its and the given vector ones.
  82388. * @param other defines the second operand
  82389. * @returns the current updated Vector3
  82390. */
  82391. maximizeInPlace(other: DeepImmutable<Vector3>): Vector3;
  82392. /**
  82393. * Updates the current Vector3 with the minimal coordinate values between its and the given coordinates
  82394. * @param x defines the x coordinate of the operand
  82395. * @param y defines the y coordinate of the operand
  82396. * @param z defines the z coordinate of the operand
  82397. * @returns the current updated Vector3
  82398. */
  82399. minimizeInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  82400. /**
  82401. * Updates the current Vector3 with the maximal coordinate values between its and the given coordinates.
  82402. * @param x defines the x coordinate of the operand
  82403. * @param y defines the y coordinate of the operand
  82404. * @param z defines the z coordinate of the operand
  82405. * @returns the current updated Vector3
  82406. */
  82407. maximizeInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  82408. /**
  82409. * Due to float precision, scale of a mesh could be uniform but float values are off by a small fraction
  82410. * Check if is non uniform within a certain amount of decimal places to account for this
  82411. * @param epsilon the amount the values can differ
  82412. * @returns if the the vector is non uniform to a certain number of decimal places
  82413. */
  82414. isNonUniformWithinEpsilon(epsilon: number): boolean;
  82415. /**
  82416. * Gets a boolean indicating that the vector is non uniform meaning x, y or z are not all the same
  82417. */
  82418. get isNonUniform(): boolean;
  82419. /**
  82420. * Gets a new Vector3 from current Vector3 floored values
  82421. * @returns a new Vector3
  82422. */
  82423. floor(): Vector3;
  82424. /**
  82425. * Gets a new Vector3 from current Vector3 floored values
  82426. * @returns a new Vector3
  82427. */
  82428. fract(): Vector3;
  82429. /**
  82430. * Gets the length of the Vector3
  82431. * @returns the length of the Vector3
  82432. */
  82433. length(): number;
  82434. /**
  82435. * Gets the squared length of the Vector3
  82436. * @returns squared length of the Vector3
  82437. */
  82438. lengthSquared(): number;
  82439. /**
  82440. * Normalize the current Vector3.
  82441. * Please note that this is an in place operation.
  82442. * @returns the current updated Vector3
  82443. */
  82444. normalize(): Vector3;
  82445. /**
  82446. * Reorders the x y z properties of the vector in place
  82447. * @param order new ordering of the properties (eg. for vector 1,2,3 with "ZYX" will produce 3,2,1)
  82448. * @returns the current updated vector
  82449. */
  82450. reorderInPlace(order: string): this;
  82451. /**
  82452. * Rotates the vector around 0,0,0 by a quaternion
  82453. * @param quaternion the rotation quaternion
  82454. * @param result vector to store the result
  82455. * @returns the resulting vector
  82456. */
  82457. rotateByQuaternionToRef(quaternion: Quaternion, result: Vector3): Vector3;
  82458. /**
  82459. * Rotates a vector around a given point
  82460. * @param quaternion the rotation quaternion
  82461. * @param point the point to rotate around
  82462. * @param result vector to store the result
  82463. * @returns the resulting vector
  82464. */
  82465. rotateByQuaternionAroundPointToRef(quaternion: Quaternion, point: Vector3, result: Vector3): Vector3;
  82466. /**
  82467. * Returns a new Vector3 as the cross product of the current vector and the "other" one
  82468. * The cross product is then orthogonal to both current and "other"
  82469. * @param other defines the right operand
  82470. * @returns the cross product
  82471. */
  82472. cross(other: Vector3): Vector3;
  82473. /**
  82474. * Normalize the current Vector3 with the given input length.
  82475. * Please note that this is an in place operation.
  82476. * @param len the length of the vector
  82477. * @returns the current updated Vector3
  82478. */
  82479. normalizeFromLength(len: number): Vector3;
  82480. /**
  82481. * Normalize the current Vector3 to a new vector
  82482. * @returns the new Vector3
  82483. */
  82484. normalizeToNew(): Vector3;
  82485. /**
  82486. * Normalize the current Vector3 to the reference
  82487. * @param reference define the Vector3 to update
  82488. * @returns the updated Vector3
  82489. */
  82490. normalizeToRef(reference: Vector3): Vector3;
  82491. /**
  82492. * Creates a new Vector3 copied from the current Vector3
  82493. * @returns the new Vector3
  82494. */
  82495. clone(): Vector3;
  82496. /**
  82497. * Copies the given vector coordinates to the current Vector3 ones
  82498. * @param source defines the source Vector3
  82499. * @returns the current updated Vector3
  82500. */
  82501. copyFrom(source: DeepImmutable<Vector3>): Vector3;
  82502. /**
  82503. * Copies the given floats to the current Vector3 coordinates
  82504. * @param x defines the x coordinate of the operand
  82505. * @param y defines the y coordinate of the operand
  82506. * @param z defines the z coordinate of the operand
  82507. * @returns the current updated Vector3
  82508. */
  82509. copyFromFloats(x: number, y: number, z: number): Vector3;
  82510. /**
  82511. * Copies the given floats to the current Vector3 coordinates
  82512. * @param x defines the x coordinate of the operand
  82513. * @param y defines the y coordinate of the operand
  82514. * @param z defines the z coordinate of the operand
  82515. * @returns the current updated Vector3
  82516. */
  82517. set(x: number, y: number, z: number): Vector3;
  82518. /**
  82519. * Copies the given float to the current Vector3 coordinates
  82520. * @param v defines the x, y and z coordinates of the operand
  82521. * @returns the current updated Vector3
  82522. */
  82523. setAll(v: number): Vector3;
  82524. /**
  82525. * Get the clip factor between two vectors
  82526. * @param vector0 defines the first operand
  82527. * @param vector1 defines the second operand
  82528. * @param axis defines the axis to use
  82529. * @param size defines the size along the axis
  82530. * @returns the clip factor
  82531. */
  82532. static GetClipFactor(vector0: DeepImmutable<Vector3>, vector1: DeepImmutable<Vector3>, axis: DeepImmutable<Vector3>, size: number): number;
  82533. /**
  82534. * Get angle between two vectors
  82535. * @param vector0 angle between vector0 and vector1
  82536. * @param vector1 angle between vector0 and vector1
  82537. * @param normal direction of the normal
  82538. * @return the angle between vector0 and vector1
  82539. */
  82540. static GetAngleBetweenVectors(vector0: DeepImmutable<Vector3>, vector1: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>): number;
  82541. /**
  82542. * Returns a new Vector3 set from the index "offset" of the given array
  82543. * @param array defines the source array
  82544. * @param offset defines the offset in the source array
  82545. * @returns the new Vector3
  82546. */
  82547. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector3;
  82548. /**
  82549. * Returns a new Vector3 set from the index "offset" of the given Float32Array
  82550. * @param array defines the source array
  82551. * @param offset defines the offset in the source array
  82552. * @returns the new Vector3
  82553. * @deprecated Please use FromArray instead.
  82554. */
  82555. static FromFloatArray(array: DeepImmutable<Float32Array>, offset?: number): Vector3;
  82556. /**
  82557. * Sets the given vector "result" with the element values from the index "offset" of the given array
  82558. * @param array defines the source array
  82559. * @param offset defines the offset in the source array
  82560. * @param result defines the Vector3 where to store the result
  82561. */
  82562. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector3): void;
  82563. /**
  82564. * Sets the given vector "result" with the element values from the index "offset" of the given Float32Array
  82565. * @param array defines the source array
  82566. * @param offset defines the offset in the source array
  82567. * @param result defines the Vector3 where to store the result
  82568. * @deprecated Please use FromArrayToRef instead.
  82569. */
  82570. static FromFloatArrayToRef(array: DeepImmutable<Float32Array>, offset: number, result: Vector3): void;
  82571. /**
  82572. * Sets the given vector "result" with the given floats.
  82573. * @param x defines the x coordinate of the source
  82574. * @param y defines the y coordinate of the source
  82575. * @param z defines the z coordinate of the source
  82576. * @param result defines the Vector3 where to store the result
  82577. */
  82578. static FromFloatsToRef(x: number, y: number, z: number, result: Vector3): void;
  82579. /**
  82580. * Returns a new Vector3 set to (0.0, 0.0, 0.0)
  82581. * @returns a new empty Vector3
  82582. */
  82583. static Zero(): Vector3;
  82584. /**
  82585. * Returns a new Vector3 set to (1.0, 1.0, 1.0)
  82586. * @returns a new unit Vector3
  82587. */
  82588. static One(): Vector3;
  82589. /**
  82590. * Returns a new Vector3 set to (0.0, 1.0, 0.0)
  82591. * @returns a new up Vector3
  82592. */
  82593. static Up(): Vector3;
  82594. /**
  82595. * Gets a up Vector3 that must not be updated
  82596. */
  82597. static get UpReadOnly(): DeepImmutable<Vector3>;
  82598. /**
  82599. * Gets a zero Vector3 that must not be updated
  82600. */
  82601. static get ZeroReadOnly(): DeepImmutable<Vector3>;
  82602. /**
  82603. * Returns a new Vector3 set to (0.0, -1.0, 0.0)
  82604. * @returns a new down Vector3
  82605. */
  82606. static Down(): Vector3;
  82607. /**
  82608. * Returns a new Vector3 set to (0.0, 0.0, 1.0)
  82609. * @param rightHandedSystem is the scene right-handed (negative z)
  82610. * @returns a new forward Vector3
  82611. */
  82612. static Forward(rightHandedSystem?: boolean): Vector3;
  82613. /**
  82614. * Returns a new Vector3 set to (0.0, 0.0, -1.0)
  82615. * @param rightHandedSystem is the scene right-handed (negative-z)
  82616. * @returns a new forward Vector3
  82617. */
  82618. static Backward(rightHandedSystem?: boolean): Vector3;
  82619. /**
  82620. * Returns a new Vector3 set to (1.0, 0.0, 0.0)
  82621. * @returns a new right Vector3
  82622. */
  82623. static Right(): Vector3;
  82624. /**
  82625. * Returns a new Vector3 set to (-1.0, 0.0, 0.0)
  82626. * @returns a new left Vector3
  82627. */
  82628. static Left(): Vector3;
  82629. /**
  82630. * Returns a new Vector3 set with the result of the transformation by the given matrix of the given vector.
  82631. * This method computes tranformed coordinates only, not transformed direction vectors (ie. it takes translation in account)
  82632. * @param vector defines the Vector3 to transform
  82633. * @param transformation defines the transformation matrix
  82634. * @returns the transformed Vector3
  82635. */
  82636. static TransformCoordinates(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>): Vector3;
  82637. /**
  82638. * Sets the given vector "result" coordinates with the result of the transformation by the given matrix of the given vector
  82639. * This method computes tranformed coordinates only, not transformed direction vectors (ie. it takes translation in account)
  82640. * @param vector defines the Vector3 to transform
  82641. * @param transformation defines the transformation matrix
  82642. * @param result defines the Vector3 where to store the result
  82643. */
  82644. static TransformCoordinatesToRef(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  82645. /**
  82646. * Sets the given vector "result" coordinates with the result of the transformation by the given matrix of the given floats (x, y, z)
  82647. * This method computes tranformed coordinates only, not transformed direction vectors
  82648. * @param x define the x coordinate of the source vector
  82649. * @param y define the y coordinate of the source vector
  82650. * @param z define the z coordinate of the source vector
  82651. * @param transformation defines the transformation matrix
  82652. * @param result defines the Vector3 where to store the result
  82653. */
  82654. static TransformCoordinatesFromFloatsToRef(x: number, y: number, z: number, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  82655. /**
  82656. * Returns a new Vector3 set with the result of the normal transformation by the given matrix of the given vector
  82657. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  82658. * @param vector defines the Vector3 to transform
  82659. * @param transformation defines the transformation matrix
  82660. * @returns the new Vector3
  82661. */
  82662. static TransformNormal(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>): Vector3;
  82663. /**
  82664. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given vector
  82665. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  82666. * @param vector defines the Vector3 to transform
  82667. * @param transformation defines the transformation matrix
  82668. * @param result defines the Vector3 where to store the result
  82669. */
  82670. static TransformNormalToRef(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  82671. /**
  82672. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given floats (x, y, z)
  82673. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  82674. * @param x define the x coordinate of the source vector
  82675. * @param y define the y coordinate of the source vector
  82676. * @param z define the z coordinate of the source vector
  82677. * @param transformation defines the transformation matrix
  82678. * @param result defines the Vector3 where to store the result
  82679. */
  82680. static TransformNormalFromFloatsToRef(x: number, y: number, z: number, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  82681. /**
  82682. * Returns a new Vector3 located for "amount" on the CatmullRom interpolation spline defined by the vectors "value1", "value2", "value3", "value4"
  82683. * @param value1 defines the first control point
  82684. * @param value2 defines the second control point
  82685. * @param value3 defines the third control point
  82686. * @param value4 defines the fourth control point
  82687. * @param amount defines the amount on the spline to use
  82688. * @returns the new Vector3
  82689. */
  82690. static CatmullRom(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>, value3: DeepImmutable<Vector3>, value4: DeepImmutable<Vector3>, amount: number): Vector3;
  82691. /**
  82692. * 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"
  82693. * If a coordinate value of "value" is lower than one of the "min" coordinate, then this "value" coordinate is set with the "min" one
  82694. * If a coordinate value of "value" is greater than one of the "max" coordinate, then this "value" coordinate is set with the "max" one
  82695. * @param value defines the current value
  82696. * @param min defines the lower range value
  82697. * @param max defines the upper range value
  82698. * @returns the new Vector3
  82699. */
  82700. static Clamp(value: DeepImmutable<Vector3>, min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>): Vector3;
  82701. /**
  82702. * 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"
  82703. * If a coordinate value of "value" is lower than one of the "min" coordinate, then this "value" coordinate is set with the "min" one
  82704. * If a coordinate value of "value" is greater than one of the "max" coordinate, then this "value" coordinate is set with the "max" one
  82705. * @param value defines the current value
  82706. * @param min defines the lower range value
  82707. * @param max defines the upper range value
  82708. * @param result defines the Vector3 where to store the result
  82709. */
  82710. static ClampToRef(value: DeepImmutable<Vector3>, min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, result: Vector3): void;
  82711. /**
  82712. * Checks if a given vector is inside a specific range
  82713. * @param v defines the vector to test
  82714. * @param min defines the minimum range
  82715. * @param max defines the maximum range
  82716. */
  82717. static CheckExtends(v: Vector3, min: Vector3, max: Vector3): void;
  82718. /**
  82719. * Returns a new Vector3 located for "amount" (float) on the Hermite interpolation spline defined by the vectors "value1", "tangent1", "value2", "tangent2"
  82720. * @param value1 defines the first control point
  82721. * @param tangent1 defines the first tangent vector
  82722. * @param value2 defines the second control point
  82723. * @param tangent2 defines the second tangent vector
  82724. * @param amount defines the amount on the interpolation spline (between 0 and 1)
  82725. * @returns the new Vector3
  82726. */
  82727. static Hermite(value1: DeepImmutable<Vector3>, tangent1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>, tangent2: DeepImmutable<Vector3>, amount: number): Vector3;
  82728. /**
  82729. * Returns a new Vector3 located for "amount" (float) on the linear interpolation between the vectors "start" and "end"
  82730. * @param start defines the start value
  82731. * @param end defines the end value
  82732. * @param amount max defines amount between both (between 0 and 1)
  82733. * @returns the new Vector3
  82734. */
  82735. static Lerp(start: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, amount: number): Vector3;
  82736. /**
  82737. * Sets the given vector "result" with the result of the linear interpolation from the vector "start" for "amount" to the vector "end"
  82738. * @param start defines the start value
  82739. * @param end defines the end value
  82740. * @param amount max defines amount between both (between 0 and 1)
  82741. * @param result defines the Vector3 where to store the result
  82742. */
  82743. static LerpToRef(start: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, amount: number, result: Vector3): void;
  82744. /**
  82745. * Returns the dot product (float) between the vectors "left" and "right"
  82746. * @param left defines the left operand
  82747. * @param right defines the right operand
  82748. * @returns the dot product
  82749. */
  82750. static Dot(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): number;
  82751. /**
  82752. * Returns a new Vector3 as the cross product of the vectors "left" and "right"
  82753. * The cross product is then orthogonal to both "left" and "right"
  82754. * @param left defines the left operand
  82755. * @param right defines the right operand
  82756. * @returns the cross product
  82757. */
  82758. static Cross(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  82759. /**
  82760. * Sets the given vector "result" with the cross product of "left" and "right"
  82761. * The cross product is then orthogonal to both "left" and "right"
  82762. * @param left defines the left operand
  82763. * @param right defines the right operand
  82764. * @param result defines the Vector3 where to store the result
  82765. */
  82766. static CrossToRef(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>, result: Vector3): void;
  82767. /**
  82768. * Returns a new Vector3 as the normalization of the given vector
  82769. * @param vector defines the Vector3 to normalize
  82770. * @returns the new Vector3
  82771. */
  82772. static Normalize(vector: DeepImmutable<Vector3>): Vector3;
  82773. /**
  82774. * Sets the given vector "result" with the normalization of the given first vector
  82775. * @param vector defines the Vector3 to normalize
  82776. * @param result defines the Vector3 where to store the result
  82777. */
  82778. static NormalizeToRef(vector: DeepImmutable<Vector3>, result: Vector3): void;
  82779. /**
  82780. * Project a Vector3 onto screen space
  82781. * @param vector defines the Vector3 to project
  82782. * @param world defines the world matrix to use
  82783. * @param transform defines the transform (view x projection) matrix to use
  82784. * @param viewport defines the screen viewport to use
  82785. * @returns the new Vector3
  82786. */
  82787. static Project(vector: DeepImmutable<Vector3>, world: DeepImmutable<Matrix>, transform: DeepImmutable<Matrix>, viewport: DeepImmutable<Viewport>): Vector3;
  82788. /** @hidden */
  82789. static _UnprojectFromInvertedMatrixToRef(source: DeepImmutable<Vector3>, matrix: DeepImmutable<Matrix>, result: Vector3): void;
  82790. /**
  82791. * Unproject from screen space to object space
  82792. * @param source defines the screen space Vector3 to use
  82793. * @param viewportWidth defines the current width of the viewport
  82794. * @param viewportHeight defines the current height of the viewport
  82795. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  82796. * @param transform defines the transform (view x projection) matrix to use
  82797. * @returns the new Vector3
  82798. */
  82799. static UnprojectFromTransform(source: Vector3, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, transform: DeepImmutable<Matrix>): Vector3;
  82800. /**
  82801. * Unproject from screen space to object space
  82802. * @param source defines the screen space Vector3 to use
  82803. * @param viewportWidth defines the current width of the viewport
  82804. * @param viewportHeight defines the current height of the viewport
  82805. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  82806. * @param view defines the view matrix to use
  82807. * @param projection defines the projection matrix to use
  82808. * @returns the new Vector3
  82809. */
  82810. static Unproject(source: DeepImmutable<Vector3>, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Vector3;
  82811. /**
  82812. * Unproject from screen space to object space
  82813. * @param source defines the screen space Vector3 to use
  82814. * @param viewportWidth defines the current width of the viewport
  82815. * @param viewportHeight defines the current height of the viewport
  82816. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  82817. * @param view defines the view matrix to use
  82818. * @param projection defines the projection matrix to use
  82819. * @param result defines the Vector3 where to store the result
  82820. */
  82821. static UnprojectToRef(source: DeepImmutable<Vector3>, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, result: Vector3): void;
  82822. /**
  82823. * Unproject from screen space to object space
  82824. * @param sourceX defines the screen space x coordinate to use
  82825. * @param sourceY defines the screen space y coordinate to use
  82826. * @param sourceZ defines the screen space z coordinate to use
  82827. * @param viewportWidth defines the current width of the viewport
  82828. * @param viewportHeight defines the current height of the viewport
  82829. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  82830. * @param view defines the view matrix to use
  82831. * @param projection defines the projection matrix to use
  82832. * @param result defines the Vector3 where to store the result
  82833. */
  82834. static UnprojectFloatsToRef(sourceX: float, sourceY: float, sourceZ: float, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, result: Vector3): void;
  82835. /**
  82836. * Gets the minimal coordinate values between two Vector3
  82837. * @param left defines the first operand
  82838. * @param right defines the second operand
  82839. * @returns the new Vector3
  82840. */
  82841. static Minimize(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  82842. /**
  82843. * Gets the maximal coordinate values between two Vector3
  82844. * @param left defines the first operand
  82845. * @param right defines the second operand
  82846. * @returns the new Vector3
  82847. */
  82848. static Maximize(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  82849. /**
  82850. * Returns the distance between the vectors "value1" and "value2"
  82851. * @param value1 defines the first operand
  82852. * @param value2 defines the second operand
  82853. * @returns the distance
  82854. */
  82855. static Distance(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): number;
  82856. /**
  82857. * Returns the squared distance between the vectors "value1" and "value2"
  82858. * @param value1 defines the first operand
  82859. * @param value2 defines the second operand
  82860. * @returns the squared distance
  82861. */
  82862. static DistanceSquared(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): number;
  82863. /**
  82864. * Returns a new Vector3 located at the center between "value1" and "value2"
  82865. * @param value1 defines the first operand
  82866. * @param value2 defines the second operand
  82867. * @returns the new Vector3
  82868. */
  82869. static Center(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): Vector3;
  82870. /**
  82871. * Given three orthogonal normalized left-handed oriented Vector3 axis in space (target system),
  82872. * RotationFromAxis() returns the rotation Euler angles (ex : rotation.x, rotation.y, rotation.z) to apply
  82873. * to something in order to rotate it from its local system to the given target system
  82874. * Note: axis1, axis2 and axis3 are normalized during this operation
  82875. * @param axis1 defines the first axis
  82876. * @param axis2 defines the second axis
  82877. * @param axis3 defines the third axis
  82878. * @returns a new Vector3
  82879. */
  82880. static RotationFromAxis(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>): Vector3;
  82881. /**
  82882. * The same than RotationFromAxis but updates the given ref Vector3 parameter instead of returning a new Vector3
  82883. * @param axis1 defines the first axis
  82884. * @param axis2 defines the second axis
  82885. * @param axis3 defines the third axis
  82886. * @param ref defines the Vector3 where to store the result
  82887. */
  82888. static RotationFromAxisToRef(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>, ref: Vector3): void;
  82889. }
  82890. /**
  82891. * Vector4 class created for EulerAngle class conversion to Quaternion
  82892. */
  82893. export class Vector4 {
  82894. /** x value of the vector */
  82895. x: number;
  82896. /** y value of the vector */
  82897. y: number;
  82898. /** z value of the vector */
  82899. z: number;
  82900. /** w value of the vector */
  82901. w: number;
  82902. /**
  82903. * Creates a Vector4 object from the given floats.
  82904. * @param x x value of the vector
  82905. * @param y y value of the vector
  82906. * @param z z value of the vector
  82907. * @param w w value of the vector
  82908. */
  82909. constructor(
  82910. /** x value of the vector */
  82911. x: number,
  82912. /** y value of the vector */
  82913. y: number,
  82914. /** z value of the vector */
  82915. z: number,
  82916. /** w value of the vector */
  82917. w: number);
  82918. /**
  82919. * Returns the string with the Vector4 coordinates.
  82920. * @returns a string containing all the vector values
  82921. */
  82922. toString(): string;
  82923. /**
  82924. * Returns the string "Vector4".
  82925. * @returns "Vector4"
  82926. */
  82927. getClassName(): string;
  82928. /**
  82929. * Returns the Vector4 hash code.
  82930. * @returns a unique hash code
  82931. */
  82932. getHashCode(): number;
  82933. /**
  82934. * Returns a new array populated with 4 elements : the Vector4 coordinates.
  82935. * @returns the resulting array
  82936. */
  82937. asArray(): number[];
  82938. /**
  82939. * Populates the given array from the given index with the Vector4 coordinates.
  82940. * @param array array to populate
  82941. * @param index index of the array to start at (default: 0)
  82942. * @returns the Vector4.
  82943. */
  82944. toArray(array: FloatArray, index?: number): Vector4;
  82945. /**
  82946. * Update the current vector from an array
  82947. * @param array defines the destination array
  82948. * @param index defines the offset in the destination array
  82949. * @returns the current Vector3
  82950. */
  82951. fromArray(array: FloatArray, index?: number): Vector4;
  82952. /**
  82953. * Adds the given vector to the current Vector4.
  82954. * @param otherVector the vector to add
  82955. * @returns the updated Vector4.
  82956. */
  82957. addInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  82958. /**
  82959. * Returns a new Vector4 as the result of the addition of the current Vector4 and the given one.
  82960. * @param otherVector the vector to add
  82961. * @returns the resulting vector
  82962. */
  82963. add(otherVector: DeepImmutable<Vector4>): Vector4;
  82964. /**
  82965. * Updates the given vector "result" with the result of the addition of the current Vector4 and the given one.
  82966. * @param otherVector the vector to add
  82967. * @param result the vector to store the result
  82968. * @returns the current Vector4.
  82969. */
  82970. addToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  82971. /**
  82972. * Subtract in place the given vector from the current Vector4.
  82973. * @param otherVector the vector to subtract
  82974. * @returns the updated Vector4.
  82975. */
  82976. subtractInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  82977. /**
  82978. * Returns a new Vector4 with the result of the subtraction of the given vector from the current Vector4.
  82979. * @param otherVector the vector to add
  82980. * @returns the new vector with the result
  82981. */
  82982. subtract(otherVector: DeepImmutable<Vector4>): Vector4;
  82983. /**
  82984. * Sets the given vector "result" with the result of the subtraction of the given vector from the current Vector4.
  82985. * @param otherVector the vector to subtract
  82986. * @param result the vector to store the result
  82987. * @returns the current Vector4.
  82988. */
  82989. subtractToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  82990. /**
  82991. * Returns a new Vector4 set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  82992. */
  82993. /**
  82994. * Returns a new Vector4 set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  82995. * @param x value to subtract
  82996. * @param y value to subtract
  82997. * @param z value to subtract
  82998. * @param w value to subtract
  82999. * @returns new vector containing the result
  83000. */
  83001. subtractFromFloats(x: number, y: number, z: number, w: number): Vector4;
  83002. /**
  83003. * Sets the given vector "result" set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  83004. * @param x value to subtract
  83005. * @param y value to subtract
  83006. * @param z value to subtract
  83007. * @param w value to subtract
  83008. * @param result the vector to store the result in
  83009. * @returns the current Vector4.
  83010. */
  83011. subtractFromFloatsToRef(x: number, y: number, z: number, w: number, result: Vector4): Vector4;
  83012. /**
  83013. * Returns a new Vector4 set with the current Vector4 negated coordinates.
  83014. * @returns a new vector with the negated values
  83015. */
  83016. negate(): Vector4;
  83017. /**
  83018. * Negate this vector in place
  83019. * @returns this
  83020. */
  83021. negateInPlace(): Vector4;
  83022. /**
  83023. * Negate the current Vector4 and stores the result in the given vector "result" coordinates
  83024. * @param result defines the Vector3 object where to store the result
  83025. * @returns the current Vector4
  83026. */
  83027. negateToRef(result: Vector4): Vector4;
  83028. /**
  83029. * Multiplies the current Vector4 coordinates by scale (float).
  83030. * @param scale the number to scale with
  83031. * @returns the updated Vector4.
  83032. */
  83033. scaleInPlace(scale: number): Vector4;
  83034. /**
  83035. * Returns a new Vector4 set with the current Vector4 coordinates multiplied by scale (float).
  83036. * @param scale the number to scale with
  83037. * @returns a new vector with the result
  83038. */
  83039. scale(scale: number): Vector4;
  83040. /**
  83041. * Sets the given vector "result" with the current Vector4 coordinates multiplied by scale (float).
  83042. * @param scale the number to scale with
  83043. * @param result a vector to store the result in
  83044. * @returns the current Vector4.
  83045. */
  83046. scaleToRef(scale: number, result: Vector4): Vector4;
  83047. /**
  83048. * Scale the current Vector4 values by a factor and add the result to a given Vector4
  83049. * @param scale defines the scale factor
  83050. * @param result defines the Vector4 object where to store the result
  83051. * @returns the unmodified current Vector4
  83052. */
  83053. scaleAndAddToRef(scale: number, result: Vector4): Vector4;
  83054. /**
  83055. * Boolean : True if the current Vector4 coordinates are stricly equal to the given ones.
  83056. * @param otherVector the vector to compare against
  83057. * @returns true if they are equal
  83058. */
  83059. equals(otherVector: DeepImmutable<Vector4>): boolean;
  83060. /**
  83061. * Boolean : True if the current Vector4 coordinates are each beneath the distance "epsilon" from the given vector ones.
  83062. * @param otherVector vector to compare against
  83063. * @param epsilon (Default: very small number)
  83064. * @returns true if they are equal
  83065. */
  83066. equalsWithEpsilon(otherVector: DeepImmutable<Vector4>, epsilon?: number): boolean;
  83067. /**
  83068. * Boolean : True if the given floats are strictly equal to the current Vector4 coordinates.
  83069. * @param x x value to compare against
  83070. * @param y y value to compare against
  83071. * @param z z value to compare against
  83072. * @param w w value to compare against
  83073. * @returns true if equal
  83074. */
  83075. equalsToFloats(x: number, y: number, z: number, w: number): boolean;
  83076. /**
  83077. * Multiplies in place the current Vector4 by the given one.
  83078. * @param otherVector vector to multiple with
  83079. * @returns the updated Vector4.
  83080. */
  83081. multiplyInPlace(otherVector: Vector4): Vector4;
  83082. /**
  83083. * Returns a new Vector4 set with the multiplication result of the current Vector4 and the given one.
  83084. * @param otherVector vector to multiple with
  83085. * @returns resulting new vector
  83086. */
  83087. multiply(otherVector: DeepImmutable<Vector4>): Vector4;
  83088. /**
  83089. * Updates the given vector "result" with the multiplication result of the current Vector4 and the given one.
  83090. * @param otherVector vector to multiple with
  83091. * @param result vector to store the result
  83092. * @returns the current Vector4.
  83093. */
  83094. multiplyToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  83095. /**
  83096. * Returns a new Vector4 set with the multiplication result of the given floats and the current Vector4 coordinates.
  83097. * @param x x value multiply with
  83098. * @param y y value multiply with
  83099. * @param z z value multiply with
  83100. * @param w w value multiply with
  83101. * @returns resulting new vector
  83102. */
  83103. multiplyByFloats(x: number, y: number, z: number, w: number): Vector4;
  83104. /**
  83105. * Returns a new Vector4 set with the division result of the current Vector4 by the given one.
  83106. * @param otherVector vector to devide with
  83107. * @returns resulting new vector
  83108. */
  83109. divide(otherVector: DeepImmutable<Vector4>): Vector4;
  83110. /**
  83111. * Updates the given vector "result" with the division result of the current Vector4 by the given one.
  83112. * @param otherVector vector to devide with
  83113. * @param result vector to store the result
  83114. * @returns the current Vector4.
  83115. */
  83116. divideToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  83117. /**
  83118. * Divides the current Vector3 coordinates by the given ones.
  83119. * @param otherVector vector to devide with
  83120. * @returns the updated Vector3.
  83121. */
  83122. divideInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  83123. /**
  83124. * Updates the Vector4 coordinates with the minimum values between its own and the given vector ones
  83125. * @param other defines the second operand
  83126. * @returns the current updated Vector4
  83127. */
  83128. minimizeInPlace(other: DeepImmutable<Vector4>): Vector4;
  83129. /**
  83130. * Updates the Vector4 coordinates with the maximum values between its own and the given vector ones
  83131. * @param other defines the second operand
  83132. * @returns the current updated Vector4
  83133. */
  83134. maximizeInPlace(other: DeepImmutable<Vector4>): Vector4;
  83135. /**
  83136. * Gets a new Vector4 from current Vector4 floored values
  83137. * @returns a new Vector4
  83138. */
  83139. floor(): Vector4;
  83140. /**
  83141. * Gets a new Vector4 from current Vector3 floored values
  83142. * @returns a new Vector4
  83143. */
  83144. fract(): Vector4;
  83145. /**
  83146. * Returns the Vector4 length (float).
  83147. * @returns the length
  83148. */
  83149. length(): number;
  83150. /**
  83151. * Returns the Vector4 squared length (float).
  83152. * @returns the length squared
  83153. */
  83154. lengthSquared(): number;
  83155. /**
  83156. * Normalizes in place the Vector4.
  83157. * @returns the updated Vector4.
  83158. */
  83159. normalize(): Vector4;
  83160. /**
  83161. * Returns a new Vector3 from the Vector4 (x, y, z) coordinates.
  83162. * @returns this converted to a new vector3
  83163. */
  83164. toVector3(): Vector3;
  83165. /**
  83166. * Returns a new Vector4 copied from the current one.
  83167. * @returns the new cloned vector
  83168. */
  83169. clone(): Vector4;
  83170. /**
  83171. * Updates the current Vector4 with the given one coordinates.
  83172. * @param source the source vector to copy from
  83173. * @returns the updated Vector4.
  83174. */
  83175. copyFrom(source: DeepImmutable<Vector4>): Vector4;
  83176. /**
  83177. * Updates the current Vector4 coordinates with the given floats.
  83178. * @param x float to copy from
  83179. * @param y float to copy from
  83180. * @param z float to copy from
  83181. * @param w float to copy from
  83182. * @returns the updated Vector4.
  83183. */
  83184. copyFromFloats(x: number, y: number, z: number, w: number): Vector4;
  83185. /**
  83186. * Updates the current Vector4 coordinates with the given floats.
  83187. * @param x float to set from
  83188. * @param y float to set from
  83189. * @param z float to set from
  83190. * @param w float to set from
  83191. * @returns the updated Vector4.
  83192. */
  83193. set(x: number, y: number, z: number, w: number): Vector4;
  83194. /**
  83195. * Copies the given float to the current Vector3 coordinates
  83196. * @param v defines the x, y, z and w coordinates of the operand
  83197. * @returns the current updated Vector3
  83198. */
  83199. setAll(v: number): Vector4;
  83200. /**
  83201. * Returns a new Vector4 set from the starting index of the given array.
  83202. * @param array the array to pull values from
  83203. * @param offset the offset into the array to start at
  83204. * @returns the new vector
  83205. */
  83206. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector4;
  83207. /**
  83208. * Updates the given vector "result" from the starting index of the given array.
  83209. * @param array the array to pull values from
  83210. * @param offset the offset into the array to start at
  83211. * @param result the vector to store the result in
  83212. */
  83213. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector4): void;
  83214. /**
  83215. * Updates the given vector "result" from the starting index of the given Float32Array.
  83216. * @param array the array to pull values from
  83217. * @param offset the offset into the array to start at
  83218. * @param result the vector to store the result in
  83219. */
  83220. static FromFloatArrayToRef(array: DeepImmutable<Float32Array>, offset: number, result: Vector4): void;
  83221. /**
  83222. * Updates the given vector "result" coordinates from the given floats.
  83223. * @param x float to set from
  83224. * @param y float to set from
  83225. * @param z float to set from
  83226. * @param w float to set from
  83227. * @param result the vector to the floats in
  83228. */
  83229. static FromFloatsToRef(x: number, y: number, z: number, w: number, result: Vector4): void;
  83230. /**
  83231. * Returns a new Vector4 set to (0.0, 0.0, 0.0, 0.0)
  83232. * @returns the new vector
  83233. */
  83234. static Zero(): Vector4;
  83235. /**
  83236. * Returns a new Vector4 set to (1.0, 1.0, 1.0, 1.0)
  83237. * @returns the new vector
  83238. */
  83239. static One(): Vector4;
  83240. /**
  83241. * Returns a new normalized Vector4 from the given one.
  83242. * @param vector the vector to normalize
  83243. * @returns the vector
  83244. */
  83245. static Normalize(vector: DeepImmutable<Vector4>): Vector4;
  83246. /**
  83247. * Updates the given vector "result" from the normalization of the given one.
  83248. * @param vector the vector to normalize
  83249. * @param result the vector to store the result in
  83250. */
  83251. static NormalizeToRef(vector: DeepImmutable<Vector4>, result: Vector4): void;
  83252. /**
  83253. * Returns a vector with the minimum values from the left and right vectors
  83254. * @param left left vector to minimize
  83255. * @param right right vector to minimize
  83256. * @returns a new vector with the minimum of the left and right vector values
  83257. */
  83258. static Minimize(left: DeepImmutable<Vector4>, right: DeepImmutable<Vector4>): Vector4;
  83259. /**
  83260. * Returns a vector with the maximum values from the left and right vectors
  83261. * @param left left vector to maximize
  83262. * @param right right vector to maximize
  83263. * @returns a new vector with the maximum of the left and right vector values
  83264. */
  83265. static Maximize(left: DeepImmutable<Vector4>, right: DeepImmutable<Vector4>): Vector4;
  83266. /**
  83267. * Returns the distance (float) between the vectors "value1" and "value2".
  83268. * @param value1 value to calulate the distance between
  83269. * @param value2 value to calulate the distance between
  83270. * @return the distance between the two vectors
  83271. */
  83272. static Distance(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): number;
  83273. /**
  83274. * Returns the squared distance (float) between the vectors "value1" and "value2".
  83275. * @param value1 value to calulate the distance between
  83276. * @param value2 value to calulate the distance between
  83277. * @return the distance between the two vectors squared
  83278. */
  83279. static DistanceSquared(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): number;
  83280. /**
  83281. * Returns a new Vector4 located at the center between the vectors "value1" and "value2".
  83282. * @param value1 value to calulate the center between
  83283. * @param value2 value to calulate the center between
  83284. * @return the center between the two vectors
  83285. */
  83286. static Center(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): Vector4;
  83287. /**
  83288. * Returns a new Vector4 set with the result of the normal transformation by the given matrix of the given vector.
  83289. * This methods computes transformed normalized direction vectors only.
  83290. * @param vector the vector to transform
  83291. * @param transformation the transformation matrix to apply
  83292. * @returns the new vector
  83293. */
  83294. static TransformNormal(vector: DeepImmutable<Vector4>, transformation: DeepImmutable<Matrix>): Vector4;
  83295. /**
  83296. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given vector.
  83297. * This methods computes transformed normalized direction vectors only.
  83298. * @param vector the vector to transform
  83299. * @param transformation the transformation matrix to apply
  83300. * @param result the vector to store the result in
  83301. */
  83302. static TransformNormalToRef(vector: DeepImmutable<Vector4>, transformation: DeepImmutable<Matrix>, result: Vector4): void;
  83303. /**
  83304. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given floats (x, y, z, w).
  83305. * This methods computes transformed normalized direction vectors only.
  83306. * @param x value to transform
  83307. * @param y value to transform
  83308. * @param z value to transform
  83309. * @param w value to transform
  83310. * @param transformation the transformation matrix to apply
  83311. * @param result the vector to store the results in
  83312. */
  83313. static TransformNormalFromFloatsToRef(x: number, y: number, z: number, w: number, transformation: DeepImmutable<Matrix>, result: Vector4): void;
  83314. /**
  83315. * Creates a new Vector4 from a Vector3
  83316. * @param source defines the source data
  83317. * @param w defines the 4th component (default is 0)
  83318. * @returns a new Vector4
  83319. */
  83320. static FromVector3(source: Vector3, w?: number): Vector4;
  83321. }
  83322. /**
  83323. * Class used to store quaternion data
  83324. * @see https://en.wikipedia.org/wiki/Quaternion
  83325. * @see https://doc.babylonjs.com/features/position,_rotation,_scaling
  83326. */
  83327. export class Quaternion {
  83328. /** @hidden */
  83329. _x: number;
  83330. /** @hidden */
  83331. _y: number;
  83332. /** @hidden */
  83333. _z: number;
  83334. /** @hidden */
  83335. _w: number;
  83336. /** @hidden */
  83337. _isDirty: boolean;
  83338. /** Gets or sets the x coordinate */
  83339. get x(): number;
  83340. set x(value: number);
  83341. /** Gets or sets the y coordinate */
  83342. get y(): number;
  83343. set y(value: number);
  83344. /** Gets or sets the z coordinate */
  83345. get z(): number;
  83346. set z(value: number);
  83347. /** Gets or sets the w coordinate */
  83348. get w(): number;
  83349. set w(value: number);
  83350. /**
  83351. * Creates a new Quaternion from the given floats
  83352. * @param x defines the first component (0 by default)
  83353. * @param y defines the second component (0 by default)
  83354. * @param z defines the third component (0 by default)
  83355. * @param w defines the fourth component (1.0 by default)
  83356. */
  83357. constructor(x?: number, y?: number, z?: number, w?: number);
  83358. /**
  83359. * Gets a string representation for the current quaternion
  83360. * @returns a string with the Quaternion coordinates
  83361. */
  83362. toString(): string;
  83363. /**
  83364. * Gets the class name of the quaternion
  83365. * @returns the string "Quaternion"
  83366. */
  83367. getClassName(): string;
  83368. /**
  83369. * Gets a hash code for this quaternion
  83370. * @returns the quaternion hash code
  83371. */
  83372. getHashCode(): number;
  83373. /**
  83374. * Copy the quaternion to an array
  83375. * @returns a new array populated with 4 elements from the quaternion coordinates
  83376. */
  83377. asArray(): number[];
  83378. /**
  83379. * Check if two quaternions are equals
  83380. * @param otherQuaternion defines the second operand
  83381. * @return true if the current quaternion and the given one coordinates are strictly equals
  83382. */
  83383. equals(otherQuaternion: DeepImmutable<Quaternion>): boolean;
  83384. /**
  83385. * Gets a boolean if two quaternions are equals (using an epsilon value)
  83386. * @param otherQuaternion defines the other quaternion
  83387. * @param epsilon defines the minimal distance to consider equality
  83388. * @returns true if the given quaternion coordinates are close to the current ones by a distance of epsilon.
  83389. */
  83390. equalsWithEpsilon(otherQuaternion: DeepImmutable<Quaternion>, epsilon?: number): boolean;
  83391. /**
  83392. * Clone the current quaternion
  83393. * @returns a new quaternion copied from the current one
  83394. */
  83395. clone(): Quaternion;
  83396. /**
  83397. * Copy a quaternion to the current one
  83398. * @param other defines the other quaternion
  83399. * @returns the updated current quaternion
  83400. */
  83401. copyFrom(other: DeepImmutable<Quaternion>): Quaternion;
  83402. /**
  83403. * Updates the current quaternion with the given float coordinates
  83404. * @param x defines the x coordinate
  83405. * @param y defines the y coordinate
  83406. * @param z defines the z coordinate
  83407. * @param w defines the w coordinate
  83408. * @returns the updated current quaternion
  83409. */
  83410. copyFromFloats(x: number, y: number, z: number, w: number): Quaternion;
  83411. /**
  83412. * Updates the current quaternion from the given float coordinates
  83413. * @param x defines the x coordinate
  83414. * @param y defines the y coordinate
  83415. * @param z defines the z coordinate
  83416. * @param w defines the w coordinate
  83417. * @returns the updated current quaternion
  83418. */
  83419. set(x: number, y: number, z: number, w: number): Quaternion;
  83420. /**
  83421. * Adds two quaternions
  83422. * @param other defines the second operand
  83423. * @returns a new quaternion as the addition result of the given one and the current quaternion
  83424. */
  83425. add(other: DeepImmutable<Quaternion>): Quaternion;
  83426. /**
  83427. * Add a quaternion to the current one
  83428. * @param other defines the quaternion to add
  83429. * @returns the current quaternion
  83430. */
  83431. addInPlace(other: DeepImmutable<Quaternion>): Quaternion;
  83432. /**
  83433. * Subtract two quaternions
  83434. * @param other defines the second operand
  83435. * @returns a new quaternion as the subtraction result of the given one from the current one
  83436. */
  83437. subtract(other: Quaternion): Quaternion;
  83438. /**
  83439. * Multiplies the current quaternion by a scale factor
  83440. * @param value defines the scale factor
  83441. * @returns a new quaternion set by multiplying the current quaternion coordinates by the float "scale"
  83442. */
  83443. scale(value: number): Quaternion;
  83444. /**
  83445. * Scale the current quaternion values by a factor and stores the result to a given quaternion
  83446. * @param scale defines the scale factor
  83447. * @param result defines the Quaternion object where to store the result
  83448. * @returns the unmodified current quaternion
  83449. */
  83450. scaleToRef(scale: number, result: Quaternion): Quaternion;
  83451. /**
  83452. * Multiplies in place the current quaternion by a scale factor
  83453. * @param value defines the scale factor
  83454. * @returns the current modified quaternion
  83455. */
  83456. scaleInPlace(value: number): Quaternion;
  83457. /**
  83458. * Scale the current quaternion values by a factor and add the result to a given quaternion
  83459. * @param scale defines the scale factor
  83460. * @param result defines the Quaternion object where to store the result
  83461. * @returns the unmodified current quaternion
  83462. */
  83463. scaleAndAddToRef(scale: number, result: Quaternion): Quaternion;
  83464. /**
  83465. * Multiplies two quaternions
  83466. * @param q1 defines the second operand
  83467. * @returns a new quaternion set as the multiplication result of the current one with the given one "q1"
  83468. */
  83469. multiply(q1: DeepImmutable<Quaternion>): Quaternion;
  83470. /**
  83471. * Sets the given "result" as the the multiplication result of the current one with the given one "q1"
  83472. * @param q1 defines the second operand
  83473. * @param result defines the target quaternion
  83474. * @returns the current quaternion
  83475. */
  83476. multiplyToRef(q1: DeepImmutable<Quaternion>, result: Quaternion): Quaternion;
  83477. /**
  83478. * Updates the current quaternion with the multiplication of itself with the given one "q1"
  83479. * @param q1 defines the second operand
  83480. * @returns the currentupdated quaternion
  83481. */
  83482. multiplyInPlace(q1: DeepImmutable<Quaternion>): Quaternion;
  83483. /**
  83484. * Conjugates (1-q) the current quaternion and stores the result in the given quaternion
  83485. * @param ref defines the target quaternion
  83486. * @returns the current quaternion
  83487. */
  83488. conjugateToRef(ref: Quaternion): Quaternion;
  83489. /**
  83490. * Conjugates in place (1-q) the current quaternion
  83491. * @returns the current updated quaternion
  83492. */
  83493. conjugateInPlace(): Quaternion;
  83494. /**
  83495. * Conjugates in place (1-q) the current quaternion
  83496. * @returns a new quaternion
  83497. */
  83498. conjugate(): Quaternion;
  83499. /**
  83500. * Gets length of current quaternion
  83501. * @returns the quaternion length (float)
  83502. */
  83503. length(): number;
  83504. /**
  83505. * Normalize in place the current quaternion
  83506. * @returns the current updated quaternion
  83507. */
  83508. normalize(): Quaternion;
  83509. /**
  83510. * Returns a new Vector3 set with the Euler angles translated from the current quaternion
  83511. * @param order is a reserved parameter and is ignore for now
  83512. * @returns a new Vector3 containing the Euler angles
  83513. */
  83514. toEulerAngles(order?: string): Vector3;
  83515. /**
  83516. * Sets the given vector3 "result" with the Euler angles translated from the current quaternion
  83517. * @param result defines the vector which will be filled with the Euler angles
  83518. * @param order is a reserved parameter and is ignore for now
  83519. * @returns the current unchanged quaternion
  83520. */
  83521. toEulerAnglesToRef(result: Vector3): Quaternion;
  83522. /**
  83523. * Updates the given rotation matrix with the current quaternion values
  83524. * @param result defines the target matrix
  83525. * @returns the current unchanged quaternion
  83526. */
  83527. toRotationMatrix(result: Matrix): Quaternion;
  83528. /**
  83529. * Updates the current quaternion from the given rotation matrix values
  83530. * @param matrix defines the source matrix
  83531. * @returns the current updated quaternion
  83532. */
  83533. fromRotationMatrix(matrix: DeepImmutable<Matrix>): Quaternion;
  83534. /**
  83535. * Creates a new quaternion from a rotation matrix
  83536. * @param matrix defines the source matrix
  83537. * @returns a new quaternion created from the given rotation matrix values
  83538. */
  83539. static FromRotationMatrix(matrix: DeepImmutable<Matrix>): Quaternion;
  83540. /**
  83541. * Updates the given quaternion with the given rotation matrix values
  83542. * @param matrix defines the source matrix
  83543. * @param result defines the target quaternion
  83544. */
  83545. static FromRotationMatrixToRef(matrix: DeepImmutable<Matrix>, result: Quaternion): void;
  83546. /**
  83547. * Returns the dot product (float) between the quaternions "left" and "right"
  83548. * @param left defines the left operand
  83549. * @param right defines the right operand
  83550. * @returns the dot product
  83551. */
  83552. static Dot(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>): number;
  83553. /**
  83554. * Checks if the two quaternions are close to each other
  83555. * @param quat0 defines the first quaternion to check
  83556. * @param quat1 defines the second quaternion to check
  83557. * @returns true if the two quaternions are close to each other
  83558. */
  83559. static AreClose(quat0: DeepImmutable<Quaternion>, quat1: DeepImmutable<Quaternion>): boolean;
  83560. /**
  83561. * Creates an empty quaternion
  83562. * @returns a new quaternion set to (0.0, 0.0, 0.0)
  83563. */
  83564. static Zero(): Quaternion;
  83565. /**
  83566. * Inverse a given quaternion
  83567. * @param q defines the source quaternion
  83568. * @returns a new quaternion as the inverted current quaternion
  83569. */
  83570. static Inverse(q: DeepImmutable<Quaternion>): Quaternion;
  83571. /**
  83572. * Inverse a given quaternion
  83573. * @param q defines the source quaternion
  83574. * @param result the quaternion the result will be stored in
  83575. * @returns the result quaternion
  83576. */
  83577. static InverseToRef(q: Quaternion, result: Quaternion): Quaternion;
  83578. /**
  83579. * Creates an identity quaternion
  83580. * @returns the identity quaternion
  83581. */
  83582. static Identity(): Quaternion;
  83583. /**
  83584. * Gets a boolean indicating if the given quaternion is identity
  83585. * @param quaternion defines the quaternion to check
  83586. * @returns true if the quaternion is identity
  83587. */
  83588. static IsIdentity(quaternion: DeepImmutable<Quaternion>): boolean;
  83589. /**
  83590. * Creates a quaternion from a rotation around an axis
  83591. * @param axis defines the axis to use
  83592. * @param angle defines the angle to use
  83593. * @returns a new quaternion created from the given axis (Vector3) and angle in radians (float)
  83594. */
  83595. static RotationAxis(axis: DeepImmutable<Vector3>, angle: number): Quaternion;
  83596. /**
  83597. * Creates a rotation around an axis and stores it into the given quaternion
  83598. * @param axis defines the axis to use
  83599. * @param angle defines the angle to use
  83600. * @param result defines the target quaternion
  83601. * @returns the target quaternion
  83602. */
  83603. static RotationAxisToRef(axis: DeepImmutable<Vector3>, angle: number, result: Quaternion): Quaternion;
  83604. /**
  83605. * Creates a new quaternion from data stored into an array
  83606. * @param array defines the data source
  83607. * @param offset defines the offset in the source array where the data starts
  83608. * @returns a new quaternion
  83609. */
  83610. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Quaternion;
  83611. /**
  83612. * Updates the given quaternion "result" from the starting index of the given array.
  83613. * @param array the array to pull values from
  83614. * @param offset the offset into the array to start at
  83615. * @param result the quaternion to store the result in
  83616. */
  83617. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Quaternion): void;
  83618. /**
  83619. * Create a quaternion from Euler rotation angles
  83620. * @param x Pitch
  83621. * @param y Yaw
  83622. * @param z Roll
  83623. * @returns the new Quaternion
  83624. */
  83625. static FromEulerAngles(x: number, y: number, z: number): Quaternion;
  83626. /**
  83627. * Updates a quaternion from Euler rotation angles
  83628. * @param x Pitch
  83629. * @param y Yaw
  83630. * @param z Roll
  83631. * @param result the quaternion to store the result
  83632. * @returns the updated quaternion
  83633. */
  83634. static FromEulerAnglesToRef(x: number, y: number, z: number, result: Quaternion): Quaternion;
  83635. /**
  83636. * Create a quaternion from Euler rotation vector
  83637. * @param vec the Euler vector (x Pitch, y Yaw, z Roll)
  83638. * @returns the new Quaternion
  83639. */
  83640. static FromEulerVector(vec: DeepImmutable<Vector3>): Quaternion;
  83641. /**
  83642. * Updates a quaternion from Euler rotation vector
  83643. * @param vec the Euler vector (x Pitch, y Yaw, z Roll)
  83644. * @param result the quaternion to store the result
  83645. * @returns the updated quaternion
  83646. */
  83647. static FromEulerVectorToRef(vec: DeepImmutable<Vector3>, result: Quaternion): Quaternion;
  83648. /**
  83649. * Creates a new quaternion from the given Euler float angles (y, x, z)
  83650. * @param yaw defines the rotation around Y axis
  83651. * @param pitch defines the rotation around X axis
  83652. * @param roll defines the rotation around Z axis
  83653. * @returns the new quaternion
  83654. */
  83655. static RotationYawPitchRoll(yaw: number, pitch: number, roll: number): Quaternion;
  83656. /**
  83657. * Creates a new rotation from the given Euler float angles (y, x, z) and stores it in the target quaternion
  83658. * @param yaw defines the rotation around Y axis
  83659. * @param pitch defines the rotation around X axis
  83660. * @param roll defines the rotation around Z axis
  83661. * @param result defines the target quaternion
  83662. */
  83663. static RotationYawPitchRollToRef(yaw: number, pitch: number, roll: number, result: Quaternion): void;
  83664. /**
  83665. * Creates a new quaternion from the given Euler float angles expressed in z-x-z orientation
  83666. * @param alpha defines the rotation around first axis
  83667. * @param beta defines the rotation around second axis
  83668. * @param gamma defines the rotation around third axis
  83669. * @returns the new quaternion
  83670. */
  83671. static RotationAlphaBetaGamma(alpha: number, beta: number, gamma: number): Quaternion;
  83672. /**
  83673. * Creates a new quaternion from the given Euler float angles expressed in z-x-z orientation and stores it in the target quaternion
  83674. * @param alpha defines the rotation around first axis
  83675. * @param beta defines the rotation around second axis
  83676. * @param gamma defines the rotation around third axis
  83677. * @param result defines the target quaternion
  83678. */
  83679. static RotationAlphaBetaGammaToRef(alpha: number, beta: number, gamma: number, result: Quaternion): void;
  83680. /**
  83681. * 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)
  83682. * @param axis1 defines the first axis
  83683. * @param axis2 defines the second axis
  83684. * @param axis3 defines the third axis
  83685. * @returns the new quaternion
  83686. */
  83687. static RotationQuaternionFromAxis(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>): Quaternion;
  83688. /**
  83689. * 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
  83690. * @param axis1 defines the first axis
  83691. * @param axis2 defines the second axis
  83692. * @param axis3 defines the third axis
  83693. * @param ref defines the target quaternion
  83694. */
  83695. static RotationQuaternionFromAxisToRef(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>, ref: Quaternion): void;
  83696. /**
  83697. * Interpolates between two quaternions
  83698. * @param left defines first quaternion
  83699. * @param right defines second quaternion
  83700. * @param amount defines the gradient to use
  83701. * @returns the new interpolated quaternion
  83702. */
  83703. static Slerp(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>, amount: number): Quaternion;
  83704. /**
  83705. * Interpolates between two quaternions and stores it into a target quaternion
  83706. * @param left defines first quaternion
  83707. * @param right defines second quaternion
  83708. * @param amount defines the gradient to use
  83709. * @param result defines the target quaternion
  83710. */
  83711. static SlerpToRef(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>, amount: number, result: Quaternion): void;
  83712. /**
  83713. * Interpolate between two quaternions using Hermite interpolation
  83714. * @param value1 defines first quaternion
  83715. * @param tangent1 defines the incoming tangent
  83716. * @param value2 defines second quaternion
  83717. * @param tangent2 defines the outgoing tangent
  83718. * @param amount defines the target quaternion
  83719. * @returns the new interpolated quaternion
  83720. */
  83721. static Hermite(value1: DeepImmutable<Quaternion>, tangent1: DeepImmutable<Quaternion>, value2: DeepImmutable<Quaternion>, tangent2: DeepImmutable<Quaternion>, amount: number): Quaternion;
  83722. }
  83723. /**
  83724. * Class used to store matrix data (4x4)
  83725. */
  83726. export class Matrix {
  83727. /**
  83728. * Gets the precision of matrix computations
  83729. */
  83730. static get Use64Bits(): boolean;
  83731. private static _updateFlagSeed;
  83732. private static _identityReadOnly;
  83733. private _isIdentity;
  83734. private _isIdentityDirty;
  83735. private _isIdentity3x2;
  83736. private _isIdentity3x2Dirty;
  83737. /**
  83738. * Gets the update flag of the matrix which is an unique number for the matrix.
  83739. * It will be incremented every time the matrix data change.
  83740. * You can use it to speed the comparison between two versions of the same matrix.
  83741. */
  83742. updateFlag: number;
  83743. private readonly _m;
  83744. /**
  83745. * Gets the internal data of the matrix
  83746. */
  83747. get m(): DeepImmutable<Float32Array | Array<number>>;
  83748. /** @hidden */
  83749. _markAsUpdated(): void;
  83750. /** @hidden */
  83751. private _updateIdentityStatus;
  83752. /**
  83753. * Creates an empty matrix (filled with zeros)
  83754. */
  83755. constructor();
  83756. /**
  83757. * Check if the current matrix is identity
  83758. * @returns true is the matrix is the identity matrix
  83759. */
  83760. isIdentity(): boolean;
  83761. /**
  83762. * Check if the current matrix is identity as a texture matrix (3x2 store in 4x4)
  83763. * @returns true is the matrix is the identity matrix
  83764. */
  83765. isIdentityAs3x2(): boolean;
  83766. /**
  83767. * Gets the determinant of the matrix
  83768. * @returns the matrix determinant
  83769. */
  83770. determinant(): number;
  83771. /**
  83772. * Returns the matrix as a Float32Array or Array<number>
  83773. * @returns the matrix underlying array
  83774. */
  83775. toArray(): DeepImmutable<Float32Array | Array<number>>;
  83776. /**
  83777. * Returns the matrix as a Float32Array or Array<number>
  83778. * @returns the matrix underlying array.
  83779. */
  83780. asArray(): DeepImmutable<Float32Array | Array<number>>;
  83781. /**
  83782. * Inverts the current matrix in place
  83783. * @returns the current inverted matrix
  83784. */
  83785. invert(): Matrix;
  83786. /**
  83787. * Sets all the matrix elements to zero
  83788. * @returns the current matrix
  83789. */
  83790. reset(): Matrix;
  83791. /**
  83792. * Adds the current matrix with a second one
  83793. * @param other defines the matrix to add
  83794. * @returns a new matrix as the addition of the current matrix and the given one
  83795. */
  83796. add(other: DeepImmutable<Matrix>): Matrix;
  83797. /**
  83798. * Sets the given matrix "result" to the addition of the current matrix and the given one
  83799. * @param other defines the matrix to add
  83800. * @param result defines the target matrix
  83801. * @returns the current matrix
  83802. */
  83803. addToRef(other: DeepImmutable<Matrix>, result: Matrix): Matrix;
  83804. /**
  83805. * Adds in place the given matrix to the current matrix
  83806. * @param other defines the second operand
  83807. * @returns the current updated matrix
  83808. */
  83809. addToSelf(other: DeepImmutable<Matrix>): Matrix;
  83810. /**
  83811. * Sets the given matrix to the current inverted Matrix
  83812. * @param other defines the target matrix
  83813. * @returns the unmodified current matrix
  83814. */
  83815. invertToRef(other: Matrix): Matrix;
  83816. /**
  83817. * add a value at the specified position in the current Matrix
  83818. * @param index the index of the value within the matrix. between 0 and 15.
  83819. * @param value the value to be added
  83820. * @returns the current updated matrix
  83821. */
  83822. addAtIndex(index: number, value: number): Matrix;
  83823. /**
  83824. * mutiply the specified position in the current Matrix by a value
  83825. * @param index the index of the value within the matrix. between 0 and 15.
  83826. * @param value the value to be added
  83827. * @returns the current updated matrix
  83828. */
  83829. multiplyAtIndex(index: number, value: number): Matrix;
  83830. /**
  83831. * Inserts the translation vector (using 3 floats) in the current matrix
  83832. * @param x defines the 1st component of the translation
  83833. * @param y defines the 2nd component of the translation
  83834. * @param z defines the 3rd component of the translation
  83835. * @returns the current updated matrix
  83836. */
  83837. setTranslationFromFloats(x: number, y: number, z: number): Matrix;
  83838. /**
  83839. * Adds the translation vector (using 3 floats) in the current matrix
  83840. * @param x defines the 1st component of the translation
  83841. * @param y defines the 2nd component of the translation
  83842. * @param z defines the 3rd component of the translation
  83843. * @returns the current updated matrix
  83844. */
  83845. addTranslationFromFloats(x: number, y: number, z: number): Matrix;
  83846. /**
  83847. * Inserts the translation vector in the current matrix
  83848. * @param vector3 defines the translation to insert
  83849. * @returns the current updated matrix
  83850. */
  83851. setTranslation(vector3: DeepImmutable<Vector3>): Matrix;
  83852. /**
  83853. * Gets the translation value of the current matrix
  83854. * @returns a new Vector3 as the extracted translation from the matrix
  83855. */
  83856. getTranslation(): Vector3;
  83857. /**
  83858. * Fill a Vector3 with the extracted translation from the matrix
  83859. * @param result defines the Vector3 where to store the translation
  83860. * @returns the current matrix
  83861. */
  83862. getTranslationToRef(result: Vector3): Matrix;
  83863. /**
  83864. * Remove rotation and scaling part from the matrix
  83865. * @returns the updated matrix
  83866. */
  83867. removeRotationAndScaling(): Matrix;
  83868. /**
  83869. * Multiply two matrices
  83870. * @param other defines the second operand
  83871. * @returns a new matrix set with the multiplication result of the current Matrix and the given one
  83872. */
  83873. multiply(other: DeepImmutable<Matrix>): Matrix;
  83874. /**
  83875. * Copy the current matrix from the given one
  83876. * @param other defines the source matrix
  83877. * @returns the current updated matrix
  83878. */
  83879. copyFrom(other: DeepImmutable<Matrix>): Matrix;
  83880. /**
  83881. * Populates the given array from the starting index with the current matrix values
  83882. * @param array defines the target array
  83883. * @param offset defines the offset in the target array where to start storing values
  83884. * @returns the current matrix
  83885. */
  83886. copyToArray(array: Float32Array | Array<number>, offset?: number): Matrix;
  83887. /**
  83888. * Sets the given matrix "result" with the multiplication result of the current Matrix and the given one
  83889. * @param other defines the second operand
  83890. * @param result defines the matrix where to store the multiplication
  83891. * @returns the current matrix
  83892. */
  83893. multiplyToRef(other: DeepImmutable<Matrix>, result: Matrix): Matrix;
  83894. /**
  83895. * Sets the Float32Array "result" from the given index "offset" with the multiplication of the current matrix and the given one
  83896. * @param other defines the second operand
  83897. * @param result defines the array where to store the multiplication
  83898. * @param offset defines the offset in the target array where to start storing values
  83899. * @returns the current matrix
  83900. */
  83901. multiplyToArray(other: DeepImmutable<Matrix>, result: Float32Array | Array<number>, offset: number): Matrix;
  83902. /**
  83903. * Check equality between this matrix and a second one
  83904. * @param value defines the second matrix to compare
  83905. * @returns true is the current matrix and the given one values are strictly equal
  83906. */
  83907. equals(value: DeepImmutable<Matrix>): boolean;
  83908. /**
  83909. * Clone the current matrix
  83910. * @returns a new matrix from the current matrix
  83911. */
  83912. clone(): Matrix;
  83913. /**
  83914. * Returns the name of the current matrix class
  83915. * @returns the string "Matrix"
  83916. */
  83917. getClassName(): string;
  83918. /**
  83919. * Gets the hash code of the current matrix
  83920. * @returns the hash code
  83921. */
  83922. getHashCode(): number;
  83923. /**
  83924. * Decomposes the current Matrix into a translation, rotation and scaling components
  83925. * @param scale defines the scale vector3 given as a reference to update
  83926. * @param rotation defines the rotation quaternion given as a reference to update
  83927. * @param translation defines the translation vector3 given as a reference to update
  83928. * @returns true if operation was successful
  83929. */
  83930. decompose(scale?: Vector3, rotation?: Quaternion, translation?: Vector3): boolean;
  83931. /**
  83932. * Gets specific row of the matrix
  83933. * @param index defines the number of the row to get
  83934. * @returns the index-th row of the current matrix as a new Vector4
  83935. */
  83936. getRow(index: number): Nullable<Vector4>;
  83937. /**
  83938. * Sets the index-th row of the current matrix to the vector4 values
  83939. * @param index defines the number of the row to set
  83940. * @param row defines the target vector4
  83941. * @returns the updated current matrix
  83942. */
  83943. setRow(index: number, row: Vector4): Matrix;
  83944. /**
  83945. * Compute the transpose of the matrix
  83946. * @returns the new transposed matrix
  83947. */
  83948. transpose(): Matrix;
  83949. /**
  83950. * Compute the transpose of the matrix and store it in a given matrix
  83951. * @param result defines the target matrix
  83952. * @returns the current matrix
  83953. */
  83954. transposeToRef(result: Matrix): Matrix;
  83955. /**
  83956. * Sets the index-th row of the current matrix with the given 4 x float values
  83957. * @param index defines the row index
  83958. * @param x defines the x component to set
  83959. * @param y defines the y component to set
  83960. * @param z defines the z component to set
  83961. * @param w defines the w component to set
  83962. * @returns the updated current matrix
  83963. */
  83964. setRowFromFloats(index: number, x: number, y: number, z: number, w: number): Matrix;
  83965. /**
  83966. * Compute a new matrix set with the current matrix values multiplied by scale (float)
  83967. * @param scale defines the scale factor
  83968. * @returns a new matrix
  83969. */
  83970. scale(scale: number): Matrix;
  83971. /**
  83972. * Scale the current matrix values by a factor to a given result matrix
  83973. * @param scale defines the scale factor
  83974. * @param result defines the matrix to store the result
  83975. * @returns the current matrix
  83976. */
  83977. scaleToRef(scale: number, result: Matrix): Matrix;
  83978. /**
  83979. * Scale the current matrix values by a factor and add the result to a given matrix
  83980. * @param scale defines the scale factor
  83981. * @param result defines the Matrix to store the result
  83982. * @returns the current matrix
  83983. */
  83984. scaleAndAddToRef(scale: number, result: Matrix): Matrix;
  83985. /**
  83986. * Writes to the given matrix a normal matrix, computed from this one (using values from identity matrix for fourth row and column).
  83987. * @param ref matrix to store the result
  83988. */
  83989. toNormalMatrix(ref: Matrix): void;
  83990. /**
  83991. * Gets only rotation part of the current matrix
  83992. * @returns a new matrix sets to the extracted rotation matrix from the current one
  83993. */
  83994. getRotationMatrix(): Matrix;
  83995. /**
  83996. * Extracts the rotation matrix from the current one and sets it as the given "result"
  83997. * @param result defines the target matrix to store data to
  83998. * @returns the current matrix
  83999. */
  84000. getRotationMatrixToRef(result: Matrix): Matrix;
  84001. /**
  84002. * Toggles model matrix from being right handed to left handed in place and vice versa
  84003. */
  84004. toggleModelMatrixHandInPlace(): void;
  84005. /**
  84006. * Toggles projection matrix from being right handed to left handed in place and vice versa
  84007. */
  84008. toggleProjectionMatrixHandInPlace(): void;
  84009. /**
  84010. * Creates a matrix from an array
  84011. * @param array defines the source array
  84012. * @param offset defines an offset in the source array
  84013. * @returns a new Matrix set from the starting index of the given array
  84014. */
  84015. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Matrix;
  84016. /**
  84017. * Copy the content of an array into a given matrix
  84018. * @param array defines the source array
  84019. * @param offset defines an offset in the source array
  84020. * @param result defines the target matrix
  84021. */
  84022. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Matrix): void;
  84023. /**
  84024. * Stores an array into a matrix after having multiplied each component by a given factor
  84025. * @param array defines the source array
  84026. * @param offset defines the offset in the source array
  84027. * @param scale defines the scaling factor
  84028. * @param result defines the target matrix
  84029. */
  84030. static FromFloat32ArrayToRefScaled(array: DeepImmutable<Float32Array | Array<number>>, offset: number, scale: number, result: Matrix): void;
  84031. /**
  84032. * Gets an identity matrix that must not be updated
  84033. */
  84034. static get IdentityReadOnly(): DeepImmutable<Matrix>;
  84035. /**
  84036. * Stores a list of values (16) inside a given matrix
  84037. * @param initialM11 defines 1st value of 1st row
  84038. * @param initialM12 defines 2nd value of 1st row
  84039. * @param initialM13 defines 3rd value of 1st row
  84040. * @param initialM14 defines 4th value of 1st row
  84041. * @param initialM21 defines 1st value of 2nd row
  84042. * @param initialM22 defines 2nd value of 2nd row
  84043. * @param initialM23 defines 3rd value of 2nd row
  84044. * @param initialM24 defines 4th value of 2nd row
  84045. * @param initialM31 defines 1st value of 3rd row
  84046. * @param initialM32 defines 2nd value of 3rd row
  84047. * @param initialM33 defines 3rd value of 3rd row
  84048. * @param initialM34 defines 4th value of 3rd row
  84049. * @param initialM41 defines 1st value of 4th row
  84050. * @param initialM42 defines 2nd value of 4th row
  84051. * @param initialM43 defines 3rd value of 4th row
  84052. * @param initialM44 defines 4th value of 4th row
  84053. * @param result defines the target matrix
  84054. */
  84055. 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;
  84056. /**
  84057. * Creates new matrix from a list of values (16)
  84058. * @param initialM11 defines 1st value of 1st row
  84059. * @param initialM12 defines 2nd value of 1st row
  84060. * @param initialM13 defines 3rd value of 1st row
  84061. * @param initialM14 defines 4th value of 1st row
  84062. * @param initialM21 defines 1st value of 2nd row
  84063. * @param initialM22 defines 2nd value of 2nd row
  84064. * @param initialM23 defines 3rd value of 2nd row
  84065. * @param initialM24 defines 4th value of 2nd row
  84066. * @param initialM31 defines 1st value of 3rd row
  84067. * @param initialM32 defines 2nd value of 3rd row
  84068. * @param initialM33 defines 3rd value of 3rd row
  84069. * @param initialM34 defines 4th value of 3rd row
  84070. * @param initialM41 defines 1st value of 4th row
  84071. * @param initialM42 defines 2nd value of 4th row
  84072. * @param initialM43 defines 3rd value of 4th row
  84073. * @param initialM44 defines 4th value of 4th row
  84074. * @returns the new matrix
  84075. */
  84076. 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;
  84077. /**
  84078. * Creates a new matrix composed by merging scale (vector3), rotation (quaternion) and translation (vector3)
  84079. * @param scale defines the scale vector3
  84080. * @param rotation defines the rotation quaternion
  84081. * @param translation defines the translation vector3
  84082. * @returns a new matrix
  84083. */
  84084. static Compose(scale: DeepImmutable<Vector3>, rotation: DeepImmutable<Quaternion>, translation: DeepImmutable<Vector3>): Matrix;
  84085. /**
  84086. * Sets a matrix to a value composed by merging scale (vector3), rotation (quaternion) and translation (vector3)
  84087. * @param scale defines the scale vector3
  84088. * @param rotation defines the rotation quaternion
  84089. * @param translation defines the translation vector3
  84090. * @param result defines the target matrix
  84091. */
  84092. static ComposeToRef(scale: DeepImmutable<Vector3>, rotation: DeepImmutable<Quaternion>, translation: DeepImmutable<Vector3>, result: Matrix): void;
  84093. /**
  84094. * Creates a new identity matrix
  84095. * @returns a new identity matrix
  84096. */
  84097. static Identity(): Matrix;
  84098. /**
  84099. * Creates a new identity matrix and stores the result in a given matrix
  84100. * @param result defines the target matrix
  84101. */
  84102. static IdentityToRef(result: Matrix): void;
  84103. /**
  84104. * Creates a new zero matrix
  84105. * @returns a new zero matrix
  84106. */
  84107. static Zero(): Matrix;
  84108. /**
  84109. * Creates a new rotation matrix for "angle" radians around the X axis
  84110. * @param angle defines the angle (in radians) to use
  84111. * @return the new matrix
  84112. */
  84113. static RotationX(angle: number): Matrix;
  84114. /**
  84115. * Creates a new matrix as the invert of a given matrix
  84116. * @param source defines the source matrix
  84117. * @returns the new matrix
  84118. */
  84119. static Invert(source: DeepImmutable<Matrix>): Matrix;
  84120. /**
  84121. * Creates a new rotation matrix for "angle" radians around the X axis and stores it in a given matrix
  84122. * @param angle defines the angle (in radians) to use
  84123. * @param result defines the target matrix
  84124. */
  84125. static RotationXToRef(angle: number, result: Matrix): void;
  84126. /**
  84127. * Creates a new rotation matrix for "angle" radians around the Y axis
  84128. * @param angle defines the angle (in radians) to use
  84129. * @return the new matrix
  84130. */
  84131. static RotationY(angle: number): Matrix;
  84132. /**
  84133. * Creates a new rotation matrix for "angle" radians around the Y axis and stores it in a given matrix
  84134. * @param angle defines the angle (in radians) to use
  84135. * @param result defines the target matrix
  84136. */
  84137. static RotationYToRef(angle: number, result: Matrix): void;
  84138. /**
  84139. * Creates a new rotation matrix for "angle" radians around the Z axis
  84140. * @param angle defines the angle (in radians) to use
  84141. * @return the new matrix
  84142. */
  84143. static RotationZ(angle: number): Matrix;
  84144. /**
  84145. * Creates a new rotation matrix for "angle" radians around the Z axis and stores it in a given matrix
  84146. * @param angle defines the angle (in radians) to use
  84147. * @param result defines the target matrix
  84148. */
  84149. static RotationZToRef(angle: number, result: Matrix): void;
  84150. /**
  84151. * Creates a new rotation matrix for "angle" radians around the given axis
  84152. * @param axis defines the axis to use
  84153. * @param angle defines the angle (in radians) to use
  84154. * @return the new matrix
  84155. */
  84156. static RotationAxis(axis: DeepImmutable<Vector3>, angle: number): Matrix;
  84157. /**
  84158. * Creates a new rotation matrix for "angle" radians around the given axis and stores it in a given matrix
  84159. * @param axis defines the axis to use
  84160. * @param angle defines the angle (in radians) to use
  84161. * @param result defines the target matrix
  84162. */
  84163. static RotationAxisToRef(axis: DeepImmutable<Vector3>, angle: number, result: Matrix): void;
  84164. /**
  84165. * Takes normalised vectors and returns a rotation matrix to align "from" with "to".
  84166. * Taken from http://www.iquilezles.org/www/articles/noacos/noacos.htm
  84167. * @param from defines the vector to align
  84168. * @param to defines the vector to align to
  84169. * @param result defines the target matrix
  84170. */
  84171. static RotationAlignToRef(from: DeepImmutable<Vector3>, to: DeepImmutable<Vector3>, result: Matrix): void;
  84172. /**
  84173. * Creates a rotation matrix
  84174. * @param yaw defines the yaw angle in radians (Y axis)
  84175. * @param pitch defines the pitch angle in radians (X axis)
  84176. * @param roll defines the roll angle in radians (Z axis)
  84177. * @returns the new rotation matrix
  84178. */
  84179. static RotationYawPitchRoll(yaw: number, pitch: number, roll: number): Matrix;
  84180. /**
  84181. * Creates a rotation matrix and stores it in a given matrix
  84182. * @param yaw defines the yaw angle in radians (Y axis)
  84183. * @param pitch defines the pitch angle in radians (X axis)
  84184. * @param roll defines the roll angle in radians (Z axis)
  84185. * @param result defines the target matrix
  84186. */
  84187. static RotationYawPitchRollToRef(yaw: number, pitch: number, roll: number, result: Matrix): void;
  84188. /**
  84189. * Creates a scaling matrix
  84190. * @param x defines the scale factor on X axis
  84191. * @param y defines the scale factor on Y axis
  84192. * @param z defines the scale factor on Z axis
  84193. * @returns the new matrix
  84194. */
  84195. static Scaling(x: number, y: number, z: number): Matrix;
  84196. /**
  84197. * Creates a scaling matrix and stores it in a given matrix
  84198. * @param x defines the scale factor on X axis
  84199. * @param y defines the scale factor on Y axis
  84200. * @param z defines the scale factor on Z axis
  84201. * @param result defines the target matrix
  84202. */
  84203. static ScalingToRef(x: number, y: number, z: number, result: Matrix): void;
  84204. /**
  84205. * Creates a translation matrix
  84206. * @param x defines the translation on X axis
  84207. * @param y defines the translation on Y axis
  84208. * @param z defines the translationon Z axis
  84209. * @returns the new matrix
  84210. */
  84211. static Translation(x: number, y: number, z: number): Matrix;
  84212. /**
  84213. * Creates a translation matrix and stores it in a given matrix
  84214. * @param x defines the translation on X axis
  84215. * @param y defines the translation on Y axis
  84216. * @param z defines the translationon Z axis
  84217. * @param result defines the target matrix
  84218. */
  84219. static TranslationToRef(x: number, y: number, z: number, result: Matrix): void;
  84220. /**
  84221. * Returns a new Matrix whose values are the interpolated values for "gradient" (float) between the ones of the matrices "startValue" and "endValue".
  84222. * @param startValue defines the start value
  84223. * @param endValue defines the end value
  84224. * @param gradient defines the gradient factor
  84225. * @returns the new matrix
  84226. */
  84227. static Lerp(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number): Matrix;
  84228. /**
  84229. * Set the given matrix "result" as the interpolated values for "gradient" (float) between the ones of the matrices "startValue" and "endValue".
  84230. * @param startValue defines the start value
  84231. * @param endValue defines the end value
  84232. * @param gradient defines the gradient factor
  84233. * @param result defines the Matrix object where to store data
  84234. */
  84235. static LerpToRef(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number, result: Matrix): void;
  84236. /**
  84237. * Builds a new matrix whose values are computed by:
  84238. * * decomposing the the "startValue" and "endValue" matrices into their respective scale, rotation and translation matrices
  84239. * * interpolating for "gradient" (float) the values between each of these decomposed matrices between the start and the end
  84240. * * recomposing a new matrix from these 3 interpolated scale, rotation and translation matrices
  84241. * @param startValue defines the first matrix
  84242. * @param endValue defines the second matrix
  84243. * @param gradient defines the gradient between the two matrices
  84244. * @returns the new matrix
  84245. */
  84246. static DecomposeLerp(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number): Matrix;
  84247. /**
  84248. * Update a matrix to values which are computed by:
  84249. * * decomposing the the "startValue" and "endValue" matrices into their respective scale, rotation and translation matrices
  84250. * * interpolating for "gradient" (float) the values between each of these decomposed matrices between the start and the end
  84251. * * recomposing a new matrix from these 3 interpolated scale, rotation and translation matrices
  84252. * @param startValue defines the first matrix
  84253. * @param endValue defines the second matrix
  84254. * @param gradient defines the gradient between the two matrices
  84255. * @param result defines the target matrix
  84256. */
  84257. static DecomposeLerpToRef(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number, result: Matrix): void;
  84258. /**
  84259. * 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"
  84260. * This function works in left handed mode
  84261. * @param eye defines the final position of the entity
  84262. * @param target defines where the entity should look at
  84263. * @param up defines the up vector for the entity
  84264. * @returns the new matrix
  84265. */
  84266. static LookAtLH(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>): Matrix;
  84267. /**
  84268. * 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".
  84269. * This function works in left handed mode
  84270. * @param eye defines the final position of the entity
  84271. * @param target defines where the entity should look at
  84272. * @param up defines the up vector for the entity
  84273. * @param result defines the target matrix
  84274. */
  84275. static LookAtLHToRef(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>, result: Matrix): void;
  84276. /**
  84277. * 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"
  84278. * This function works in right handed mode
  84279. * @param eye defines the final position of the entity
  84280. * @param target defines where the entity should look at
  84281. * @param up defines the up vector for the entity
  84282. * @returns the new matrix
  84283. */
  84284. static LookAtRH(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>): Matrix;
  84285. /**
  84286. * 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".
  84287. * This function works in right handed mode
  84288. * @param eye defines the final position of the entity
  84289. * @param target defines where the entity should look at
  84290. * @param up defines the up vector for the entity
  84291. * @param result defines the target matrix
  84292. */
  84293. static LookAtRHToRef(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>, result: Matrix): void;
  84294. /**
  84295. * Create a left-handed orthographic projection matrix
  84296. * @param width defines the viewport width
  84297. * @param height defines the viewport height
  84298. * @param znear defines the near clip plane
  84299. * @param zfar defines the far clip plane
  84300. * @returns a new matrix as a left-handed orthographic projection matrix
  84301. */
  84302. static OrthoLH(width: number, height: number, znear: number, zfar: number): Matrix;
  84303. /**
  84304. * Store a left-handed orthographic projection to a given matrix
  84305. * @param width defines the viewport width
  84306. * @param height defines the viewport height
  84307. * @param znear defines the near clip plane
  84308. * @param zfar defines the far clip plane
  84309. * @param result defines the target matrix
  84310. */
  84311. static OrthoLHToRef(width: number, height: number, znear: number, zfar: number, result: Matrix): void;
  84312. /**
  84313. * Create a left-handed orthographic projection matrix
  84314. * @param left defines the viewport left coordinate
  84315. * @param right defines the viewport right coordinate
  84316. * @param bottom defines the viewport bottom coordinate
  84317. * @param top defines the viewport top coordinate
  84318. * @param znear defines the near clip plane
  84319. * @param zfar defines the far clip plane
  84320. * @returns a new matrix as a left-handed orthographic projection matrix
  84321. */
  84322. static OrthoOffCenterLH(left: number, right: number, bottom: number, top: number, znear: number, zfar: number): Matrix;
  84323. /**
  84324. * Stores a left-handed orthographic projection into a given matrix
  84325. * @param left defines the viewport left coordinate
  84326. * @param right defines the viewport right coordinate
  84327. * @param bottom defines the viewport bottom coordinate
  84328. * @param top defines the viewport top coordinate
  84329. * @param znear defines the near clip plane
  84330. * @param zfar defines the far clip plane
  84331. * @param result defines the target matrix
  84332. */
  84333. static OrthoOffCenterLHToRef(left: number, right: number, bottom: number, top: number, znear: number, zfar: number, result: Matrix): void;
  84334. /**
  84335. * Creates a right-handed orthographic projection matrix
  84336. * @param left defines the viewport left coordinate
  84337. * @param right defines the viewport right coordinate
  84338. * @param bottom defines the viewport bottom coordinate
  84339. * @param top defines the viewport top coordinate
  84340. * @param znear defines the near clip plane
  84341. * @param zfar defines the far clip plane
  84342. * @returns a new matrix as a right-handed orthographic projection matrix
  84343. */
  84344. static OrthoOffCenterRH(left: number, right: number, bottom: number, top: number, znear: number, zfar: number): Matrix;
  84345. /**
  84346. * Stores a right-handed orthographic projection into a given matrix
  84347. * @param left defines the viewport left coordinate
  84348. * @param right defines the viewport right coordinate
  84349. * @param bottom defines the viewport bottom coordinate
  84350. * @param top defines the viewport top coordinate
  84351. * @param znear defines the near clip plane
  84352. * @param zfar defines the far clip plane
  84353. * @param result defines the target matrix
  84354. */
  84355. static OrthoOffCenterRHToRef(left: number, right: number, bottom: number, top: number, znear: number, zfar: number, result: Matrix): void;
  84356. /**
  84357. * Creates a left-handed perspective projection matrix
  84358. * @param width defines the viewport width
  84359. * @param height defines the viewport height
  84360. * @param znear defines the near clip plane
  84361. * @param zfar defines the far clip plane
  84362. * @returns a new matrix as a left-handed perspective projection matrix
  84363. */
  84364. static PerspectiveLH(width: number, height: number, znear: number, zfar: number): Matrix;
  84365. /**
  84366. * Creates a left-handed perspective projection matrix
  84367. * @param fov defines the horizontal field of view
  84368. * @param aspect defines the aspect ratio
  84369. * @param znear defines the near clip plane
  84370. * @param zfar defines the far clip plane
  84371. * @returns a new matrix as a left-handed perspective projection matrix
  84372. */
  84373. static PerspectiveFovLH(fov: number, aspect: number, znear: number, zfar: number): Matrix;
  84374. /**
  84375. * Stores a left-handed perspective projection into a given matrix
  84376. * @param fov defines the horizontal field of view
  84377. * @param aspect defines the aspect ratio
  84378. * @param znear defines the near clip plane
  84379. * @param zfar defines the far clip plane
  84380. * @param result defines the target matrix
  84381. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  84382. */
  84383. static PerspectiveFovLHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  84384. /**
  84385. * Stores a left-handed perspective projection into a given matrix with depth reversed
  84386. * @param fov defines the horizontal field of view
  84387. * @param aspect defines the aspect ratio
  84388. * @param znear defines the near clip plane
  84389. * @param zfar not used as infinity is used as far clip
  84390. * @param result defines the target matrix
  84391. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  84392. */
  84393. static PerspectiveFovReverseLHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  84394. /**
  84395. * Creates a right-handed perspective projection matrix
  84396. * @param fov defines the horizontal field of view
  84397. * @param aspect defines the aspect ratio
  84398. * @param znear defines the near clip plane
  84399. * @param zfar defines the far clip plane
  84400. * @returns a new matrix as a right-handed perspective projection matrix
  84401. */
  84402. static PerspectiveFovRH(fov: number, aspect: number, znear: number, zfar: number): Matrix;
  84403. /**
  84404. * Stores a right-handed perspective projection into a given matrix
  84405. * @param fov defines the horizontal field of view
  84406. * @param aspect defines the aspect ratio
  84407. * @param znear defines the near clip plane
  84408. * @param zfar defines the far clip plane
  84409. * @param result defines the target matrix
  84410. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  84411. */
  84412. static PerspectiveFovRHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  84413. /**
  84414. * Stores a right-handed perspective projection into a given matrix
  84415. * @param fov defines the horizontal field of view
  84416. * @param aspect defines the aspect ratio
  84417. * @param znear defines the near clip plane
  84418. * @param zfar not used as infinity is used as far clip
  84419. * @param result defines the target matrix
  84420. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  84421. */
  84422. static PerspectiveFovReverseRHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  84423. /**
  84424. * Stores a perspective projection for WebVR info a given matrix
  84425. * @param fov defines the field of view
  84426. * @param znear defines the near clip plane
  84427. * @param zfar defines the far clip plane
  84428. * @param result defines the target matrix
  84429. * @param rightHanded defines if the matrix must be in right-handed mode (false by default)
  84430. */
  84431. static PerspectiveFovWebVRToRef(fov: {
  84432. upDegrees: number;
  84433. downDegrees: number;
  84434. leftDegrees: number;
  84435. rightDegrees: number;
  84436. }, znear: number, zfar: number, result: Matrix, rightHanded?: boolean): void;
  84437. /**
  84438. * Computes a complete transformation matrix
  84439. * @param viewport defines the viewport to use
  84440. * @param world defines the world matrix
  84441. * @param view defines the view matrix
  84442. * @param projection defines the projection matrix
  84443. * @param zmin defines the near clip plane
  84444. * @param zmax defines the far clip plane
  84445. * @returns the transformation matrix
  84446. */
  84447. static GetFinalMatrix(viewport: DeepImmutable<Viewport>, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, zmin: number, zmax: number): Matrix;
  84448. /**
  84449. * Extracts a 2x2 matrix from a given matrix and store the result in a Float32Array
  84450. * @param matrix defines the matrix to use
  84451. * @returns a new Float32Array array with 4 elements : the 2x2 matrix extracted from the given matrix
  84452. */
  84453. static GetAsMatrix2x2(matrix: DeepImmutable<Matrix>): Float32Array | Array<number>;
  84454. /**
  84455. * Extracts a 3x3 matrix from a given matrix and store the result in a Float32Array
  84456. * @param matrix defines the matrix to use
  84457. * @returns a new Float32Array array with 9 elements : the 3x3 matrix extracted from the given matrix
  84458. */
  84459. static GetAsMatrix3x3(matrix: DeepImmutable<Matrix>): Float32Array | Array<number>;
  84460. /**
  84461. * Compute the transpose of a given matrix
  84462. * @param matrix defines the matrix to transpose
  84463. * @returns the new matrix
  84464. */
  84465. static Transpose(matrix: DeepImmutable<Matrix>): Matrix;
  84466. /**
  84467. * Compute the transpose of a matrix and store it in a target matrix
  84468. * @param matrix defines the matrix to transpose
  84469. * @param result defines the target matrix
  84470. */
  84471. static TransposeToRef(matrix: DeepImmutable<Matrix>, result: Matrix): void;
  84472. /**
  84473. * Computes a reflection matrix from a plane
  84474. * @param plane defines the reflection plane
  84475. * @returns a new matrix
  84476. */
  84477. static Reflection(plane: DeepImmutable<IPlaneLike>): Matrix;
  84478. /**
  84479. * Computes a reflection matrix from a plane
  84480. * @param plane defines the reflection plane
  84481. * @param result defines the target matrix
  84482. */
  84483. static ReflectionToRef(plane: DeepImmutable<IPlaneLike>, result: Matrix): void;
  84484. /**
  84485. * Sets the given matrix as a rotation matrix composed from the 3 left handed axes
  84486. * @param xaxis defines the value of the 1st axis
  84487. * @param yaxis defines the value of the 2nd axis
  84488. * @param zaxis defines the value of the 3rd axis
  84489. * @param result defines the target matrix
  84490. */
  84491. static FromXYZAxesToRef(xaxis: DeepImmutable<Vector3>, yaxis: DeepImmutable<Vector3>, zaxis: DeepImmutable<Vector3>, result: Matrix): void;
  84492. /**
  84493. * Creates a rotation matrix from a quaternion and stores it in a target matrix
  84494. * @param quat defines the quaternion to use
  84495. * @param result defines the target matrix
  84496. */
  84497. static FromQuaternionToRef(quat: DeepImmutable<Quaternion>, result: Matrix): void;
  84498. }
  84499. /**
  84500. * @hidden
  84501. */
  84502. export class TmpVectors {
  84503. static Vector2: Vector2[];
  84504. static Vector3: Vector3[];
  84505. static Vector4: Vector4[];
  84506. static Quaternion: Quaternion[];
  84507. static Matrix: Matrix[];
  84508. }
  84509. }
  84510. declare module BABYLON {
  84511. /**
  84512. * Defines potential orientation for back face culling
  84513. */
  84514. export enum Orientation {
  84515. /**
  84516. * Clockwise
  84517. */
  84518. CW = 0,
  84519. /** Counter clockwise */
  84520. CCW = 1
  84521. }
  84522. /** Class used to represent a Bezier curve */
  84523. export class BezierCurve {
  84524. /**
  84525. * Returns the cubic Bezier interpolated value (float) at "t" (float) from the given x1, y1, x2, y2 floats
  84526. * @param t defines the time
  84527. * @param x1 defines the left coordinate on X axis
  84528. * @param y1 defines the left coordinate on Y axis
  84529. * @param x2 defines the right coordinate on X axis
  84530. * @param y2 defines the right coordinate on Y axis
  84531. * @returns the interpolated value
  84532. */
  84533. static Interpolate(t: number, x1: number, y1: number, x2: number, y2: number): number;
  84534. }
  84535. /**
  84536. * Defines angle representation
  84537. */
  84538. export class Angle {
  84539. private _radians;
  84540. /**
  84541. * Creates an Angle object of "radians" radians (float).
  84542. * @param radians the angle in radians
  84543. */
  84544. constructor(radians: number);
  84545. /**
  84546. * Get value in degrees
  84547. * @returns the Angle value in degrees (float)
  84548. */
  84549. degrees(): number;
  84550. /**
  84551. * Get value in radians
  84552. * @returns the Angle value in radians (float)
  84553. */
  84554. radians(): number;
  84555. /**
  84556. * Gets a new Angle object valued with the gradient angle, in radians, of the line joining two points
  84557. * @param a defines first point as the origin
  84558. * @param b defines point
  84559. * @returns a new Angle
  84560. */
  84561. static BetweenTwoPoints(a: DeepImmutable<Vector2>, b: DeepImmutable<Vector2>): Angle;
  84562. /**
  84563. * Gets a new Angle object from the given float in radians
  84564. * @param radians defines the angle value in radians
  84565. * @returns a new Angle
  84566. */
  84567. static FromRadians(radians: number): Angle;
  84568. /**
  84569. * Gets a new Angle object from the given float in degrees
  84570. * @param degrees defines the angle value in degrees
  84571. * @returns a new Angle
  84572. */
  84573. static FromDegrees(degrees: number): Angle;
  84574. }
  84575. /**
  84576. * This represents an arc in a 2d space.
  84577. */
  84578. export class Arc2 {
  84579. /** Defines the start point of the arc */
  84580. startPoint: Vector2;
  84581. /** Defines the mid point of the arc */
  84582. midPoint: Vector2;
  84583. /** Defines the end point of the arc */
  84584. endPoint: Vector2;
  84585. /**
  84586. * Defines the center point of the arc.
  84587. */
  84588. centerPoint: Vector2;
  84589. /**
  84590. * Defines the radius of the arc.
  84591. */
  84592. radius: number;
  84593. /**
  84594. * Defines the angle of the arc (from mid point to end point).
  84595. */
  84596. angle: Angle;
  84597. /**
  84598. * Defines the start angle of the arc (from start point to middle point).
  84599. */
  84600. startAngle: Angle;
  84601. /**
  84602. * Defines the orientation of the arc (clock wise/counter clock wise).
  84603. */
  84604. orientation: Orientation;
  84605. /**
  84606. * Creates an Arc object from the three given points : start, middle and end.
  84607. * @param startPoint Defines the start point of the arc
  84608. * @param midPoint Defines the midlle point of the arc
  84609. * @param endPoint Defines the end point of the arc
  84610. */
  84611. constructor(
  84612. /** Defines the start point of the arc */
  84613. startPoint: Vector2,
  84614. /** Defines the mid point of the arc */
  84615. midPoint: Vector2,
  84616. /** Defines the end point of the arc */
  84617. endPoint: Vector2);
  84618. }
  84619. /**
  84620. * Represents a 2D path made up of multiple 2D points
  84621. */
  84622. export class Path2 {
  84623. private _points;
  84624. private _length;
  84625. /**
  84626. * If the path start and end point are the same
  84627. */
  84628. closed: boolean;
  84629. /**
  84630. * Creates a Path2 object from the starting 2D coordinates x and y.
  84631. * @param x the starting points x value
  84632. * @param y the starting points y value
  84633. */
  84634. constructor(x: number, y: number);
  84635. /**
  84636. * Adds a new segment until the given coordinates (x, y) to the current Path2.
  84637. * @param x the added points x value
  84638. * @param y the added points y value
  84639. * @returns the updated Path2.
  84640. */
  84641. addLineTo(x: number, y: number): Path2;
  84642. /**
  84643. * 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.
  84644. * @param midX middle point x value
  84645. * @param midY middle point y value
  84646. * @param endX end point x value
  84647. * @param endY end point y value
  84648. * @param numberOfSegments (default: 36)
  84649. * @returns the updated Path2.
  84650. */
  84651. addArcTo(midX: number, midY: number, endX: number, endY: number, numberOfSegments?: number): Path2;
  84652. /**
  84653. * Closes the Path2.
  84654. * @returns the Path2.
  84655. */
  84656. close(): Path2;
  84657. /**
  84658. * Gets the sum of the distance between each sequential point in the path
  84659. * @returns the Path2 total length (float).
  84660. */
  84661. length(): number;
  84662. /**
  84663. * Gets the points which construct the path
  84664. * @returns the Path2 internal array of points.
  84665. */
  84666. getPoints(): Vector2[];
  84667. /**
  84668. * Retreives the point at the distance aways from the starting point
  84669. * @param normalizedLengthPosition the length along the path to retreive the point from
  84670. * @returns a new Vector2 located at a percentage of the Path2 total length on this path.
  84671. */
  84672. getPointAtLengthPosition(normalizedLengthPosition: number): Vector2;
  84673. /**
  84674. * Creates a new path starting from an x and y position
  84675. * @param x starting x value
  84676. * @param y starting y value
  84677. * @returns a new Path2 starting at the coordinates (x, y).
  84678. */
  84679. static StartingAt(x: number, y: number): Path2;
  84680. }
  84681. /**
  84682. * Represents a 3D path made up of multiple 3D points
  84683. */
  84684. export class Path3D {
  84685. /**
  84686. * an array of Vector3, the curve axis of the Path3D
  84687. */
  84688. path: Vector3[];
  84689. private _curve;
  84690. private _distances;
  84691. private _tangents;
  84692. private _normals;
  84693. private _binormals;
  84694. private _raw;
  84695. private _alignTangentsWithPath;
  84696. private readonly _pointAtData;
  84697. /**
  84698. * new Path3D(path, normal, raw)
  84699. * Creates a Path3D. A Path3D is a logical math object, so not a mesh.
  84700. * please read the description in the tutorial : https://doc.babylonjs.com/how_to/how_to_use_path3d
  84701. * @param path an array of Vector3, the curve axis of the Path3D
  84702. * @param firstNormal (options) Vector3, the first wanted normal to the curve. Ex (0, 1, 0) for a vertical normal.
  84703. * @param raw (optional, default false) : boolean, if true the returned Path3D isn't normalized. Useful to depict path acceleration or speed.
  84704. * @param alignTangentsWithPath (optional, default false) : boolean, if true the tangents will be aligned with the path.
  84705. */
  84706. constructor(
  84707. /**
  84708. * an array of Vector3, the curve axis of the Path3D
  84709. */
  84710. path: Vector3[], firstNormal?: Nullable<Vector3>, raw?: boolean, alignTangentsWithPath?: boolean);
  84711. /**
  84712. * Returns the Path3D array of successive Vector3 designing its curve.
  84713. * @returns the Path3D array of successive Vector3 designing its curve.
  84714. */
  84715. getCurve(): Vector3[];
  84716. /**
  84717. * Returns the Path3D array of successive Vector3 designing its curve.
  84718. * @returns the Path3D array of successive Vector3 designing its curve.
  84719. */
  84720. getPoints(): Vector3[];
  84721. /**
  84722. * @returns the computed length (float) of the path.
  84723. */
  84724. length(): number;
  84725. /**
  84726. * Returns an array populated with tangent vectors on each Path3D curve point.
  84727. * @returns an array populated with tangent vectors on each Path3D curve point.
  84728. */
  84729. getTangents(): Vector3[];
  84730. /**
  84731. * Returns an array populated with normal vectors on each Path3D curve point.
  84732. * @returns an array populated with normal vectors on each Path3D curve point.
  84733. */
  84734. getNormals(): Vector3[];
  84735. /**
  84736. * Returns an array populated with binormal vectors on each Path3D curve point.
  84737. * @returns an array populated with binormal vectors on each Path3D curve point.
  84738. */
  84739. getBinormals(): Vector3[];
  84740. /**
  84741. * Returns an array populated with distances (float) of the i-th point from the first curve point.
  84742. * @returns an array populated with distances (float) of the i-th point from the first curve point.
  84743. */
  84744. getDistances(): number[];
  84745. /**
  84746. * Returns an interpolated point along this path
  84747. * @param position the position of the point along this path, from 0.0 to 1.0
  84748. * @returns a new Vector3 as the point
  84749. */
  84750. getPointAt(position: number): Vector3;
  84751. /**
  84752. * Returns the tangent vector of an interpolated Path3D curve point at the specified position along this path.
  84753. * @param position the position of the point along this path, from 0.0 to 1.0
  84754. * @param interpolated (optional, default false) : boolean, if true returns an interpolated tangent instead of the tangent of the previous path point.
  84755. * @returns a tangent vector corresponding to the interpolated Path3D curve point, if not interpolated, the tangent is taken from the precomputed tangents array.
  84756. */
  84757. getTangentAt(position: number, interpolated?: boolean): Vector3;
  84758. /**
  84759. * Returns the tangent vector of an interpolated Path3D curve point at the specified position along this path.
  84760. * @param position the position of the point along this path, from 0.0 to 1.0
  84761. * @param interpolated (optional, default false) : boolean, if true returns an interpolated normal instead of the normal of the previous path point.
  84762. * @returns a normal vector corresponding to the interpolated Path3D curve point, if not interpolated, the normal is taken from the precomputed normals array.
  84763. */
  84764. getNormalAt(position: number, interpolated?: boolean): Vector3;
  84765. /**
  84766. * Returns the binormal vector of an interpolated Path3D curve point at the specified position along this path.
  84767. * @param position the position of the point along this path, from 0.0 to 1.0
  84768. * @param interpolated (optional, default false) : boolean, if true returns an interpolated binormal instead of the binormal of the previous path point.
  84769. * @returns a binormal vector corresponding to the interpolated Path3D curve point, if not interpolated, the binormal is taken from the precomputed binormals array.
  84770. */
  84771. getBinormalAt(position: number, interpolated?: boolean): Vector3;
  84772. /**
  84773. * Returns the distance (float) of an interpolated Path3D curve point at the specified position along this path.
  84774. * @param position the position of the point along this path, from 0.0 to 1.0
  84775. * @returns the distance of the interpolated Path3D curve point at the specified position along this path.
  84776. */
  84777. getDistanceAt(position: number): number;
  84778. /**
  84779. * Returns the array index of the previous point of an interpolated point along this path
  84780. * @param position the position of the point to interpolate along this path, from 0.0 to 1.0
  84781. * @returns the array index
  84782. */
  84783. getPreviousPointIndexAt(position: number): number;
  84784. /**
  84785. * 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)
  84786. * @param position the position of the point to interpolate along this path, from 0.0 to 1.0
  84787. * @returns the sub position
  84788. */
  84789. getSubPositionAt(position: number): number;
  84790. /**
  84791. * Returns the position of the closest virtual point on this path to an arbitrary Vector3, from 0.0 to 1.0
  84792. * @param target the vector of which to get the closest position to
  84793. * @returns the position of the closest virtual point on this path to the target vector
  84794. */
  84795. getClosestPositionTo(target: Vector3): number;
  84796. /**
  84797. * Returns a sub path (slice) of this path
  84798. * @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
  84799. * @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
  84800. * @returns a sub path (slice) of this path
  84801. */
  84802. slice(start?: number, end?: number): Path3D;
  84803. /**
  84804. * Forces the Path3D tangent, normal, binormal and distance recomputation.
  84805. * @param path path which all values are copied into the curves points
  84806. * @param firstNormal which should be projected onto the curve
  84807. * @param alignTangentsWithPath (optional, default false) : boolean, if true the tangents will be aligned with the path
  84808. * @returns the same object updated.
  84809. */
  84810. update(path: Vector3[], firstNormal?: Nullable<Vector3>, alignTangentsWithPath?: boolean): Path3D;
  84811. private _compute;
  84812. private _getFirstNonNullVector;
  84813. private _getLastNonNullVector;
  84814. private _normalVector;
  84815. /**
  84816. * Updates the point at data for an interpolated point along this curve
  84817. * @param position the position of the point along this curve, from 0.0 to 1.0
  84818. * @interpolateTNB wether to compute the interpolated tangent, normal and binormal
  84819. * @returns the (updated) point at data
  84820. */
  84821. private _updatePointAtData;
  84822. /**
  84823. * Updates the point at data from the specified parameters
  84824. * @param position where along the path the interpolated point is, from 0.0 to 1.0
  84825. * @param point the interpolated point
  84826. * @param parentIndex the index of an existing curve point that is on, or else positionally the first behind, the interpolated point
  84827. */
  84828. private _setPointAtData;
  84829. /**
  84830. * Updates the point at interpolation matrix for the tangents, normals and binormals
  84831. */
  84832. private _updateInterpolationMatrix;
  84833. }
  84834. /**
  84835. * A Curve3 object is a logical object, so not a mesh, to handle curves in the 3D geometric space.
  84836. * A Curve3 is designed from a series of successive Vector3.
  84837. * @see https://doc.babylonjs.com/how_to/how_to_use_curve3
  84838. */
  84839. export class Curve3 {
  84840. private _points;
  84841. private _length;
  84842. /**
  84843. * Returns a Curve3 object along a Quadratic Bezier curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#quadratic-bezier-curve
  84844. * @param v0 (Vector3) the origin point of the Quadratic Bezier
  84845. * @param v1 (Vector3) the control point
  84846. * @param v2 (Vector3) the end point of the Quadratic Bezier
  84847. * @param nbPoints (integer) the wanted number of points in the curve
  84848. * @returns the created Curve3
  84849. */
  84850. static CreateQuadraticBezier(v0: DeepImmutable<Vector3>, v1: DeepImmutable<Vector3>, v2: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  84851. /**
  84852. * Returns a Curve3 object along a Cubic Bezier curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#cubic-bezier-curve
  84853. * @param v0 (Vector3) the origin point of the Cubic Bezier
  84854. * @param v1 (Vector3) the first control point
  84855. * @param v2 (Vector3) the second control point
  84856. * @param v3 (Vector3) the end point of the Cubic Bezier
  84857. * @param nbPoints (integer) the wanted number of points in the curve
  84858. * @returns the created Curve3
  84859. */
  84860. static CreateCubicBezier(v0: DeepImmutable<Vector3>, v1: DeepImmutable<Vector3>, v2: DeepImmutable<Vector3>, v3: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  84861. /**
  84862. * Returns a Curve3 object along a Hermite Spline curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#hermite-spline
  84863. * @param p1 (Vector3) the origin point of the Hermite Spline
  84864. * @param t1 (Vector3) the tangent vector at the origin point
  84865. * @param p2 (Vector3) the end point of the Hermite Spline
  84866. * @param t2 (Vector3) the tangent vector at the end point
  84867. * @param nbPoints (integer) the wanted number of points in the curve
  84868. * @returns the created Curve3
  84869. */
  84870. static CreateHermiteSpline(p1: DeepImmutable<Vector3>, t1: DeepImmutable<Vector3>, p2: DeepImmutable<Vector3>, t2: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  84871. /**
  84872. * Returns a Curve3 object along a CatmullRom Spline curve :
  84873. * @param points (array of Vector3) the points the spline must pass through. At least, four points required
  84874. * @param nbPoints (integer) the wanted number of points between each curve control points
  84875. * @param closed (boolean) optional with default false, when true forms a closed loop from the points
  84876. * @returns the created Curve3
  84877. */
  84878. static CreateCatmullRomSpline(points: DeepImmutable<Vector3[]>, nbPoints: number, closed?: boolean): Curve3;
  84879. /**
  84880. * A Curve3 object is a logical object, so not a mesh, to handle curves in the 3D geometric space.
  84881. * A Curve3 is designed from a series of successive Vector3.
  84882. * Tuto : https://doc.babylonjs.com/how_to/how_to_use_curve3#curve3-object
  84883. * @param points points which make up the curve
  84884. */
  84885. constructor(points: Vector3[]);
  84886. /**
  84887. * @returns the Curve3 stored array of successive Vector3
  84888. */
  84889. getPoints(): Vector3[];
  84890. /**
  84891. * @returns the computed length (float) of the curve.
  84892. */
  84893. length(): number;
  84894. /**
  84895. * Returns a new instance of Curve3 object : var curve = curveA.continue(curveB);
  84896. * This new Curve3 is built by translating and sticking the curveB at the end of the curveA.
  84897. * curveA and curveB keep unchanged.
  84898. * @param curve the curve to continue from this curve
  84899. * @returns the newly constructed curve
  84900. */
  84901. continue(curve: DeepImmutable<Curve3>): Curve3;
  84902. private _computeLength;
  84903. }
  84904. }
  84905. declare module BABYLON {
  84906. /**
  84907. * This represents the main contract an easing function should follow.
  84908. * Easing functions are used throughout the animation system.
  84909. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  84910. */
  84911. export interface IEasingFunction {
  84912. /**
  84913. * Given an input gradient between 0 and 1, this returns the corrseponding value
  84914. * of the easing function.
  84915. * The link below provides some of the most common examples of easing functions.
  84916. * @see https://easings.net/
  84917. * @param gradient Defines the value between 0 and 1 we want the easing value for
  84918. * @returns the corresponding value on the curve defined by the easing function
  84919. */
  84920. ease(gradient: number): number;
  84921. }
  84922. /**
  84923. * Base class used for every default easing function.
  84924. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  84925. */
  84926. export class EasingFunction implements IEasingFunction {
  84927. /**
  84928. * Interpolation follows the mathematical formula associated with the easing function.
  84929. */
  84930. static readonly EASINGMODE_EASEIN: number;
  84931. /**
  84932. * Interpolation follows 100% interpolation minus the output of the formula associated with the easing function.
  84933. */
  84934. static readonly EASINGMODE_EASEOUT: number;
  84935. /**
  84936. * Interpolation uses EaseIn for the first half of the animation and EaseOut for the second half.
  84937. */
  84938. static readonly EASINGMODE_EASEINOUT: number;
  84939. private _easingMode;
  84940. /**
  84941. * Sets the easing mode of the current function.
  84942. * @param easingMode Defines the willing mode (EASINGMODE_EASEIN, EASINGMODE_EASEOUT or EASINGMODE_EASEINOUT)
  84943. */
  84944. setEasingMode(easingMode: number): void;
  84945. /**
  84946. * Gets the current easing mode.
  84947. * @returns the easing mode
  84948. */
  84949. getEasingMode(): number;
  84950. /**
  84951. * @hidden
  84952. */
  84953. easeInCore(gradient: number): number;
  84954. /**
  84955. * Given an input gradient between 0 and 1, this returns the corresponding value
  84956. * of the easing function.
  84957. * @param gradient Defines the value between 0 and 1 we want the easing value for
  84958. * @returns the corresponding value on the curve defined by the easing function
  84959. */
  84960. ease(gradient: number): number;
  84961. }
  84962. /**
  84963. * Easing function with a circle shape (see link below).
  84964. * @see https://easings.net/#easeInCirc
  84965. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  84966. */
  84967. export class CircleEase extends EasingFunction implements IEasingFunction {
  84968. /** @hidden */
  84969. easeInCore(gradient: number): number;
  84970. }
  84971. /**
  84972. * Easing function with a ease back shape (see link below).
  84973. * @see https://easings.net/#easeInBack
  84974. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  84975. */
  84976. export class BackEase extends EasingFunction implements IEasingFunction {
  84977. /** Defines the amplitude of the function */
  84978. amplitude: number;
  84979. /**
  84980. * Instantiates a back ease easing
  84981. * @see https://easings.net/#easeInBack
  84982. * @param amplitude Defines the amplitude of the function
  84983. */
  84984. constructor(
  84985. /** Defines the amplitude of the function */
  84986. amplitude?: number);
  84987. /** @hidden */
  84988. easeInCore(gradient: number): number;
  84989. }
  84990. /**
  84991. * Easing function with a bouncing shape (see link below).
  84992. * @see https://easings.net/#easeInBounce
  84993. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  84994. */
  84995. export class BounceEase extends EasingFunction implements IEasingFunction {
  84996. /** Defines the number of bounces */
  84997. bounces: number;
  84998. /** Defines the amplitude of the bounce */
  84999. bounciness: number;
  85000. /**
  85001. * Instantiates a bounce easing
  85002. * @see https://easings.net/#easeInBounce
  85003. * @param bounces Defines the number of bounces
  85004. * @param bounciness Defines the amplitude of the bounce
  85005. */
  85006. constructor(
  85007. /** Defines the number of bounces */
  85008. bounces?: number,
  85009. /** Defines the amplitude of the bounce */
  85010. bounciness?: number);
  85011. /** @hidden */
  85012. easeInCore(gradient: number): number;
  85013. }
  85014. /**
  85015. * Easing function with a power of 3 shape (see link below).
  85016. * @see https://easings.net/#easeInCubic
  85017. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  85018. */
  85019. export class CubicEase extends EasingFunction implements IEasingFunction {
  85020. /** @hidden */
  85021. easeInCore(gradient: number): number;
  85022. }
  85023. /**
  85024. * Easing function with an elastic shape (see link below).
  85025. * @see https://easings.net/#easeInElastic
  85026. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  85027. */
  85028. export class ElasticEase extends EasingFunction implements IEasingFunction {
  85029. /** Defines the number of oscillations*/
  85030. oscillations: number;
  85031. /** Defines the amplitude of the oscillations*/
  85032. springiness: number;
  85033. /**
  85034. * Instantiates an elastic easing function
  85035. * @see https://easings.net/#easeInElastic
  85036. * @param oscillations Defines the number of oscillations
  85037. * @param springiness Defines the amplitude of the oscillations
  85038. */
  85039. constructor(
  85040. /** Defines the number of oscillations*/
  85041. oscillations?: number,
  85042. /** Defines the amplitude of the oscillations*/
  85043. springiness?: number);
  85044. /** @hidden */
  85045. easeInCore(gradient: number): number;
  85046. }
  85047. /**
  85048. * Easing function with an exponential shape (see link below).
  85049. * @see https://easings.net/#easeInExpo
  85050. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  85051. */
  85052. export class ExponentialEase extends EasingFunction implements IEasingFunction {
  85053. /** Defines the exponent of the function */
  85054. exponent: number;
  85055. /**
  85056. * Instantiates an exponential easing function
  85057. * @see https://easings.net/#easeInExpo
  85058. * @param exponent Defines the exponent of the function
  85059. */
  85060. constructor(
  85061. /** Defines the exponent of the function */
  85062. exponent?: number);
  85063. /** @hidden */
  85064. easeInCore(gradient: number): number;
  85065. }
  85066. /**
  85067. * Easing function with a power shape (see link below).
  85068. * @see https://easings.net/#easeInQuad
  85069. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  85070. */
  85071. export class PowerEase extends EasingFunction implements IEasingFunction {
  85072. /** Defines the power of the function */
  85073. power: number;
  85074. /**
  85075. * Instantiates an power base easing function
  85076. * @see https://easings.net/#easeInQuad
  85077. * @param power Defines the power of the function
  85078. */
  85079. constructor(
  85080. /** Defines the power of the function */
  85081. power?: number);
  85082. /** @hidden */
  85083. easeInCore(gradient: number): number;
  85084. }
  85085. /**
  85086. * Easing function with a power of 2 shape (see link below).
  85087. * @see https://easings.net/#easeInQuad
  85088. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  85089. */
  85090. export class QuadraticEase extends EasingFunction implements IEasingFunction {
  85091. /** @hidden */
  85092. easeInCore(gradient: number): number;
  85093. }
  85094. /**
  85095. * Easing function with a power of 4 shape (see link below).
  85096. * @see https://easings.net/#easeInQuart
  85097. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  85098. */
  85099. export class QuarticEase extends EasingFunction implements IEasingFunction {
  85100. /** @hidden */
  85101. easeInCore(gradient: number): number;
  85102. }
  85103. /**
  85104. * Easing function with a power of 5 shape (see link below).
  85105. * @see https://easings.net/#easeInQuint
  85106. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  85107. */
  85108. export class QuinticEase extends EasingFunction implements IEasingFunction {
  85109. /** @hidden */
  85110. easeInCore(gradient: number): number;
  85111. }
  85112. /**
  85113. * Easing function with a sin shape (see link below).
  85114. * @see https://easings.net/#easeInSine
  85115. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  85116. */
  85117. export class SineEase extends EasingFunction implements IEasingFunction {
  85118. /** @hidden */
  85119. easeInCore(gradient: number): number;
  85120. }
  85121. /**
  85122. * Easing function with a bezier shape (see link below).
  85123. * @see http://cubic-bezier.com/#.17,.67,.83,.67
  85124. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  85125. */
  85126. export class BezierCurveEase extends EasingFunction implements IEasingFunction {
  85127. /** Defines the x component of the start tangent in the bezier curve */
  85128. x1: number;
  85129. /** Defines the y component of the start tangent in the bezier curve */
  85130. y1: number;
  85131. /** Defines the x component of the end tangent in the bezier curve */
  85132. x2: number;
  85133. /** Defines the y component of the end tangent in the bezier curve */
  85134. y2: number;
  85135. /**
  85136. * Instantiates a bezier function
  85137. * @see http://cubic-bezier.com/#.17,.67,.83,.67
  85138. * @param x1 Defines the x component of the start tangent in the bezier curve
  85139. * @param y1 Defines the y component of the start tangent in the bezier curve
  85140. * @param x2 Defines the x component of the end tangent in the bezier curve
  85141. * @param y2 Defines the y component of the end tangent in the bezier curve
  85142. */
  85143. constructor(
  85144. /** Defines the x component of the start tangent in the bezier curve */
  85145. x1?: number,
  85146. /** Defines the y component of the start tangent in the bezier curve */
  85147. y1?: number,
  85148. /** Defines the x component of the end tangent in the bezier curve */
  85149. x2?: number,
  85150. /** Defines the y component of the end tangent in the bezier curve */
  85151. y2?: number);
  85152. /** @hidden */
  85153. easeInCore(gradient: number): number;
  85154. }
  85155. }
  85156. declare module BABYLON {
  85157. /**
  85158. * Class used to hold a RBG color
  85159. */
  85160. export class Color3 {
  85161. /**
  85162. * Defines the red component (between 0 and 1, default is 0)
  85163. */
  85164. r: number;
  85165. /**
  85166. * Defines the green component (between 0 and 1, default is 0)
  85167. */
  85168. g: number;
  85169. /**
  85170. * Defines the blue component (between 0 and 1, default is 0)
  85171. */
  85172. b: number;
  85173. /**
  85174. * Creates a new Color3 object from red, green, blue values, all between 0 and 1
  85175. * @param r defines the red component (between 0 and 1, default is 0)
  85176. * @param g defines the green component (between 0 and 1, default is 0)
  85177. * @param b defines the blue component (between 0 and 1, default is 0)
  85178. */
  85179. constructor(
  85180. /**
  85181. * Defines the red component (between 0 and 1, default is 0)
  85182. */
  85183. r?: number,
  85184. /**
  85185. * Defines the green component (between 0 and 1, default is 0)
  85186. */
  85187. g?: number,
  85188. /**
  85189. * Defines the blue component (between 0 and 1, default is 0)
  85190. */
  85191. b?: number);
  85192. /**
  85193. * Creates a string with the Color3 current values
  85194. * @returns the string representation of the Color3 object
  85195. */
  85196. toString(): string;
  85197. /**
  85198. * Returns the string "Color3"
  85199. * @returns "Color3"
  85200. */
  85201. getClassName(): string;
  85202. /**
  85203. * Compute the Color3 hash code
  85204. * @returns an unique number that can be used to hash Color3 objects
  85205. */
  85206. getHashCode(): number;
  85207. /**
  85208. * Stores in the given array from the given starting index the red, green, blue values as successive elements
  85209. * @param array defines the array where to store the r,g,b components
  85210. * @param index defines an optional index in the target array to define where to start storing values
  85211. * @returns the current Color3 object
  85212. */
  85213. toArray(array: FloatArray, index?: number): Color3;
  85214. /**
  85215. * Update the current color with values stored in an array from the starting index of the given array
  85216. * @param array defines the source array
  85217. * @param offset defines an offset in the source array
  85218. * @returns the current Color3 object
  85219. */
  85220. fromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Color3;
  85221. /**
  85222. * Returns a new Color4 object from the current Color3 and the given alpha
  85223. * @param alpha defines the alpha component on the new Color4 object (default is 1)
  85224. * @returns a new Color4 object
  85225. */
  85226. toColor4(alpha?: number): Color4;
  85227. /**
  85228. * Returns a new array populated with 3 numeric elements : red, green and blue values
  85229. * @returns the new array
  85230. */
  85231. asArray(): number[];
  85232. /**
  85233. * Returns the luminance value
  85234. * @returns a float value
  85235. */
  85236. toLuminance(): number;
  85237. /**
  85238. * Multiply each Color3 rgb values by the given Color3 rgb values in a new Color3 object
  85239. * @param otherColor defines the second operand
  85240. * @returns the new Color3 object
  85241. */
  85242. multiply(otherColor: DeepImmutable<Color3>): Color3;
  85243. /**
  85244. * Multiply the rgb values of the Color3 and the given Color3 and stores the result in the object "result"
  85245. * @param otherColor defines the second operand
  85246. * @param result defines the Color3 object where to store the result
  85247. * @returns the current Color3
  85248. */
  85249. multiplyToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  85250. /**
  85251. * Determines equality between Color3 objects
  85252. * @param otherColor defines the second operand
  85253. * @returns true if the rgb values are equal to the given ones
  85254. */
  85255. equals(otherColor: DeepImmutable<Color3>): boolean;
  85256. /**
  85257. * Determines equality between the current Color3 object and a set of r,b,g values
  85258. * @param r defines the red component to check
  85259. * @param g defines the green component to check
  85260. * @param b defines the blue component to check
  85261. * @returns true if the rgb values are equal to the given ones
  85262. */
  85263. equalsFloats(r: number, g: number, b: number): boolean;
  85264. /**
  85265. * Multiplies in place each rgb value by scale
  85266. * @param scale defines the scaling factor
  85267. * @returns the updated Color3
  85268. */
  85269. scale(scale: number): Color3;
  85270. /**
  85271. * Multiplies the rgb values by scale and stores the result into "result"
  85272. * @param scale defines the scaling factor
  85273. * @param result defines the Color3 object where to store the result
  85274. * @returns the unmodified current Color3
  85275. */
  85276. scaleToRef(scale: number, result: Color3): Color3;
  85277. /**
  85278. * Scale the current Color3 values by a factor and add the result to a given Color3
  85279. * @param scale defines the scale factor
  85280. * @param result defines color to store the result into
  85281. * @returns the unmodified current Color3
  85282. */
  85283. scaleAndAddToRef(scale: number, result: Color3): Color3;
  85284. /**
  85285. * Clamps the rgb values by the min and max values and stores the result into "result"
  85286. * @param min defines minimum clamping value (default is 0)
  85287. * @param max defines maximum clamping value (default is 1)
  85288. * @param result defines color to store the result into
  85289. * @returns the original Color3
  85290. */
  85291. clampToRef(min: number | undefined, max: number | undefined, result: Color3): Color3;
  85292. /**
  85293. * Creates a new Color3 set with the added values of the current Color3 and of the given one
  85294. * @param otherColor defines the second operand
  85295. * @returns the new Color3
  85296. */
  85297. add(otherColor: DeepImmutable<Color3>): Color3;
  85298. /**
  85299. * Stores the result of the addition of the current Color3 and given one rgb values into "result"
  85300. * @param otherColor defines the second operand
  85301. * @param result defines Color3 object to store the result into
  85302. * @returns the unmodified current Color3
  85303. */
  85304. addToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  85305. /**
  85306. * Returns a new Color3 set with the subtracted values of the given one from the current Color3
  85307. * @param otherColor defines the second operand
  85308. * @returns the new Color3
  85309. */
  85310. subtract(otherColor: DeepImmutable<Color3>): Color3;
  85311. /**
  85312. * Stores the result of the subtraction of given one from the current Color3 rgb values into "result"
  85313. * @param otherColor defines the second operand
  85314. * @param result defines Color3 object to store the result into
  85315. * @returns the unmodified current Color3
  85316. */
  85317. subtractToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  85318. /**
  85319. * Copy the current object
  85320. * @returns a new Color3 copied the current one
  85321. */
  85322. clone(): Color3;
  85323. /**
  85324. * Copies the rgb values from the source in the current Color3
  85325. * @param source defines the source Color3 object
  85326. * @returns the updated Color3 object
  85327. */
  85328. copyFrom(source: DeepImmutable<Color3>): Color3;
  85329. /**
  85330. * Updates the Color3 rgb values from the given floats
  85331. * @param r defines the red component to read from
  85332. * @param g defines the green component to read from
  85333. * @param b defines the blue component to read from
  85334. * @returns the current Color3 object
  85335. */
  85336. copyFromFloats(r: number, g: number, b: number): Color3;
  85337. /**
  85338. * Updates the Color3 rgb values from the given floats
  85339. * @param r defines the red component to read from
  85340. * @param g defines the green component to read from
  85341. * @param b defines the blue component to read from
  85342. * @returns the current Color3 object
  85343. */
  85344. set(r: number, g: number, b: number): Color3;
  85345. /**
  85346. * Compute the Color3 hexadecimal code as a string
  85347. * @returns a string containing the hexadecimal representation of the Color3 object
  85348. */
  85349. toHexString(): string;
  85350. /**
  85351. * Computes a new Color3 converted from the current one to linear space
  85352. * @returns a new Color3 object
  85353. */
  85354. toLinearSpace(): Color3;
  85355. /**
  85356. * Converts current color in rgb space to HSV values
  85357. * @returns a new color3 representing the HSV values
  85358. */
  85359. toHSV(): Color3;
  85360. /**
  85361. * Converts current color in rgb space to HSV values
  85362. * @param result defines the Color3 where to store the HSV values
  85363. */
  85364. toHSVToRef(result: Color3): void;
  85365. /**
  85366. * Converts the Color3 values to linear space and stores the result in "convertedColor"
  85367. * @param convertedColor defines the Color3 object where to store the linear space version
  85368. * @returns the unmodified Color3
  85369. */
  85370. toLinearSpaceToRef(convertedColor: Color3): Color3;
  85371. /**
  85372. * Computes a new Color3 converted from the current one to gamma space
  85373. * @returns a new Color3 object
  85374. */
  85375. toGammaSpace(): Color3;
  85376. /**
  85377. * Converts the Color3 values to gamma space and stores the result in "convertedColor"
  85378. * @param convertedColor defines the Color3 object where to store the gamma space version
  85379. * @returns the unmodified Color3
  85380. */
  85381. toGammaSpaceToRef(convertedColor: Color3): Color3;
  85382. private static _BlackReadOnly;
  85383. /**
  85384. * Convert Hue, saturation and value to a Color3 (RGB)
  85385. * @param hue defines the hue
  85386. * @param saturation defines the saturation
  85387. * @param value defines the value
  85388. * @param result defines the Color3 where to store the RGB values
  85389. */
  85390. static HSVtoRGBToRef(hue: number, saturation: number, value: number, result: Color3): void;
  85391. /**
  85392. * Creates a new Color3 from the string containing valid hexadecimal values
  85393. * @param hex defines a string containing valid hexadecimal values
  85394. * @returns a new Color3 object
  85395. */
  85396. static FromHexString(hex: string): Color3;
  85397. /**
  85398. * Creates a new Color3 from the starting index of the given array
  85399. * @param array defines the source array
  85400. * @param offset defines an offset in the source array
  85401. * @returns a new Color3 object
  85402. */
  85403. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Color3;
  85404. /**
  85405. * Creates a new Color3 from the starting index element of the given array
  85406. * @param array defines the source array to read from
  85407. * @param offset defines the offset in the source array
  85408. * @param result defines the target Color3 object
  85409. */
  85410. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number | undefined, result: Color3): void;
  85411. /**
  85412. * Creates a new Color3 from integer values (< 256)
  85413. * @param r defines the red component to read from (value between 0 and 255)
  85414. * @param g defines the green component to read from (value between 0 and 255)
  85415. * @param b defines the blue component to read from (value between 0 and 255)
  85416. * @returns a new Color3 object
  85417. */
  85418. static FromInts(r: number, g: number, b: number): Color3;
  85419. /**
  85420. * Creates a new Color3 with values linearly interpolated of "amount" between the start Color3 and the end Color3
  85421. * @param start defines the start Color3 value
  85422. * @param end defines the end Color3 value
  85423. * @param amount defines the gradient value between start and end
  85424. * @returns a new Color3 object
  85425. */
  85426. static Lerp(start: DeepImmutable<Color3>, end: DeepImmutable<Color3>, amount: number): Color3;
  85427. /**
  85428. * Creates a new Color3 with values linearly interpolated of "amount" between the start Color3 and the end Color3
  85429. * @param left defines the start value
  85430. * @param right defines the end value
  85431. * @param amount defines the gradient factor
  85432. * @param result defines the Color3 object where to store the result
  85433. */
  85434. static LerpToRef(left: DeepImmutable<Color3>, right: DeepImmutable<Color3>, amount: number, result: Color3): void;
  85435. /**
  85436. * Returns a Color3 value containing a red color
  85437. * @returns a new Color3 object
  85438. */
  85439. static Red(): Color3;
  85440. /**
  85441. * Returns a Color3 value containing a green color
  85442. * @returns a new Color3 object
  85443. */
  85444. static Green(): Color3;
  85445. /**
  85446. * Returns a Color3 value containing a blue color
  85447. * @returns a new Color3 object
  85448. */
  85449. static Blue(): Color3;
  85450. /**
  85451. * Returns a Color3 value containing a black color
  85452. * @returns a new Color3 object
  85453. */
  85454. static Black(): Color3;
  85455. /**
  85456. * Gets a Color3 value containing a black color that must not be updated
  85457. */
  85458. static get BlackReadOnly(): DeepImmutable<Color3>;
  85459. /**
  85460. * Returns a Color3 value containing a white color
  85461. * @returns a new Color3 object
  85462. */
  85463. static White(): Color3;
  85464. /**
  85465. * Returns a Color3 value containing a purple color
  85466. * @returns a new Color3 object
  85467. */
  85468. static Purple(): Color3;
  85469. /**
  85470. * Returns a Color3 value containing a magenta color
  85471. * @returns a new Color3 object
  85472. */
  85473. static Magenta(): Color3;
  85474. /**
  85475. * Returns a Color3 value containing a yellow color
  85476. * @returns a new Color3 object
  85477. */
  85478. static Yellow(): Color3;
  85479. /**
  85480. * Returns a Color3 value containing a gray color
  85481. * @returns a new Color3 object
  85482. */
  85483. static Gray(): Color3;
  85484. /**
  85485. * Returns a Color3 value containing a teal color
  85486. * @returns a new Color3 object
  85487. */
  85488. static Teal(): Color3;
  85489. /**
  85490. * Returns a Color3 value containing a random color
  85491. * @returns a new Color3 object
  85492. */
  85493. static Random(): Color3;
  85494. }
  85495. /**
  85496. * Class used to hold a RBGA color
  85497. */
  85498. export class Color4 {
  85499. /**
  85500. * Defines the red component (between 0 and 1, default is 0)
  85501. */
  85502. r: number;
  85503. /**
  85504. * Defines the green component (between 0 and 1, default is 0)
  85505. */
  85506. g: number;
  85507. /**
  85508. * Defines the blue component (between 0 and 1, default is 0)
  85509. */
  85510. b: number;
  85511. /**
  85512. * Defines the alpha component (between 0 and 1, default is 1)
  85513. */
  85514. a: number;
  85515. /**
  85516. * Creates a new Color4 object from red, green, blue values, all between 0 and 1
  85517. * @param r defines the red component (between 0 and 1, default is 0)
  85518. * @param g defines the green component (between 0 and 1, default is 0)
  85519. * @param b defines the blue component (between 0 and 1, default is 0)
  85520. * @param a defines the alpha component (between 0 and 1, default is 1)
  85521. */
  85522. constructor(
  85523. /**
  85524. * Defines the red component (between 0 and 1, default is 0)
  85525. */
  85526. r?: number,
  85527. /**
  85528. * Defines the green component (between 0 and 1, default is 0)
  85529. */
  85530. g?: number,
  85531. /**
  85532. * Defines the blue component (between 0 and 1, default is 0)
  85533. */
  85534. b?: number,
  85535. /**
  85536. * Defines the alpha component (between 0 and 1, default is 1)
  85537. */
  85538. a?: number);
  85539. /**
  85540. * Adds in place the given Color4 values to the current Color4 object
  85541. * @param right defines the second operand
  85542. * @returns the current updated Color4 object
  85543. */
  85544. addInPlace(right: DeepImmutable<Color4>): Color4;
  85545. /**
  85546. * Creates a new array populated with 4 numeric elements : red, green, blue, alpha values
  85547. * @returns the new array
  85548. */
  85549. asArray(): number[];
  85550. /**
  85551. * Stores from the starting index in the given array the Color4 successive values
  85552. * @param array defines the array where to store the r,g,b components
  85553. * @param index defines an optional index in the target array to define where to start storing values
  85554. * @returns the current Color4 object
  85555. */
  85556. toArray(array: number[], index?: number): Color4;
  85557. /**
  85558. * Update the current color with values stored in an array from the starting index of the given array
  85559. * @param array defines the source array
  85560. * @param offset defines an offset in the source array
  85561. * @returns the current Color4 object
  85562. */
  85563. fromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Color4;
  85564. /**
  85565. * Determines equality between Color4 objects
  85566. * @param otherColor defines the second operand
  85567. * @returns true if the rgba values are equal to the given ones
  85568. */
  85569. equals(otherColor: DeepImmutable<Color4>): boolean;
  85570. /**
  85571. * Creates a new Color4 set with the added values of the current Color4 and of the given one
  85572. * @param right defines the second operand
  85573. * @returns a new Color4 object
  85574. */
  85575. add(right: DeepImmutable<Color4>): Color4;
  85576. /**
  85577. * Creates a new Color4 set with the subtracted values of the given one from the current Color4
  85578. * @param right defines the second operand
  85579. * @returns a new Color4 object
  85580. */
  85581. subtract(right: DeepImmutable<Color4>): Color4;
  85582. /**
  85583. * Subtracts the given ones from the current Color4 values and stores the results in "result"
  85584. * @param right defines the second operand
  85585. * @param result defines the Color4 object where to store the result
  85586. * @returns the current Color4 object
  85587. */
  85588. subtractToRef(right: DeepImmutable<Color4>, result: Color4): Color4;
  85589. /**
  85590. * Creates a new Color4 with the current Color4 values multiplied by scale
  85591. * @param scale defines the scaling factor to apply
  85592. * @returns a new Color4 object
  85593. */
  85594. scale(scale: number): Color4;
  85595. /**
  85596. * Multiplies the current Color4 values by scale and stores the result in "result"
  85597. * @param scale defines the scaling factor to apply
  85598. * @param result defines the Color4 object where to store the result
  85599. * @returns the current unmodified Color4
  85600. */
  85601. scaleToRef(scale: number, result: Color4): Color4;
  85602. /**
  85603. * Scale the current Color4 values by a factor and add the result to a given Color4
  85604. * @param scale defines the scale factor
  85605. * @param result defines the Color4 object where to store the result
  85606. * @returns the unmodified current Color4
  85607. */
  85608. scaleAndAddToRef(scale: number, result: Color4): Color4;
  85609. /**
  85610. * Clamps the rgb values by the min and max values and stores the result into "result"
  85611. * @param min defines minimum clamping value (default is 0)
  85612. * @param max defines maximum clamping value (default is 1)
  85613. * @param result defines color to store the result into.
  85614. * @returns the cuurent Color4
  85615. */
  85616. clampToRef(min: number | undefined, max: number | undefined, result: Color4): Color4;
  85617. /**
  85618. * Multipy an Color4 value by another and return a new Color4 object
  85619. * @param color defines the Color4 value to multiply by
  85620. * @returns a new Color4 object
  85621. */
  85622. multiply(color: Color4): Color4;
  85623. /**
  85624. * Multipy a Color4 value by another and push the result in a reference value
  85625. * @param color defines the Color4 value to multiply by
  85626. * @param result defines the Color4 to fill the result in
  85627. * @returns the result Color4
  85628. */
  85629. multiplyToRef(color: Color4, result: Color4): Color4;
  85630. /**
  85631. * Creates a string with the Color4 current values
  85632. * @returns the string representation of the Color4 object
  85633. */
  85634. toString(): string;
  85635. /**
  85636. * Returns the string "Color4"
  85637. * @returns "Color4"
  85638. */
  85639. getClassName(): string;
  85640. /**
  85641. * Compute the Color4 hash code
  85642. * @returns an unique number that can be used to hash Color4 objects
  85643. */
  85644. getHashCode(): number;
  85645. /**
  85646. * Creates a new Color4 copied from the current one
  85647. * @returns a new Color4 object
  85648. */
  85649. clone(): Color4;
  85650. /**
  85651. * Copies the given Color4 values into the current one
  85652. * @param source defines the source Color4 object
  85653. * @returns the current updated Color4 object
  85654. */
  85655. copyFrom(source: Color4): Color4;
  85656. /**
  85657. * Copies the given float values into the current one
  85658. * @param r defines the red component to read from
  85659. * @param g defines the green component to read from
  85660. * @param b defines the blue component to read from
  85661. * @param a defines the alpha component to read from
  85662. * @returns the current updated Color4 object
  85663. */
  85664. copyFromFloats(r: number, g: number, b: number, a: number): Color4;
  85665. /**
  85666. * Copies the given float values into the current one
  85667. * @param r defines the red component to read from
  85668. * @param g defines the green component to read from
  85669. * @param b defines the blue component to read from
  85670. * @param a defines the alpha component to read from
  85671. * @returns the current updated Color4 object
  85672. */
  85673. set(r: number, g: number, b: number, a: number): Color4;
  85674. /**
  85675. * Compute the Color4 hexadecimal code as a string
  85676. * @param returnAsColor3 defines if the string should only contains RGB values (off by default)
  85677. * @returns a string containing the hexadecimal representation of the Color4 object
  85678. */
  85679. toHexString(returnAsColor3?: boolean): string;
  85680. /**
  85681. * Computes a new Color4 converted from the current one to linear space
  85682. * @returns a new Color4 object
  85683. */
  85684. toLinearSpace(): Color4;
  85685. /**
  85686. * Converts the Color4 values to linear space and stores the result in "convertedColor"
  85687. * @param convertedColor defines the Color4 object where to store the linear space version
  85688. * @returns the unmodified Color4
  85689. */
  85690. toLinearSpaceToRef(convertedColor: Color4): Color4;
  85691. /**
  85692. * Computes a new Color4 converted from the current one to gamma space
  85693. * @returns a new Color4 object
  85694. */
  85695. toGammaSpace(): Color4;
  85696. /**
  85697. * Converts the Color4 values to gamma space and stores the result in "convertedColor"
  85698. * @param convertedColor defines the Color4 object where to store the gamma space version
  85699. * @returns the unmodified Color4
  85700. */
  85701. toGammaSpaceToRef(convertedColor: Color4): Color4;
  85702. /**
  85703. * Creates a new Color4 from the string containing valid hexadecimal values
  85704. * @param hex defines a string containing valid hexadecimal values
  85705. * @returns a new Color4 object
  85706. */
  85707. static FromHexString(hex: string): Color4;
  85708. /**
  85709. * Creates a new Color4 object set with the linearly interpolated values of "amount" between the left Color4 object and the right Color4 object
  85710. * @param left defines the start value
  85711. * @param right defines the end value
  85712. * @param amount defines the gradient factor
  85713. * @returns a new Color4 object
  85714. */
  85715. static Lerp(left: DeepImmutable<Color4>, right: DeepImmutable<Color4>, amount: number): Color4;
  85716. /**
  85717. * Set the given "result" with the linearly interpolated values of "amount" between the left Color4 object and the right Color4 object
  85718. * @param left defines the start value
  85719. * @param right defines the end value
  85720. * @param amount defines the gradient factor
  85721. * @param result defines the Color4 object where to store data
  85722. */
  85723. static LerpToRef(left: DeepImmutable<Color4>, right: DeepImmutable<Color4>, amount: number, result: Color4): void;
  85724. /**
  85725. * Creates a new Color4 from a Color3 and an alpha value
  85726. * @param color3 defines the source Color3 to read from
  85727. * @param alpha defines the alpha component (1.0 by default)
  85728. * @returns a new Color4 object
  85729. */
  85730. static FromColor3(color3: DeepImmutable<Color3>, alpha?: number): Color4;
  85731. /**
  85732. * Creates a new Color4 from the starting index element of the given array
  85733. * @param array defines the source array to read from
  85734. * @param offset defines the offset in the source array
  85735. * @returns a new Color4 object
  85736. */
  85737. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Color4;
  85738. /**
  85739. * Creates a new Color4 from the starting index element of the given array
  85740. * @param array defines the source array to read from
  85741. * @param offset defines the offset in the source array
  85742. * @param result defines the target Color4 object
  85743. */
  85744. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number | undefined, result: Color4): void;
  85745. /**
  85746. * Creates a new Color3 from integer values (< 256)
  85747. * @param r defines the red component to read from (value between 0 and 255)
  85748. * @param g defines the green component to read from (value between 0 and 255)
  85749. * @param b defines the blue component to read from (value between 0 and 255)
  85750. * @param a defines the alpha component to read from (value between 0 and 255)
  85751. * @returns a new Color3 object
  85752. */
  85753. static FromInts(r: number, g: number, b: number, a: number): Color4;
  85754. /**
  85755. * Check the content of a given array and convert it to an array containing RGBA data
  85756. * If the original array was already containing count * 4 values then it is returned directly
  85757. * @param colors defines the array to check
  85758. * @param count defines the number of RGBA data to expect
  85759. * @returns an array containing count * 4 values (RGBA)
  85760. */
  85761. static CheckColors4(colors: number[], count: number): number[];
  85762. }
  85763. /**
  85764. * @hidden
  85765. */
  85766. export class TmpColors {
  85767. static Color3: Color3[];
  85768. static Color4: Color4[];
  85769. }
  85770. }
  85771. declare module BABYLON {
  85772. /**
  85773. * Defines an interface which represents an animation key frame
  85774. */
  85775. export interface IAnimationKey {
  85776. /**
  85777. * Frame of the key frame
  85778. */
  85779. frame: number;
  85780. /**
  85781. * Value at the specifies key frame
  85782. */
  85783. value: any;
  85784. /**
  85785. * The input tangent for the cubic hermite spline
  85786. */
  85787. inTangent?: any;
  85788. /**
  85789. * The output tangent for the cubic hermite spline
  85790. */
  85791. outTangent?: any;
  85792. /**
  85793. * The animation interpolation type
  85794. */
  85795. interpolation?: AnimationKeyInterpolation;
  85796. }
  85797. /**
  85798. * Enum for the animation key frame interpolation type
  85799. */
  85800. export enum AnimationKeyInterpolation {
  85801. /**
  85802. * Do not interpolate between keys and use the start key value only. Tangents are ignored
  85803. */
  85804. STEP = 1
  85805. }
  85806. }
  85807. declare module BABYLON {
  85808. /**
  85809. * Represents the range of an animation
  85810. */
  85811. export class AnimationRange {
  85812. /**The name of the animation range**/
  85813. name: string;
  85814. /**The starting frame of the animation */
  85815. from: number;
  85816. /**The ending frame of the animation*/
  85817. to: number;
  85818. /**
  85819. * Initializes the range of an animation
  85820. * @param name The name of the animation range
  85821. * @param from The starting frame of the animation
  85822. * @param to The ending frame of the animation
  85823. */
  85824. constructor(
  85825. /**The name of the animation range**/
  85826. name: string,
  85827. /**The starting frame of the animation */
  85828. from: number,
  85829. /**The ending frame of the animation*/
  85830. to: number);
  85831. /**
  85832. * Makes a copy of the animation range
  85833. * @returns A copy of the animation range
  85834. */
  85835. clone(): AnimationRange;
  85836. }
  85837. }
  85838. declare module BABYLON {
  85839. /**
  85840. * Composed of a frame, and an action function
  85841. */
  85842. export class AnimationEvent {
  85843. /** The frame for which the event is triggered **/
  85844. frame: number;
  85845. /** The event to perform when triggered **/
  85846. action: (currentFrame: number) => void;
  85847. /** Specifies if the event should be triggered only once**/
  85848. onlyOnce?: boolean | undefined;
  85849. /**
  85850. * Specifies if the animation event is done
  85851. */
  85852. isDone: boolean;
  85853. /**
  85854. * Initializes the animation event
  85855. * @param frame The frame for which the event is triggered
  85856. * @param action The event to perform when triggered
  85857. * @param onlyOnce Specifies if the event should be triggered only once
  85858. */
  85859. constructor(
  85860. /** The frame for which the event is triggered **/
  85861. frame: number,
  85862. /** The event to perform when triggered **/
  85863. action: (currentFrame: number) => void,
  85864. /** Specifies if the event should be triggered only once**/
  85865. onlyOnce?: boolean | undefined);
  85866. /** @hidden */
  85867. _clone(): AnimationEvent;
  85868. }
  85869. }
  85870. declare module BABYLON {
  85871. /**
  85872. * Interface used to define a behavior
  85873. */
  85874. export interface Behavior<T> {
  85875. /** gets or sets behavior's name */
  85876. name: string;
  85877. /**
  85878. * Function called when the behavior needs to be initialized (after attaching it to a target)
  85879. */
  85880. init(): void;
  85881. /**
  85882. * Called when the behavior is attached to a target
  85883. * @param target defines the target where the behavior is attached to
  85884. */
  85885. attach(target: T): void;
  85886. /**
  85887. * Called when the behavior is detached from its target
  85888. */
  85889. detach(): void;
  85890. }
  85891. /**
  85892. * Interface implemented by classes supporting behaviors
  85893. */
  85894. export interface IBehaviorAware<T> {
  85895. /**
  85896. * Attach a behavior
  85897. * @param behavior defines the behavior to attach
  85898. * @returns the current host
  85899. */
  85900. addBehavior(behavior: Behavior<T>): T;
  85901. /**
  85902. * Remove a behavior from the current object
  85903. * @param behavior defines the behavior to detach
  85904. * @returns the current host
  85905. */
  85906. removeBehavior(behavior: Behavior<T>): T;
  85907. /**
  85908. * Gets a behavior using its name to search
  85909. * @param name defines the name to search
  85910. * @returns the behavior or null if not found
  85911. */
  85912. getBehaviorByName(name: string): Nullable<Behavior<T>>;
  85913. }
  85914. }
  85915. declare module BABYLON {
  85916. /**
  85917. * Defines an array and its length.
  85918. * It can be helpfull to group result from both Arrays and smart arrays in one structure.
  85919. */
  85920. export interface ISmartArrayLike<T> {
  85921. /**
  85922. * The data of the array.
  85923. */
  85924. data: Array<T>;
  85925. /**
  85926. * The active length of the array.
  85927. */
  85928. length: number;
  85929. }
  85930. /**
  85931. * Defines an GC Friendly array where the backfield array do not shrink to prevent over allocations.
  85932. */
  85933. export class SmartArray<T> implements ISmartArrayLike<T> {
  85934. /**
  85935. * The full set of data from the array.
  85936. */
  85937. data: Array<T>;
  85938. /**
  85939. * The active length of the array.
  85940. */
  85941. length: number;
  85942. protected _id: number;
  85943. /**
  85944. * Instantiates a Smart Array.
  85945. * @param capacity defines the default capacity of the array.
  85946. */
  85947. constructor(capacity: number);
  85948. /**
  85949. * Pushes a value at the end of the active data.
  85950. * @param value defines the object to push in the array.
  85951. */
  85952. push(value: T): void;
  85953. /**
  85954. * Iterates over the active data and apply the lambda to them.
  85955. * @param func defines the action to apply on each value.
  85956. */
  85957. forEach(func: (content: T) => void): void;
  85958. /**
  85959. * Sorts the full sets of data.
  85960. * @param compareFn defines the comparison function to apply.
  85961. */
  85962. sort(compareFn: (a: T, b: T) => number): void;
  85963. /**
  85964. * Resets the active data to an empty array.
  85965. */
  85966. reset(): void;
  85967. /**
  85968. * Releases all the data from the array as well as the array.
  85969. */
  85970. dispose(): void;
  85971. /**
  85972. * Concats the active data with a given array.
  85973. * @param array defines the data to concatenate with.
  85974. */
  85975. concat(array: any): void;
  85976. /**
  85977. * Returns the position of a value in the active data.
  85978. * @param value defines the value to find the index for
  85979. * @returns the index if found in the active data otherwise -1
  85980. */
  85981. indexOf(value: T): number;
  85982. /**
  85983. * Returns whether an element is part of the active data.
  85984. * @param value defines the value to look for
  85985. * @returns true if found in the active data otherwise false
  85986. */
  85987. contains(value: T): boolean;
  85988. private static _GlobalId;
  85989. }
  85990. /**
  85991. * Defines an GC Friendly array where the backfield array do not shrink to prevent over allocations.
  85992. * The data in this array can only be present once
  85993. */
  85994. export class SmartArrayNoDuplicate<T> extends SmartArray<T> {
  85995. private _duplicateId;
  85996. /**
  85997. * Pushes a value at the end of the active data.
  85998. * THIS DOES NOT PREVENT DUPPLICATE DATA
  85999. * @param value defines the object to push in the array.
  86000. */
  86001. push(value: T): void;
  86002. /**
  86003. * Pushes a value at the end of the active data.
  86004. * If the data is already present, it won t be added again
  86005. * @param value defines the object to push in the array.
  86006. * @returns true if added false if it was already present
  86007. */
  86008. pushNoDuplicate(value: T): boolean;
  86009. /**
  86010. * Resets the active data to an empty array.
  86011. */
  86012. reset(): void;
  86013. /**
  86014. * Concats the active data with a given array.
  86015. * This ensures no dupplicate will be present in the result.
  86016. * @param array defines the data to concatenate with.
  86017. */
  86018. concatWithNoDuplicate(array: any): void;
  86019. }
  86020. }
  86021. declare module BABYLON {
  86022. /**
  86023. * @ignore
  86024. * This is a list of all the different input types that are available in the application.
  86025. * Fo instance: ArcRotateCameraGamepadInput...
  86026. */
  86027. export var CameraInputTypes: {};
  86028. /**
  86029. * This is the contract to implement in order to create a new input class.
  86030. * Inputs are dealing with listening to user actions and moving the camera accordingly.
  86031. */
  86032. export interface ICameraInput<TCamera extends Camera> {
  86033. /**
  86034. * Defines the camera the input is attached to.
  86035. */
  86036. camera: Nullable<TCamera>;
  86037. /**
  86038. * Gets the class name of the current intput.
  86039. * @returns the class name
  86040. */
  86041. getClassName(): string;
  86042. /**
  86043. * Get the friendly name associated with the input class.
  86044. * @returns the input friendly name
  86045. */
  86046. getSimpleName(): string;
  86047. /**
  86048. * Attach the input controls to a specific dom element to get the input from.
  86049. * @param element Defines the element the controls should be listened from
  86050. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  86051. */
  86052. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  86053. /**
  86054. * Detach the current controls from the specified dom element.
  86055. * @param element Defines the element to stop listening the inputs from
  86056. */
  86057. detachControl(element: Nullable<HTMLElement>): void;
  86058. /**
  86059. * Update the current camera state depending on the inputs that have been used this frame.
  86060. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  86061. */
  86062. checkInputs?: () => void;
  86063. }
  86064. /**
  86065. * Represents a map of input types to input instance or input index to input instance.
  86066. */
  86067. export interface CameraInputsMap<TCamera extends Camera> {
  86068. /**
  86069. * Accessor to the input by input type.
  86070. */
  86071. [name: string]: ICameraInput<TCamera>;
  86072. /**
  86073. * Accessor to the input by input index.
  86074. */
  86075. [idx: number]: ICameraInput<TCamera>;
  86076. }
  86077. /**
  86078. * This represents the input manager used within a camera.
  86079. * It helps dealing with all the different kind of input attached to a camera.
  86080. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  86081. */
  86082. export class CameraInputsManager<TCamera extends Camera> {
  86083. /**
  86084. * Defines the list of inputs attahed to the camera.
  86085. */
  86086. attached: CameraInputsMap<TCamera>;
  86087. /**
  86088. * Defines the dom element the camera is collecting inputs from.
  86089. * This is null if the controls have not been attached.
  86090. */
  86091. attachedElement: Nullable<HTMLElement>;
  86092. /**
  86093. * Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  86094. */
  86095. noPreventDefault: boolean;
  86096. /**
  86097. * Defined the camera the input manager belongs to.
  86098. */
  86099. camera: TCamera;
  86100. /**
  86101. * Update the current camera state depending on the inputs that have been used this frame.
  86102. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  86103. */
  86104. checkInputs: () => void;
  86105. /**
  86106. * Instantiate a new Camera Input Manager.
  86107. * @param camera Defines the camera the input manager blongs to
  86108. */
  86109. constructor(camera: TCamera);
  86110. /**
  86111. * Add an input method to a camera
  86112. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  86113. * @param input camera input method
  86114. */
  86115. add(input: ICameraInput<TCamera>): void;
  86116. /**
  86117. * Remove a specific input method from a camera
  86118. * example: camera.inputs.remove(camera.inputs.attached.mouse);
  86119. * @param inputToRemove camera input method
  86120. */
  86121. remove(inputToRemove: ICameraInput<TCamera>): void;
  86122. /**
  86123. * Remove a specific input type from a camera
  86124. * example: camera.inputs.remove("ArcRotateCameraGamepadInput");
  86125. * @param inputType the type of the input to remove
  86126. */
  86127. removeByType(inputType: string): void;
  86128. private _addCheckInputs;
  86129. /**
  86130. * Attach the input controls to the currently attached dom element to listen the events from.
  86131. * @param input Defines the input to attach
  86132. */
  86133. attachInput(input: ICameraInput<TCamera>): void;
  86134. /**
  86135. * Attach the current manager inputs controls to a specific dom element to listen the events from.
  86136. * @param element Defines the dom element to collect the events from
  86137. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  86138. */
  86139. attachElement(element: HTMLElement, noPreventDefault?: boolean): void;
  86140. /**
  86141. * Detach the current manager inputs controls from a specific dom element.
  86142. * @param element Defines the dom element to collect the events from
  86143. * @param disconnect Defines whether the input should be removed from the current list of attached inputs
  86144. */
  86145. detachElement(element: HTMLElement, disconnect?: boolean): void;
  86146. /**
  86147. * Rebuild the dynamic inputCheck function from the current list of
  86148. * defined inputs in the manager.
  86149. */
  86150. rebuildInputCheck(): void;
  86151. /**
  86152. * Remove all attached input methods from a camera
  86153. */
  86154. clear(): void;
  86155. /**
  86156. * Serialize the current input manager attached to a camera.
  86157. * This ensures than once parsed,
  86158. * the input associated to the camera will be identical to the current ones
  86159. * @param serializedCamera Defines the camera serialization JSON the input serialization should write to
  86160. */
  86161. serialize(serializedCamera: any): void;
  86162. /**
  86163. * Parses an input manager serialized JSON to restore the previous list of inputs
  86164. * and states associated to a camera.
  86165. * @param parsedCamera Defines the JSON to parse
  86166. */
  86167. parse(parsedCamera: any): void;
  86168. }
  86169. }
  86170. declare module BABYLON {
  86171. /**
  86172. * Class used to store data that will be store in GPU memory
  86173. */
  86174. export class Buffer {
  86175. private _engine;
  86176. private _buffer;
  86177. /** @hidden */
  86178. _data: Nullable<DataArray>;
  86179. private _updatable;
  86180. private _instanced;
  86181. private _divisor;
  86182. /**
  86183. * Gets the byte stride.
  86184. */
  86185. readonly byteStride: number;
  86186. /**
  86187. * Constructor
  86188. * @param engine the engine
  86189. * @param data the data to use for this buffer
  86190. * @param updatable whether the data is updatable
  86191. * @param stride the stride (optional)
  86192. * @param postponeInternalCreation whether to postpone creating the internal WebGL buffer (optional)
  86193. * @param instanced whether the buffer is instanced (optional)
  86194. * @param useBytes set to true if the stride in in bytes (optional)
  86195. * @param divisor sets an optional divisor for instances (1 by default)
  86196. */
  86197. constructor(engine: any, data: DataArray, updatable: boolean, stride?: number, postponeInternalCreation?: boolean, instanced?: boolean, useBytes?: boolean, divisor?: number);
  86198. /**
  86199. * Create a new VertexBuffer based on the current buffer
  86200. * @param kind defines the vertex buffer kind (position, normal, etc.)
  86201. * @param offset defines offset in the buffer (0 by default)
  86202. * @param size defines the size in floats of attributes (position is 3 for instance)
  86203. * @param stride defines the stride size in floats in the buffer (the offset to apply to reach next value when data is interleaved)
  86204. * @param instanced defines if the vertex buffer contains indexed data
  86205. * @param useBytes defines if the offset and stride are in bytes *
  86206. * @param divisor sets an optional divisor for instances (1 by default)
  86207. * @returns the new vertex buffer
  86208. */
  86209. createVertexBuffer(kind: string, offset: number, size: number, stride?: number, instanced?: boolean, useBytes?: boolean, divisor?: number): VertexBuffer;
  86210. /**
  86211. * Gets a boolean indicating if the Buffer is updatable?
  86212. * @returns true if the buffer is updatable
  86213. */
  86214. isUpdatable(): boolean;
  86215. /**
  86216. * Gets current buffer's data
  86217. * @returns a DataArray or null
  86218. */
  86219. getData(): Nullable<DataArray>;
  86220. /**
  86221. * Gets underlying native buffer
  86222. * @returns underlying native buffer
  86223. */
  86224. getBuffer(): Nullable<DataBuffer>;
  86225. /**
  86226. * Gets the stride in float32 units (i.e. byte stride / 4).
  86227. * May not be an integer if the byte stride is not divisible by 4.
  86228. * @returns the stride in float32 units
  86229. * @deprecated Please use byteStride instead.
  86230. */
  86231. getStrideSize(): number;
  86232. /**
  86233. * Store data into the buffer. If the buffer was already used it will be either recreated or updated depending on isUpdatable property
  86234. * @param data defines the data to store
  86235. */
  86236. create(data?: Nullable<DataArray>): void;
  86237. /** @hidden */
  86238. _rebuild(): void;
  86239. /**
  86240. * Update current buffer data
  86241. * @param data defines the data to store
  86242. */
  86243. update(data: DataArray): void;
  86244. /**
  86245. * Updates the data directly.
  86246. * @param data the new data
  86247. * @param offset the new offset
  86248. * @param vertexCount the vertex count (optional)
  86249. * @param useBytes set to true if the offset is in bytes
  86250. */
  86251. updateDirectly(data: DataArray, offset: number, vertexCount?: number, useBytes?: boolean): void;
  86252. /**
  86253. * Release all resources
  86254. */
  86255. dispose(): void;
  86256. }
  86257. /**
  86258. * Specialized buffer used to store vertex data
  86259. */
  86260. export class VertexBuffer {
  86261. /** @hidden */
  86262. _buffer: Buffer;
  86263. private _kind;
  86264. private _size;
  86265. private _ownsBuffer;
  86266. private _instanced;
  86267. private _instanceDivisor;
  86268. /**
  86269. * The byte type.
  86270. */
  86271. static readonly BYTE: number;
  86272. /**
  86273. * The unsigned byte type.
  86274. */
  86275. static readonly UNSIGNED_BYTE: number;
  86276. /**
  86277. * The short type.
  86278. */
  86279. static readonly SHORT: number;
  86280. /**
  86281. * The unsigned short type.
  86282. */
  86283. static readonly UNSIGNED_SHORT: number;
  86284. /**
  86285. * The integer type.
  86286. */
  86287. static readonly INT: number;
  86288. /**
  86289. * The unsigned integer type.
  86290. */
  86291. static readonly UNSIGNED_INT: number;
  86292. /**
  86293. * The float type.
  86294. */
  86295. static readonly FLOAT: number;
  86296. /**
  86297. * Gets or sets the instance divisor when in instanced mode
  86298. */
  86299. get instanceDivisor(): number;
  86300. set instanceDivisor(value: number);
  86301. /**
  86302. * Gets the byte stride.
  86303. */
  86304. readonly byteStride: number;
  86305. /**
  86306. * Gets the byte offset.
  86307. */
  86308. readonly byteOffset: number;
  86309. /**
  86310. * Gets whether integer data values should be normalized into a certain range when being casted to a float.
  86311. */
  86312. readonly normalized: boolean;
  86313. /**
  86314. * Gets the data type of each component in the array.
  86315. */
  86316. readonly type: number;
  86317. /**
  86318. * Constructor
  86319. * @param engine the engine
  86320. * @param data the data to use for this vertex buffer
  86321. * @param kind the vertex buffer kind
  86322. * @param updatable whether the data is updatable
  86323. * @param postponeInternalCreation whether to postpone creating the internal WebGL buffer (optional)
  86324. * @param stride the stride (optional)
  86325. * @param instanced whether the buffer is instanced (optional)
  86326. * @param offset the offset of the data (optional)
  86327. * @param size the number of components (optional)
  86328. * @param type the type of the component (optional)
  86329. * @param normalized whether the data contains normalized data (optional)
  86330. * @param useBytes set to true if stride and offset are in bytes (optional)
  86331. * @param divisor defines the instance divisor to use (1 by default)
  86332. */
  86333. 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);
  86334. /** @hidden */
  86335. _rebuild(): void;
  86336. /**
  86337. * Returns the kind of the VertexBuffer (string)
  86338. * @returns a string
  86339. */
  86340. getKind(): string;
  86341. /**
  86342. * Gets a boolean indicating if the VertexBuffer is updatable?
  86343. * @returns true if the buffer is updatable
  86344. */
  86345. isUpdatable(): boolean;
  86346. /**
  86347. * Gets current buffer's data
  86348. * @returns a DataArray or null
  86349. */
  86350. getData(): Nullable<DataArray>;
  86351. /**
  86352. * Gets underlying native buffer
  86353. * @returns underlying native buffer
  86354. */
  86355. getBuffer(): Nullable<DataBuffer>;
  86356. /**
  86357. * Gets the stride in float32 units (i.e. byte stride / 4).
  86358. * May not be an integer if the byte stride is not divisible by 4.
  86359. * @returns the stride in float32 units
  86360. * @deprecated Please use byteStride instead.
  86361. */
  86362. getStrideSize(): number;
  86363. /**
  86364. * Returns the offset as a multiple of the type byte length.
  86365. * @returns the offset in bytes
  86366. * @deprecated Please use byteOffset instead.
  86367. */
  86368. getOffset(): number;
  86369. /**
  86370. * Returns the number of components per vertex attribute (integer)
  86371. * @returns the size in float
  86372. */
  86373. getSize(): number;
  86374. /**
  86375. * Gets a boolean indicating is the internal buffer of the VertexBuffer is instanced
  86376. * @returns true if this buffer is instanced
  86377. */
  86378. getIsInstanced(): boolean;
  86379. /**
  86380. * Returns the instancing divisor, zero for non-instanced (integer).
  86381. * @returns a number
  86382. */
  86383. getInstanceDivisor(): number;
  86384. /**
  86385. * Store data into the buffer. If the buffer was already used it will be either recreated or updated depending on isUpdatable property
  86386. * @param data defines the data to store
  86387. */
  86388. create(data?: DataArray): void;
  86389. /**
  86390. * Updates the underlying buffer according to the passed numeric array or Float32Array.
  86391. * This function will create a new buffer if the current one is not updatable
  86392. * @param data defines the data to store
  86393. */
  86394. update(data: DataArray): void;
  86395. /**
  86396. * Updates directly the underlying WebGLBuffer according to the passed numeric array or Float32Array.
  86397. * Returns the directly updated WebGLBuffer.
  86398. * @param data the new data
  86399. * @param offset the new offset
  86400. * @param useBytes set to true if the offset is in bytes
  86401. */
  86402. updateDirectly(data: DataArray, offset: number, useBytes?: boolean): void;
  86403. /**
  86404. * Disposes the VertexBuffer and the underlying WebGLBuffer.
  86405. */
  86406. dispose(): void;
  86407. /**
  86408. * Enumerates each value of this vertex buffer as numbers.
  86409. * @param count the number of values to enumerate
  86410. * @param callback the callback function called for each value
  86411. */
  86412. forEach(count: number, callback: (value: number, index: number) => void): void;
  86413. /**
  86414. * Positions
  86415. */
  86416. static readonly PositionKind: string;
  86417. /**
  86418. * Normals
  86419. */
  86420. static readonly NormalKind: string;
  86421. /**
  86422. * Tangents
  86423. */
  86424. static readonly TangentKind: string;
  86425. /**
  86426. * Texture coordinates
  86427. */
  86428. static readonly UVKind: string;
  86429. /**
  86430. * Texture coordinates 2
  86431. */
  86432. static readonly UV2Kind: string;
  86433. /**
  86434. * Texture coordinates 3
  86435. */
  86436. static readonly UV3Kind: string;
  86437. /**
  86438. * Texture coordinates 4
  86439. */
  86440. static readonly UV4Kind: string;
  86441. /**
  86442. * Texture coordinates 5
  86443. */
  86444. static readonly UV5Kind: string;
  86445. /**
  86446. * Texture coordinates 6
  86447. */
  86448. static readonly UV6Kind: string;
  86449. /**
  86450. * Colors
  86451. */
  86452. static readonly ColorKind: string;
  86453. /**
  86454. * Matrix indices (for bones)
  86455. */
  86456. static readonly MatricesIndicesKind: string;
  86457. /**
  86458. * Matrix weights (for bones)
  86459. */
  86460. static readonly MatricesWeightsKind: string;
  86461. /**
  86462. * Additional matrix indices (for bones)
  86463. */
  86464. static readonly MatricesIndicesExtraKind: string;
  86465. /**
  86466. * Additional matrix weights (for bones)
  86467. */
  86468. static readonly MatricesWeightsExtraKind: string;
  86469. /**
  86470. * Deduces the stride given a kind.
  86471. * @param kind The kind string to deduce
  86472. * @returns The deduced stride
  86473. */
  86474. static DeduceStride(kind: string): number;
  86475. /**
  86476. * Gets the byte length of the given type.
  86477. * @param type the type
  86478. * @returns the number of bytes
  86479. */
  86480. static GetTypeByteLength(type: number): number;
  86481. /**
  86482. * Enumerates each value of the given parameters as numbers.
  86483. * @param data the data to enumerate
  86484. * @param byteOffset the byte offset of the data
  86485. * @param byteStride the byte stride of the data
  86486. * @param componentCount the number of components per element
  86487. * @param componentType the type of the component
  86488. * @param count the number of values to enumerate
  86489. * @param normalized whether the data is normalized
  86490. * @param callback the callback function called for each value
  86491. */
  86492. static ForEach(data: DataArray, byteOffset: number, byteStride: number, componentCount: number, componentType: number, count: number, normalized: boolean, callback: (value: number, index: number) => void): void;
  86493. private static _GetFloatValue;
  86494. }
  86495. }
  86496. declare module BABYLON {
  86497. /**
  86498. * @hidden
  86499. */
  86500. export class IntersectionInfo {
  86501. bu: Nullable<number>;
  86502. bv: Nullable<number>;
  86503. distance: number;
  86504. faceId: number;
  86505. subMeshId: number;
  86506. constructor(bu: Nullable<number>, bv: Nullable<number>, distance: number);
  86507. }
  86508. }
  86509. declare module BABYLON {
  86510. /**
  86511. * Class used to store bounding sphere information
  86512. */
  86513. export class BoundingSphere {
  86514. /**
  86515. * Gets the center of the bounding sphere in local space
  86516. */
  86517. readonly center: Vector3;
  86518. /**
  86519. * Radius of the bounding sphere in local space
  86520. */
  86521. radius: number;
  86522. /**
  86523. * Gets the center of the bounding sphere in world space
  86524. */
  86525. readonly centerWorld: Vector3;
  86526. /**
  86527. * Radius of the bounding sphere in world space
  86528. */
  86529. radiusWorld: number;
  86530. /**
  86531. * Gets the minimum vector in local space
  86532. */
  86533. readonly minimum: Vector3;
  86534. /**
  86535. * Gets the maximum vector in local space
  86536. */
  86537. readonly maximum: Vector3;
  86538. private _worldMatrix;
  86539. private static readonly TmpVector3;
  86540. /**
  86541. * Creates a new bounding sphere
  86542. * @param min defines the minimum vector (in local space)
  86543. * @param max defines the maximum vector (in local space)
  86544. * @param worldMatrix defines the new world matrix
  86545. */
  86546. constructor(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  86547. /**
  86548. * Recreates the entire bounding sphere from scratch as if we call the constructor in place
  86549. * @param min defines the new minimum vector (in local space)
  86550. * @param max defines the new maximum vector (in local space)
  86551. * @param worldMatrix defines the new world matrix
  86552. */
  86553. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  86554. /**
  86555. * Scale the current bounding sphere by applying a scale factor
  86556. * @param factor defines the scale factor to apply
  86557. * @returns the current bounding box
  86558. */
  86559. scale(factor: number): BoundingSphere;
  86560. /**
  86561. * Gets the world matrix of the bounding box
  86562. * @returns a matrix
  86563. */
  86564. getWorldMatrix(): DeepImmutable<Matrix>;
  86565. /** @hidden */
  86566. _update(worldMatrix: DeepImmutable<Matrix>): void;
  86567. /**
  86568. * Tests if the bounding sphere is intersecting the frustum planes
  86569. * @param frustumPlanes defines the frustum planes to test
  86570. * @returns true if there is an intersection
  86571. */
  86572. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  86573. /**
  86574. * Tests if the bounding sphere center is in between the frustum planes.
  86575. * Used for optimistic fast inclusion.
  86576. * @param frustumPlanes defines the frustum planes to test
  86577. * @returns true if the sphere center is in between the frustum planes
  86578. */
  86579. isCenterInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  86580. /**
  86581. * Tests if a point is inside the bounding sphere
  86582. * @param point defines the point to test
  86583. * @returns true if the point is inside the bounding sphere
  86584. */
  86585. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  86586. /**
  86587. * Checks if two sphere intersct
  86588. * @param sphere0 sphere 0
  86589. * @param sphere1 sphere 1
  86590. * @returns true if the speres intersect
  86591. */
  86592. static Intersects(sphere0: DeepImmutable<BoundingSphere>, sphere1: DeepImmutable<BoundingSphere>): boolean;
  86593. }
  86594. }
  86595. declare module BABYLON {
  86596. /**
  86597. * Class used to store bounding box information
  86598. */
  86599. export class BoundingBox implements ICullable {
  86600. /**
  86601. * Gets the 8 vectors representing the bounding box in local space
  86602. */
  86603. readonly vectors: Vector3[];
  86604. /**
  86605. * Gets the center of the bounding box in local space
  86606. */
  86607. readonly center: Vector3;
  86608. /**
  86609. * Gets the center of the bounding box in world space
  86610. */
  86611. readonly centerWorld: Vector3;
  86612. /**
  86613. * Gets the extend size in local space
  86614. */
  86615. readonly extendSize: Vector3;
  86616. /**
  86617. * Gets the extend size in world space
  86618. */
  86619. readonly extendSizeWorld: Vector3;
  86620. /**
  86621. * Gets the OBB (object bounding box) directions
  86622. */
  86623. readonly directions: Vector3[];
  86624. /**
  86625. * Gets the 8 vectors representing the bounding box in world space
  86626. */
  86627. readonly vectorsWorld: Vector3[];
  86628. /**
  86629. * Gets the minimum vector in world space
  86630. */
  86631. readonly minimumWorld: Vector3;
  86632. /**
  86633. * Gets the maximum vector in world space
  86634. */
  86635. readonly maximumWorld: Vector3;
  86636. /**
  86637. * Gets the minimum vector in local space
  86638. */
  86639. readonly minimum: Vector3;
  86640. /**
  86641. * Gets the maximum vector in local space
  86642. */
  86643. readonly maximum: Vector3;
  86644. private _worldMatrix;
  86645. private static readonly TmpVector3;
  86646. /**
  86647. * @hidden
  86648. */
  86649. _tag: number;
  86650. /**
  86651. * Creates a new bounding box
  86652. * @param min defines the minimum vector (in local space)
  86653. * @param max defines the maximum vector (in local space)
  86654. * @param worldMatrix defines the new world matrix
  86655. */
  86656. constructor(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  86657. /**
  86658. * Recreates the entire bounding box from scratch as if we call the constructor in place
  86659. * @param min defines the new minimum vector (in local space)
  86660. * @param max defines the new maximum vector (in local space)
  86661. * @param worldMatrix defines the new world matrix
  86662. */
  86663. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  86664. /**
  86665. * Scale the current bounding box by applying a scale factor
  86666. * @param factor defines the scale factor to apply
  86667. * @returns the current bounding box
  86668. */
  86669. scale(factor: number): BoundingBox;
  86670. /**
  86671. * Gets the world matrix of the bounding box
  86672. * @returns a matrix
  86673. */
  86674. getWorldMatrix(): DeepImmutable<Matrix>;
  86675. /** @hidden */
  86676. _update(world: DeepImmutable<Matrix>): void;
  86677. /**
  86678. * Tests if the bounding box is intersecting the frustum planes
  86679. * @param frustumPlanes defines the frustum planes to test
  86680. * @returns true if there is an intersection
  86681. */
  86682. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  86683. /**
  86684. * Tests if the bounding box is entirely inside the frustum planes
  86685. * @param frustumPlanes defines the frustum planes to test
  86686. * @returns true if there is an inclusion
  86687. */
  86688. isCompletelyInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  86689. /**
  86690. * Tests if a point is inside the bounding box
  86691. * @param point defines the point to test
  86692. * @returns true if the point is inside the bounding box
  86693. */
  86694. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  86695. /**
  86696. * Tests if the bounding box intersects with a bounding sphere
  86697. * @param sphere defines the sphere to test
  86698. * @returns true if there is an intersection
  86699. */
  86700. intersectsSphere(sphere: DeepImmutable<BoundingSphere>): boolean;
  86701. /**
  86702. * Tests if the bounding box intersects with a box defined by a min and max vectors
  86703. * @param min defines the min vector to use
  86704. * @param max defines the max vector to use
  86705. * @returns true if there is an intersection
  86706. */
  86707. intersectsMinMax(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>): boolean;
  86708. /**
  86709. * Tests if two bounding boxes are intersections
  86710. * @param box0 defines the first box to test
  86711. * @param box1 defines the second box to test
  86712. * @returns true if there is an intersection
  86713. */
  86714. static Intersects(box0: DeepImmutable<BoundingBox>, box1: DeepImmutable<BoundingBox>): boolean;
  86715. /**
  86716. * Tests if a bounding box defines by a min/max vectors intersects a sphere
  86717. * @param minPoint defines the minimum vector of the bounding box
  86718. * @param maxPoint defines the maximum vector of the bounding box
  86719. * @param sphereCenter defines the sphere center
  86720. * @param sphereRadius defines the sphere radius
  86721. * @returns true if there is an intersection
  86722. */
  86723. static IntersectsSphere(minPoint: DeepImmutable<Vector3>, maxPoint: DeepImmutable<Vector3>, sphereCenter: DeepImmutable<Vector3>, sphereRadius: number): boolean;
  86724. /**
  86725. * Tests if a bounding box defined with 8 vectors is entirely inside frustum planes
  86726. * @param boundingVectors defines an array of 8 vectors representing a bounding box
  86727. * @param frustumPlanes defines the frustum planes to test
  86728. * @return true if there is an inclusion
  86729. */
  86730. static IsCompletelyInFrustum(boundingVectors: Array<DeepImmutable<Vector3>>, frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  86731. /**
  86732. * Tests if a bounding box defined with 8 vectors intersects frustum planes
  86733. * @param boundingVectors defines an array of 8 vectors representing a bounding box
  86734. * @param frustumPlanes defines the frustum planes to test
  86735. * @return true if there is an intersection
  86736. */
  86737. static IsInFrustum(boundingVectors: Array<DeepImmutable<Vector3>>, frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  86738. }
  86739. }
  86740. declare module BABYLON {
  86741. /** @hidden */
  86742. export class Collider {
  86743. /** Define if a collision was found */
  86744. collisionFound: boolean;
  86745. /**
  86746. * Define last intersection point in local space
  86747. */
  86748. intersectionPoint: Vector3;
  86749. /**
  86750. * Define last collided mesh
  86751. */
  86752. collidedMesh: Nullable<AbstractMesh>;
  86753. private _collisionPoint;
  86754. private _planeIntersectionPoint;
  86755. private _tempVector;
  86756. private _tempVector2;
  86757. private _tempVector3;
  86758. private _tempVector4;
  86759. private _edge;
  86760. private _baseToVertex;
  86761. private _destinationPoint;
  86762. private _slidePlaneNormal;
  86763. private _displacementVector;
  86764. /** @hidden */
  86765. _radius: Vector3;
  86766. /** @hidden */
  86767. _retry: number;
  86768. private _velocity;
  86769. private _basePoint;
  86770. private _epsilon;
  86771. /** @hidden */
  86772. _velocityWorldLength: number;
  86773. /** @hidden */
  86774. _basePointWorld: Vector3;
  86775. private _velocityWorld;
  86776. private _normalizedVelocity;
  86777. /** @hidden */
  86778. _initialVelocity: Vector3;
  86779. /** @hidden */
  86780. _initialPosition: Vector3;
  86781. private _nearestDistance;
  86782. private _collisionMask;
  86783. get collisionMask(): number;
  86784. set collisionMask(mask: number);
  86785. /**
  86786. * Gets the plane normal used to compute the sliding response (in local space)
  86787. */
  86788. get slidePlaneNormal(): Vector3;
  86789. /** @hidden */
  86790. _initialize(source: Vector3, dir: Vector3, e: number): void;
  86791. /** @hidden */
  86792. _checkPointInTriangle(point: Vector3, pa: Vector3, pb: Vector3, pc: Vector3, n: Vector3): boolean;
  86793. /** @hidden */
  86794. _canDoCollision(sphereCenter: Vector3, sphereRadius: number, vecMin: Vector3, vecMax: Vector3): boolean;
  86795. /** @hidden */
  86796. _testTriangle(faceIndex: number, trianglePlaneArray: Array<Plane>, p1: Vector3, p2: Vector3, p3: Vector3, hasMaterial: boolean, hostMesh: AbstractMesh): void;
  86797. /** @hidden */
  86798. _collide(trianglePlaneArray: Array<Plane>, pts: Vector3[], indices: IndicesArray, indexStart: number, indexEnd: number, decal: number, hasMaterial: boolean, hostMesh: AbstractMesh): void;
  86799. /** @hidden */
  86800. _getResponse(pos: Vector3, vel: Vector3): void;
  86801. }
  86802. }
  86803. declare module BABYLON {
  86804. /**
  86805. * Interface for cullable objects
  86806. * @see https://doc.babylonjs.com/babylon101/materials#back-face-culling
  86807. */
  86808. export interface ICullable {
  86809. /**
  86810. * Checks if the object or part of the object is in the frustum
  86811. * @param frustumPlanes Camera near/planes
  86812. * @returns true if the object is in frustum otherwise false
  86813. */
  86814. isInFrustum(frustumPlanes: Plane[]): boolean;
  86815. /**
  86816. * Checks if a cullable object (mesh...) is in the camera frustum
  86817. * Unlike isInFrustum this cheks the full bounding box
  86818. * @param frustumPlanes Camera near/planes
  86819. * @returns true if the object is in frustum otherwise false
  86820. */
  86821. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  86822. }
  86823. /**
  86824. * Info for a bounding data of a mesh
  86825. */
  86826. export class BoundingInfo implements ICullable {
  86827. /**
  86828. * Bounding box for the mesh
  86829. */
  86830. readonly boundingBox: BoundingBox;
  86831. /**
  86832. * Bounding sphere for the mesh
  86833. */
  86834. readonly boundingSphere: BoundingSphere;
  86835. private _isLocked;
  86836. private static readonly TmpVector3;
  86837. /**
  86838. * Constructs bounding info
  86839. * @param minimum min vector of the bounding box/sphere
  86840. * @param maximum max vector of the bounding box/sphere
  86841. * @param worldMatrix defines the new world matrix
  86842. */
  86843. constructor(minimum: DeepImmutable<Vector3>, maximum: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  86844. /**
  86845. * Recreates the entire bounding info from scratch as if we call the constructor in place
  86846. * @param min defines the new minimum vector (in local space)
  86847. * @param max defines the new maximum vector (in local space)
  86848. * @param worldMatrix defines the new world matrix
  86849. */
  86850. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  86851. /**
  86852. * min vector of the bounding box/sphere
  86853. */
  86854. get minimum(): Vector3;
  86855. /**
  86856. * max vector of the bounding box/sphere
  86857. */
  86858. get maximum(): Vector3;
  86859. /**
  86860. * If the info is locked and won't be updated to avoid perf overhead
  86861. */
  86862. get isLocked(): boolean;
  86863. set isLocked(value: boolean);
  86864. /**
  86865. * Updates the bounding sphere and box
  86866. * @param world world matrix to be used to update
  86867. */
  86868. update(world: DeepImmutable<Matrix>): void;
  86869. /**
  86870. * Recreate the bounding info to be centered around a specific point given a specific extend.
  86871. * @param center New center of the bounding info
  86872. * @param extend New extend of the bounding info
  86873. * @returns the current bounding info
  86874. */
  86875. centerOn(center: DeepImmutable<Vector3>, extend: DeepImmutable<Vector3>): BoundingInfo;
  86876. /**
  86877. * Scale the current bounding info by applying a scale factor
  86878. * @param factor defines the scale factor to apply
  86879. * @returns the current bounding info
  86880. */
  86881. scale(factor: number): BoundingInfo;
  86882. /**
  86883. * Returns `true` if the bounding info is within the frustum defined by the passed array of planes.
  86884. * @param frustumPlanes defines the frustum to test
  86885. * @param strategy defines the strategy to use for the culling (default is BABYLON.AbstractMesh.CULLINGSTRATEGY_STANDARD)
  86886. * @returns true if the bounding info is in the frustum planes
  86887. */
  86888. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>, strategy?: number): boolean;
  86889. /**
  86890. * Gets the world distance between the min and max points of the bounding box
  86891. */
  86892. get diagonalLength(): number;
  86893. /**
  86894. * Checks if a cullable object (mesh...) is in the camera frustum
  86895. * Unlike isInFrustum this cheks the full bounding box
  86896. * @param frustumPlanes Camera near/planes
  86897. * @returns true if the object is in frustum otherwise false
  86898. */
  86899. isCompletelyInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  86900. /** @hidden */
  86901. _checkCollision(collider: Collider): boolean;
  86902. /**
  86903. * Checks if a point is inside the bounding box and bounding sphere or the mesh
  86904. * @see https://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  86905. * @param point the point to check intersection with
  86906. * @returns if the point intersects
  86907. */
  86908. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  86909. /**
  86910. * Checks if another bounding info intersects the bounding box and bounding sphere or the mesh
  86911. * @see https://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  86912. * @param boundingInfo the bounding info to check intersection with
  86913. * @param precise if the intersection should be done using OBB
  86914. * @returns if the bounding info intersects
  86915. */
  86916. intersects(boundingInfo: DeepImmutable<BoundingInfo>, precise: boolean): boolean;
  86917. }
  86918. }
  86919. declare module BABYLON {
  86920. /**
  86921. * Extracts minimum and maximum values from a list of indexed positions
  86922. * @param positions defines the positions to use
  86923. * @param indices defines the indices to the positions
  86924. * @param indexStart defines the start index
  86925. * @param indexCount defines the end index
  86926. * @param bias defines bias value to add to the result
  86927. * @return minimum and maximum values
  86928. */
  86929. export function extractMinAndMaxIndexed(positions: FloatArray, indices: IndicesArray, indexStart: number, indexCount: number, bias?: Nullable<Vector2>): {
  86930. minimum: Vector3;
  86931. maximum: Vector3;
  86932. };
  86933. /**
  86934. * Extracts minimum and maximum values from a list of positions
  86935. * @param positions defines the positions to use
  86936. * @param start defines the start index in the positions array
  86937. * @param count defines the number of positions to handle
  86938. * @param bias defines bias value to add to the result
  86939. * @param stride defines the stride size to use (distance between two positions in the positions array)
  86940. * @return minimum and maximum values
  86941. */
  86942. export function extractMinAndMax(positions: FloatArray, start: number, count: number, bias?: Nullable<Vector2>, stride?: number): {
  86943. minimum: Vector3;
  86944. maximum: Vector3;
  86945. };
  86946. }
  86947. declare module BABYLON {
  86948. /** @hidden */
  86949. export class WebGLDataBuffer extends DataBuffer {
  86950. private _buffer;
  86951. constructor(resource: WebGLBuffer);
  86952. get underlyingResource(): any;
  86953. }
  86954. }
  86955. declare module BABYLON {
  86956. /** @hidden */
  86957. export class WebGLPipelineContext implements IPipelineContext {
  86958. engine: ThinEngine;
  86959. program: Nullable<WebGLProgram>;
  86960. context?: WebGLRenderingContext;
  86961. vertexShader?: WebGLShader;
  86962. fragmentShader?: WebGLShader;
  86963. isParallelCompiled: boolean;
  86964. onCompiled?: () => void;
  86965. transformFeedback?: WebGLTransformFeedback | null;
  86966. vertexCompilationError: Nullable<string>;
  86967. fragmentCompilationError: Nullable<string>;
  86968. programLinkError: Nullable<string>;
  86969. programValidationError: Nullable<string>;
  86970. get isAsync(): boolean;
  86971. get isReady(): boolean;
  86972. _handlesSpectorRebuildCallback(onCompiled: (program: WebGLProgram) => void): void;
  86973. _getVertexShaderCode(): string | null;
  86974. _getFragmentShaderCode(): string | null;
  86975. }
  86976. }
  86977. declare module BABYLON {
  86978. interface ThinEngine {
  86979. /**
  86980. * Create an uniform buffer
  86981. * @see https://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  86982. * @param elements defines the content of the uniform buffer
  86983. * @returns the webGL uniform buffer
  86984. */
  86985. createUniformBuffer(elements: FloatArray): DataBuffer;
  86986. /**
  86987. * Create a dynamic uniform buffer
  86988. * @see https://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  86989. * @param elements defines the content of the uniform buffer
  86990. * @returns the webGL uniform buffer
  86991. */
  86992. createDynamicUniformBuffer(elements: FloatArray): DataBuffer;
  86993. /**
  86994. * Update an existing uniform buffer
  86995. * @see https://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  86996. * @param uniformBuffer defines the target uniform buffer
  86997. * @param elements defines the content to update
  86998. * @param offset defines the offset in the uniform buffer where update should start
  86999. * @param count defines the size of the data to update
  87000. */
  87001. updateUniformBuffer(uniformBuffer: DataBuffer, elements: FloatArray, offset?: number, count?: number): void;
  87002. /**
  87003. * Bind an uniform buffer to the current webGL context
  87004. * @param buffer defines the buffer to bind
  87005. */
  87006. bindUniformBuffer(buffer: Nullable<DataBuffer>): void;
  87007. /**
  87008. * Bind a buffer to the current webGL context at a given location
  87009. * @param buffer defines the buffer to bind
  87010. * @param location defines the index where to bind the buffer
  87011. */
  87012. bindUniformBufferBase(buffer: DataBuffer, location: number): void;
  87013. /**
  87014. * Bind a specific block at a given index in a specific shader program
  87015. * @param pipelineContext defines the pipeline context to use
  87016. * @param blockName defines the block name
  87017. * @param index defines the index where to bind the block
  87018. */
  87019. bindUniformBlock(pipelineContext: IPipelineContext, blockName: string, index: number): void;
  87020. }
  87021. }
  87022. declare module BABYLON {
  87023. /**
  87024. * Uniform buffer objects.
  87025. *
  87026. * Handles blocks of uniform on the GPU.
  87027. *
  87028. * If WebGL 2 is not available, this class falls back on traditionnal setUniformXXX calls.
  87029. *
  87030. * For more information, please refer to :
  87031. * https://www.khronos.org/opengl/wiki/Uniform_Buffer_Object
  87032. */
  87033. export class UniformBuffer {
  87034. private _engine;
  87035. private _buffer;
  87036. private _data;
  87037. private _bufferData;
  87038. private _dynamic?;
  87039. private _uniformLocations;
  87040. private _uniformSizes;
  87041. private _uniformLocationPointer;
  87042. private _needSync;
  87043. private _noUBO;
  87044. private _currentEffect;
  87045. /** @hidden */
  87046. _alreadyBound: boolean;
  87047. private static _MAX_UNIFORM_SIZE;
  87048. private static _tempBuffer;
  87049. /**
  87050. * Lambda to Update a 3x3 Matrix in a uniform buffer.
  87051. * This is dynamic to allow compat with webgl 1 and 2.
  87052. * You will need to pass the name of the uniform as well as the value.
  87053. */
  87054. updateMatrix3x3: (name: string, matrix: Float32Array) => void;
  87055. /**
  87056. * Lambda to Update a 2x2 Matrix in a uniform buffer.
  87057. * This is dynamic to allow compat with webgl 1 and 2.
  87058. * You will need to pass the name of the uniform as well as the value.
  87059. */
  87060. updateMatrix2x2: (name: string, matrix: Float32Array) => void;
  87061. /**
  87062. * Lambda to Update a single float in a uniform buffer.
  87063. * This is dynamic to allow compat with webgl 1 and 2.
  87064. * You will need to pass the name of the uniform as well as the value.
  87065. */
  87066. updateFloat: (name: string, x: number) => void;
  87067. /**
  87068. * Lambda to Update a vec2 of float in a uniform buffer.
  87069. * This is dynamic to allow compat with webgl 1 and 2.
  87070. * You will need to pass the name of the uniform as well as the value.
  87071. */
  87072. updateFloat2: (name: string, x: number, y: number, suffix?: string) => void;
  87073. /**
  87074. * Lambda to Update a vec3 of float in a uniform buffer.
  87075. * This is dynamic to allow compat with webgl 1 and 2.
  87076. * You will need to pass the name of the uniform as well as the value.
  87077. */
  87078. updateFloat3: (name: string, x: number, y: number, z: number, suffix?: string) => void;
  87079. /**
  87080. * Lambda to Update a vec4 of float in a uniform buffer.
  87081. * This is dynamic to allow compat with webgl 1 and 2.
  87082. * You will need to pass the name of the uniform as well as the value.
  87083. */
  87084. updateFloat4: (name: string, x: number, y: number, z: number, w: number, suffix?: string) => void;
  87085. /**
  87086. * Lambda to Update a 4x4 Matrix in a uniform buffer.
  87087. * This is dynamic to allow compat with webgl 1 and 2.
  87088. * You will need to pass the name of the uniform as well as the value.
  87089. */
  87090. updateMatrix: (name: string, mat: Matrix) => void;
  87091. /**
  87092. * Lambda to Update vec3 of float from a Vector in a uniform buffer.
  87093. * This is dynamic to allow compat with webgl 1 and 2.
  87094. * You will need to pass the name of the uniform as well as the value.
  87095. */
  87096. updateVector3: (name: string, vector: Vector3) => void;
  87097. /**
  87098. * Lambda to Update vec4 of float from a Vector in a uniform buffer.
  87099. * This is dynamic to allow compat with webgl 1 and 2.
  87100. * You will need to pass the name of the uniform as well as the value.
  87101. */
  87102. updateVector4: (name: string, vector: Vector4) => void;
  87103. /**
  87104. * Lambda to Update vec3 of float from a Color in a uniform buffer.
  87105. * This is dynamic to allow compat with webgl 1 and 2.
  87106. * You will need to pass the name of the uniform as well as the value.
  87107. */
  87108. updateColor3: (name: string, color: Color3, suffix?: string) => void;
  87109. /**
  87110. * Lambda to Update vec4 of float from a Color in a uniform buffer.
  87111. * This is dynamic to allow compat with webgl 1 and 2.
  87112. * You will need to pass the name of the uniform as well as the value.
  87113. */
  87114. updateColor4: (name: string, color: Color3, alpha: number, suffix?: string) => void;
  87115. /**
  87116. * Instantiates a new Uniform buffer objects.
  87117. *
  87118. * Handles blocks of uniform on the GPU.
  87119. *
  87120. * If WebGL 2 is not available, this class falls back on traditionnal setUniformXXX calls.
  87121. *
  87122. * For more information, please refer to :
  87123. * @see https://www.khronos.org/opengl/wiki/Uniform_Buffer_Object
  87124. * @param engine Define the engine the buffer is associated with
  87125. * @param data Define the data contained in the buffer
  87126. * @param dynamic Define if the buffer is updatable
  87127. */
  87128. constructor(engine: Engine, data?: number[], dynamic?: boolean);
  87129. /**
  87130. * Indicates if the buffer is using the WebGL2 UBO implementation,
  87131. * or just falling back on setUniformXXX calls.
  87132. */
  87133. get useUbo(): boolean;
  87134. /**
  87135. * Indicates if the WebGL underlying uniform buffer is in sync
  87136. * with the javascript cache data.
  87137. */
  87138. get isSync(): boolean;
  87139. /**
  87140. * Indicates if the WebGL underlying uniform buffer is dynamic.
  87141. * Also, a dynamic UniformBuffer will disable cache verification and always
  87142. * update the underlying WebGL uniform buffer to the GPU.
  87143. * @returns if Dynamic, otherwise false
  87144. */
  87145. isDynamic(): boolean;
  87146. /**
  87147. * The data cache on JS side.
  87148. * @returns the underlying data as a float array
  87149. */
  87150. getData(): Float32Array;
  87151. /**
  87152. * The underlying WebGL Uniform buffer.
  87153. * @returns the webgl buffer
  87154. */
  87155. getBuffer(): Nullable<DataBuffer>;
  87156. /**
  87157. * std140 layout specifies how to align data within an UBO structure.
  87158. * See https://khronos.org/registry/OpenGL/specs/gl/glspec45.core.pdf#page=159
  87159. * for specs.
  87160. */
  87161. private _fillAlignment;
  87162. /**
  87163. * Adds an uniform in the buffer.
  87164. * Warning : the subsequents calls of this function must be in the same order as declared in the shader
  87165. * for the layout to be correct !
  87166. * @param name Name of the uniform, as used in the uniform block in the shader.
  87167. * @param size Data size, or data directly.
  87168. */
  87169. addUniform(name: string, size: number | number[]): void;
  87170. /**
  87171. * Adds a Matrix 4x4 to the uniform buffer.
  87172. * @param name Name of the uniform, as used in the uniform block in the shader.
  87173. * @param mat A 4x4 matrix.
  87174. */
  87175. addMatrix(name: string, mat: Matrix): void;
  87176. /**
  87177. * Adds a vec2 to the uniform buffer.
  87178. * @param name Name of the uniform, as used in the uniform block in the shader.
  87179. * @param x Define the x component value of the vec2
  87180. * @param y Define the y component value of the vec2
  87181. */
  87182. addFloat2(name: string, x: number, y: number): void;
  87183. /**
  87184. * Adds a vec3 to the uniform buffer.
  87185. * @param name Name of the uniform, as used in the uniform block in the shader.
  87186. * @param x Define the x component value of the vec3
  87187. * @param y Define the y component value of the vec3
  87188. * @param z Define the z component value of the vec3
  87189. */
  87190. addFloat3(name: string, x: number, y: number, z: number): void;
  87191. /**
  87192. * Adds a vec3 to the uniform buffer.
  87193. * @param name Name of the uniform, as used in the uniform block in the shader.
  87194. * @param color Define the vec3 from a Color
  87195. */
  87196. addColor3(name: string, color: Color3): void;
  87197. /**
  87198. * Adds a vec4 to the uniform buffer.
  87199. * @param name Name of the uniform, as used in the uniform block in the shader.
  87200. * @param color Define the rgb components from a Color
  87201. * @param alpha Define the a component of the vec4
  87202. */
  87203. addColor4(name: string, color: Color3, alpha: number): void;
  87204. /**
  87205. * Adds a vec3 to the uniform buffer.
  87206. * @param name Name of the uniform, as used in the uniform block in the shader.
  87207. * @param vector Define the vec3 components from a Vector
  87208. */
  87209. addVector3(name: string, vector: Vector3): void;
  87210. /**
  87211. * Adds a Matrix 3x3 to the uniform buffer.
  87212. * @param name Name of the uniform, as used in the uniform block in the shader.
  87213. */
  87214. addMatrix3x3(name: string): void;
  87215. /**
  87216. * Adds a Matrix 2x2 to the uniform buffer.
  87217. * @param name Name of the uniform, as used in the uniform block in the shader.
  87218. */
  87219. addMatrix2x2(name: string): void;
  87220. /**
  87221. * Effectively creates the WebGL Uniform Buffer, once layout is completed with `addUniform`.
  87222. */
  87223. create(): void;
  87224. /** @hidden */
  87225. _rebuild(): void;
  87226. /**
  87227. * Updates the WebGL Uniform Buffer on the GPU.
  87228. * If the `dynamic` flag is set to true, no cache comparison is done.
  87229. * Otherwise, the buffer will be updated only if the cache differs.
  87230. */
  87231. update(): void;
  87232. /**
  87233. * Updates the value of an uniform. The `update` method must be called afterwards to make it effective in the GPU.
  87234. * @param uniformName Define the name of the uniform, as used in the uniform block in the shader.
  87235. * @param data Define the flattened data
  87236. * @param size Define the size of the data.
  87237. */
  87238. updateUniform(uniformName: string, data: FloatArray, size: number): void;
  87239. private _valueCache;
  87240. private _cacheMatrix;
  87241. private _updateMatrix3x3ForUniform;
  87242. private _updateMatrix3x3ForEffect;
  87243. private _updateMatrix2x2ForEffect;
  87244. private _updateMatrix2x2ForUniform;
  87245. private _updateFloatForEffect;
  87246. private _updateFloatForUniform;
  87247. private _updateFloat2ForEffect;
  87248. private _updateFloat2ForUniform;
  87249. private _updateFloat3ForEffect;
  87250. private _updateFloat3ForUniform;
  87251. private _updateFloat4ForEffect;
  87252. private _updateFloat4ForUniform;
  87253. private _updateMatrixForEffect;
  87254. private _updateMatrixForUniform;
  87255. private _updateVector3ForEffect;
  87256. private _updateVector3ForUniform;
  87257. private _updateVector4ForEffect;
  87258. private _updateVector4ForUniform;
  87259. private _updateColor3ForEffect;
  87260. private _updateColor3ForUniform;
  87261. private _updateColor4ForEffect;
  87262. private _updateColor4ForUniform;
  87263. /**
  87264. * Sets a sampler uniform on the effect.
  87265. * @param name Define the name of the sampler.
  87266. * @param texture Define the texture to set in the sampler
  87267. */
  87268. setTexture(name: string, texture: Nullable<BaseTexture>): void;
  87269. /**
  87270. * Directly updates the value of the uniform in the cache AND on the GPU.
  87271. * @param uniformName Define the name of the uniform, as used in the uniform block in the shader.
  87272. * @param data Define the flattened data
  87273. */
  87274. updateUniformDirectly(uniformName: string, data: FloatArray): void;
  87275. /**
  87276. * Binds this uniform buffer to an effect.
  87277. * @param effect Define the effect to bind the buffer to
  87278. * @param name Name of the uniform block in the shader.
  87279. */
  87280. bindToEffect(effect: Effect, name: string): void;
  87281. /**
  87282. * Disposes the uniform buffer.
  87283. */
  87284. dispose(): void;
  87285. }
  87286. }
  87287. declare module BABYLON {
  87288. /**
  87289. * Enum that determines the text-wrapping mode to use.
  87290. */
  87291. export enum InspectableType {
  87292. /**
  87293. * Checkbox for booleans
  87294. */
  87295. Checkbox = 0,
  87296. /**
  87297. * Sliders for numbers
  87298. */
  87299. Slider = 1,
  87300. /**
  87301. * Vector3
  87302. */
  87303. Vector3 = 2,
  87304. /**
  87305. * Quaternions
  87306. */
  87307. Quaternion = 3,
  87308. /**
  87309. * Color3
  87310. */
  87311. Color3 = 4,
  87312. /**
  87313. * String
  87314. */
  87315. String = 5
  87316. }
  87317. /**
  87318. * Interface used to define custom inspectable properties.
  87319. * This interface is used by the inspector to display custom property grids
  87320. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  87321. */
  87322. export interface IInspectable {
  87323. /**
  87324. * Gets the label to display
  87325. */
  87326. label: string;
  87327. /**
  87328. * Gets the name of the property to edit
  87329. */
  87330. propertyName: string;
  87331. /**
  87332. * Gets the type of the editor to use
  87333. */
  87334. type: InspectableType;
  87335. /**
  87336. * Gets the minimum value of the property when using in "slider" mode
  87337. */
  87338. min?: number;
  87339. /**
  87340. * Gets the maximum value of the property when using in "slider" mode
  87341. */
  87342. max?: number;
  87343. /**
  87344. * Gets the setp to use when using in "slider" mode
  87345. */
  87346. step?: number;
  87347. }
  87348. }
  87349. declare module BABYLON {
  87350. /**
  87351. * Class used to provide helper for timing
  87352. */
  87353. export class TimingTools {
  87354. /**
  87355. * Polyfill for setImmediate
  87356. * @param action defines the action to execute after the current execution block
  87357. */
  87358. static SetImmediate(action: () => void): void;
  87359. }
  87360. }
  87361. declare module BABYLON {
  87362. /**
  87363. * Class used to enable instatition of objects by class name
  87364. */
  87365. export class InstantiationTools {
  87366. /**
  87367. * Use this object to register external classes like custom textures or material
  87368. * to allow the laoders to instantiate them
  87369. */
  87370. static RegisteredExternalClasses: {
  87371. [key: string]: Object;
  87372. };
  87373. /**
  87374. * Tries to instantiate a new object from a given class name
  87375. * @param className defines the class name to instantiate
  87376. * @returns the new object or null if the system was not able to do the instantiation
  87377. */
  87378. static Instantiate(className: string): any;
  87379. }
  87380. }
  87381. declare module BABYLON {
  87382. /**
  87383. * Define options used to create a depth texture
  87384. */
  87385. export class DepthTextureCreationOptions {
  87386. /** Specifies whether or not a stencil should be allocated in the texture */
  87387. generateStencil?: boolean;
  87388. /** Specifies whether or not bilinear filtering is enable on the texture */
  87389. bilinearFiltering?: boolean;
  87390. /** Specifies the comparison function to set on the texture. If 0 or undefined, the texture is not in comparison mode */
  87391. comparisonFunction?: number;
  87392. /** Specifies if the created texture is a cube texture */
  87393. isCube?: boolean;
  87394. }
  87395. }
  87396. declare module BABYLON {
  87397. interface ThinEngine {
  87398. /**
  87399. * Creates a depth stencil cube texture.
  87400. * This is only available in WebGL 2.
  87401. * @param size The size of face edge in the cube texture.
  87402. * @param options The options defining the cube texture.
  87403. * @returns The cube texture
  87404. */
  87405. _createDepthStencilCubeTexture(size: number, options: DepthTextureCreationOptions): InternalTexture;
  87406. /**
  87407. * Creates a cube texture
  87408. * @param rootUrl defines the url where the files to load is located
  87409. * @param scene defines the current scene
  87410. * @param files defines the list of files to load (1 per face)
  87411. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  87412. * @param onLoad defines an optional callback raised when the texture is loaded
  87413. * @param onError defines an optional callback raised if there is an issue to load the texture
  87414. * @param format defines the format of the data
  87415. * @param forcedExtension defines the extension to use to pick the right loader
  87416. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  87417. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  87418. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  87419. * @param fallback defines texture to use while falling back when (compressed) texture file not found.
  87420. * @returns the cube texture as an InternalTexture
  87421. */
  87422. 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;
  87423. /**
  87424. * Creates a cube texture
  87425. * @param rootUrl defines the url where the files to load is located
  87426. * @param scene defines the current scene
  87427. * @param files defines the list of files to load (1 per face)
  87428. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  87429. * @param onLoad defines an optional callback raised when the texture is loaded
  87430. * @param onError defines an optional callback raised if there is an issue to load the texture
  87431. * @param format defines the format of the data
  87432. * @param forcedExtension defines the extension to use to pick the right loader
  87433. * @returns the cube texture as an InternalTexture
  87434. */
  87435. 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;
  87436. /**
  87437. * Creates a cube texture
  87438. * @param rootUrl defines the url where the files to load is located
  87439. * @param scene defines the current scene
  87440. * @param files defines the list of files to load (1 per face)
  87441. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  87442. * @param onLoad defines an optional callback raised when the texture is loaded
  87443. * @param onError defines an optional callback raised if there is an issue to load the texture
  87444. * @param format defines the format of the data
  87445. * @param forcedExtension defines the extension to use to pick the right loader
  87446. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  87447. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  87448. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  87449. * @returns the cube texture as an InternalTexture
  87450. */
  87451. 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;
  87452. /** @hidden */
  87453. _partialLoadFile(url: string, index: number, loadedFiles: ArrayBuffer[], onfinish: (files: ArrayBuffer[]) => void, onErrorCallBack: Nullable<(message?: string, exception?: any) => void>): void;
  87454. /** @hidden */
  87455. _cascadeLoadFiles(scene: Nullable<Scene>, onfinish: (images: ArrayBuffer[]) => void, files: string[], onError: Nullable<(message?: string, exception?: any) => void>): void;
  87456. /** @hidden */
  87457. _cascadeLoadImgs(scene: Nullable<Scene>, onfinish: (images: HTMLImageElement[]) => void, files: string[], onError: Nullable<(message?: string, exception?: any) => void>, mimeType?: string): void;
  87458. /** @hidden */
  87459. _partialLoadImg(url: string, index: number, loadedImages: HTMLImageElement[], scene: Nullable<Scene>, onfinish: (images: HTMLImageElement[]) => void, onErrorCallBack: Nullable<(message?: string, exception?: any) => void>, mimeType?: string): void;
  87460. /**
  87461. * @hidden
  87462. */
  87463. _setCubeMapTextureParams(loadMipmap: boolean): void;
  87464. }
  87465. }
  87466. declare module BABYLON {
  87467. /**
  87468. * Class for creating a cube texture
  87469. */
  87470. export class CubeTexture extends BaseTexture {
  87471. private _delayedOnLoad;
  87472. /**
  87473. * Observable triggered once the texture has been loaded.
  87474. */
  87475. onLoadObservable: Observable<CubeTexture>;
  87476. /**
  87477. * The url of the texture
  87478. */
  87479. url: string;
  87480. /**
  87481. * Gets or sets the center of the bounding box associated with the cube texture.
  87482. * It must define where the camera used to render the texture was set
  87483. * @see https://doc.babylonjs.com/how_to/reflect#using-local-cubemap-mode
  87484. */
  87485. boundingBoxPosition: Vector3;
  87486. private _boundingBoxSize;
  87487. /**
  87488. * Gets or sets the size of the bounding box associated with the cube texture
  87489. * When defined, the cubemap will switch to local mode
  87490. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  87491. * @example https://www.babylonjs-playground.com/#RNASML
  87492. */
  87493. set boundingBoxSize(value: Vector3);
  87494. /**
  87495. * Returns the bounding box size
  87496. * @see https://doc.babylonjs.com/how_to/reflect#using-local-cubemap-mode
  87497. */
  87498. get boundingBoxSize(): Vector3;
  87499. protected _rotationY: number;
  87500. /**
  87501. * Sets texture matrix rotation angle around Y axis in radians.
  87502. */
  87503. set rotationY(value: number);
  87504. /**
  87505. * Gets texture matrix rotation angle around Y axis radians.
  87506. */
  87507. get rotationY(): number;
  87508. /**
  87509. * Are mip maps generated for this texture or not.
  87510. */
  87511. get noMipmap(): boolean;
  87512. private _noMipmap;
  87513. private _files;
  87514. protected _forcedExtension: Nullable<string>;
  87515. private _extensions;
  87516. private _textureMatrix;
  87517. private _format;
  87518. private _createPolynomials;
  87519. /**
  87520. * Creates a cube texture from an array of image urls
  87521. * @param files defines an array of image urls
  87522. * @param scene defines the hosting scene
  87523. * @param noMipmap specifies if mip maps are not used
  87524. * @returns a cube texture
  87525. */
  87526. static CreateFromImages(files: string[], scene: Scene, noMipmap?: boolean): CubeTexture;
  87527. /**
  87528. * Creates and return a texture created from prefilterd data by tools like IBL Baker or Lys.
  87529. * @param url defines the url of the prefiltered texture
  87530. * @param scene defines the scene the texture is attached to
  87531. * @param forcedExtension defines the extension of the file if different from the url
  87532. * @param createPolynomials defines whether or not to create polynomial harmonics from the texture data if necessary
  87533. * @return the prefiltered texture
  87534. */
  87535. static CreateFromPrefilteredData(url: string, scene: Scene, forcedExtension?: any, createPolynomials?: boolean): CubeTexture;
  87536. /**
  87537. * Creates a cube texture to use with reflection for instance. It can be based upon dds or six images as well
  87538. * as prefiltered data.
  87539. * @param rootUrl defines the url of the texture or the root name of the six images
  87540. * @param null defines the scene or engine the texture is attached to
  87541. * @param extensions defines the suffixes add to the picture name in case six images are in use like _px.jpg...
  87542. * @param noMipmap defines if mipmaps should be created or not
  87543. * @param files defines the six files to load for the different faces in that order: px, py, pz, nx, ny, nz
  87544. * @param onLoad defines a callback triggered at the end of the file load if no errors occured
  87545. * @param onError defines a callback triggered in case of error during load
  87546. * @param format defines the internal format to use for the texture once loaded
  87547. * @param prefiltered defines whether or not the texture is created from prefiltered data
  87548. * @param forcedExtension defines the extensions to use (force a special type of file to load) in case it is different from the file name
  87549. * @param createPolynomials defines whether or not to create polynomial harmonics from the texture data if necessary
  87550. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  87551. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  87552. * @return the cube texture
  87553. */
  87554. 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);
  87555. /**
  87556. * Get the current class name of the texture useful for serialization or dynamic coding.
  87557. * @returns "CubeTexture"
  87558. */
  87559. getClassName(): string;
  87560. /**
  87561. * Update the url (and optional buffer) of this texture if url was null during construction.
  87562. * @param url the url of the texture
  87563. * @param forcedExtension defines the extension to use
  87564. * @param onLoad callback called when the texture is loaded (defaults to null)
  87565. * @param prefiltered Defines whether the updated texture is prefiltered or not
  87566. */
  87567. updateURL(url: string, forcedExtension?: string, onLoad?: () => void, prefiltered?: boolean): void;
  87568. /**
  87569. * Delays loading of the cube texture
  87570. * @param forcedExtension defines the extension to use
  87571. */
  87572. delayLoad(forcedExtension?: string): void;
  87573. /**
  87574. * Returns the reflection texture matrix
  87575. * @returns the reflection texture matrix
  87576. */
  87577. getReflectionTextureMatrix(): Matrix;
  87578. /**
  87579. * Sets the reflection texture matrix
  87580. * @param value Reflection texture matrix
  87581. */
  87582. setReflectionTextureMatrix(value: Matrix): void;
  87583. /**
  87584. * Parses text to create a cube texture
  87585. * @param parsedTexture define the serialized text to read from
  87586. * @param scene defines the hosting scene
  87587. * @param rootUrl defines the root url of the cube texture
  87588. * @returns a cube texture
  87589. */
  87590. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): CubeTexture;
  87591. /**
  87592. * Makes a clone, or deep copy, of the cube texture
  87593. * @returns a new cube texture
  87594. */
  87595. clone(): CubeTexture;
  87596. }
  87597. }
  87598. declare module BABYLON {
  87599. /**
  87600. * Manages the defines for the Material
  87601. */
  87602. export class MaterialDefines {
  87603. /** @hidden */
  87604. protected _keys: string[];
  87605. private _isDirty;
  87606. /** @hidden */
  87607. _renderId: number;
  87608. /** @hidden */
  87609. _areLightsDirty: boolean;
  87610. /** @hidden */
  87611. _areLightsDisposed: boolean;
  87612. /** @hidden */
  87613. _areAttributesDirty: boolean;
  87614. /** @hidden */
  87615. _areTexturesDirty: boolean;
  87616. /** @hidden */
  87617. _areFresnelDirty: boolean;
  87618. /** @hidden */
  87619. _areMiscDirty: boolean;
  87620. /** @hidden */
  87621. _areImageProcessingDirty: boolean;
  87622. /** @hidden */
  87623. _normals: boolean;
  87624. /** @hidden */
  87625. _uvs: boolean;
  87626. /** @hidden */
  87627. _needNormals: boolean;
  87628. /** @hidden */
  87629. _needUVs: boolean;
  87630. [id: string]: any;
  87631. /**
  87632. * Specifies if the material needs to be re-calculated
  87633. */
  87634. get isDirty(): boolean;
  87635. /**
  87636. * Marks the material to indicate that it has been re-calculated
  87637. */
  87638. markAsProcessed(): void;
  87639. /**
  87640. * Marks the material to indicate that it needs to be re-calculated
  87641. */
  87642. markAsUnprocessed(): void;
  87643. /**
  87644. * Marks the material to indicate all of its defines need to be re-calculated
  87645. */
  87646. markAllAsDirty(): void;
  87647. /**
  87648. * Marks the material to indicate that image processing needs to be re-calculated
  87649. */
  87650. markAsImageProcessingDirty(): void;
  87651. /**
  87652. * Marks the material to indicate the lights need to be re-calculated
  87653. * @param disposed Defines whether the light is dirty due to dispose or not
  87654. */
  87655. markAsLightDirty(disposed?: boolean): void;
  87656. /**
  87657. * Marks the attribute state as changed
  87658. */
  87659. markAsAttributesDirty(): void;
  87660. /**
  87661. * Marks the texture state as changed
  87662. */
  87663. markAsTexturesDirty(): void;
  87664. /**
  87665. * Marks the fresnel state as changed
  87666. */
  87667. markAsFresnelDirty(): void;
  87668. /**
  87669. * Marks the misc state as changed
  87670. */
  87671. markAsMiscDirty(): void;
  87672. /**
  87673. * Rebuilds the material defines
  87674. */
  87675. rebuild(): void;
  87676. /**
  87677. * Specifies if two material defines are equal
  87678. * @param other - A material define instance to compare to
  87679. * @returns - Boolean indicating if the material defines are equal (true) or not (false)
  87680. */
  87681. isEqual(other: MaterialDefines): boolean;
  87682. /**
  87683. * Clones this instance's defines to another instance
  87684. * @param other - material defines to clone values to
  87685. */
  87686. cloneTo(other: MaterialDefines): void;
  87687. /**
  87688. * Resets the material define values
  87689. */
  87690. reset(): void;
  87691. /**
  87692. * Converts the material define values to a string
  87693. * @returns - String of material define information
  87694. */
  87695. toString(): string;
  87696. }
  87697. }
  87698. declare module BABYLON {
  87699. /**
  87700. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  87701. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  87702. * 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;
  87703. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  87704. */
  87705. export class ColorCurves {
  87706. private _dirty;
  87707. private _tempColor;
  87708. private _globalCurve;
  87709. private _highlightsCurve;
  87710. private _midtonesCurve;
  87711. private _shadowsCurve;
  87712. private _positiveCurve;
  87713. private _negativeCurve;
  87714. private _globalHue;
  87715. private _globalDensity;
  87716. private _globalSaturation;
  87717. private _globalExposure;
  87718. /**
  87719. * Gets the global Hue value.
  87720. * 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).
  87721. */
  87722. get globalHue(): number;
  87723. /**
  87724. * Sets the global Hue value.
  87725. * 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).
  87726. */
  87727. set globalHue(value: number);
  87728. /**
  87729. * Gets the global Density value.
  87730. * 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.
  87731. * Values less than zero provide a filter of opposite hue.
  87732. */
  87733. get globalDensity(): number;
  87734. /**
  87735. * Sets the global Density value.
  87736. * 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.
  87737. * Values less than zero provide a filter of opposite hue.
  87738. */
  87739. set globalDensity(value: number);
  87740. /**
  87741. * Gets the global Saturation value.
  87742. * 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.
  87743. */
  87744. get globalSaturation(): number;
  87745. /**
  87746. * Sets the global Saturation value.
  87747. * 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.
  87748. */
  87749. set globalSaturation(value: number);
  87750. /**
  87751. * Gets the global Exposure value.
  87752. * 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.
  87753. */
  87754. get globalExposure(): number;
  87755. /**
  87756. * Sets the global Exposure value.
  87757. * 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.
  87758. */
  87759. set globalExposure(value: number);
  87760. private _highlightsHue;
  87761. private _highlightsDensity;
  87762. private _highlightsSaturation;
  87763. private _highlightsExposure;
  87764. /**
  87765. * Gets the highlights Hue value.
  87766. * 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).
  87767. */
  87768. get highlightsHue(): number;
  87769. /**
  87770. * Sets the highlights Hue value.
  87771. * 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).
  87772. */
  87773. set highlightsHue(value: number);
  87774. /**
  87775. * Gets the highlights Density value.
  87776. * 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.
  87777. * Values less than zero provide a filter of opposite hue.
  87778. */
  87779. get highlightsDensity(): number;
  87780. /**
  87781. * Sets the highlights Density value.
  87782. * 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.
  87783. * Values less than zero provide a filter of opposite hue.
  87784. */
  87785. set highlightsDensity(value: number);
  87786. /**
  87787. * Gets the highlights Saturation value.
  87788. * 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.
  87789. */
  87790. get highlightsSaturation(): number;
  87791. /**
  87792. * Sets the highlights Saturation value.
  87793. * 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.
  87794. */
  87795. set highlightsSaturation(value: number);
  87796. /**
  87797. * Gets the highlights Exposure value.
  87798. * 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.
  87799. */
  87800. get highlightsExposure(): number;
  87801. /**
  87802. * Sets the highlights Exposure value.
  87803. * 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.
  87804. */
  87805. set highlightsExposure(value: number);
  87806. private _midtonesHue;
  87807. private _midtonesDensity;
  87808. private _midtonesSaturation;
  87809. private _midtonesExposure;
  87810. /**
  87811. * Gets the midtones Hue value.
  87812. * 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).
  87813. */
  87814. get midtonesHue(): number;
  87815. /**
  87816. * Sets the midtones Hue value.
  87817. * 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).
  87818. */
  87819. set midtonesHue(value: number);
  87820. /**
  87821. * Gets the midtones Density value.
  87822. * 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.
  87823. * Values less than zero provide a filter of opposite hue.
  87824. */
  87825. get midtonesDensity(): number;
  87826. /**
  87827. * Sets the midtones Density value.
  87828. * 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.
  87829. * Values less than zero provide a filter of opposite hue.
  87830. */
  87831. set midtonesDensity(value: number);
  87832. /**
  87833. * Gets the midtones Saturation value.
  87834. * 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.
  87835. */
  87836. get midtonesSaturation(): number;
  87837. /**
  87838. * Sets the midtones Saturation value.
  87839. * 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.
  87840. */
  87841. set midtonesSaturation(value: number);
  87842. /**
  87843. * Gets the midtones Exposure value.
  87844. * 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.
  87845. */
  87846. get midtonesExposure(): number;
  87847. /**
  87848. * Sets the midtones Exposure value.
  87849. * 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.
  87850. */
  87851. set midtonesExposure(value: number);
  87852. private _shadowsHue;
  87853. private _shadowsDensity;
  87854. private _shadowsSaturation;
  87855. private _shadowsExposure;
  87856. /**
  87857. * Gets the shadows Hue value.
  87858. * 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).
  87859. */
  87860. get shadowsHue(): number;
  87861. /**
  87862. * Sets the shadows Hue value.
  87863. * 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).
  87864. */
  87865. set shadowsHue(value: number);
  87866. /**
  87867. * Gets the shadows Density value.
  87868. * 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.
  87869. * Values less than zero provide a filter of opposite hue.
  87870. */
  87871. get shadowsDensity(): number;
  87872. /**
  87873. * Sets the shadows Density value.
  87874. * 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.
  87875. * Values less than zero provide a filter of opposite hue.
  87876. */
  87877. set shadowsDensity(value: number);
  87878. /**
  87879. * Gets the shadows Saturation value.
  87880. * 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.
  87881. */
  87882. get shadowsSaturation(): number;
  87883. /**
  87884. * Sets the shadows Saturation value.
  87885. * 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.
  87886. */
  87887. set shadowsSaturation(value: number);
  87888. /**
  87889. * Gets the shadows Exposure value.
  87890. * 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.
  87891. */
  87892. get shadowsExposure(): number;
  87893. /**
  87894. * Sets the shadows Exposure value.
  87895. * 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.
  87896. */
  87897. set shadowsExposure(value: number);
  87898. /**
  87899. * Returns the class name
  87900. * @returns The class name
  87901. */
  87902. getClassName(): string;
  87903. /**
  87904. * Binds the color curves to the shader.
  87905. * @param colorCurves The color curve to bind
  87906. * @param effect The effect to bind to
  87907. * @param positiveUniform The positive uniform shader parameter
  87908. * @param neutralUniform The neutral uniform shader parameter
  87909. * @param negativeUniform The negative uniform shader parameter
  87910. */
  87911. static Bind(colorCurves: ColorCurves, effect: Effect, positiveUniform?: string, neutralUniform?: string, negativeUniform?: string): void;
  87912. /**
  87913. * Prepare the list of uniforms associated with the ColorCurves effects.
  87914. * @param uniformsList The list of uniforms used in the effect
  87915. */
  87916. static PrepareUniforms(uniformsList: string[]): void;
  87917. /**
  87918. * Returns color grading data based on a hue, density, saturation and exposure value.
  87919. * @param filterHue The hue of the color filter.
  87920. * @param filterDensity The density of the color filter.
  87921. * @param saturation The saturation.
  87922. * @param exposure The exposure.
  87923. * @param result The result data container.
  87924. */
  87925. private getColorGradingDataToRef;
  87926. /**
  87927. * Takes an input slider value and returns an adjusted value that provides extra control near the centre.
  87928. * @param value The input slider value in range [-100,100].
  87929. * @returns Adjusted value.
  87930. */
  87931. private static applyColorGradingSliderNonlinear;
  87932. /**
  87933. * Returns an RGBA Color4 based on Hue, Saturation and Brightness (also referred to as value, HSV).
  87934. * @param hue The hue (H) input.
  87935. * @param saturation The saturation (S) input.
  87936. * @param brightness The brightness (B) input.
  87937. * @result An RGBA color represented as Vector4.
  87938. */
  87939. private static fromHSBToRef;
  87940. /**
  87941. * Returns a value clamped between min and max
  87942. * @param value The value to clamp
  87943. * @param min The minimum of value
  87944. * @param max The maximum of value
  87945. * @returns The clamped value.
  87946. */
  87947. private static clamp;
  87948. /**
  87949. * Clones the current color curve instance.
  87950. * @return The cloned curves
  87951. */
  87952. clone(): ColorCurves;
  87953. /**
  87954. * Serializes the current color curve instance to a json representation.
  87955. * @return a JSON representation
  87956. */
  87957. serialize(): any;
  87958. /**
  87959. * Parses the color curve from a json representation.
  87960. * @param source the JSON source to parse
  87961. * @return The parsed curves
  87962. */
  87963. static Parse(source: any): ColorCurves;
  87964. }
  87965. }
  87966. declare module BABYLON {
  87967. /**
  87968. * Interface to follow in your material defines to integrate easily the
  87969. * Image proccessing functions.
  87970. * @hidden
  87971. */
  87972. export interface IImageProcessingConfigurationDefines {
  87973. IMAGEPROCESSING: boolean;
  87974. VIGNETTE: boolean;
  87975. VIGNETTEBLENDMODEMULTIPLY: boolean;
  87976. VIGNETTEBLENDMODEOPAQUE: boolean;
  87977. TONEMAPPING: boolean;
  87978. TONEMAPPING_ACES: boolean;
  87979. CONTRAST: boolean;
  87980. EXPOSURE: boolean;
  87981. COLORCURVES: boolean;
  87982. COLORGRADING: boolean;
  87983. COLORGRADING3D: boolean;
  87984. SAMPLER3DGREENDEPTH: boolean;
  87985. SAMPLER3DBGRMAP: boolean;
  87986. IMAGEPROCESSINGPOSTPROCESS: boolean;
  87987. }
  87988. /**
  87989. * @hidden
  87990. */
  87991. export class ImageProcessingConfigurationDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  87992. IMAGEPROCESSING: boolean;
  87993. VIGNETTE: boolean;
  87994. VIGNETTEBLENDMODEMULTIPLY: boolean;
  87995. VIGNETTEBLENDMODEOPAQUE: boolean;
  87996. TONEMAPPING: boolean;
  87997. TONEMAPPING_ACES: boolean;
  87998. CONTRAST: boolean;
  87999. COLORCURVES: boolean;
  88000. COLORGRADING: boolean;
  88001. COLORGRADING3D: boolean;
  88002. SAMPLER3DGREENDEPTH: boolean;
  88003. SAMPLER3DBGRMAP: boolean;
  88004. IMAGEPROCESSINGPOSTPROCESS: boolean;
  88005. EXPOSURE: boolean;
  88006. constructor();
  88007. }
  88008. /**
  88009. * This groups together the common properties used for image processing either in direct forward pass
  88010. * or through post processing effect depending on the use of the image processing pipeline in your scene
  88011. * or not.
  88012. */
  88013. export class ImageProcessingConfiguration {
  88014. /**
  88015. * Default tone mapping applied in BabylonJS.
  88016. */
  88017. static readonly TONEMAPPING_STANDARD: number;
  88018. /**
  88019. * ACES Tone mapping (used by default in unreal and unity). This can help getting closer
  88020. * to other engines rendering to increase portability.
  88021. */
  88022. static readonly TONEMAPPING_ACES: number;
  88023. /**
  88024. * Color curves setup used in the effect if colorCurvesEnabled is set to true
  88025. */
  88026. colorCurves: Nullable<ColorCurves>;
  88027. private _colorCurvesEnabled;
  88028. /**
  88029. * Gets wether the color curves effect is enabled.
  88030. */
  88031. get colorCurvesEnabled(): boolean;
  88032. /**
  88033. * Sets wether the color curves effect is enabled.
  88034. */
  88035. set colorCurvesEnabled(value: boolean);
  88036. private _colorGradingTexture;
  88037. /**
  88038. * Color grading LUT texture used in the effect if colorGradingEnabled is set to true
  88039. */
  88040. get colorGradingTexture(): Nullable<BaseTexture>;
  88041. /**
  88042. * Color grading LUT texture used in the effect if colorGradingEnabled is set to true
  88043. */
  88044. set colorGradingTexture(value: Nullable<BaseTexture>);
  88045. private _colorGradingEnabled;
  88046. /**
  88047. * Gets wether the color grading effect is enabled.
  88048. */
  88049. get colorGradingEnabled(): boolean;
  88050. /**
  88051. * Sets wether the color grading effect is enabled.
  88052. */
  88053. set colorGradingEnabled(value: boolean);
  88054. private _colorGradingWithGreenDepth;
  88055. /**
  88056. * Gets wether the color grading effect is using a green depth for the 3d Texture.
  88057. */
  88058. get colorGradingWithGreenDepth(): boolean;
  88059. /**
  88060. * Sets wether the color grading effect is using a green depth for the 3d Texture.
  88061. */
  88062. set colorGradingWithGreenDepth(value: boolean);
  88063. private _colorGradingBGR;
  88064. /**
  88065. * Gets wether the color grading texture contains BGR values.
  88066. */
  88067. get colorGradingBGR(): boolean;
  88068. /**
  88069. * Sets wether the color grading texture contains BGR values.
  88070. */
  88071. set colorGradingBGR(value: boolean);
  88072. /** @hidden */
  88073. _exposure: number;
  88074. /**
  88075. * Gets the Exposure used in the effect.
  88076. */
  88077. get exposure(): number;
  88078. /**
  88079. * Sets the Exposure used in the effect.
  88080. */
  88081. set exposure(value: number);
  88082. private _toneMappingEnabled;
  88083. /**
  88084. * Gets wether the tone mapping effect is enabled.
  88085. */
  88086. get toneMappingEnabled(): boolean;
  88087. /**
  88088. * Sets wether the tone mapping effect is enabled.
  88089. */
  88090. set toneMappingEnabled(value: boolean);
  88091. private _toneMappingType;
  88092. /**
  88093. * Gets the type of tone mapping effect.
  88094. */
  88095. get toneMappingType(): number;
  88096. /**
  88097. * Sets the type of tone mapping effect used in BabylonJS.
  88098. */
  88099. set toneMappingType(value: number);
  88100. protected _contrast: number;
  88101. /**
  88102. * Gets the contrast used in the effect.
  88103. */
  88104. get contrast(): number;
  88105. /**
  88106. * Sets the contrast used in the effect.
  88107. */
  88108. set contrast(value: number);
  88109. /**
  88110. * Vignette stretch size.
  88111. */
  88112. vignetteStretch: number;
  88113. /**
  88114. * Vignette centre X Offset.
  88115. */
  88116. vignetteCentreX: number;
  88117. /**
  88118. * Vignette centre Y Offset.
  88119. */
  88120. vignetteCentreY: number;
  88121. /**
  88122. * Vignette weight or intensity of the vignette effect.
  88123. */
  88124. vignetteWeight: number;
  88125. /**
  88126. * Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  88127. * if vignetteEnabled is set to true.
  88128. */
  88129. vignetteColor: Color4;
  88130. /**
  88131. * Camera field of view used by the Vignette effect.
  88132. */
  88133. vignetteCameraFov: number;
  88134. private _vignetteBlendMode;
  88135. /**
  88136. * Gets the vignette blend mode allowing different kind of effect.
  88137. */
  88138. get vignetteBlendMode(): number;
  88139. /**
  88140. * Sets the vignette blend mode allowing different kind of effect.
  88141. */
  88142. set vignetteBlendMode(value: number);
  88143. private _vignetteEnabled;
  88144. /**
  88145. * Gets wether the vignette effect is enabled.
  88146. */
  88147. get vignetteEnabled(): boolean;
  88148. /**
  88149. * Sets wether the vignette effect is enabled.
  88150. */
  88151. set vignetteEnabled(value: boolean);
  88152. private _applyByPostProcess;
  88153. /**
  88154. * Gets wether the image processing is applied through a post process or not.
  88155. */
  88156. get applyByPostProcess(): boolean;
  88157. /**
  88158. * Sets wether the image processing is applied through a post process or not.
  88159. */
  88160. set applyByPostProcess(value: boolean);
  88161. private _isEnabled;
  88162. /**
  88163. * Gets wether the image processing is enabled or not.
  88164. */
  88165. get isEnabled(): boolean;
  88166. /**
  88167. * Sets wether the image processing is enabled or not.
  88168. */
  88169. set isEnabled(value: boolean);
  88170. /**
  88171. * An event triggered when the configuration changes and requires Shader to Update some parameters.
  88172. */
  88173. onUpdateParameters: Observable<ImageProcessingConfiguration>;
  88174. /**
  88175. * Method called each time the image processing information changes requires to recompile the effect.
  88176. */
  88177. protected _updateParameters(): void;
  88178. /**
  88179. * Gets the current class name.
  88180. * @return "ImageProcessingConfiguration"
  88181. */
  88182. getClassName(): string;
  88183. /**
  88184. * Prepare the list of uniforms associated with the Image Processing effects.
  88185. * @param uniforms The list of uniforms used in the effect
  88186. * @param defines the list of defines currently in use
  88187. */
  88188. static PrepareUniforms(uniforms: string[], defines: IImageProcessingConfigurationDefines): void;
  88189. /**
  88190. * Prepare the list of samplers associated with the Image Processing effects.
  88191. * @param samplersList The list of uniforms used in the effect
  88192. * @param defines the list of defines currently in use
  88193. */
  88194. static PrepareSamplers(samplersList: string[], defines: IImageProcessingConfigurationDefines): void;
  88195. /**
  88196. * Prepare the list of defines associated to the shader.
  88197. * @param defines the list of defines to complete
  88198. * @param forPostProcess Define if we are currently in post process mode or not
  88199. */
  88200. prepareDefines(defines: IImageProcessingConfigurationDefines, forPostProcess?: boolean): void;
  88201. /**
  88202. * Returns true if all the image processing information are ready.
  88203. * @returns True if ready, otherwise, false
  88204. */
  88205. isReady(): boolean;
  88206. /**
  88207. * Binds the image processing to the shader.
  88208. * @param effect The effect to bind to
  88209. * @param overrideAspectRatio Override the aspect ratio of the effect
  88210. */
  88211. bind(effect: Effect, overrideAspectRatio?: number): void;
  88212. /**
  88213. * Clones the current image processing instance.
  88214. * @return The cloned image processing
  88215. */
  88216. clone(): ImageProcessingConfiguration;
  88217. /**
  88218. * Serializes the current image processing instance to a json representation.
  88219. * @return a JSON representation
  88220. */
  88221. serialize(): any;
  88222. /**
  88223. * Parses the image processing from a json representation.
  88224. * @param source the JSON source to parse
  88225. * @return The parsed image processing
  88226. */
  88227. static Parse(source: any): ImageProcessingConfiguration;
  88228. private static _VIGNETTEMODE_MULTIPLY;
  88229. private static _VIGNETTEMODE_OPAQUE;
  88230. /**
  88231. * Used to apply the vignette as a mix with the pixel color.
  88232. */
  88233. static get VIGNETTEMODE_MULTIPLY(): number;
  88234. /**
  88235. * Used to apply the vignette as a replacement of the pixel color.
  88236. */
  88237. static get VIGNETTEMODE_OPAQUE(): number;
  88238. }
  88239. }
  88240. declare module BABYLON {
  88241. /** @hidden */
  88242. export var postprocessVertexShader: {
  88243. name: string;
  88244. shader: string;
  88245. };
  88246. }
  88247. declare module BABYLON {
  88248. interface ThinEngine {
  88249. /**
  88250. * Creates a new render target texture
  88251. * @param size defines the size of the texture
  88252. * @param options defines the options used to create the texture
  88253. * @returns a new render target texture stored in an InternalTexture
  88254. */
  88255. createRenderTargetTexture(size: number | {
  88256. width: number;
  88257. height: number;
  88258. layers?: number;
  88259. }, options: boolean | RenderTargetCreationOptions): InternalTexture;
  88260. /**
  88261. * Creates a depth stencil texture.
  88262. * This is only available in WebGL 2 or with the depth texture extension available.
  88263. * @param size The size of face edge in the texture.
  88264. * @param options The options defining the texture.
  88265. * @returns The texture
  88266. */
  88267. createDepthStencilTexture(size: number | {
  88268. width: number;
  88269. height: number;
  88270. layers?: number;
  88271. }, options: DepthTextureCreationOptions): InternalTexture;
  88272. /** @hidden */
  88273. _createDepthStencilTexture(size: number | {
  88274. width: number;
  88275. height: number;
  88276. layers?: number;
  88277. }, options: DepthTextureCreationOptions): InternalTexture;
  88278. }
  88279. }
  88280. declare module BABYLON {
  88281. /**
  88282. * Defines the kind of connection point for node based material
  88283. */
  88284. export enum NodeMaterialBlockConnectionPointTypes {
  88285. /** Float */
  88286. Float = 1,
  88287. /** Int */
  88288. Int = 2,
  88289. /** Vector2 */
  88290. Vector2 = 4,
  88291. /** Vector3 */
  88292. Vector3 = 8,
  88293. /** Vector4 */
  88294. Vector4 = 16,
  88295. /** Color3 */
  88296. Color3 = 32,
  88297. /** Color4 */
  88298. Color4 = 64,
  88299. /** Matrix */
  88300. Matrix = 128,
  88301. /** Custom object */
  88302. Object = 256,
  88303. /** Detect type based on connection */
  88304. AutoDetect = 1024,
  88305. /** Output type that will be defined by input type */
  88306. BasedOnInput = 2048
  88307. }
  88308. }
  88309. declare module BABYLON {
  88310. /**
  88311. * Enum used to define the target of a block
  88312. */
  88313. export enum NodeMaterialBlockTargets {
  88314. /** Vertex shader */
  88315. Vertex = 1,
  88316. /** Fragment shader */
  88317. Fragment = 2,
  88318. /** Neutral */
  88319. Neutral = 4,
  88320. /** Vertex and Fragment */
  88321. VertexAndFragment = 3
  88322. }
  88323. }
  88324. declare module BABYLON {
  88325. /**
  88326. * Enum defining the mode of a NodeMaterialBlockConnectionPoint
  88327. */
  88328. export enum NodeMaterialBlockConnectionPointMode {
  88329. /** Value is an uniform */
  88330. Uniform = 0,
  88331. /** Value is a mesh attribute */
  88332. Attribute = 1,
  88333. /** Value is a varying between vertex and fragment shaders */
  88334. Varying = 2,
  88335. /** Mode is undefined */
  88336. Undefined = 3
  88337. }
  88338. }
  88339. declare module BABYLON {
  88340. /**
  88341. * Enum used to define system values e.g. values automatically provided by the system
  88342. */
  88343. export enum NodeMaterialSystemValues {
  88344. /** World */
  88345. World = 1,
  88346. /** View */
  88347. View = 2,
  88348. /** Projection */
  88349. Projection = 3,
  88350. /** ViewProjection */
  88351. ViewProjection = 4,
  88352. /** WorldView */
  88353. WorldView = 5,
  88354. /** WorldViewProjection */
  88355. WorldViewProjection = 6,
  88356. /** CameraPosition */
  88357. CameraPosition = 7,
  88358. /** Fog Color */
  88359. FogColor = 8,
  88360. /** Delta time */
  88361. DeltaTime = 9
  88362. }
  88363. }
  88364. declare module BABYLON {
  88365. /** Defines supported spaces */
  88366. export enum Space {
  88367. /** Local (object) space */
  88368. LOCAL = 0,
  88369. /** World space */
  88370. WORLD = 1,
  88371. /** Bone space */
  88372. BONE = 2
  88373. }
  88374. /** Defines the 3 main axes */
  88375. export class Axis {
  88376. /** X axis */
  88377. static X: Vector3;
  88378. /** Y axis */
  88379. static Y: Vector3;
  88380. /** Z axis */
  88381. static Z: Vector3;
  88382. }
  88383. }
  88384. declare module BABYLON {
  88385. /**
  88386. * Represents a camera frustum
  88387. */
  88388. export class Frustum {
  88389. /**
  88390. * Gets the planes representing the frustum
  88391. * @param transform matrix to be applied to the returned planes
  88392. * @returns a new array of 6 Frustum planes computed by the given transformation matrix.
  88393. */
  88394. static GetPlanes(transform: DeepImmutable<Matrix>): Plane[];
  88395. /**
  88396. * Gets the near frustum plane transformed by the transform matrix
  88397. * @param transform transformation matrix to be applied to the resulting frustum plane
  88398. * @param frustumPlane the resuling frustum plane
  88399. */
  88400. static GetNearPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  88401. /**
  88402. * Gets the far frustum plane transformed by the transform matrix
  88403. * @param transform transformation matrix to be applied to the resulting frustum plane
  88404. * @param frustumPlane the resuling frustum plane
  88405. */
  88406. static GetFarPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  88407. /**
  88408. * Gets the left frustum plane transformed by the transform matrix
  88409. * @param transform transformation matrix to be applied to the resulting frustum plane
  88410. * @param frustumPlane the resuling frustum plane
  88411. */
  88412. static GetLeftPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  88413. /**
  88414. * Gets the right frustum plane transformed by the transform matrix
  88415. * @param transform transformation matrix to be applied to the resulting frustum plane
  88416. * @param frustumPlane the resuling frustum plane
  88417. */
  88418. static GetRightPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  88419. /**
  88420. * Gets the top frustum plane transformed by the transform matrix
  88421. * @param transform transformation matrix to be applied to the resulting frustum plane
  88422. * @param frustumPlane the resuling frustum plane
  88423. */
  88424. static GetTopPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  88425. /**
  88426. * Gets the bottom frustum plane transformed by the transform matrix
  88427. * @param transform transformation matrix to be applied to the resulting frustum plane
  88428. * @param frustumPlane the resuling frustum plane
  88429. */
  88430. static GetBottomPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  88431. /**
  88432. * Sets the given array "frustumPlanes" with the 6 Frustum planes computed by the given transformation matrix.
  88433. * @param transform transformation matrix to be applied to the resulting frustum planes
  88434. * @param frustumPlanes the resuling frustum planes
  88435. */
  88436. static GetPlanesToRef(transform: DeepImmutable<Matrix>, frustumPlanes: Plane[]): void;
  88437. }
  88438. }
  88439. declare module BABYLON {
  88440. /**
  88441. * Interface for the size containing width and height
  88442. */
  88443. export interface ISize {
  88444. /**
  88445. * Width
  88446. */
  88447. width: number;
  88448. /**
  88449. * Heighht
  88450. */
  88451. height: number;
  88452. }
  88453. /**
  88454. * Size containing widht and height
  88455. */
  88456. export class Size implements ISize {
  88457. /**
  88458. * Width
  88459. */
  88460. width: number;
  88461. /**
  88462. * Height
  88463. */
  88464. height: number;
  88465. /**
  88466. * Creates a Size object from the given width and height (floats).
  88467. * @param width width of the new size
  88468. * @param height height of the new size
  88469. */
  88470. constructor(width: number, height: number);
  88471. /**
  88472. * Returns a string with the Size width and height
  88473. * @returns a string with the Size width and height
  88474. */
  88475. toString(): string;
  88476. /**
  88477. * "Size"
  88478. * @returns the string "Size"
  88479. */
  88480. getClassName(): string;
  88481. /**
  88482. * Returns the Size hash code.
  88483. * @returns a hash code for a unique width and height
  88484. */
  88485. getHashCode(): number;
  88486. /**
  88487. * Updates the current size from the given one.
  88488. * @param src the given size
  88489. */
  88490. copyFrom(src: Size): void;
  88491. /**
  88492. * Updates in place the current Size from the given floats.
  88493. * @param width width of the new size
  88494. * @param height height of the new size
  88495. * @returns the updated Size.
  88496. */
  88497. copyFromFloats(width: number, height: number): Size;
  88498. /**
  88499. * Updates in place the current Size from the given floats.
  88500. * @param width width to set
  88501. * @param height height to set
  88502. * @returns the updated Size.
  88503. */
  88504. set(width: number, height: number): Size;
  88505. /**
  88506. * Multiplies the width and height by numbers
  88507. * @param w factor to multiple the width by
  88508. * @param h factor to multiple the height by
  88509. * @returns a new Size set with the multiplication result of the current Size and the given floats.
  88510. */
  88511. multiplyByFloats(w: number, h: number): Size;
  88512. /**
  88513. * Clones the size
  88514. * @returns a new Size copied from the given one.
  88515. */
  88516. clone(): Size;
  88517. /**
  88518. * True if the current Size and the given one width and height are strictly equal.
  88519. * @param other the other size to compare against
  88520. * @returns True if the current Size and the given one width and height are strictly equal.
  88521. */
  88522. equals(other: Size): boolean;
  88523. /**
  88524. * The surface of the Size : width * height (float).
  88525. */
  88526. get surface(): number;
  88527. /**
  88528. * Create a new size of zero
  88529. * @returns a new Size set to (0.0, 0.0)
  88530. */
  88531. static Zero(): Size;
  88532. /**
  88533. * Sums the width and height of two sizes
  88534. * @param otherSize size to add to this size
  88535. * @returns a new Size set as the addition result of the current Size and the given one.
  88536. */
  88537. add(otherSize: Size): Size;
  88538. /**
  88539. * Subtracts the width and height of two
  88540. * @param otherSize size to subtract to this size
  88541. * @returns a new Size set as the subtraction result of the given one from the current Size.
  88542. */
  88543. subtract(otherSize: Size): Size;
  88544. /**
  88545. * Creates a new Size set at the linear interpolation "amount" between "start" and "end"
  88546. * @param start starting size to lerp between
  88547. * @param end end size to lerp between
  88548. * @param amount amount to lerp between the start and end values
  88549. * @returns a new Size set at the linear interpolation "amount" between "start" and "end"
  88550. */
  88551. static Lerp(start: Size, end: Size, amount: number): Size;
  88552. }
  88553. }
  88554. declare module BABYLON {
  88555. /**
  88556. * Contains position and normal vectors for a vertex
  88557. */
  88558. export class PositionNormalVertex {
  88559. /** the position of the vertex (defaut: 0,0,0) */
  88560. position: Vector3;
  88561. /** the normal of the vertex (defaut: 0,1,0) */
  88562. normal: Vector3;
  88563. /**
  88564. * Creates a PositionNormalVertex
  88565. * @param position the position of the vertex (defaut: 0,0,0)
  88566. * @param normal the normal of the vertex (defaut: 0,1,0)
  88567. */
  88568. constructor(
  88569. /** the position of the vertex (defaut: 0,0,0) */
  88570. position?: Vector3,
  88571. /** the normal of the vertex (defaut: 0,1,0) */
  88572. normal?: Vector3);
  88573. /**
  88574. * Clones the PositionNormalVertex
  88575. * @returns the cloned PositionNormalVertex
  88576. */
  88577. clone(): PositionNormalVertex;
  88578. }
  88579. /**
  88580. * Contains position, normal and uv vectors for a vertex
  88581. */
  88582. export class PositionNormalTextureVertex {
  88583. /** the position of the vertex (defaut: 0,0,0) */
  88584. position: Vector3;
  88585. /** the normal of the vertex (defaut: 0,1,0) */
  88586. normal: Vector3;
  88587. /** the uv of the vertex (default: 0,0) */
  88588. uv: Vector2;
  88589. /**
  88590. * Creates a PositionNormalTextureVertex
  88591. * @param position the position of the vertex (defaut: 0,0,0)
  88592. * @param normal the normal of the vertex (defaut: 0,1,0)
  88593. * @param uv the uv of the vertex (default: 0,0)
  88594. */
  88595. constructor(
  88596. /** the position of the vertex (defaut: 0,0,0) */
  88597. position?: Vector3,
  88598. /** the normal of the vertex (defaut: 0,1,0) */
  88599. normal?: Vector3,
  88600. /** the uv of the vertex (default: 0,0) */
  88601. uv?: Vector2);
  88602. /**
  88603. * Clones the PositionNormalTextureVertex
  88604. * @returns the cloned PositionNormalTextureVertex
  88605. */
  88606. clone(): PositionNormalTextureVertex;
  88607. }
  88608. }
  88609. declare module BABYLON {
  88610. /**
  88611. * Enum defining the type of animations supported by InputBlock
  88612. */
  88613. export enum AnimatedInputBlockTypes {
  88614. /** No animation */
  88615. None = 0,
  88616. /** Time based animation. Will only work for floats */
  88617. Time = 1
  88618. }
  88619. }
  88620. declare module BABYLON {
  88621. /**
  88622. * Interface describing all the common properties and methods a shadow light needs to implement.
  88623. * This helps both the shadow generator and materials to genrate the corresponding shadow maps
  88624. * as well as binding the different shadow properties to the effects.
  88625. */
  88626. export interface IShadowLight extends Light {
  88627. /**
  88628. * The light id in the scene (used in scene.findLighById for instance)
  88629. */
  88630. id: string;
  88631. /**
  88632. * The position the shdow will be casted from.
  88633. */
  88634. position: Vector3;
  88635. /**
  88636. * In 2d mode (needCube being false), the direction used to cast the shadow.
  88637. */
  88638. direction: Vector3;
  88639. /**
  88640. * The transformed position. Position of the light in world space taking parenting in account.
  88641. */
  88642. transformedPosition: Vector3;
  88643. /**
  88644. * The transformed direction. Direction of the light in world space taking parenting in account.
  88645. */
  88646. transformedDirection: Vector3;
  88647. /**
  88648. * The friendly name of the light in the scene.
  88649. */
  88650. name: string;
  88651. /**
  88652. * Defines the shadow projection clipping minimum z value.
  88653. */
  88654. shadowMinZ: number;
  88655. /**
  88656. * Defines the shadow projection clipping maximum z value.
  88657. */
  88658. shadowMaxZ: number;
  88659. /**
  88660. * Computes the transformed information (transformedPosition and transformedDirection in World space) of the current light
  88661. * @returns true if the information has been computed, false if it does not need to (no parenting)
  88662. */
  88663. computeTransformedInformation(): boolean;
  88664. /**
  88665. * Gets the scene the light belongs to.
  88666. * @returns The scene
  88667. */
  88668. getScene(): Scene;
  88669. /**
  88670. * Callback defining a custom Projection Matrix Builder.
  88671. * This can be used to override the default projection matrix computation.
  88672. */
  88673. customProjectionMatrixBuilder: (viewMatrix: Matrix, renderList: Array<AbstractMesh>, result: Matrix) => void;
  88674. /**
  88675. * Sets the shadow projection matrix in parameter to the generated projection matrix.
  88676. * @param matrix The materix to updated with the projection information
  88677. * @param viewMatrix The transform matrix of the light
  88678. * @param renderList The list of mesh to render in the map
  88679. * @returns The current light
  88680. */
  88681. setShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): IShadowLight;
  88682. /**
  88683. * Gets the current depth scale used in ESM.
  88684. * @returns The scale
  88685. */
  88686. getDepthScale(): number;
  88687. /**
  88688. * Returns whether or not the shadow generation require a cube texture or a 2d texture.
  88689. * @returns true if a cube texture needs to be use
  88690. */
  88691. needCube(): boolean;
  88692. /**
  88693. * Detects if the projection matrix requires to be recomputed this frame.
  88694. * @returns true if it requires to be recomputed otherwise, false.
  88695. */
  88696. needProjectionMatrixCompute(): boolean;
  88697. /**
  88698. * Forces the shadow generator to recompute the projection matrix even if position and direction did not changed.
  88699. */
  88700. forceProjectionMatrixCompute(): void;
  88701. /**
  88702. * Get the direction to use to render the shadow map. In case of cube texture, the face index can be passed.
  88703. * @param faceIndex The index of the face we are computed the direction to generate shadow
  88704. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  88705. */
  88706. getShadowDirection(faceIndex?: number): Vector3;
  88707. /**
  88708. * Gets the minZ used for shadow according to both the scene and the light.
  88709. * @param activeCamera The camera we are returning the min for
  88710. * @returns the depth min z
  88711. */
  88712. getDepthMinZ(activeCamera: Camera): number;
  88713. /**
  88714. * Gets the maxZ used for shadow according to both the scene and the light.
  88715. * @param activeCamera The camera we are returning the max for
  88716. * @returns the depth max z
  88717. */
  88718. getDepthMaxZ(activeCamera: Camera): number;
  88719. }
  88720. /**
  88721. * Base implementation IShadowLight
  88722. * It groups all the common behaviour in order to reduce dupplication and better follow the DRY pattern.
  88723. */
  88724. export abstract class ShadowLight extends Light implements IShadowLight {
  88725. protected abstract _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  88726. protected _position: Vector3;
  88727. protected _setPosition(value: Vector3): void;
  88728. /**
  88729. * Sets the position the shadow will be casted from. Also use as the light position for both
  88730. * point and spot lights.
  88731. */
  88732. get position(): Vector3;
  88733. /**
  88734. * Sets the position the shadow will be casted from. Also use as the light position for both
  88735. * point and spot lights.
  88736. */
  88737. set position(value: Vector3);
  88738. protected _direction: Vector3;
  88739. protected _setDirection(value: Vector3): void;
  88740. /**
  88741. * In 2d mode (needCube being false), gets the direction used to cast the shadow.
  88742. * Also use as the light direction on spot and directional lights.
  88743. */
  88744. get direction(): Vector3;
  88745. /**
  88746. * In 2d mode (needCube being false), sets the direction used to cast the shadow.
  88747. * Also use as the light direction on spot and directional lights.
  88748. */
  88749. set direction(value: Vector3);
  88750. protected _shadowMinZ: number;
  88751. /**
  88752. * Gets the shadow projection clipping minimum z value.
  88753. */
  88754. get shadowMinZ(): number;
  88755. /**
  88756. * Sets the shadow projection clipping minimum z value.
  88757. */
  88758. set shadowMinZ(value: number);
  88759. protected _shadowMaxZ: number;
  88760. /**
  88761. * Sets the shadow projection clipping maximum z value.
  88762. */
  88763. get shadowMaxZ(): number;
  88764. /**
  88765. * Gets the shadow projection clipping maximum z value.
  88766. */
  88767. set shadowMaxZ(value: number);
  88768. /**
  88769. * Callback defining a custom Projection Matrix Builder.
  88770. * This can be used to override the default projection matrix computation.
  88771. */
  88772. customProjectionMatrixBuilder: (viewMatrix: Matrix, renderList: Array<AbstractMesh>, result: Matrix) => void;
  88773. /**
  88774. * The transformed position. Position of the light in world space taking parenting in account.
  88775. */
  88776. transformedPosition: Vector3;
  88777. /**
  88778. * The transformed direction. Direction of the light in world space taking parenting in account.
  88779. */
  88780. transformedDirection: Vector3;
  88781. private _needProjectionMatrixCompute;
  88782. /**
  88783. * Computes the transformed information (transformedPosition and transformedDirection in World space) of the current light
  88784. * @returns true if the information has been computed, false if it does not need to (no parenting)
  88785. */
  88786. computeTransformedInformation(): boolean;
  88787. /**
  88788. * Return the depth scale used for the shadow map.
  88789. * @returns the depth scale.
  88790. */
  88791. getDepthScale(): number;
  88792. /**
  88793. * Get the direction to use to render the shadow map. In case of cube texture, the face index can be passed.
  88794. * @param faceIndex The index of the face we are computed the direction to generate shadow
  88795. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  88796. */
  88797. getShadowDirection(faceIndex?: number): Vector3;
  88798. /**
  88799. * Returns the ShadowLight absolute position in the World.
  88800. * @returns the position vector in world space
  88801. */
  88802. getAbsolutePosition(): Vector3;
  88803. /**
  88804. * Sets the ShadowLight direction toward the passed target.
  88805. * @param target The point to target in local space
  88806. * @returns the updated ShadowLight direction
  88807. */
  88808. setDirectionToTarget(target: Vector3): Vector3;
  88809. /**
  88810. * Returns the light rotation in euler definition.
  88811. * @returns the x y z rotation in local space.
  88812. */
  88813. getRotation(): Vector3;
  88814. /**
  88815. * Returns whether or not the shadow generation require a cube texture or a 2d texture.
  88816. * @returns true if a cube texture needs to be use
  88817. */
  88818. needCube(): boolean;
  88819. /**
  88820. * Detects if the projection matrix requires to be recomputed this frame.
  88821. * @returns true if it requires to be recomputed otherwise, false.
  88822. */
  88823. needProjectionMatrixCompute(): boolean;
  88824. /**
  88825. * Forces the shadow generator to recompute the projection matrix even if position and direction did not changed.
  88826. */
  88827. forceProjectionMatrixCompute(): void;
  88828. /** @hidden */
  88829. _initCache(): void;
  88830. /** @hidden */
  88831. _isSynchronized(): boolean;
  88832. /**
  88833. * Computes the world matrix of the node
  88834. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  88835. * @returns the world matrix
  88836. */
  88837. computeWorldMatrix(force?: boolean): Matrix;
  88838. /**
  88839. * Gets the minZ used for shadow according to both the scene and the light.
  88840. * @param activeCamera The camera we are returning the min for
  88841. * @returns the depth min z
  88842. */
  88843. getDepthMinZ(activeCamera: Camera): number;
  88844. /**
  88845. * Gets the maxZ used for shadow according to both the scene and the light.
  88846. * @param activeCamera The camera we are returning the max for
  88847. * @returns the depth max z
  88848. */
  88849. getDepthMaxZ(activeCamera: Camera): number;
  88850. /**
  88851. * Sets the shadow projection matrix in parameter to the generated projection matrix.
  88852. * @param matrix The materix to updated with the projection information
  88853. * @param viewMatrix The transform matrix of the light
  88854. * @param renderList The list of mesh to render in the map
  88855. * @returns The current light
  88856. */
  88857. setShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): IShadowLight;
  88858. }
  88859. }
  88860. declare module BABYLON {
  88861. /** @hidden */
  88862. export var packingFunctions: {
  88863. name: string;
  88864. shader: string;
  88865. };
  88866. }
  88867. declare module BABYLON {
  88868. /** @hidden */
  88869. export var bayerDitherFunctions: {
  88870. name: string;
  88871. shader: string;
  88872. };
  88873. }
  88874. declare module BABYLON {
  88875. /** @hidden */
  88876. export var shadowMapFragmentDeclaration: {
  88877. name: string;
  88878. shader: string;
  88879. };
  88880. }
  88881. declare module BABYLON {
  88882. /** @hidden */
  88883. export var clipPlaneFragmentDeclaration: {
  88884. name: string;
  88885. shader: string;
  88886. };
  88887. }
  88888. declare module BABYLON {
  88889. /** @hidden */
  88890. export var clipPlaneFragment: {
  88891. name: string;
  88892. shader: string;
  88893. };
  88894. }
  88895. declare module BABYLON {
  88896. /** @hidden */
  88897. export var shadowMapFragment: {
  88898. name: string;
  88899. shader: string;
  88900. };
  88901. }
  88902. declare module BABYLON {
  88903. /** @hidden */
  88904. export var shadowMapPixelShader: {
  88905. name: string;
  88906. shader: string;
  88907. };
  88908. }
  88909. declare module BABYLON {
  88910. /** @hidden */
  88911. export var bonesDeclaration: {
  88912. name: string;
  88913. shader: string;
  88914. };
  88915. }
  88916. declare module BABYLON {
  88917. /** @hidden */
  88918. export var morphTargetsVertexGlobalDeclaration: {
  88919. name: string;
  88920. shader: string;
  88921. };
  88922. }
  88923. declare module BABYLON {
  88924. /** @hidden */
  88925. export var morphTargetsVertexDeclaration: {
  88926. name: string;
  88927. shader: string;
  88928. };
  88929. }
  88930. declare module BABYLON {
  88931. /** @hidden */
  88932. export var instancesDeclaration: {
  88933. name: string;
  88934. shader: string;
  88935. };
  88936. }
  88937. declare module BABYLON {
  88938. /** @hidden */
  88939. export var helperFunctions: {
  88940. name: string;
  88941. shader: string;
  88942. };
  88943. }
  88944. declare module BABYLON {
  88945. /** @hidden */
  88946. export var shadowMapVertexDeclaration: {
  88947. name: string;
  88948. shader: string;
  88949. };
  88950. }
  88951. declare module BABYLON {
  88952. /** @hidden */
  88953. export var clipPlaneVertexDeclaration: {
  88954. name: string;
  88955. shader: string;
  88956. };
  88957. }
  88958. declare module BABYLON {
  88959. /** @hidden */
  88960. export var morphTargetsVertex: {
  88961. name: string;
  88962. shader: string;
  88963. };
  88964. }
  88965. declare module BABYLON {
  88966. /** @hidden */
  88967. export var instancesVertex: {
  88968. name: string;
  88969. shader: string;
  88970. };
  88971. }
  88972. declare module BABYLON {
  88973. /** @hidden */
  88974. export var bonesVertex: {
  88975. name: string;
  88976. shader: string;
  88977. };
  88978. }
  88979. declare module BABYLON {
  88980. /** @hidden */
  88981. export var shadowMapVertexNormalBias: {
  88982. name: string;
  88983. shader: string;
  88984. };
  88985. }
  88986. declare module BABYLON {
  88987. /** @hidden */
  88988. export var shadowMapVertexMetric: {
  88989. name: string;
  88990. shader: string;
  88991. };
  88992. }
  88993. declare module BABYLON {
  88994. /** @hidden */
  88995. export var clipPlaneVertex: {
  88996. name: string;
  88997. shader: string;
  88998. };
  88999. }
  89000. declare module BABYLON {
  89001. /** @hidden */
  89002. export var shadowMapVertexShader: {
  89003. name: string;
  89004. shader: string;
  89005. };
  89006. }
  89007. declare module BABYLON {
  89008. /** @hidden */
  89009. export var depthBoxBlurPixelShader: {
  89010. name: string;
  89011. shader: string;
  89012. };
  89013. }
  89014. declare module BABYLON {
  89015. /** @hidden */
  89016. export var shadowMapFragmentSoftTransparentShadow: {
  89017. name: string;
  89018. shader: string;
  89019. };
  89020. }
  89021. declare module BABYLON {
  89022. /**
  89023. * EffectFallbacks can be used to add fallbacks (properties to disable) to certain properties when desired to improve performance.
  89024. * (Eg. Start at high quality with reflection and fog, if fps is low, remove reflection, if still low remove fog)
  89025. */
  89026. export class EffectFallbacks implements IEffectFallbacks {
  89027. private _defines;
  89028. private _currentRank;
  89029. private _maxRank;
  89030. private _mesh;
  89031. /**
  89032. * Removes the fallback from the bound mesh.
  89033. */
  89034. unBindMesh(): void;
  89035. /**
  89036. * Adds a fallback on the specified property.
  89037. * @param rank The rank of the fallback (Lower ranks will be fallbacked to first)
  89038. * @param define The name of the define in the shader
  89039. */
  89040. addFallback(rank: number, define: string): void;
  89041. /**
  89042. * Sets the mesh to use CPU skinning when needing to fallback.
  89043. * @param rank The rank of the fallback (Lower ranks will be fallbacked to first)
  89044. * @param mesh The mesh to use the fallbacks.
  89045. */
  89046. addCPUSkinningFallback(rank: number, mesh: AbstractMesh): void;
  89047. /**
  89048. * Checks to see if more fallbacks are still availible.
  89049. */
  89050. get hasMoreFallbacks(): boolean;
  89051. /**
  89052. * Removes the defines that should be removed when falling back.
  89053. * @param currentDefines defines the current define statements for the shader.
  89054. * @param effect defines the current effect we try to compile
  89055. * @returns The resulting defines with defines of the current rank removed.
  89056. */
  89057. reduce(currentDefines: string, effect: Effect): string;
  89058. }
  89059. }
  89060. declare module BABYLON {
  89061. /**
  89062. * Interface used to define Action
  89063. */
  89064. export interface IAction {
  89065. /**
  89066. * Trigger for the action
  89067. */
  89068. trigger: number;
  89069. /** Options of the trigger */
  89070. triggerOptions: any;
  89071. /**
  89072. * Gets the trigger parameters
  89073. * @returns the trigger parameters
  89074. */
  89075. getTriggerParameter(): any;
  89076. /**
  89077. * Internal only - executes current action event
  89078. * @hidden
  89079. */
  89080. _executeCurrent(evt?: ActionEvent): void;
  89081. /**
  89082. * Serialize placeholder for child classes
  89083. * @param parent of child
  89084. * @returns the serialized object
  89085. */
  89086. serialize(parent: any): any;
  89087. /**
  89088. * Internal only
  89089. * @hidden
  89090. */
  89091. _prepare(): void;
  89092. /**
  89093. * Internal only - manager for action
  89094. * @hidden
  89095. */
  89096. _actionManager: Nullable<AbstractActionManager>;
  89097. /**
  89098. * Adds action to chain of actions, may be a DoNothingAction
  89099. * @param action defines the next action to execute
  89100. * @returns The action passed in
  89101. * @see https://www.babylonjs-playground.com/#1T30HR#0
  89102. */
  89103. then(action: IAction): IAction;
  89104. }
  89105. /**
  89106. * The action to be carried out following a trigger
  89107. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#available-actions
  89108. */
  89109. export class Action implements IAction {
  89110. /** the trigger, with or without parameters, for the action */
  89111. triggerOptions: any;
  89112. /**
  89113. * Trigger for the action
  89114. */
  89115. trigger: number;
  89116. /**
  89117. * Internal only - manager for action
  89118. * @hidden
  89119. */
  89120. _actionManager: ActionManager;
  89121. private _nextActiveAction;
  89122. private _child;
  89123. private _condition?;
  89124. private _triggerParameter;
  89125. /**
  89126. * An event triggered prior to action being executed.
  89127. */
  89128. onBeforeExecuteObservable: Observable<Action>;
  89129. /**
  89130. * Creates a new Action
  89131. * @param triggerOptions the trigger, with or without parameters, for the action
  89132. * @param condition an optional determinant of action
  89133. */
  89134. constructor(
  89135. /** the trigger, with or without parameters, for the action */
  89136. triggerOptions: any, condition?: Condition);
  89137. /**
  89138. * Internal only
  89139. * @hidden
  89140. */
  89141. _prepare(): void;
  89142. /**
  89143. * Gets the trigger parameters
  89144. * @returns the trigger parameters
  89145. */
  89146. getTriggerParameter(): any;
  89147. /**
  89148. * Internal only - executes current action event
  89149. * @hidden
  89150. */
  89151. _executeCurrent(evt?: ActionEvent): void;
  89152. /**
  89153. * Execute placeholder for child classes
  89154. * @param evt optional action event
  89155. */
  89156. execute(evt?: ActionEvent): void;
  89157. /**
  89158. * Skips to next active action
  89159. */
  89160. skipToNextActiveAction(): void;
  89161. /**
  89162. * Adds action to chain of actions, may be a DoNothingAction
  89163. * @param action defines the next action to execute
  89164. * @returns The action passed in
  89165. * @see https://www.babylonjs-playground.com/#1T30HR#0
  89166. */
  89167. then(action: Action): Action;
  89168. /**
  89169. * Internal only
  89170. * @hidden
  89171. */
  89172. _getProperty(propertyPath: string): string;
  89173. /**
  89174. * Internal only
  89175. * @hidden
  89176. */
  89177. _getEffectiveTarget(target: any, propertyPath: string): any;
  89178. /**
  89179. * Serialize placeholder for child classes
  89180. * @param parent of child
  89181. * @returns the serialized object
  89182. */
  89183. serialize(parent: any): any;
  89184. /**
  89185. * Internal only called by serialize
  89186. * @hidden
  89187. */
  89188. protected _serialize(serializedAction: any, parent?: any): any;
  89189. /**
  89190. * Internal only
  89191. * @hidden
  89192. */
  89193. static _SerializeValueAsString: (value: any) => string;
  89194. /**
  89195. * Internal only
  89196. * @hidden
  89197. */
  89198. static _GetTargetProperty: (target: Scene | Node) => {
  89199. name: string;
  89200. targetType: string;
  89201. value: string;
  89202. };
  89203. }
  89204. }
  89205. declare module BABYLON {
  89206. /**
  89207. * A Condition applied to an Action
  89208. */
  89209. export class Condition {
  89210. /**
  89211. * Internal only - manager for action
  89212. * @hidden
  89213. */
  89214. _actionManager: ActionManager;
  89215. /**
  89216. * Internal only
  89217. * @hidden
  89218. */
  89219. _evaluationId: number;
  89220. /**
  89221. * Internal only
  89222. * @hidden
  89223. */
  89224. _currentResult: boolean;
  89225. /**
  89226. * Creates a new Condition
  89227. * @param actionManager the manager of the action the condition is applied to
  89228. */
  89229. constructor(actionManager: ActionManager);
  89230. /**
  89231. * Check if the current condition is valid
  89232. * @returns a boolean
  89233. */
  89234. isValid(): boolean;
  89235. /**
  89236. * Internal only
  89237. * @hidden
  89238. */
  89239. _getProperty(propertyPath: string): string;
  89240. /**
  89241. * Internal only
  89242. * @hidden
  89243. */
  89244. _getEffectiveTarget(target: any, propertyPath: string): any;
  89245. /**
  89246. * Serialize placeholder for child classes
  89247. * @returns the serialized object
  89248. */
  89249. serialize(): any;
  89250. /**
  89251. * Internal only
  89252. * @hidden
  89253. */
  89254. protected _serialize(serializedCondition: any): any;
  89255. }
  89256. /**
  89257. * Defines specific conditional operators as extensions of Condition
  89258. */
  89259. export class ValueCondition extends Condition {
  89260. /** path to specify the property of the target the conditional operator uses */
  89261. propertyPath: string;
  89262. /** the value compared by the conditional operator against the current value of the property */
  89263. value: any;
  89264. /** the conditional operator, default ValueCondition.IsEqual */
  89265. operator: number;
  89266. /**
  89267. * Internal only
  89268. * @hidden
  89269. */
  89270. private static _IsEqual;
  89271. /**
  89272. * Internal only
  89273. * @hidden
  89274. */
  89275. private static _IsDifferent;
  89276. /**
  89277. * Internal only
  89278. * @hidden
  89279. */
  89280. private static _IsGreater;
  89281. /**
  89282. * Internal only
  89283. * @hidden
  89284. */
  89285. private static _IsLesser;
  89286. /**
  89287. * returns the number for IsEqual
  89288. */
  89289. static get IsEqual(): number;
  89290. /**
  89291. * Returns the number for IsDifferent
  89292. */
  89293. static get IsDifferent(): number;
  89294. /**
  89295. * Returns the number for IsGreater
  89296. */
  89297. static get IsGreater(): number;
  89298. /**
  89299. * Returns the number for IsLesser
  89300. */
  89301. static get IsLesser(): number;
  89302. /**
  89303. * Internal only The action manager for the condition
  89304. * @hidden
  89305. */
  89306. _actionManager: ActionManager;
  89307. /**
  89308. * Internal only
  89309. * @hidden
  89310. */
  89311. private _target;
  89312. /**
  89313. * Internal only
  89314. * @hidden
  89315. */
  89316. private _effectiveTarget;
  89317. /**
  89318. * Internal only
  89319. * @hidden
  89320. */
  89321. private _property;
  89322. /**
  89323. * Creates a new ValueCondition
  89324. * @param actionManager manager for the action the condition applies to
  89325. * @param target for the action
  89326. * @param propertyPath path to specify the property of the target the conditional operator uses
  89327. * @param value the value compared by the conditional operator against the current value of the property
  89328. * @param operator the conditional operator, default ValueCondition.IsEqual
  89329. */
  89330. constructor(actionManager: ActionManager, target: any,
  89331. /** path to specify the property of the target the conditional operator uses */
  89332. propertyPath: string,
  89333. /** the value compared by the conditional operator against the current value of the property */
  89334. value: any,
  89335. /** the conditional operator, default ValueCondition.IsEqual */
  89336. operator?: number);
  89337. /**
  89338. * Compares the given value with the property value for the specified conditional operator
  89339. * @returns the result of the comparison
  89340. */
  89341. isValid(): boolean;
  89342. /**
  89343. * Serialize the ValueCondition into a JSON compatible object
  89344. * @returns serialization object
  89345. */
  89346. serialize(): any;
  89347. /**
  89348. * Gets the name of the conditional operator for the ValueCondition
  89349. * @param operator the conditional operator
  89350. * @returns the name
  89351. */
  89352. static GetOperatorName(operator: number): string;
  89353. }
  89354. /**
  89355. * Defines a predicate condition as an extension of Condition
  89356. */
  89357. export class PredicateCondition extends Condition {
  89358. /** defines the predicate function used to validate the condition */
  89359. predicate: () => boolean;
  89360. /**
  89361. * Internal only - manager for action
  89362. * @hidden
  89363. */
  89364. _actionManager: ActionManager;
  89365. /**
  89366. * Creates a new PredicateCondition
  89367. * @param actionManager manager for the action the condition applies to
  89368. * @param predicate defines the predicate function used to validate the condition
  89369. */
  89370. constructor(actionManager: ActionManager,
  89371. /** defines the predicate function used to validate the condition */
  89372. predicate: () => boolean);
  89373. /**
  89374. * @returns the validity of the predicate condition
  89375. */
  89376. isValid(): boolean;
  89377. }
  89378. /**
  89379. * Defines a state condition as an extension of Condition
  89380. */
  89381. export class StateCondition extends Condition {
  89382. /** Value to compare with target state */
  89383. value: string;
  89384. /**
  89385. * Internal only - manager for action
  89386. * @hidden
  89387. */
  89388. _actionManager: ActionManager;
  89389. /**
  89390. * Internal only
  89391. * @hidden
  89392. */
  89393. private _target;
  89394. /**
  89395. * Creates a new StateCondition
  89396. * @param actionManager manager for the action the condition applies to
  89397. * @param target of the condition
  89398. * @param value to compare with target state
  89399. */
  89400. constructor(actionManager: ActionManager, target: any,
  89401. /** Value to compare with target state */
  89402. value: string);
  89403. /**
  89404. * Gets a boolean indicating if the current condition is met
  89405. * @returns the validity of the state
  89406. */
  89407. isValid(): boolean;
  89408. /**
  89409. * Serialize the StateCondition into a JSON compatible object
  89410. * @returns serialization object
  89411. */
  89412. serialize(): any;
  89413. }
  89414. }
  89415. declare module BABYLON {
  89416. /**
  89417. * This defines an action responsible to toggle a boolean once triggered.
  89418. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  89419. */
  89420. export class SwitchBooleanAction extends Action {
  89421. /**
  89422. * The path to the boolean property in the target object
  89423. */
  89424. propertyPath: string;
  89425. private _target;
  89426. private _effectiveTarget;
  89427. private _property;
  89428. /**
  89429. * Instantiate the action
  89430. * @param triggerOptions defines the trigger options
  89431. * @param target defines the object containing the boolean
  89432. * @param propertyPath defines the path to the boolean property in the target object
  89433. * @param condition defines the trigger related conditions
  89434. */
  89435. constructor(triggerOptions: any, target: any, propertyPath: string, condition?: Condition);
  89436. /** @hidden */
  89437. _prepare(): void;
  89438. /**
  89439. * Execute the action toggle the boolean value.
  89440. */
  89441. execute(): void;
  89442. /**
  89443. * Serializes the actions and its related information.
  89444. * @param parent defines the object to serialize in
  89445. * @returns the serialized object
  89446. */
  89447. serialize(parent: any): any;
  89448. }
  89449. /**
  89450. * This defines an action responsible to set a the state field of the target
  89451. * to a desired value once triggered.
  89452. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  89453. */
  89454. export class SetStateAction extends Action {
  89455. /**
  89456. * The value to store in the state field.
  89457. */
  89458. value: string;
  89459. private _target;
  89460. /**
  89461. * Instantiate the action
  89462. * @param triggerOptions defines the trigger options
  89463. * @param target defines the object containing the state property
  89464. * @param value defines the value to store in the state field
  89465. * @param condition defines the trigger related conditions
  89466. */
  89467. constructor(triggerOptions: any, target: any, value: string, condition?: Condition);
  89468. /**
  89469. * Execute the action and store the value on the target state property.
  89470. */
  89471. execute(): void;
  89472. /**
  89473. * Serializes the actions and its related information.
  89474. * @param parent defines the object to serialize in
  89475. * @returns the serialized object
  89476. */
  89477. serialize(parent: any): any;
  89478. }
  89479. /**
  89480. * This defines an action responsible to set a property of the target
  89481. * to a desired value once triggered.
  89482. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  89483. */
  89484. export class SetValueAction extends Action {
  89485. /**
  89486. * The path of the property to set in the target.
  89487. */
  89488. propertyPath: string;
  89489. /**
  89490. * The value to set in the property
  89491. */
  89492. value: any;
  89493. private _target;
  89494. private _effectiveTarget;
  89495. private _property;
  89496. /**
  89497. * Instantiate the action
  89498. * @param triggerOptions defines the trigger options
  89499. * @param target defines the object containing the property
  89500. * @param propertyPath defines the path of the property to set in the target
  89501. * @param value defines the value to set in the property
  89502. * @param condition defines the trigger related conditions
  89503. */
  89504. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, condition?: Condition);
  89505. /** @hidden */
  89506. _prepare(): void;
  89507. /**
  89508. * Execute the action and set the targetted property to the desired value.
  89509. */
  89510. execute(): void;
  89511. /**
  89512. * Serializes the actions and its related information.
  89513. * @param parent defines the object to serialize in
  89514. * @returns the serialized object
  89515. */
  89516. serialize(parent: any): any;
  89517. }
  89518. /**
  89519. * This defines an action responsible to increment the target value
  89520. * to a desired value once triggered.
  89521. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  89522. */
  89523. export class IncrementValueAction extends Action {
  89524. /**
  89525. * The path of the property to increment in the target.
  89526. */
  89527. propertyPath: string;
  89528. /**
  89529. * The value we should increment the property by.
  89530. */
  89531. value: any;
  89532. private _target;
  89533. private _effectiveTarget;
  89534. private _property;
  89535. /**
  89536. * Instantiate the action
  89537. * @param triggerOptions defines the trigger options
  89538. * @param target defines the object containing the property
  89539. * @param propertyPath defines the path of the property to increment in the target
  89540. * @param value defines the value value we should increment the property by
  89541. * @param condition defines the trigger related conditions
  89542. */
  89543. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, condition?: Condition);
  89544. /** @hidden */
  89545. _prepare(): void;
  89546. /**
  89547. * Execute the action and increment the target of the value amount.
  89548. */
  89549. execute(): void;
  89550. /**
  89551. * Serializes the actions and its related information.
  89552. * @param parent defines the object to serialize in
  89553. * @returns the serialized object
  89554. */
  89555. serialize(parent: any): any;
  89556. }
  89557. /**
  89558. * This defines an action responsible to start an animation once triggered.
  89559. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  89560. */
  89561. export class PlayAnimationAction extends Action {
  89562. /**
  89563. * Where the animation should start (animation frame)
  89564. */
  89565. from: number;
  89566. /**
  89567. * Where the animation should stop (animation frame)
  89568. */
  89569. to: number;
  89570. /**
  89571. * Define if the animation should loop or stop after the first play.
  89572. */
  89573. loop?: boolean;
  89574. private _target;
  89575. /**
  89576. * Instantiate the action
  89577. * @param triggerOptions defines the trigger options
  89578. * @param target defines the target animation or animation name
  89579. * @param from defines from where the animation should start (animation frame)
  89580. * @param end defines where the animation should stop (animation frame)
  89581. * @param loop defines if the animation should loop or stop after the first play
  89582. * @param condition defines the trigger related conditions
  89583. */
  89584. constructor(triggerOptions: any, target: any, from: number, to: number, loop?: boolean, condition?: Condition);
  89585. /** @hidden */
  89586. _prepare(): void;
  89587. /**
  89588. * Execute the action and play the animation.
  89589. */
  89590. execute(): void;
  89591. /**
  89592. * Serializes the actions and its related information.
  89593. * @param parent defines the object to serialize in
  89594. * @returns the serialized object
  89595. */
  89596. serialize(parent: any): any;
  89597. }
  89598. /**
  89599. * This defines an action responsible to stop an animation once triggered.
  89600. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  89601. */
  89602. export class StopAnimationAction extends Action {
  89603. private _target;
  89604. /**
  89605. * Instantiate the action
  89606. * @param triggerOptions defines the trigger options
  89607. * @param target defines the target animation or animation name
  89608. * @param condition defines the trigger related conditions
  89609. */
  89610. constructor(triggerOptions: any, target: any, condition?: Condition);
  89611. /** @hidden */
  89612. _prepare(): void;
  89613. /**
  89614. * Execute the action and stop the animation.
  89615. */
  89616. execute(): void;
  89617. /**
  89618. * Serializes the actions and its related information.
  89619. * @param parent defines the object to serialize in
  89620. * @returns the serialized object
  89621. */
  89622. serialize(parent: any): any;
  89623. }
  89624. /**
  89625. * This defines an action responsible that does nothing once triggered.
  89626. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  89627. */
  89628. export class DoNothingAction extends Action {
  89629. /**
  89630. * Instantiate the action
  89631. * @param triggerOptions defines the trigger options
  89632. * @param condition defines the trigger related conditions
  89633. */
  89634. constructor(triggerOptions?: any, condition?: Condition);
  89635. /**
  89636. * Execute the action and do nothing.
  89637. */
  89638. execute(): void;
  89639. /**
  89640. * Serializes the actions and its related information.
  89641. * @param parent defines the object to serialize in
  89642. * @returns the serialized object
  89643. */
  89644. serialize(parent: any): any;
  89645. }
  89646. /**
  89647. * This defines an action responsible to trigger several actions once triggered.
  89648. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  89649. */
  89650. export class CombineAction extends Action {
  89651. /**
  89652. * The list of aggregated animations to run.
  89653. */
  89654. children: Action[];
  89655. /**
  89656. * Instantiate the action
  89657. * @param triggerOptions defines the trigger options
  89658. * @param children defines the list of aggregated animations to run
  89659. * @param condition defines the trigger related conditions
  89660. */
  89661. constructor(triggerOptions: any, children: Action[], condition?: Condition);
  89662. /** @hidden */
  89663. _prepare(): void;
  89664. /**
  89665. * Execute the action and executes all the aggregated actions.
  89666. */
  89667. execute(evt: ActionEvent): void;
  89668. /**
  89669. * Serializes the actions and its related information.
  89670. * @param parent defines the object to serialize in
  89671. * @returns the serialized object
  89672. */
  89673. serialize(parent: any): any;
  89674. }
  89675. /**
  89676. * This defines an action responsible to run code (external event) once triggered.
  89677. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  89678. */
  89679. export class ExecuteCodeAction extends Action {
  89680. /**
  89681. * The callback function to run.
  89682. */
  89683. func: (evt: ActionEvent) => void;
  89684. /**
  89685. * Instantiate the action
  89686. * @param triggerOptions defines the trigger options
  89687. * @param func defines the callback function to run
  89688. * @param condition defines the trigger related conditions
  89689. */
  89690. constructor(triggerOptions: any, func: (evt: ActionEvent) => void, condition?: Condition);
  89691. /**
  89692. * Execute the action and run the attached code.
  89693. */
  89694. execute(evt: ActionEvent): void;
  89695. }
  89696. /**
  89697. * This defines an action responsible to set the parent property of the target once triggered.
  89698. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  89699. */
  89700. export class SetParentAction extends Action {
  89701. private _parent;
  89702. private _target;
  89703. /**
  89704. * Instantiate the action
  89705. * @param triggerOptions defines the trigger options
  89706. * @param target defines the target containing the parent property
  89707. * @param parent defines from where the animation should start (animation frame)
  89708. * @param condition defines the trigger related conditions
  89709. */
  89710. constructor(triggerOptions: any, target: any, parent: any, condition?: Condition);
  89711. /** @hidden */
  89712. _prepare(): void;
  89713. /**
  89714. * Execute the action and set the parent property.
  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. declare module BABYLON {
  89726. /**
  89727. * Action Manager manages all events to be triggered on a given mesh or the global scene.
  89728. * A single scene can have many Action Managers to handle predefined actions on specific meshes.
  89729. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  89730. */
  89731. export class ActionManager extends AbstractActionManager {
  89732. /**
  89733. * Nothing
  89734. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  89735. */
  89736. static readonly NothingTrigger: number;
  89737. /**
  89738. * On pick
  89739. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  89740. */
  89741. static readonly OnPickTrigger: number;
  89742. /**
  89743. * On left pick
  89744. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  89745. */
  89746. static readonly OnLeftPickTrigger: number;
  89747. /**
  89748. * On right pick
  89749. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  89750. */
  89751. static readonly OnRightPickTrigger: number;
  89752. /**
  89753. * On center pick
  89754. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  89755. */
  89756. static readonly OnCenterPickTrigger: number;
  89757. /**
  89758. * On pick down
  89759. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  89760. */
  89761. static readonly OnPickDownTrigger: number;
  89762. /**
  89763. * On double pick
  89764. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  89765. */
  89766. static readonly OnDoublePickTrigger: number;
  89767. /**
  89768. * On pick up
  89769. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  89770. */
  89771. static readonly OnPickUpTrigger: number;
  89772. /**
  89773. * On pick out.
  89774. * This trigger will only be raised if you also declared a OnPickDown
  89775. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  89776. */
  89777. static readonly OnPickOutTrigger: number;
  89778. /**
  89779. * On long press
  89780. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  89781. */
  89782. static readonly OnLongPressTrigger: number;
  89783. /**
  89784. * On pointer over
  89785. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  89786. */
  89787. static readonly OnPointerOverTrigger: number;
  89788. /**
  89789. * On pointer out
  89790. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  89791. */
  89792. static readonly OnPointerOutTrigger: number;
  89793. /**
  89794. * On every frame
  89795. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  89796. */
  89797. static readonly OnEveryFrameTrigger: number;
  89798. /**
  89799. * On intersection enter
  89800. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  89801. */
  89802. static readonly OnIntersectionEnterTrigger: number;
  89803. /**
  89804. * On intersection exit
  89805. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  89806. */
  89807. static readonly OnIntersectionExitTrigger: number;
  89808. /**
  89809. * On key down
  89810. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  89811. */
  89812. static readonly OnKeyDownTrigger: number;
  89813. /**
  89814. * On key up
  89815. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  89816. */
  89817. static readonly OnKeyUpTrigger: number;
  89818. private _scene;
  89819. /**
  89820. * Creates a new action manager
  89821. * @param scene defines the hosting scene
  89822. */
  89823. constructor(scene: Scene);
  89824. /**
  89825. * Releases all associated resources
  89826. */
  89827. dispose(): void;
  89828. /**
  89829. * Gets hosting scene
  89830. * @returns the hosting scene
  89831. */
  89832. getScene(): Scene;
  89833. /**
  89834. * Does this action manager handles actions of any of the given triggers
  89835. * @param triggers defines the triggers to be tested
  89836. * @return a boolean indicating whether one (or more) of the triggers is handled
  89837. */
  89838. hasSpecificTriggers(triggers: number[]): boolean;
  89839. /**
  89840. * Does this action manager handles actions of any of the given triggers. This function takes two arguments for
  89841. * speed.
  89842. * @param triggerA defines the trigger to be tested
  89843. * @param triggerB defines the trigger to be tested
  89844. * @return a boolean indicating whether one (or more) of the triggers is handled
  89845. */
  89846. hasSpecificTriggers2(triggerA: number, triggerB: number): boolean;
  89847. /**
  89848. * Does this action manager handles actions of a given trigger
  89849. * @param trigger defines the trigger to be tested
  89850. * @param parameterPredicate defines an optional predicate to filter triggers by parameter
  89851. * @return whether the trigger is handled
  89852. */
  89853. hasSpecificTrigger(trigger: number, parameterPredicate?: (parameter: any) => boolean): boolean;
  89854. /**
  89855. * Does this action manager has pointer triggers
  89856. */
  89857. get hasPointerTriggers(): boolean;
  89858. /**
  89859. * Does this action manager has pick triggers
  89860. */
  89861. get hasPickTriggers(): boolean;
  89862. /**
  89863. * Registers an action to this action manager
  89864. * @param action defines the action to be registered
  89865. * @return the action amended (prepared) after registration
  89866. */
  89867. registerAction(action: IAction): Nullable<IAction>;
  89868. /**
  89869. * Unregisters an action to this action manager
  89870. * @param action defines the action to be unregistered
  89871. * @return a boolean indicating whether the action has been unregistered
  89872. */
  89873. unregisterAction(action: IAction): Boolean;
  89874. /**
  89875. * Process a specific trigger
  89876. * @param trigger defines the trigger to process
  89877. * @param evt defines the event details to be processed
  89878. */
  89879. processTrigger(trigger: number, evt?: IActionEvent): void;
  89880. /** @hidden */
  89881. _getEffectiveTarget(target: any, propertyPath: string): any;
  89882. /** @hidden */
  89883. _getProperty(propertyPath: string): string;
  89884. /**
  89885. * Serialize this manager to a JSON object
  89886. * @param name defines the property name to store this manager
  89887. * @returns a JSON representation of this manager
  89888. */
  89889. serialize(name: string): any;
  89890. /**
  89891. * Creates a new ActionManager from a JSON data
  89892. * @param parsedActions defines the JSON data to read from
  89893. * @param object defines the hosting mesh
  89894. * @param scene defines the hosting scene
  89895. */
  89896. static Parse(parsedActions: any, object: Nullable<AbstractMesh>, scene: Scene): void;
  89897. /**
  89898. * Get a trigger name by index
  89899. * @param trigger defines the trigger index
  89900. * @returns a trigger name
  89901. */
  89902. static GetTriggerName(trigger: number): string;
  89903. }
  89904. }
  89905. declare module BABYLON {
  89906. /**
  89907. * Class used to represent a sprite
  89908. * @see https://doc.babylonjs.com/babylon101/sprites
  89909. */
  89910. export class Sprite implements IAnimatable {
  89911. /** defines the name */
  89912. name: string;
  89913. /** Gets or sets the current world position */
  89914. position: Vector3;
  89915. /** Gets or sets the main color */
  89916. color: Color4;
  89917. /** Gets or sets the width */
  89918. width: number;
  89919. /** Gets or sets the height */
  89920. height: number;
  89921. /** Gets or sets rotation angle */
  89922. angle: number;
  89923. /** Gets or sets the cell index in the sprite sheet */
  89924. cellIndex: number;
  89925. /** Gets or sets the cell reference in the sprite sheet, uses sprite's filename when added to sprite sheet */
  89926. cellRef: string;
  89927. /** Gets or sets a boolean indicating if UV coordinates should be inverted in U axis */
  89928. invertU: boolean;
  89929. /** Gets or sets a boolean indicating if UV coordinates should be inverted in B axis */
  89930. invertV: boolean;
  89931. /** Gets or sets a boolean indicating that this sprite should be disposed after animation ends */
  89932. disposeWhenFinishedAnimating: boolean;
  89933. /** Gets the list of attached animations */
  89934. animations: Nullable<Array<Animation>>;
  89935. /** Gets or sets a boolean indicating if the sprite can be picked */
  89936. isPickable: boolean;
  89937. /** Gets or sets a boolean indicating that sprite texture alpha will be used for precise picking (false by default) */
  89938. useAlphaForPicking: boolean;
  89939. /** @hidden */
  89940. _xOffset: number;
  89941. /** @hidden */
  89942. _yOffset: number;
  89943. /** @hidden */
  89944. _xSize: number;
  89945. /** @hidden */
  89946. _ySize: number;
  89947. /**
  89948. * Gets or sets the associated action manager
  89949. */
  89950. actionManager: Nullable<ActionManager>;
  89951. /**
  89952. * An event triggered when the control has been disposed
  89953. */
  89954. onDisposeObservable: Observable<Sprite>;
  89955. private _animationStarted;
  89956. private _loopAnimation;
  89957. private _fromIndex;
  89958. private _toIndex;
  89959. private _delay;
  89960. private _direction;
  89961. private _manager;
  89962. private _time;
  89963. private _onAnimationEnd;
  89964. /**
  89965. * Gets or sets a boolean indicating if the sprite is visible (renderable). Default is true
  89966. */
  89967. isVisible: boolean;
  89968. /**
  89969. * Gets or sets the sprite size
  89970. */
  89971. get size(): number;
  89972. set size(value: number);
  89973. /**
  89974. * Returns a boolean indicating if the animation is started
  89975. */
  89976. get animationStarted(): boolean;
  89977. /**
  89978. * Gets or sets the unique id of the sprite
  89979. */
  89980. uniqueId: number;
  89981. /**
  89982. * Gets the manager of this sprite
  89983. */
  89984. get manager(): ISpriteManager;
  89985. /**
  89986. * Creates a new Sprite
  89987. * @param name defines the name
  89988. * @param manager defines the manager
  89989. */
  89990. constructor(
  89991. /** defines the name */
  89992. name: string, manager: ISpriteManager);
  89993. /**
  89994. * Returns the string "Sprite"
  89995. * @returns "Sprite"
  89996. */
  89997. getClassName(): string;
  89998. /** Gets or sets the initial key for the animation (setting it will restart the animation) */
  89999. get fromIndex(): number;
  90000. set fromIndex(value: number);
  90001. /** Gets or sets the end key for the animation (setting it will restart the animation) */
  90002. get toIndex(): number;
  90003. set toIndex(value: number);
  90004. /** Gets or sets a boolean indicating if the animation is looping (setting it will restart the animation) */
  90005. get loopAnimation(): boolean;
  90006. set loopAnimation(value: boolean);
  90007. /** Gets or sets the delay between cell changes (setting it will restart the animation) */
  90008. get delay(): number;
  90009. set delay(value: number);
  90010. /**
  90011. * Starts an animation
  90012. * @param from defines the initial key
  90013. * @param to defines the end key
  90014. * @param loop defines if the animation must loop
  90015. * @param delay defines the start delay (in ms)
  90016. * @param onAnimationEnd defines a callback to call when animation ends
  90017. */
  90018. playAnimation(from: number, to: number, loop: boolean, delay: number, onAnimationEnd?: Nullable<() => void>): void;
  90019. /** Stops current animation (if any) */
  90020. stopAnimation(): void;
  90021. /** @hidden */
  90022. _animate(deltaTime: number): void;
  90023. /** Release associated resources */
  90024. dispose(): void;
  90025. /**
  90026. * Serializes the sprite to a JSON object
  90027. * @returns the JSON object
  90028. */
  90029. serialize(): any;
  90030. /**
  90031. * Parses a JSON object to create a new sprite
  90032. * @param parsedSprite The JSON object to parse
  90033. * @param manager defines the hosting manager
  90034. * @returns the new sprite
  90035. */
  90036. static Parse(parsedSprite: any, manager: SpriteManager): Sprite;
  90037. }
  90038. }
  90039. declare module BABYLON {
  90040. /**
  90041. * Information about the result of picking within a scene
  90042. * @see https://doc.babylonjs.com/babylon101/picking_collisions
  90043. */
  90044. export class PickingInfo {
  90045. /** @hidden */
  90046. _pickingUnavailable: boolean;
  90047. /**
  90048. * If the pick collided with an object
  90049. */
  90050. hit: boolean;
  90051. /**
  90052. * Distance away where the pick collided
  90053. */
  90054. distance: number;
  90055. /**
  90056. * The location of pick collision
  90057. */
  90058. pickedPoint: Nullable<Vector3>;
  90059. /**
  90060. * The mesh corresponding the the pick collision
  90061. */
  90062. pickedMesh: Nullable<AbstractMesh>;
  90063. /** (See getTextureCoordinates) The barycentric U coordinate that is used when calculating the texture coordinates of the collision.*/
  90064. bu: number;
  90065. /** (See getTextureCoordinates) The barycentric V coordinate that is used when calculating the texture coordinates of the collision.*/
  90066. bv: number;
  90067. /** The index of the face on the mesh that was picked, or the index of the Line if the picked Mesh is a LinesMesh */
  90068. faceId: number;
  90069. /** The index of the face on the subMesh that was picked, or the index of the Line if the picked Mesh is a LinesMesh */
  90070. subMeshFaceId: number;
  90071. /** Id of the the submesh that was picked */
  90072. subMeshId: number;
  90073. /** If a sprite was picked, this will be the sprite the pick collided with */
  90074. pickedSprite: Nullable<Sprite>;
  90075. /** If we are pikcing a mesh with thin instance, this will give you the picked thin instance */
  90076. thinInstanceIndex: number;
  90077. /**
  90078. * If a mesh was used to do the picking (eg. 6dof controller) this will be populated.
  90079. */
  90080. originMesh: Nullable<AbstractMesh>;
  90081. /**
  90082. * The ray that was used to perform the picking.
  90083. */
  90084. ray: Nullable<Ray>;
  90085. /**
  90086. * Gets the normal correspodning to the face the pick collided with
  90087. * @param useWorldCoordinates If the resulting normal should be relative to the world (default: false)
  90088. * @param useVerticesNormals If the vertices normals should be used to calculate the normal instead of the normal map
  90089. * @returns The normal correspodning to the face the pick collided with
  90090. */
  90091. getNormal(useWorldCoordinates?: boolean, useVerticesNormals?: boolean): Nullable<Vector3>;
  90092. /**
  90093. * Gets the texture coordinates of where the pick occured
  90094. * @returns the vector containing the coordnates of the texture
  90095. */
  90096. getTextureCoordinates(): Nullable<Vector2>;
  90097. }
  90098. }
  90099. declare module BABYLON {
  90100. /**
  90101. * Class representing a ray with position and direction
  90102. */
  90103. export class Ray {
  90104. /** origin point */
  90105. origin: Vector3;
  90106. /** direction */
  90107. direction: Vector3;
  90108. /** length of the ray */
  90109. length: number;
  90110. private static readonly _TmpVector3;
  90111. private _tmpRay;
  90112. /**
  90113. * Creates a new ray
  90114. * @param origin origin point
  90115. * @param direction direction
  90116. * @param length length of the ray
  90117. */
  90118. constructor(
  90119. /** origin point */
  90120. origin: Vector3,
  90121. /** direction */
  90122. direction: Vector3,
  90123. /** length of the ray */
  90124. length?: number);
  90125. /**
  90126. * Checks if the ray intersects a box
  90127. * This does not account for the ray lenght by design to improve perfs.
  90128. * @param minimum bound of the box
  90129. * @param maximum bound of the box
  90130. * @param intersectionTreshold extra extend to be added to the box in all direction
  90131. * @returns if the box was hit
  90132. */
  90133. intersectsBoxMinMax(minimum: DeepImmutable<Vector3>, maximum: DeepImmutable<Vector3>, intersectionTreshold?: number): boolean;
  90134. /**
  90135. * Checks if the ray intersects a box
  90136. * This does not account for the ray lenght by design to improve perfs.
  90137. * @param box the bounding box to check
  90138. * @param intersectionTreshold extra extend to be added to the BoundingBox in all direction
  90139. * @returns if the box was hit
  90140. */
  90141. intersectsBox(box: DeepImmutable<BoundingBox>, intersectionTreshold?: number): boolean;
  90142. /**
  90143. * If the ray hits a sphere
  90144. * @param sphere the bounding sphere to check
  90145. * @param intersectionTreshold extra extend to be added to the BoundingSphere in all direction
  90146. * @returns true if it hits the sphere
  90147. */
  90148. intersectsSphere(sphere: DeepImmutable<BoundingSphere>, intersectionTreshold?: number): boolean;
  90149. /**
  90150. * If the ray hits a triange
  90151. * @param vertex0 triangle vertex
  90152. * @param vertex1 triangle vertex
  90153. * @param vertex2 triangle vertex
  90154. * @returns intersection information if hit
  90155. */
  90156. intersectsTriangle(vertex0: DeepImmutable<Vector3>, vertex1: DeepImmutable<Vector3>, vertex2: DeepImmutable<Vector3>): Nullable<IntersectionInfo>;
  90157. /**
  90158. * Checks if ray intersects a plane
  90159. * @param plane the plane to check
  90160. * @returns the distance away it was hit
  90161. */
  90162. intersectsPlane(plane: DeepImmutable<Plane>): Nullable<number>;
  90163. /**
  90164. * Calculate the intercept of a ray on a given axis
  90165. * @param axis to check 'x' | 'y' | 'z'
  90166. * @param offset from axis interception (i.e. an offset of 1y is intercepted above ground)
  90167. * @returns a vector containing the coordinates where 'axis' is equal to zero (else offset), or null if there is no intercept.
  90168. */
  90169. intersectsAxis(axis: string, offset?: number): Nullable<Vector3>;
  90170. /**
  90171. * Checks if ray intersects a mesh
  90172. * @param mesh the mesh to check
  90173. * @param fastCheck defines if the first intersection will be used (and not the closest)
  90174. * @returns picking info of the intersecton
  90175. */
  90176. intersectsMesh(mesh: DeepImmutable<AbstractMesh>, fastCheck?: boolean): PickingInfo;
  90177. /**
  90178. * Checks if ray intersects a mesh
  90179. * @param meshes the meshes to check
  90180. * @param fastCheck defines if the first intersection will be used (and not the closest)
  90181. * @param results array to store result in
  90182. * @returns Array of picking infos
  90183. */
  90184. intersectsMeshes(meshes: Array<DeepImmutable<AbstractMesh>>, fastCheck?: boolean, results?: Array<PickingInfo>): Array<PickingInfo>;
  90185. private _comparePickingInfo;
  90186. private static smallnum;
  90187. private static rayl;
  90188. /**
  90189. * Intersection test between the ray and a given segment whithin a given tolerance (threshold)
  90190. * @param sega the first point of the segment to test the intersection against
  90191. * @param segb the second point of the segment to test the intersection against
  90192. * @param threshold the tolerance margin, if the ray doesn't intersect the segment but is close to the given threshold, the intersection is successful
  90193. * @return the distance from the ray origin to the intersection point if there's intersection, or -1 if there's no intersection
  90194. */
  90195. intersectionSegment(sega: DeepImmutable<Vector3>, segb: DeepImmutable<Vector3>, threshold: number): number;
  90196. /**
  90197. * Update the ray from viewport position
  90198. * @param x position
  90199. * @param y y position
  90200. * @param viewportWidth viewport width
  90201. * @param viewportHeight viewport height
  90202. * @param world world matrix
  90203. * @param view view matrix
  90204. * @param projection projection matrix
  90205. * @returns this ray updated
  90206. */
  90207. update(x: number, y: number, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Ray;
  90208. /**
  90209. * Creates a ray with origin and direction of 0,0,0
  90210. * @returns the new ray
  90211. */
  90212. static Zero(): Ray;
  90213. /**
  90214. * Creates a new ray from screen space and viewport
  90215. * @param x position
  90216. * @param y y position
  90217. * @param viewportWidth viewport width
  90218. * @param viewportHeight viewport height
  90219. * @param world world matrix
  90220. * @param view view matrix
  90221. * @param projection projection matrix
  90222. * @returns new ray
  90223. */
  90224. static CreateNew(x: number, y: number, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Ray;
  90225. /**
  90226. * 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
  90227. * transformed to the given world matrix.
  90228. * @param origin The origin point
  90229. * @param end The end point
  90230. * @param world a matrix to transform the ray to. Default is the identity matrix.
  90231. * @returns the new ray
  90232. */
  90233. static CreateNewFromTo(origin: Vector3, end: Vector3, world?: DeepImmutable<Matrix>): Ray;
  90234. /**
  90235. * Transforms a ray by a matrix
  90236. * @param ray ray to transform
  90237. * @param matrix matrix to apply
  90238. * @returns the resulting new ray
  90239. */
  90240. static Transform(ray: DeepImmutable<Ray>, matrix: DeepImmutable<Matrix>): Ray;
  90241. /**
  90242. * Transforms a ray by a matrix
  90243. * @param ray ray to transform
  90244. * @param matrix matrix to apply
  90245. * @param result ray to store result in
  90246. */
  90247. static TransformToRef(ray: DeepImmutable<Ray>, matrix: DeepImmutable<Matrix>, result: Ray): void;
  90248. /**
  90249. * Unproject a ray from screen space to object space
  90250. * @param sourceX defines the screen space x coordinate to use
  90251. * @param sourceY defines the screen space y coordinate to use
  90252. * @param viewportWidth defines the current width of the viewport
  90253. * @param viewportHeight defines the current height of the viewport
  90254. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  90255. * @param view defines the view matrix to use
  90256. * @param projection defines the projection matrix to use
  90257. */
  90258. unprojectRayToRef(sourceX: float, sourceY: float, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): void;
  90259. }
  90260. /**
  90261. * Type used to define predicate used to select faces when a mesh intersection is detected
  90262. */
  90263. export type TrianglePickingPredicate = (p0: Vector3, p1: Vector3, p2: Vector3, ray: Ray) => boolean;
  90264. interface Scene {
  90265. /** @hidden */
  90266. _tempPickingRay: Nullable<Ray>;
  90267. /** @hidden */
  90268. _cachedRayForTransform: Ray;
  90269. /** @hidden */
  90270. _pickWithRayInverseMatrix: Matrix;
  90271. /** @hidden */
  90272. _internalPick(rayFunction: (world: Matrix) => Ray, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, onlyBoundingInfo?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  90273. /** @hidden */
  90274. _internalMultiPick(rayFunction: (world: Matrix) => Ray, predicate?: (mesh: AbstractMesh) => boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  90275. /** @hidden */
  90276. _internalPickForMesh(pickingInfo: Nullable<PickingInfo>, rayFunction: (world: Matrix) => Ray, mesh: AbstractMesh, world: Matrix, fastCheck?: boolean, onlyBoundingInfo?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  90277. }
  90278. }
  90279. declare module BABYLON {
  90280. /**
  90281. * Groups all the scene component constants in one place to ease maintenance.
  90282. * @hidden
  90283. */
  90284. export class SceneComponentConstants {
  90285. static readonly NAME_EFFECTLAYER: string;
  90286. static readonly NAME_LAYER: string;
  90287. static readonly NAME_LENSFLARESYSTEM: string;
  90288. static readonly NAME_BOUNDINGBOXRENDERER: string;
  90289. static readonly NAME_PARTICLESYSTEM: string;
  90290. static readonly NAME_GAMEPAD: string;
  90291. static readonly NAME_SIMPLIFICATIONQUEUE: string;
  90292. static readonly NAME_GEOMETRYBUFFERRENDERER: string;
  90293. static readonly NAME_PREPASSRENDERER: string;
  90294. static readonly NAME_DEPTHRENDERER: string;
  90295. static readonly NAME_POSTPROCESSRENDERPIPELINEMANAGER: string;
  90296. static readonly NAME_SPRITE: string;
  90297. static readonly NAME_OUTLINERENDERER: string;
  90298. static readonly NAME_PROCEDURALTEXTURE: string;
  90299. static readonly NAME_SHADOWGENERATOR: string;
  90300. static readonly NAME_OCTREE: string;
  90301. static readonly NAME_PHYSICSENGINE: string;
  90302. static readonly NAME_AUDIO: string;
  90303. static readonly STEP_ISREADYFORMESH_EFFECTLAYER: number;
  90304. static readonly STEP_BEFOREEVALUATEACTIVEMESH_BOUNDINGBOXRENDERER: number;
  90305. static readonly STEP_EVALUATESUBMESH_BOUNDINGBOXRENDERER: number;
  90306. static readonly STEP_ACTIVEMESH_BOUNDINGBOXRENDERER: number;
  90307. static readonly STEP_CAMERADRAWRENDERTARGET_EFFECTLAYER: number;
  90308. static readonly STEP_BEFORECAMERADRAW_EFFECTLAYER: number;
  90309. static readonly STEP_BEFORECAMERADRAW_LAYER: number;
  90310. static readonly STEP_BEFORECAMERADRAW_PREPASS: number;
  90311. static readonly STEP_BEFORERENDERTARGETDRAW_LAYER: number;
  90312. static readonly STEP_BEFORERENDERINGMESH_OUTLINE: number;
  90313. static readonly STEP_AFTERRENDERINGMESH_OUTLINE: number;
  90314. static readonly STEP_AFTERRENDERINGGROUPDRAW_EFFECTLAYER_DRAW: number;
  90315. static readonly STEP_AFTERRENDERINGGROUPDRAW_BOUNDINGBOXRENDERER: number;
  90316. static readonly STEP_BEFORECAMERAUPDATE_SIMPLIFICATIONQUEUE: number;
  90317. static readonly STEP_BEFORECAMERAUPDATE_GAMEPAD: number;
  90318. static readonly STEP_BEFORECLEAR_PROCEDURALTEXTURE: number;
  90319. static readonly STEP_AFTERRENDERTARGETDRAW_LAYER: number;
  90320. static readonly STEP_AFTERCAMERADRAW_EFFECTLAYER: number;
  90321. static readonly STEP_AFTERCAMERADRAW_LENSFLARESYSTEM: number;
  90322. static readonly STEP_AFTERCAMERADRAW_EFFECTLAYER_DRAW: number;
  90323. static readonly STEP_AFTERCAMERADRAW_LAYER: number;
  90324. static readonly STEP_AFTERCAMERADRAW_PREPASS: number;
  90325. static readonly STEP_AFTERRENDER_AUDIO: number;
  90326. static readonly STEP_GATHERRENDERTARGETS_DEPTHRENDERER: number;
  90327. static readonly STEP_GATHERRENDERTARGETS_GEOMETRYBUFFERRENDERER: number;
  90328. static readonly STEP_GATHERRENDERTARGETS_SHADOWGENERATOR: number;
  90329. static readonly STEP_GATHERRENDERTARGETS_POSTPROCESSRENDERPIPELINEMANAGER: number;
  90330. static readonly STEP_GATHERACTIVECAMERARENDERTARGETS_DEPTHRENDERER: number;
  90331. static readonly STEP_BEFORECLEARSTAGE_PREPASS: number;
  90332. static readonly STEP_POINTERMOVE_SPRITE: number;
  90333. static readonly STEP_POINTERDOWN_SPRITE: number;
  90334. static readonly STEP_POINTERUP_SPRITE: number;
  90335. }
  90336. /**
  90337. * This represents a scene component.
  90338. *
  90339. * This is used to decouple the dependency the scene is having on the different workloads like
  90340. * layers, post processes...
  90341. */
  90342. export interface ISceneComponent {
  90343. /**
  90344. * The name of the component. Each component must have a unique name.
  90345. */
  90346. name: string;
  90347. /**
  90348. * The scene the component belongs to.
  90349. */
  90350. scene: Scene;
  90351. /**
  90352. * Register the component to one instance of a scene.
  90353. */
  90354. register(): void;
  90355. /**
  90356. * Rebuilds the elements related to this component in case of
  90357. * context lost for instance.
  90358. */
  90359. rebuild(): void;
  90360. /**
  90361. * Disposes the component and the associated ressources.
  90362. */
  90363. dispose(): void;
  90364. }
  90365. /**
  90366. * This represents a SERIALIZABLE scene component.
  90367. *
  90368. * This extends Scene Component to add Serialization methods on top.
  90369. */
  90370. export interface ISceneSerializableComponent extends ISceneComponent {
  90371. /**
  90372. * Adds all the elements from the container to the scene
  90373. * @param container the container holding the elements
  90374. */
  90375. addFromContainer(container: AbstractScene): void;
  90376. /**
  90377. * Removes all the elements in the container from the scene
  90378. * @param container contains the elements to remove
  90379. * @param dispose if the removed element should be disposed (default: false)
  90380. */
  90381. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  90382. /**
  90383. * Serializes the component data to the specified json object
  90384. * @param serializationObject The object to serialize to
  90385. */
  90386. serialize(serializationObject: any): void;
  90387. }
  90388. /**
  90389. * Strong typing of a Mesh related stage step action
  90390. */
  90391. export type MeshStageAction = (mesh: AbstractMesh, hardwareInstancedRendering: boolean) => boolean;
  90392. /**
  90393. * Strong typing of a Evaluate Sub Mesh related stage step action
  90394. */
  90395. export type EvaluateSubMeshStageAction = (mesh: AbstractMesh, subMesh: SubMesh) => void;
  90396. /**
  90397. * Strong typing of a Active Mesh related stage step action
  90398. */
  90399. export type ActiveMeshStageAction = (sourceMesh: AbstractMesh, mesh: AbstractMesh) => void;
  90400. /**
  90401. * Strong typing of a Camera related stage step action
  90402. */
  90403. export type CameraStageAction = (camera: Camera) => void;
  90404. /**
  90405. * Strong typing of a Camera Frame buffer related stage step action
  90406. */
  90407. export type CameraStageFrameBufferAction = (camera: Camera) => boolean;
  90408. /**
  90409. * Strong typing of a Render Target related stage step action
  90410. */
  90411. export type RenderTargetStageAction = (renderTarget: RenderTargetTexture) => void;
  90412. /**
  90413. * Strong typing of a RenderingGroup related stage step action
  90414. */
  90415. export type RenderingGroupStageAction = (renderingGroupId: number) => void;
  90416. /**
  90417. * Strong typing of a Mesh Render related stage step action
  90418. */
  90419. export type RenderingMeshStageAction = (mesh: Mesh, subMesh: SubMesh, batch: _InstancesBatch) => void;
  90420. /**
  90421. * Strong typing of a simple stage step action
  90422. */
  90423. export type SimpleStageAction = () => void;
  90424. /**
  90425. * Strong typing of a render target action.
  90426. */
  90427. export type RenderTargetsStageAction = (renderTargets: SmartArrayNoDuplicate<RenderTargetTexture>) => void;
  90428. /**
  90429. * Strong typing of a pointer move action.
  90430. */
  90431. export type PointerMoveStageAction = (unTranslatedPointerX: number, unTranslatedPointerY: number, pickResult: Nullable<PickingInfo>, isMeshPicked: boolean, element: HTMLElement) => Nullable<PickingInfo>;
  90432. /**
  90433. * Strong typing of a pointer up/down action.
  90434. */
  90435. export type PointerUpDownStageAction = (unTranslatedPointerX: number, unTranslatedPointerY: number, pickResult: Nullable<PickingInfo>, evt: PointerEvent) => Nullable<PickingInfo>;
  90436. /**
  90437. * Representation of a stage in the scene (Basically a list of ordered steps)
  90438. * @hidden
  90439. */
  90440. export class Stage<T extends Function> extends Array<{
  90441. index: number;
  90442. component: ISceneComponent;
  90443. action: T;
  90444. }> {
  90445. /**
  90446. * Hide ctor from the rest of the world.
  90447. * @param items The items to add.
  90448. */
  90449. private constructor();
  90450. /**
  90451. * Creates a new Stage.
  90452. * @returns A new instance of a Stage
  90453. */
  90454. static Create<T extends Function>(): Stage<T>;
  90455. /**
  90456. * Registers a step in an ordered way in the targeted stage.
  90457. * @param index Defines the position to register the step in
  90458. * @param component Defines the component attached to the step
  90459. * @param action Defines the action to launch during the step
  90460. */
  90461. registerStep(index: number, component: ISceneComponent, action: T): void;
  90462. /**
  90463. * Clears all the steps from the stage.
  90464. */
  90465. clear(): void;
  90466. }
  90467. }
  90468. declare module BABYLON {
  90469. interface Scene {
  90470. /** @hidden */
  90471. _pointerOverSprite: Nullable<Sprite>;
  90472. /** @hidden */
  90473. _pickedDownSprite: Nullable<Sprite>;
  90474. /** @hidden */
  90475. _tempSpritePickingRay: Nullable<Ray>;
  90476. /**
  90477. * All of the sprite managers added to this scene
  90478. * @see https://doc.babylonjs.com/babylon101/sprites
  90479. */
  90480. spriteManagers: Array<ISpriteManager>;
  90481. /**
  90482. * An event triggered when sprites rendering is about to start
  90483. * Note: This event can be trigger more than once per frame (because sprites can be rendered by render target textures as well)
  90484. */
  90485. onBeforeSpritesRenderingObservable: Observable<Scene>;
  90486. /**
  90487. * An event triggered when sprites rendering is done
  90488. * Note: This event can be trigger more than once per frame (because sprites can be rendered by render target textures as well)
  90489. */
  90490. onAfterSpritesRenderingObservable: Observable<Scene>;
  90491. /** @hidden */
  90492. _internalPickSprites(ray: Ray, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  90493. /** Launch a ray to try to pick a sprite in the scene
  90494. * @param x position on screen
  90495. * @param y position on screen
  90496. * @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
  90497. * @param fastCheck defines if the first intersection will be used (and not the closest)
  90498. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  90499. * @returns a PickingInfo
  90500. */
  90501. pickSprite(x: number, y: number, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  90502. /** Use the given ray to pick a sprite in the scene
  90503. * @param ray The ray (in world space) to use to pick meshes
  90504. * @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
  90505. * @param fastCheck defines if the first intersection will be used (and not the closest)
  90506. * @param camera camera to use. Can be set to null. In this case, the scene.activeCamera will be used
  90507. * @returns a PickingInfo
  90508. */
  90509. pickSpriteWithRay(ray: Ray, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  90510. /** @hidden */
  90511. _internalMultiPickSprites(ray: Ray, predicate?: (sprite: Sprite) => boolean, camera?: Camera): Nullable<PickingInfo[]>;
  90512. /** Launch a ray to try to pick sprites in the scene
  90513. * @param x position on screen
  90514. * @param y position on screen
  90515. * @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
  90516. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  90517. * @returns a PickingInfo array
  90518. */
  90519. multiPickSprite(x: number, y: number, predicate?: (sprite: Sprite) => boolean, camera?: Camera): Nullable<PickingInfo[]>;
  90520. /** Use the given ray to pick sprites in the scene
  90521. * @param ray The ray (in world space) to use to pick meshes
  90522. * @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
  90523. * @param camera camera to use. Can be set to null. In this case, the scene.activeCamera will be used
  90524. * @returns a PickingInfo array
  90525. */
  90526. multiPickSpriteWithRay(ray: Ray, predicate?: (sprite: Sprite) => boolean, camera?: Camera): Nullable<PickingInfo[]>;
  90527. /**
  90528. * Force the sprite under the pointer
  90529. * @param sprite defines the sprite to use
  90530. */
  90531. setPointerOverSprite(sprite: Nullable<Sprite>): void;
  90532. /**
  90533. * Gets the sprite under the pointer
  90534. * @returns a Sprite or null if no sprite is under the pointer
  90535. */
  90536. getPointerOverSprite(): Nullable<Sprite>;
  90537. }
  90538. /**
  90539. * Defines the sprite scene component responsible to manage sprites
  90540. * in a given scene.
  90541. */
  90542. export class SpriteSceneComponent implements ISceneComponent {
  90543. /**
  90544. * The component name helpfull to identify the component in the list of scene components.
  90545. */
  90546. readonly name: string;
  90547. /**
  90548. * The scene the component belongs to.
  90549. */
  90550. scene: Scene;
  90551. /** @hidden */
  90552. private _spritePredicate;
  90553. /**
  90554. * Creates a new instance of the component for the given scene
  90555. * @param scene Defines the scene to register the component in
  90556. */
  90557. constructor(scene: Scene);
  90558. /**
  90559. * Registers the component in a given scene
  90560. */
  90561. register(): void;
  90562. /**
  90563. * Rebuilds the elements related to this component in case of
  90564. * context lost for instance.
  90565. */
  90566. rebuild(): void;
  90567. /**
  90568. * Disposes the component and the associated ressources.
  90569. */
  90570. dispose(): void;
  90571. private _pickSpriteButKeepRay;
  90572. private _pointerMove;
  90573. private _pointerDown;
  90574. private _pointerUp;
  90575. }
  90576. }
  90577. declare module BABYLON {
  90578. /** @hidden */
  90579. export var fogFragmentDeclaration: {
  90580. name: string;
  90581. shader: string;
  90582. };
  90583. }
  90584. declare module BABYLON {
  90585. /** @hidden */
  90586. export var fogFragment: {
  90587. name: string;
  90588. shader: string;
  90589. };
  90590. }
  90591. declare module BABYLON {
  90592. /** @hidden */
  90593. export var spritesPixelShader: {
  90594. name: string;
  90595. shader: string;
  90596. };
  90597. }
  90598. declare module BABYLON {
  90599. /** @hidden */
  90600. export var fogVertexDeclaration: {
  90601. name: string;
  90602. shader: string;
  90603. };
  90604. }
  90605. declare module BABYLON {
  90606. /** @hidden */
  90607. export var spritesVertexShader: {
  90608. name: string;
  90609. shader: string;
  90610. };
  90611. }
  90612. declare module BABYLON {
  90613. /**
  90614. * Defines the minimum interface to fullfil in order to be a sprite manager.
  90615. */
  90616. export interface ISpriteManager extends IDisposable {
  90617. /**
  90618. * Gets manager's name
  90619. */
  90620. name: string;
  90621. /**
  90622. * Restricts the camera to viewing objects with the same layerMask.
  90623. * A camera with a layerMask of 1 will render spriteManager.layerMask & camera.layerMask!== 0
  90624. */
  90625. layerMask: number;
  90626. /**
  90627. * Gets or sets a boolean indicating if the mesh can be picked (by scene.pick for instance or through actions). Default is true
  90628. */
  90629. isPickable: boolean;
  90630. /**
  90631. * Gets the hosting scene
  90632. */
  90633. scene: Scene;
  90634. /**
  90635. * Specifies the rendering group id for this mesh (0 by default)
  90636. * @see https://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#rendering-groups
  90637. */
  90638. renderingGroupId: number;
  90639. /**
  90640. * Defines the list of sprites managed by the manager.
  90641. */
  90642. sprites: Array<Sprite>;
  90643. /**
  90644. * Gets or sets the spritesheet texture
  90645. */
  90646. texture: Texture;
  90647. /** Defines the default width of a cell in the spritesheet */
  90648. cellWidth: number;
  90649. /** Defines the default height of a cell in the spritesheet */
  90650. cellHeight: number;
  90651. /**
  90652. * Tests the intersection of a sprite with a specific ray.
  90653. * @param ray The ray we are sending to test the collision
  90654. * @param camera The camera space we are sending rays in
  90655. * @param predicate A predicate allowing excluding sprites from the list of object to test
  90656. * @param fastCheck defines if the first intersection will be used (and not the closest)
  90657. * @returns picking info or null.
  90658. */
  90659. intersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  90660. /**
  90661. * Intersects the sprites with a ray
  90662. * @param ray defines the ray to intersect with
  90663. * @param camera defines the current active camera
  90664. * @param predicate defines a predicate used to select candidate sprites
  90665. * @returns null if no hit or a PickingInfo array
  90666. */
  90667. multiIntersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean): Nullable<PickingInfo[]>;
  90668. /**
  90669. * Renders the list of sprites on screen.
  90670. */
  90671. render(): void;
  90672. }
  90673. /**
  90674. * Class used to manage multiple sprites on the same spritesheet
  90675. * @see https://doc.babylonjs.com/babylon101/sprites
  90676. */
  90677. export class SpriteManager implements ISpriteManager {
  90678. /** defines the manager's name */
  90679. name: string;
  90680. /** Define the Url to load snippets */
  90681. static SnippetUrl: string;
  90682. /** Snippet ID if the manager was created from the snippet server */
  90683. snippetId: string;
  90684. /** Gets the list of sprites */
  90685. sprites: Sprite[];
  90686. /** Gets or sets the rendering group id (0 by default) */
  90687. renderingGroupId: number;
  90688. /** Gets or sets camera layer mask */
  90689. layerMask: number;
  90690. /** Gets or sets a boolean indicating if the manager must consider scene fog when rendering */
  90691. fogEnabled: boolean;
  90692. /** Gets or sets a boolean indicating if the sprites are pickable */
  90693. isPickable: boolean;
  90694. /** Defines the default width of a cell in the spritesheet */
  90695. cellWidth: number;
  90696. /** Defines the default height of a cell in the spritesheet */
  90697. cellHeight: number;
  90698. /** Associative array from JSON sprite data file */
  90699. private _cellData;
  90700. /** Array of sprite names from JSON sprite data file */
  90701. private _spriteMap;
  90702. /** True when packed cell data from JSON file is ready*/
  90703. private _packedAndReady;
  90704. private _textureContent;
  90705. private _useInstancing;
  90706. /**
  90707. * An event triggered when the manager is disposed.
  90708. */
  90709. onDisposeObservable: Observable<SpriteManager>;
  90710. private _onDisposeObserver;
  90711. /**
  90712. * Callback called when the manager is disposed
  90713. */
  90714. set onDispose(callback: () => void);
  90715. private _capacity;
  90716. private _fromPacked;
  90717. private _spriteTexture;
  90718. private _epsilon;
  90719. private _scene;
  90720. private _vertexData;
  90721. private _buffer;
  90722. private _vertexBuffers;
  90723. private _spriteBuffer;
  90724. private _indexBuffer;
  90725. private _effectBase;
  90726. private _effectFog;
  90727. private _vertexBufferSize;
  90728. /**
  90729. * Gets or sets the unique id of the sprite
  90730. */
  90731. uniqueId: number;
  90732. /**
  90733. * Gets the array of sprites
  90734. */
  90735. get children(): Sprite[];
  90736. /**
  90737. * Gets the hosting scene
  90738. */
  90739. get scene(): Scene;
  90740. /**
  90741. * Gets the capacity of the manager
  90742. */
  90743. get capacity(): number;
  90744. /**
  90745. * Gets or sets the spritesheet texture
  90746. */
  90747. get texture(): Texture;
  90748. set texture(value: Texture);
  90749. private _blendMode;
  90750. /**
  90751. * Blend mode use to render the particle, it can be any of
  90752. * the static Constants.ALPHA_x properties provided in this class.
  90753. * Default value is Constants.ALPHA_COMBINE
  90754. */
  90755. get blendMode(): number;
  90756. set blendMode(blendMode: number);
  90757. /** Disables writing to the depth buffer when rendering the sprites.
  90758. * It can be handy to disable depth writing when using textures without alpha channel
  90759. * and setting some specific blend modes.
  90760. */
  90761. disableDepthWrite: boolean;
  90762. /**
  90763. * Creates a new sprite manager
  90764. * @param name defines the manager's name
  90765. * @param imgUrl defines the sprite sheet url
  90766. * @param capacity defines the maximum allowed number of sprites
  90767. * @param cellSize defines the size of a sprite cell
  90768. * @param scene defines the hosting scene
  90769. * @param epsilon defines the epsilon value to align texture (0.01 by default)
  90770. * @param samplingMode defines the smapling mode to use with spritesheet
  90771. * @param fromPacked set to false; do not alter
  90772. * @param spriteJSON null otherwise a JSON object defining sprite sheet data; do not alter
  90773. */
  90774. constructor(
  90775. /** defines the manager's name */
  90776. name: string, imgUrl: string, capacity: number, cellSize: any, scene: Scene, epsilon?: number, samplingMode?: number, fromPacked?: boolean, spriteJSON?: any | null);
  90777. /**
  90778. * Returns the string "SpriteManager"
  90779. * @returns "SpriteManager"
  90780. */
  90781. getClassName(): string;
  90782. private _makePacked;
  90783. private _appendSpriteVertex;
  90784. private _checkTextureAlpha;
  90785. /**
  90786. * Intersects the sprites with a ray
  90787. * @param ray defines the ray to intersect with
  90788. * @param camera defines the current active camera
  90789. * @param predicate defines a predicate used to select candidate sprites
  90790. * @param fastCheck defines if a fast check only must be done (the first potential sprite is will be used and not the closer)
  90791. * @returns null if no hit or a PickingInfo
  90792. */
  90793. intersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  90794. /**
  90795. * Intersects the sprites with a ray
  90796. * @param ray defines the ray to intersect with
  90797. * @param camera defines the current active camera
  90798. * @param predicate defines a predicate used to select candidate sprites
  90799. * @returns null if no hit or a PickingInfo array
  90800. */
  90801. multiIntersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean): Nullable<PickingInfo[]>;
  90802. /**
  90803. * Render all child sprites
  90804. */
  90805. render(): void;
  90806. /**
  90807. * Release associated resources
  90808. */
  90809. dispose(): void;
  90810. /**
  90811. * Serializes the sprite manager to a JSON object
  90812. * @param serializeTexture defines if the texture must be serialized as well
  90813. * @returns the JSON object
  90814. */
  90815. serialize(serializeTexture?: boolean): any;
  90816. /**
  90817. * Parses a JSON object to create a new sprite manager.
  90818. * @param parsedManager The JSON object to parse
  90819. * @param scene The scene to create the sprite managerin
  90820. * @param rootUrl The root url to use to load external dependencies like texture
  90821. * @returns the new sprite manager
  90822. */
  90823. static Parse(parsedManager: any, scene: Scene, rootUrl: string): SpriteManager;
  90824. /**
  90825. * Creates a sprite manager from a snippet saved in a remote file
  90826. * @param name defines the name of the sprite manager to create (can be null or empty to use the one from the json data)
  90827. * @param url defines the url to load from
  90828. * @param scene defines the hosting scene
  90829. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  90830. * @returns a promise that will resolve to the new sprite manager
  90831. */
  90832. static ParseFromFileAsync(name: Nullable<string>, url: string, scene: Scene, rootUrl?: string): Promise<SpriteManager>;
  90833. /**
  90834. * Creates a sprite manager from a snippet saved by the sprite editor
  90835. * @param snippetId defines the snippet to load (can be set to _BLANK to create a default one)
  90836. * @param scene defines the hosting scene
  90837. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  90838. * @returns a promise that will resolve to the new sprite manager
  90839. */
  90840. static CreateFromSnippetAsync(snippetId: string, scene: Scene, rootUrl?: string): Promise<SpriteManager>;
  90841. }
  90842. }
  90843. declare module BABYLON {
  90844. /** Interface used by value gradients (color, factor, ...) */
  90845. export interface IValueGradient {
  90846. /**
  90847. * Gets or sets the gradient value (between 0 and 1)
  90848. */
  90849. gradient: number;
  90850. }
  90851. /** Class used to store color4 gradient */
  90852. export class ColorGradient implements IValueGradient {
  90853. /**
  90854. * Gets or sets the gradient value (between 0 and 1)
  90855. */
  90856. gradient: number;
  90857. /**
  90858. * Gets or sets first associated color
  90859. */
  90860. color1: Color4;
  90861. /**
  90862. * Gets or sets second associated color
  90863. */
  90864. color2?: Color4 | undefined;
  90865. /**
  90866. * Creates a new color4 gradient
  90867. * @param gradient gets or sets the gradient value (between 0 and 1)
  90868. * @param color1 gets or sets first associated color
  90869. * @param color2 gets or sets first second color
  90870. */
  90871. constructor(
  90872. /**
  90873. * Gets or sets the gradient value (between 0 and 1)
  90874. */
  90875. gradient: number,
  90876. /**
  90877. * Gets or sets first associated color
  90878. */
  90879. color1: Color4,
  90880. /**
  90881. * Gets or sets second associated color
  90882. */
  90883. color2?: Color4 | undefined);
  90884. /**
  90885. * Will get a color picked randomly between color1 and color2.
  90886. * If color2 is undefined then color1 will be used
  90887. * @param result defines the target Color4 to store the result in
  90888. */
  90889. getColorToRef(result: Color4): void;
  90890. }
  90891. /** Class used to store color 3 gradient */
  90892. export class Color3Gradient implements IValueGradient {
  90893. /**
  90894. * Gets or sets the gradient value (between 0 and 1)
  90895. */
  90896. gradient: number;
  90897. /**
  90898. * Gets or sets the associated color
  90899. */
  90900. color: Color3;
  90901. /**
  90902. * Creates a new color3 gradient
  90903. * @param gradient gets or sets the gradient value (between 0 and 1)
  90904. * @param color gets or sets associated color
  90905. */
  90906. constructor(
  90907. /**
  90908. * Gets or sets the gradient value (between 0 and 1)
  90909. */
  90910. gradient: number,
  90911. /**
  90912. * Gets or sets the associated color
  90913. */
  90914. color: Color3);
  90915. }
  90916. /** Class used to store factor gradient */
  90917. export class FactorGradient implements IValueGradient {
  90918. /**
  90919. * Gets or sets the gradient value (between 0 and 1)
  90920. */
  90921. gradient: number;
  90922. /**
  90923. * Gets or sets first associated factor
  90924. */
  90925. factor1: number;
  90926. /**
  90927. * Gets or sets second associated factor
  90928. */
  90929. factor2?: number | undefined;
  90930. /**
  90931. * Creates a new factor gradient
  90932. * @param gradient gets or sets the gradient value (between 0 and 1)
  90933. * @param factor1 gets or sets first associated factor
  90934. * @param factor2 gets or sets second associated factor
  90935. */
  90936. constructor(
  90937. /**
  90938. * Gets or sets the gradient value (between 0 and 1)
  90939. */
  90940. gradient: number,
  90941. /**
  90942. * Gets or sets first associated factor
  90943. */
  90944. factor1: number,
  90945. /**
  90946. * Gets or sets second associated factor
  90947. */
  90948. factor2?: number | undefined);
  90949. /**
  90950. * Will get a number picked randomly between factor1 and factor2.
  90951. * If factor2 is undefined then factor1 will be used
  90952. * @returns the picked number
  90953. */
  90954. getFactor(): number;
  90955. }
  90956. /**
  90957. * Helper used to simplify some generic gradient tasks
  90958. */
  90959. export class GradientHelper {
  90960. /**
  90961. * Gets the current gradient from an array of IValueGradient
  90962. * @param ratio defines the current ratio to get
  90963. * @param gradients defines the array of IValueGradient
  90964. * @param updateFunc defines the callback function used to get the final value from the selected gradients
  90965. */
  90966. static GetCurrentGradient(ratio: number, gradients: IValueGradient[], updateFunc: (current: IValueGradient, next: IValueGradient, scale: number) => void): void;
  90967. }
  90968. }
  90969. declare module BABYLON {
  90970. interface ThinEngine {
  90971. /**
  90972. * Creates a raw texture
  90973. * @param data defines the data to store in the texture
  90974. * @param width defines the width of the texture
  90975. * @param height defines the height of the texture
  90976. * @param format defines the format of the data
  90977. * @param generateMipMaps defines if the engine should generate the mip levels
  90978. * @param invertY defines if data must be stored with Y axis inverted
  90979. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  90980. * @param compression defines the compression used (null by default)
  90981. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  90982. * @returns the raw texture inside an InternalTexture
  90983. */
  90984. createRawTexture(data: Nullable<ArrayBufferView>, width: number, height: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>, type: number): InternalTexture;
  90985. /**
  90986. * Update a raw texture
  90987. * @param texture defines the texture to update
  90988. * @param data defines the data to store in the texture
  90989. * @param format defines the format of the data
  90990. * @param invertY defines if data must be stored with Y axis inverted
  90991. */
  90992. updateRawTexture(texture: Nullable<InternalTexture>, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;
  90993. /**
  90994. * Update a raw texture
  90995. * @param texture defines the texture to update
  90996. * @param data defines the data to store in the texture
  90997. * @param format defines the format of the data
  90998. * @param invertY defines if data must be stored with Y axis inverted
  90999. * @param compression defines the compression used (null by default)
  91000. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  91001. */
  91002. updateRawTexture(texture: Nullable<InternalTexture>, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression: Nullable<string>, type: number): void;
  91003. /**
  91004. * Creates a new raw cube texture
  91005. * @param data defines the array of data to use to create each face
  91006. * @param size defines the size of the textures
  91007. * @param format defines the format of the data
  91008. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  91009. * @param generateMipMaps defines if the engine should generate the mip levels
  91010. * @param invertY defines if data must be stored with Y axis inverted
  91011. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  91012. * @param compression defines the compression used (null by default)
  91013. * @returns the cube texture as an InternalTexture
  91014. */
  91015. createRawCubeTexture(data: Nullable<ArrayBufferView[]>, size: number, format: number, type: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>): InternalTexture;
  91016. /**
  91017. * Update a raw cube texture
  91018. * @param texture defines the texture to udpdate
  91019. * @param data defines the data to store
  91020. * @param format defines the data format
  91021. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  91022. * @param invertY defines if data must be stored with Y axis inverted
  91023. */
  91024. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean): void;
  91025. /**
  91026. * Update a raw cube texture
  91027. * @param texture defines the texture to udpdate
  91028. * @param data defines the data to store
  91029. * @param format defines the data format
  91030. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  91031. * @param invertY defines if data must be stored with Y axis inverted
  91032. * @param compression defines the compression used (null by default)
  91033. */
  91034. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression: Nullable<string>): void;
  91035. /**
  91036. * Update a raw cube texture
  91037. * @param texture defines the texture to udpdate
  91038. * @param data defines the data to store
  91039. * @param format defines the data format
  91040. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  91041. * @param invertY defines if data must be stored with Y axis inverted
  91042. * @param compression defines the compression used (null by default)
  91043. * @param level defines which level of the texture to update
  91044. */
  91045. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression: Nullable<string>, level: number): void;
  91046. /**
  91047. * Creates a new raw cube texture from a specified url
  91048. * @param url defines the url where the data is located
  91049. * @param scene defines the current scene
  91050. * @param size defines the size of the textures
  91051. * @param format defines the format of the data
  91052. * @param type defines the type fo the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  91053. * @param noMipmap defines if the engine should avoid generating the mip levels
  91054. * @param callback defines a callback used to extract texture data from loaded data
  91055. * @param mipmapGenerator defines to provide an optional tool to generate mip levels
  91056. * @param onLoad defines a callback called when texture is loaded
  91057. * @param onError defines a callback called if there is an error
  91058. * @returns the cube texture as an InternalTexture
  91059. */
  91060. 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;
  91061. /**
  91062. * Creates a new raw cube texture from a specified url
  91063. * @param url defines the url where the data is located
  91064. * @param scene defines the current scene
  91065. * @param size defines the size of the textures
  91066. * @param format defines the format of the data
  91067. * @param type defines the type fo the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  91068. * @param noMipmap defines if the engine should avoid generating the mip levels
  91069. * @param callback defines a callback used to extract texture data from loaded data
  91070. * @param mipmapGenerator defines to provide an optional tool to generate mip levels
  91071. * @param onLoad defines a callback called when texture is loaded
  91072. * @param onError defines a callback called if there is an error
  91073. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  91074. * @param invertY defines if data must be stored with Y axis inverted
  91075. * @returns the cube texture as an InternalTexture
  91076. */
  91077. 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;
  91078. /**
  91079. * Creates a new raw 3D texture
  91080. * @param data defines the data used to create the texture
  91081. * @param width defines the width of the texture
  91082. * @param height defines the height of the texture
  91083. * @param depth defines the depth of the texture
  91084. * @param format defines the format of the texture
  91085. * @param generateMipMaps defines if the engine must generate mip levels
  91086. * @param invertY defines if data must be stored with Y axis inverted
  91087. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  91088. * @param compression defines the compressed used (can be null)
  91089. * @param textureType defines the compressed used (can be null)
  91090. * @returns a new raw 3D texture (stored in an InternalTexture)
  91091. */
  91092. createRawTexture3D(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>, textureType: number): InternalTexture;
  91093. /**
  91094. * Update a raw 3D texture
  91095. * @param texture defines the texture to update
  91096. * @param data defines the data to store
  91097. * @param format defines the data format
  91098. * @param invertY defines if data must be stored with Y axis inverted
  91099. */
  91100. updateRawTexture3D(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;
  91101. /**
  91102. * Update a raw 3D texture
  91103. * @param texture defines the texture to update
  91104. * @param data defines the data to store
  91105. * @param format defines the data format
  91106. * @param invertY defines if data must be stored with Y axis inverted
  91107. * @param compression defines the used compression (can be null)
  91108. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  91109. */
  91110. updateRawTexture3D(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression: Nullable<string>, textureType: number): void;
  91111. /**
  91112. * Creates a new raw 2D array texture
  91113. * @param data defines the data used to create the texture
  91114. * @param width defines the width of the texture
  91115. * @param height defines the height of the texture
  91116. * @param depth defines the number of layers of the texture
  91117. * @param format defines the format of the texture
  91118. * @param generateMipMaps defines if the engine must generate mip levels
  91119. * @param invertY defines if data must be stored with Y axis inverted
  91120. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  91121. * @param compression defines the compressed used (can be null)
  91122. * @param textureType defines the compressed used (can be null)
  91123. * @returns a new raw 2D array texture (stored in an InternalTexture)
  91124. */
  91125. createRawTexture2DArray(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>, textureType: number): InternalTexture;
  91126. /**
  91127. * Update a raw 2D array texture
  91128. * @param texture defines the texture to update
  91129. * @param data defines the data to store
  91130. * @param format defines the data format
  91131. * @param invertY defines if data must be stored with Y axis inverted
  91132. */
  91133. updateRawTexture2DArray(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;
  91134. /**
  91135. * Update a raw 2D array texture
  91136. * @param texture defines the texture to update
  91137. * @param data defines the data to store
  91138. * @param format defines the data format
  91139. * @param invertY defines if data must be stored with Y axis inverted
  91140. * @param compression defines the used compression (can be null)
  91141. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  91142. */
  91143. updateRawTexture2DArray(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression: Nullable<string>, textureType: number): void;
  91144. }
  91145. }
  91146. declare module BABYLON {
  91147. /**
  91148. * Raw texture can help creating a texture directly from an array of data.
  91149. * This can be super useful if you either get the data from an uncompressed source or
  91150. * if you wish to create your texture pixel by pixel.
  91151. */
  91152. export class RawTexture extends Texture {
  91153. /**
  91154. * Define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  91155. */
  91156. format: number;
  91157. /**
  91158. * Instantiates a new RawTexture.
  91159. * Raw texture can help creating a texture directly from an array of data.
  91160. * This can be super useful if you either get the data from an uncompressed source or
  91161. * if you wish to create your texture pixel by pixel.
  91162. * @param data define the array of data to use to create the texture
  91163. * @param width define the width of the texture
  91164. * @param height define the height of the texture
  91165. * @param format define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  91166. * @param sceneOrEngine defines the scene or engine the texture will belong to
  91167. * @param generateMipMaps define whether mip maps should be generated or not
  91168. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  91169. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  91170. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  91171. */
  91172. constructor(data: ArrayBufferView, width: number, height: number,
  91173. /**
  91174. * Define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  91175. */
  91176. format: number, sceneOrEngine: Nullable<Scene | ThinEngine>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number);
  91177. /**
  91178. * Updates the texture underlying data.
  91179. * @param data Define the new data of the texture
  91180. */
  91181. update(data: ArrayBufferView): void;
  91182. /**
  91183. * Creates a luminance texture from some data.
  91184. * @param data Define the texture data
  91185. * @param width Define the width of the texture
  91186. * @param height Define the height of the texture
  91187. * @param sceneOrEngine defines the scene or engine the texture will belong to
  91188. * @param generateMipMaps Define whether or not to create mip maps for the texture
  91189. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  91190. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  91191. * @returns the luminance texture
  91192. */
  91193. static CreateLuminanceTexture(data: ArrayBufferView, width: number, height: number, sceneOrEngine: Nullable<Scene | ThinEngine>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  91194. /**
  91195. * Creates a luminance alpha texture from some data.
  91196. * @param data Define the texture data
  91197. * @param width Define the width of the texture
  91198. * @param height Define the height of the texture
  91199. * @param sceneOrEngine defines the scene or engine the texture will belong to
  91200. * @param generateMipMaps Define whether or not to create mip maps for the texture
  91201. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  91202. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  91203. * @returns the luminance alpha texture
  91204. */
  91205. static CreateLuminanceAlphaTexture(data: ArrayBufferView, width: number, height: number, sceneOrEngine: Nullable<Scene | ThinEngine>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  91206. /**
  91207. * Creates an alpha texture from some data.
  91208. * @param data Define the texture data
  91209. * @param width Define the width of the texture
  91210. * @param height Define the height of the texture
  91211. * @param sceneOrEngine defines the scene or engine the texture will belong to
  91212. * @param generateMipMaps Define whether or not to create mip maps for the texture
  91213. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  91214. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  91215. * @returns the alpha texture
  91216. */
  91217. static CreateAlphaTexture(data: ArrayBufferView, width: number, height: number, sceneOrEngine: Nullable<Scene | ThinEngine>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  91218. /**
  91219. * Creates a RGB texture from some data.
  91220. * @param data Define the texture data
  91221. * @param width Define the width of the texture
  91222. * @param height Define the height of the texture
  91223. * @param sceneOrEngine defines the scene or engine the texture will belong to
  91224. * @param generateMipMaps Define whether or not to create mip maps for the texture
  91225. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  91226. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  91227. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  91228. * @returns the RGB alpha texture
  91229. */
  91230. static CreateRGBTexture(data: ArrayBufferView, width: number, height: number, sceneOrEngine: Nullable<Scene | ThinEngine>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  91231. /**
  91232. * Creates a RGBA texture from some data.
  91233. * @param data Define the texture data
  91234. * @param width Define the width of the texture
  91235. * @param height Define the height of the texture
  91236. * @param sceneOrEngine defines the scene or engine the texture will belong to
  91237. * @param generateMipMaps Define whether or not to create mip maps for the texture
  91238. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  91239. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  91240. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  91241. * @returns the RGBA texture
  91242. */
  91243. static CreateRGBATexture(data: ArrayBufferView, width: number, height: number, sceneOrEngine: Nullable<Scene | ThinEngine>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  91244. /**
  91245. * Creates a R texture from some data.
  91246. * @param data Define the texture data
  91247. * @param width Define the width of the texture
  91248. * @param height Define the height of the texture
  91249. * @param sceneOrEngine defines the scene or engine the texture will belong to
  91250. * @param generateMipMaps Define whether or not to create mip maps for the texture
  91251. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  91252. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  91253. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  91254. * @returns the R texture
  91255. */
  91256. static CreateRTexture(data: ArrayBufferView, width: number, height: number, sceneOrEngine: Nullable<Scene | ThinEngine>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  91257. }
  91258. }
  91259. declare module BABYLON {
  91260. interface ThinEngine {
  91261. /**
  91262. * Update a dynamic index buffer
  91263. * @param indexBuffer defines the target index buffer
  91264. * @param indices defines the data to update
  91265. * @param offset defines the offset in the target index buffer where update should start
  91266. */
  91267. updateDynamicIndexBuffer(indexBuffer: DataBuffer, indices: IndicesArray, offset?: number): void;
  91268. /**
  91269. * Updates a dynamic vertex buffer.
  91270. * @param vertexBuffer the vertex buffer to update
  91271. * @param data the data used to update the vertex buffer
  91272. * @param byteOffset the byte offset of the data
  91273. * @param byteLength the byte length of the data
  91274. */
  91275. updateDynamicVertexBuffer(vertexBuffer: DataBuffer, data: DataArray, byteOffset?: number, byteLength?: number): void;
  91276. }
  91277. }
  91278. declare module BABYLON {
  91279. interface AbstractScene {
  91280. /**
  91281. * The list of procedural textures added to the scene
  91282. * @see https://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  91283. */
  91284. proceduralTextures: Array<ProceduralTexture>;
  91285. }
  91286. /**
  91287. * Defines the Procedural Texture scene component responsible to manage any Procedural Texture
  91288. * in a given scene.
  91289. */
  91290. export class ProceduralTextureSceneComponent implements ISceneComponent {
  91291. /**
  91292. * The component name helpfull to identify the component in the list of scene components.
  91293. */
  91294. readonly name: string;
  91295. /**
  91296. * The scene the component belongs to.
  91297. */
  91298. scene: Scene;
  91299. /**
  91300. * Creates a new instance of the component for the given scene
  91301. * @param scene Defines the scene to register the component in
  91302. */
  91303. constructor(scene: Scene);
  91304. /**
  91305. * Registers the component in a given scene
  91306. */
  91307. register(): void;
  91308. /**
  91309. * Rebuilds the elements related to this component in case of
  91310. * context lost for instance.
  91311. */
  91312. rebuild(): void;
  91313. /**
  91314. * Disposes the component and the associated ressources.
  91315. */
  91316. dispose(): void;
  91317. private _beforeClear;
  91318. }
  91319. }
  91320. declare module BABYLON {
  91321. interface ThinEngine {
  91322. /**
  91323. * Creates a new render target cube texture
  91324. * @param size defines the size of the texture
  91325. * @param options defines the options used to create the texture
  91326. * @returns a new render target cube texture stored in an InternalTexture
  91327. */
  91328. createRenderTargetCubeTexture(size: number, options?: Partial<RenderTargetCreationOptions>): InternalTexture;
  91329. }
  91330. }
  91331. declare module BABYLON {
  91332. /** @hidden */
  91333. export var proceduralVertexShader: {
  91334. name: string;
  91335. shader: string;
  91336. };
  91337. }
  91338. declare module BABYLON {
  91339. /**
  91340. * 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.
  91341. * This is the base class of any Procedural texture and contains most of the shareable code.
  91342. * @see https://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  91343. */
  91344. export class ProceduralTexture extends Texture {
  91345. /**
  91346. * Define if the texture is enabled or not (disabled texture will not render)
  91347. */
  91348. isEnabled: boolean;
  91349. /**
  91350. * Define if the texture must be cleared before rendering (default is true)
  91351. */
  91352. autoClear: boolean;
  91353. /**
  91354. * Callback called when the texture is generated
  91355. */
  91356. onGenerated: () => void;
  91357. /**
  91358. * Event raised when the texture is generated
  91359. */
  91360. onGeneratedObservable: Observable<ProceduralTexture>;
  91361. /** @hidden */
  91362. _generateMipMaps: boolean;
  91363. /** @hidden **/
  91364. _effect: Effect;
  91365. /** @hidden */
  91366. _textures: {
  91367. [key: string]: Texture;
  91368. };
  91369. /** @hidden */
  91370. protected _fallbackTexture: Nullable<Texture>;
  91371. private _size;
  91372. private _currentRefreshId;
  91373. private _frameId;
  91374. private _refreshRate;
  91375. private _vertexBuffers;
  91376. private _indexBuffer;
  91377. private _uniforms;
  91378. private _samplers;
  91379. private _fragment;
  91380. private _floats;
  91381. private _ints;
  91382. private _floatsArrays;
  91383. private _colors3;
  91384. private _colors4;
  91385. private _vectors2;
  91386. private _vectors3;
  91387. private _matrices;
  91388. private _fallbackTextureUsed;
  91389. private _fullEngine;
  91390. private _cachedDefines;
  91391. private _contentUpdateId;
  91392. private _contentData;
  91393. /**
  91394. * Instantiates a new procedural texture.
  91395. * 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.
  91396. * This is the base class of any Procedural texture and contains most of the shareable code.
  91397. * @see https://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  91398. * @param name Define the name of the texture
  91399. * @param size Define the size of the texture to create
  91400. * @param fragment Define the fragment shader to use to generate the texture or null if it is defined later
  91401. * @param scene Define the scene the texture belongs to
  91402. * @param fallbackTexture Define a fallback texture in case there were issues to create the custom texture
  91403. * @param generateMipMaps Define if the texture should creates mip maps or not
  91404. * @param isCube Define if the texture is a cube texture or not (this will render each faces of the cube)
  91405. */
  91406. constructor(name: string, size: any, fragment: any, scene: Nullable<Scene>, fallbackTexture?: Nullable<Texture>, generateMipMaps?: boolean, isCube?: boolean);
  91407. /**
  91408. * The effect that is created when initializing the post process.
  91409. * @returns The created effect corresponding the the postprocess.
  91410. */
  91411. getEffect(): Effect;
  91412. /**
  91413. * Gets texture content (Use this function wisely as reading from a texture can be slow)
  91414. * @returns an ArrayBufferView (Uint8Array or Float32Array)
  91415. */
  91416. getContent(): Nullable<ArrayBufferView>;
  91417. private _createIndexBuffer;
  91418. /** @hidden */
  91419. _rebuild(): void;
  91420. /**
  91421. * Resets the texture in order to recreate its associated resources.
  91422. * This can be called in case of context loss
  91423. */
  91424. reset(): void;
  91425. protected _getDefines(): string;
  91426. /**
  91427. * Is the texture ready to be used ? (rendered at least once)
  91428. * @returns true if ready, otherwise, false.
  91429. */
  91430. isReady(): boolean;
  91431. /**
  91432. * Resets the refresh counter of the texture and start bak from scratch.
  91433. * Could be useful to regenerate the texture if it is setup to render only once.
  91434. */
  91435. resetRefreshCounter(): void;
  91436. /**
  91437. * Set the fragment shader to use in order to render the texture.
  91438. * @param fragment This can be set to a path (into the shader store) or to a json object containing a fragmentElement property.
  91439. */
  91440. setFragment(fragment: any): void;
  91441. /**
  91442. * Define the refresh rate of the texture or the rendering frequency.
  91443. * Use 0 to render just once, 1 to render on every frame, 2 to render every two frames and so on...
  91444. */
  91445. get refreshRate(): number;
  91446. set refreshRate(value: number);
  91447. /** @hidden */
  91448. _shouldRender(): boolean;
  91449. /**
  91450. * Get the size the texture is rendering at.
  91451. * @returns the size (texture is always squared)
  91452. */
  91453. getRenderSize(): number;
  91454. /**
  91455. * Resize the texture to new value.
  91456. * @param size Define the new size the texture should have
  91457. * @param generateMipMaps Define whether the new texture should create mip maps
  91458. */
  91459. resize(size: number, generateMipMaps: boolean): void;
  91460. private _checkUniform;
  91461. /**
  91462. * Set a texture in the shader program used to render.
  91463. * @param name Define the name of the uniform samplers as defined in the shader
  91464. * @param texture Define the texture to bind to this sampler
  91465. * @return the texture itself allowing "fluent" like uniform updates
  91466. */
  91467. setTexture(name: string, texture: Texture): ProceduralTexture;
  91468. /**
  91469. * Set a float in the shader.
  91470. * @param name Define the name of the uniform as defined in the shader
  91471. * @param value Define the value to give to the uniform
  91472. * @return the texture itself allowing "fluent" like uniform updates
  91473. */
  91474. setFloat(name: string, value: number): ProceduralTexture;
  91475. /**
  91476. * Set a int in the shader.
  91477. * @param name Define the name of the uniform as defined in the shader
  91478. * @param value Define the value to give to the uniform
  91479. * @return the texture itself allowing "fluent" like uniform updates
  91480. */
  91481. setInt(name: string, value: number): ProceduralTexture;
  91482. /**
  91483. * Set an array of floats in the shader.
  91484. * @param name Define the name of the uniform as defined in the shader
  91485. * @param value Define the value to give to the uniform
  91486. * @return the texture itself allowing "fluent" like uniform updates
  91487. */
  91488. setFloats(name: string, value: number[]): ProceduralTexture;
  91489. /**
  91490. * Set a vec3 in the shader from a Color3.
  91491. * @param name Define the name of the uniform as defined in the shader
  91492. * @param value Define the value to give to the uniform
  91493. * @return the texture itself allowing "fluent" like uniform updates
  91494. */
  91495. setColor3(name: string, value: Color3): ProceduralTexture;
  91496. /**
  91497. * Set a vec4 in the shader from a Color4.
  91498. * @param name Define the name of the uniform as defined in the shader
  91499. * @param value Define the value to give to the uniform
  91500. * @return the texture itself allowing "fluent" like uniform updates
  91501. */
  91502. setColor4(name: string, value: Color4): ProceduralTexture;
  91503. /**
  91504. * Set a vec2 in the shader from a Vector2.
  91505. * @param name Define the name of the uniform as defined in the shader
  91506. * @param value Define the value to give to the uniform
  91507. * @return the texture itself allowing "fluent" like uniform updates
  91508. */
  91509. setVector2(name: string, value: Vector2): ProceduralTexture;
  91510. /**
  91511. * Set a vec3 in the shader from a Vector3.
  91512. * @param name Define the name of the uniform as defined in the shader
  91513. * @param value Define the value to give to the uniform
  91514. * @return the texture itself allowing "fluent" like uniform updates
  91515. */
  91516. setVector3(name: string, value: Vector3): ProceduralTexture;
  91517. /**
  91518. * Set a mat4 in the shader from a MAtrix.
  91519. * @param name Define the name of the uniform as defined in the shader
  91520. * @param value Define the value to give to the uniform
  91521. * @return the texture itself allowing "fluent" like uniform updates
  91522. */
  91523. setMatrix(name: string, value: Matrix): ProceduralTexture;
  91524. /**
  91525. * Render the texture to its associated render target.
  91526. * @param useCameraPostProcess Define if camera post process should be applied to the texture
  91527. */
  91528. render(useCameraPostProcess?: boolean): void;
  91529. /**
  91530. * Clone the texture.
  91531. * @returns the cloned texture
  91532. */
  91533. clone(): ProceduralTexture;
  91534. /**
  91535. * Dispose the texture and release its asoociated resources.
  91536. */
  91537. dispose(): void;
  91538. }
  91539. }
  91540. declare module BABYLON {
  91541. /**
  91542. * This represents the base class for particle system in Babylon.
  91543. * 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.
  91544. * Particles can take different shapes while emitted like box, sphere, cone or you can write your custom function.
  91545. * @example https://doc.babylonjs.com/babylon101/particles
  91546. */
  91547. export class BaseParticleSystem {
  91548. /**
  91549. * Source color is added to the destination color without alpha affecting the result
  91550. */
  91551. static BLENDMODE_ONEONE: number;
  91552. /**
  91553. * Blend current color and particle color using particle’s alpha
  91554. */
  91555. static BLENDMODE_STANDARD: number;
  91556. /**
  91557. * Add current color and particle color multiplied by particle’s alpha
  91558. */
  91559. static BLENDMODE_ADD: number;
  91560. /**
  91561. * Multiply current color with particle color
  91562. */
  91563. static BLENDMODE_MULTIPLY: number;
  91564. /**
  91565. * Multiply current color with particle color then add current color and particle color multiplied by particle’s alpha
  91566. */
  91567. static BLENDMODE_MULTIPLYADD: number;
  91568. /**
  91569. * List of animations used by the particle system.
  91570. */
  91571. animations: Animation[];
  91572. /**
  91573. * Gets or sets the unique id of the particle system
  91574. */
  91575. uniqueId: number;
  91576. /**
  91577. * The id of the Particle system.
  91578. */
  91579. id: string;
  91580. /**
  91581. * The friendly name of the Particle system.
  91582. */
  91583. name: string;
  91584. /**
  91585. * Snippet ID if the particle system was created from the snippet server
  91586. */
  91587. snippetId: string;
  91588. /**
  91589. * The rendering group used by the Particle system to chose when to render.
  91590. */
  91591. renderingGroupId: number;
  91592. /**
  91593. * The emitter represents the Mesh or position we are attaching the particle system to.
  91594. */
  91595. emitter: Nullable<AbstractMesh | Vector3>;
  91596. /**
  91597. * The maximum number of particles to emit per frame
  91598. */
  91599. emitRate: number;
  91600. /**
  91601. * If you want to launch only a few particles at once, that can be done, as well.
  91602. */
  91603. manualEmitCount: number;
  91604. /**
  91605. * The overall motion speed (0.01 is default update speed, faster updates = faster animation)
  91606. */
  91607. updateSpeed: number;
  91608. /**
  91609. * The amount of time the particle system is running (depends of the overall update speed).
  91610. */
  91611. targetStopDuration: number;
  91612. /**
  91613. * Specifies whether the particle system will be disposed once it reaches the end of the animation.
  91614. */
  91615. disposeOnStop: boolean;
  91616. /**
  91617. * Minimum power of emitting particles.
  91618. */
  91619. minEmitPower: number;
  91620. /**
  91621. * Maximum power of emitting particles.
  91622. */
  91623. maxEmitPower: number;
  91624. /**
  91625. * Minimum life time of emitting particles.
  91626. */
  91627. minLifeTime: number;
  91628. /**
  91629. * Maximum life time of emitting particles.
  91630. */
  91631. maxLifeTime: number;
  91632. /**
  91633. * Minimum Size of emitting particles.
  91634. */
  91635. minSize: number;
  91636. /**
  91637. * Maximum Size of emitting particles.
  91638. */
  91639. maxSize: number;
  91640. /**
  91641. * Minimum scale of emitting particles on X axis.
  91642. */
  91643. minScaleX: number;
  91644. /**
  91645. * Maximum scale of emitting particles on X axis.
  91646. */
  91647. maxScaleX: number;
  91648. /**
  91649. * Minimum scale of emitting particles on Y axis.
  91650. */
  91651. minScaleY: number;
  91652. /**
  91653. * Maximum scale of emitting particles on Y axis.
  91654. */
  91655. maxScaleY: number;
  91656. /**
  91657. * Gets or sets the minimal initial rotation in radians.
  91658. */
  91659. minInitialRotation: number;
  91660. /**
  91661. * Gets or sets the maximal initial rotation in radians.
  91662. */
  91663. maxInitialRotation: number;
  91664. /**
  91665. * Minimum angular speed of emitting particles (Z-axis rotation for each particle).
  91666. */
  91667. minAngularSpeed: number;
  91668. /**
  91669. * Maximum angular speed of emitting particles (Z-axis rotation for each particle).
  91670. */
  91671. maxAngularSpeed: number;
  91672. /**
  91673. * The texture used to render each particle. (this can be a spritesheet)
  91674. */
  91675. particleTexture: Nullable<BaseTexture>;
  91676. /**
  91677. * The layer mask we are rendering the particles through.
  91678. */
  91679. layerMask: number;
  91680. /**
  91681. * This can help using your own shader to render the particle system.
  91682. * The according effect will be created
  91683. */
  91684. customShader: any;
  91685. /**
  91686. * By default particle system starts as soon as they are created. This prevents the
  91687. * automatic start to happen and let you decide when to start emitting particles.
  91688. */
  91689. preventAutoStart: boolean;
  91690. private _noiseTexture;
  91691. /**
  91692. * Gets or sets a texture used to add random noise to particle positions
  91693. */
  91694. get noiseTexture(): Nullable<ProceduralTexture>;
  91695. set noiseTexture(value: Nullable<ProceduralTexture>);
  91696. /** Gets or sets the strength to apply to the noise value (default is (10, 10, 10)) */
  91697. noiseStrength: Vector3;
  91698. /**
  91699. * Callback triggered when the particle animation is ending.
  91700. */
  91701. onAnimationEnd: Nullable<() => void>;
  91702. /**
  91703. * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE or ParticleSystem.BLENDMODE_STANDARD.
  91704. */
  91705. blendMode: number;
  91706. /**
  91707. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  91708. * to override the particles.
  91709. */
  91710. forceDepthWrite: boolean;
  91711. /** 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 */
  91712. preWarmCycles: number;
  91713. /** Gets or sets a value indicating the time step multiplier to use in pre-warm mode (default is 1) */
  91714. preWarmStepOffset: number;
  91715. /**
  91716. * 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)
  91717. */
  91718. spriteCellChangeSpeed: number;
  91719. /**
  91720. * If using a spritesheet (isAnimationSheetEnabled) defines the first sprite cell to display
  91721. */
  91722. startSpriteCellID: number;
  91723. /**
  91724. * If using a spritesheet (isAnimationSheetEnabled) defines the last sprite cell to display
  91725. */
  91726. endSpriteCellID: number;
  91727. /**
  91728. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell width to use
  91729. */
  91730. spriteCellWidth: number;
  91731. /**
  91732. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell height to use
  91733. */
  91734. spriteCellHeight: number;
  91735. /**
  91736. * This allows the system to random pick the start cell ID between startSpriteCellID and endSpriteCellID
  91737. */
  91738. spriteRandomStartCell: boolean;
  91739. /** Gets or sets a Vector2 used to move the pivot (by default (0,0)) */
  91740. translationPivot: Vector2;
  91741. /** @hidden */
  91742. protected _isAnimationSheetEnabled: boolean;
  91743. /**
  91744. * Gets or sets a boolean indicating that hosted animations (in the system.animations array) must be started when system.start() is called
  91745. */
  91746. beginAnimationOnStart: boolean;
  91747. /**
  91748. * Gets or sets the frame to start the animation from when beginAnimationOnStart is true
  91749. */
  91750. beginAnimationFrom: number;
  91751. /**
  91752. * Gets or sets the frame to end the animation on when beginAnimationOnStart is true
  91753. */
  91754. beginAnimationTo: number;
  91755. /**
  91756. * Gets or sets a boolean indicating if animations must loop when beginAnimationOnStart is true
  91757. */
  91758. beginAnimationLoop: boolean;
  91759. /**
  91760. * Gets or sets a world offset applied to all particles
  91761. */
  91762. worldOffset: Vector3;
  91763. /**
  91764. * Gets or sets whether an animation sprite sheet is enabled or not on the particle system
  91765. */
  91766. get isAnimationSheetEnabled(): boolean;
  91767. set isAnimationSheetEnabled(value: boolean);
  91768. /**
  91769. * Get hosting scene
  91770. * @returns the scene
  91771. */
  91772. getScene(): Nullable<Scene>;
  91773. /**
  91774. * You can use gravity if you want to give an orientation to your particles.
  91775. */
  91776. gravity: Vector3;
  91777. protected _colorGradients: Nullable<Array<ColorGradient>>;
  91778. protected _sizeGradients: Nullable<Array<FactorGradient>>;
  91779. protected _lifeTimeGradients: Nullable<Array<FactorGradient>>;
  91780. protected _angularSpeedGradients: Nullable<Array<FactorGradient>>;
  91781. protected _velocityGradients: Nullable<Array<FactorGradient>>;
  91782. protected _limitVelocityGradients: Nullable<Array<FactorGradient>>;
  91783. protected _dragGradients: Nullable<Array<FactorGradient>>;
  91784. protected _emitRateGradients: Nullable<Array<FactorGradient>>;
  91785. protected _startSizeGradients: Nullable<Array<FactorGradient>>;
  91786. protected _rampGradients: Nullable<Array<Color3Gradient>>;
  91787. protected _colorRemapGradients: Nullable<Array<FactorGradient>>;
  91788. protected _alphaRemapGradients: Nullable<Array<FactorGradient>>;
  91789. protected _hasTargetStopDurationDependantGradient(): boolean | null;
  91790. /**
  91791. * Defines the delay in milliseconds before starting the system (0 by default)
  91792. */
  91793. startDelay: number;
  91794. /**
  91795. * Gets the current list of drag gradients.
  91796. * You must use addDragGradient and removeDragGradient to udpate this list
  91797. * @returns the list of drag gradients
  91798. */
  91799. getDragGradients(): Nullable<Array<FactorGradient>>;
  91800. /** Gets or sets a value indicating the damping to apply if the limit velocity factor is reached */
  91801. limitVelocityDamping: number;
  91802. /**
  91803. * Gets the current list of limit velocity gradients.
  91804. * You must use addLimitVelocityGradient and removeLimitVelocityGradient to udpate this list
  91805. * @returns the list of limit velocity gradients
  91806. */
  91807. getLimitVelocityGradients(): Nullable<Array<FactorGradient>>;
  91808. /**
  91809. * Gets the current list of color gradients.
  91810. * You must use addColorGradient and removeColorGradient to udpate this list
  91811. * @returns the list of color gradients
  91812. */
  91813. getColorGradients(): Nullable<Array<ColorGradient>>;
  91814. /**
  91815. * Gets the current list of size gradients.
  91816. * You must use addSizeGradient and removeSizeGradient to udpate this list
  91817. * @returns the list of size gradients
  91818. */
  91819. getSizeGradients(): Nullable<Array<FactorGradient>>;
  91820. /**
  91821. * Gets the current list of color remap gradients.
  91822. * You must use addColorRemapGradient and removeColorRemapGradient to udpate this list
  91823. * @returns the list of color remap gradients
  91824. */
  91825. getColorRemapGradients(): Nullable<Array<FactorGradient>>;
  91826. /**
  91827. * Gets the current list of alpha remap gradients.
  91828. * You must use addAlphaRemapGradient and removeAlphaRemapGradient to udpate this list
  91829. * @returns the list of alpha remap gradients
  91830. */
  91831. getAlphaRemapGradients(): Nullable<Array<FactorGradient>>;
  91832. /**
  91833. * Gets the current list of life time gradients.
  91834. * You must use addLifeTimeGradient and removeLifeTimeGradient to udpate this list
  91835. * @returns the list of life time gradients
  91836. */
  91837. getLifeTimeGradients(): Nullable<Array<FactorGradient>>;
  91838. /**
  91839. * Gets the current list of angular speed gradients.
  91840. * You must use addAngularSpeedGradient and removeAngularSpeedGradient to udpate this list
  91841. * @returns the list of angular speed gradients
  91842. */
  91843. getAngularSpeedGradients(): Nullable<Array<FactorGradient>>;
  91844. /**
  91845. * Gets the current list of velocity gradients.
  91846. * You must use addVelocityGradient and removeVelocityGradient to udpate this list
  91847. * @returns the list of velocity gradients
  91848. */
  91849. getVelocityGradients(): Nullable<Array<FactorGradient>>;
  91850. /**
  91851. * Gets the current list of start size gradients.
  91852. * You must use addStartSizeGradient and removeStartSizeGradient to udpate this list
  91853. * @returns the list of start size gradients
  91854. */
  91855. getStartSizeGradients(): Nullable<Array<FactorGradient>>;
  91856. /**
  91857. * Gets the current list of emit rate gradients.
  91858. * You must use addEmitRateGradient and removeEmitRateGradient to udpate this list
  91859. * @returns the list of emit rate gradients
  91860. */
  91861. getEmitRateGradients(): Nullable<Array<FactorGradient>>;
  91862. /**
  91863. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  91864. * This only works when particleEmitterTyps is a BoxParticleEmitter
  91865. */
  91866. get direction1(): Vector3;
  91867. set direction1(value: Vector3);
  91868. /**
  91869. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  91870. * This only works when particleEmitterTyps is a BoxParticleEmitter
  91871. */
  91872. get direction2(): Vector3;
  91873. set direction2(value: Vector3);
  91874. /**
  91875. * 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.
  91876. * This only works when particleEmitterTyps is a BoxParticleEmitter
  91877. */
  91878. get minEmitBox(): Vector3;
  91879. set minEmitBox(value: Vector3);
  91880. /**
  91881. * 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.
  91882. * This only works when particleEmitterTyps is a BoxParticleEmitter
  91883. */
  91884. get maxEmitBox(): Vector3;
  91885. set maxEmitBox(value: Vector3);
  91886. /**
  91887. * Random color of each particle after it has been emitted, between color1 and color2 vectors
  91888. */
  91889. color1: Color4;
  91890. /**
  91891. * Random color of each particle after it has been emitted, between color1 and color2 vectors
  91892. */
  91893. color2: Color4;
  91894. /**
  91895. * Color the particle will have at the end of its lifetime
  91896. */
  91897. colorDead: Color4;
  91898. /**
  91899. * An optional mask to filter some colors out of the texture, or filter a part of the alpha channel
  91900. */
  91901. textureMask: Color4;
  91902. /**
  91903. * The particle emitter type defines the emitter used by the particle system.
  91904. * It can be for example box, sphere, or cone...
  91905. */
  91906. particleEmitterType: IParticleEmitterType;
  91907. /** @hidden */
  91908. _isSubEmitter: boolean;
  91909. /**
  91910. * Gets or sets the billboard mode to use when isBillboardBased = true.
  91911. * Value can be: ParticleSystem.BILLBOARDMODE_ALL, ParticleSystem.BILLBOARDMODE_Y, ParticleSystem.BILLBOARDMODE_STRETCHED
  91912. */
  91913. billboardMode: number;
  91914. protected _isBillboardBased: boolean;
  91915. /**
  91916. * Gets or sets a boolean indicating if the particles must be rendered as billboard or aligned with the direction
  91917. */
  91918. get isBillboardBased(): boolean;
  91919. set isBillboardBased(value: boolean);
  91920. /**
  91921. * The scene the particle system belongs to.
  91922. */
  91923. protected _scene: Nullable<Scene>;
  91924. /**
  91925. * The engine the particle system belongs to.
  91926. */
  91927. protected _engine: ThinEngine;
  91928. /**
  91929. * Local cache of defines for image processing.
  91930. */
  91931. protected _imageProcessingConfigurationDefines: ImageProcessingConfigurationDefines;
  91932. /**
  91933. * Default configuration related to image processing available in the standard Material.
  91934. */
  91935. protected _imageProcessingConfiguration: Nullable<ImageProcessingConfiguration>;
  91936. /**
  91937. * Gets the image processing configuration used either in this material.
  91938. */
  91939. get imageProcessingConfiguration(): Nullable<ImageProcessingConfiguration>;
  91940. /**
  91941. * Sets the Default image processing configuration used either in the this material.
  91942. *
  91943. * If sets to null, the scene one is in use.
  91944. */
  91945. set imageProcessingConfiguration(value: Nullable<ImageProcessingConfiguration>);
  91946. /**
  91947. * Attaches a new image processing configuration to the Standard Material.
  91948. * @param configuration
  91949. */
  91950. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  91951. /** @hidden */
  91952. protected _reset(): void;
  91953. /** @hidden */
  91954. protected _removeGradientAndTexture(gradient: number, gradients: Nullable<IValueGradient[]>, texture: Nullable<RawTexture>): BaseParticleSystem;
  91955. /**
  91956. * Instantiates a particle system.
  91957. * 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.
  91958. * @param name The name of the particle system
  91959. */
  91960. constructor(name: string);
  91961. /**
  91962. * Creates a Point Emitter for the particle system (emits directly from the emitter position)
  91963. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  91964. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  91965. * @returns the emitter
  91966. */
  91967. createPointEmitter(direction1: Vector3, direction2: Vector3): PointParticleEmitter;
  91968. /**
  91969. * Creates a Hemisphere Emitter for the particle system (emits along the hemisphere radius)
  91970. * @param radius The radius of the hemisphere to emit from
  91971. * @param radiusRange The range of the hemisphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  91972. * @returns the emitter
  91973. */
  91974. createHemisphericEmitter(radius?: number, radiusRange?: number): HemisphericParticleEmitter;
  91975. /**
  91976. * Creates a Sphere Emitter for the particle system (emits along the sphere radius)
  91977. * @param radius The radius of the sphere to emit from
  91978. * @param radiusRange The range of the sphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  91979. * @returns the emitter
  91980. */
  91981. createSphereEmitter(radius?: number, radiusRange?: number): SphereParticleEmitter;
  91982. /**
  91983. * Creates a Directed Sphere Emitter for the particle system (emits between direction1 and direction2)
  91984. * @param radius The radius of the sphere to emit from
  91985. * @param direction1 Particles are emitted between the direction1 and direction2 from within the sphere
  91986. * @param direction2 Particles are emitted between the direction1 and direction2 from within the sphere
  91987. * @returns the emitter
  91988. */
  91989. createDirectedSphereEmitter(radius?: number, direction1?: Vector3, direction2?: Vector3): SphereDirectedParticleEmitter;
  91990. /**
  91991. * Creates a Cylinder Emitter for the particle system (emits from the cylinder to the particle position)
  91992. * @param radius The radius of the emission cylinder
  91993. * @param height The height of the emission cylinder
  91994. * @param radiusRange The range of emission [0-1] 0 Surface only, 1 Entire Radius
  91995. * @param directionRandomizer How much to randomize the particle direction [0-1]
  91996. * @returns the emitter
  91997. */
  91998. createCylinderEmitter(radius?: number, height?: number, radiusRange?: number, directionRandomizer?: number): CylinderParticleEmitter;
  91999. /**
  92000. * Creates a Directed Cylinder Emitter for the particle system (emits between direction1 and direction2)
  92001. * @param radius The radius of the cylinder to emit from
  92002. * @param height The height of the emission cylinder
  92003. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  92004. * @param direction1 Particles are emitted between the direction1 and direction2 from within the cylinder
  92005. * @param direction2 Particles are emitted between the direction1 and direction2 from within the cylinder
  92006. * @returns the emitter
  92007. */
  92008. createDirectedCylinderEmitter(radius?: number, height?: number, radiusRange?: number, direction1?: Vector3, direction2?: Vector3): CylinderDirectedParticleEmitter;
  92009. /**
  92010. * Creates a Cone Emitter for the particle system (emits from the cone to the particle position)
  92011. * @param radius The radius of the cone to emit from
  92012. * @param angle The base angle of the cone
  92013. * @returns the emitter
  92014. */
  92015. createConeEmitter(radius?: number, angle?: number): ConeParticleEmitter;
  92016. /**
  92017. * Creates a Box Emitter for the particle system. (emits between direction1 and direction2 from withing the box defined by minEmitBox and maxEmitBox)
  92018. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  92019. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  92020. * @param minEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  92021. * @param maxEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  92022. * @returns the emitter
  92023. */
  92024. createBoxEmitter(direction1: Vector3, direction2: Vector3, minEmitBox: Vector3, maxEmitBox: Vector3): BoxParticleEmitter;
  92025. }
  92026. }
  92027. declare module BABYLON {
  92028. /**
  92029. * Type of sub emitter
  92030. */
  92031. export enum SubEmitterType {
  92032. /**
  92033. * Attached to the particle over it's lifetime
  92034. */
  92035. ATTACHED = 0,
  92036. /**
  92037. * Created when the particle dies
  92038. */
  92039. END = 1
  92040. }
  92041. /**
  92042. * Sub emitter class used to emit particles from an existing particle
  92043. */
  92044. export class SubEmitter {
  92045. /**
  92046. * the particle system to be used by the sub emitter
  92047. */
  92048. particleSystem: ParticleSystem;
  92049. /**
  92050. * Type of the submitter (Default: END)
  92051. */
  92052. type: SubEmitterType;
  92053. /**
  92054. * 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)
  92055. * Note: This only is supported when using an emitter of type Mesh
  92056. */
  92057. inheritDirection: boolean;
  92058. /**
  92059. * How much of the attached particles speed should be added to the sub emitted particle (default: 0)
  92060. */
  92061. inheritedVelocityAmount: number;
  92062. /**
  92063. * Creates a sub emitter
  92064. * @param particleSystem the particle system to be used by the sub emitter
  92065. */
  92066. constructor(
  92067. /**
  92068. * the particle system to be used by the sub emitter
  92069. */
  92070. particleSystem: ParticleSystem);
  92071. /**
  92072. * Clones the sub emitter
  92073. * @returns the cloned sub emitter
  92074. */
  92075. clone(): SubEmitter;
  92076. /**
  92077. * Serialize current object to a JSON object
  92078. * @returns the serialized object
  92079. */
  92080. serialize(): any;
  92081. /** @hidden */
  92082. static _ParseParticleSystem(system: any, sceneOrEngine: Scene | ThinEngine, rootUrl: string): ParticleSystem;
  92083. /**
  92084. * Creates a new SubEmitter from a serialized JSON version
  92085. * @param serializationObject defines the JSON object to read from
  92086. * @param sceneOrEngine defines the hosting scene or the hosting engine
  92087. * @param rootUrl defines the rootUrl for data loading
  92088. * @returns a new SubEmitter
  92089. */
  92090. static Parse(serializationObject: any, sceneOrEngine: Scene | ThinEngine, rootUrl: string): SubEmitter;
  92091. /** Release associated resources */
  92092. dispose(): void;
  92093. }
  92094. }
  92095. declare module BABYLON {
  92096. /** @hidden */
  92097. export var imageProcessingDeclaration: {
  92098. name: string;
  92099. shader: string;
  92100. };
  92101. }
  92102. declare module BABYLON {
  92103. /** @hidden */
  92104. export var imageProcessingFunctions: {
  92105. name: string;
  92106. shader: string;
  92107. };
  92108. }
  92109. declare module BABYLON {
  92110. /** @hidden */
  92111. export var particlesPixelShader: {
  92112. name: string;
  92113. shader: string;
  92114. };
  92115. }
  92116. declare module BABYLON {
  92117. /** @hidden */
  92118. export var particlesVertexShader: {
  92119. name: string;
  92120. shader: string;
  92121. };
  92122. }
  92123. declare module BABYLON {
  92124. /**
  92125. * Interface used to define entities containing multiple clip planes
  92126. */
  92127. export interface IClipPlanesHolder {
  92128. /**
  92129. * Gets or sets the active clipplane 1
  92130. */
  92131. clipPlane: Nullable<Plane>;
  92132. /**
  92133. * Gets or sets the active clipplane 2
  92134. */
  92135. clipPlane2: Nullable<Plane>;
  92136. /**
  92137. * Gets or sets the active clipplane 3
  92138. */
  92139. clipPlane3: Nullable<Plane>;
  92140. /**
  92141. * Gets or sets the active clipplane 4
  92142. */
  92143. clipPlane4: Nullable<Plane>;
  92144. /**
  92145. * Gets or sets the active clipplane 5
  92146. */
  92147. clipPlane5: Nullable<Plane>;
  92148. /**
  92149. * Gets or sets the active clipplane 6
  92150. */
  92151. clipPlane6: Nullable<Plane>;
  92152. }
  92153. }
  92154. declare module BABYLON {
  92155. /**
  92156. * "Static Class" containing a few commonly used helper while dealing with material for rendering purpose.
  92157. *
  92158. * It is complementary with MaterialHelper but provides completely independent functions (for tree shaking sake)
  92159. *
  92160. * This works by convention in BabylonJS but is meant to be use only with shader following the in place naming rules and conventions.
  92161. */
  92162. export class ThinMaterialHelper {
  92163. /**
  92164. * Binds the clip plane information from the holder to the effect.
  92165. * @param effect The effect we are binding the data to
  92166. * @param holder The entity containing the clip plane information
  92167. */
  92168. static BindClipPlane(effect: Effect, holder: IClipPlanesHolder): void;
  92169. }
  92170. }
  92171. declare module BABYLON {
  92172. interface ThinEngine {
  92173. /**
  92174. * Sets alpha constants used by some alpha blending modes
  92175. * @param r defines the red component
  92176. * @param g defines the green component
  92177. * @param b defines the blue component
  92178. * @param a defines the alpha component
  92179. */
  92180. setAlphaConstants(r: number, g: number, b: number, a: number): void;
  92181. /**
  92182. * Sets the current alpha mode
  92183. * @param mode defines the mode to use (one of the Engine.ALPHA_XXX)
  92184. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  92185. * @see https://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  92186. */
  92187. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  92188. /**
  92189. * Gets the current alpha mode
  92190. * @see https://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  92191. * @returns the current alpha mode
  92192. */
  92193. getAlphaMode(): number;
  92194. /**
  92195. * Sets the current alpha equation
  92196. * @param equation defines the equation to use (one of the Engine.ALPHA_EQUATION_XXX)
  92197. */
  92198. setAlphaEquation(equation: number): void;
  92199. /**
  92200. * Gets the current alpha equation.
  92201. * @returns the current alpha equation
  92202. */
  92203. getAlphaEquation(): number;
  92204. }
  92205. }
  92206. declare module BABYLON {
  92207. /**
  92208. * This represents a particle system in Babylon.
  92209. * 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.
  92210. * Particles can take different shapes while emitted like box, sphere, cone or you can write your custom function.
  92211. * @example https://doc.babylonjs.com/babylon101/particles
  92212. */
  92213. export class ParticleSystem extends BaseParticleSystem implements IDisposable, IAnimatable, IParticleSystem {
  92214. /**
  92215. * Billboard mode will only apply to Y axis
  92216. */
  92217. static readonly BILLBOARDMODE_Y: number;
  92218. /**
  92219. * Billboard mode will apply to all axes
  92220. */
  92221. static readonly BILLBOARDMODE_ALL: number;
  92222. /**
  92223. * Special billboard mode where the particle will be biilboard to the camera but rotated to align with direction
  92224. */
  92225. static readonly BILLBOARDMODE_STRETCHED: number;
  92226. /**
  92227. * This function can be defined to provide custom update for active particles.
  92228. * This function will be called instead of regular update (age, position, color, etc.).
  92229. * Do not forget that this function will be called on every frame so try to keep it simple and fast :)
  92230. */
  92231. updateFunction: (particles: Particle[]) => void;
  92232. private _emitterWorldMatrix;
  92233. /**
  92234. * This function can be defined to specify initial direction for every new particle.
  92235. * It by default use the emitterType defined function
  92236. */
  92237. startDirectionFunction: (worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean) => void;
  92238. /**
  92239. * This function can be defined to specify initial position for every new particle.
  92240. * It by default use the emitterType defined function
  92241. */
  92242. startPositionFunction: (worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean) => void;
  92243. /**
  92244. * @hidden
  92245. */
  92246. _inheritedVelocityOffset: Vector3;
  92247. /**
  92248. * An event triggered when the system is disposed
  92249. */
  92250. onDisposeObservable: Observable<IParticleSystem>;
  92251. private _onDisposeObserver;
  92252. /**
  92253. * Sets a callback that will be triggered when the system is disposed
  92254. */
  92255. set onDispose(callback: () => void);
  92256. private _particles;
  92257. private _epsilon;
  92258. private _capacity;
  92259. private _stockParticles;
  92260. private _newPartsExcess;
  92261. private _vertexData;
  92262. private _vertexBuffer;
  92263. private _vertexBuffers;
  92264. private _spriteBuffer;
  92265. private _indexBuffer;
  92266. private _effect;
  92267. private _customEffect;
  92268. private _cachedDefines;
  92269. private _scaledColorStep;
  92270. private _colorDiff;
  92271. private _scaledDirection;
  92272. private _scaledGravity;
  92273. private _currentRenderId;
  92274. private _alive;
  92275. private _useInstancing;
  92276. private _started;
  92277. private _stopped;
  92278. private _actualFrame;
  92279. private _scaledUpdateSpeed;
  92280. private _vertexBufferSize;
  92281. /** @hidden */
  92282. _currentEmitRateGradient: Nullable<FactorGradient>;
  92283. /** @hidden */
  92284. _currentEmitRate1: number;
  92285. /** @hidden */
  92286. _currentEmitRate2: number;
  92287. /** @hidden */
  92288. _currentStartSizeGradient: Nullable<FactorGradient>;
  92289. /** @hidden */
  92290. _currentStartSize1: number;
  92291. /** @hidden */
  92292. _currentStartSize2: number;
  92293. private readonly _rawTextureWidth;
  92294. private _rampGradientsTexture;
  92295. private _useRampGradients;
  92296. /** Gets or sets a matrix to use to compute projection */
  92297. defaultProjectionMatrix: Matrix;
  92298. /** Gets or sets a matrix to use to compute view */
  92299. defaultViewMatrix: Matrix;
  92300. /** Gets or sets a boolean indicating that ramp gradients must be used
  92301. * @see https://doc.babylonjs.com/babylon101/particles#ramp-gradients
  92302. */
  92303. get useRampGradients(): boolean;
  92304. set useRampGradients(value: boolean);
  92305. /**
  92306. * 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.
  92307. * 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: [])
  92308. */
  92309. subEmitters: Array<ParticleSystem | SubEmitter | Array<SubEmitter>>;
  92310. private _subEmitters;
  92311. /**
  92312. * @hidden
  92313. * If the particle systems emitter should be disposed when the particle system is disposed
  92314. */
  92315. _disposeEmitterOnDispose: boolean;
  92316. /**
  92317. * The current active Sub-systems, this property is used by the root particle system only.
  92318. */
  92319. activeSubSystems: Array<ParticleSystem>;
  92320. /**
  92321. * Specifies if the particles are updated in emitter local space or world space
  92322. */
  92323. isLocal: boolean;
  92324. private _rootParticleSystem;
  92325. /**
  92326. * Gets the current list of active particles
  92327. */
  92328. get particles(): Particle[];
  92329. /**
  92330. * Gets the number of particles active at the same time.
  92331. * @returns The number of active particles.
  92332. */
  92333. getActiveCount(): number;
  92334. /**
  92335. * Returns the string "ParticleSystem"
  92336. * @returns a string containing the class name
  92337. */
  92338. getClassName(): string;
  92339. /**
  92340. * Gets a boolean indicating that the system is stopping
  92341. * @returns true if the system is currently stopping
  92342. */
  92343. isStopping(): boolean;
  92344. /**
  92345. * Gets the custom effect used to render the particles
  92346. * @param blendMode Blend mode for which the effect should be retrieved
  92347. * @returns The effect
  92348. */
  92349. getCustomEffect(blendMode?: number): Nullable<Effect>;
  92350. /**
  92351. * Sets the custom effect used to render the particles
  92352. * @param effect The effect to set
  92353. * @param blendMode Blend mode for which the effect should be set
  92354. */
  92355. setCustomEffect(effect: Nullable<Effect>, blendMode?: number): void;
  92356. /** @hidden */
  92357. private _onBeforeDrawParticlesObservable;
  92358. /**
  92359. * Observable that will be called just before the particles are drawn
  92360. */
  92361. get onBeforeDrawParticlesObservable(): Observable<Nullable<Effect>>;
  92362. /**
  92363. * Gets the name of the particle vertex shader
  92364. */
  92365. get vertexShaderName(): string;
  92366. /**
  92367. * Instantiates a particle system.
  92368. * 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.
  92369. * @param name The name of the particle system
  92370. * @param capacity The max number of particles alive at the same time
  92371. * @param sceneOrEngine The scene the particle system belongs to or the engine to use if no scene
  92372. * @param customEffect a custom effect used to change the way particles are rendered by default
  92373. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  92374. * @param epsilon Offset used to render the particles
  92375. */
  92376. constructor(name: string, capacity: number, sceneOrEngine: Scene | ThinEngine, customEffect?: Nullable<Effect>, isAnimationSheetEnabled?: boolean, epsilon?: number);
  92377. private _addFactorGradient;
  92378. private _removeFactorGradient;
  92379. /**
  92380. * Adds a new life time gradient
  92381. * @param gradient defines the gradient to use (between 0 and 1)
  92382. * @param factor defines the life time factor to affect to the specified gradient
  92383. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  92384. * @returns the current particle system
  92385. */
  92386. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  92387. /**
  92388. * Remove a specific life time gradient
  92389. * @param gradient defines the gradient to remove
  92390. * @returns the current particle system
  92391. */
  92392. removeLifeTimeGradient(gradient: number): IParticleSystem;
  92393. /**
  92394. * Adds a new size gradient
  92395. * @param gradient defines the gradient to use (between 0 and 1)
  92396. * @param factor defines the size factor to affect to the specified gradient
  92397. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  92398. * @returns the current particle system
  92399. */
  92400. addSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  92401. /**
  92402. * Remove a specific size gradient
  92403. * @param gradient defines the gradient to remove
  92404. * @returns the current particle system
  92405. */
  92406. removeSizeGradient(gradient: number): IParticleSystem;
  92407. /**
  92408. * Adds a new color remap gradient
  92409. * @param gradient defines the gradient to use (between 0 and 1)
  92410. * @param min defines the color remap minimal range
  92411. * @param max defines the color remap maximal range
  92412. * @returns the current particle system
  92413. */
  92414. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  92415. /**
  92416. * Remove a specific color remap gradient
  92417. * @param gradient defines the gradient to remove
  92418. * @returns the current particle system
  92419. */
  92420. removeColorRemapGradient(gradient: number): IParticleSystem;
  92421. /**
  92422. * Adds a new alpha remap gradient
  92423. * @param gradient defines the gradient to use (between 0 and 1)
  92424. * @param min defines the alpha remap minimal range
  92425. * @param max defines the alpha remap maximal range
  92426. * @returns the current particle system
  92427. */
  92428. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  92429. /**
  92430. * Remove a specific alpha remap gradient
  92431. * @param gradient defines the gradient to remove
  92432. * @returns the current particle system
  92433. */
  92434. removeAlphaRemapGradient(gradient: number): IParticleSystem;
  92435. /**
  92436. * Adds a new angular speed gradient
  92437. * @param gradient defines the gradient to use (between 0 and 1)
  92438. * @param factor defines the angular speed to affect to the specified gradient
  92439. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  92440. * @returns the current particle system
  92441. */
  92442. addAngularSpeedGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  92443. /**
  92444. * Remove a specific angular speed gradient
  92445. * @param gradient defines the gradient to remove
  92446. * @returns the current particle system
  92447. */
  92448. removeAngularSpeedGradient(gradient: number): IParticleSystem;
  92449. /**
  92450. * Adds a new velocity gradient
  92451. * @param gradient defines the gradient to use (between 0 and 1)
  92452. * @param factor defines the velocity to affect to the specified gradient
  92453. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  92454. * @returns the current particle system
  92455. */
  92456. addVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  92457. /**
  92458. * Remove a specific velocity gradient
  92459. * @param gradient defines the gradient to remove
  92460. * @returns the current particle system
  92461. */
  92462. removeVelocityGradient(gradient: number): IParticleSystem;
  92463. /**
  92464. * Adds a new limit velocity gradient
  92465. * @param gradient defines the gradient to use (between 0 and 1)
  92466. * @param factor defines the limit velocity value to affect to the specified gradient
  92467. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  92468. * @returns the current particle system
  92469. */
  92470. addLimitVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  92471. /**
  92472. * Remove a specific limit velocity gradient
  92473. * @param gradient defines the gradient to remove
  92474. * @returns the current particle system
  92475. */
  92476. removeLimitVelocityGradient(gradient: number): IParticleSystem;
  92477. /**
  92478. * Adds a new drag gradient
  92479. * @param gradient defines the gradient to use (between 0 and 1)
  92480. * @param factor defines the drag value to affect to the specified gradient
  92481. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  92482. * @returns the current particle system
  92483. */
  92484. addDragGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  92485. /**
  92486. * Remove a specific drag gradient
  92487. * @param gradient defines the gradient to remove
  92488. * @returns the current particle system
  92489. */
  92490. removeDragGradient(gradient: number): IParticleSystem;
  92491. /**
  92492. * Adds a new emit rate gradient (please note that this will only work if you set the targetStopDuration property)
  92493. * @param gradient defines the gradient to use (between 0 and 1)
  92494. * @param factor defines the emit rate value to affect to the specified gradient
  92495. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  92496. * @returns the current particle system
  92497. */
  92498. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  92499. /**
  92500. * Remove a specific emit rate gradient
  92501. * @param gradient defines the gradient to remove
  92502. * @returns the current particle system
  92503. */
  92504. removeEmitRateGradient(gradient: number): IParticleSystem;
  92505. /**
  92506. * Adds a new start size gradient (please note that this will only work if you set the targetStopDuration property)
  92507. * @param gradient defines the gradient to use (between 0 and 1)
  92508. * @param factor defines the start size value to affect to the specified gradient
  92509. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  92510. * @returns the current particle system
  92511. */
  92512. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  92513. /**
  92514. * Remove a specific start size gradient
  92515. * @param gradient defines the gradient to remove
  92516. * @returns the current particle system
  92517. */
  92518. removeStartSizeGradient(gradient: number): IParticleSystem;
  92519. private _createRampGradientTexture;
  92520. /**
  92521. * Gets the current list of ramp gradients.
  92522. * You must use addRampGradient and removeRampGradient to udpate this list
  92523. * @returns the list of ramp gradients
  92524. */
  92525. getRampGradients(): Nullable<Array<Color3Gradient>>;
  92526. /** Force the system to rebuild all gradients that need to be resync */
  92527. forceRefreshGradients(): void;
  92528. private _syncRampGradientTexture;
  92529. /**
  92530. * Adds a new ramp gradient used to remap particle colors
  92531. * @param gradient defines the gradient to use (between 0 and 1)
  92532. * @param color defines the color to affect to the specified gradient
  92533. * @returns the current particle system
  92534. */
  92535. addRampGradient(gradient: number, color: Color3): ParticleSystem;
  92536. /**
  92537. * Remove a specific ramp gradient
  92538. * @param gradient defines the gradient to remove
  92539. * @returns the current particle system
  92540. */
  92541. removeRampGradient(gradient: number): ParticleSystem;
  92542. /**
  92543. * Adds a new color gradient
  92544. * @param gradient defines the gradient to use (between 0 and 1)
  92545. * @param color1 defines the color to affect to the specified gradient
  92546. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  92547. * @returns this particle system
  92548. */
  92549. addColorGradient(gradient: number, color1: Color4, color2?: Color4): IParticleSystem;
  92550. /**
  92551. * Remove a specific color gradient
  92552. * @param gradient defines the gradient to remove
  92553. * @returns this particle system
  92554. */
  92555. removeColorGradient(gradient: number): IParticleSystem;
  92556. private _fetchR;
  92557. protected _reset(): void;
  92558. private _resetEffect;
  92559. private _createVertexBuffers;
  92560. private _createIndexBuffer;
  92561. /**
  92562. * Gets the maximum number of particles active at the same time.
  92563. * @returns The max number of active particles.
  92564. */
  92565. getCapacity(): number;
  92566. /**
  92567. * Gets whether there are still active particles in the system.
  92568. * @returns True if it is alive, otherwise false.
  92569. */
  92570. isAlive(): boolean;
  92571. /**
  92572. * Gets if the system has been started. (Note: this will still be true after stop is called)
  92573. * @returns True if it has been started, otherwise false.
  92574. */
  92575. isStarted(): boolean;
  92576. private _prepareSubEmitterInternalArray;
  92577. /**
  92578. * Starts the particle system and begins to emit
  92579. * @param delay defines the delay in milliseconds before starting the system (this.startDelay by default)
  92580. */
  92581. start(delay?: number): void;
  92582. /**
  92583. * Stops the particle system.
  92584. * @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.
  92585. */
  92586. stop(stopSubEmitters?: boolean): void;
  92587. /**
  92588. * Remove all active particles
  92589. */
  92590. reset(): void;
  92591. /**
  92592. * @hidden (for internal use only)
  92593. */
  92594. _appendParticleVertex(index: number, particle: Particle, offsetX: number, offsetY: number): void;
  92595. /**
  92596. * "Recycles" one of the particle by copying it back to the "stock" of particles and removing it from the active list.
  92597. * Its lifetime will start back at 0.
  92598. */
  92599. recycleParticle: (particle: Particle) => void;
  92600. private _stopSubEmitters;
  92601. private _createParticle;
  92602. private _removeFromRoot;
  92603. private _emitFromParticle;
  92604. private _update;
  92605. /** @hidden */
  92606. static _GetAttributeNamesOrOptions(isAnimationSheetEnabled?: boolean, isBillboardBased?: boolean, useRampGradients?: boolean): string[];
  92607. /** @hidden */
  92608. static _GetEffectCreationOptions(isAnimationSheetEnabled?: boolean): string[];
  92609. /**
  92610. * Fill the defines array according to the current settings of the particle system
  92611. * @param defines Array to be updated
  92612. * @param blendMode blend mode to take into account when updating the array
  92613. */
  92614. fillDefines(defines: Array<string>, blendMode: number): void;
  92615. /**
  92616. * Fill the uniforms, attributes and samplers arrays according to the current settings of the particle system
  92617. * @param uniforms Uniforms array to fill
  92618. * @param attributes Attributes array to fill
  92619. * @param samplers Samplers array to fill
  92620. */
  92621. fillUniformsAttributesAndSamplerNames(uniforms: Array<string>, attributes: Array<string>, samplers: Array<string>): void;
  92622. /** @hidden */
  92623. private _getEffect;
  92624. /**
  92625. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  92626. * @param preWarmOnly will prevent the system from updating the vertex buffer (default is false)
  92627. */
  92628. animate(preWarmOnly?: boolean): void;
  92629. private _appendParticleVertices;
  92630. /**
  92631. * Rebuilds the particle system.
  92632. */
  92633. rebuild(): void;
  92634. /**
  92635. * Is this system ready to be used/rendered
  92636. * @return true if the system is ready
  92637. */
  92638. isReady(): boolean;
  92639. private _render;
  92640. /**
  92641. * Renders the particle system in its current state.
  92642. * @returns the current number of particles
  92643. */
  92644. render(): number;
  92645. /**
  92646. * Disposes the particle system and free the associated resources
  92647. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  92648. */
  92649. dispose(disposeTexture?: boolean): void;
  92650. /**
  92651. * Clones the particle system.
  92652. * @param name The name of the cloned object
  92653. * @param newEmitter The new emitter to use
  92654. * @returns the cloned particle system
  92655. */
  92656. clone(name: string, newEmitter: any): ParticleSystem;
  92657. /**
  92658. * Serializes the particle system to a JSON object
  92659. * @param serializeTexture defines if the texture must be serialized as well
  92660. * @returns the JSON object
  92661. */
  92662. serialize(serializeTexture?: boolean): any;
  92663. /** @hidden */
  92664. static _Serialize(serializationObject: any, particleSystem: IParticleSystem, serializeTexture: boolean): void;
  92665. /** @hidden */
  92666. static _Parse(parsedParticleSystem: any, particleSystem: IParticleSystem, sceneOrEngine: Scene | ThinEngine, rootUrl: string): void;
  92667. /**
  92668. * Parses a JSON object to create a particle system.
  92669. * @param parsedParticleSystem The JSON object to parse
  92670. * @param sceneOrEngine The scene or the engine to create the particle system in
  92671. * @param rootUrl The root url to use to load external dependencies like texture
  92672. * @param doNotStart Ignore the preventAutoStart attribute and does not start
  92673. * @returns the Parsed particle system
  92674. */
  92675. static Parse(parsedParticleSystem: any, sceneOrEngine: Scene | ThinEngine, rootUrl: string, doNotStart?: boolean): ParticleSystem;
  92676. }
  92677. }
  92678. declare module BABYLON {
  92679. /**
  92680. * A particle represents one of the element emitted by a particle system.
  92681. * This is mainly define by its coordinates, direction, velocity and age.
  92682. */
  92683. export class Particle {
  92684. /**
  92685. * The particle system the particle belongs to.
  92686. */
  92687. particleSystem: ParticleSystem;
  92688. private static _Count;
  92689. /**
  92690. * Unique ID of the particle
  92691. */
  92692. id: number;
  92693. /**
  92694. * The world position of the particle in the scene.
  92695. */
  92696. position: Vector3;
  92697. /**
  92698. * The world direction of the particle in the scene.
  92699. */
  92700. direction: Vector3;
  92701. /**
  92702. * The color of the particle.
  92703. */
  92704. color: Color4;
  92705. /**
  92706. * The color change of the particle per step.
  92707. */
  92708. colorStep: Color4;
  92709. /**
  92710. * Defines how long will the life of the particle be.
  92711. */
  92712. lifeTime: number;
  92713. /**
  92714. * The current age of the particle.
  92715. */
  92716. age: number;
  92717. /**
  92718. * The current size of the particle.
  92719. */
  92720. size: number;
  92721. /**
  92722. * The current scale of the particle.
  92723. */
  92724. scale: Vector2;
  92725. /**
  92726. * The current angle of the particle.
  92727. */
  92728. angle: number;
  92729. /**
  92730. * Defines how fast is the angle changing.
  92731. */
  92732. angularSpeed: number;
  92733. /**
  92734. * Defines the cell index used by the particle to be rendered from a sprite.
  92735. */
  92736. cellIndex: number;
  92737. /**
  92738. * The information required to support color remapping
  92739. */
  92740. remapData: Vector4;
  92741. /** @hidden */
  92742. _randomCellOffset?: number;
  92743. /** @hidden */
  92744. _initialDirection: Nullable<Vector3>;
  92745. /** @hidden */
  92746. _attachedSubEmitters: Nullable<Array<SubEmitter>>;
  92747. /** @hidden */
  92748. _initialStartSpriteCellID: number;
  92749. /** @hidden */
  92750. _initialEndSpriteCellID: number;
  92751. /** @hidden */
  92752. _currentColorGradient: Nullable<ColorGradient>;
  92753. /** @hidden */
  92754. _currentColor1: Color4;
  92755. /** @hidden */
  92756. _currentColor2: Color4;
  92757. /** @hidden */
  92758. _currentSizeGradient: Nullable<FactorGradient>;
  92759. /** @hidden */
  92760. _currentSize1: number;
  92761. /** @hidden */
  92762. _currentSize2: number;
  92763. /** @hidden */
  92764. _currentAngularSpeedGradient: Nullable<FactorGradient>;
  92765. /** @hidden */
  92766. _currentAngularSpeed1: number;
  92767. /** @hidden */
  92768. _currentAngularSpeed2: number;
  92769. /** @hidden */
  92770. _currentVelocityGradient: Nullable<FactorGradient>;
  92771. /** @hidden */
  92772. _currentVelocity1: number;
  92773. /** @hidden */
  92774. _currentVelocity2: number;
  92775. /** @hidden */
  92776. _currentLimitVelocityGradient: Nullable<FactorGradient>;
  92777. /** @hidden */
  92778. _currentLimitVelocity1: number;
  92779. /** @hidden */
  92780. _currentLimitVelocity2: number;
  92781. /** @hidden */
  92782. _currentDragGradient: Nullable<FactorGradient>;
  92783. /** @hidden */
  92784. _currentDrag1: number;
  92785. /** @hidden */
  92786. _currentDrag2: number;
  92787. /** @hidden */
  92788. _randomNoiseCoordinates1: Vector3;
  92789. /** @hidden */
  92790. _randomNoiseCoordinates2: Vector3;
  92791. /** @hidden */
  92792. _localPosition?: Vector3;
  92793. /**
  92794. * Creates a new instance Particle
  92795. * @param particleSystem the particle system the particle belongs to
  92796. */
  92797. constructor(
  92798. /**
  92799. * The particle system the particle belongs to.
  92800. */
  92801. particleSystem: ParticleSystem);
  92802. private updateCellInfoFromSystem;
  92803. /**
  92804. * Defines how the sprite cell index is updated for the particle
  92805. */
  92806. updateCellIndex(): void;
  92807. /** @hidden */
  92808. _inheritParticleInfoToSubEmitter(subEmitter: SubEmitter): void;
  92809. /** @hidden */
  92810. _inheritParticleInfoToSubEmitters(): void;
  92811. /** @hidden */
  92812. _reset(): void;
  92813. /**
  92814. * Copy the properties of particle to another one.
  92815. * @param other the particle to copy the information to.
  92816. */
  92817. copyTo(other: Particle): void;
  92818. }
  92819. }
  92820. declare module BABYLON {
  92821. /**
  92822. * Particle emitter represents a volume emitting particles.
  92823. * This is the responsibility of the implementation to define the volume shape like cone/sphere/box.
  92824. */
  92825. export interface IParticleEmitterType {
  92826. /**
  92827. * Called by the particle System when the direction is computed for the created particle.
  92828. * @param worldMatrix is the world matrix of the particle system
  92829. * @param directionToUpdate is the direction vector to update with the result
  92830. * @param particle is the particle we are computed the direction for
  92831. * @param isLocal defines if the direction should be set in local space
  92832. */
  92833. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  92834. /**
  92835. * Called by the particle System when the position is computed for the created particle.
  92836. * @param worldMatrix is the world matrix of the particle system
  92837. * @param positionToUpdate is the position vector to update with the result
  92838. * @param particle is the particle we are computed the position for
  92839. * @param isLocal defines if the position should be set in local space
  92840. */
  92841. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  92842. /**
  92843. * Clones the current emitter and returns a copy of it
  92844. * @returns the new emitter
  92845. */
  92846. clone(): IParticleEmitterType;
  92847. /**
  92848. * Called by the GPUParticleSystem to setup the update shader
  92849. * @param effect defines the update shader
  92850. */
  92851. applyToShader(effect: Effect): void;
  92852. /**
  92853. * Returns a string to use to update the GPU particles update shader
  92854. * @returns the effect defines string
  92855. */
  92856. getEffectDefines(): string;
  92857. /**
  92858. * Returns a string representing the class name
  92859. * @returns a string containing the class name
  92860. */
  92861. getClassName(): string;
  92862. /**
  92863. * Serializes the particle system to a JSON object.
  92864. * @returns the JSON object
  92865. */
  92866. serialize(): any;
  92867. /**
  92868. * Parse properties from a JSON object
  92869. * @param serializationObject defines the JSON object
  92870. * @param scene defines the hosting scene
  92871. */
  92872. parse(serializationObject: any, scene: Nullable<Scene>): void;
  92873. }
  92874. }
  92875. declare module BABYLON {
  92876. /**
  92877. * Particle emitter emitting particles from the inside of a box.
  92878. * It emits the particles randomly between 2 given directions.
  92879. */
  92880. export class BoxParticleEmitter implements IParticleEmitterType {
  92881. /**
  92882. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  92883. */
  92884. direction1: Vector3;
  92885. /**
  92886. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  92887. */
  92888. direction2: Vector3;
  92889. /**
  92890. * 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.
  92891. */
  92892. minEmitBox: Vector3;
  92893. /**
  92894. * 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.
  92895. */
  92896. maxEmitBox: Vector3;
  92897. /**
  92898. * Creates a new instance BoxParticleEmitter
  92899. */
  92900. constructor();
  92901. /**
  92902. * Called by the particle System when the direction is computed for the created particle.
  92903. * @param worldMatrix is the world matrix of the particle system
  92904. * @param directionToUpdate is the direction vector to update with the result
  92905. * @param particle is the particle we are computed the direction for
  92906. * @param isLocal defines if the direction should be set in local space
  92907. */
  92908. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  92909. /**
  92910. * Called by the particle System when the position is computed for the created particle.
  92911. * @param worldMatrix is the world matrix of the particle system
  92912. * @param positionToUpdate is the position vector to update with the result
  92913. * @param particle is the particle we are computed the position for
  92914. * @param isLocal defines if the position should be set in local space
  92915. */
  92916. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  92917. /**
  92918. * Clones the current emitter and returns a copy of it
  92919. * @returns the new emitter
  92920. */
  92921. clone(): BoxParticleEmitter;
  92922. /**
  92923. * Called by the GPUParticleSystem to setup the update shader
  92924. * @param effect defines the update shader
  92925. */
  92926. applyToShader(effect: Effect): void;
  92927. /**
  92928. * Returns a string to use to update the GPU particles update shader
  92929. * @returns a string containng the defines string
  92930. */
  92931. getEffectDefines(): string;
  92932. /**
  92933. * Returns the string "BoxParticleEmitter"
  92934. * @returns a string containing the class name
  92935. */
  92936. getClassName(): string;
  92937. /**
  92938. * Serializes the particle system to a JSON object.
  92939. * @returns the JSON object
  92940. */
  92941. serialize(): any;
  92942. /**
  92943. * Parse properties from a JSON object
  92944. * @param serializationObject defines the JSON object
  92945. */
  92946. parse(serializationObject: any): void;
  92947. }
  92948. }
  92949. declare module BABYLON {
  92950. /**
  92951. * Particle emitter emitting particles from the inside of a cone.
  92952. * It emits the particles alongside the cone volume from the base to the particle.
  92953. * The emission direction might be randomized.
  92954. */
  92955. export class ConeParticleEmitter implements IParticleEmitterType {
  92956. /** defines how much to randomize the particle direction [0-1] (default is 0) */
  92957. directionRandomizer: number;
  92958. private _radius;
  92959. private _angle;
  92960. private _height;
  92961. /**
  92962. * Gets or sets a value indicating where on the radius the start position should be picked (1 = everywhere, 0 = only surface)
  92963. */
  92964. radiusRange: number;
  92965. /**
  92966. * Gets or sets a value indicating where on the height the start position should be picked (1 = everywhere, 0 = only surface)
  92967. */
  92968. heightRange: number;
  92969. /**
  92970. * Gets or sets a value indicating if all the particles should be emitted from the spawn point only (the base of the cone)
  92971. */
  92972. emitFromSpawnPointOnly: boolean;
  92973. /**
  92974. * Gets or sets the radius of the emission cone
  92975. */
  92976. get radius(): number;
  92977. set radius(value: number);
  92978. /**
  92979. * Gets or sets the angle of the emission cone
  92980. */
  92981. get angle(): number;
  92982. set angle(value: number);
  92983. private _buildHeight;
  92984. /**
  92985. * Creates a new instance ConeParticleEmitter
  92986. * @param radius the radius of the emission cone (1 by default)
  92987. * @param angle the cone base angle (PI by default)
  92988. * @param directionRandomizer defines how much to randomize the particle direction [0-1] (default is 0)
  92989. */
  92990. constructor(radius?: number, angle?: number,
  92991. /** defines how much to randomize the particle direction [0-1] (default is 0) */
  92992. directionRandomizer?: number);
  92993. /**
  92994. * Called by the particle System when the direction is computed for the created particle.
  92995. * @param worldMatrix is the world matrix of the particle system
  92996. * @param directionToUpdate is the direction vector to update with the result
  92997. * @param particle is the particle we are computed the direction for
  92998. * @param isLocal defines if the direction should be set in local space
  92999. */
  93000. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  93001. /**
  93002. * Called by the particle System when the position is computed for the created particle.
  93003. * @param worldMatrix is the world matrix of the particle system
  93004. * @param positionToUpdate is the position vector to update with the result
  93005. * @param particle is the particle we are computed the position for
  93006. * @param isLocal defines if the position should be set in local space
  93007. */
  93008. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  93009. /**
  93010. * Clones the current emitter and returns a copy of it
  93011. * @returns the new emitter
  93012. */
  93013. clone(): ConeParticleEmitter;
  93014. /**
  93015. * Called by the GPUParticleSystem to setup the update shader
  93016. * @param effect defines the update shader
  93017. */
  93018. applyToShader(effect: Effect): void;
  93019. /**
  93020. * Returns a string to use to update the GPU particles update shader
  93021. * @returns a string containng the defines string
  93022. */
  93023. getEffectDefines(): string;
  93024. /**
  93025. * Returns the string "ConeParticleEmitter"
  93026. * @returns a string containing the class name
  93027. */
  93028. getClassName(): string;
  93029. /**
  93030. * Serializes the particle system to a JSON object.
  93031. * @returns the JSON object
  93032. */
  93033. serialize(): any;
  93034. /**
  93035. * Parse properties from a JSON object
  93036. * @param serializationObject defines the JSON object
  93037. */
  93038. parse(serializationObject: any): void;
  93039. }
  93040. }
  93041. declare module BABYLON {
  93042. /**
  93043. * Particle emitter emitting particles from the inside of a cylinder.
  93044. * It emits the particles alongside the cylinder radius. The emission direction might be randomized.
  93045. */
  93046. export class CylinderParticleEmitter implements IParticleEmitterType {
  93047. /**
  93048. * The radius of the emission cylinder.
  93049. */
  93050. radius: number;
  93051. /**
  93052. * The height of the emission cylinder.
  93053. */
  93054. height: number;
  93055. /**
  93056. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  93057. */
  93058. radiusRange: number;
  93059. /**
  93060. * How much to randomize the particle direction [0-1].
  93061. */
  93062. directionRandomizer: number;
  93063. /**
  93064. * Creates a new instance CylinderParticleEmitter
  93065. * @param radius the radius of the emission cylinder (1 by default)
  93066. * @param height the height of the emission cylinder (1 by default)
  93067. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  93068. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  93069. */
  93070. constructor(
  93071. /**
  93072. * The radius of the emission cylinder.
  93073. */
  93074. radius?: number,
  93075. /**
  93076. * The height of the emission cylinder.
  93077. */
  93078. height?: number,
  93079. /**
  93080. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  93081. */
  93082. radiusRange?: number,
  93083. /**
  93084. * How much to randomize the particle direction [0-1].
  93085. */
  93086. directionRandomizer?: number);
  93087. /**
  93088. * Called by the particle System when the direction is computed for the created particle.
  93089. * @param worldMatrix is the world matrix of the particle system
  93090. * @param directionToUpdate is the direction vector to update with the result
  93091. * @param particle is the particle we are computed the direction for
  93092. * @param isLocal defines if the direction should be set in local space
  93093. */
  93094. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  93095. /**
  93096. * Called by the particle System when the position is computed for the created particle.
  93097. * @param worldMatrix is the world matrix of the particle system
  93098. * @param positionToUpdate is the position vector to update with the result
  93099. * @param particle is the particle we are computed the position for
  93100. * @param isLocal defines if the position should be set in local space
  93101. */
  93102. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  93103. /**
  93104. * Clones the current emitter and returns a copy of it
  93105. * @returns the new emitter
  93106. */
  93107. clone(): CylinderParticleEmitter;
  93108. /**
  93109. * Called by the GPUParticleSystem to setup the update shader
  93110. * @param effect defines the update shader
  93111. */
  93112. applyToShader(effect: Effect): void;
  93113. /**
  93114. * Returns a string to use to update the GPU particles update shader
  93115. * @returns a string containng the defines string
  93116. */
  93117. getEffectDefines(): string;
  93118. /**
  93119. * Returns the string "CylinderParticleEmitter"
  93120. * @returns a string containing the class name
  93121. */
  93122. getClassName(): string;
  93123. /**
  93124. * Serializes the particle system to a JSON object.
  93125. * @returns the JSON object
  93126. */
  93127. serialize(): any;
  93128. /**
  93129. * Parse properties from a JSON object
  93130. * @param serializationObject defines the JSON object
  93131. */
  93132. parse(serializationObject: any): void;
  93133. }
  93134. /**
  93135. * Particle emitter emitting particles from the inside of a cylinder.
  93136. * It emits the particles randomly between two vectors.
  93137. */
  93138. export class CylinderDirectedParticleEmitter extends CylinderParticleEmitter {
  93139. /**
  93140. * The min limit of the emission direction.
  93141. */
  93142. direction1: Vector3;
  93143. /**
  93144. * The max limit of the emission direction.
  93145. */
  93146. direction2: Vector3;
  93147. /**
  93148. * Creates a new instance CylinderDirectedParticleEmitter
  93149. * @param radius the radius of the emission cylinder (1 by default)
  93150. * @param height the height of the emission cylinder (1 by default)
  93151. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  93152. * @param direction1 the min limit of the emission direction (up vector by default)
  93153. * @param direction2 the max limit of the emission direction (up vector by default)
  93154. */
  93155. constructor(radius?: number, height?: number, radiusRange?: number,
  93156. /**
  93157. * The min limit of the emission direction.
  93158. */
  93159. direction1?: Vector3,
  93160. /**
  93161. * The max limit of the emission direction.
  93162. */
  93163. direction2?: Vector3);
  93164. /**
  93165. * Called by the particle System when the direction is computed for the created particle.
  93166. * @param worldMatrix is the world matrix of the particle system
  93167. * @param directionToUpdate is the direction vector to update with the result
  93168. * @param particle is the particle we are computed the direction for
  93169. */
  93170. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  93171. /**
  93172. * Clones the current emitter and returns a copy of it
  93173. * @returns the new emitter
  93174. */
  93175. clone(): CylinderDirectedParticleEmitter;
  93176. /**
  93177. * Called by the GPUParticleSystem to setup the update shader
  93178. * @param effect defines the update shader
  93179. */
  93180. applyToShader(effect: Effect): void;
  93181. /**
  93182. * Returns a string to use to update the GPU particles update shader
  93183. * @returns a string containng the defines string
  93184. */
  93185. getEffectDefines(): string;
  93186. /**
  93187. * Returns the string "CylinderDirectedParticleEmitter"
  93188. * @returns a string containing the class name
  93189. */
  93190. getClassName(): string;
  93191. /**
  93192. * Serializes the particle system to a JSON object.
  93193. * @returns the JSON object
  93194. */
  93195. serialize(): any;
  93196. /**
  93197. * Parse properties from a JSON object
  93198. * @param serializationObject defines the JSON object
  93199. */
  93200. parse(serializationObject: any): void;
  93201. }
  93202. }
  93203. declare module BABYLON {
  93204. /**
  93205. * Particle emitter emitting particles from the inside of a hemisphere.
  93206. * It emits the particles alongside the hemisphere radius. The emission direction might be randomized.
  93207. */
  93208. export class HemisphericParticleEmitter implements IParticleEmitterType {
  93209. /**
  93210. * The radius of the emission hemisphere.
  93211. */
  93212. radius: number;
  93213. /**
  93214. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  93215. */
  93216. radiusRange: number;
  93217. /**
  93218. * How much to randomize the particle direction [0-1].
  93219. */
  93220. directionRandomizer: number;
  93221. /**
  93222. * Creates a new instance HemisphericParticleEmitter
  93223. * @param radius the radius of the emission hemisphere (1 by default)
  93224. * @param radiusRange the range of the emission hemisphere [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  93225. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  93226. */
  93227. constructor(
  93228. /**
  93229. * The radius of the emission hemisphere.
  93230. */
  93231. radius?: number,
  93232. /**
  93233. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  93234. */
  93235. radiusRange?: number,
  93236. /**
  93237. * How much to randomize the particle direction [0-1].
  93238. */
  93239. directionRandomizer?: number);
  93240. /**
  93241. * Called by the particle System when the direction is computed for the created particle.
  93242. * @param worldMatrix is the world matrix of the particle system
  93243. * @param directionToUpdate is the direction vector to update with the result
  93244. * @param particle is the particle we are computed the direction for
  93245. * @param isLocal defines if the direction should be set in local space
  93246. */
  93247. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  93248. /**
  93249. * Called by the particle System when the position is computed for the created particle.
  93250. * @param worldMatrix is the world matrix of the particle system
  93251. * @param positionToUpdate is the position vector to update with the result
  93252. * @param particle is the particle we are computed the position for
  93253. * @param isLocal defines if the position should be set in local space
  93254. */
  93255. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  93256. /**
  93257. * Clones the current emitter and returns a copy of it
  93258. * @returns the new emitter
  93259. */
  93260. clone(): HemisphericParticleEmitter;
  93261. /**
  93262. * Called by the GPUParticleSystem to setup the update shader
  93263. * @param effect defines the update shader
  93264. */
  93265. applyToShader(effect: Effect): void;
  93266. /**
  93267. * Returns a string to use to update the GPU particles update shader
  93268. * @returns a string containng the defines string
  93269. */
  93270. getEffectDefines(): string;
  93271. /**
  93272. * Returns the string "HemisphericParticleEmitter"
  93273. * @returns a string containing the class name
  93274. */
  93275. getClassName(): string;
  93276. /**
  93277. * Serializes the particle system to a JSON object.
  93278. * @returns the JSON object
  93279. */
  93280. serialize(): any;
  93281. /**
  93282. * Parse properties from a JSON object
  93283. * @param serializationObject defines the JSON object
  93284. */
  93285. parse(serializationObject: any): void;
  93286. }
  93287. }
  93288. declare module BABYLON {
  93289. /**
  93290. * Particle emitter emitting particles from a point.
  93291. * It emits the particles randomly between 2 given directions.
  93292. */
  93293. export class PointParticleEmitter implements IParticleEmitterType {
  93294. /**
  93295. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  93296. */
  93297. direction1: Vector3;
  93298. /**
  93299. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  93300. */
  93301. direction2: Vector3;
  93302. /**
  93303. * Creates a new instance PointParticleEmitter
  93304. */
  93305. constructor();
  93306. /**
  93307. * Called by the particle System when the direction is computed for the created particle.
  93308. * @param worldMatrix is the world matrix of the particle system
  93309. * @param directionToUpdate is the direction vector to update with the result
  93310. * @param particle is the particle we are computed the direction for
  93311. * @param isLocal defines if the direction should be set in local space
  93312. */
  93313. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  93314. /**
  93315. * Called by the particle System when the position is computed for the created particle.
  93316. * @param worldMatrix is the world matrix of the particle system
  93317. * @param positionToUpdate is the position vector to update with the result
  93318. * @param particle is the particle we are computed the position for
  93319. * @param isLocal defines if the position should be set in local space
  93320. */
  93321. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  93322. /**
  93323. * Clones the current emitter and returns a copy of it
  93324. * @returns the new emitter
  93325. */
  93326. clone(): PointParticleEmitter;
  93327. /**
  93328. * Called by the GPUParticleSystem to setup the update shader
  93329. * @param effect defines the update shader
  93330. */
  93331. applyToShader(effect: Effect): void;
  93332. /**
  93333. * Returns a string to use to update the GPU particles update shader
  93334. * @returns a string containng the defines string
  93335. */
  93336. getEffectDefines(): string;
  93337. /**
  93338. * Returns the string "PointParticleEmitter"
  93339. * @returns a string containing the class name
  93340. */
  93341. getClassName(): string;
  93342. /**
  93343. * Serializes the particle system to a JSON object.
  93344. * @returns the JSON object
  93345. */
  93346. serialize(): any;
  93347. /**
  93348. * Parse properties from a JSON object
  93349. * @param serializationObject defines the JSON object
  93350. */
  93351. parse(serializationObject: any): void;
  93352. }
  93353. }
  93354. declare module BABYLON {
  93355. /**
  93356. * Particle emitter emitting particles from the inside of a sphere.
  93357. * It emits the particles alongside the sphere radius. The emission direction might be randomized.
  93358. */
  93359. export class SphereParticleEmitter implements IParticleEmitterType {
  93360. /**
  93361. * The radius of the emission sphere.
  93362. */
  93363. radius: number;
  93364. /**
  93365. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  93366. */
  93367. radiusRange: number;
  93368. /**
  93369. * How much to randomize the particle direction [0-1].
  93370. */
  93371. directionRandomizer: number;
  93372. /**
  93373. * Creates a new instance SphereParticleEmitter
  93374. * @param radius the radius of the emission sphere (1 by default)
  93375. * @param radiusRange the range of the emission sphere [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  93376. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  93377. */
  93378. constructor(
  93379. /**
  93380. * The radius of the emission sphere.
  93381. */
  93382. radius?: number,
  93383. /**
  93384. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  93385. */
  93386. radiusRange?: number,
  93387. /**
  93388. * How much to randomize the particle direction [0-1].
  93389. */
  93390. directionRandomizer?: number);
  93391. /**
  93392. * Called by the particle System when the direction is computed for the created particle.
  93393. * @param worldMatrix is the world matrix of the particle system
  93394. * @param directionToUpdate is the direction vector to update with the result
  93395. * @param particle is the particle we are computed the direction for
  93396. * @param isLocal defines if the direction should be set in local space
  93397. */
  93398. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  93399. /**
  93400. * Called by the particle System when the position is computed for the created particle.
  93401. * @param worldMatrix is the world matrix of the particle system
  93402. * @param positionToUpdate is the position vector to update with the result
  93403. * @param particle is the particle we are computed the position for
  93404. * @param isLocal defines if the position should be set in local space
  93405. */
  93406. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  93407. /**
  93408. * Clones the current emitter and returns a copy of it
  93409. * @returns the new emitter
  93410. */
  93411. clone(): SphereParticleEmitter;
  93412. /**
  93413. * Called by the GPUParticleSystem to setup the update shader
  93414. * @param effect defines the update shader
  93415. */
  93416. applyToShader(effect: Effect): void;
  93417. /**
  93418. * Returns a string to use to update the GPU particles update shader
  93419. * @returns a string containng the defines string
  93420. */
  93421. getEffectDefines(): string;
  93422. /**
  93423. * Returns the string "SphereParticleEmitter"
  93424. * @returns a string containing the class name
  93425. */
  93426. getClassName(): string;
  93427. /**
  93428. * Serializes the particle system to a JSON object.
  93429. * @returns the JSON object
  93430. */
  93431. serialize(): any;
  93432. /**
  93433. * Parse properties from a JSON object
  93434. * @param serializationObject defines the JSON object
  93435. */
  93436. parse(serializationObject: any): void;
  93437. }
  93438. /**
  93439. * Particle emitter emitting particles from the inside of a sphere.
  93440. * It emits the particles randomly between two vectors.
  93441. */
  93442. export class SphereDirectedParticleEmitter extends SphereParticleEmitter {
  93443. /**
  93444. * The min limit of the emission direction.
  93445. */
  93446. direction1: Vector3;
  93447. /**
  93448. * The max limit of the emission direction.
  93449. */
  93450. direction2: Vector3;
  93451. /**
  93452. * Creates a new instance SphereDirectedParticleEmitter
  93453. * @param radius the radius of the emission sphere (1 by default)
  93454. * @param direction1 the min limit of the emission direction (up vector by default)
  93455. * @param direction2 the max limit of the emission direction (up vector by default)
  93456. */
  93457. constructor(radius?: number,
  93458. /**
  93459. * The min limit of the emission direction.
  93460. */
  93461. direction1?: Vector3,
  93462. /**
  93463. * The max limit of the emission direction.
  93464. */
  93465. direction2?: Vector3);
  93466. /**
  93467. * Called by the particle System when the direction is computed for the created particle.
  93468. * @param worldMatrix is the world matrix of the particle system
  93469. * @param directionToUpdate is the direction vector to update with the result
  93470. * @param particle is the particle we are computed the direction for
  93471. */
  93472. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  93473. /**
  93474. * Clones the current emitter and returns a copy of it
  93475. * @returns the new emitter
  93476. */
  93477. clone(): SphereDirectedParticleEmitter;
  93478. /**
  93479. * Called by the GPUParticleSystem to setup the update shader
  93480. * @param effect defines the update shader
  93481. */
  93482. applyToShader(effect: Effect): void;
  93483. /**
  93484. * Returns a string to use to update the GPU particles update shader
  93485. * @returns a string containng the defines string
  93486. */
  93487. getEffectDefines(): string;
  93488. /**
  93489. * Returns the string "SphereDirectedParticleEmitter"
  93490. * @returns a string containing the class name
  93491. */
  93492. getClassName(): string;
  93493. /**
  93494. * Serializes the particle system to a JSON object.
  93495. * @returns the JSON object
  93496. */
  93497. serialize(): any;
  93498. /**
  93499. * Parse properties from a JSON object
  93500. * @param serializationObject defines the JSON object
  93501. */
  93502. parse(serializationObject: any): void;
  93503. }
  93504. }
  93505. declare module BABYLON {
  93506. /**
  93507. * Particle emitter emitting particles from a custom list of positions.
  93508. */
  93509. export class CustomParticleEmitter implements IParticleEmitterType {
  93510. /**
  93511. * Gets or sets the position generator that will create the inital position of each particle.
  93512. * Index will be provided when used with GPU particle. Particle will be provided when used with CPU particles
  93513. */
  93514. particlePositionGenerator: (index: number, particle: Nullable<Particle>, outPosition: Vector3) => void;
  93515. /**
  93516. * Gets or sets the destination generator that will create the final destination of each particle.
  93517. * * Index will be provided when used with GPU particle. Particle will be provided when used with CPU particles
  93518. */
  93519. particleDestinationGenerator: (index: number, particle: Nullable<Particle>, outDestination: Vector3) => void;
  93520. /**
  93521. * Creates a new instance CustomParticleEmitter
  93522. */
  93523. constructor();
  93524. /**
  93525. * Called by the particle System when the direction is computed for the created particle.
  93526. * @param worldMatrix is the world matrix of the particle system
  93527. * @param directionToUpdate is the direction vector to update with the result
  93528. * @param particle is the particle we are computed the direction for
  93529. * @param isLocal defines if the direction should be set in local space
  93530. */
  93531. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  93532. /**
  93533. * Called by the particle System when the position is computed for the created particle.
  93534. * @param worldMatrix is the world matrix of the particle system
  93535. * @param positionToUpdate is the position vector to update with the result
  93536. * @param particle is the particle we are computed the position for
  93537. * @param isLocal defines if the position should be set in local space
  93538. */
  93539. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  93540. /**
  93541. * Clones the current emitter and returns a copy of it
  93542. * @returns the new emitter
  93543. */
  93544. clone(): CustomParticleEmitter;
  93545. /**
  93546. * Called by the GPUParticleSystem to setup the update shader
  93547. * @param effect defines the update shader
  93548. */
  93549. applyToShader(effect: Effect): void;
  93550. /**
  93551. * Returns a string to use to update the GPU particles update shader
  93552. * @returns a string containng the defines string
  93553. */
  93554. getEffectDefines(): string;
  93555. /**
  93556. * Returns the string "PointParticleEmitter"
  93557. * @returns a string containing the class name
  93558. */
  93559. getClassName(): string;
  93560. /**
  93561. * Serializes the particle system to a JSON object.
  93562. * @returns the JSON object
  93563. */
  93564. serialize(): any;
  93565. /**
  93566. * Parse properties from a JSON object
  93567. * @param serializationObject defines the JSON object
  93568. */
  93569. parse(serializationObject: any): void;
  93570. }
  93571. }
  93572. declare module BABYLON {
  93573. /**
  93574. * Particle emitter emitting particles from the inside of a box.
  93575. * It emits the particles randomly between 2 given directions.
  93576. */
  93577. export class MeshParticleEmitter implements IParticleEmitterType {
  93578. private _indices;
  93579. private _positions;
  93580. private _normals;
  93581. private _storedNormal;
  93582. private _mesh;
  93583. /**
  93584. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  93585. */
  93586. direction1: Vector3;
  93587. /**
  93588. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  93589. */
  93590. direction2: Vector3;
  93591. /**
  93592. * Gets or sets a boolean indicating that particle directions must be built from mesh face normals
  93593. */
  93594. useMeshNormalsForDirection: boolean;
  93595. /** Defines the mesh to use as source */
  93596. get mesh(): Nullable<AbstractMesh>;
  93597. set mesh(value: Nullable<AbstractMesh>);
  93598. /**
  93599. * Creates a new instance MeshParticleEmitter
  93600. * @param mesh defines the mesh to use as source
  93601. */
  93602. constructor(mesh?: Nullable<AbstractMesh>);
  93603. /**
  93604. * Called by the particle System when the direction is computed for the created particle.
  93605. * @param worldMatrix is the world matrix of the particle system
  93606. * @param directionToUpdate is the direction vector to update with the result
  93607. * @param particle is the particle we are computed the direction for
  93608. * @param isLocal defines if the direction should be set in local space
  93609. */
  93610. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  93611. /**
  93612. * Called by the particle System when the position is computed for the created particle.
  93613. * @param worldMatrix is the world matrix of the particle system
  93614. * @param positionToUpdate is the position vector to update with the result
  93615. * @param particle is the particle we are computed the position for
  93616. * @param isLocal defines if the position should be set in local space
  93617. */
  93618. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  93619. /**
  93620. * Clones the current emitter and returns a copy of it
  93621. * @returns the new emitter
  93622. */
  93623. clone(): MeshParticleEmitter;
  93624. /**
  93625. * Called by the GPUParticleSystem to setup the update shader
  93626. * @param effect defines the update shader
  93627. */
  93628. applyToShader(effect: Effect): void;
  93629. /**
  93630. * Returns a string to use to update the GPU particles update shader
  93631. * @returns a string containng the defines string
  93632. */
  93633. getEffectDefines(): string;
  93634. /**
  93635. * Returns the string "BoxParticleEmitter"
  93636. * @returns a string containing the class name
  93637. */
  93638. getClassName(): string;
  93639. /**
  93640. * Serializes the particle system to a JSON object.
  93641. * @returns the JSON object
  93642. */
  93643. serialize(): any;
  93644. /**
  93645. * Parse properties from a JSON object
  93646. * @param serializationObject defines the JSON object
  93647. * @param scene defines the hosting scene
  93648. */
  93649. parse(serializationObject: any, scene: Nullable<Scene>): void;
  93650. }
  93651. }
  93652. declare module BABYLON {
  93653. /**
  93654. * Interface representing a particle system in Babylon.js.
  93655. * This groups the common functionalities that needs to be implemented in order to create a particle system.
  93656. * A particle system represents a way to manage particles from their emission to their animation and rendering.
  93657. */
  93658. export interface IParticleSystem {
  93659. /**
  93660. * List of animations used by the particle system.
  93661. */
  93662. animations: Animation[];
  93663. /**
  93664. * The id of the Particle system.
  93665. */
  93666. id: string;
  93667. /**
  93668. * The name of the Particle system.
  93669. */
  93670. name: string;
  93671. /**
  93672. * The emitter represents the Mesh or position we are attaching the particle system to.
  93673. */
  93674. emitter: Nullable<AbstractMesh | Vector3>;
  93675. /**
  93676. * Gets or sets a boolean indicating if the particles must be rendered as billboard or aligned with the direction
  93677. */
  93678. isBillboardBased: boolean;
  93679. /**
  93680. * The rendering group used by the Particle system to chose when to render.
  93681. */
  93682. renderingGroupId: number;
  93683. /**
  93684. * The layer mask we are rendering the particles through.
  93685. */
  93686. layerMask: number;
  93687. /**
  93688. * The overall motion speed (0.01 is default update speed, faster updates = faster animation)
  93689. */
  93690. updateSpeed: number;
  93691. /**
  93692. * The amount of time the particle system is running (depends of the overall update speed).
  93693. */
  93694. targetStopDuration: number;
  93695. /**
  93696. * The texture used to render each particle. (this can be a spritesheet)
  93697. */
  93698. particleTexture: Nullable<BaseTexture>;
  93699. /**
  93700. * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE, ParticleSystem.BLENDMODE_STANDARD or ParticleSystem.BLENDMODE_ADD.
  93701. */
  93702. blendMode: number;
  93703. /**
  93704. * Minimum life time of emitting particles.
  93705. */
  93706. minLifeTime: number;
  93707. /**
  93708. * Maximum life time of emitting particles.
  93709. */
  93710. maxLifeTime: number;
  93711. /**
  93712. * Minimum Size of emitting particles.
  93713. */
  93714. minSize: number;
  93715. /**
  93716. * Maximum Size of emitting particles.
  93717. */
  93718. maxSize: number;
  93719. /**
  93720. * Minimum scale of emitting particles on X axis.
  93721. */
  93722. minScaleX: number;
  93723. /**
  93724. * Maximum scale of emitting particles on X axis.
  93725. */
  93726. maxScaleX: number;
  93727. /**
  93728. * Minimum scale of emitting particles on Y axis.
  93729. */
  93730. minScaleY: number;
  93731. /**
  93732. * Maximum scale of emitting particles on Y axis.
  93733. */
  93734. maxScaleY: number;
  93735. /**
  93736. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  93737. */
  93738. color1: Color4;
  93739. /**
  93740. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  93741. */
  93742. color2: Color4;
  93743. /**
  93744. * Color the particle will have at the end of its lifetime.
  93745. */
  93746. colorDead: Color4;
  93747. /**
  93748. * The maximum number of particles to emit per frame until we reach the activeParticleCount value
  93749. */
  93750. emitRate: number;
  93751. /**
  93752. * You can use gravity if you want to give an orientation to your particles.
  93753. */
  93754. gravity: Vector3;
  93755. /**
  93756. * Minimum power of emitting particles.
  93757. */
  93758. minEmitPower: number;
  93759. /**
  93760. * Maximum power of emitting particles.
  93761. */
  93762. maxEmitPower: number;
  93763. /**
  93764. * Minimum angular speed of emitting particles (Z-axis rotation for each particle).
  93765. */
  93766. minAngularSpeed: number;
  93767. /**
  93768. * Maximum angular speed of emitting particles (Z-axis rotation for each particle).
  93769. */
  93770. maxAngularSpeed: number;
  93771. /**
  93772. * Gets or sets the minimal initial rotation in radians.
  93773. */
  93774. minInitialRotation: number;
  93775. /**
  93776. * Gets or sets the maximal initial rotation in radians.
  93777. */
  93778. maxInitialRotation: number;
  93779. /**
  93780. * The particle emitter type defines the emitter used by the particle system.
  93781. * It can be for example box, sphere, or cone...
  93782. */
  93783. particleEmitterType: Nullable<IParticleEmitterType>;
  93784. /**
  93785. * Defines the delay in milliseconds before starting the system (0 by default)
  93786. */
  93787. startDelay: number;
  93788. /**
  93789. * 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
  93790. */
  93791. preWarmCycles: number;
  93792. /**
  93793. * Gets or sets a value indicating the time step multiplier to use in pre-warm mode (default is 1)
  93794. */
  93795. preWarmStepOffset: number;
  93796. /**
  93797. * 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)
  93798. */
  93799. spriteCellChangeSpeed: number;
  93800. /**
  93801. * If using a spritesheet (isAnimationSheetEnabled) defines the first sprite cell to display
  93802. */
  93803. startSpriteCellID: number;
  93804. /**
  93805. * If using a spritesheet (isAnimationSheetEnabled) defines the last sprite cell to display
  93806. */
  93807. endSpriteCellID: number;
  93808. /**
  93809. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell width to use
  93810. */
  93811. spriteCellWidth: number;
  93812. /**
  93813. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell height to use
  93814. */
  93815. spriteCellHeight: number;
  93816. /**
  93817. * This allows the system to random pick the start cell ID between startSpriteCellID and endSpriteCellID
  93818. */
  93819. spriteRandomStartCell: boolean;
  93820. /**
  93821. * Gets or sets a boolean indicating if a spritesheet is used to animate the particles texture
  93822. */
  93823. isAnimationSheetEnabled: boolean;
  93824. /** Gets or sets a Vector2 used to move the pivot (by default (0,0)) */
  93825. translationPivot: Vector2;
  93826. /**
  93827. * Gets or sets a texture used to add random noise to particle positions
  93828. */
  93829. noiseTexture: Nullable<BaseTexture>;
  93830. /** Gets or sets the strength to apply to the noise value (default is (10, 10, 10)) */
  93831. noiseStrength: Vector3;
  93832. /**
  93833. * Gets or sets the billboard mode to use when isBillboardBased = true.
  93834. * Value can be: ParticleSystem.BILLBOARDMODE_ALL, ParticleSystem.BILLBOARDMODE_Y, ParticleSystem.BILLBOARDMODE_STRETCHED
  93835. */
  93836. billboardMode: number;
  93837. /** Gets or sets a value indicating the damping to apply if the limit velocity factor is reached */
  93838. limitVelocityDamping: number;
  93839. /**
  93840. * Gets or sets a boolean indicating that hosted animations (in the system.animations array) must be started when system.start() is called
  93841. */
  93842. beginAnimationOnStart: boolean;
  93843. /**
  93844. * Gets or sets the frame to start the animation from when beginAnimationOnStart is true
  93845. */
  93846. beginAnimationFrom: number;
  93847. /**
  93848. * Gets or sets the frame to end the animation on when beginAnimationOnStart is true
  93849. */
  93850. beginAnimationTo: number;
  93851. /**
  93852. * Gets or sets a boolean indicating if animations must loop when beginAnimationOnStart is true
  93853. */
  93854. beginAnimationLoop: boolean;
  93855. /**
  93856. * Specifies whether the particle system will be disposed once it reaches the end of the animation.
  93857. */
  93858. disposeOnStop: boolean;
  93859. /**
  93860. * Specifies if the particles are updated in emitter local space or world space
  93861. */
  93862. isLocal: boolean;
  93863. /** Snippet ID if the particle system was created from the snippet server */
  93864. snippetId: string;
  93865. /** Gets or sets a matrix to use to compute projection */
  93866. defaultProjectionMatrix: Matrix;
  93867. /**
  93868. * Gets the maximum number of particles active at the same time.
  93869. * @returns The max number of active particles.
  93870. */
  93871. getCapacity(): number;
  93872. /**
  93873. * Gets the number of particles active at the same time.
  93874. * @returns The number of active particles.
  93875. */
  93876. getActiveCount(): number;
  93877. /**
  93878. * Gets if the system has been started. (Note: this will still be true after stop is called)
  93879. * @returns True if it has been started, otherwise false.
  93880. */
  93881. isStarted(): boolean;
  93882. /**
  93883. * Animates the particle system for this frame.
  93884. */
  93885. animate(): void;
  93886. /**
  93887. * Renders the particle system in its current state.
  93888. * @returns the current number of particles
  93889. */
  93890. render(): number;
  93891. /**
  93892. * Dispose the particle system and frees its associated resources.
  93893. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  93894. */
  93895. dispose(disposeTexture?: boolean): void;
  93896. /**
  93897. * An event triggered when the system is disposed
  93898. */
  93899. onDisposeObservable: Observable<IParticleSystem>;
  93900. /**
  93901. * Clones the particle system.
  93902. * @param name The name of the cloned object
  93903. * @param newEmitter The new emitter to use
  93904. * @returns the cloned particle system
  93905. */
  93906. clone(name: string, newEmitter: any): Nullable<IParticleSystem>;
  93907. /**
  93908. * Serializes the particle system to a JSON object
  93909. * @param serializeTexture defines if the texture must be serialized as well
  93910. * @returns the JSON object
  93911. */
  93912. serialize(serializeTexture: boolean): any;
  93913. /**
  93914. * Rebuild the particle system
  93915. */
  93916. rebuild(): void;
  93917. /** Force the system to rebuild all gradients that need to be resync */
  93918. forceRefreshGradients(): void;
  93919. /**
  93920. * Starts the particle system and begins to emit
  93921. * @param delay defines the delay in milliseconds before starting the system (0 by default)
  93922. */
  93923. start(delay?: number): void;
  93924. /**
  93925. * Stops the particle system.
  93926. */
  93927. stop(): void;
  93928. /**
  93929. * Remove all active particles
  93930. */
  93931. reset(): void;
  93932. /**
  93933. * Gets a boolean indicating that the system is stopping
  93934. * @returns true if the system is currently stopping
  93935. */
  93936. isStopping(): boolean;
  93937. /**
  93938. * Is this system ready to be used/rendered
  93939. * @return true if the system is ready
  93940. */
  93941. isReady(): boolean;
  93942. /**
  93943. * Returns the string "ParticleSystem"
  93944. * @returns a string containing the class name
  93945. */
  93946. getClassName(): string;
  93947. /**
  93948. * Gets the custom effect used to render the particles
  93949. * @param blendMode Blend mode for which the effect should be retrieved
  93950. * @returns The effect
  93951. */
  93952. getCustomEffect(blendMode: number): Nullable<Effect>;
  93953. /**
  93954. * Sets the custom effect used to render the particles
  93955. * @param effect The effect to set
  93956. * @param blendMode Blend mode for which the effect should be set
  93957. */
  93958. setCustomEffect(effect: Nullable<Effect>, blendMode: number): void;
  93959. /**
  93960. * Fill the defines array according to the current settings of the particle system
  93961. * @param defines Array to be updated
  93962. * @param blendMode blend mode to take into account when updating the array
  93963. */
  93964. fillDefines(defines: Array<string>, blendMode: number): void;
  93965. /**
  93966. * Fill the uniforms, attributes and samplers arrays according to the current settings of the particle system
  93967. * @param uniforms Uniforms array to fill
  93968. * @param attributes Attributes array to fill
  93969. * @param samplers Samplers array to fill
  93970. */
  93971. fillUniformsAttributesAndSamplerNames(uniforms: Array<string>, attributes: Array<string>, samplers: Array<string>): void;
  93972. /**
  93973. * Observable that will be called just before the particles are drawn
  93974. */
  93975. onBeforeDrawParticlesObservable: Observable<Nullable<Effect>>;
  93976. /**
  93977. * Gets the name of the particle vertex shader
  93978. */
  93979. vertexShaderName: string;
  93980. /**
  93981. * Adds a new color gradient
  93982. * @param gradient defines the gradient to use (between 0 and 1)
  93983. * @param color1 defines the color to affect to the specified gradient
  93984. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  93985. * @returns the current particle system
  93986. */
  93987. addColorGradient(gradient: number, color1: Color4, color2?: Color4): IParticleSystem;
  93988. /**
  93989. * Remove a specific color gradient
  93990. * @param gradient defines the gradient to remove
  93991. * @returns the current particle system
  93992. */
  93993. removeColorGradient(gradient: number): IParticleSystem;
  93994. /**
  93995. * Adds a new size gradient
  93996. * @param gradient defines the gradient to use (between 0 and 1)
  93997. * @param factor defines the size factor to affect to the specified gradient
  93998. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  93999. * @returns the current particle system
  94000. */
  94001. addSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  94002. /**
  94003. * Remove a specific size gradient
  94004. * @param gradient defines the gradient to remove
  94005. * @returns the current particle system
  94006. */
  94007. removeSizeGradient(gradient: number): IParticleSystem;
  94008. /**
  94009. * Gets the current list of color gradients.
  94010. * You must use addColorGradient and removeColorGradient to udpate this list
  94011. * @returns the list of color gradients
  94012. */
  94013. getColorGradients(): Nullable<Array<ColorGradient>>;
  94014. /**
  94015. * Gets the current list of size gradients.
  94016. * You must use addSizeGradient and removeSizeGradient to udpate this list
  94017. * @returns the list of size gradients
  94018. */
  94019. getSizeGradients(): Nullable<Array<FactorGradient>>;
  94020. /**
  94021. * Gets the current list of angular speed gradients.
  94022. * You must use addAngularSpeedGradient and removeAngularSpeedGradient to udpate this list
  94023. * @returns the list of angular speed gradients
  94024. */
  94025. getAngularSpeedGradients(): Nullable<Array<FactorGradient>>;
  94026. /**
  94027. * Adds a new angular speed gradient
  94028. * @param gradient defines the gradient to use (between 0 and 1)
  94029. * @param factor defines the angular speed to affect to the specified gradient
  94030. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  94031. * @returns the current particle system
  94032. */
  94033. addAngularSpeedGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  94034. /**
  94035. * Remove a specific angular speed gradient
  94036. * @param gradient defines the gradient to remove
  94037. * @returns the current particle system
  94038. */
  94039. removeAngularSpeedGradient(gradient: number): IParticleSystem;
  94040. /**
  94041. * Gets the current list of velocity gradients.
  94042. * You must use addVelocityGradient and removeVelocityGradient to udpate this list
  94043. * @returns the list of velocity gradients
  94044. */
  94045. getVelocityGradients(): Nullable<Array<FactorGradient>>;
  94046. /**
  94047. * Adds a new velocity gradient
  94048. * @param gradient defines the gradient to use (between 0 and 1)
  94049. * @param factor defines the velocity to affect to the specified gradient
  94050. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  94051. * @returns the current particle system
  94052. */
  94053. addVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  94054. /**
  94055. * Remove a specific velocity gradient
  94056. * @param gradient defines the gradient to remove
  94057. * @returns the current particle system
  94058. */
  94059. removeVelocityGradient(gradient: number): IParticleSystem;
  94060. /**
  94061. * Gets the current list of limit velocity gradients.
  94062. * You must use addLimitVelocityGradient and removeLimitVelocityGradient to udpate this list
  94063. * @returns the list of limit velocity gradients
  94064. */
  94065. getLimitVelocityGradients(): Nullable<Array<FactorGradient>>;
  94066. /**
  94067. * Adds a new limit velocity gradient
  94068. * @param gradient defines the gradient to use (between 0 and 1)
  94069. * @param factor defines the limit velocity to affect to the specified gradient
  94070. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  94071. * @returns the current particle system
  94072. */
  94073. addLimitVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  94074. /**
  94075. * Remove a specific limit velocity gradient
  94076. * @param gradient defines the gradient to remove
  94077. * @returns the current particle system
  94078. */
  94079. removeLimitVelocityGradient(gradient: number): IParticleSystem;
  94080. /**
  94081. * Adds a new drag gradient
  94082. * @param gradient defines the gradient to use (between 0 and 1)
  94083. * @param factor defines the drag to affect to the specified gradient
  94084. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  94085. * @returns the current particle system
  94086. */
  94087. addDragGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  94088. /**
  94089. * Remove a specific drag gradient
  94090. * @param gradient defines the gradient to remove
  94091. * @returns the current particle system
  94092. */
  94093. removeDragGradient(gradient: number): IParticleSystem;
  94094. /**
  94095. * Gets the current list of drag gradients.
  94096. * You must use addDragGradient and removeDragGradient to udpate this list
  94097. * @returns the list of drag gradients
  94098. */
  94099. getDragGradients(): Nullable<Array<FactorGradient>>;
  94100. /**
  94101. * Adds a new emit rate gradient (please note that this will only work if you set the targetStopDuration property)
  94102. * @param gradient defines the gradient to use (between 0 and 1)
  94103. * @param factor defines the emit rate to affect to the specified gradient
  94104. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  94105. * @returns the current particle system
  94106. */
  94107. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  94108. /**
  94109. * Remove a specific emit rate gradient
  94110. * @param gradient defines the gradient to remove
  94111. * @returns the current particle system
  94112. */
  94113. removeEmitRateGradient(gradient: number): IParticleSystem;
  94114. /**
  94115. * Gets the current list of emit rate gradients.
  94116. * You must use addEmitRateGradient and removeEmitRateGradient to udpate this list
  94117. * @returns the list of emit rate gradients
  94118. */
  94119. getEmitRateGradients(): Nullable<Array<FactorGradient>>;
  94120. /**
  94121. * Adds a new start size gradient (please note that this will only work if you set the targetStopDuration property)
  94122. * @param gradient defines the gradient to use (between 0 and 1)
  94123. * @param factor defines the start size to affect to the specified gradient
  94124. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  94125. * @returns the current particle system
  94126. */
  94127. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  94128. /**
  94129. * Remove a specific start size gradient
  94130. * @param gradient defines the gradient to remove
  94131. * @returns the current particle system
  94132. */
  94133. removeStartSizeGradient(gradient: number): IParticleSystem;
  94134. /**
  94135. * Gets the current list of start size gradients.
  94136. * You must use addStartSizeGradient and removeStartSizeGradient to udpate this list
  94137. * @returns the list of start size gradients
  94138. */
  94139. getStartSizeGradients(): Nullable<Array<FactorGradient>>;
  94140. /**
  94141. * Adds a new life time gradient
  94142. * @param gradient defines the gradient to use (between 0 and 1)
  94143. * @param factor defines the life time factor to affect to the specified gradient
  94144. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  94145. * @returns the current particle system
  94146. */
  94147. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  94148. /**
  94149. * Remove a specific life time gradient
  94150. * @param gradient defines the gradient to remove
  94151. * @returns the current particle system
  94152. */
  94153. removeLifeTimeGradient(gradient: number): IParticleSystem;
  94154. /**
  94155. * Gets the current list of life time gradients.
  94156. * You must use addLifeTimeGradient and removeLifeTimeGradient to udpate this list
  94157. * @returns the list of life time gradients
  94158. */
  94159. getLifeTimeGradients(): Nullable<Array<FactorGradient>>;
  94160. /**
  94161. * Gets the current list of color gradients.
  94162. * You must use addColorGradient and removeColorGradient to udpate this list
  94163. * @returns the list of color gradients
  94164. */
  94165. getColorGradients(): Nullable<Array<ColorGradient>>;
  94166. /**
  94167. * Adds a new ramp gradient used to remap particle colors
  94168. * @param gradient defines the gradient to use (between 0 and 1)
  94169. * @param color defines the color to affect to the specified gradient
  94170. * @returns the current particle system
  94171. */
  94172. addRampGradient(gradient: number, color: Color3): IParticleSystem;
  94173. /**
  94174. * Gets the current list of ramp gradients.
  94175. * You must use addRampGradient and removeRampGradient to udpate this list
  94176. * @returns the list of ramp gradients
  94177. */
  94178. getRampGradients(): Nullable<Array<Color3Gradient>>;
  94179. /** Gets or sets a boolean indicating that ramp gradients must be used
  94180. * @see https://doc.babylonjs.com/babylon101/particles#ramp-gradients
  94181. */
  94182. useRampGradients: boolean;
  94183. /**
  94184. * Adds a new color remap gradient
  94185. * @param gradient defines the gradient to use (between 0 and 1)
  94186. * @param min defines the color remap minimal range
  94187. * @param max defines the color remap maximal range
  94188. * @returns the current particle system
  94189. */
  94190. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  94191. /**
  94192. * Gets the current list of color remap gradients.
  94193. * You must use addColorRemapGradient and removeColorRemapGradient to udpate this list
  94194. * @returns the list of color remap gradients
  94195. */
  94196. getColorRemapGradients(): Nullable<Array<FactorGradient>>;
  94197. /**
  94198. * Adds a new alpha remap gradient
  94199. * @param gradient defines the gradient to use (between 0 and 1)
  94200. * @param min defines the alpha remap minimal range
  94201. * @param max defines the alpha remap maximal range
  94202. * @returns the current particle system
  94203. */
  94204. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  94205. /**
  94206. * Gets the current list of alpha remap gradients.
  94207. * You must use addAlphaRemapGradient and removeAlphaRemapGradient to udpate this list
  94208. * @returns the list of alpha remap gradients
  94209. */
  94210. getAlphaRemapGradients(): Nullable<Array<FactorGradient>>;
  94211. /**
  94212. * Creates a Point Emitter for the particle system (emits directly from the emitter position)
  94213. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  94214. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  94215. * @returns the emitter
  94216. */
  94217. createPointEmitter(direction1: Vector3, direction2: Vector3): PointParticleEmitter;
  94218. /**
  94219. * Creates a Hemisphere Emitter for the particle system (emits along the hemisphere radius)
  94220. * @param radius The radius of the hemisphere to emit from
  94221. * @param radiusRange The range of the hemisphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  94222. * @returns the emitter
  94223. */
  94224. createHemisphericEmitter(radius: number, radiusRange: number): HemisphericParticleEmitter;
  94225. /**
  94226. * Creates a Sphere Emitter for the particle system (emits along the sphere radius)
  94227. * @param radius The radius of the sphere to emit from
  94228. * @param radiusRange The range of the sphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  94229. * @returns the emitter
  94230. */
  94231. createSphereEmitter(radius: number, radiusRange: number): SphereParticleEmitter;
  94232. /**
  94233. * Creates a Directed Sphere Emitter for the particle system (emits between direction1 and direction2)
  94234. * @param radius The radius of the sphere to emit from
  94235. * @param direction1 Particles are emitted between the direction1 and direction2 from within the sphere
  94236. * @param direction2 Particles are emitted between the direction1 and direction2 from within the sphere
  94237. * @returns the emitter
  94238. */
  94239. createDirectedSphereEmitter(radius: number, direction1: Vector3, direction2: Vector3): SphereDirectedParticleEmitter;
  94240. /**
  94241. * Creates a Cylinder Emitter for the particle system (emits from the cylinder to the particle position)
  94242. * @param radius The radius of the emission cylinder
  94243. * @param height The height of the emission cylinder
  94244. * @param radiusRange The range of emission [0-1] 0 Surface only, 1 Entire Radius
  94245. * @param directionRandomizer How much to randomize the particle direction [0-1]
  94246. * @returns the emitter
  94247. */
  94248. createCylinderEmitter(radius: number, height: number, radiusRange: number, directionRandomizer: number): CylinderParticleEmitter;
  94249. /**
  94250. * Creates a Directed Cylinder Emitter for the particle system (emits between direction1 and direction2)
  94251. * @param radius The radius of the cylinder to emit from
  94252. * @param height The height of the emission cylinder
  94253. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  94254. * @param direction1 Particles are emitted between the direction1 and direction2 from within the cylinder
  94255. * @param direction2 Particles are emitted between the direction1 and direction2 from within the cylinder
  94256. * @returns the emitter
  94257. */
  94258. createDirectedCylinderEmitter(radius: number, height: number, radiusRange: number, direction1: Vector3, direction2: Vector3): SphereDirectedParticleEmitter;
  94259. /**
  94260. * Creates a Cone Emitter for the particle system (emits from the cone to the particle position)
  94261. * @param radius The radius of the cone to emit from
  94262. * @param angle The base angle of the cone
  94263. * @returns the emitter
  94264. */
  94265. createConeEmitter(radius: number, angle: number): ConeParticleEmitter;
  94266. /**
  94267. * Creates a Box Emitter for the particle system. (emits between direction1 and direction2 from withing the box defined by minEmitBox and maxEmitBox)
  94268. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  94269. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  94270. * @param minEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  94271. * @param maxEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  94272. * @returns the emitter
  94273. */
  94274. createBoxEmitter(direction1: Vector3, direction2: Vector3, minEmitBox: Vector3, maxEmitBox: Vector3): BoxParticleEmitter;
  94275. /**
  94276. * Get hosting scene
  94277. * @returns the scene
  94278. */
  94279. getScene(): Nullable<Scene>;
  94280. }
  94281. }
  94282. declare module BABYLON {
  94283. /**
  94284. * 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.
  94285. * @see https://doc.babylonjs.com/how_to/transformnode
  94286. */
  94287. export class TransformNode extends Node {
  94288. /**
  94289. * Object will not rotate to face the camera
  94290. */
  94291. static BILLBOARDMODE_NONE: number;
  94292. /**
  94293. * Object will rotate to face the camera but only on the x axis
  94294. */
  94295. static BILLBOARDMODE_X: number;
  94296. /**
  94297. * Object will rotate to face the camera but only on the y axis
  94298. */
  94299. static BILLBOARDMODE_Y: number;
  94300. /**
  94301. * Object will rotate to face the camera but only on the z axis
  94302. */
  94303. static BILLBOARDMODE_Z: number;
  94304. /**
  94305. * Object will rotate to face the camera
  94306. */
  94307. static BILLBOARDMODE_ALL: number;
  94308. /**
  94309. * Object will rotate to face the camera's position instead of orientation
  94310. */
  94311. static BILLBOARDMODE_USE_POSITION: number;
  94312. private static _TmpRotation;
  94313. private static _TmpScaling;
  94314. private static _TmpTranslation;
  94315. private _forward;
  94316. private _forwardInverted;
  94317. private _up;
  94318. private _right;
  94319. private _rightInverted;
  94320. private _position;
  94321. private _rotation;
  94322. private _rotationQuaternion;
  94323. protected _scaling: Vector3;
  94324. protected _isDirty: boolean;
  94325. private _transformToBoneReferal;
  94326. private _isAbsoluteSynced;
  94327. private _billboardMode;
  94328. /**
  94329. * Gets or sets the billboard mode. Default is 0.
  94330. *
  94331. * | Value | Type | Description |
  94332. * | --- | --- | --- |
  94333. * | 0 | BILLBOARDMODE_NONE | |
  94334. * | 1 | BILLBOARDMODE_X | |
  94335. * | 2 | BILLBOARDMODE_Y | |
  94336. * | 4 | BILLBOARDMODE_Z | |
  94337. * | 7 | BILLBOARDMODE_ALL | |
  94338. *
  94339. */
  94340. get billboardMode(): number;
  94341. set billboardMode(value: number);
  94342. private _preserveParentRotationForBillboard;
  94343. /**
  94344. * Gets or sets a boolean indicating that parent rotation should be preserved when using billboards.
  94345. * This could be useful for glTF objects where parent rotation helps converting from right handed to left handed
  94346. */
  94347. get preserveParentRotationForBillboard(): boolean;
  94348. set preserveParentRotationForBillboard(value: boolean);
  94349. /**
  94350. * 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
  94351. */
  94352. scalingDeterminant: number;
  94353. private _infiniteDistance;
  94354. /**
  94355. * Gets or sets the distance of the object to max, often used by skybox
  94356. */
  94357. get infiniteDistance(): boolean;
  94358. set infiniteDistance(value: boolean);
  94359. /**
  94360. * Gets or sets a boolean indicating that non uniform scaling (when at least one component is different from others) should be ignored.
  94361. * By default the system will update normals to compensate
  94362. */
  94363. ignoreNonUniformScaling: boolean;
  94364. /**
  94365. * 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
  94366. */
  94367. reIntegrateRotationIntoRotationQuaternion: boolean;
  94368. /** @hidden */
  94369. _poseMatrix: Nullable<Matrix>;
  94370. /** @hidden */
  94371. _localMatrix: Matrix;
  94372. private _usePivotMatrix;
  94373. private _absolutePosition;
  94374. private _absoluteScaling;
  94375. private _absoluteRotationQuaternion;
  94376. private _pivotMatrix;
  94377. private _pivotMatrixInverse;
  94378. protected _postMultiplyPivotMatrix: boolean;
  94379. protected _isWorldMatrixFrozen: boolean;
  94380. /** @hidden */
  94381. _indexInSceneTransformNodesArray: number;
  94382. /**
  94383. * An event triggered after the world matrix is updated
  94384. */
  94385. onAfterWorldMatrixUpdateObservable: Observable<TransformNode>;
  94386. constructor(name: string, scene?: Nullable<Scene>, isPure?: boolean);
  94387. /**
  94388. * Gets a string identifying the name of the class
  94389. * @returns "TransformNode" string
  94390. */
  94391. getClassName(): string;
  94392. /**
  94393. * Gets or set the node position (default is (0.0, 0.0, 0.0))
  94394. */
  94395. get position(): Vector3;
  94396. set position(newPosition: Vector3);
  94397. /**
  94398. * 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)).
  94399. * If rotation quaternion is set, this Vector3 will be ignored and copy from the quaternion
  94400. */
  94401. get rotation(): Vector3;
  94402. set rotation(newRotation: Vector3);
  94403. /**
  94404. * 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)).
  94405. */
  94406. get scaling(): Vector3;
  94407. set scaling(newScaling: Vector3);
  94408. /**
  94409. * 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).
  94410. * If set, only the rotationQuaternion is then used to compute the node rotation (ie. node.rotation will be ignored)
  94411. */
  94412. get rotationQuaternion(): Nullable<Quaternion>;
  94413. set rotationQuaternion(quaternion: Nullable<Quaternion>);
  94414. /**
  94415. * The forward direction of that transform in world space.
  94416. */
  94417. get forward(): Vector3;
  94418. /**
  94419. * The up direction of that transform in world space.
  94420. */
  94421. get up(): Vector3;
  94422. /**
  94423. * The right direction of that transform in world space.
  94424. */
  94425. get right(): Vector3;
  94426. /**
  94427. * Copies the parameter passed Matrix into the mesh Pose matrix.
  94428. * @param matrix the matrix to copy the pose from
  94429. * @returns this TransformNode.
  94430. */
  94431. updatePoseMatrix(matrix: Matrix): TransformNode;
  94432. /**
  94433. * Returns the mesh Pose matrix.
  94434. * @returns the pose matrix
  94435. */
  94436. getPoseMatrix(): Matrix;
  94437. /** @hidden */
  94438. _isSynchronized(): boolean;
  94439. /** @hidden */
  94440. _initCache(): void;
  94441. /**
  94442. * Flag the transform node as dirty (Forcing it to update everything)
  94443. * @param property if set to "rotation" the objects rotationQuaternion will be set to null
  94444. * @returns this transform node
  94445. */
  94446. markAsDirty(property: string): TransformNode;
  94447. /**
  94448. * Returns the current mesh absolute position.
  94449. * Returns a Vector3.
  94450. */
  94451. get absolutePosition(): Vector3;
  94452. /**
  94453. * Returns the current mesh absolute scaling.
  94454. * Returns a Vector3.
  94455. */
  94456. get absoluteScaling(): Vector3;
  94457. /**
  94458. * Returns the current mesh absolute rotation.
  94459. * Returns a Quaternion.
  94460. */
  94461. get absoluteRotationQuaternion(): Quaternion;
  94462. /**
  94463. * Sets a new matrix to apply before all other transformation
  94464. * @param matrix defines the transform matrix
  94465. * @returns the current TransformNode
  94466. */
  94467. setPreTransformMatrix(matrix: Matrix): TransformNode;
  94468. /**
  94469. * Sets a new pivot matrix to the current node
  94470. * @param matrix defines the new pivot matrix to use
  94471. * @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
  94472. * @returns the current TransformNode
  94473. */
  94474. setPivotMatrix(matrix: DeepImmutable<Matrix>, postMultiplyPivotMatrix?: boolean): TransformNode;
  94475. /**
  94476. * Returns the mesh pivot matrix.
  94477. * Default : Identity.
  94478. * @returns the matrix
  94479. */
  94480. getPivotMatrix(): Matrix;
  94481. /**
  94482. * Instantiate (when possible) or clone that node with its hierarchy
  94483. * @param newParent defines the new parent to use for the instance (or clone)
  94484. * @param options defines options to configure how copy is done
  94485. * @param onNewNodeCreated defines an option callback to call when a clone or an instance is created
  94486. * @returns an instance (or a clone) of the current node with its hiearchy
  94487. */
  94488. instantiateHierarchy(newParent?: Nullable<TransformNode>, options?: {
  94489. doNotInstantiate: boolean;
  94490. }, onNewNodeCreated?: (source: TransformNode, clone: TransformNode) => void): Nullable<TransformNode>;
  94491. /**
  94492. * Prevents the World matrix to be computed any longer
  94493. * @param newWorldMatrix defines an optional matrix to use as world matrix
  94494. * @returns the TransformNode.
  94495. */
  94496. freezeWorldMatrix(newWorldMatrix?: Nullable<Matrix>): TransformNode;
  94497. /**
  94498. * Allows back the World matrix computation.
  94499. * @returns the TransformNode.
  94500. */
  94501. unfreezeWorldMatrix(): this;
  94502. /**
  94503. * True if the World matrix has been frozen.
  94504. */
  94505. get isWorldMatrixFrozen(): boolean;
  94506. /**
  94507. * Retuns the mesh absolute position in the World.
  94508. * @returns a Vector3.
  94509. */
  94510. getAbsolutePosition(): Vector3;
  94511. /**
  94512. * Sets the mesh absolute position in the World from a Vector3 or an Array(3).
  94513. * @param absolutePosition the absolute position to set
  94514. * @returns the TransformNode.
  94515. */
  94516. setAbsolutePosition(absolutePosition: Vector3): TransformNode;
  94517. /**
  94518. * Sets the mesh position in its local space.
  94519. * @param vector3 the position to set in localspace
  94520. * @returns the TransformNode.
  94521. */
  94522. setPositionWithLocalVector(vector3: Vector3): TransformNode;
  94523. /**
  94524. * Returns the mesh position in the local space from the current World matrix values.
  94525. * @returns a new Vector3.
  94526. */
  94527. getPositionExpressedInLocalSpace(): Vector3;
  94528. /**
  94529. * Translates the mesh along the passed Vector3 in its local space.
  94530. * @param vector3 the distance to translate in localspace
  94531. * @returns the TransformNode.
  94532. */
  94533. locallyTranslate(vector3: Vector3): TransformNode;
  94534. private static _lookAtVectorCache;
  94535. /**
  94536. * Orients a mesh towards a target point. Mesh must be drawn facing user.
  94537. * @param targetPoint the position (must be in same space as current mesh) to look at
  94538. * @param yawCor optional yaw (y-axis) correction in radians
  94539. * @param pitchCor optional pitch (x-axis) correction in radians
  94540. * @param rollCor optional roll (z-axis) correction in radians
  94541. * @param space the choosen space of the target
  94542. * @returns the TransformNode.
  94543. */
  94544. lookAt(targetPoint: Vector3, yawCor?: number, pitchCor?: number, rollCor?: number, space?: Space): TransformNode;
  94545. /**
  94546. * Returns a new Vector3 that is the localAxis, expressed in the mesh local space, rotated like the mesh.
  94547. * This Vector3 is expressed in the World space.
  94548. * @param localAxis axis to rotate
  94549. * @returns a new Vector3 that is the localAxis, expressed in the mesh local space, rotated like the mesh.
  94550. */
  94551. getDirection(localAxis: Vector3): Vector3;
  94552. /**
  94553. * Sets the Vector3 "result" as the rotated Vector3 "localAxis" in the same rotation than the mesh.
  94554. * localAxis is expressed in the mesh local space.
  94555. * result is computed in the Wordl space from the mesh World matrix.
  94556. * @param localAxis axis to rotate
  94557. * @param result the resulting transformnode
  94558. * @returns this TransformNode.
  94559. */
  94560. getDirectionToRef(localAxis: Vector3, result: Vector3): TransformNode;
  94561. /**
  94562. * Sets this transform node rotation to the given local axis.
  94563. * @param localAxis the axis in local space
  94564. * @param yawCor optional yaw (y-axis) correction in radians
  94565. * @param pitchCor optional pitch (x-axis) correction in radians
  94566. * @param rollCor optional roll (z-axis) correction in radians
  94567. * @returns this TransformNode
  94568. */
  94569. setDirection(localAxis: Vector3, yawCor?: number, pitchCor?: number, rollCor?: number): TransformNode;
  94570. /**
  94571. * Sets a new pivot point to the current node
  94572. * @param point defines the new pivot point to use
  94573. * @param space defines if the point is in world or local space (local by default)
  94574. * @returns the current TransformNode
  94575. */
  94576. setPivotPoint(point: Vector3, space?: Space): TransformNode;
  94577. /**
  94578. * Returns a new Vector3 set with the mesh pivot point coordinates in the local space.
  94579. * @returns the pivot point
  94580. */
  94581. getPivotPoint(): Vector3;
  94582. /**
  94583. * Sets the passed Vector3 "result" with the coordinates of the mesh pivot point in the local space.
  94584. * @param result the vector3 to store the result
  94585. * @returns this TransformNode.
  94586. */
  94587. getPivotPointToRef(result: Vector3): TransformNode;
  94588. /**
  94589. * Returns a new Vector3 set with the mesh pivot point World coordinates.
  94590. * @returns a new Vector3 set with the mesh pivot point World coordinates.
  94591. */
  94592. getAbsolutePivotPoint(): Vector3;
  94593. /**
  94594. * Sets the Vector3 "result" coordinates with the mesh pivot point World coordinates.
  94595. * @param result vector3 to store the result
  94596. * @returns this TransformNode.
  94597. */
  94598. getAbsolutePivotPointToRef(result: Vector3): TransformNode;
  94599. /**
  94600. * Defines the passed node as the parent of the current node.
  94601. * The node will remain exactly where it is and its position / rotation will be updated accordingly
  94602. * @see https://doc.babylonjs.com/how_to/parenting
  94603. * @param node the node ot set as the parent
  94604. * @returns this TransformNode.
  94605. */
  94606. setParent(node: Nullable<Node>): TransformNode;
  94607. private _nonUniformScaling;
  94608. /**
  94609. * True if the scaling property of this object is non uniform eg. (1,2,1)
  94610. */
  94611. get nonUniformScaling(): boolean;
  94612. /** @hidden */
  94613. _updateNonUniformScalingState(value: boolean): boolean;
  94614. /**
  94615. * Attach the current TransformNode to another TransformNode associated with a bone
  94616. * @param bone Bone affecting the TransformNode
  94617. * @param affectedTransformNode TransformNode associated with the bone
  94618. * @returns this object
  94619. */
  94620. attachToBone(bone: Bone, affectedTransformNode: TransformNode): TransformNode;
  94621. /**
  94622. * Detach the transform node if its associated with a bone
  94623. * @returns this object
  94624. */
  94625. detachFromBone(): TransformNode;
  94626. private static _rotationAxisCache;
  94627. /**
  94628. * Rotates the mesh around the axis vector for the passed angle (amount) expressed in radians, in the given space.
  94629. * space (default LOCAL) can be either Space.LOCAL, either Space.WORLD.
  94630. * Note that the property `rotationQuaternion` is then automatically updated and the property `rotation` is set to (0,0,0) and no longer used.
  94631. * The passed axis is also normalized.
  94632. * @param axis the axis to rotate around
  94633. * @param amount the amount to rotate in radians
  94634. * @param space Space to rotate in (Default: local)
  94635. * @returns the TransformNode.
  94636. */
  94637. rotate(axis: Vector3, amount: number, space?: Space): TransformNode;
  94638. /**
  94639. * Rotates the mesh around the axis vector for the passed angle (amount) expressed in radians, in world space.
  94640. * Note that the property `rotationQuaternion` is then automatically updated and the property `rotation` is set to (0,0,0) and no longer used.
  94641. * The passed axis is also normalized. .
  94642. * Method is based on http://www.euclideanspace.com/maths/geometry/affine/aroundPoint/index.htm
  94643. * @param point the point to rotate around
  94644. * @param axis the axis to rotate around
  94645. * @param amount the amount to rotate in radians
  94646. * @returns the TransformNode
  94647. */
  94648. rotateAround(point: Vector3, axis: Vector3, amount: number): TransformNode;
  94649. /**
  94650. * Translates the mesh along the axis vector for the passed distance in the given space.
  94651. * space (default LOCAL) can be either Space.LOCAL, either Space.WORLD.
  94652. * @param axis the axis to translate in
  94653. * @param distance the distance to translate
  94654. * @param space Space to rotate in (Default: local)
  94655. * @returns the TransformNode.
  94656. */
  94657. translate(axis: Vector3, distance: number, space?: Space): TransformNode;
  94658. /**
  94659. * Adds a rotation step to the mesh current rotation.
  94660. * x, y, z are Euler angles expressed in radians.
  94661. * This methods updates the current mesh rotation, either mesh.rotation, either mesh.rotationQuaternion if it's set.
  94662. * This means this rotation is made in the mesh local space only.
  94663. * It's useful to set a custom rotation order different from the BJS standard one YXZ.
  94664. * Example : this rotates the mesh first around its local X axis, then around its local Z axis, finally around its local Y axis.
  94665. * ```javascript
  94666. * mesh.addRotation(x1, 0, 0).addRotation(0, 0, z2).addRotation(0, 0, y3);
  94667. * ```
  94668. * Note that `addRotation()` accumulates the passed rotation values to the current ones and computes the .rotation or .rotationQuaternion updated values.
  94669. * 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.
  94670. * @param x Rotation to add
  94671. * @param y Rotation to add
  94672. * @param z Rotation to add
  94673. * @returns the TransformNode.
  94674. */
  94675. addRotation(x: number, y: number, z: number): TransformNode;
  94676. /**
  94677. * @hidden
  94678. */
  94679. protected _getEffectiveParent(): Nullable<Node>;
  94680. /**
  94681. * Computes the world matrix of the node
  94682. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  94683. * @returns the world matrix
  94684. */
  94685. computeWorldMatrix(force?: boolean): Matrix;
  94686. /**
  94687. * Resets this nodeTransform's local matrix to Matrix.Identity().
  94688. * @param independentOfChildren indicates if all child nodeTransform's world-space transform should be preserved.
  94689. */
  94690. resetLocalMatrix(independentOfChildren?: boolean): void;
  94691. protected _afterComputeWorldMatrix(): void;
  94692. /**
  94693. * If you'd like to be called back after the mesh position, rotation or scaling has been updated.
  94694. * @param func callback function to add
  94695. *
  94696. * @returns the TransformNode.
  94697. */
  94698. registerAfterWorldMatrixUpdate(func: (mesh: TransformNode) => void): TransformNode;
  94699. /**
  94700. * Removes a registered callback function.
  94701. * @param func callback function to remove
  94702. * @returns the TransformNode.
  94703. */
  94704. unregisterAfterWorldMatrixUpdate(func: (mesh: TransformNode) => void): TransformNode;
  94705. /**
  94706. * Gets the position of the current mesh in camera space
  94707. * @param camera defines the camera to use
  94708. * @returns a position
  94709. */
  94710. getPositionInCameraSpace(camera?: Nullable<Camera>): Vector3;
  94711. /**
  94712. * Returns the distance from the mesh to the active camera
  94713. * @param camera defines the camera to use
  94714. * @returns the distance
  94715. */
  94716. getDistanceToCamera(camera?: Nullable<Camera>): number;
  94717. /**
  94718. * Clone the current transform node
  94719. * @param name Name of the new clone
  94720. * @param newParent New parent for the clone
  94721. * @param doNotCloneChildren Do not clone children hierarchy
  94722. * @returns the new transform node
  94723. */
  94724. clone(name: string, newParent: Nullable<Node>, doNotCloneChildren?: boolean): Nullable<TransformNode>;
  94725. /**
  94726. * Serializes the objects information.
  94727. * @param currentSerializationObject defines the object to serialize in
  94728. * @returns the serialized object
  94729. */
  94730. serialize(currentSerializationObject?: any): any;
  94731. /**
  94732. * Returns a new TransformNode object parsed from the source provided.
  94733. * @param parsedTransformNode is the source.
  94734. * @param scene the scne the object belongs to
  94735. * @param rootUrl is a string, it's the root URL to prefix the `delayLoadingFile` property with
  94736. * @returns a new TransformNode object parsed from the source provided.
  94737. */
  94738. static Parse(parsedTransformNode: any, scene: Scene, rootUrl: string): TransformNode;
  94739. /**
  94740. * Get all child-transformNodes of this node
  94741. * @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
  94742. * @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
  94743. * @returns an array of TransformNode
  94744. */
  94745. getChildTransformNodes(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): TransformNode[];
  94746. /**
  94747. * Releases resources associated with this transform node.
  94748. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  94749. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  94750. */
  94751. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  94752. /**
  94753. * Uniformly scales the mesh to fit inside of a unit cube (1 X 1 X 1 units)
  94754. * @param includeDescendants Use the hierarchy's bounding box instead of the mesh's bounding box. Default is false
  94755. * @param ignoreRotation ignore rotation when computing the scale (ie. object will be axis aligned). Default is false
  94756. * @param predicate predicate that is passed in to getHierarchyBoundingVectors when selecting which object should be included when scaling
  94757. * @returns the current mesh
  94758. */
  94759. normalizeToUnitCube(includeDescendants?: boolean, ignoreRotation?: boolean, predicate?: Nullable<(node: AbstractMesh) => boolean>): TransformNode;
  94760. private _syncAbsoluteScalingAndRotation;
  94761. }
  94762. }
  94763. declare module BABYLON {
  94764. /**
  94765. * Class used to override all child animations of a given target
  94766. */
  94767. export class AnimationPropertiesOverride {
  94768. /**
  94769. * Gets or sets a value indicating if animation blending must be used
  94770. */
  94771. enableBlending: boolean;
  94772. /**
  94773. * Gets or sets the blending speed to use when enableBlending is true
  94774. */
  94775. blendingSpeed: number;
  94776. /**
  94777. * Gets or sets the default loop mode to use
  94778. */
  94779. loopMode: number;
  94780. }
  94781. }
  94782. declare module BABYLON {
  94783. /**
  94784. * Class used to store bone information
  94785. * @see https://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  94786. */
  94787. export class Bone extends Node {
  94788. /**
  94789. * defines the bone name
  94790. */
  94791. name: string;
  94792. private static _tmpVecs;
  94793. private static _tmpQuat;
  94794. private static _tmpMats;
  94795. /**
  94796. * Gets the list of child bones
  94797. */
  94798. children: Bone[];
  94799. /** Gets the animations associated with this bone */
  94800. animations: Animation[];
  94801. /**
  94802. * Gets or sets bone length
  94803. */
  94804. length: number;
  94805. /**
  94806. * @hidden Internal only
  94807. * Set this value to map this bone to a different index in the transform matrices
  94808. * Set this value to -1 to exclude the bone from the transform matrices
  94809. */
  94810. _index: Nullable<number>;
  94811. private _skeleton;
  94812. private _localMatrix;
  94813. private _restPose;
  94814. private _bindPose;
  94815. private _baseMatrix;
  94816. private _absoluteTransform;
  94817. private _invertedAbsoluteTransform;
  94818. private _parent;
  94819. private _scalingDeterminant;
  94820. private _worldTransform;
  94821. private _localScaling;
  94822. private _localRotation;
  94823. private _localPosition;
  94824. private _needToDecompose;
  94825. private _needToCompose;
  94826. /** @hidden */
  94827. _linkedTransformNode: Nullable<TransformNode>;
  94828. /** @hidden */
  94829. _waitingTransformNodeId: Nullable<string>;
  94830. /** @hidden */
  94831. get _matrix(): Matrix;
  94832. /** @hidden */
  94833. set _matrix(value: Matrix);
  94834. /**
  94835. * Create a new bone
  94836. * @param name defines the bone name
  94837. * @param skeleton defines the parent skeleton
  94838. * @param parentBone defines the parent (can be null if the bone is the root)
  94839. * @param localMatrix defines the local matrix
  94840. * @param restPose defines the rest pose matrix
  94841. * @param baseMatrix defines the base matrix
  94842. * @param index defines index of the bone in the hiearchy
  94843. */
  94844. constructor(
  94845. /**
  94846. * defines the bone name
  94847. */
  94848. name: string, skeleton: Skeleton, parentBone?: Nullable<Bone>, localMatrix?: Nullable<Matrix>, restPose?: Nullable<Matrix>, baseMatrix?: Nullable<Matrix>, index?: Nullable<number>);
  94849. /**
  94850. * Gets the current object class name.
  94851. * @return the class name
  94852. */
  94853. getClassName(): string;
  94854. /**
  94855. * Gets the parent skeleton
  94856. * @returns a skeleton
  94857. */
  94858. getSkeleton(): Skeleton;
  94859. /**
  94860. * Gets parent bone
  94861. * @returns a bone or null if the bone is the root of the bone hierarchy
  94862. */
  94863. getParent(): Nullable<Bone>;
  94864. /**
  94865. * Returns an array containing the root bones
  94866. * @returns an array containing the root bones
  94867. */
  94868. getChildren(): Array<Bone>;
  94869. /**
  94870. * Gets the node index in matrix array generated for rendering
  94871. * @returns the node index
  94872. */
  94873. getIndex(): number;
  94874. /**
  94875. * Sets the parent bone
  94876. * @param parent defines the parent (can be null if the bone is the root)
  94877. * @param updateDifferenceMatrix defines if the difference matrix must be updated
  94878. */
  94879. setParent(parent: Nullable<Bone>, updateDifferenceMatrix?: boolean): void;
  94880. /**
  94881. * Gets the local matrix
  94882. * @returns a matrix
  94883. */
  94884. getLocalMatrix(): Matrix;
  94885. /**
  94886. * Gets the base matrix (initial matrix which remains unchanged)
  94887. * @returns a matrix
  94888. */
  94889. getBaseMatrix(): Matrix;
  94890. /**
  94891. * Gets the rest pose matrix
  94892. * @returns a matrix
  94893. */
  94894. getRestPose(): Matrix;
  94895. /**
  94896. * Sets the rest pose matrix
  94897. * @param matrix the local-space rest pose to set for this bone
  94898. */
  94899. setRestPose(matrix: Matrix): void;
  94900. /**
  94901. * Gets the bind pose matrix
  94902. * @returns the bind pose matrix
  94903. */
  94904. getBindPose(): Matrix;
  94905. /**
  94906. * Sets the bind pose matrix
  94907. * @param matrix the local-space bind pose to set for this bone
  94908. */
  94909. setBindPose(matrix: Matrix): void;
  94910. /**
  94911. * Gets a matrix used to store world matrix (ie. the matrix sent to shaders)
  94912. */
  94913. getWorldMatrix(): Matrix;
  94914. /**
  94915. * Sets the local matrix to rest pose matrix
  94916. */
  94917. returnToRest(): void;
  94918. /**
  94919. * Gets the inverse of the absolute transform matrix.
  94920. * This matrix will be multiplied by local matrix to get the difference matrix (ie. the difference between original state and current state)
  94921. * @returns a matrix
  94922. */
  94923. getInvertedAbsoluteTransform(): Matrix;
  94924. /**
  94925. * Gets the absolute transform matrix (ie base matrix * parent world matrix)
  94926. * @returns a matrix
  94927. */
  94928. getAbsoluteTransform(): Matrix;
  94929. /**
  94930. * Links with the given transform node.
  94931. * The local matrix of this bone is copied from the transform node every frame.
  94932. * @param transformNode defines the transform node to link to
  94933. */
  94934. linkTransformNode(transformNode: Nullable<TransformNode>): void;
  94935. /**
  94936. * Gets the node used to drive the bone's transformation
  94937. * @returns a transform node or null
  94938. */
  94939. getTransformNode(): Nullable<TransformNode>;
  94940. /** Gets or sets current position (in local space) */
  94941. get position(): Vector3;
  94942. set position(newPosition: Vector3);
  94943. /** Gets or sets current rotation (in local space) */
  94944. get rotation(): Vector3;
  94945. set rotation(newRotation: Vector3);
  94946. /** Gets or sets current rotation quaternion (in local space) */
  94947. get rotationQuaternion(): Quaternion;
  94948. set rotationQuaternion(newRotation: Quaternion);
  94949. /** Gets or sets current scaling (in local space) */
  94950. get scaling(): Vector3;
  94951. set scaling(newScaling: Vector3);
  94952. /**
  94953. * Gets the animation properties override
  94954. */
  94955. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  94956. private _decompose;
  94957. private _compose;
  94958. /**
  94959. * Update the base and local matrices
  94960. * @param matrix defines the new base or local matrix
  94961. * @param updateDifferenceMatrix defines if the difference matrix must be updated
  94962. * @param updateLocalMatrix defines if the local matrix should be updated
  94963. */
  94964. updateMatrix(matrix: Matrix, updateDifferenceMatrix?: boolean, updateLocalMatrix?: boolean): void;
  94965. /** @hidden */
  94966. _updateDifferenceMatrix(rootMatrix?: Matrix, updateChildren?: boolean): void;
  94967. /**
  94968. * Flag the bone as dirty (Forcing it to update everything)
  94969. */
  94970. markAsDirty(): void;
  94971. /** @hidden */
  94972. _markAsDirtyAndCompose(): void;
  94973. private _markAsDirtyAndDecompose;
  94974. /**
  94975. * Translate the bone in local or world space
  94976. * @param vec The amount to translate the bone
  94977. * @param space The space that the translation is in
  94978. * @param mesh The mesh that this bone is attached to. This is only used in world space
  94979. */
  94980. translate(vec: Vector3, space?: Space, mesh?: AbstractMesh): void;
  94981. /**
  94982. * Set the postion of the bone in local or world space
  94983. * @param position The position to set the bone
  94984. * @param space The space that the position is in
  94985. * @param mesh The mesh that this bone is attached to. This is only used in world space
  94986. */
  94987. setPosition(position: Vector3, space?: Space, mesh?: AbstractMesh): void;
  94988. /**
  94989. * Set the absolute position of the bone (world space)
  94990. * @param position The position to set the bone
  94991. * @param mesh The mesh that this bone is attached to
  94992. */
  94993. setAbsolutePosition(position: Vector3, mesh?: AbstractMesh): void;
  94994. /**
  94995. * Scale the bone on the x, y and z axes (in local space)
  94996. * @param x The amount to scale the bone on the x axis
  94997. * @param y The amount to scale the bone on the y axis
  94998. * @param z The amount to scale the bone on the z axis
  94999. * @param scaleChildren sets this to true if children of the bone should be scaled as well (false by default)
  95000. */
  95001. scale(x: number, y: number, z: number, scaleChildren?: boolean): void;
  95002. /**
  95003. * Set the bone scaling in local space
  95004. * @param scale defines the scaling vector
  95005. */
  95006. setScale(scale: Vector3): void;
  95007. /**
  95008. * Gets the current scaling in local space
  95009. * @returns the current scaling vector
  95010. */
  95011. getScale(): Vector3;
  95012. /**
  95013. * Gets the current scaling in local space and stores it in a target vector
  95014. * @param result defines the target vector
  95015. */
  95016. getScaleToRef(result: Vector3): void;
  95017. /**
  95018. * Set the yaw, pitch, and roll of the bone in local or world space
  95019. * @param yaw The rotation of the bone on the y axis
  95020. * @param pitch The rotation of the bone on the x axis
  95021. * @param roll The rotation of the bone on the z axis
  95022. * @param space The space that the axes of rotation are in
  95023. * @param mesh The mesh that this bone is attached to. This is only used in world space
  95024. */
  95025. setYawPitchRoll(yaw: number, pitch: number, roll: number, space?: Space, mesh?: AbstractMesh): void;
  95026. /**
  95027. * Add a rotation to the bone on an axis in local or world space
  95028. * @param axis The axis to rotate the bone on
  95029. * @param amount The amount to rotate the bone
  95030. * @param space The space that the axis is in
  95031. * @param mesh The mesh that this bone is attached to. This is only used in world space
  95032. */
  95033. rotate(axis: Vector3, amount: number, space?: Space, mesh?: AbstractMesh): void;
  95034. /**
  95035. * Set the rotation of the bone to a particular axis angle in local or world space
  95036. * @param axis The axis to rotate the bone on
  95037. * @param angle The angle that the bone should be rotated to
  95038. * @param space The space that the axis is in
  95039. * @param mesh The mesh that this bone is attached to. This is only used in world space
  95040. */
  95041. setAxisAngle(axis: Vector3, angle: number, space?: Space, mesh?: AbstractMesh): void;
  95042. /**
  95043. * Set the euler rotation of the bone in local of world space
  95044. * @param rotation The euler rotation that the bone should be set to
  95045. * @param space The space that the rotation is in
  95046. * @param mesh The mesh that this bone is attached to. This is only used in world space
  95047. */
  95048. setRotation(rotation: Vector3, space?: Space, mesh?: AbstractMesh): void;
  95049. /**
  95050. * Set the quaternion rotation of the bone in local of world space
  95051. * @param quat The quaternion rotation that the bone should be set to
  95052. * @param space The space that the rotation is in
  95053. * @param mesh The mesh that this bone is attached to. This is only used in world space
  95054. */
  95055. setRotationQuaternion(quat: Quaternion, space?: Space, mesh?: AbstractMesh): void;
  95056. /**
  95057. * Set the rotation matrix of the bone in local of world space
  95058. * @param rotMat The rotation matrix that the bone should be set to
  95059. * @param space The space that the rotation is in
  95060. * @param mesh The mesh that this bone is attached to. This is only used in world space
  95061. */
  95062. setRotationMatrix(rotMat: Matrix, space?: Space, mesh?: AbstractMesh): void;
  95063. private _rotateWithMatrix;
  95064. private _getNegativeRotationToRef;
  95065. /**
  95066. * Get the position of the bone in local or world space
  95067. * @param space The space that the returned position is in
  95068. * @param mesh The mesh that this bone is attached to. This is only used in world space
  95069. * @returns The position of the bone
  95070. */
  95071. getPosition(space?: Space, mesh?: Nullable<AbstractMesh>): Vector3;
  95072. /**
  95073. * Copy the position of the bone to a vector3 in local or world space
  95074. * @param space The space that the returned position is in
  95075. * @param mesh The mesh that this bone is attached to. This is only used in world space
  95076. * @param result The vector3 to copy the position to
  95077. */
  95078. getPositionToRef(space: Space | undefined, mesh: Nullable<AbstractMesh>, result: Vector3): void;
  95079. /**
  95080. * Get the absolute position of the bone (world space)
  95081. * @param mesh The mesh that this bone is attached to
  95082. * @returns The absolute position of the bone
  95083. */
  95084. getAbsolutePosition(mesh?: Nullable<AbstractMesh>): Vector3;
  95085. /**
  95086. * Copy the absolute position of the bone (world space) to the result param
  95087. * @param mesh The mesh that this bone is attached to
  95088. * @param result The vector3 to copy the absolute position to
  95089. */
  95090. getAbsolutePositionToRef(mesh: AbstractMesh, result: Vector3): void;
  95091. /**
  95092. * Compute the absolute transforms of this bone and its children
  95093. */
  95094. computeAbsoluteTransforms(): void;
  95095. /**
  95096. * Get the world direction from an axis that is in the local space of the bone
  95097. * @param localAxis The local direction that is used to compute the world direction
  95098. * @param mesh The mesh that this bone is attached to
  95099. * @returns The world direction
  95100. */
  95101. getDirection(localAxis: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  95102. /**
  95103. * Copy the world direction to a vector3 from an axis that is in the local space of the bone
  95104. * @param localAxis The local direction that is used to compute the world direction
  95105. * @param mesh The mesh that this bone is attached to
  95106. * @param result The vector3 that the world direction will be copied to
  95107. */
  95108. getDirectionToRef(localAxis: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  95109. /**
  95110. * Get the euler rotation of the bone in local or world space
  95111. * @param space The space that the rotation should be in
  95112. * @param mesh The mesh that this bone is attached to. This is only used in world space
  95113. * @returns The euler rotation
  95114. */
  95115. getRotation(space?: Space, mesh?: Nullable<AbstractMesh>): Vector3;
  95116. /**
  95117. * Copy the euler rotation of the bone to a vector3. The rotation can be in either local or world space
  95118. * @param space The space that the rotation should be in
  95119. * @param mesh The mesh that this bone is attached to. This is only used in world space
  95120. * @param result The vector3 that the rotation should be copied to
  95121. */
  95122. getRotationToRef(space: Space | undefined, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  95123. /**
  95124. * Get the quaternion rotation of the bone in either local or world space
  95125. * @param space The space that the rotation should be in
  95126. * @param mesh The mesh that this bone is attached to. This is only used in world space
  95127. * @returns The quaternion rotation
  95128. */
  95129. getRotationQuaternion(space?: Space, mesh?: Nullable<AbstractMesh>): Quaternion;
  95130. /**
  95131. * Copy the quaternion rotation of the bone to a quaternion. The rotation can be in either local or world space
  95132. * @param space The space that the rotation should be in
  95133. * @param mesh The mesh that this bone is attached to. This is only used in world space
  95134. * @param result The quaternion that the rotation should be copied to
  95135. */
  95136. getRotationQuaternionToRef(space: Space | undefined, mesh: AbstractMesh | null | undefined, result: Quaternion): void;
  95137. /**
  95138. * Get the rotation matrix of the bone in local or world space
  95139. * @param space The space that the rotation should be in
  95140. * @param mesh The mesh that this bone is attached to. This is only used in world space
  95141. * @returns The rotation matrix
  95142. */
  95143. getRotationMatrix(space: Space | undefined, mesh: AbstractMesh): Matrix;
  95144. /**
  95145. * Copy the rotation matrix of the bone to a matrix. The rotation can be in either local or world space
  95146. * @param space The space that the rotation should be in
  95147. * @param mesh The mesh that this bone is attached to. This is only used in world space
  95148. * @param result The quaternion that the rotation should be copied to
  95149. */
  95150. getRotationMatrixToRef(space: Space | undefined, mesh: AbstractMesh, result: Matrix): void;
  95151. /**
  95152. * Get the world position of a point that is in the local space of the bone
  95153. * @param position The local position
  95154. * @param mesh The mesh that this bone is attached to
  95155. * @returns The world position
  95156. */
  95157. getAbsolutePositionFromLocal(position: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  95158. /**
  95159. * Get the world position of a point that is in the local space of the bone and copy it to the result param
  95160. * @param position The local position
  95161. * @param mesh The mesh that this bone is attached to
  95162. * @param result The vector3 that the world position should be copied to
  95163. */
  95164. getAbsolutePositionFromLocalToRef(position: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  95165. /**
  95166. * Get the local position of a point that is in world space
  95167. * @param position The world position
  95168. * @param mesh The mesh that this bone is attached to
  95169. * @returns The local position
  95170. */
  95171. getLocalPositionFromAbsolute(position: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  95172. /**
  95173. * Get the local position of a point that is in world space and copy it to the result param
  95174. * @param position The world position
  95175. * @param mesh The mesh that this bone is attached to
  95176. * @param result The vector3 that the local position should be copied to
  95177. */
  95178. getLocalPositionFromAbsoluteToRef(position: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  95179. }
  95180. }
  95181. declare module BABYLON {
  95182. /**
  95183. * Defines a runtime animation
  95184. */
  95185. export class RuntimeAnimation {
  95186. private _events;
  95187. /**
  95188. * The current frame of the runtime animation
  95189. */
  95190. private _currentFrame;
  95191. /**
  95192. * The animation used by the runtime animation
  95193. */
  95194. private _animation;
  95195. /**
  95196. * The target of the runtime animation
  95197. */
  95198. private _target;
  95199. /**
  95200. * The initiating animatable
  95201. */
  95202. private _host;
  95203. /**
  95204. * The original value of the runtime animation
  95205. */
  95206. private _originalValue;
  95207. /**
  95208. * The original blend value of the runtime animation
  95209. */
  95210. private _originalBlendValue;
  95211. /**
  95212. * The offsets cache of the runtime animation
  95213. */
  95214. private _offsetsCache;
  95215. /**
  95216. * The high limits cache of the runtime animation
  95217. */
  95218. private _highLimitsCache;
  95219. /**
  95220. * Specifies if the runtime animation has been stopped
  95221. */
  95222. private _stopped;
  95223. /**
  95224. * The blending factor of the runtime animation
  95225. */
  95226. private _blendingFactor;
  95227. /**
  95228. * The BabylonJS scene
  95229. */
  95230. private _scene;
  95231. /**
  95232. * The current value of the runtime animation
  95233. */
  95234. private _currentValue;
  95235. /** @hidden */
  95236. _animationState: _IAnimationState;
  95237. /**
  95238. * The active target of the runtime animation
  95239. */
  95240. private _activeTargets;
  95241. private _currentActiveTarget;
  95242. private _directTarget;
  95243. /**
  95244. * The target path of the runtime animation
  95245. */
  95246. private _targetPath;
  95247. /**
  95248. * The weight of the runtime animation
  95249. */
  95250. private _weight;
  95251. /**
  95252. * The ratio offset of the runtime animation
  95253. */
  95254. private _ratioOffset;
  95255. /**
  95256. * The previous delay of the runtime animation
  95257. */
  95258. private _previousDelay;
  95259. /**
  95260. * The previous ratio of the runtime animation
  95261. */
  95262. private _previousRatio;
  95263. private _enableBlending;
  95264. private _keys;
  95265. private _minFrame;
  95266. private _maxFrame;
  95267. private _minValue;
  95268. private _maxValue;
  95269. private _targetIsArray;
  95270. /**
  95271. * Gets the current frame of the runtime animation
  95272. */
  95273. get currentFrame(): number;
  95274. /**
  95275. * Gets the weight of the runtime animation
  95276. */
  95277. get weight(): number;
  95278. /**
  95279. * Gets the current value of the runtime animation
  95280. */
  95281. get currentValue(): any;
  95282. /**
  95283. * Gets the target path of the runtime animation
  95284. */
  95285. get targetPath(): string;
  95286. /**
  95287. * Gets the actual target of the runtime animation
  95288. */
  95289. get target(): any;
  95290. /**
  95291. * Gets the additive state of the runtime animation
  95292. */
  95293. get isAdditive(): boolean;
  95294. /** @hidden */
  95295. _onLoop: () => void;
  95296. /**
  95297. * Create a new RuntimeAnimation object
  95298. * @param target defines the target of the animation
  95299. * @param animation defines the source animation object
  95300. * @param scene defines the hosting scene
  95301. * @param host defines the initiating Animatable
  95302. */
  95303. constructor(target: any, animation: Animation, scene: Scene, host: Animatable);
  95304. private _preparePath;
  95305. /**
  95306. * Gets the animation from the runtime animation
  95307. */
  95308. get animation(): Animation;
  95309. /**
  95310. * Resets the runtime animation to the beginning
  95311. * @param restoreOriginal defines whether to restore the target property to the original value
  95312. */
  95313. reset(restoreOriginal?: boolean): void;
  95314. /**
  95315. * Specifies if the runtime animation is stopped
  95316. * @returns Boolean specifying if the runtime animation is stopped
  95317. */
  95318. isStopped(): boolean;
  95319. /**
  95320. * Disposes of the runtime animation
  95321. */
  95322. dispose(): void;
  95323. /**
  95324. * Apply the interpolated value to the target
  95325. * @param currentValue defines the value computed by the animation
  95326. * @param weight defines the weight to apply to this value (Defaults to 1.0)
  95327. */
  95328. setValue(currentValue: any, weight: number): void;
  95329. private _getOriginalValues;
  95330. private _setValue;
  95331. /**
  95332. * Gets the loop pmode of the runtime animation
  95333. * @returns Loop Mode
  95334. */
  95335. private _getCorrectLoopMode;
  95336. /**
  95337. * Move the current animation to a given frame
  95338. * @param frame defines the frame to move to
  95339. */
  95340. goToFrame(frame: number): void;
  95341. /**
  95342. * @hidden Internal use only
  95343. */
  95344. _prepareForSpeedRatioChange(newSpeedRatio: number): void;
  95345. /**
  95346. * Execute the current animation
  95347. * @param delay defines the delay to add to the current frame
  95348. * @param from defines the lower bound of the animation range
  95349. * @param to defines the upper bound of the animation range
  95350. * @param loop defines if the current animation must loop
  95351. * @param speedRatio defines the current speed ratio
  95352. * @param weight defines the weight of the animation (default is -1 so no weight)
  95353. * @param onLoop optional callback called when animation loops
  95354. * @returns a boolean indicating if the animation is running
  95355. */
  95356. animate(delay: number, from: number, to: number, loop: boolean, speedRatio: number, weight?: number): boolean;
  95357. }
  95358. }
  95359. declare module BABYLON {
  95360. /**
  95361. * Class used to store an actual running animation
  95362. */
  95363. export class Animatable {
  95364. /** defines the target object */
  95365. target: any;
  95366. /** defines the starting frame number (default is 0) */
  95367. fromFrame: number;
  95368. /** defines the ending frame number (default is 100) */
  95369. toFrame: number;
  95370. /** defines if the animation must loop (default is false) */
  95371. loopAnimation: boolean;
  95372. /** defines a callback to call when animation ends if it is not looping */
  95373. onAnimationEnd?: (() => void) | null | undefined;
  95374. /** defines a callback to call when animation loops */
  95375. onAnimationLoop?: (() => void) | null | undefined;
  95376. /** defines whether the animation should be evaluated additively */
  95377. isAdditive: boolean;
  95378. private _localDelayOffset;
  95379. private _pausedDelay;
  95380. private _runtimeAnimations;
  95381. private _paused;
  95382. private _scene;
  95383. private _speedRatio;
  95384. private _weight;
  95385. private _syncRoot;
  95386. /**
  95387. * Gets or sets a boolean indicating if the animatable must be disposed and removed at the end of the animation.
  95388. * This will only apply for non looping animation (default is true)
  95389. */
  95390. disposeOnEnd: boolean;
  95391. /**
  95392. * Gets a boolean indicating if the animation has started
  95393. */
  95394. animationStarted: boolean;
  95395. /**
  95396. * Observer raised when the animation ends
  95397. */
  95398. onAnimationEndObservable: Observable<Animatable>;
  95399. /**
  95400. * Observer raised when the animation loops
  95401. */
  95402. onAnimationLoopObservable: Observable<Animatable>;
  95403. /**
  95404. * Gets the root Animatable used to synchronize and normalize animations
  95405. */
  95406. get syncRoot(): Nullable<Animatable>;
  95407. /**
  95408. * Gets the current frame of the first RuntimeAnimation
  95409. * Used to synchronize Animatables
  95410. */
  95411. get masterFrame(): number;
  95412. /**
  95413. * Gets or sets the animatable weight (-1.0 by default meaning not weighted)
  95414. */
  95415. get weight(): number;
  95416. set weight(value: number);
  95417. /**
  95418. * Gets or sets the speed ratio to apply to the animatable (1.0 by default)
  95419. */
  95420. get speedRatio(): number;
  95421. set speedRatio(value: number);
  95422. /**
  95423. * Creates a new Animatable
  95424. * @param scene defines the hosting scene
  95425. * @param target defines the target object
  95426. * @param fromFrame defines the starting frame number (default is 0)
  95427. * @param toFrame defines the ending frame number (default is 100)
  95428. * @param loopAnimation defines if the animation must loop (default is false)
  95429. * @param speedRatio defines the factor to apply to animation speed (default is 1)
  95430. * @param onAnimationEnd defines a callback to call when animation ends if it is not looping
  95431. * @param animations defines a group of animation to add to the new Animatable
  95432. * @param onAnimationLoop defines a callback to call when animation loops
  95433. * @param isAdditive defines whether the animation should be evaluated additively
  95434. */
  95435. constructor(scene: Scene,
  95436. /** defines the target object */
  95437. target: any,
  95438. /** defines the starting frame number (default is 0) */
  95439. fromFrame?: number,
  95440. /** defines the ending frame number (default is 100) */
  95441. toFrame?: number,
  95442. /** defines if the animation must loop (default is false) */
  95443. loopAnimation?: boolean, speedRatio?: number,
  95444. /** defines a callback to call when animation ends if it is not looping */
  95445. onAnimationEnd?: (() => void) | null | undefined, animations?: Animation[],
  95446. /** defines a callback to call when animation loops */
  95447. onAnimationLoop?: (() => void) | null | undefined,
  95448. /** defines whether the animation should be evaluated additively */
  95449. isAdditive?: boolean);
  95450. /**
  95451. * Synchronize and normalize current Animatable with a source Animatable
  95452. * This is useful when using animation weights and when animations are not of the same length
  95453. * @param root defines the root Animatable to synchronize with
  95454. * @returns the current Animatable
  95455. */
  95456. syncWith(root: Animatable): Animatable;
  95457. /**
  95458. * Gets the list of runtime animations
  95459. * @returns an array of RuntimeAnimation
  95460. */
  95461. getAnimations(): RuntimeAnimation[];
  95462. /**
  95463. * Adds more animations to the current animatable
  95464. * @param target defines the target of the animations
  95465. * @param animations defines the new animations to add
  95466. */
  95467. appendAnimations(target: any, animations: Animation[]): void;
  95468. /**
  95469. * Gets the source animation for a specific property
  95470. * @param property defines the propertyu to look for
  95471. * @returns null or the source animation for the given property
  95472. */
  95473. getAnimationByTargetProperty(property: string): Nullable<Animation>;
  95474. /**
  95475. * Gets the runtime animation for a specific property
  95476. * @param property defines the propertyu to look for
  95477. * @returns null or the runtime animation for the given property
  95478. */
  95479. getRuntimeAnimationByTargetProperty(property: string): Nullable<RuntimeAnimation>;
  95480. /**
  95481. * Resets the animatable to its original state
  95482. */
  95483. reset(): void;
  95484. /**
  95485. * Allows the animatable to blend with current running animations
  95486. * @see https://doc.babylonjs.com/babylon101/animations#animation-blending
  95487. * @param blendingSpeed defines the blending speed to use
  95488. */
  95489. enableBlending(blendingSpeed: number): void;
  95490. /**
  95491. * Disable animation blending
  95492. * @see https://doc.babylonjs.com/babylon101/animations#animation-blending
  95493. */
  95494. disableBlending(): void;
  95495. /**
  95496. * Jump directly to a given frame
  95497. * @param frame defines the frame to jump to
  95498. */
  95499. goToFrame(frame: number): void;
  95500. /**
  95501. * Pause the animation
  95502. */
  95503. pause(): void;
  95504. /**
  95505. * Restart the animation
  95506. */
  95507. restart(): void;
  95508. private _raiseOnAnimationEnd;
  95509. /**
  95510. * Stop and delete the current animation
  95511. * @param animationName defines a string used to only stop some of the runtime animations instead of all
  95512. * @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)
  95513. */
  95514. stop(animationName?: string, targetMask?: (target: any) => boolean): void;
  95515. /**
  95516. * Wait asynchronously for the animation to end
  95517. * @returns a promise which will be fullfilled when the animation ends
  95518. */
  95519. waitAsync(): Promise<Animatable>;
  95520. /** @hidden */
  95521. _animate(delay: number): boolean;
  95522. }
  95523. interface Scene {
  95524. /** @hidden */
  95525. _registerTargetForLateAnimationBinding(runtimeAnimation: RuntimeAnimation, originalValue: any): void;
  95526. /** @hidden */
  95527. _processLateAnimationBindingsForMatrices(holder: {
  95528. totalWeight: number;
  95529. totalAdditiveWeight: number;
  95530. animations: RuntimeAnimation[];
  95531. additiveAnimations: RuntimeAnimation[];
  95532. originalValue: Matrix;
  95533. }): any;
  95534. /** @hidden */
  95535. _processLateAnimationBindingsForQuaternions(holder: {
  95536. totalWeight: number;
  95537. totalAdditiveWeight: number;
  95538. animations: RuntimeAnimation[];
  95539. additiveAnimations: RuntimeAnimation[];
  95540. originalValue: Quaternion;
  95541. }, refQuaternion: Quaternion): Quaternion;
  95542. /** @hidden */
  95543. _processLateAnimationBindings(): void;
  95544. /**
  95545. * Will start the animation sequence of a given target
  95546. * @param target defines the target
  95547. * @param from defines from which frame should animation start
  95548. * @param to defines until which frame should animation run.
  95549. * @param weight defines the weight to apply to the animation (1.0 by default)
  95550. * @param loop defines if the animation loops
  95551. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  95552. * @param onAnimationEnd defines the function to be executed when the animation ends
  95553. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  95554. * @param targetMask defines if the target should be animated if animations are present (this is called recursively on descendant animatables regardless of return value)
  95555. * @param onAnimationLoop defines the callback to call when an animation loops
  95556. * @param isAdditive defines whether the animation should be evaluated additively (false by default)
  95557. * @returns the animatable object created for this animation
  95558. */
  95559. 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;
  95560. /**
  95561. * Will start the animation sequence of a given target
  95562. * @param target defines the target
  95563. * @param from defines from which frame should animation start
  95564. * @param to defines until which frame should animation run.
  95565. * @param loop defines if the animation loops
  95566. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  95567. * @param onAnimationEnd defines the function to be executed when the animation ends
  95568. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  95569. * @param stopCurrent defines if the current animations must be stopped first (true by default)
  95570. * @param targetMask defines if the target should be animate if animations are present (this is called recursively on descendant animatables regardless of return value)
  95571. * @param onAnimationLoop defines the callback to call when an animation loops
  95572. * @param isAdditive defines whether the animation should be evaluated additively (false by default)
  95573. * @returns the animatable object created for this animation
  95574. */
  95575. 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;
  95576. /**
  95577. * Will start the animation sequence of a given target and its hierarchy
  95578. * @param target defines the target
  95579. * @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.
  95580. * @param from defines from which frame should animation start
  95581. * @param to defines until which frame should animation run.
  95582. * @param loop defines if the animation loops
  95583. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  95584. * @param onAnimationEnd defines the function to be executed when the animation ends
  95585. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  95586. * @param stopCurrent defines if the current animations must be stopped first (true by default)
  95587. * @param targetMask defines if the target should be animated if animations are present (this is called recursively on descendant animatables regardless of return value)
  95588. * @param onAnimationLoop defines the callback to call when an animation loops
  95589. * @param isAdditive defines whether the animation should be evaluated additively (false by default)
  95590. * @returns the list of created animatables
  95591. */
  95592. 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[];
  95593. /**
  95594. * Begin a new animation on a given node
  95595. * @param target defines the target where the animation will take place
  95596. * @param animations defines the list of animations to start
  95597. * @param from defines the initial value
  95598. * @param to defines the final value
  95599. * @param loop defines if you want animation to loop (off by default)
  95600. * @param speedRatio defines the speed ratio to apply to all animations
  95601. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  95602. * @param onAnimationLoop defines the callback to call when an animation loops
  95603. * @param isAdditive defines whether the animation should be evaluated additively (false by default)
  95604. * @returns the list of created animatables
  95605. */
  95606. beginDirectAnimation(target: any, animations: Animation[], from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, onAnimationLoop?: () => void, isAdditive?: boolean): Animatable;
  95607. /**
  95608. * Begin a new animation on a given node and its hierarchy
  95609. * @param target defines the root node where the animation will take place
  95610. * @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.
  95611. * @param animations defines the list of animations to start
  95612. * @param from defines the initial value
  95613. * @param to defines the final value
  95614. * @param loop defines if you want animation to loop (off by default)
  95615. * @param speedRatio defines the speed ratio to apply to all animations
  95616. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  95617. * @param onAnimationLoop defines the callback to call when an animation loops
  95618. * @param isAdditive defines whether the animation should be evaluated additively (false by default)
  95619. * @returns the list of animatables created for all nodes
  95620. */
  95621. beginDirectHierarchyAnimation(target: Node, directDescendantsOnly: boolean, animations: Animation[], from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, onAnimationLoop?: () => void, isAdditive?: boolean): Animatable[];
  95622. /**
  95623. * Gets the animatable associated with a specific target
  95624. * @param target defines the target of the animatable
  95625. * @returns the required animatable if found
  95626. */
  95627. getAnimatableByTarget(target: any): Nullable<Animatable>;
  95628. /**
  95629. * Gets all animatables associated with a given target
  95630. * @param target defines the target to look animatables for
  95631. * @returns an array of Animatables
  95632. */
  95633. getAllAnimatablesByTarget(target: any): Array<Animatable>;
  95634. /**
  95635. * Stops and removes all animations that have been applied to the scene
  95636. */
  95637. stopAllAnimations(): void;
  95638. /**
  95639. * Gets the current delta time used by animation engine
  95640. */
  95641. deltaTime: number;
  95642. }
  95643. interface Bone {
  95644. /**
  95645. * Copy an animation range from another bone
  95646. * @param source defines the source bone
  95647. * @param rangeName defines the range name to copy
  95648. * @param frameOffset defines the frame offset
  95649. * @param rescaleAsRequired defines if rescaling must be applied if required
  95650. * @param skelDimensionsRatio defines the scaling ratio
  95651. * @returns true if operation was successful
  95652. */
  95653. copyAnimationRange(source: Bone, rangeName: string, frameOffset: number, rescaleAsRequired: boolean, skelDimensionsRatio: Nullable<Vector3>): boolean;
  95654. }
  95655. }
  95656. declare module BABYLON {
  95657. /**
  95658. * Class used to handle skinning animations
  95659. * @see https://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  95660. */
  95661. export class Skeleton implements IAnimatable {
  95662. /** defines the skeleton name */
  95663. name: string;
  95664. /** defines the skeleton Id */
  95665. id: string;
  95666. /**
  95667. * Defines the list of child bones
  95668. */
  95669. bones: Bone[];
  95670. /**
  95671. * Defines an estimate of the dimension of the skeleton at rest
  95672. */
  95673. dimensionsAtRest: Vector3;
  95674. /**
  95675. * Defines a boolean indicating if the root matrix is provided by meshes or by the current skeleton (this is the default value)
  95676. */
  95677. needInitialSkinMatrix: boolean;
  95678. /**
  95679. * Defines a mesh that override the matrix used to get the world matrix (null by default).
  95680. */
  95681. overrideMesh: Nullable<AbstractMesh>;
  95682. /**
  95683. * Gets the list of animations attached to this skeleton
  95684. */
  95685. animations: Array<Animation>;
  95686. private _scene;
  95687. private _isDirty;
  95688. private _transformMatrices;
  95689. private _transformMatrixTexture;
  95690. private _meshesWithPoseMatrix;
  95691. private _animatables;
  95692. private _identity;
  95693. private _synchronizedWithMesh;
  95694. private _ranges;
  95695. private _lastAbsoluteTransformsUpdateId;
  95696. private _canUseTextureForBones;
  95697. private _uniqueId;
  95698. /** @hidden */
  95699. _numBonesWithLinkedTransformNode: number;
  95700. /** @hidden */
  95701. _hasWaitingData: Nullable<boolean>;
  95702. /** @hidden */
  95703. _waitingOverrideMeshId: Nullable<string>;
  95704. /**
  95705. * Specifies if the skeleton should be serialized
  95706. */
  95707. doNotSerialize: boolean;
  95708. private _useTextureToStoreBoneMatrices;
  95709. /**
  95710. * Gets or sets a boolean indicating that bone matrices should be stored as a texture instead of using shader uniforms (default is true).
  95711. * Please note that this option is not available if the hardware does not support it
  95712. */
  95713. get useTextureToStoreBoneMatrices(): boolean;
  95714. set useTextureToStoreBoneMatrices(value: boolean);
  95715. private _animationPropertiesOverride;
  95716. /**
  95717. * Gets or sets the animation properties override
  95718. */
  95719. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  95720. set animationPropertiesOverride(value: Nullable<AnimationPropertiesOverride>);
  95721. /**
  95722. * List of inspectable custom properties (used by the Inspector)
  95723. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  95724. */
  95725. inspectableCustomProperties: IInspectable[];
  95726. /**
  95727. * An observable triggered before computing the skeleton's matrices
  95728. */
  95729. onBeforeComputeObservable: Observable<Skeleton>;
  95730. /**
  95731. * Gets a boolean indicating that the skeleton effectively stores matrices into a texture
  95732. */
  95733. get isUsingTextureForMatrices(): boolean;
  95734. /**
  95735. * Gets the unique ID of this skeleton
  95736. */
  95737. get uniqueId(): number;
  95738. /**
  95739. * Creates a new skeleton
  95740. * @param name defines the skeleton name
  95741. * @param id defines the skeleton Id
  95742. * @param scene defines the hosting scene
  95743. */
  95744. constructor(
  95745. /** defines the skeleton name */
  95746. name: string,
  95747. /** defines the skeleton Id */
  95748. id: string, scene: Scene);
  95749. /**
  95750. * Gets the current object class name.
  95751. * @return the class name
  95752. */
  95753. getClassName(): string;
  95754. /**
  95755. * Returns an array containing the root bones
  95756. * @returns an array containing the root bones
  95757. */
  95758. getChildren(): Array<Bone>;
  95759. /**
  95760. * Gets the list of transform matrices to send to shaders (one matrix per bone)
  95761. * @param mesh defines the mesh to use to get the root matrix (if needInitialSkinMatrix === true)
  95762. * @returns a Float32Array containing matrices data
  95763. */
  95764. getTransformMatrices(mesh: AbstractMesh): Float32Array;
  95765. /**
  95766. * Gets the list of transform matrices to send to shaders inside a texture (one matrix per bone)
  95767. * @param mesh defines the mesh to use to get the root matrix (if needInitialSkinMatrix === true)
  95768. * @returns a raw texture containing the data
  95769. */
  95770. getTransformMatrixTexture(mesh: AbstractMesh): Nullable<RawTexture>;
  95771. /**
  95772. * Gets the current hosting scene
  95773. * @returns a scene object
  95774. */
  95775. getScene(): Scene;
  95776. /**
  95777. * Gets a string representing the current skeleton data
  95778. * @param fullDetails defines a boolean indicating if we want a verbose version
  95779. * @returns a string representing the current skeleton data
  95780. */
  95781. toString(fullDetails?: boolean): string;
  95782. /**
  95783. * Get bone's index searching by name
  95784. * @param name defines bone's name to search for
  95785. * @return the indice of the bone. Returns -1 if not found
  95786. */
  95787. getBoneIndexByName(name: string): number;
  95788. /**
  95789. * Creater a new animation range
  95790. * @param name defines the name of the range
  95791. * @param from defines the start key
  95792. * @param to defines the end key
  95793. */
  95794. createAnimationRange(name: string, from: number, to: number): void;
  95795. /**
  95796. * Delete a specific animation range
  95797. * @param name defines the name of the range
  95798. * @param deleteFrames defines if frames must be removed as well
  95799. */
  95800. deleteAnimationRange(name: string, deleteFrames?: boolean): void;
  95801. /**
  95802. * Gets a specific animation range
  95803. * @param name defines the name of the range to look for
  95804. * @returns the requested animation range or null if not found
  95805. */
  95806. getAnimationRange(name: string): Nullable<AnimationRange>;
  95807. /**
  95808. * Gets the list of all animation ranges defined on this skeleton
  95809. * @returns an array
  95810. */
  95811. getAnimationRanges(): Nullable<AnimationRange>[];
  95812. /**
  95813. * Copy animation range from a source skeleton.
  95814. * This is not for a complete retargeting, only between very similar skeleton's with only possible bone length differences
  95815. * @param source defines the source skeleton
  95816. * @param name defines the name of the range to copy
  95817. * @param rescaleAsRequired defines if rescaling must be applied if required
  95818. * @returns true if operation was successful
  95819. */
  95820. copyAnimationRange(source: Skeleton, name: string, rescaleAsRequired?: boolean): boolean;
  95821. /**
  95822. * Forces the skeleton to go to rest pose
  95823. */
  95824. returnToRest(): void;
  95825. private _getHighestAnimationFrame;
  95826. /**
  95827. * Begin a specific animation range
  95828. * @param name defines the name of the range to start
  95829. * @param loop defines if looping must be turned on (false by default)
  95830. * @param speedRatio defines the speed ratio to apply (1 by default)
  95831. * @param onAnimationEnd defines a callback which will be called when animation will end
  95832. * @returns a new animatable
  95833. */
  95834. beginAnimation(name: string, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Nullable<Animatable>;
  95835. /**
  95836. * Convert the keyframes for a range of animation on a skeleton to be relative to a given reference frame.
  95837. * @param skeleton defines the Skeleton containing the animation range to convert
  95838. * @param referenceFrame defines the frame that keyframes in the range will be relative to
  95839. * @param range defines the name of the AnimationRange belonging to the Skeleton to convert
  95840. * @returns the original skeleton
  95841. */
  95842. static MakeAnimationAdditive(skeleton: Skeleton, referenceFrame: number | undefined, range: string): Nullable<Skeleton>;
  95843. /** @hidden */
  95844. _markAsDirty(): void;
  95845. /** @hidden */
  95846. _registerMeshWithPoseMatrix(mesh: AbstractMesh): void;
  95847. /** @hidden */
  95848. _unregisterMeshWithPoseMatrix(mesh: AbstractMesh): void;
  95849. private _computeTransformMatrices;
  95850. /**
  95851. * Build all resources required to render a skeleton
  95852. */
  95853. prepare(): void;
  95854. /**
  95855. * Gets the list of animatables currently running for this skeleton
  95856. * @returns an array of animatables
  95857. */
  95858. getAnimatables(): IAnimatable[];
  95859. /**
  95860. * Clone the current skeleton
  95861. * @param name defines the name of the new skeleton
  95862. * @param id defines the id of the new skeleton
  95863. * @returns the new skeleton
  95864. */
  95865. clone(name: string, id?: string): Skeleton;
  95866. /**
  95867. * Enable animation blending for this skeleton
  95868. * @param blendingSpeed defines the blending speed to apply
  95869. * @see https://doc.babylonjs.com/babylon101/animations#animation-blending
  95870. */
  95871. enableBlending(blendingSpeed?: number): void;
  95872. /**
  95873. * Releases all resources associated with the current skeleton
  95874. */
  95875. dispose(): void;
  95876. /**
  95877. * Serialize the skeleton in a JSON object
  95878. * @returns a JSON object
  95879. */
  95880. serialize(): any;
  95881. /**
  95882. * Creates a new skeleton from serialized data
  95883. * @param parsedSkeleton defines the serialized data
  95884. * @param scene defines the hosting scene
  95885. * @returns a new skeleton
  95886. */
  95887. static Parse(parsedSkeleton: any, scene: Scene): Skeleton;
  95888. /**
  95889. * Compute all node absolute transforms
  95890. * @param forceUpdate defines if computation must be done even if cache is up to date
  95891. */
  95892. computeAbsoluteTransforms(forceUpdate?: boolean): void;
  95893. /**
  95894. * Gets the root pose matrix
  95895. * @returns a matrix
  95896. */
  95897. getPoseMatrix(): Nullable<Matrix>;
  95898. /**
  95899. * Sorts bones per internal index
  95900. */
  95901. sortBones(): void;
  95902. private _sortBones;
  95903. }
  95904. }
  95905. declare module BABYLON {
  95906. /**
  95907. * Creates an instance based on a source mesh.
  95908. */
  95909. export class InstancedMesh extends AbstractMesh {
  95910. private _sourceMesh;
  95911. private _currentLOD;
  95912. /** @hidden */
  95913. _indexInSourceMeshInstanceArray: number;
  95914. constructor(name: string, source: Mesh);
  95915. /**
  95916. * Returns the string "InstancedMesh".
  95917. */
  95918. getClassName(): string;
  95919. /** Gets the list of lights affecting that mesh */
  95920. get lightSources(): Light[];
  95921. _resyncLightSources(): void;
  95922. _resyncLightSource(light: Light): void;
  95923. _removeLightSource(light: Light, dispose: boolean): void;
  95924. /**
  95925. * If the source mesh receives shadows
  95926. */
  95927. get receiveShadows(): boolean;
  95928. /**
  95929. * The material of the source mesh
  95930. */
  95931. get material(): Nullable<Material>;
  95932. /**
  95933. * Visibility of the source mesh
  95934. */
  95935. get visibility(): number;
  95936. /**
  95937. * Skeleton of the source mesh
  95938. */
  95939. get skeleton(): Nullable<Skeleton>;
  95940. /**
  95941. * Rendering ground id of the source mesh
  95942. */
  95943. get renderingGroupId(): number;
  95944. set renderingGroupId(value: number);
  95945. /**
  95946. * Returns the total number of vertices (integer).
  95947. */
  95948. getTotalVertices(): number;
  95949. /**
  95950. * Returns a positive integer : the total number of indices in this mesh geometry.
  95951. * @returns the numner of indices or zero if the mesh has no geometry.
  95952. */
  95953. getTotalIndices(): number;
  95954. /**
  95955. * The source mesh of the instance
  95956. */
  95957. get sourceMesh(): Mesh;
  95958. /**
  95959. * Creates a new InstancedMesh object from the mesh model.
  95960. * @see https://doc.babylonjs.com/how_to/how_to_use_instances
  95961. * @param name defines the name of the new instance
  95962. * @returns a new InstancedMesh
  95963. */
  95964. createInstance(name: string): InstancedMesh;
  95965. /**
  95966. * Is this node ready to be used/rendered
  95967. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  95968. * @return {boolean} is it ready
  95969. */
  95970. isReady(completeCheck?: boolean): boolean;
  95971. /**
  95972. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  95973. * @param kind kind of verticies to retreive (eg. positons, normals, uvs, etc.)
  95974. * @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.
  95975. * @returns a float array or a Float32Array of the requested kind of data : positons, normals, uvs, etc.
  95976. */
  95977. getVerticesData(kind: string, copyWhenShared?: boolean): Nullable<FloatArray>;
  95978. /**
  95979. * Sets the vertex data of the mesh geometry for the requested `kind`.
  95980. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  95981. * The `data` are either a numeric array either a Float32Array.
  95982. * The parameter `updatable` is passed as is to the underlying Geometry object constructor (if initianilly none) or updater.
  95983. * 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).
  95984. * Note that a new underlying VertexBuffer object is created each call.
  95985. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  95986. *
  95987. * Possible `kind` values :
  95988. * - VertexBuffer.PositionKind
  95989. * - VertexBuffer.UVKind
  95990. * - VertexBuffer.UV2Kind
  95991. * - VertexBuffer.UV3Kind
  95992. * - VertexBuffer.UV4Kind
  95993. * - VertexBuffer.UV5Kind
  95994. * - VertexBuffer.UV6Kind
  95995. * - VertexBuffer.ColorKind
  95996. * - VertexBuffer.MatricesIndicesKind
  95997. * - VertexBuffer.MatricesIndicesExtraKind
  95998. * - VertexBuffer.MatricesWeightsKind
  95999. * - VertexBuffer.MatricesWeightsExtraKind
  96000. *
  96001. * Returns the Mesh.
  96002. */
  96003. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  96004. /**
  96005. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  96006. * If the mesh has no geometry, it is simply returned as it is.
  96007. * The `data` are either a numeric array either a Float32Array.
  96008. * No new underlying VertexBuffer object is created.
  96009. * 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.
  96010. * If the parameter `makeItUnique` is true, a new global geometry is created from this positions and is set to the mesh.
  96011. *
  96012. * Possible `kind` values :
  96013. * - VertexBuffer.PositionKind
  96014. * - VertexBuffer.UVKind
  96015. * - VertexBuffer.UV2Kind
  96016. * - VertexBuffer.UV3Kind
  96017. * - VertexBuffer.UV4Kind
  96018. * - VertexBuffer.UV5Kind
  96019. * - VertexBuffer.UV6Kind
  96020. * - VertexBuffer.ColorKind
  96021. * - VertexBuffer.MatricesIndicesKind
  96022. * - VertexBuffer.MatricesIndicesExtraKind
  96023. * - VertexBuffer.MatricesWeightsKind
  96024. * - VertexBuffer.MatricesWeightsExtraKind
  96025. *
  96026. * Returns the Mesh.
  96027. */
  96028. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): Mesh;
  96029. /**
  96030. * Sets the mesh indices.
  96031. * Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array).
  96032. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  96033. * This method creates a new index buffer each call.
  96034. * Returns the Mesh.
  96035. */
  96036. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>): Mesh;
  96037. /**
  96038. * Boolean : True if the mesh owns the requested kind of data.
  96039. */
  96040. isVerticesDataPresent(kind: string): boolean;
  96041. /**
  96042. * Returns an array of indices (IndicesArray).
  96043. */
  96044. getIndices(): Nullable<IndicesArray>;
  96045. get _positions(): Nullable<Vector3[]>;
  96046. /**
  96047. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  96048. * This means the mesh underlying bounding box and sphere are recomputed.
  96049. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  96050. * @returns the current mesh
  96051. */
  96052. refreshBoundingInfo(applySkeleton?: boolean): InstancedMesh;
  96053. /** @hidden */
  96054. _preActivate(): InstancedMesh;
  96055. /** @hidden */
  96056. _activate(renderId: number, intermediateRendering: boolean): boolean;
  96057. /** @hidden */
  96058. _postActivate(): void;
  96059. getWorldMatrix(): Matrix;
  96060. get isAnInstance(): boolean;
  96061. /**
  96062. * Returns the current associated LOD AbstractMesh.
  96063. */
  96064. getLOD(camera: Camera): AbstractMesh;
  96065. /** @hidden */
  96066. _preActivateForIntermediateRendering(renderId: number): Mesh;
  96067. /** @hidden */
  96068. _syncSubMeshes(): InstancedMesh;
  96069. /** @hidden */
  96070. _generatePointsArray(): boolean;
  96071. /** @hidden */
  96072. _updateBoundingInfo(): AbstractMesh;
  96073. /**
  96074. * Creates a new InstancedMesh from the current mesh.
  96075. * - name (string) : the cloned mesh name
  96076. * - newParent (optional Node) : the optional Node to parent the clone to.
  96077. * - doNotCloneChildren (optional boolean, default `false`) : if `true` the model children aren't cloned.
  96078. *
  96079. * Returns the clone.
  96080. */
  96081. clone(name: string, newParent?: Nullable<Node>, doNotCloneChildren?: boolean): InstancedMesh;
  96082. /**
  96083. * Disposes the InstancedMesh.
  96084. * Returns nothing.
  96085. */
  96086. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  96087. }
  96088. interface Mesh {
  96089. /**
  96090. * Register a custom buffer that will be instanced
  96091. * @see https://doc.babylonjs.com/how_to/how_to_use_instances#custom-buffers
  96092. * @param kind defines the buffer kind
  96093. * @param stride defines the stride in floats
  96094. */
  96095. registerInstancedBuffer(kind: string, stride: number): void;
  96096. /**
  96097. * true to use the edge renderer for all instances of this mesh
  96098. */
  96099. edgesShareWithInstances: boolean;
  96100. /** @hidden */
  96101. _userInstancedBuffersStorage: {
  96102. data: {
  96103. [key: string]: Float32Array;
  96104. };
  96105. sizes: {
  96106. [key: string]: number;
  96107. };
  96108. vertexBuffers: {
  96109. [key: string]: Nullable<VertexBuffer>;
  96110. };
  96111. strides: {
  96112. [key: string]: number;
  96113. };
  96114. };
  96115. }
  96116. interface AbstractMesh {
  96117. /**
  96118. * Object used to store instanced buffers defined by user
  96119. * @see https://doc.babylonjs.com/how_to/how_to_use_instances#custom-buffers
  96120. */
  96121. instancedBuffers: {
  96122. [key: string]: any;
  96123. };
  96124. }
  96125. }
  96126. declare module BABYLON {
  96127. /**
  96128. * Defines the options associated with the creation of a shader material.
  96129. */
  96130. export interface IShaderMaterialOptions {
  96131. /**
  96132. * Does the material work in alpha blend mode
  96133. */
  96134. needAlphaBlending: boolean;
  96135. /**
  96136. * Does the material work in alpha test mode
  96137. */
  96138. needAlphaTesting: boolean;
  96139. /**
  96140. * The list of attribute names used in the shader
  96141. */
  96142. attributes: string[];
  96143. /**
  96144. * The list of unifrom names used in the shader
  96145. */
  96146. uniforms: string[];
  96147. /**
  96148. * The list of UBO names used in the shader
  96149. */
  96150. uniformBuffers: string[];
  96151. /**
  96152. * The list of sampler names used in the shader
  96153. */
  96154. samplers: string[];
  96155. /**
  96156. * The list of defines used in the shader
  96157. */
  96158. defines: string[];
  96159. }
  96160. /**
  96161. * 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.
  96162. *
  96163. * This returned material effects how the mesh will look based on the code in the shaders.
  96164. *
  96165. * @see https://doc.babylonjs.com/how_to/shader_material
  96166. */
  96167. export class ShaderMaterial extends Material {
  96168. private _shaderPath;
  96169. private _options;
  96170. private _textures;
  96171. private _textureArrays;
  96172. private _floats;
  96173. private _ints;
  96174. private _floatsArrays;
  96175. private _colors3;
  96176. private _colors3Arrays;
  96177. private _colors4;
  96178. private _colors4Arrays;
  96179. private _vectors2;
  96180. private _vectors3;
  96181. private _vectors4;
  96182. private _matrices;
  96183. private _matrixArrays;
  96184. private _matrices3x3;
  96185. private _matrices2x2;
  96186. private _vectors2Arrays;
  96187. private _vectors3Arrays;
  96188. private _vectors4Arrays;
  96189. private _cachedWorldViewMatrix;
  96190. private _cachedWorldViewProjectionMatrix;
  96191. private _renderId;
  96192. private _multiview;
  96193. private _cachedDefines;
  96194. /** Define the Url to load snippets */
  96195. static SnippetUrl: string;
  96196. /** Snippet ID if the material was created from the snippet server */
  96197. snippetId: string;
  96198. /**
  96199. * Instantiate a new shader material.
  96200. * 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.
  96201. * This returned material effects how the mesh will look based on the code in the shaders.
  96202. * @see https://doc.babylonjs.com/how_to/shader_material
  96203. * @param name Define the name of the material in the scene
  96204. * @param scene Define the scene the material belongs to
  96205. * @param shaderPath Defines the route to the shader code in one of three ways:
  96206. * * object: { vertex: "custom", fragment: "custom" }, used with Effect.ShadersStore["customVertexShader"] and Effect.ShadersStore["customFragmentShader"]
  96207. * * object: { vertexElement: "vertexShaderCode", fragmentElement: "fragmentShaderCode" }, used with shader code in script tags
  96208. * * object: { vertexSource: "vertex shader code string", fragmentSource: "fragment shader code string" } using with strings containing the shaders code
  96209. * * string: "./COMMON_NAME", used with external files COMMON_NAME.vertex.fx and COMMON_NAME.fragment.fx in index.html folder.
  96210. * @param options Define the options used to create the shader
  96211. */
  96212. constructor(name: string, scene: Scene, shaderPath: any, options?: Partial<IShaderMaterialOptions>);
  96213. /**
  96214. * Gets the shader path used to define the shader code
  96215. * It can be modified to trigger a new compilation
  96216. */
  96217. get shaderPath(): any;
  96218. /**
  96219. * Sets the shader path used to define the shader code
  96220. * It can be modified to trigger a new compilation
  96221. */
  96222. set shaderPath(shaderPath: any);
  96223. /**
  96224. * Gets the options used to compile the shader.
  96225. * They can be modified to trigger a new compilation
  96226. */
  96227. get options(): IShaderMaterialOptions;
  96228. /**
  96229. * Gets the current class name of the material e.g. "ShaderMaterial"
  96230. * Mainly use in serialization.
  96231. * @returns the class name
  96232. */
  96233. getClassName(): string;
  96234. /**
  96235. * Specifies if the material will require alpha blending
  96236. * @returns a boolean specifying if alpha blending is needed
  96237. */
  96238. needAlphaBlending(): boolean;
  96239. /**
  96240. * Specifies if this material should be rendered in alpha test mode
  96241. * @returns a boolean specifying if an alpha test is needed.
  96242. */
  96243. needAlphaTesting(): boolean;
  96244. private _checkUniform;
  96245. /**
  96246. * Set a texture in the shader.
  96247. * @param name Define the name of the uniform samplers as defined in the shader
  96248. * @param texture Define the texture to bind to this sampler
  96249. * @return the material itself allowing "fluent" like uniform updates
  96250. */
  96251. setTexture(name: string, texture: BaseTexture): ShaderMaterial;
  96252. /**
  96253. * Set a texture array in the shader.
  96254. * @param name Define the name of the uniform sampler array as defined in the shader
  96255. * @param textures Define the list of textures to bind to this sampler
  96256. * @return the material itself allowing "fluent" like uniform updates
  96257. */
  96258. setTextureArray(name: string, textures: BaseTexture[]): ShaderMaterial;
  96259. /**
  96260. * Set a float in the shader.
  96261. * @param name Define the name of the uniform as defined in the shader
  96262. * @param value Define the value to give to the uniform
  96263. * @return the material itself allowing "fluent" like uniform updates
  96264. */
  96265. setFloat(name: string, value: number): ShaderMaterial;
  96266. /**
  96267. * Set a int in the shader.
  96268. * @param name Define the name of the uniform as defined in the shader
  96269. * @param value Define the value to give to the uniform
  96270. * @return the material itself allowing "fluent" like uniform updates
  96271. */
  96272. setInt(name: string, value: number): ShaderMaterial;
  96273. /**
  96274. * Set an array of floats in the shader.
  96275. * @param name Define the name of the uniform as defined in the shader
  96276. * @param value Define the value to give to the uniform
  96277. * @return the material itself allowing "fluent" like uniform updates
  96278. */
  96279. setFloats(name: string, value: number[]): ShaderMaterial;
  96280. /**
  96281. * Set a vec3 in the shader from a Color3.
  96282. * @param name Define the name of the uniform as defined in the shader
  96283. * @param value Define the value to give to the uniform
  96284. * @return the material itself allowing "fluent" like uniform updates
  96285. */
  96286. setColor3(name: string, value: Color3): ShaderMaterial;
  96287. /**
  96288. * Set a vec3 array in the shader from a Color3 array.
  96289. * @param name Define the name of the uniform as defined in the shader
  96290. * @param value Define the value to give to the uniform
  96291. * @return the material itself allowing "fluent" like uniform updates
  96292. */
  96293. setColor3Array(name: string, value: Color3[]): ShaderMaterial;
  96294. /**
  96295. * Set a vec4 in the shader from a Color4.
  96296. * @param name Define the name of the uniform as defined in the shader
  96297. * @param value Define the value to give to the uniform
  96298. * @return the material itself allowing "fluent" like uniform updates
  96299. */
  96300. setColor4(name: string, value: Color4): ShaderMaterial;
  96301. /**
  96302. * Set a vec4 array in the shader from a Color4 array.
  96303. * @param name Define the name of the uniform as defined in the shader
  96304. * @param value Define the value to give to the uniform
  96305. * @return the material itself allowing "fluent" like uniform updates
  96306. */
  96307. setColor4Array(name: string, value: Color4[]): ShaderMaterial;
  96308. /**
  96309. * Set a vec2 in the shader from a Vector2.
  96310. * @param name Define the name of the uniform as defined in the shader
  96311. * @param value Define the value to give to the uniform
  96312. * @return the material itself allowing "fluent" like uniform updates
  96313. */
  96314. setVector2(name: string, value: Vector2): ShaderMaterial;
  96315. /**
  96316. * Set a vec3 in the shader from a Vector3.
  96317. * @param name Define the name of the uniform as defined in the shader
  96318. * @param value Define the value to give to the uniform
  96319. * @return the material itself allowing "fluent" like uniform updates
  96320. */
  96321. setVector3(name: string, value: Vector3): ShaderMaterial;
  96322. /**
  96323. * Set a vec4 in the shader from a Vector4.
  96324. * @param name Define the name of the uniform as defined in the shader
  96325. * @param value Define the value to give to the uniform
  96326. * @return the material itself allowing "fluent" like uniform updates
  96327. */
  96328. setVector4(name: string, value: Vector4): ShaderMaterial;
  96329. /**
  96330. * Set a mat4 in the shader from a Matrix.
  96331. * @param name Define the name of the uniform as defined in the shader
  96332. * @param value Define the value to give to the uniform
  96333. * @return the material itself allowing "fluent" like uniform updates
  96334. */
  96335. setMatrix(name: string, value: Matrix): ShaderMaterial;
  96336. /**
  96337. * Set a float32Array in the shader from a matrix array.
  96338. * @param name Define the name of the uniform as defined in the shader
  96339. * @param value Define the value to give to the uniform
  96340. * @return the material itself allowing "fluent" like uniform updates
  96341. */
  96342. setMatrices(name: string, value: Matrix[]): ShaderMaterial;
  96343. /**
  96344. * Set a mat3 in the shader from a Float32Array.
  96345. * @param name Define the name of the uniform as defined in the shader
  96346. * @param value Define the value to give to the uniform
  96347. * @return the material itself allowing "fluent" like uniform updates
  96348. */
  96349. setMatrix3x3(name: string, value: Float32Array | Array<number>): ShaderMaterial;
  96350. /**
  96351. * Set a mat2 in the shader from a Float32Array.
  96352. * @param name Define the name of the uniform as defined in the shader
  96353. * @param value Define the value to give to the uniform
  96354. * @return the material itself allowing "fluent" like uniform updates
  96355. */
  96356. setMatrix2x2(name: string, value: Float32Array | Array<number>): ShaderMaterial;
  96357. /**
  96358. * Set a vec2 array in the shader from a number array.
  96359. * @param name Define the name of the uniform as defined in the shader
  96360. * @param value Define the value to give to the uniform
  96361. * @return the material itself allowing "fluent" like uniform updates
  96362. */
  96363. setArray2(name: string, value: number[]): ShaderMaterial;
  96364. /**
  96365. * Set a vec3 array in the shader from a number array.
  96366. * @param name Define the name of the uniform as defined in the shader
  96367. * @param value Define the value to give to the uniform
  96368. * @return the material itself allowing "fluent" like uniform updates
  96369. */
  96370. setArray3(name: string, value: number[]): ShaderMaterial;
  96371. /**
  96372. * Set a vec4 array in the shader from a number array.
  96373. * @param name Define the name of the uniform as defined in the shader
  96374. * @param value Define the value to give to the uniform
  96375. * @return the material itself allowing "fluent" like uniform updates
  96376. */
  96377. setArray4(name: string, value: number[]): ShaderMaterial;
  96378. private _checkCache;
  96379. /**
  96380. * Specifies that the submesh is ready to be used
  96381. * @param mesh defines the mesh to check
  96382. * @param subMesh defines which submesh to check
  96383. * @param useInstances specifies that instances should be used
  96384. * @returns a boolean indicating that the submesh is ready or not
  96385. */
  96386. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  96387. /**
  96388. * Checks if the material is ready to render the requested mesh
  96389. * @param mesh Define the mesh to render
  96390. * @param useInstances Define whether or not the material is used with instances
  96391. * @returns true if ready, otherwise false
  96392. */
  96393. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  96394. /**
  96395. * Binds the world matrix to the material
  96396. * @param world defines the world transformation matrix
  96397. * @param effectOverride - If provided, use this effect instead of internal effect
  96398. */
  96399. bindOnlyWorldMatrix(world: Matrix, effectOverride?: Nullable<Effect>): void;
  96400. /**
  96401. * Binds the submesh to this material by preparing the effect and shader to draw
  96402. * @param world defines the world transformation matrix
  96403. * @param mesh defines the mesh containing the submesh
  96404. * @param subMesh defines the submesh to bind the material to
  96405. */
  96406. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  96407. /**
  96408. * Binds the material to the mesh
  96409. * @param world defines the world transformation matrix
  96410. * @param mesh defines the mesh to bind the material to
  96411. * @param effectOverride - If provided, use this effect instead of internal effect
  96412. */
  96413. bind(world: Matrix, mesh?: Mesh, effectOverride?: Nullable<Effect>): void;
  96414. protected _afterBind(mesh?: Mesh): void;
  96415. /**
  96416. * Gets the active textures from the material
  96417. * @returns an array of textures
  96418. */
  96419. getActiveTextures(): BaseTexture[];
  96420. /**
  96421. * Specifies if the material uses a texture
  96422. * @param texture defines the texture to check against the material
  96423. * @returns a boolean specifying if the material uses the texture
  96424. */
  96425. hasTexture(texture: BaseTexture): boolean;
  96426. /**
  96427. * Makes a duplicate of the material, and gives it a new name
  96428. * @param name defines the new name for the duplicated material
  96429. * @returns the cloned material
  96430. */
  96431. clone(name: string): ShaderMaterial;
  96432. /**
  96433. * Disposes the material
  96434. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  96435. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  96436. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  96437. */
  96438. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  96439. /**
  96440. * Serializes this material in a JSON representation
  96441. * @returns the serialized material object
  96442. */
  96443. serialize(): any;
  96444. /**
  96445. * Creates a shader material from parsed shader material data
  96446. * @param source defines the JSON represnetation of the material
  96447. * @param scene defines the hosting scene
  96448. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  96449. * @returns a new material
  96450. */
  96451. static Parse(source: any, scene: Scene, rootUrl: string): ShaderMaterial;
  96452. /**
  96453. * Creates a new ShaderMaterial from a snippet saved in a remote file
  96454. * @param name defines the name of the ShaderMaterial to create (can be null or empty to use the one from the json data)
  96455. * @param url defines the url to load from
  96456. * @param scene defines the hosting scene
  96457. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  96458. * @returns a promise that will resolve to the new ShaderMaterial
  96459. */
  96460. static ParseFromFileAsync(name: Nullable<string>, url: string, scene: Scene, rootUrl?: string): Promise<ShaderMaterial>;
  96461. /**
  96462. * Creates a ShaderMaterial from a snippet saved by the Inspector
  96463. * @param snippetId defines the snippet to load
  96464. * @param scene defines the hosting scene
  96465. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  96466. * @returns a promise that will resolve to the new ShaderMaterial
  96467. */
  96468. static CreateFromSnippetAsync(snippetId: string, scene: Scene, rootUrl?: string): Promise<ShaderMaterial>;
  96469. }
  96470. }
  96471. declare module BABYLON {
  96472. /** @hidden */
  96473. export var colorPixelShader: {
  96474. name: string;
  96475. shader: string;
  96476. };
  96477. }
  96478. declare module BABYLON {
  96479. /** @hidden */
  96480. export var colorVertexShader: {
  96481. name: string;
  96482. shader: string;
  96483. };
  96484. }
  96485. declare module BABYLON {
  96486. /**
  96487. * Line mesh
  96488. * @see https://doc.babylonjs.com/babylon101/parametric_shapes
  96489. */
  96490. export class LinesMesh extends Mesh {
  96491. /**
  96492. * If vertex color should be applied to the mesh
  96493. */
  96494. readonly useVertexColor?: boolean | undefined;
  96495. /**
  96496. * If vertex alpha should be applied to the mesh
  96497. */
  96498. readonly useVertexAlpha?: boolean | undefined;
  96499. /**
  96500. * Color of the line (Default: White)
  96501. */
  96502. color: Color3;
  96503. /**
  96504. * Alpha of the line (Default: 1)
  96505. */
  96506. alpha: number;
  96507. /**
  96508. * The intersection Threshold is the margin applied when intersection a segment of the LinesMesh with a Ray.
  96509. * This margin is expressed in world space coordinates, so its value may vary.
  96510. * Default value is 0.1
  96511. */
  96512. intersectionThreshold: number;
  96513. private _colorShader;
  96514. private color4;
  96515. /**
  96516. * Creates a new LinesMesh
  96517. * @param name defines the name
  96518. * @param scene defines the hosting scene
  96519. * @param parent defines the parent mesh if any
  96520. * @param source defines the optional source LinesMesh used to clone data from
  96521. * @param doNotCloneChildren When cloning, skip cloning child meshes of source, default False.
  96522. * When false, achieved by calling a clone(), also passing False.
  96523. * This will make creation of children, recursive.
  96524. * @param useVertexColor defines if this LinesMesh supports vertex color
  96525. * @param useVertexAlpha defines if this LinesMesh supports vertex alpha
  96526. */
  96527. constructor(name: string, scene?: Nullable<Scene>, parent?: Nullable<Node>, source?: Nullable<LinesMesh>, doNotCloneChildren?: boolean,
  96528. /**
  96529. * If vertex color should be applied to the mesh
  96530. */
  96531. useVertexColor?: boolean | undefined,
  96532. /**
  96533. * If vertex alpha should be applied to the mesh
  96534. */
  96535. useVertexAlpha?: boolean | undefined);
  96536. private _addClipPlaneDefine;
  96537. private _removeClipPlaneDefine;
  96538. isReady(): boolean;
  96539. /**
  96540. * Returns the string "LineMesh"
  96541. */
  96542. getClassName(): string;
  96543. /**
  96544. * @hidden
  96545. */
  96546. get material(): Material;
  96547. /**
  96548. * @hidden
  96549. */
  96550. set material(value: Material);
  96551. /**
  96552. * @hidden
  96553. */
  96554. get checkCollisions(): boolean;
  96555. /** @hidden */
  96556. _bind(subMesh: SubMesh, effect: Effect, fillMode: number): Mesh;
  96557. /** @hidden */
  96558. _draw(subMesh: SubMesh, fillMode: number, instancesCount?: number): Mesh;
  96559. /**
  96560. * Disposes of the line mesh
  96561. * @param doNotRecurse If children should be disposed
  96562. */
  96563. dispose(doNotRecurse?: boolean): void;
  96564. /**
  96565. * Returns a new LineMesh object cloned from the current one.
  96566. */
  96567. clone(name: string, newParent?: Nullable<Node>, doNotCloneChildren?: boolean): LinesMesh;
  96568. /**
  96569. * Creates a new InstancedLinesMesh object from the mesh model.
  96570. * @see https://doc.babylonjs.com/how_to/how_to_use_instances
  96571. * @param name defines the name of the new instance
  96572. * @returns a new InstancedLinesMesh
  96573. */
  96574. createInstance(name: string): InstancedLinesMesh;
  96575. }
  96576. /**
  96577. * Creates an instance based on a source LinesMesh
  96578. */
  96579. export class InstancedLinesMesh extends InstancedMesh {
  96580. /**
  96581. * The intersection Threshold is the margin applied when intersection a segment of the LinesMesh with a Ray.
  96582. * This margin is expressed in world space coordinates, so its value may vary.
  96583. * Initilized with the intersectionThreshold value of the source LinesMesh
  96584. */
  96585. intersectionThreshold: number;
  96586. constructor(name: string, source: LinesMesh);
  96587. /**
  96588. * Returns the string "InstancedLinesMesh".
  96589. */
  96590. getClassName(): string;
  96591. }
  96592. }
  96593. declare module BABYLON {
  96594. /** @hidden */
  96595. export var linePixelShader: {
  96596. name: string;
  96597. shader: string;
  96598. };
  96599. }
  96600. declare module BABYLON {
  96601. /** @hidden */
  96602. export var lineVertexShader: {
  96603. name: string;
  96604. shader: string;
  96605. };
  96606. }
  96607. declare module BABYLON {
  96608. interface Scene {
  96609. /** @hidden */
  96610. _edgeRenderLineShader: Nullable<ShaderMaterial>;
  96611. }
  96612. interface AbstractMesh {
  96613. /**
  96614. * Gets the edgesRenderer associated with the mesh
  96615. */
  96616. edgesRenderer: Nullable<EdgesRenderer>;
  96617. }
  96618. interface LinesMesh {
  96619. /**
  96620. * Enables the edge rendering mode on the mesh.
  96621. * This mode makes the mesh edges visible
  96622. * @param epsilon defines the maximal distance between two angles to detect a face
  96623. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  96624. * @returns the currentAbstractMesh
  96625. * @see https://www.babylonjs-playground.com/#19O9TU#0
  96626. */
  96627. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): AbstractMesh;
  96628. }
  96629. interface InstancedLinesMesh {
  96630. /**
  96631. * Enables the edge rendering mode on the mesh.
  96632. * This mode makes the mesh edges visible
  96633. * @param epsilon defines the maximal distance between two angles to detect a face
  96634. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  96635. * @returns the current InstancedLinesMesh
  96636. * @see https://www.babylonjs-playground.com/#19O9TU#0
  96637. */
  96638. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): InstancedLinesMesh;
  96639. }
  96640. /**
  96641. * Defines the minimum contract an Edges renderer should follow.
  96642. */
  96643. export interface IEdgesRenderer extends IDisposable {
  96644. /**
  96645. * Gets or sets a boolean indicating if the edgesRenderer is active
  96646. */
  96647. isEnabled: boolean;
  96648. /**
  96649. * Renders the edges of the attached mesh,
  96650. */
  96651. render(): void;
  96652. /**
  96653. * Checks wether or not the edges renderer is ready to render.
  96654. * @return true if ready, otherwise false.
  96655. */
  96656. isReady(): boolean;
  96657. /**
  96658. * List of instances to render in case the source mesh has instances
  96659. */
  96660. customInstances: SmartArray<Matrix>;
  96661. }
  96662. /**
  96663. * Defines the additional options of the edges renderer
  96664. */
  96665. export interface IEdgesRendererOptions {
  96666. /**
  96667. * Gets or sets a boolean indicating that the alternate edge finder algorithm must be used
  96668. * If not defined, the default value is true
  96669. */
  96670. useAlternateEdgeFinder?: boolean;
  96671. /**
  96672. * Gets or sets a boolean indicating that the vertex merger fast processing must be used.
  96673. * If not defined, the default value is true.
  96674. * 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)
  96675. * This option is used only if useAlternateEdgeFinder = true
  96676. */
  96677. useFastVertexMerger?: boolean;
  96678. /**
  96679. * During edges processing, the vertices are merged if they are close enough: epsilonVertexMerge is the limit whithin which vertices are considered to be equal.
  96680. * The default value is 1e-6
  96681. * This option is used only if useAlternateEdgeFinder = true
  96682. */
  96683. epsilonVertexMerge?: number;
  96684. /**
  96685. * 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
  96686. * 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.
  96687. * This option is used only if useAlternateEdgeFinder = true
  96688. */
  96689. applyTessellation?: boolean;
  96690. /**
  96691. * 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
  96692. * The default value is 1e-6
  96693. * This option is used only if useAlternateEdgeFinder = true
  96694. */
  96695. epsilonVertexAligned?: number;
  96696. }
  96697. /**
  96698. * This class is used to generate edges of the mesh that could then easily be rendered in a scene.
  96699. */
  96700. export class EdgesRenderer implements IEdgesRenderer {
  96701. /**
  96702. * Define the size of the edges with an orthographic camera
  96703. */
  96704. edgesWidthScalerForOrthographic: number;
  96705. /**
  96706. * Define the size of the edges with a perspective camera
  96707. */
  96708. edgesWidthScalerForPerspective: number;
  96709. protected _source: AbstractMesh;
  96710. protected _linesPositions: number[];
  96711. protected _linesNormals: number[];
  96712. protected _linesIndices: number[];
  96713. protected _epsilon: number;
  96714. protected _indicesCount: number;
  96715. protected _lineShader: ShaderMaterial;
  96716. protected _ib: DataBuffer;
  96717. protected _buffers: {
  96718. [key: string]: Nullable<VertexBuffer>;
  96719. };
  96720. protected _buffersForInstances: {
  96721. [key: string]: Nullable<VertexBuffer>;
  96722. };
  96723. protected _checkVerticesInsteadOfIndices: boolean;
  96724. protected _options: Nullable<IEdgesRendererOptions>;
  96725. private _meshRebuildObserver;
  96726. private _meshDisposeObserver;
  96727. /** Gets or sets a boolean indicating if the edgesRenderer is active */
  96728. isEnabled: boolean;
  96729. /**
  96730. * List of instances to render in case the source mesh has instances
  96731. */
  96732. customInstances: SmartArray<Matrix>;
  96733. private static GetShader;
  96734. /**
  96735. * Creates an instance of the EdgesRenderer. It is primarily use to display edges of a mesh.
  96736. * Beware when you use this class with complex objects as the adjacencies computation can be really long
  96737. * @param source Mesh used to create edges
  96738. * @param epsilon sum of angles in adjacency to check for edge
  96739. * @param checkVerticesInsteadOfIndices bases the edges detection on vertices vs indices. Note that this parameter is not used if options.useAlternateEdgeFinder = true
  96740. * @param generateEdgesLines - should generate Lines or only prepare resources.
  96741. * @param options The options to apply when generating the edges
  96742. */
  96743. constructor(source: AbstractMesh, epsilon?: number, checkVerticesInsteadOfIndices?: boolean, generateEdgesLines?: boolean, options?: IEdgesRendererOptions);
  96744. protected _prepareRessources(): void;
  96745. /** @hidden */
  96746. _rebuild(): void;
  96747. /**
  96748. * Releases the required resources for the edges renderer
  96749. */
  96750. dispose(): void;
  96751. protected _processEdgeForAdjacencies(pa: number, pb: number, p0: number, p1: number, p2: number): number;
  96752. protected _processEdgeForAdjacenciesWithVertices(pa: Vector3, pb: Vector3, p0: Vector3, p1: Vector3, p2: Vector3): number;
  96753. /**
  96754. * Checks if the pair of p0 and p1 is en edge
  96755. * @param faceIndex
  96756. * @param edge
  96757. * @param faceNormals
  96758. * @param p0
  96759. * @param p1
  96760. * @private
  96761. */
  96762. protected _checkEdge(faceIndex: number, edge: number, faceNormals: Array<Vector3>, p0: Vector3, p1: Vector3): void;
  96763. /**
  96764. * push line into the position, normal and index buffer
  96765. * @protected
  96766. */
  96767. protected createLine(p0: Vector3, p1: Vector3, offset: number): void;
  96768. /**
  96769. * See https://playground.babylonjs.com/#R3JR6V#1 for a visual display of the algorithm
  96770. */
  96771. private _tessellateTriangle;
  96772. private _generateEdgesLinesAlternate;
  96773. /**
  96774. * Generates lines edges from adjacencjes
  96775. * @private
  96776. */
  96777. _generateEdgesLines(): void;
  96778. /**
  96779. * Checks wether or not the edges renderer is ready to render.
  96780. * @return true if ready, otherwise false.
  96781. */
  96782. isReady(): boolean;
  96783. /**
  96784. * Renders the edges of the attached mesh,
  96785. */
  96786. render(): void;
  96787. }
  96788. /**
  96789. * LineEdgesRenderer for LineMeshes to remove unnecessary triangulation
  96790. */
  96791. export class LineEdgesRenderer extends EdgesRenderer {
  96792. /**
  96793. * This constructor turns off auto generating edges line in Edges Renderer to make it here.
  96794. * @param source LineMesh used to generate edges
  96795. * @param epsilon not important (specified angle for edge detection)
  96796. * @param checkVerticesInsteadOfIndices not important for LineMesh
  96797. */
  96798. constructor(source: AbstractMesh, epsilon?: number, checkVerticesInsteadOfIndices?: boolean);
  96799. /**
  96800. * Generate edges for each line in LinesMesh. Every Line should be rendered as edge.
  96801. */
  96802. _generateEdgesLines(): void;
  96803. }
  96804. }
  96805. declare module BABYLON {
  96806. /**
  96807. * This represents the object necessary to create a rendering group.
  96808. * This is exclusively used and created by the rendering manager.
  96809. * To modify the behavior, you use the available helpers in your scene or meshes.
  96810. * @hidden
  96811. */
  96812. export class RenderingGroup {
  96813. index: number;
  96814. private static _zeroVector;
  96815. private _scene;
  96816. private _opaqueSubMeshes;
  96817. private _transparentSubMeshes;
  96818. private _alphaTestSubMeshes;
  96819. private _depthOnlySubMeshes;
  96820. private _particleSystems;
  96821. private _spriteManagers;
  96822. private _opaqueSortCompareFn;
  96823. private _alphaTestSortCompareFn;
  96824. private _transparentSortCompareFn;
  96825. private _renderOpaque;
  96826. private _renderAlphaTest;
  96827. private _renderTransparent;
  96828. /** @hidden */
  96829. _edgesRenderers: SmartArrayNoDuplicate<IEdgesRenderer>;
  96830. onBeforeTransparentRendering: () => void;
  96831. /**
  96832. * Set the opaque sort comparison function.
  96833. * If null the sub meshes will be render in the order they were created
  96834. */
  96835. set opaqueSortCompareFn(value: Nullable<(a: SubMesh, b: SubMesh) => number>);
  96836. /**
  96837. * Set the alpha test sort comparison function.
  96838. * If null the sub meshes will be render in the order they were created
  96839. */
  96840. set alphaTestSortCompareFn(value: Nullable<(a: SubMesh, b: SubMesh) => number>);
  96841. /**
  96842. * Set the transparent sort comparison function.
  96843. * If null the sub meshes will be render in the order they were created
  96844. */
  96845. set transparentSortCompareFn(value: Nullable<(a: SubMesh, b: SubMesh) => number>);
  96846. /**
  96847. * Creates a new rendering group.
  96848. * @param index The rendering group index
  96849. * @param opaqueSortCompareFn The opaque sort comparison function. If null no order is applied
  96850. * @param alphaTestSortCompareFn The alpha test sort comparison function. If null no order is applied
  96851. * @param transparentSortCompareFn The transparent sort comparison function. If null back to front + alpha index sort is applied
  96852. */
  96853. 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>);
  96854. /**
  96855. * Render all the sub meshes contained in the group.
  96856. * @param customRenderFunction Used to override the default render behaviour of the group.
  96857. * @returns true if rendered some submeshes.
  96858. */
  96859. render(customRenderFunction: Nullable<(opaqueSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>) => void>, renderSprites: boolean, renderParticles: boolean, activeMeshes: Nullable<AbstractMesh[]>): void;
  96860. /**
  96861. * Renders the opaque submeshes in the order from the opaqueSortCompareFn.
  96862. * @param subMeshes The submeshes to render
  96863. */
  96864. private renderOpaqueSorted;
  96865. /**
  96866. * Renders the opaque submeshes in the order from the alphatestSortCompareFn.
  96867. * @param subMeshes The submeshes to render
  96868. */
  96869. private renderAlphaTestSorted;
  96870. /**
  96871. * Renders the opaque submeshes in the order from the transparentSortCompareFn.
  96872. * @param subMeshes The submeshes to render
  96873. */
  96874. private renderTransparentSorted;
  96875. /**
  96876. * Renders the submeshes in a specified order.
  96877. * @param subMeshes The submeshes to sort before render
  96878. * @param sortCompareFn The comparison function use to sort
  96879. * @param cameraPosition The camera position use to preprocess the submeshes to help sorting
  96880. * @param transparent Specifies to activate blending if true
  96881. */
  96882. private static renderSorted;
  96883. /**
  96884. * Renders the submeshes in the order they were dispatched (no sort applied).
  96885. * @param subMeshes The submeshes to render
  96886. */
  96887. private static renderUnsorted;
  96888. /**
  96889. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  96890. * are rendered back to front if in the same alpha index.
  96891. *
  96892. * @param a The first submesh
  96893. * @param b The second submesh
  96894. * @returns The result of the comparison
  96895. */
  96896. static defaultTransparentSortCompare(a: SubMesh, b: SubMesh): number;
  96897. /**
  96898. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  96899. * are rendered back to front.
  96900. *
  96901. * @param a The first submesh
  96902. * @param b The second submesh
  96903. * @returns The result of the comparison
  96904. */
  96905. static backToFrontSortCompare(a: SubMesh, b: SubMesh): number;
  96906. /**
  96907. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  96908. * are rendered front to back (prevent overdraw).
  96909. *
  96910. * @param a The first submesh
  96911. * @param b The second submesh
  96912. * @returns The result of the comparison
  96913. */
  96914. static frontToBackSortCompare(a: SubMesh, b: SubMesh): number;
  96915. /**
  96916. * Resets the different lists of submeshes to prepare a new frame.
  96917. */
  96918. prepare(): void;
  96919. dispose(): void;
  96920. /**
  96921. * Inserts the submesh in its correct queue depending on its material.
  96922. * @param subMesh The submesh to dispatch
  96923. * @param [mesh] Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  96924. * @param [material] Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  96925. */
  96926. dispatch(subMesh: SubMesh, mesh?: AbstractMesh, material?: Nullable<Material>): void;
  96927. dispatchSprites(spriteManager: ISpriteManager): void;
  96928. dispatchParticles(particleSystem: IParticleSystem): void;
  96929. private _renderParticles;
  96930. private _renderSprites;
  96931. }
  96932. }
  96933. declare module BABYLON {
  96934. /**
  96935. * Interface describing the different options available in the rendering manager
  96936. * regarding Auto Clear between groups.
  96937. */
  96938. export interface IRenderingManagerAutoClearSetup {
  96939. /**
  96940. * Defines whether or not autoclear is enable.
  96941. */
  96942. autoClear: boolean;
  96943. /**
  96944. * Defines whether or not to autoclear the depth buffer.
  96945. */
  96946. depth: boolean;
  96947. /**
  96948. * Defines whether or not to autoclear the stencil buffer.
  96949. */
  96950. stencil: boolean;
  96951. }
  96952. /**
  96953. * This class is used by the onRenderingGroupObservable
  96954. */
  96955. export class RenderingGroupInfo {
  96956. /**
  96957. * The Scene that being rendered
  96958. */
  96959. scene: Scene;
  96960. /**
  96961. * The camera currently used for the rendering pass
  96962. */
  96963. camera: Nullable<Camera>;
  96964. /**
  96965. * The ID of the renderingGroup being processed
  96966. */
  96967. renderingGroupId: number;
  96968. }
  96969. /**
  96970. * This is the manager responsible of all the rendering for meshes sprites and particles.
  96971. * It is enable to manage the different groups as well as the different necessary sort functions.
  96972. * This should not be used directly aside of the few static configurations
  96973. */
  96974. export class RenderingManager {
  96975. /**
  96976. * The max id used for rendering groups (not included)
  96977. */
  96978. static MAX_RENDERINGGROUPS: number;
  96979. /**
  96980. * The min id used for rendering groups (included)
  96981. */
  96982. static MIN_RENDERINGGROUPS: number;
  96983. /**
  96984. * Used to globally prevent autoclearing scenes.
  96985. */
  96986. static AUTOCLEAR: boolean;
  96987. /**
  96988. * @hidden
  96989. */
  96990. _useSceneAutoClearSetup: boolean;
  96991. private _scene;
  96992. private _renderingGroups;
  96993. private _depthStencilBufferAlreadyCleaned;
  96994. private _autoClearDepthStencil;
  96995. private _customOpaqueSortCompareFn;
  96996. private _customAlphaTestSortCompareFn;
  96997. private _customTransparentSortCompareFn;
  96998. private _renderingGroupInfo;
  96999. /**
  97000. * Instantiates a new rendering group for a particular scene
  97001. * @param scene Defines the scene the groups belongs to
  97002. */
  97003. constructor(scene: Scene);
  97004. private _clearDepthStencilBuffer;
  97005. /**
  97006. * Renders the entire managed groups. This is used by the scene or the different rennder targets.
  97007. * @hidden
  97008. */
  97009. render(customRenderFunction: Nullable<(opaqueSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>) => void>, activeMeshes: Nullable<AbstractMesh[]>, renderParticles: boolean, renderSprites: boolean): void;
  97010. /**
  97011. * Resets the different information of the group to prepare a new frame
  97012. * @hidden
  97013. */
  97014. reset(): void;
  97015. /**
  97016. * Dispose and release the group and its associated resources.
  97017. * @hidden
  97018. */
  97019. dispose(): void;
  97020. /**
  97021. * Clear the info related to rendering groups preventing retention points during dispose.
  97022. */
  97023. freeRenderingGroups(): void;
  97024. private _prepareRenderingGroup;
  97025. /**
  97026. * Add a sprite manager to the rendering manager in order to render it this frame.
  97027. * @param spriteManager Define the sprite manager to render
  97028. */
  97029. dispatchSprites(spriteManager: ISpriteManager): void;
  97030. /**
  97031. * Add a particle system to the rendering manager in order to render it this frame.
  97032. * @param particleSystem Define the particle system to render
  97033. */
  97034. dispatchParticles(particleSystem: IParticleSystem): void;
  97035. /**
  97036. * Add a submesh to the manager in order to render it this frame
  97037. * @param subMesh The submesh to dispatch
  97038. * @param mesh Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  97039. * @param material Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  97040. */
  97041. dispatch(subMesh: SubMesh, mesh?: AbstractMesh, material?: Nullable<Material>): void;
  97042. /**
  97043. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  97044. * This allowed control for front to back rendering or reversly depending of the special needs.
  97045. *
  97046. * @param renderingGroupId The rendering group id corresponding to its index
  97047. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  97048. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  97049. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  97050. */
  97051. 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;
  97052. /**
  97053. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  97054. *
  97055. * @param renderingGroupId The rendering group id corresponding to its index
  97056. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  97057. * @param depth Automatically clears depth between groups if true and autoClear is true.
  97058. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  97059. */
  97060. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  97061. /**
  97062. * Gets the current auto clear configuration for one rendering group of the rendering
  97063. * manager.
  97064. * @param index the rendering group index to get the information for
  97065. * @returns The auto clear setup for the requested rendering group
  97066. */
  97067. getAutoClearDepthStencilSetup(index: number): IRenderingManagerAutoClearSetup;
  97068. }
  97069. }
  97070. declare module BABYLON {
  97071. /**
  97072. * Defines the options associated with the creation of a custom shader for a shadow generator.
  97073. */
  97074. export interface ICustomShaderOptions {
  97075. /**
  97076. * Gets or sets the custom shader name to use
  97077. */
  97078. shaderName: string;
  97079. /**
  97080. * The list of attribute names used in the shader
  97081. */
  97082. attributes?: string[];
  97083. /**
  97084. * The list of unifrom names used in the shader
  97085. */
  97086. uniforms?: string[];
  97087. /**
  97088. * The list of sampler names used in the shader
  97089. */
  97090. samplers?: string[];
  97091. /**
  97092. * The list of defines used in the shader
  97093. */
  97094. defines?: string[];
  97095. }
  97096. /**
  97097. * Interface to implement to create a shadow generator compatible with BJS.
  97098. */
  97099. export interface IShadowGenerator {
  97100. /** Gets or set the id of the shadow generator. It will be the one from the light if not defined */
  97101. id: string;
  97102. /**
  97103. * Gets the main RTT containing the shadow map (usually storing depth from the light point of view).
  97104. * @returns The render target texture if present otherwise, null
  97105. */
  97106. getShadowMap(): Nullable<RenderTargetTexture>;
  97107. /**
  97108. * Determine wheter the shadow generator is ready or not (mainly all effects and related post processes needs to be ready).
  97109. * @param subMesh The submesh we want to render in the shadow map
  97110. * @param useInstances Defines wether will draw in the map using instances
  97111. * @param isTransparent Indicates that isReady is called for a transparent subMesh
  97112. * @returns true if ready otherwise, false
  97113. */
  97114. isReady(subMesh: SubMesh, useInstances: boolean, isTransparent: boolean): boolean;
  97115. /**
  97116. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  97117. * @param defines Defines of the material we want to update
  97118. * @param lightIndex Index of the light in the enabled light list of the material
  97119. */
  97120. prepareDefines(defines: MaterialDefines, lightIndex: number): void;
  97121. /**
  97122. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  97123. * defined in the generator but impacting the effect).
  97124. * It implies the unifroms available on the materials are the standard BJS ones.
  97125. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  97126. * @param effect The effect we are binfing the information for
  97127. */
  97128. bindShadowLight(lightIndex: string, effect: Effect): void;
  97129. /**
  97130. * Gets the transformation matrix used to project the meshes into the map from the light point of view.
  97131. * (eq to shadow prjection matrix * light transform matrix)
  97132. * @returns The transform matrix used to create the shadow map
  97133. */
  97134. getTransformMatrix(): Matrix;
  97135. /**
  97136. * Recreates the shadow map dependencies like RTT and post processes. This can be used during the switch between
  97137. * Cube and 2D textures for instance.
  97138. */
  97139. recreateShadowMap(): void;
  97140. /**
  97141. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  97142. * @param onCompiled Callback triggered at the and of the effects compilation
  97143. * @param options Sets of optional options forcing the compilation with different modes
  97144. */
  97145. forceCompilation(onCompiled?: (generator: IShadowGenerator) => void, options?: Partial<{
  97146. useInstances: boolean;
  97147. }>): void;
  97148. /**
  97149. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  97150. * @param options Sets of optional options forcing the compilation with different modes
  97151. * @returns A promise that resolves when the compilation completes
  97152. */
  97153. forceCompilationAsync(options?: Partial<{
  97154. useInstances: boolean;
  97155. }>): Promise<void>;
  97156. /**
  97157. * Serializes the shadow generator setup to a json object.
  97158. * @returns The serialized JSON object
  97159. */
  97160. serialize(): any;
  97161. /**
  97162. * Disposes the Shadow map and related Textures and effects.
  97163. */
  97164. dispose(): void;
  97165. }
  97166. /**
  97167. * Default implementation IShadowGenerator.
  97168. * This is the main object responsible of generating shadows in the framework.
  97169. * Documentation: https://doc.babylonjs.com/babylon101/shadows
  97170. */
  97171. export class ShadowGenerator implements IShadowGenerator {
  97172. /**
  97173. * Name of the shadow generator class
  97174. */
  97175. static CLASSNAME: string;
  97176. /**
  97177. * Shadow generator mode None: no filtering applied.
  97178. */
  97179. static readonly FILTER_NONE: number;
  97180. /**
  97181. * Shadow generator mode ESM: Exponential Shadow Mapping.
  97182. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  97183. */
  97184. static readonly FILTER_EXPONENTIALSHADOWMAP: number;
  97185. /**
  97186. * Shadow generator mode Poisson Sampling: Percentage Closer Filtering.
  97187. * (Multiple Tap around evenly distributed around the pixel are used to evaluate the shadow strength)
  97188. */
  97189. static readonly FILTER_POISSONSAMPLING: number;
  97190. /**
  97191. * Shadow generator mode ESM: Blurred Exponential Shadow Mapping.
  97192. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  97193. */
  97194. static readonly FILTER_BLUREXPONENTIALSHADOWMAP: number;
  97195. /**
  97196. * Shadow generator mode ESM: Exponential Shadow Mapping using the inverse of the exponential preventing
  97197. * edge artifacts on steep falloff.
  97198. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  97199. */
  97200. static readonly FILTER_CLOSEEXPONENTIALSHADOWMAP: number;
  97201. /**
  97202. * Shadow generator mode ESM: Blurred Exponential Shadow Mapping using the inverse of the exponential preventing
  97203. * edge artifacts on steep falloff.
  97204. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  97205. */
  97206. static readonly FILTER_BLURCLOSEEXPONENTIALSHADOWMAP: number;
  97207. /**
  97208. * Shadow generator mode PCF: Percentage Closer Filtering
  97209. * benefits from Webgl 2 shadow samplers. Fallback to Poisson Sampling in Webgl 1
  97210. * (https://developer.nvidia.com/gpugems/GPUGems/gpugems_ch11.html)
  97211. */
  97212. static readonly FILTER_PCF: number;
  97213. /**
  97214. * Shadow generator mode PCSS: Percentage Closering Soft Shadow.
  97215. * benefits from Webgl 2 shadow samplers. Fallback to Poisson Sampling in Webgl 1
  97216. * Contact Hardening
  97217. */
  97218. static readonly FILTER_PCSS: number;
  97219. /**
  97220. * Reserved for PCF and PCSS
  97221. * Highest Quality.
  97222. *
  97223. * Execute PCF on a 5*5 kernel improving a lot the shadow aliasing artifacts.
  97224. *
  97225. * Execute PCSS with 32 taps blocker search and 64 taps PCF.
  97226. */
  97227. static readonly QUALITY_HIGH: number;
  97228. /**
  97229. * Reserved for PCF and PCSS
  97230. * Good tradeoff for quality/perf cross devices
  97231. *
  97232. * Execute PCF on a 3*3 kernel.
  97233. *
  97234. * Execute PCSS with 16 taps blocker search and 32 taps PCF.
  97235. */
  97236. static readonly QUALITY_MEDIUM: number;
  97237. /**
  97238. * Reserved for PCF and PCSS
  97239. * The lowest quality but the fastest.
  97240. *
  97241. * Execute PCF on a 1*1 kernel.
  97242. *
  97243. * Execute PCSS with 16 taps blocker search and 16 taps PCF.
  97244. */
  97245. static readonly QUALITY_LOW: number;
  97246. /** Gets or set the id of the shadow generator. It will be the one from the light if not defined */
  97247. id: string;
  97248. /** Gets or sets the custom shader name to use */
  97249. customShaderOptions: ICustomShaderOptions;
  97250. /**
  97251. * Observable triggered before the shadow is rendered. Can be used to update internal effect state
  97252. */
  97253. onBeforeShadowMapRenderObservable: Observable<Effect>;
  97254. /**
  97255. * Observable triggered after the shadow is rendered. Can be used to restore internal effect state
  97256. */
  97257. onAfterShadowMapRenderObservable: Observable<Effect>;
  97258. /**
  97259. * Observable triggered before a mesh is rendered in the shadow map.
  97260. * Can be used to update internal effect state (that you can get from the onBeforeShadowMapRenderObservable)
  97261. */
  97262. onBeforeShadowMapRenderMeshObservable: Observable<Mesh>;
  97263. /**
  97264. * Observable triggered after a mesh is rendered in the shadow map.
  97265. * Can be used to update internal effect state (that you can get from the onAfterShadowMapRenderObservable)
  97266. */
  97267. onAfterShadowMapRenderMeshObservable: Observable<Mesh>;
  97268. protected _bias: number;
  97269. /**
  97270. * Gets the bias: offset applied on the depth preventing acnea (in light direction).
  97271. */
  97272. get bias(): number;
  97273. /**
  97274. * Sets the bias: offset applied on the depth preventing acnea (in light direction).
  97275. */
  97276. set bias(bias: number);
  97277. protected _normalBias: number;
  97278. /**
  97279. * Gets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportinal to the light/normal angle).
  97280. */
  97281. get normalBias(): number;
  97282. /**
  97283. * Sets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportinal to the light/normal angle).
  97284. */
  97285. set normalBias(normalBias: number);
  97286. protected _blurBoxOffset: number;
  97287. /**
  97288. * Gets the blur box offset: offset applied during the blur pass.
  97289. * Only useful if useKernelBlur = false
  97290. */
  97291. get blurBoxOffset(): number;
  97292. /**
  97293. * Sets the blur box offset: offset applied during the blur pass.
  97294. * Only useful if useKernelBlur = false
  97295. */
  97296. set blurBoxOffset(value: number);
  97297. protected _blurScale: number;
  97298. /**
  97299. * Gets the blur scale: scale of the blurred texture compared to the main shadow map.
  97300. * 2 means half of the size.
  97301. */
  97302. get blurScale(): number;
  97303. /**
  97304. * Sets the blur scale: scale of the blurred texture compared to the main shadow map.
  97305. * 2 means half of the size.
  97306. */
  97307. set blurScale(value: number);
  97308. protected _blurKernel: number;
  97309. /**
  97310. * Gets the blur kernel: kernel size of the blur pass.
  97311. * Only useful if useKernelBlur = true
  97312. */
  97313. get blurKernel(): number;
  97314. /**
  97315. * Sets the blur kernel: kernel size of the blur pass.
  97316. * Only useful if useKernelBlur = true
  97317. */
  97318. set blurKernel(value: number);
  97319. protected _useKernelBlur: boolean;
  97320. /**
  97321. * Gets whether the blur pass is a kernel blur (if true) or box blur.
  97322. * Only useful in filtered mode (useBlurExponentialShadowMap...)
  97323. */
  97324. get useKernelBlur(): boolean;
  97325. /**
  97326. * Sets whether the blur pass is a kernel blur (if true) or box blur.
  97327. * Only useful in filtered mode (useBlurExponentialShadowMap...)
  97328. */
  97329. set useKernelBlur(value: boolean);
  97330. protected _depthScale: number;
  97331. /**
  97332. * Gets the depth scale used in ESM mode.
  97333. */
  97334. get depthScale(): number;
  97335. /**
  97336. * Sets the depth scale used in ESM mode.
  97337. * This can override the scale stored on the light.
  97338. */
  97339. set depthScale(value: number);
  97340. protected _validateFilter(filter: number): number;
  97341. protected _filter: number;
  97342. /**
  97343. * Gets the current mode of the shadow generator (normal, PCF, ESM...).
  97344. * The returned value is a number equal to one of the available mode defined in ShadowMap.FILTER_x like _FILTER_NONE
  97345. */
  97346. get filter(): number;
  97347. /**
  97348. * Sets the current mode of the shadow generator (normal, PCF, ESM...).
  97349. * The returned value is a number equal to one of the available mode defined in ShadowMap.FILTER_x like _FILTER_NONE
  97350. */
  97351. set filter(value: number);
  97352. /**
  97353. * Gets if the current filter is set to Poisson Sampling.
  97354. */
  97355. get usePoissonSampling(): boolean;
  97356. /**
  97357. * Sets the current filter to Poisson Sampling.
  97358. */
  97359. set usePoissonSampling(value: boolean);
  97360. /**
  97361. * Gets if the current filter is set to ESM.
  97362. */
  97363. get useExponentialShadowMap(): boolean;
  97364. /**
  97365. * Sets the current filter is to ESM.
  97366. */
  97367. set useExponentialShadowMap(value: boolean);
  97368. /**
  97369. * Gets if the current filter is set to filtered ESM.
  97370. */
  97371. get useBlurExponentialShadowMap(): boolean;
  97372. /**
  97373. * Gets if the current filter is set to filtered ESM.
  97374. */
  97375. set useBlurExponentialShadowMap(value: boolean);
  97376. /**
  97377. * Gets if the current filter is set to "close ESM" (using the inverse of the
  97378. * exponential to prevent steep falloff artifacts).
  97379. */
  97380. get useCloseExponentialShadowMap(): boolean;
  97381. /**
  97382. * Sets the current filter to "close ESM" (using the inverse of the
  97383. * exponential to prevent steep falloff artifacts).
  97384. */
  97385. set useCloseExponentialShadowMap(value: boolean);
  97386. /**
  97387. * Gets if the current filter is set to filtered "close ESM" (using the inverse of the
  97388. * exponential to prevent steep falloff artifacts).
  97389. */
  97390. get useBlurCloseExponentialShadowMap(): boolean;
  97391. /**
  97392. * Sets the current filter to filtered "close ESM" (using the inverse of the
  97393. * exponential to prevent steep falloff artifacts).
  97394. */
  97395. set useBlurCloseExponentialShadowMap(value: boolean);
  97396. /**
  97397. * Gets if the current filter is set to "PCF" (percentage closer filtering).
  97398. */
  97399. get usePercentageCloserFiltering(): boolean;
  97400. /**
  97401. * Sets the current filter to "PCF" (percentage closer filtering).
  97402. */
  97403. set usePercentageCloserFiltering(value: boolean);
  97404. protected _filteringQuality: number;
  97405. /**
  97406. * Gets the PCF or PCSS Quality.
  97407. * Only valid if usePercentageCloserFiltering or usePercentageCloserFiltering is true.
  97408. */
  97409. get filteringQuality(): number;
  97410. /**
  97411. * Sets the PCF or PCSS Quality.
  97412. * Only valid if usePercentageCloserFiltering or usePercentageCloserFiltering is true.
  97413. */
  97414. set filteringQuality(filteringQuality: number);
  97415. /**
  97416. * Gets if the current filter is set to "PCSS" (contact hardening).
  97417. */
  97418. get useContactHardeningShadow(): boolean;
  97419. /**
  97420. * Sets the current filter to "PCSS" (contact hardening).
  97421. */
  97422. set useContactHardeningShadow(value: boolean);
  97423. protected _contactHardeningLightSizeUVRatio: number;
  97424. /**
  97425. * Gets the Light Size (in shadow map uv unit) used in PCSS to determine the blocker search area and the penumbra size.
  97426. * Using a ratio helps keeping shape stability independently of the map size.
  97427. *
  97428. * It does not account for the light projection as it was having too much
  97429. * instability during the light setup or during light position changes.
  97430. *
  97431. * Only valid if useContactHardeningShadow is true.
  97432. */
  97433. get contactHardeningLightSizeUVRatio(): number;
  97434. /**
  97435. * Sets the Light Size (in shadow map uv unit) used in PCSS to determine the blocker search area and the penumbra size.
  97436. * Using a ratio helps keeping shape stability independently of the map size.
  97437. *
  97438. * It does not account for the light projection as it was having too much
  97439. * instability during the light setup or during light position changes.
  97440. *
  97441. * Only valid if useContactHardeningShadow is true.
  97442. */
  97443. set contactHardeningLightSizeUVRatio(contactHardeningLightSizeUVRatio: number);
  97444. protected _darkness: number;
  97445. /** Gets or sets the actual darkness of a shadow */
  97446. get darkness(): number;
  97447. set darkness(value: number);
  97448. /**
  97449. * Returns the darkness value (float). This can only decrease the actual darkness of a shadow.
  97450. * 0 means strongest and 1 would means no shadow.
  97451. * @returns the darkness.
  97452. */
  97453. getDarkness(): number;
  97454. /**
  97455. * Sets the darkness value (float). This can only decrease the actual darkness of a shadow.
  97456. * @param darkness The darkness value 0 means strongest and 1 would means no shadow.
  97457. * @returns the shadow generator allowing fluent coding.
  97458. */
  97459. setDarkness(darkness: number): ShadowGenerator;
  97460. protected _transparencyShadow: boolean;
  97461. /** Gets or sets the ability to have transparent shadow */
  97462. get transparencyShadow(): boolean;
  97463. set transparencyShadow(value: boolean);
  97464. /**
  97465. * Sets the ability to have transparent shadow (boolean).
  97466. * @param transparent True if transparent else False
  97467. * @returns the shadow generator allowing fluent coding
  97468. */
  97469. setTransparencyShadow(transparent: boolean): ShadowGenerator;
  97470. /**
  97471. * Enables or disables shadows with varying strength based on the transparency
  97472. * When it is enabled, the strength of the shadow is taken equal to mesh.visibility
  97473. * If you enabled an alpha texture on your material, the alpha value red from the texture is also combined to compute the strength:
  97474. * mesh.visibility * alphaTexture.a
  97475. * Note that by definition transparencyShadow must be set to true for enableSoftTransparentShadow to work!
  97476. */
  97477. enableSoftTransparentShadow: boolean;
  97478. protected _shadowMap: Nullable<RenderTargetTexture>;
  97479. protected _shadowMap2: Nullable<RenderTargetTexture>;
  97480. /**
  97481. * Gets the main RTT containing the shadow map (usually storing depth from the light point of view).
  97482. * @returns The render target texture if present otherwise, null
  97483. */
  97484. getShadowMap(): Nullable<RenderTargetTexture>;
  97485. /**
  97486. * Gets the RTT used during rendering (can be a blurred version of the shadow map or the shadow map itself).
  97487. * @returns The render target texture if the shadow map is present otherwise, null
  97488. */
  97489. getShadowMapForRendering(): Nullable<RenderTargetTexture>;
  97490. /**
  97491. * Gets the class name of that object
  97492. * @returns "ShadowGenerator"
  97493. */
  97494. getClassName(): string;
  97495. /**
  97496. * Helper function to add a mesh and its descendants to the list of shadow casters.
  97497. * @param mesh Mesh to add
  97498. * @param includeDescendants boolean indicating if the descendants should be added. Default to true
  97499. * @returns the Shadow Generator itself
  97500. */
  97501. addShadowCaster(mesh: AbstractMesh, includeDescendants?: boolean): ShadowGenerator;
  97502. /**
  97503. * Helper function to remove a mesh and its descendants from the list of shadow casters
  97504. * @param mesh Mesh to remove
  97505. * @param includeDescendants boolean indicating if the descendants should be removed. Default to true
  97506. * @returns the Shadow Generator itself
  97507. */
  97508. removeShadowCaster(mesh: AbstractMesh, includeDescendants?: boolean): ShadowGenerator;
  97509. /**
  97510. * Controls the extent to which the shadows fade out at the edge of the frustum
  97511. */
  97512. frustumEdgeFalloff: number;
  97513. protected _light: IShadowLight;
  97514. /**
  97515. * Returns the associated light object.
  97516. * @returns the light generating the shadow
  97517. */
  97518. getLight(): IShadowLight;
  97519. /**
  97520. * If true the shadow map is generated by rendering the back face of the mesh instead of the front face.
  97521. * This can help with self-shadowing as the geometry making up the back of objects is slightly offset.
  97522. * It might on the other hand introduce peter panning.
  97523. */
  97524. forceBackFacesOnly: boolean;
  97525. protected _scene: Scene;
  97526. protected _lightDirection: Vector3;
  97527. protected _effect: Effect;
  97528. protected _viewMatrix: Matrix;
  97529. protected _projectionMatrix: Matrix;
  97530. protected _transformMatrix: Matrix;
  97531. protected _cachedPosition: Vector3;
  97532. protected _cachedDirection: Vector3;
  97533. protected _cachedDefines: string;
  97534. protected _currentRenderID: number;
  97535. protected _boxBlurPostprocess: Nullable<PostProcess>;
  97536. protected _kernelBlurXPostprocess: Nullable<PostProcess>;
  97537. protected _kernelBlurYPostprocess: Nullable<PostProcess>;
  97538. protected _blurPostProcesses: PostProcess[];
  97539. protected _mapSize: number;
  97540. protected _currentFaceIndex: number;
  97541. protected _currentFaceIndexCache: number;
  97542. protected _textureType: number;
  97543. protected _defaultTextureMatrix: Matrix;
  97544. protected _storedUniqueId: Nullable<number>;
  97545. /** @hidden */
  97546. static _SceneComponentInitialization: (scene: Scene) => void;
  97547. /**
  97548. * Creates a ShadowGenerator object.
  97549. * A ShadowGenerator is the required tool to use the shadows.
  97550. * Each light casting shadows needs to use its own ShadowGenerator.
  97551. * Documentation : https://doc.babylonjs.com/babylon101/shadows
  97552. * @param mapSize The size of the texture what stores the shadows. Example : 1024.
  97553. * @param light The light object generating the shadows.
  97554. * @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.
  97555. */
  97556. constructor(mapSize: number, light: IShadowLight, usefulFloatFirst?: boolean);
  97557. protected _initializeGenerator(): void;
  97558. protected _createTargetRenderTexture(): void;
  97559. protected _initializeShadowMap(): void;
  97560. protected _initializeBlurRTTAndPostProcesses(): void;
  97561. protected _renderForShadowMap(opaqueSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>): void;
  97562. protected _bindCustomEffectForRenderSubMeshForShadowMap(subMesh: SubMesh, effect: Effect, matriceNames: any, mesh: AbstractMesh): void;
  97563. protected _renderSubMeshForShadowMap(subMesh: SubMesh, isTransparent?: boolean): void;
  97564. protected _applyFilterValues(): void;
  97565. /**
  97566. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  97567. * @param onCompiled Callback triggered at the and of the effects compilation
  97568. * @param options Sets of optional options forcing the compilation with different modes
  97569. */
  97570. forceCompilation(onCompiled?: (generator: IShadowGenerator) => void, options?: Partial<{
  97571. useInstances: boolean;
  97572. }>): void;
  97573. /**
  97574. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  97575. * @param options Sets of optional options forcing the compilation with different modes
  97576. * @returns A promise that resolves when the compilation completes
  97577. */
  97578. forceCompilationAsync(options?: Partial<{
  97579. useInstances: boolean;
  97580. }>): Promise<void>;
  97581. protected _isReadyCustomDefines(defines: any, subMesh: SubMesh, useInstances: boolean): void;
  97582. private _prepareShadowDefines;
  97583. /**
  97584. * Determine wheter the shadow generator is ready or not (mainly all effects and related post processes needs to be ready).
  97585. * @param subMesh The submesh we want to render in the shadow map
  97586. * @param useInstances Defines wether will draw in the map using instances
  97587. * @param isTransparent Indicates that isReady is called for a transparent subMesh
  97588. * @returns true if ready otherwise, false
  97589. */
  97590. isReady(subMesh: SubMesh, useInstances: boolean, isTransparent: boolean): boolean;
  97591. /**
  97592. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  97593. * @param defines Defines of the material we want to update
  97594. * @param lightIndex Index of the light in the enabled light list of the material
  97595. */
  97596. prepareDefines(defines: any, lightIndex: number): void;
  97597. /**
  97598. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  97599. * defined in the generator but impacting the effect).
  97600. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  97601. * @param effect The effect we are binfing the information for
  97602. */
  97603. bindShadowLight(lightIndex: string, effect: Effect): void;
  97604. /**
  97605. * Gets the transformation matrix used to project the meshes into the map from the light point of view.
  97606. * (eq to shadow prjection matrix * light transform matrix)
  97607. * @returns The transform matrix used to create the shadow map
  97608. */
  97609. getTransformMatrix(): Matrix;
  97610. /**
  97611. * Recreates the shadow map dependencies like RTT and post processes. This can be used during the switch between
  97612. * Cube and 2D textures for instance.
  97613. */
  97614. recreateShadowMap(): void;
  97615. protected _disposeBlurPostProcesses(): void;
  97616. protected _disposeRTTandPostProcesses(): void;
  97617. /**
  97618. * Disposes the ShadowGenerator.
  97619. * Returns nothing.
  97620. */
  97621. dispose(): void;
  97622. /**
  97623. * Serializes the shadow generator setup to a json object.
  97624. * @returns The serialized JSON object
  97625. */
  97626. serialize(): any;
  97627. /**
  97628. * Parses a serialized ShadowGenerator and returns a new ShadowGenerator.
  97629. * @param parsedShadowGenerator The JSON object to parse
  97630. * @param scene The scene to create the shadow map for
  97631. * @param constr A function that builds a shadow generator or undefined to create an instance of the default shadow generator
  97632. * @returns The parsed shadow generator
  97633. */
  97634. static Parse(parsedShadowGenerator: any, scene: Scene, constr?: (mapSize: number, light: IShadowLight) => ShadowGenerator): ShadowGenerator;
  97635. }
  97636. }
  97637. declare module BABYLON {
  97638. /**
  97639. * Base class of all the lights in Babylon. It groups all the generic information about lights.
  97640. * Lights are used, as you would expect, to affect how meshes are seen, in terms of both illumination and colour.
  97641. * 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.
  97642. */
  97643. export abstract class Light extends Node {
  97644. /**
  97645. * Falloff Default: light is falling off following the material specification:
  97646. * standard material is using standard falloff whereas pbr material can request special falloff per materials.
  97647. */
  97648. static readonly FALLOFF_DEFAULT: number;
  97649. /**
  97650. * Falloff Physical: light is falling off following the inverse squared distance law.
  97651. */
  97652. static readonly FALLOFF_PHYSICAL: number;
  97653. /**
  97654. * Falloff gltf: light is falling off as described in the gltf moving to PBR document
  97655. * to enhance interoperability with other engines.
  97656. */
  97657. static readonly FALLOFF_GLTF: number;
  97658. /**
  97659. * Falloff Standard: light is falling off like in the standard material
  97660. * to enhance interoperability with other materials.
  97661. */
  97662. static readonly FALLOFF_STANDARD: number;
  97663. /**
  97664. * If every light affecting the material is in this lightmapMode,
  97665. * material.lightmapTexture adds or multiplies
  97666. * (depends on material.useLightmapAsShadowmap)
  97667. * after every other light calculations.
  97668. */
  97669. static readonly LIGHTMAP_DEFAULT: number;
  97670. /**
  97671. * material.lightmapTexture as only diffuse lighting from this light
  97672. * adds only specular lighting from this light
  97673. * adds dynamic shadows
  97674. */
  97675. static readonly LIGHTMAP_SPECULAR: number;
  97676. /**
  97677. * material.lightmapTexture as only lighting
  97678. * no light calculation from this light
  97679. * only adds dynamic shadows from this light
  97680. */
  97681. static readonly LIGHTMAP_SHADOWSONLY: number;
  97682. /**
  97683. * Each light type uses the default quantity according to its type:
  97684. * point/spot lights use luminous intensity
  97685. * directional lights use illuminance
  97686. */
  97687. static readonly INTENSITYMODE_AUTOMATIC: number;
  97688. /**
  97689. * lumen (lm)
  97690. */
  97691. static readonly INTENSITYMODE_LUMINOUSPOWER: number;
  97692. /**
  97693. * candela (lm/sr)
  97694. */
  97695. static readonly INTENSITYMODE_LUMINOUSINTENSITY: number;
  97696. /**
  97697. * lux (lm/m^2)
  97698. */
  97699. static readonly INTENSITYMODE_ILLUMINANCE: number;
  97700. /**
  97701. * nit (cd/m^2)
  97702. */
  97703. static readonly INTENSITYMODE_LUMINANCE: number;
  97704. /**
  97705. * Light type const id of the point light.
  97706. */
  97707. static readonly LIGHTTYPEID_POINTLIGHT: number;
  97708. /**
  97709. * Light type const id of the directional light.
  97710. */
  97711. static readonly LIGHTTYPEID_DIRECTIONALLIGHT: number;
  97712. /**
  97713. * Light type const id of the spot light.
  97714. */
  97715. static readonly LIGHTTYPEID_SPOTLIGHT: number;
  97716. /**
  97717. * Light type const id of the hemispheric light.
  97718. */
  97719. static readonly LIGHTTYPEID_HEMISPHERICLIGHT: number;
  97720. /**
  97721. * Diffuse gives the basic color to an object.
  97722. */
  97723. diffuse: Color3;
  97724. /**
  97725. * Specular produces a highlight color on an object.
  97726. * Note: This is note affecting PBR materials.
  97727. */
  97728. specular: Color3;
  97729. /**
  97730. * Defines the falloff type for this light. This lets overrriding how punctual light are
  97731. * falling off base on range or angle.
  97732. * This can be set to any values in Light.FALLOFF_x.
  97733. *
  97734. * Note: This is only useful for PBR Materials at the moment. This could be extended if required to
  97735. * other types of materials.
  97736. */
  97737. falloffType: number;
  97738. /**
  97739. * Strength of the light.
  97740. * Note: By default it is define in the framework own unit.
  97741. * Note: In PBR materials the intensityMode can be use to chose what unit the intensity is defined in.
  97742. */
  97743. intensity: number;
  97744. private _range;
  97745. protected _inverseSquaredRange: number;
  97746. /**
  97747. * Defines how far from the source the light is impacting in scene units.
  97748. * Note: Unused in PBR material as the distance light falloff is defined following the inverse squared falloff.
  97749. */
  97750. get range(): number;
  97751. /**
  97752. * Defines how far from the source the light is impacting in scene units.
  97753. * Note: Unused in PBR material as the distance light falloff is defined following the inverse squared falloff.
  97754. */
  97755. set range(value: number);
  97756. /**
  97757. * Cached photometric scale default to 1.0 as the automatic intensity mode defaults to 1.0 for every type
  97758. * of light.
  97759. */
  97760. private _photometricScale;
  97761. private _intensityMode;
  97762. /**
  97763. * Gets the photometric scale used to interpret the intensity.
  97764. * This is only relevant with PBR Materials where the light intensity can be defined in a physical way.
  97765. */
  97766. get intensityMode(): number;
  97767. /**
  97768. * Sets the photometric scale used to interpret the intensity.
  97769. * This is only relevant with PBR Materials where the light intensity can be defined in a physical way.
  97770. */
  97771. set intensityMode(value: number);
  97772. private _radius;
  97773. /**
  97774. * Gets the light radius used by PBR Materials to simulate soft area lights.
  97775. */
  97776. get radius(): number;
  97777. /**
  97778. * sets the light radius used by PBR Materials to simulate soft area lights.
  97779. */
  97780. set radius(value: number);
  97781. private _renderPriority;
  97782. /**
  97783. * Defines the rendering priority of the lights. It can help in case of fallback or number of lights
  97784. * exceeding the number allowed of the materials.
  97785. */
  97786. renderPriority: number;
  97787. private _shadowEnabled;
  97788. /**
  97789. * Gets wether or not the shadows are enabled for this light. This can help turning off/on shadow without detaching
  97790. * the current shadow generator.
  97791. */
  97792. get shadowEnabled(): boolean;
  97793. /**
  97794. * Sets wether or not the shadows are enabled for this light. This can help turning off/on shadow without detaching
  97795. * the current shadow generator.
  97796. */
  97797. set shadowEnabled(value: boolean);
  97798. private _includedOnlyMeshes;
  97799. /**
  97800. * Gets the only meshes impacted by this light.
  97801. */
  97802. get includedOnlyMeshes(): AbstractMesh[];
  97803. /**
  97804. * Sets the only meshes impacted by this light.
  97805. */
  97806. set includedOnlyMeshes(value: AbstractMesh[]);
  97807. private _excludedMeshes;
  97808. /**
  97809. * Gets the meshes not impacted by this light.
  97810. */
  97811. get excludedMeshes(): AbstractMesh[];
  97812. /**
  97813. * Sets the meshes not impacted by this light.
  97814. */
  97815. set excludedMeshes(value: AbstractMesh[]);
  97816. private _excludeWithLayerMask;
  97817. /**
  97818. * Gets the layer id use to find what meshes are not impacted by the light.
  97819. * Inactive if 0
  97820. */
  97821. get excludeWithLayerMask(): number;
  97822. /**
  97823. * Sets the layer id use to find what meshes are not impacted by the light.
  97824. * Inactive if 0
  97825. */
  97826. set excludeWithLayerMask(value: number);
  97827. private _includeOnlyWithLayerMask;
  97828. /**
  97829. * Gets the layer id use to find what meshes are impacted by the light.
  97830. * Inactive if 0
  97831. */
  97832. get includeOnlyWithLayerMask(): number;
  97833. /**
  97834. * Sets the layer id use to find what meshes are impacted by the light.
  97835. * Inactive if 0
  97836. */
  97837. set includeOnlyWithLayerMask(value: number);
  97838. private _lightmapMode;
  97839. /**
  97840. * Gets the lightmap mode of this light (should be one of the constants defined by Light.LIGHTMAP_x)
  97841. */
  97842. get lightmapMode(): number;
  97843. /**
  97844. * Sets the lightmap mode of this light (should be one of the constants defined by Light.LIGHTMAP_x)
  97845. */
  97846. set lightmapMode(value: number);
  97847. /**
  97848. * Shadow generator associted to the light.
  97849. * @hidden Internal use only.
  97850. */
  97851. _shadowGenerator: Nullable<IShadowGenerator>;
  97852. /**
  97853. * @hidden Internal use only.
  97854. */
  97855. _excludedMeshesIds: string[];
  97856. /**
  97857. * @hidden Internal use only.
  97858. */
  97859. _includedOnlyMeshesIds: string[];
  97860. /**
  97861. * The current light unifom buffer.
  97862. * @hidden Internal use only.
  97863. */
  97864. _uniformBuffer: UniformBuffer;
  97865. /** @hidden */
  97866. _renderId: number;
  97867. /**
  97868. * Creates a Light object in the scene.
  97869. * Documentation : https://doc.babylonjs.com/babylon101/lights
  97870. * @param name The firendly name of the light
  97871. * @param scene The scene the light belongs too
  97872. */
  97873. constructor(name: string, scene: Scene);
  97874. protected abstract _buildUniformLayout(): void;
  97875. /**
  97876. * Sets the passed Effect "effect" with the Light information.
  97877. * @param effect The effect to update
  97878. * @param lightIndex The index of the light in the effect to update
  97879. * @returns The light
  97880. */
  97881. abstract transferToEffect(effect: Effect, lightIndex: string): Light;
  97882. /**
  97883. * Sets the passed Effect "effect" with the Light textures.
  97884. * @param effect The effect to update
  97885. * @param lightIndex The index of the light in the effect to update
  97886. * @returns The light
  97887. */
  97888. transferTexturesToEffect(effect: Effect, lightIndex: string): Light;
  97889. /**
  97890. * Binds the lights information from the scene to the effect for the given mesh.
  97891. * @param lightIndex Light index
  97892. * @param scene The scene where the light belongs to
  97893. * @param effect The effect we are binding the data to
  97894. * @param useSpecular Defines if specular is supported
  97895. * @param rebuildInParallel Specifies whether the shader is rebuilding in parallel
  97896. */
  97897. _bindLight(lightIndex: number, scene: Scene, effect: Effect, useSpecular: boolean, rebuildInParallel?: boolean): void;
  97898. /**
  97899. * Sets the passed Effect "effect" with the Light information.
  97900. * @param effect The effect to update
  97901. * @param lightDataUniformName The uniform used to store light data (position or direction)
  97902. * @returns The light
  97903. */
  97904. abstract transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): Light;
  97905. /**
  97906. * Returns the string "Light".
  97907. * @returns the class name
  97908. */
  97909. getClassName(): string;
  97910. /** @hidden */
  97911. readonly _isLight: boolean;
  97912. /**
  97913. * Converts the light information to a readable string for debug purpose.
  97914. * @param fullDetails Supports for multiple levels of logging within scene loading
  97915. * @returns the human readable light info
  97916. */
  97917. toString(fullDetails?: boolean): string;
  97918. /** @hidden */
  97919. protected _syncParentEnabledState(): void;
  97920. /**
  97921. * Set the enabled state of this node.
  97922. * @param value - the new enabled state
  97923. */
  97924. setEnabled(value: boolean): void;
  97925. /**
  97926. * Returns the Light associated shadow generator if any.
  97927. * @return the associated shadow generator.
  97928. */
  97929. getShadowGenerator(): Nullable<IShadowGenerator>;
  97930. /**
  97931. * Returns a Vector3, the absolute light position in the World.
  97932. * @returns the world space position of the light
  97933. */
  97934. getAbsolutePosition(): Vector3;
  97935. /**
  97936. * Specifies if the light will affect the passed mesh.
  97937. * @param mesh The mesh to test against the light
  97938. * @return true the mesh is affected otherwise, false.
  97939. */
  97940. canAffectMesh(mesh: AbstractMesh): boolean;
  97941. /**
  97942. * Sort function to order lights for rendering.
  97943. * @param a First Light object to compare to second.
  97944. * @param b Second Light object to compare first.
  97945. * @return -1 to reduce's a's index relative to be, 0 for no change, 1 to increase a's index relative to b.
  97946. */
  97947. static CompareLightsPriority(a: Light, b: Light): number;
  97948. /**
  97949. * Releases resources associated with this node.
  97950. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  97951. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  97952. */
  97953. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  97954. /**
  97955. * Returns the light type ID (integer).
  97956. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  97957. */
  97958. getTypeID(): number;
  97959. /**
  97960. * Returns the intensity scaled by the Photometric Scale according to the light type and intensity mode.
  97961. * @returns the scaled intensity in intensity mode unit
  97962. */
  97963. getScaledIntensity(): number;
  97964. /**
  97965. * Returns a new Light object, named "name", from the current one.
  97966. * @param name The name of the cloned light
  97967. * @param newParent The parent of this light, if it has one
  97968. * @returns the new created light
  97969. */
  97970. clone(name: string, newParent?: Nullable<Node>): Nullable<Light>;
  97971. /**
  97972. * Serializes the current light into a Serialization object.
  97973. * @returns the serialized object.
  97974. */
  97975. serialize(): any;
  97976. /**
  97977. * Creates a new typed light from the passed type (integer) : point light = 0, directional light = 1, spot light = 2, hemispheric light = 3.
  97978. * This new light is named "name" and added to the passed scene.
  97979. * @param type Type according to the types available in Light.LIGHTTYPEID_x
  97980. * @param name The friendly name of the light
  97981. * @param scene The scene the new light will belong to
  97982. * @returns the constructor function
  97983. */
  97984. static GetConstructorFromName(type: number, name: string, scene: Scene): Nullable<() => Light>;
  97985. /**
  97986. * Parses the passed "parsedLight" and returns a new instanced Light from this parsing.
  97987. * @param parsedLight The JSON representation of the light
  97988. * @param scene The scene to create the parsed light in
  97989. * @returns the created light after parsing
  97990. */
  97991. static Parse(parsedLight: any, scene: Scene): Nullable<Light>;
  97992. private _hookArrayForExcluded;
  97993. private _hookArrayForIncludedOnly;
  97994. private _resyncMeshes;
  97995. /**
  97996. * Forces the meshes to update their light related information in their rendering used effects
  97997. * @hidden Internal Use Only
  97998. */
  97999. _markMeshesAsLightDirty(): void;
  98000. /**
  98001. * Recomputes the cached photometric scale if needed.
  98002. */
  98003. private _computePhotometricScale;
  98004. /**
  98005. * Returns the Photometric Scale according to the light type and intensity mode.
  98006. */
  98007. private _getPhotometricScale;
  98008. /**
  98009. * Reorder the light in the scene according to their defined priority.
  98010. * @hidden Internal Use Only
  98011. */
  98012. _reorderLightsInScene(): void;
  98013. /**
  98014. * Prepares the list of defines specific to the light type.
  98015. * @param defines the list of defines
  98016. * @param lightIndex defines the index of the light for the effect
  98017. */
  98018. abstract prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  98019. }
  98020. }
  98021. declare module BABYLON {
  98022. /**
  98023. * A target camera takes a mesh or position as a target and continues to look at it while it moves.
  98024. * This is the base of the follow, arc rotate cameras and Free camera
  98025. * @see https://doc.babylonjs.com/features/cameras
  98026. */
  98027. export class TargetCamera extends Camera {
  98028. private static _RigCamTransformMatrix;
  98029. private static _TargetTransformMatrix;
  98030. private static _TargetFocalPoint;
  98031. private _tmpUpVector;
  98032. private _tmpTargetVector;
  98033. /**
  98034. * Define the current direction the camera is moving to
  98035. */
  98036. cameraDirection: Vector3;
  98037. /**
  98038. * Define the current rotation the camera is rotating to
  98039. */
  98040. cameraRotation: Vector2;
  98041. /** Gets or sets a boolean indicating that the scaling of the parent hierarchy will not be taken in account by the camera */
  98042. ignoreParentScaling: boolean;
  98043. /**
  98044. * When set, the up vector of the camera will be updated by the rotation of the camera
  98045. */
  98046. updateUpVectorFromRotation: boolean;
  98047. private _tmpQuaternion;
  98048. /**
  98049. * Define the current rotation of the camera
  98050. */
  98051. rotation: Vector3;
  98052. /**
  98053. * Define the current rotation of the camera as a quaternion to prevent Gimbal lock
  98054. */
  98055. rotationQuaternion: Quaternion;
  98056. /**
  98057. * Define the current speed of the camera
  98058. */
  98059. speed: number;
  98060. /**
  98061. * Add constraint to the camera to prevent it to move freely in all directions and
  98062. * around all axis.
  98063. */
  98064. noRotationConstraint: boolean;
  98065. /**
  98066. * Reverses mouselook direction to 'natural' panning as opposed to traditional direct
  98067. * panning
  98068. */
  98069. invertRotation: boolean;
  98070. /**
  98071. * Speed multiplier for inverse camera panning
  98072. */
  98073. inverseRotationSpeed: number;
  98074. /**
  98075. * Define the current target of the camera as an object or a position.
  98076. */
  98077. lockedTarget: any;
  98078. /** @hidden */
  98079. _currentTarget: Vector3;
  98080. /** @hidden */
  98081. _initialFocalDistance: number;
  98082. /** @hidden */
  98083. _viewMatrix: Matrix;
  98084. /** @hidden */
  98085. _camMatrix: Matrix;
  98086. /** @hidden */
  98087. _cameraTransformMatrix: Matrix;
  98088. /** @hidden */
  98089. _cameraRotationMatrix: Matrix;
  98090. /** @hidden */
  98091. _referencePoint: Vector3;
  98092. /** @hidden */
  98093. _transformedReferencePoint: Vector3;
  98094. /** @hidden */
  98095. _reset: () => void;
  98096. private _defaultUp;
  98097. /**
  98098. * Instantiates a target camera that takes a mesh or position as a target and continues to look at it while it moves.
  98099. * This is the base of the follow, arc rotate cameras and Free camera
  98100. * @see https://doc.babylonjs.com/features/cameras
  98101. * @param name Defines the name of the camera in the scene
  98102. * @param position Defines the start position of the camera in the scene
  98103. * @param scene Defines the scene the camera belongs to
  98104. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  98105. */
  98106. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  98107. /**
  98108. * Gets the position in front of the camera at a given distance.
  98109. * @param distance The distance from the camera we want the position to be
  98110. * @returns the position
  98111. */
  98112. getFrontPosition(distance: number): Vector3;
  98113. /** @hidden */
  98114. _getLockedTargetPosition(): Nullable<Vector3>;
  98115. private _storedPosition;
  98116. private _storedRotation;
  98117. private _storedRotationQuaternion;
  98118. /**
  98119. * Store current camera state of the camera (fov, position, rotation, etc..)
  98120. * @returns the camera
  98121. */
  98122. storeState(): Camera;
  98123. /**
  98124. * Restored camera state. You must call storeState() first
  98125. * @returns whether it was successful or not
  98126. * @hidden
  98127. */
  98128. _restoreStateValues(): boolean;
  98129. /** @hidden */
  98130. _initCache(): void;
  98131. /** @hidden */
  98132. _updateCache(ignoreParentClass?: boolean): void;
  98133. /** @hidden */
  98134. _isSynchronizedViewMatrix(): boolean;
  98135. /** @hidden */
  98136. _computeLocalCameraSpeed(): number;
  98137. /**
  98138. * Defines the target the camera should look at.
  98139. * @param target Defines the new target as a Vector or a mesh
  98140. */
  98141. setTarget(target: Vector3): void;
  98142. /**
  98143. * Defines the target point of the camera.
  98144. * The camera looks towards it form the radius distance.
  98145. */
  98146. get target(): Vector3;
  98147. set target(value: Vector3);
  98148. /**
  98149. * Return the current target position of the camera. This value is expressed in local space.
  98150. * @returns the target position
  98151. */
  98152. getTarget(): Vector3;
  98153. /** @hidden */
  98154. _decideIfNeedsToMove(): boolean;
  98155. /** @hidden */
  98156. _updatePosition(): void;
  98157. /** @hidden */
  98158. _checkInputs(): void;
  98159. protected _updateCameraRotationMatrix(): void;
  98160. /**
  98161. * 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)
  98162. * @returns the current camera
  98163. */
  98164. private _rotateUpVectorWithCameraRotationMatrix;
  98165. private _cachedRotationZ;
  98166. private _cachedQuaternionRotationZ;
  98167. /** @hidden */
  98168. _getViewMatrix(): Matrix;
  98169. protected _computeViewMatrix(position: Vector3, target: Vector3, up: Vector3): void;
  98170. /**
  98171. * @hidden
  98172. */
  98173. createRigCamera(name: string, cameraIndex: number): Nullable<Camera>;
  98174. /**
  98175. * @hidden
  98176. */
  98177. _updateRigCameras(): void;
  98178. private _getRigCamPositionAndTarget;
  98179. /**
  98180. * Gets the current object class name.
  98181. * @return the class name
  98182. */
  98183. getClassName(): string;
  98184. }
  98185. }
  98186. declare module BABYLON {
  98187. /**
  98188. * Gather the list of keyboard event types as constants.
  98189. */
  98190. export class KeyboardEventTypes {
  98191. /**
  98192. * The keydown event is fired when a key becomes active (pressed).
  98193. */
  98194. static readonly KEYDOWN: number;
  98195. /**
  98196. * The keyup event is fired when a key has been released.
  98197. */
  98198. static readonly KEYUP: number;
  98199. }
  98200. /**
  98201. * This class is used to store keyboard related info for the onKeyboardObservable event.
  98202. */
  98203. export class KeyboardInfo {
  98204. /**
  98205. * Defines the type of event (KeyboardEventTypes)
  98206. */
  98207. type: number;
  98208. /**
  98209. * Defines the related dom event
  98210. */
  98211. event: KeyboardEvent;
  98212. /**
  98213. * Instantiates a new keyboard info.
  98214. * This class is used to store keyboard related info for the onKeyboardObservable event.
  98215. * @param type Defines the type of event (KeyboardEventTypes)
  98216. * @param event Defines the related dom event
  98217. */
  98218. constructor(
  98219. /**
  98220. * Defines the type of event (KeyboardEventTypes)
  98221. */
  98222. type: number,
  98223. /**
  98224. * Defines the related dom event
  98225. */
  98226. event: KeyboardEvent);
  98227. }
  98228. /**
  98229. * This class is used to store keyboard related info for the onPreKeyboardObservable event.
  98230. * Set the skipOnKeyboardObservable property to true if you want the engine to stop any process after this event is triggered, even not calling onKeyboardObservable
  98231. */
  98232. export class KeyboardInfoPre extends KeyboardInfo {
  98233. /**
  98234. * Defines the type of event (KeyboardEventTypes)
  98235. */
  98236. type: number;
  98237. /**
  98238. * Defines the related dom event
  98239. */
  98240. event: KeyboardEvent;
  98241. /**
  98242. * Defines whether the engine should skip the next onKeyboardObservable associated to this pre.
  98243. */
  98244. skipOnPointerObservable: boolean;
  98245. /**
  98246. * Instantiates a new keyboard pre info.
  98247. * This class is used to store keyboard related info for the onPreKeyboardObservable event.
  98248. * @param type Defines the type of event (KeyboardEventTypes)
  98249. * @param event Defines the related dom event
  98250. */
  98251. constructor(
  98252. /**
  98253. * Defines the type of event (KeyboardEventTypes)
  98254. */
  98255. type: number,
  98256. /**
  98257. * Defines the related dom event
  98258. */
  98259. event: KeyboardEvent);
  98260. }
  98261. }
  98262. declare module BABYLON {
  98263. /**
  98264. * Manage the keyboard inputs to control the movement of a free camera.
  98265. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  98266. */
  98267. export class FreeCameraKeyboardMoveInput implements ICameraInput<FreeCamera> {
  98268. /**
  98269. * Defines the camera the input is attached to.
  98270. */
  98271. camera: FreeCamera;
  98272. /**
  98273. * Gets or Set the list of keyboard keys used to control the forward move of the camera.
  98274. */
  98275. keysUp: number[];
  98276. /**
  98277. * Gets or Set the list of keyboard keys used to control the upward move of the camera.
  98278. */
  98279. keysUpward: number[];
  98280. /**
  98281. * Gets or Set the list of keyboard keys used to control the backward move of the camera.
  98282. */
  98283. keysDown: number[];
  98284. /**
  98285. * Gets or Set the list of keyboard keys used to control the downward move of the camera.
  98286. */
  98287. keysDownward: number[];
  98288. /**
  98289. * Gets or Set the list of keyboard keys used to control the left strafe move of the camera.
  98290. */
  98291. keysLeft: number[];
  98292. /**
  98293. * Gets or Set the list of keyboard keys used to control the right strafe move of the camera.
  98294. */
  98295. keysRight: number[];
  98296. private _keys;
  98297. private _onCanvasBlurObserver;
  98298. private _onKeyboardObserver;
  98299. private _engine;
  98300. private _scene;
  98301. /**
  98302. * Attach the input controls to a specific dom element to get the input from.
  98303. * @param element Defines the element the controls should be listened from
  98304. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  98305. */
  98306. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  98307. /**
  98308. * Detach the current controls from the specified dom element.
  98309. * @param element Defines the element to stop listening the inputs from
  98310. */
  98311. detachControl(element: Nullable<HTMLElement>): void;
  98312. /**
  98313. * Update the current camera state depending on the inputs that have been used this frame.
  98314. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  98315. */
  98316. checkInputs(): void;
  98317. /**
  98318. * Gets the class name of the current intput.
  98319. * @returns the class name
  98320. */
  98321. getClassName(): string;
  98322. /** @hidden */
  98323. _onLostFocus(): void;
  98324. /**
  98325. * Get the friendly name associated with the input class.
  98326. * @returns the input friendly name
  98327. */
  98328. getSimpleName(): string;
  98329. }
  98330. }
  98331. declare module BABYLON {
  98332. /**
  98333. * Gather the list of pointer event types as constants.
  98334. */
  98335. export class PointerEventTypes {
  98336. /**
  98337. * 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.
  98338. */
  98339. static readonly POINTERDOWN: number;
  98340. /**
  98341. * The pointerup event is fired when a pointer is no longer active.
  98342. */
  98343. static readonly POINTERUP: number;
  98344. /**
  98345. * The pointermove event is fired when a pointer changes coordinates.
  98346. */
  98347. static readonly POINTERMOVE: number;
  98348. /**
  98349. * The pointerwheel event is fired when a mouse wheel has been rotated.
  98350. */
  98351. static readonly POINTERWHEEL: number;
  98352. /**
  98353. * The pointerpick event is fired when a mesh or sprite has been picked by the pointer.
  98354. */
  98355. static readonly POINTERPICK: number;
  98356. /**
  98357. * The pointertap event is fired when a the object has been touched and released without drag.
  98358. */
  98359. static readonly POINTERTAP: number;
  98360. /**
  98361. * The pointerdoubletap event is fired when a the object has been touched and released twice without drag.
  98362. */
  98363. static readonly POINTERDOUBLETAP: number;
  98364. }
  98365. /**
  98366. * Base class of pointer info types.
  98367. */
  98368. export class PointerInfoBase {
  98369. /**
  98370. * Defines the type of event (PointerEventTypes)
  98371. */
  98372. type: number;
  98373. /**
  98374. * Defines the related dom event
  98375. */
  98376. event: PointerEvent | MouseWheelEvent;
  98377. /**
  98378. * Instantiates the base class of pointers info.
  98379. * @param type Defines the type of event (PointerEventTypes)
  98380. * @param event Defines the related dom event
  98381. */
  98382. constructor(
  98383. /**
  98384. * Defines the type of event (PointerEventTypes)
  98385. */
  98386. type: number,
  98387. /**
  98388. * Defines the related dom event
  98389. */
  98390. event: PointerEvent | MouseWheelEvent);
  98391. }
  98392. /**
  98393. * This class is used to store pointer related info for the onPrePointerObservable event.
  98394. * Set the skipOnPointerObservable property to true if you want the engine to stop any process after this event is triggered, even not calling onPointerObservable
  98395. */
  98396. export class PointerInfoPre extends PointerInfoBase {
  98397. /**
  98398. * Ray from a pointer if availible (eg. 6dof controller)
  98399. */
  98400. ray: Nullable<Ray>;
  98401. /**
  98402. * Defines the local position of the pointer on the canvas.
  98403. */
  98404. localPosition: Vector2;
  98405. /**
  98406. * Defines whether the engine should skip the next OnPointerObservable associated to this pre.
  98407. */
  98408. skipOnPointerObservable: boolean;
  98409. /**
  98410. * Instantiates a PointerInfoPre to store pointer related info to the onPrePointerObservable event.
  98411. * @param type Defines the type of event (PointerEventTypes)
  98412. * @param event Defines the related dom event
  98413. * @param localX Defines the local x coordinates of the pointer when the event occured
  98414. * @param localY Defines the local y coordinates of the pointer when the event occured
  98415. */
  98416. constructor(type: number, event: PointerEvent | MouseWheelEvent, localX: number, localY: number);
  98417. }
  98418. /**
  98419. * This type contains all the data related to a pointer event in Babylon.js.
  98420. * 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.
  98421. */
  98422. export class PointerInfo extends PointerInfoBase {
  98423. /**
  98424. * Defines the picking info associated to the info (if any)\
  98425. */
  98426. pickInfo: Nullable<PickingInfo>;
  98427. /**
  98428. * Instantiates a PointerInfo to store pointer related info to the onPointerObservable event.
  98429. * @param type Defines the type of event (PointerEventTypes)
  98430. * @param event Defines the related dom event
  98431. * @param pickInfo Defines the picking info associated to the info (if any)\
  98432. */
  98433. constructor(type: number, event: PointerEvent | MouseWheelEvent,
  98434. /**
  98435. * Defines the picking info associated to the info (if any)\
  98436. */
  98437. pickInfo: Nullable<PickingInfo>);
  98438. }
  98439. /**
  98440. * Data relating to a touch event on the screen.
  98441. */
  98442. export interface PointerTouch {
  98443. /**
  98444. * X coordinate of touch.
  98445. */
  98446. x: number;
  98447. /**
  98448. * Y coordinate of touch.
  98449. */
  98450. y: number;
  98451. /**
  98452. * Id of touch. Unique for each finger.
  98453. */
  98454. pointerId: number;
  98455. /**
  98456. * Event type passed from DOM.
  98457. */
  98458. type: any;
  98459. }
  98460. }
  98461. declare module BABYLON {
  98462. /**
  98463. * Manage the mouse inputs to control the movement of a free camera.
  98464. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  98465. */
  98466. export class FreeCameraMouseInput implements ICameraInput<FreeCamera> {
  98467. /**
  98468. * Define if touch is enabled in the mouse input
  98469. */
  98470. touchEnabled: boolean;
  98471. /**
  98472. * Defines the camera the input is attached to.
  98473. */
  98474. camera: FreeCamera;
  98475. /**
  98476. * Defines the buttons associated with the input to handle camera move.
  98477. */
  98478. buttons: number[];
  98479. /**
  98480. * Defines the pointer angular sensibility along the X and Y axis or how fast is the camera rotating.
  98481. */
  98482. angularSensibility: number;
  98483. private _pointerInput;
  98484. private _onMouseMove;
  98485. private _observer;
  98486. private previousPosition;
  98487. /**
  98488. * Observable for when a pointer move event occurs containing the move offset
  98489. */
  98490. onPointerMovedObservable: Observable<{
  98491. offsetX: number;
  98492. offsetY: number;
  98493. }>;
  98494. /**
  98495. * @hidden
  98496. * If the camera should be rotated automatically based on pointer movement
  98497. */
  98498. _allowCameraRotation: boolean;
  98499. /**
  98500. * Manage the mouse inputs to control the movement of a free camera.
  98501. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  98502. * @param touchEnabled Defines if touch is enabled or not
  98503. */
  98504. constructor(
  98505. /**
  98506. * Define if touch is enabled in the mouse input
  98507. */
  98508. touchEnabled?: boolean);
  98509. /**
  98510. * Attach the input controls to a specific dom element to get the input from.
  98511. * @param element Defines the element the controls should be listened from
  98512. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  98513. */
  98514. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  98515. /**
  98516. * Called on JS contextmenu event.
  98517. * Override this method to provide functionality.
  98518. */
  98519. protected onContextMenu(evt: PointerEvent): void;
  98520. /**
  98521. * Detach the current controls from the specified dom element.
  98522. * @param element Defines the element to stop listening the inputs from
  98523. */
  98524. detachControl(element: Nullable<HTMLElement>): void;
  98525. /**
  98526. * Gets the class name of the current intput.
  98527. * @returns the class name
  98528. */
  98529. getClassName(): string;
  98530. /**
  98531. * Get the friendly name associated with the input class.
  98532. * @returns the input friendly name
  98533. */
  98534. getSimpleName(): string;
  98535. }
  98536. }
  98537. declare module BABYLON {
  98538. /**
  98539. * Manage the touch inputs to control the movement of a free camera.
  98540. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  98541. */
  98542. export class FreeCameraTouchInput implements ICameraInput<FreeCamera> {
  98543. /**
  98544. * Define if mouse events can be treated as touch events
  98545. */
  98546. allowMouse: boolean;
  98547. /**
  98548. * Defines the camera the input is attached to.
  98549. */
  98550. camera: FreeCamera;
  98551. /**
  98552. * Defines the touch sensibility for rotation.
  98553. * The higher the faster.
  98554. */
  98555. touchAngularSensibility: number;
  98556. /**
  98557. * Defines the touch sensibility for move.
  98558. * The higher the faster.
  98559. */
  98560. touchMoveSensibility: number;
  98561. private _offsetX;
  98562. private _offsetY;
  98563. private _pointerPressed;
  98564. private _pointerInput;
  98565. private _observer;
  98566. private _onLostFocus;
  98567. /**
  98568. * Manage the touch inputs to control the movement of a free camera.
  98569. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  98570. * @param allowMouse Defines if mouse events can be treated as touch events
  98571. */
  98572. constructor(
  98573. /**
  98574. * Define if mouse events can be treated as touch events
  98575. */
  98576. allowMouse?: boolean);
  98577. /**
  98578. * Attach the input controls to a specific dom element to get the input from.
  98579. * @param element Defines the element the controls should be listened from
  98580. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  98581. */
  98582. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  98583. /**
  98584. * Detach the current controls from the specified dom element.
  98585. * @param element Defines the element to stop listening the inputs from
  98586. */
  98587. detachControl(element: Nullable<HTMLElement>): void;
  98588. /**
  98589. * Update the current camera state depending on the inputs that have been used this frame.
  98590. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  98591. */
  98592. checkInputs(): void;
  98593. /**
  98594. * Gets the class name of the current intput.
  98595. * @returns the class name
  98596. */
  98597. getClassName(): string;
  98598. /**
  98599. * Get the friendly name associated with the input class.
  98600. * @returns the input friendly name
  98601. */
  98602. getSimpleName(): string;
  98603. }
  98604. }
  98605. declare module BABYLON {
  98606. /**
  98607. * Default Inputs manager for the FreeCamera.
  98608. * It groups all the default supported inputs for ease of use.
  98609. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  98610. */
  98611. export class FreeCameraInputsManager extends CameraInputsManager<FreeCamera> {
  98612. /**
  98613. * @hidden
  98614. */
  98615. _mouseInput: Nullable<FreeCameraMouseInput>;
  98616. /**
  98617. * Instantiates a new FreeCameraInputsManager.
  98618. * @param camera Defines the camera the inputs belong to
  98619. */
  98620. constructor(camera: FreeCamera);
  98621. /**
  98622. * Add keyboard input support to the input manager.
  98623. * @returns the current input manager
  98624. */
  98625. addKeyboard(): FreeCameraInputsManager;
  98626. /**
  98627. * Add mouse input support to the input manager.
  98628. * @param touchEnabled if the FreeCameraMouseInput should support touch (default: true)
  98629. * @returns the current input manager
  98630. */
  98631. addMouse(touchEnabled?: boolean): FreeCameraInputsManager;
  98632. /**
  98633. * Removes the mouse input support from the manager
  98634. * @returns the current input manager
  98635. */
  98636. removeMouse(): FreeCameraInputsManager;
  98637. /**
  98638. * Add touch input support to the input manager.
  98639. * @returns the current input manager
  98640. */
  98641. addTouch(): FreeCameraInputsManager;
  98642. /**
  98643. * Remove all attached input methods from a camera
  98644. */
  98645. clear(): void;
  98646. }
  98647. }
  98648. declare module BABYLON {
  98649. /**
  98650. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  98651. * Please consider using the new UniversalCamera instead as it adds more functionality like the gamepad.
  98652. * @see https://doc.babylonjs.com/features/cameras#universal-camera
  98653. */
  98654. export class FreeCamera extends TargetCamera {
  98655. /**
  98656. * Define the collision ellipsoid of the camera.
  98657. * This is helpful to simulate a camera body like the player body around the camera
  98658. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  98659. */
  98660. ellipsoid: Vector3;
  98661. /**
  98662. * Define an offset for the position of the ellipsoid around the camera.
  98663. * This can be helpful to determine the center of the body near the gravity center of the body
  98664. * instead of its head.
  98665. */
  98666. ellipsoidOffset: Vector3;
  98667. /**
  98668. * Enable or disable collisions of the camera with the rest of the scene objects.
  98669. */
  98670. checkCollisions: boolean;
  98671. /**
  98672. * Enable or disable gravity on the camera.
  98673. */
  98674. applyGravity: boolean;
  98675. /**
  98676. * Define the input manager associated to the camera.
  98677. */
  98678. inputs: FreeCameraInputsManager;
  98679. /**
  98680. * Gets the input sensibility for a mouse input. (default is 2000.0)
  98681. * Higher values reduce sensitivity.
  98682. */
  98683. get angularSensibility(): number;
  98684. /**
  98685. * Sets the input sensibility for a mouse input. (default is 2000.0)
  98686. * Higher values reduce sensitivity.
  98687. */
  98688. set angularSensibility(value: number);
  98689. /**
  98690. * Gets or Set the list of keyboard keys used to control the forward move of the camera.
  98691. */
  98692. get keysUp(): number[];
  98693. set keysUp(value: number[]);
  98694. /**
  98695. * Gets or Set the list of keyboard keys used to control the upward move of the camera.
  98696. */
  98697. get keysUpward(): number[];
  98698. set keysUpward(value: number[]);
  98699. /**
  98700. * Gets or Set the list of keyboard keys used to control the backward move of the camera.
  98701. */
  98702. get keysDown(): number[];
  98703. set keysDown(value: number[]);
  98704. /**
  98705. * Gets or Set the list of keyboard keys used to control the downward move of the camera.
  98706. */
  98707. get keysDownward(): number[];
  98708. set keysDownward(value: number[]);
  98709. /**
  98710. * Gets or Set the list of keyboard keys used to control the left strafe move of the camera.
  98711. */
  98712. get keysLeft(): number[];
  98713. set keysLeft(value: number[]);
  98714. /**
  98715. * Gets or Set the list of keyboard keys used to control the right strafe move of the camera.
  98716. */
  98717. get keysRight(): number[];
  98718. set keysRight(value: number[]);
  98719. /**
  98720. * Event raised when the camera collide with a mesh in the scene.
  98721. */
  98722. onCollide: (collidedMesh: AbstractMesh) => void;
  98723. private _collider;
  98724. private _needMoveForGravity;
  98725. private _oldPosition;
  98726. private _diffPosition;
  98727. private _newPosition;
  98728. /** @hidden */
  98729. _localDirection: Vector3;
  98730. /** @hidden */
  98731. _transformedDirection: Vector3;
  98732. /**
  98733. * Instantiates a Free Camera.
  98734. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  98735. * Please consider using the new UniversalCamera instead as it adds more functionality like touch to this camera.
  98736. * @see https://doc.babylonjs.com/features/cameras#universal-camera
  98737. * @param name Define the name of the camera in the scene
  98738. * @param position Define the start position of the camera in the scene
  98739. * @param scene Define the scene the camera belongs to
  98740. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  98741. */
  98742. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  98743. /**
  98744. * Attached controls to the current camera.
  98745. * @param element Defines the element the controls should be listened from
  98746. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  98747. */
  98748. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  98749. /**
  98750. * Detach the current controls from the camera.
  98751. * The camera will stop reacting to inputs.
  98752. * @param element Defines the element to stop listening the inputs from
  98753. */
  98754. detachControl(element: HTMLElement): void;
  98755. private _collisionMask;
  98756. /**
  98757. * Define a collision mask to limit the list of object the camera can collide with
  98758. */
  98759. get collisionMask(): number;
  98760. set collisionMask(mask: number);
  98761. /** @hidden */
  98762. _collideWithWorld(displacement: Vector3): void;
  98763. private _onCollisionPositionChange;
  98764. /** @hidden */
  98765. _checkInputs(): void;
  98766. /** @hidden */
  98767. _decideIfNeedsToMove(): boolean;
  98768. /** @hidden */
  98769. _updatePosition(): void;
  98770. /**
  98771. * Destroy the camera and release the current resources hold by it.
  98772. */
  98773. dispose(): void;
  98774. /**
  98775. * Gets the current object class name.
  98776. * @return the class name
  98777. */
  98778. getClassName(): string;
  98779. }
  98780. }
  98781. declare module BABYLON {
  98782. /**
  98783. * Represents a gamepad control stick position
  98784. */
  98785. export class StickValues {
  98786. /**
  98787. * The x component of the control stick
  98788. */
  98789. x: number;
  98790. /**
  98791. * The y component of the control stick
  98792. */
  98793. y: number;
  98794. /**
  98795. * Initializes the gamepad x and y control stick values
  98796. * @param x The x component of the gamepad control stick value
  98797. * @param y The y component of the gamepad control stick value
  98798. */
  98799. constructor(
  98800. /**
  98801. * The x component of the control stick
  98802. */
  98803. x: number,
  98804. /**
  98805. * The y component of the control stick
  98806. */
  98807. y: number);
  98808. }
  98809. /**
  98810. * An interface which manages callbacks for gamepad button changes
  98811. */
  98812. export interface GamepadButtonChanges {
  98813. /**
  98814. * Called when a gamepad has been changed
  98815. */
  98816. changed: boolean;
  98817. /**
  98818. * Called when a gamepad press event has been triggered
  98819. */
  98820. pressChanged: boolean;
  98821. /**
  98822. * Called when a touch event has been triggered
  98823. */
  98824. touchChanged: boolean;
  98825. /**
  98826. * Called when a value has changed
  98827. */
  98828. valueChanged: boolean;
  98829. }
  98830. /**
  98831. * Represents a gamepad
  98832. */
  98833. export class Gamepad {
  98834. /**
  98835. * The id of the gamepad
  98836. */
  98837. id: string;
  98838. /**
  98839. * The index of the gamepad
  98840. */
  98841. index: number;
  98842. /**
  98843. * The browser gamepad
  98844. */
  98845. browserGamepad: any;
  98846. /**
  98847. * Specifies what type of gamepad this represents
  98848. */
  98849. type: number;
  98850. private _leftStick;
  98851. private _rightStick;
  98852. /** @hidden */
  98853. _isConnected: boolean;
  98854. private _leftStickAxisX;
  98855. private _leftStickAxisY;
  98856. private _rightStickAxisX;
  98857. private _rightStickAxisY;
  98858. /**
  98859. * Triggered when the left control stick has been changed
  98860. */
  98861. private _onleftstickchanged;
  98862. /**
  98863. * Triggered when the right control stick has been changed
  98864. */
  98865. private _onrightstickchanged;
  98866. /**
  98867. * Represents a gamepad controller
  98868. */
  98869. static GAMEPAD: number;
  98870. /**
  98871. * Represents a generic controller
  98872. */
  98873. static GENERIC: number;
  98874. /**
  98875. * Represents an XBox controller
  98876. */
  98877. static XBOX: number;
  98878. /**
  98879. * Represents a pose-enabled controller
  98880. */
  98881. static POSE_ENABLED: number;
  98882. /**
  98883. * Represents an Dual Shock controller
  98884. */
  98885. static DUALSHOCK: number;
  98886. /**
  98887. * Specifies whether the left control stick should be Y-inverted
  98888. */
  98889. protected _invertLeftStickY: boolean;
  98890. /**
  98891. * Specifies if the gamepad has been connected
  98892. */
  98893. get isConnected(): boolean;
  98894. /**
  98895. * Initializes the gamepad
  98896. * @param id The id of the gamepad
  98897. * @param index The index of the gamepad
  98898. * @param browserGamepad The browser gamepad
  98899. * @param leftStickX The x component of the left joystick
  98900. * @param leftStickY The y component of the left joystick
  98901. * @param rightStickX The x component of the right joystick
  98902. * @param rightStickY The y component of the right joystick
  98903. */
  98904. constructor(
  98905. /**
  98906. * The id of the gamepad
  98907. */
  98908. id: string,
  98909. /**
  98910. * The index of the gamepad
  98911. */
  98912. index: number,
  98913. /**
  98914. * The browser gamepad
  98915. */
  98916. browserGamepad: any, leftStickX?: number, leftStickY?: number, rightStickX?: number, rightStickY?: number);
  98917. /**
  98918. * Callback triggered when the left joystick has changed
  98919. * @param callback
  98920. */
  98921. onleftstickchanged(callback: (values: StickValues) => void): void;
  98922. /**
  98923. * Callback triggered when the right joystick has changed
  98924. * @param callback
  98925. */
  98926. onrightstickchanged(callback: (values: StickValues) => void): void;
  98927. /**
  98928. * Gets the left joystick
  98929. */
  98930. get leftStick(): StickValues;
  98931. /**
  98932. * Sets the left joystick values
  98933. */
  98934. set leftStick(newValues: StickValues);
  98935. /**
  98936. * Gets the right joystick
  98937. */
  98938. get rightStick(): StickValues;
  98939. /**
  98940. * Sets the right joystick value
  98941. */
  98942. set rightStick(newValues: StickValues);
  98943. /**
  98944. * Updates the gamepad joystick positions
  98945. */
  98946. update(): void;
  98947. /**
  98948. * Disposes the gamepad
  98949. */
  98950. dispose(): void;
  98951. }
  98952. /**
  98953. * Represents a generic gamepad
  98954. */
  98955. export class GenericPad extends Gamepad {
  98956. private _buttons;
  98957. private _onbuttondown;
  98958. private _onbuttonup;
  98959. /**
  98960. * Observable triggered when a button has been pressed
  98961. */
  98962. onButtonDownObservable: Observable<number>;
  98963. /**
  98964. * Observable triggered when a button has been released
  98965. */
  98966. onButtonUpObservable: Observable<number>;
  98967. /**
  98968. * Callback triggered when a button has been pressed
  98969. * @param callback Called when a button has been pressed
  98970. */
  98971. onbuttondown(callback: (buttonPressed: number) => void): void;
  98972. /**
  98973. * Callback triggered when a button has been released
  98974. * @param callback Called when a button has been released
  98975. */
  98976. onbuttonup(callback: (buttonReleased: number) => void): void;
  98977. /**
  98978. * Initializes the generic gamepad
  98979. * @param id The id of the generic gamepad
  98980. * @param index The index of the generic gamepad
  98981. * @param browserGamepad The browser gamepad
  98982. */
  98983. constructor(id: string, index: number, browserGamepad: any);
  98984. private _setButtonValue;
  98985. /**
  98986. * Updates the generic gamepad
  98987. */
  98988. update(): void;
  98989. /**
  98990. * Disposes the generic gamepad
  98991. */
  98992. dispose(): void;
  98993. }
  98994. }
  98995. declare module BABYLON {
  98996. /**
  98997. * Defines the types of pose enabled controllers that are supported
  98998. */
  98999. export enum PoseEnabledControllerType {
  99000. /**
  99001. * HTC Vive
  99002. */
  99003. VIVE = 0,
  99004. /**
  99005. * Oculus Rift
  99006. */
  99007. OCULUS = 1,
  99008. /**
  99009. * Windows mixed reality
  99010. */
  99011. WINDOWS = 2,
  99012. /**
  99013. * Samsung gear VR
  99014. */
  99015. GEAR_VR = 3,
  99016. /**
  99017. * Google Daydream
  99018. */
  99019. DAYDREAM = 4,
  99020. /**
  99021. * Generic
  99022. */
  99023. GENERIC = 5
  99024. }
  99025. /**
  99026. * Defines the MutableGamepadButton interface for the state of a gamepad button
  99027. */
  99028. export interface MutableGamepadButton {
  99029. /**
  99030. * Value of the button/trigger
  99031. */
  99032. value: number;
  99033. /**
  99034. * If the button/trigger is currently touched
  99035. */
  99036. touched: boolean;
  99037. /**
  99038. * If the button/trigger is currently pressed
  99039. */
  99040. pressed: boolean;
  99041. }
  99042. /**
  99043. * Defines the ExtendedGamepadButton interface for a gamepad button which includes state provided by a pose controller
  99044. * @hidden
  99045. */
  99046. export interface ExtendedGamepadButton extends GamepadButton {
  99047. /**
  99048. * If the button/trigger is currently pressed
  99049. */
  99050. readonly pressed: boolean;
  99051. /**
  99052. * If the button/trigger is currently touched
  99053. */
  99054. readonly touched: boolean;
  99055. /**
  99056. * Value of the button/trigger
  99057. */
  99058. readonly value: number;
  99059. }
  99060. /** @hidden */
  99061. export interface _GamePadFactory {
  99062. /**
  99063. * Returns whether or not the current gamepad can be created for this type of controller.
  99064. * @param gamepadInfo Defines the gamepad info as received from the controller APIs.
  99065. * @returns true if it can be created, otherwise false
  99066. */
  99067. canCreate(gamepadInfo: any): boolean;
  99068. /**
  99069. * Creates a new instance of the Gamepad.
  99070. * @param gamepadInfo Defines the gamepad info as received from the controller APIs.
  99071. * @returns the new gamepad instance
  99072. */
  99073. create(gamepadInfo: any): Gamepad;
  99074. }
  99075. /**
  99076. * Defines the PoseEnabledControllerHelper object that is used initialize a gamepad as the controller type it is specified as (eg. windows mixed reality controller)
  99077. */
  99078. export class PoseEnabledControllerHelper {
  99079. /** @hidden */
  99080. static _ControllerFactories: _GamePadFactory[];
  99081. /** @hidden */
  99082. static _DefaultControllerFactory: Nullable<(gamepadInfo: any) => Gamepad>;
  99083. /**
  99084. * Initializes a gamepad as the controller type it is specified as (eg. windows mixed reality controller)
  99085. * @param vrGamepad the gamepad to initialized
  99086. * @returns a vr controller of the type the gamepad identified as
  99087. */
  99088. static InitiateController(vrGamepad: any): Gamepad;
  99089. }
  99090. /**
  99091. * Defines the PoseEnabledController object that contains state of a vr capable controller
  99092. */
  99093. export class PoseEnabledController extends Gamepad implements PoseControlled {
  99094. /**
  99095. * If the controller is used in a webXR session
  99096. */
  99097. isXR: boolean;
  99098. private _deviceRoomPosition;
  99099. private _deviceRoomRotationQuaternion;
  99100. /**
  99101. * The device position in babylon space
  99102. */
  99103. devicePosition: Vector3;
  99104. /**
  99105. * The device rotation in babylon space
  99106. */
  99107. deviceRotationQuaternion: Quaternion;
  99108. /**
  99109. * The scale factor of the device in babylon space
  99110. */
  99111. deviceScaleFactor: number;
  99112. /**
  99113. * (Likely devicePosition should be used instead) The device position in its room space
  99114. */
  99115. position: Vector3;
  99116. /**
  99117. * (Likely deviceRotationQuaternion should be used instead) The device rotation in its room space
  99118. */
  99119. rotationQuaternion: Quaternion;
  99120. /**
  99121. * The type of controller (Eg. Windows mixed reality)
  99122. */
  99123. controllerType: PoseEnabledControllerType;
  99124. protected _calculatedPosition: Vector3;
  99125. private _calculatedRotation;
  99126. /**
  99127. * The raw pose from the device
  99128. */
  99129. rawPose: DevicePose;
  99130. private _trackPosition;
  99131. private _maxRotationDistFromHeadset;
  99132. private _draggedRoomRotation;
  99133. /**
  99134. * @hidden
  99135. */
  99136. _disableTrackPosition(fixedPosition: Vector3): void;
  99137. /**
  99138. * Internal, the mesh attached to the controller
  99139. * @hidden
  99140. */
  99141. _mesh: Nullable<AbstractMesh>;
  99142. private _poseControlledCamera;
  99143. private _leftHandSystemQuaternion;
  99144. /**
  99145. * Internal, matrix used to convert room space to babylon space
  99146. * @hidden
  99147. */
  99148. _deviceToWorld: Matrix;
  99149. /**
  99150. * Node to be used when casting a ray from the controller
  99151. * @hidden
  99152. */
  99153. _pointingPoseNode: Nullable<TransformNode>;
  99154. /**
  99155. * Name of the child mesh that can be used to cast a ray from the controller
  99156. */
  99157. static readonly POINTING_POSE: string;
  99158. /**
  99159. * Creates a new PoseEnabledController from a gamepad
  99160. * @param browserGamepad the gamepad that the PoseEnabledController should be created from
  99161. */
  99162. constructor(browserGamepad: any);
  99163. private _workingMatrix;
  99164. /**
  99165. * Updates the state of the pose enbaled controller and mesh based on the current position and rotation of the controller
  99166. */
  99167. update(): void;
  99168. /**
  99169. * Updates only the pose device and mesh without doing any button event checking
  99170. */
  99171. protected _updatePoseAndMesh(): void;
  99172. /**
  99173. * Updates the state of the pose enbaled controller based on the raw pose data from the device
  99174. * @param poseData raw pose fromthe device
  99175. */
  99176. updateFromDevice(poseData: DevicePose): void;
  99177. /**
  99178. * @hidden
  99179. */
  99180. _meshAttachedObservable: Observable<AbstractMesh>;
  99181. /**
  99182. * Attaches a mesh to the controller
  99183. * @param mesh the mesh to be attached
  99184. */
  99185. attachToMesh(mesh: AbstractMesh): void;
  99186. /**
  99187. * Attaches the controllers mesh to a camera
  99188. * @param camera the camera the mesh should be attached to
  99189. */
  99190. attachToPoseControlledCamera(camera: TargetCamera): void;
  99191. /**
  99192. * Disposes of the controller
  99193. */
  99194. dispose(): void;
  99195. /**
  99196. * The mesh that is attached to the controller
  99197. */
  99198. get mesh(): Nullable<AbstractMesh>;
  99199. /**
  99200. * Gets the ray of the controller in the direction the controller is pointing
  99201. * @param length the length the resulting ray should be
  99202. * @returns a ray in the direction the controller is pointing
  99203. */
  99204. getForwardRay(length?: number): Ray;
  99205. }
  99206. }
  99207. declare module BABYLON {
  99208. /**
  99209. * Defines the WebVRController object that represents controllers tracked in 3D space
  99210. */
  99211. export abstract class WebVRController extends PoseEnabledController {
  99212. /**
  99213. * Internal, the default controller model for the controller
  99214. */
  99215. protected _defaultModel: Nullable<AbstractMesh>;
  99216. /**
  99217. * Fired when the trigger state has changed
  99218. */
  99219. onTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  99220. /**
  99221. * Fired when the main button state has changed
  99222. */
  99223. onMainButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  99224. /**
  99225. * Fired when the secondary button state has changed
  99226. */
  99227. onSecondaryButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  99228. /**
  99229. * Fired when the pad state has changed
  99230. */
  99231. onPadStateChangedObservable: Observable<ExtendedGamepadButton>;
  99232. /**
  99233. * Fired when controllers stick values have changed
  99234. */
  99235. onPadValuesChangedObservable: Observable<StickValues>;
  99236. /**
  99237. * Array of button availible on the controller
  99238. */
  99239. protected _buttons: Array<MutableGamepadButton>;
  99240. private _onButtonStateChange;
  99241. /**
  99242. * Fired when a controller button's state has changed
  99243. * @param callback the callback containing the button that was modified
  99244. */
  99245. onButtonStateChange(callback: (controlledIndex: number, buttonIndex: number, state: ExtendedGamepadButton) => void): void;
  99246. /**
  99247. * X and Y axis corresponding to the controllers joystick
  99248. */
  99249. pad: StickValues;
  99250. /**
  99251. * 'left' or 'right', see https://w3c.github.io/gamepad/extensions.html#gamepadhand-enum
  99252. */
  99253. hand: string;
  99254. /**
  99255. * The default controller model for the controller
  99256. */
  99257. get defaultModel(): Nullable<AbstractMesh>;
  99258. /**
  99259. * Creates a new WebVRController from a gamepad
  99260. * @param vrGamepad the gamepad that the WebVRController should be created from
  99261. */
  99262. constructor(vrGamepad: any);
  99263. /**
  99264. * Updates the state of the controller and mesh based on the current position and rotation of the controller
  99265. */
  99266. update(): void;
  99267. /**
  99268. * Function to be called when a button is modified
  99269. */
  99270. protected abstract _handleButtonChange(buttonIdx: number, value: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  99271. /**
  99272. * Loads a mesh and attaches it to the controller
  99273. * @param scene the scene the mesh should be added to
  99274. * @param meshLoaded callback for when the mesh has been loaded
  99275. */
  99276. abstract initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  99277. private _setButtonValue;
  99278. private _changes;
  99279. private _checkChanges;
  99280. /**
  99281. * Disposes of th webVRCOntroller
  99282. */
  99283. dispose(): void;
  99284. }
  99285. }
  99286. declare module BABYLON {
  99287. /**
  99288. * The HemisphericLight simulates the ambient environment light,
  99289. * so the passed direction is the light reflection direction, not the incoming direction.
  99290. */
  99291. export class HemisphericLight extends Light {
  99292. /**
  99293. * The groundColor is the light in the opposite direction to the one specified during creation.
  99294. * 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.
  99295. */
  99296. groundColor: Color3;
  99297. /**
  99298. * The light reflection direction, not the incoming direction.
  99299. */
  99300. direction: Vector3;
  99301. /**
  99302. * Creates a HemisphericLight object in the scene according to the passed direction (Vector3).
  99303. * The HemisphericLight simulates the ambient environment light, so the passed direction is the light reflection direction, not the incoming direction.
  99304. * The HemisphericLight can't cast shadows.
  99305. * Documentation : https://doc.babylonjs.com/babylon101/lights
  99306. * @param name The friendly name of the light
  99307. * @param direction The direction of the light reflection
  99308. * @param scene The scene the light belongs to
  99309. */
  99310. constructor(name: string, direction: Vector3, scene: Scene);
  99311. protected _buildUniformLayout(): void;
  99312. /**
  99313. * Returns the string "HemisphericLight".
  99314. * @return The class name
  99315. */
  99316. getClassName(): string;
  99317. /**
  99318. * Sets the HemisphericLight direction towards the passed target (Vector3).
  99319. * Returns the updated direction.
  99320. * @param target The target the direction should point to
  99321. * @return The computed direction
  99322. */
  99323. setDirectionToTarget(target: Vector3): Vector3;
  99324. /**
  99325. * Returns the shadow generator associated to the light.
  99326. * @returns Always null for hemispheric lights because it does not support shadows.
  99327. */
  99328. getShadowGenerator(): Nullable<IShadowGenerator>;
  99329. /**
  99330. * Sets the passed Effect object with the HemisphericLight normalized direction and color and the passed name (string).
  99331. * @param effect The effect to update
  99332. * @param lightIndex The index of the light in the effect to update
  99333. * @returns The hemispheric light
  99334. */
  99335. transferToEffect(effect: Effect, lightIndex: string): HemisphericLight;
  99336. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): this;
  99337. /**
  99338. * Computes the world matrix of the node
  99339. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  99340. * @param useWasUpdatedFlag defines a reserved property
  99341. * @returns the world matrix
  99342. */
  99343. computeWorldMatrix(): Matrix;
  99344. /**
  99345. * Returns the integer 3.
  99346. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  99347. */
  99348. getTypeID(): number;
  99349. /**
  99350. * Prepares the list of defines specific to the light type.
  99351. * @param defines the list of defines
  99352. * @param lightIndex defines the index of the light for the effect
  99353. */
  99354. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  99355. }
  99356. }
  99357. declare module BABYLON {
  99358. /** @hidden */
  99359. export var vrMultiviewToSingleviewPixelShader: {
  99360. name: string;
  99361. shader: string;
  99362. };
  99363. }
  99364. declare module BABYLON {
  99365. /**
  99366. * Renders to multiple views with a single draw call
  99367. * @see https://www.khronos.org/registry/webgl/extensions/WEBGL_multiview/
  99368. */
  99369. export class MultiviewRenderTarget extends RenderTargetTexture {
  99370. /**
  99371. * Creates a multiview render target
  99372. * @param scene scene used with the render target
  99373. * @param size the size of the render target (used for each view)
  99374. */
  99375. constructor(scene: Scene, size?: number | {
  99376. width: number;
  99377. height: number;
  99378. } | {
  99379. ratio: number;
  99380. });
  99381. /**
  99382. * @hidden
  99383. * @param faceIndex the face index, if its a cube texture
  99384. */
  99385. _bindFrameBuffer(faceIndex?: number): void;
  99386. /**
  99387. * Gets the number of views the corresponding to the texture (eg. a MultiviewRenderTarget will have > 1)
  99388. * @returns the view count
  99389. */
  99390. getViewCount(): number;
  99391. }
  99392. }
  99393. declare module BABYLON {
  99394. interface Engine {
  99395. /**
  99396. * Creates a new multiview render target
  99397. * @param width defines the width of the texture
  99398. * @param height defines the height of the texture
  99399. * @returns the created multiview texture
  99400. */
  99401. createMultiviewRenderTargetTexture(width: number, height: number): InternalTexture;
  99402. /**
  99403. * Binds a multiview framebuffer to be drawn to
  99404. * @param multiviewTexture texture to bind
  99405. */
  99406. bindMultiviewFramebuffer(multiviewTexture: InternalTexture): void;
  99407. }
  99408. interface Camera {
  99409. /**
  99410. * @hidden
  99411. * 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)
  99412. */
  99413. _useMultiviewToSingleView: boolean;
  99414. /**
  99415. * @hidden
  99416. * 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)
  99417. */
  99418. _multiviewTexture: Nullable<RenderTargetTexture>;
  99419. /**
  99420. * @hidden
  99421. * ensures the multiview texture of the camera exists and has the specified width/height
  99422. * @param width height to set on the multiview texture
  99423. * @param height width to set on the multiview texture
  99424. */
  99425. _resizeOrCreateMultiviewTexture(width: number, height: number): void;
  99426. }
  99427. interface Scene {
  99428. /** @hidden */
  99429. _transformMatrixR: Matrix;
  99430. /** @hidden */
  99431. _multiviewSceneUbo: Nullable<UniformBuffer>;
  99432. /** @hidden */
  99433. _createMultiviewUbo(): void;
  99434. /** @hidden */
  99435. _updateMultiviewUbo(viewR?: Matrix, projectionR?: Matrix): void;
  99436. /** @hidden */
  99437. _renderMultiviewToSingleView(camera: Camera): void;
  99438. }
  99439. }
  99440. declare module BABYLON {
  99441. /**
  99442. * VRMultiviewToSingleview used to convert multiview texture arrays to standard textures for scenarios such as webVR
  99443. * This will not be used for webXR as it supports displaying texture arrays directly
  99444. */
  99445. export class VRMultiviewToSingleviewPostProcess extends PostProcess {
  99446. /**
  99447. * Gets a string identifying the name of the class
  99448. * @returns "VRMultiviewToSingleviewPostProcess" string
  99449. */
  99450. getClassName(): string;
  99451. /**
  99452. * Initializes a VRMultiviewToSingleview
  99453. * @param name name of the post process
  99454. * @param camera camera to be applied to
  99455. * @param scaleFactor scaling factor to the size of the output texture
  99456. */
  99457. constructor(name: string, camera: Camera, scaleFactor: number);
  99458. }
  99459. }
  99460. declare module BABYLON {
  99461. /**
  99462. * Interface used to define additional presentation attributes
  99463. */
  99464. export interface IVRPresentationAttributes {
  99465. /**
  99466. * Defines a boolean indicating that we want to get 72hz mode on Oculus Browser (default is off eg. 60hz)
  99467. */
  99468. highRefreshRate: boolean;
  99469. /**
  99470. * Enables foveation in VR to improve perf. 0 none, 1 low, 2 medium, 3 high (Default is 1)
  99471. */
  99472. foveationLevel: number;
  99473. }
  99474. interface Engine {
  99475. /** @hidden */
  99476. _vrDisplay: any;
  99477. /** @hidden */
  99478. _vrSupported: boolean;
  99479. /** @hidden */
  99480. _oldSize: Size;
  99481. /** @hidden */
  99482. _oldHardwareScaleFactor: number;
  99483. /** @hidden */
  99484. _vrExclusivePointerMode: boolean;
  99485. /** @hidden */
  99486. _webVRInitPromise: Promise<IDisplayChangedEventArgs>;
  99487. /** @hidden */
  99488. _onVRDisplayPointerRestricted: () => void;
  99489. /** @hidden */
  99490. _onVRDisplayPointerUnrestricted: () => void;
  99491. /** @hidden */
  99492. _onVrDisplayConnect: Nullable<(display: any) => void>;
  99493. /** @hidden */
  99494. _onVrDisplayDisconnect: Nullable<() => void>;
  99495. /** @hidden */
  99496. _onVrDisplayPresentChange: Nullable<() => void>;
  99497. /**
  99498. * Observable signaled when VR display mode changes
  99499. */
  99500. onVRDisplayChangedObservable: Observable<IDisplayChangedEventArgs>;
  99501. /**
  99502. * Observable signaled when VR request present is complete
  99503. */
  99504. onVRRequestPresentComplete: Observable<boolean>;
  99505. /**
  99506. * Observable signaled when VR request present starts
  99507. */
  99508. onVRRequestPresentStart: Observable<Engine>;
  99509. /**
  99510. * Gets a boolean indicating that the engine is currently in VR exclusive mode for the pointers
  99511. * @see https://docs.microsoft.com/en-us/microsoft-edge/webvr/essentials#mouse-input
  99512. */
  99513. isInVRExclusivePointerMode: boolean;
  99514. /**
  99515. * Gets a boolean indicating if a webVR device was detected
  99516. * @returns true if a webVR device was detected
  99517. */
  99518. isVRDevicePresent(): boolean;
  99519. /**
  99520. * Gets the current webVR device
  99521. * @returns the current webVR device (or null)
  99522. */
  99523. getVRDevice(): any;
  99524. /**
  99525. * Initializes a webVR display and starts listening to display change events
  99526. * The onVRDisplayChangedObservable will be notified upon these changes
  99527. * @returns A promise containing a VRDisplay and if vr is supported
  99528. */
  99529. initWebVRAsync(): Promise<IDisplayChangedEventArgs>;
  99530. /** @hidden */
  99531. _getVRDisplaysAsync(): Promise<IDisplayChangedEventArgs>;
  99532. /**
  99533. * Gets or sets the presentation attributes used to configure VR rendering
  99534. */
  99535. vrPresentationAttributes?: IVRPresentationAttributes;
  99536. /**
  99537. * Call this function to switch to webVR mode
  99538. * Will do nothing if webVR is not supported or if there is no webVR device
  99539. * @param options the webvr options provided to the camera. mainly used for multiview
  99540. * @see https://doc.babylonjs.com/how_to/webvr_camera
  99541. */
  99542. enableVR(options: WebVROptions): void;
  99543. /** @hidden */
  99544. _onVRFullScreenTriggered(): void;
  99545. }
  99546. }
  99547. declare module BABYLON {
  99548. /**
  99549. * This is a copy of VRPose. See https://developer.mozilla.org/en-US/docs/Web/API/VRPose
  99550. * IMPORTANT!! The data is right-hand data.
  99551. * @export
  99552. * @interface DevicePose
  99553. */
  99554. export interface DevicePose {
  99555. /**
  99556. * The position of the device, values in array are [x,y,z].
  99557. */
  99558. readonly position: Nullable<Float32Array>;
  99559. /**
  99560. * The linearVelocity of the device, values in array are [x,y,z].
  99561. */
  99562. readonly linearVelocity: Nullable<Float32Array>;
  99563. /**
  99564. * The linearAcceleration of the device, values in array are [x,y,z].
  99565. */
  99566. readonly linearAcceleration: Nullable<Float32Array>;
  99567. /**
  99568. * The orientation of the device in a quaternion array, values in array are [x,y,z,w].
  99569. */
  99570. readonly orientation: Nullable<Float32Array>;
  99571. /**
  99572. * The angularVelocity of the device, values in array are [x,y,z].
  99573. */
  99574. readonly angularVelocity: Nullable<Float32Array>;
  99575. /**
  99576. * The angularAcceleration of the device, values in array are [x,y,z].
  99577. */
  99578. readonly angularAcceleration: Nullable<Float32Array>;
  99579. }
  99580. /**
  99581. * Interface representing a pose controlled object in Babylon.
  99582. * A pose controlled object has both regular pose values as well as pose values
  99583. * from an external device such as a VR head mounted display
  99584. */
  99585. export interface PoseControlled {
  99586. /**
  99587. * The position of the object in babylon space.
  99588. */
  99589. position: Vector3;
  99590. /**
  99591. * The rotation quaternion of the object in babylon space.
  99592. */
  99593. rotationQuaternion: Quaternion;
  99594. /**
  99595. * The position of the device in babylon space.
  99596. */
  99597. devicePosition?: Vector3;
  99598. /**
  99599. * The rotation quaternion of the device in babylon space.
  99600. */
  99601. deviceRotationQuaternion: Quaternion;
  99602. /**
  99603. * The raw pose coming from the device.
  99604. */
  99605. rawPose: Nullable<DevicePose>;
  99606. /**
  99607. * The scale of the device to be used when translating from device space to babylon space.
  99608. */
  99609. deviceScaleFactor: number;
  99610. /**
  99611. * Updates the poseControlled values based on the input device pose.
  99612. * @param poseData the pose data to update the object with
  99613. */
  99614. updateFromDevice(poseData: DevicePose): void;
  99615. }
  99616. /**
  99617. * Set of options to customize the webVRCamera
  99618. */
  99619. export interface WebVROptions {
  99620. /**
  99621. * Sets if the webVR camera should be tracked to the vrDevice. (default: true)
  99622. */
  99623. trackPosition?: boolean;
  99624. /**
  99625. * Sets the scale of the vrDevice in babylon space. (default: 1)
  99626. */
  99627. positionScale?: number;
  99628. /**
  99629. * If there are more than one VRDisplays, this will choose the display matching this name. (default: pick first vrDisplay)
  99630. */
  99631. displayName?: string;
  99632. /**
  99633. * Should the native controller meshes be initialized. (default: true)
  99634. */
  99635. controllerMeshes?: boolean;
  99636. /**
  99637. * Creating a default HemiLight only on controllers. (default: true)
  99638. */
  99639. defaultLightingOnControllers?: boolean;
  99640. /**
  99641. * If you don't want to use the default VR button of the helper. (default: false)
  99642. */
  99643. useCustomVRButton?: boolean;
  99644. /**
  99645. * If you'd like to provide your own button to the VRHelper. (default: standard babylon vr button)
  99646. */
  99647. customVRButton?: HTMLButtonElement;
  99648. /**
  99649. * To change the length of the ray for gaze/controllers. Will be scaled by positionScale. (default: 100)
  99650. */
  99651. rayLength?: number;
  99652. /**
  99653. * To change the default offset from the ground to account for user's height in meters. Will be scaled by positionScale. (default: 1.7)
  99654. */
  99655. defaultHeight?: number;
  99656. /**
  99657. * If multiview should be used if availible (default: false)
  99658. */
  99659. useMultiview?: boolean;
  99660. }
  99661. /**
  99662. * This represents a WebVR camera.
  99663. * The WebVR camera is Babylon's simple interface to interaction with Windows Mixed Reality, HTC Vive and Oculus Rift.
  99664. * @example https://doc.babylonjs.com/how_to/webvr_camera
  99665. */
  99666. export class WebVRFreeCamera extends FreeCamera implements PoseControlled {
  99667. private webVROptions;
  99668. /**
  99669. * @hidden
  99670. * The vrDisplay tied to the camera. See https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay
  99671. */
  99672. _vrDevice: any;
  99673. /**
  99674. * The rawPose of the vrDevice.
  99675. */
  99676. rawPose: Nullable<DevicePose>;
  99677. private _onVREnabled;
  99678. private _specsVersion;
  99679. private _attached;
  99680. private _frameData;
  99681. protected _descendants: Array<Node>;
  99682. private _deviceRoomPosition;
  99683. /** @hidden */
  99684. _deviceRoomRotationQuaternion: Quaternion;
  99685. private _standingMatrix;
  99686. /**
  99687. * Represents device position in babylon space.
  99688. */
  99689. devicePosition: Vector3;
  99690. /**
  99691. * Represents device rotation in babylon space.
  99692. */
  99693. deviceRotationQuaternion: Quaternion;
  99694. /**
  99695. * The scale of the device to be used when translating from device space to babylon space.
  99696. */
  99697. deviceScaleFactor: number;
  99698. private _deviceToWorld;
  99699. private _worldToDevice;
  99700. /**
  99701. * References to the webVR controllers for the vrDevice.
  99702. */
  99703. controllers: Array<WebVRController>;
  99704. /**
  99705. * Emits an event when a controller is attached.
  99706. */
  99707. onControllersAttachedObservable: Observable<WebVRController[]>;
  99708. /**
  99709. * Emits an event when a controller's mesh has been loaded;
  99710. */
  99711. onControllerMeshLoadedObservable: Observable<WebVRController>;
  99712. /**
  99713. * Emits an event when the HMD's pose has been updated.
  99714. */
  99715. onPoseUpdatedFromDeviceObservable: Observable<any>;
  99716. private _poseSet;
  99717. /**
  99718. * If the rig cameras be used as parent instead of this camera.
  99719. */
  99720. rigParenting: boolean;
  99721. private _lightOnControllers;
  99722. private _defaultHeight?;
  99723. /**
  99724. * Instantiates a WebVRFreeCamera.
  99725. * @param name The name of the WebVRFreeCamera
  99726. * @param position The starting anchor position for the camera
  99727. * @param scene The scene the camera belongs to
  99728. * @param webVROptions a set of customizable options for the webVRCamera
  99729. */
  99730. constructor(name: string, position: Vector3, scene: Scene, webVROptions?: WebVROptions);
  99731. /**
  99732. * Gets the device distance from the ground in meters.
  99733. * @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.
  99734. */
  99735. deviceDistanceToRoomGround(): number;
  99736. /**
  99737. * Enables the standing matrix when supported. This can be used to position the user's view the correct height from the ground.
  99738. * @param callback will be called when the standing matrix is set. Callback parameter is if the standing matrix is supported.
  99739. */
  99740. useStandingMatrix(callback?: (bool: boolean) => void): void;
  99741. /**
  99742. * Enables the standing matrix when supported. This can be used to position the user's view the correct height from the ground.
  99743. * @returns A promise with a boolean set to if the standing matrix is supported.
  99744. */
  99745. useStandingMatrixAsync(): Promise<boolean>;
  99746. /**
  99747. * Disposes the camera
  99748. */
  99749. dispose(): void;
  99750. /**
  99751. * Gets a vrController by name.
  99752. * @param name The name of the controller to retreive
  99753. * @returns the controller matching the name specified or null if not found
  99754. */
  99755. getControllerByName(name: string): Nullable<WebVRController>;
  99756. private _leftController;
  99757. /**
  99758. * The controller corresponding to the users left hand.
  99759. */
  99760. get leftController(): Nullable<WebVRController>;
  99761. private _rightController;
  99762. /**
  99763. * The controller corresponding to the users right hand.
  99764. */
  99765. get rightController(): Nullable<WebVRController>;
  99766. /**
  99767. * Casts a ray forward from the vrCamera's gaze.
  99768. * @param length Length of the ray (default: 100)
  99769. * @returns the ray corresponding to the gaze
  99770. */
  99771. getForwardRay(length?: number): Ray;
  99772. /**
  99773. * @hidden
  99774. * Updates the camera based on device's frame data
  99775. */
  99776. _checkInputs(): void;
  99777. /**
  99778. * Updates the poseControlled values based on the input device pose.
  99779. * @param poseData Pose coming from the device
  99780. */
  99781. updateFromDevice(poseData: DevicePose): void;
  99782. private _htmlElementAttached;
  99783. private _detachIfAttached;
  99784. /**
  99785. * WebVR's attach control will start broadcasting frames to the device.
  99786. * Note that in certain browsers (chrome for example) this function must be called
  99787. * within a user-interaction callback. Example:
  99788. * <pre> scene.onPointerDown = function() { camera.attachControl(canvas); }</pre>
  99789. *
  99790. * @param element html element to attach the vrDevice to
  99791. * @param noPreventDefault prevent the default html element operation when attaching the vrDevice
  99792. */
  99793. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  99794. /**
  99795. * Detaches the camera from the html element and disables VR
  99796. *
  99797. * @param element html element to detach from
  99798. */
  99799. detachControl(element: HTMLElement): void;
  99800. /**
  99801. * @returns the name of this class
  99802. */
  99803. getClassName(): string;
  99804. /**
  99805. * Calls resetPose on the vrDisplay
  99806. * See: https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay/resetPose
  99807. */
  99808. resetToCurrentRotation(): void;
  99809. /**
  99810. * @hidden
  99811. * Updates the rig cameras (left and right eye)
  99812. */
  99813. _updateRigCameras(): void;
  99814. private _workingVector;
  99815. private _oneVector;
  99816. private _workingMatrix;
  99817. private updateCacheCalled;
  99818. private _correctPositionIfNotTrackPosition;
  99819. /**
  99820. * @hidden
  99821. * Updates the cached values of the camera
  99822. * @param ignoreParentClass ignores updating the parent class's cache (default: false)
  99823. */
  99824. _updateCache(ignoreParentClass?: boolean): void;
  99825. /**
  99826. * @hidden
  99827. * Get current device position in babylon world
  99828. */
  99829. _computeDevicePosition(): void;
  99830. /**
  99831. * Updates the current device position and rotation in the babylon world
  99832. */
  99833. update(): void;
  99834. /**
  99835. * @hidden
  99836. * Gets the view matrix of this camera (Always set to identity as left and right eye cameras contain the actual view matrix)
  99837. * @returns an identity matrix
  99838. */
  99839. _getViewMatrix(): Matrix;
  99840. private _tmpMatrix;
  99841. /**
  99842. * This function is called by the two RIG cameras.
  99843. * 'this' is the left or right camera (and NOT (!!!) the WebVRFreeCamera instance)
  99844. * @hidden
  99845. */
  99846. _getWebVRViewMatrix(): Matrix;
  99847. /** @hidden */
  99848. _getWebVRProjectionMatrix(): Matrix;
  99849. private _onGamepadConnectedObserver;
  99850. private _onGamepadDisconnectedObserver;
  99851. private _updateCacheWhenTrackingDisabledObserver;
  99852. /**
  99853. * Initializes the controllers and their meshes
  99854. */
  99855. initControllers(): void;
  99856. }
  99857. }
  99858. declare module BABYLON {
  99859. /**
  99860. * "Static Class" containing the most commonly used helper while dealing with material for rendering purpose.
  99861. *
  99862. * It contains the basic tools to help defining defines, binding uniform for the common part of the materials.
  99863. *
  99864. * This works by convention in BabylonJS but is meant to be use only with shader following the in place naming rules and conventions.
  99865. */
  99866. export class MaterialHelper {
  99867. /**
  99868. * Bind the current view position to an effect.
  99869. * @param effect The effect to be bound
  99870. * @param scene The scene the eyes position is used from
  99871. * @param variableName name of the shader variable that will hold the eye position
  99872. */
  99873. static BindEyePosition(effect: Effect, scene: Scene, variableName?: string): void;
  99874. /**
  99875. * Helps preparing the defines values about the UVs in used in the effect.
  99876. * UVs are shared as much as we can accross channels in the shaders.
  99877. * @param texture The texture we are preparing the UVs for
  99878. * @param defines The defines to update
  99879. * @param key The channel key "diffuse", "specular"... used in the shader
  99880. */
  99881. static PrepareDefinesForMergedUV(texture: BaseTexture, defines: any, key: string): void;
  99882. /**
  99883. * Binds a texture matrix value to its corrsponding uniform
  99884. * @param texture The texture to bind the matrix for
  99885. * @param uniformBuffer The uniform buffer receivin the data
  99886. * @param key The channel key "diffuse", "specular"... used in the shader
  99887. */
  99888. static BindTextureMatrix(texture: BaseTexture, uniformBuffer: UniformBuffer, key: string): void;
  99889. /**
  99890. * Gets the current status of the fog (should it be enabled?)
  99891. * @param mesh defines the mesh to evaluate for fog support
  99892. * @param scene defines the hosting scene
  99893. * @returns true if fog must be enabled
  99894. */
  99895. static GetFogState(mesh: AbstractMesh, scene: Scene): boolean;
  99896. /**
  99897. * Helper used to prepare the list of defines associated with misc. values for shader compilation
  99898. * @param mesh defines the current mesh
  99899. * @param scene defines the current scene
  99900. * @param useLogarithmicDepth defines if logarithmic depth has to be turned on
  99901. * @param pointsCloud defines if point cloud rendering has to be turned on
  99902. * @param fogEnabled defines if fog has to be turned on
  99903. * @param alphaTest defines if alpha testing has to be turned on
  99904. * @param defines defines the current list of defines
  99905. */
  99906. static PrepareDefinesForMisc(mesh: AbstractMesh, scene: Scene, useLogarithmicDepth: boolean, pointsCloud: boolean, fogEnabled: boolean, alphaTest: boolean, defines: any): void;
  99907. /**
  99908. * Helper used to prepare the list of defines associated with frame values for shader compilation
  99909. * @param scene defines the current scene
  99910. * @param engine defines the current engine
  99911. * @param defines specifies the list of active defines
  99912. * @param useInstances defines if instances have to be turned on
  99913. * @param useClipPlane defines if clip plane have to be turned on
  99914. * @param useInstances defines if instances have to be turned on
  99915. * @param useThinInstances defines if thin instances have to be turned on
  99916. */
  99917. static PrepareDefinesForFrameBoundValues(scene: Scene, engine: Engine, defines: any, useInstances: boolean, useClipPlane?: Nullable<boolean>, useThinInstances?: boolean): void;
  99918. /**
  99919. * Prepares the defines for bones
  99920. * @param mesh The mesh containing the geometry data we will draw
  99921. * @param defines The defines to update
  99922. */
  99923. static PrepareDefinesForBones(mesh: AbstractMesh, defines: any): void;
  99924. /**
  99925. * Prepares the defines for morph targets
  99926. * @param mesh The mesh containing the geometry data we will draw
  99927. * @param defines The defines to update
  99928. */
  99929. static PrepareDefinesForMorphTargets(mesh: AbstractMesh, defines: any): void;
  99930. /**
  99931. * Prepares the defines used in the shader depending on the attributes data available in the mesh
  99932. * @param mesh The mesh containing the geometry data we will draw
  99933. * @param defines The defines to update
  99934. * @param useVertexColor Precise whether vertex colors should be used or not (override mesh info)
  99935. * @param useBones Precise whether bones should be used or not (override mesh info)
  99936. * @param useMorphTargets Precise whether morph targets should be used or not (override mesh info)
  99937. * @param useVertexAlpha Precise whether vertex alpha should be used or not (override mesh info)
  99938. * @returns false if defines are considered not dirty and have not been checked
  99939. */
  99940. static PrepareDefinesForAttributes(mesh: AbstractMesh, defines: any, useVertexColor: boolean, useBones: boolean, useMorphTargets?: boolean, useVertexAlpha?: boolean): boolean;
  99941. /**
  99942. * Prepares the defines related to multiview
  99943. * @param scene The scene we are intending to draw
  99944. * @param defines The defines to update
  99945. */
  99946. static PrepareDefinesForMultiview(scene: Scene, defines: any): void;
  99947. /**
  99948. * Prepares the defines related to the prepass
  99949. * @param scene The scene we are intending to draw
  99950. * @param defines The defines to update
  99951. * @param canRenderToMRT Indicates if this material renders to several textures in the prepass
  99952. */
  99953. static PrepareDefinesForPrePass(scene: Scene, defines: any, canRenderToMRT: boolean): void;
  99954. /**
  99955. * Prepares the defines related to the light information passed in parameter
  99956. * @param scene The scene we are intending to draw
  99957. * @param mesh The mesh the effect is compiling for
  99958. * @param light The light the effect is compiling for
  99959. * @param lightIndex The index of the light
  99960. * @param defines The defines to update
  99961. * @param specularSupported Specifies whether specular is supported or not (override lights data)
  99962. * @param state Defines the current state regarding what is needed (normals, etc...)
  99963. */
  99964. static PrepareDefinesForLight(scene: Scene, mesh: AbstractMesh, light: Light, lightIndex: number, defines: any, specularSupported: boolean, state: {
  99965. needNormals: boolean;
  99966. needRebuild: boolean;
  99967. shadowEnabled: boolean;
  99968. specularEnabled: boolean;
  99969. lightmapMode: boolean;
  99970. }): void;
  99971. /**
  99972. * Prepares the defines related to the light information passed in parameter
  99973. * @param scene The scene we are intending to draw
  99974. * @param mesh The mesh the effect is compiling for
  99975. * @param defines The defines to update
  99976. * @param specularSupported Specifies whether specular is supported or not (override lights data)
  99977. * @param maxSimultaneousLights Specfies how manuy lights can be added to the effect at max
  99978. * @param disableLighting Specifies whether the lighting is disabled (override scene and light)
  99979. * @returns true if normals will be required for the rest of the effect
  99980. */
  99981. static PrepareDefinesForLights(scene: Scene, mesh: AbstractMesh, defines: any, specularSupported: boolean, maxSimultaneousLights?: number, disableLighting?: boolean): boolean;
  99982. /**
  99983. * Prepares the uniforms and samplers list to be used in the effect (for a specific light)
  99984. * @param lightIndex defines the light index
  99985. * @param uniformsList The uniform list
  99986. * @param samplersList The sampler list
  99987. * @param projectedLightTexture defines if projected texture must be used
  99988. * @param uniformBuffersList defines an optional list of uniform buffers
  99989. */
  99990. static PrepareUniformsAndSamplersForLight(lightIndex: number, uniformsList: string[], samplersList: string[], projectedLightTexture?: any, uniformBuffersList?: Nullable<string[]>): void;
  99991. /**
  99992. * Prepares the uniforms and samplers list to be used in the effect
  99993. * @param uniformsListOrOptions The uniform names to prepare or an EffectCreationOptions containing the liist and extra information
  99994. * @param samplersList The sampler list
  99995. * @param defines The defines helping in the list generation
  99996. * @param maxSimultaneousLights The maximum number of simultanous light allowed in the effect
  99997. */
  99998. static PrepareUniformsAndSamplersList(uniformsListOrOptions: string[] | IEffectCreationOptions, samplersList?: string[], defines?: any, maxSimultaneousLights?: number): void;
  99999. /**
  100000. * This helps decreasing rank by rank the shadow quality (0 being the highest rank and quality)
  100001. * @param defines The defines to update while falling back
  100002. * @param fallbacks The authorized effect fallbacks
  100003. * @param maxSimultaneousLights The maximum number of lights allowed
  100004. * @param rank the current rank of the Effect
  100005. * @returns The newly affected rank
  100006. */
  100007. static HandleFallbacksForShadows(defines: any, fallbacks: EffectFallbacks, maxSimultaneousLights?: number, rank?: number): number;
  100008. private static _TmpMorphInfluencers;
  100009. /**
  100010. * Prepares the list of attributes required for morph targets according to the effect defines.
  100011. * @param attribs The current list of supported attribs
  100012. * @param mesh The mesh to prepare the morph targets attributes for
  100013. * @param influencers The number of influencers
  100014. */
  100015. static PrepareAttributesForMorphTargetsInfluencers(attribs: string[], mesh: AbstractMesh, influencers: number): void;
  100016. /**
  100017. * Prepares the list of attributes required for morph targets according to the effect defines.
  100018. * @param attribs The current list of supported attribs
  100019. * @param mesh The mesh to prepare the morph targets attributes for
  100020. * @param defines The current Defines of the effect
  100021. */
  100022. static PrepareAttributesForMorphTargets(attribs: string[], mesh: AbstractMesh, defines: any): void;
  100023. /**
  100024. * Prepares the list of attributes required for bones according to the effect defines.
  100025. * @param attribs The current list of supported attribs
  100026. * @param mesh The mesh to prepare the bones attributes for
  100027. * @param defines The current Defines of the effect
  100028. * @param fallbacks The current efffect fallback strategy
  100029. */
  100030. static PrepareAttributesForBones(attribs: string[], mesh: AbstractMesh, defines: any, fallbacks: EffectFallbacks): void;
  100031. /**
  100032. * Check and prepare the list of attributes required for instances according to the effect defines.
  100033. * @param attribs The current list of supported attribs
  100034. * @param defines The current MaterialDefines of the effect
  100035. */
  100036. static PrepareAttributesForInstances(attribs: string[], defines: MaterialDefines): void;
  100037. /**
  100038. * Add the list of attributes required for instances to the attribs array.
  100039. * @param attribs The current list of supported attribs
  100040. */
  100041. static PushAttributesForInstances(attribs: string[]): void;
  100042. /**
  100043. * Binds the light information to the effect.
  100044. * @param light The light containing the generator
  100045. * @param effect The effect we are binding the data to
  100046. * @param lightIndex The light index in the effect used to render
  100047. */
  100048. static BindLightProperties(light: Light, effect: Effect, lightIndex: number): void;
  100049. /**
  100050. * Binds the lights information from the scene to the effect for the given mesh.
  100051. * @param light Light to bind
  100052. * @param lightIndex Light index
  100053. * @param scene The scene where the light belongs to
  100054. * @param effect The effect we are binding the data to
  100055. * @param useSpecular Defines if specular is supported
  100056. * @param rebuildInParallel Specifies whether the shader is rebuilding in parallel
  100057. */
  100058. static BindLight(light: Light, lightIndex: number, scene: Scene, effect: Effect, useSpecular: boolean, rebuildInParallel?: boolean): void;
  100059. /**
  100060. * Binds the lights information from the scene to the effect for the given mesh.
  100061. * @param scene The scene the lights belongs to
  100062. * @param mesh The mesh we are binding the information to render
  100063. * @param effect The effect we are binding the data to
  100064. * @param defines The generated defines for the effect
  100065. * @param maxSimultaneousLights The maximum number of light that can be bound to the effect
  100066. * @param rebuildInParallel Specifies whether the shader is rebuilding in parallel
  100067. */
  100068. static BindLights(scene: Scene, mesh: AbstractMesh, effect: Effect, defines: any, maxSimultaneousLights?: number, rebuildInParallel?: boolean): void;
  100069. private static _tempFogColor;
  100070. /**
  100071. * Binds the fog information from the scene to the effect for the given mesh.
  100072. * @param scene The scene the lights belongs to
  100073. * @param mesh The mesh we are binding the information to render
  100074. * @param effect The effect we are binding the data to
  100075. * @param linearSpace Defines if the fog effect is applied in linear space
  100076. */
  100077. static BindFogParameters(scene: Scene, mesh: AbstractMesh, effect: Effect, linearSpace?: boolean): void;
  100078. /**
  100079. * Binds the bones information from the mesh to the effect.
  100080. * @param mesh The mesh we are binding the information to render
  100081. * @param effect The effect we are binding the data to
  100082. */
  100083. static BindBonesParameters(mesh?: AbstractMesh, effect?: Effect): void;
  100084. /**
  100085. * Binds the morph targets information from the mesh to the effect.
  100086. * @param abstractMesh The mesh we are binding the information to render
  100087. * @param effect The effect we are binding the data to
  100088. */
  100089. static BindMorphTargetParameters(abstractMesh: AbstractMesh, effect: Effect): void;
  100090. /**
  100091. * Binds the logarithmic depth information from the scene to the effect for the given defines.
  100092. * @param defines The generated defines used in the effect
  100093. * @param effect The effect we are binding the data to
  100094. * @param scene The scene we are willing to render with logarithmic scale for
  100095. */
  100096. static BindLogDepth(defines: any, effect: Effect, scene: Scene): void;
  100097. /**
  100098. * Binds the clip plane information from the scene to the effect.
  100099. * @param scene The scene the clip plane information are extracted from
  100100. * @param effect The effect we are binding the data to
  100101. */
  100102. static BindClipPlane(effect: Effect, scene: Scene): void;
  100103. }
  100104. }
  100105. declare module BABYLON {
  100106. /**
  100107. * Block used to expose an input value
  100108. */
  100109. export class InputBlock extends NodeMaterialBlock {
  100110. private _mode;
  100111. private _associatedVariableName;
  100112. private _storedValue;
  100113. private _valueCallback;
  100114. private _type;
  100115. private _animationType;
  100116. /** Gets or set a value used to limit the range of float values */
  100117. min: number;
  100118. /** Gets or set a value used to limit the range of float values */
  100119. max: number;
  100120. /** Gets or set a value indicating that this input can only get 0 and 1 values */
  100121. isBoolean: boolean;
  100122. /** Gets or sets a value used by the Node Material editor to determine how to configure the current value if it is a matrix */
  100123. matrixMode: number;
  100124. /** @hidden */
  100125. _systemValue: Nullable<NodeMaterialSystemValues>;
  100126. /** Gets or sets a boolean indicating that this input can be edited in the Inspector (false by default) */
  100127. visibleInInspector: boolean;
  100128. /** Gets or sets a boolean indicating that the value of this input will not change after a build */
  100129. isConstant: boolean;
  100130. /** Gets or sets the group to use to display this block in the Inspector */
  100131. groupInInspector: string;
  100132. /** Gets an observable raised when the value is changed */
  100133. onValueChangedObservable: Observable<InputBlock>;
  100134. /**
  100135. * Gets or sets the connection point type (default is float)
  100136. */
  100137. get type(): NodeMaterialBlockConnectionPointTypes;
  100138. /**
  100139. * Creates a new InputBlock
  100140. * @param name defines the block name
  100141. * @param target defines the target of that block (Vertex by default)
  100142. * @param type defines the type of the input (can be set to NodeMaterialBlockConnectionPointTypes.AutoDetect)
  100143. */
  100144. constructor(name: string, target?: NodeMaterialBlockTargets, type?: NodeMaterialBlockConnectionPointTypes);
  100145. /**
  100146. * Validates if a name is a reserve word.
  100147. * @param newName the new name to be given to the node.
  100148. * @returns false if the name is a reserve word, else true.
  100149. */
  100150. validateBlockName(newName: string): boolean;
  100151. /**
  100152. * Gets the output component
  100153. */
  100154. get output(): NodeMaterialConnectionPoint;
  100155. /**
  100156. * Set the source of this connection point to a vertex attribute
  100157. * @param attributeName defines the attribute name (position, uv, normal, etc...). If not specified it will take the connection point name
  100158. * @returns the current connection point
  100159. */
  100160. setAsAttribute(attributeName?: string): InputBlock;
  100161. /**
  100162. * Set the source of this connection point to a system value
  100163. * @param value define the system value to use (world, view, etc...) or null to switch to manual value
  100164. * @returns the current connection point
  100165. */
  100166. setAsSystemValue(value: Nullable<NodeMaterialSystemValues>): InputBlock;
  100167. /**
  100168. * Gets or sets the value of that point.
  100169. * Please note that this value will be ignored if valueCallback is defined
  100170. */
  100171. get value(): any;
  100172. set value(value: any);
  100173. /**
  100174. * Gets or sets a callback used to get the value of that point.
  100175. * Please note that setting this value will force the connection point to ignore the value property
  100176. */
  100177. get valueCallback(): () => any;
  100178. set valueCallback(value: () => any);
  100179. /**
  100180. * Gets or sets the associated variable name in the shader
  100181. */
  100182. get associatedVariableName(): string;
  100183. set associatedVariableName(value: string);
  100184. /** Gets or sets the type of animation applied to the input */
  100185. get animationType(): AnimatedInputBlockTypes;
  100186. set animationType(value: AnimatedInputBlockTypes);
  100187. /**
  100188. * Gets a boolean indicating that this connection point not defined yet
  100189. */
  100190. get isUndefined(): boolean;
  100191. /**
  100192. * Gets or sets a boolean indicating that this connection point is coming from an uniform.
  100193. * In this case the connection point name must be the name of the uniform to use.
  100194. * Can only be set on inputs
  100195. */
  100196. get isUniform(): boolean;
  100197. set isUniform(value: boolean);
  100198. /**
  100199. * Gets or sets a boolean indicating that this connection point is coming from an attribute.
  100200. * In this case the connection point name must be the name of the attribute to use
  100201. * Can only be set on inputs
  100202. */
  100203. get isAttribute(): boolean;
  100204. set isAttribute(value: boolean);
  100205. /**
  100206. * Gets or sets a boolean indicating that this connection point is generating a varying variable.
  100207. * Can only be set on exit points
  100208. */
  100209. get isVarying(): boolean;
  100210. set isVarying(value: boolean);
  100211. /**
  100212. * Gets a boolean indicating that the current connection point is a system value
  100213. */
  100214. get isSystemValue(): boolean;
  100215. /**
  100216. * Gets or sets the current well known value or null if not defined as a system value
  100217. */
  100218. get systemValue(): Nullable<NodeMaterialSystemValues>;
  100219. set systemValue(value: Nullable<NodeMaterialSystemValues>);
  100220. /**
  100221. * Gets the current class name
  100222. * @returns the class name
  100223. */
  100224. getClassName(): string;
  100225. /**
  100226. * Animate the input if animationType !== None
  100227. * @param scene defines the rendering scene
  100228. */
  100229. animate(scene: Scene): void;
  100230. private _emitDefine;
  100231. initialize(state: NodeMaterialBuildState): void;
  100232. /**
  100233. * Set the input block to its default value (based on its type)
  100234. */
  100235. setDefaultValue(): void;
  100236. private _emitConstant;
  100237. /** @hidden */
  100238. get _noContextSwitch(): boolean;
  100239. private _emit;
  100240. /** @hidden */
  100241. _transmitWorld(effect: Effect, world: Matrix, worldView: Matrix, worldViewProjection: Matrix): void;
  100242. /** @hidden */
  100243. _transmit(effect: Effect, scene: Scene): void;
  100244. protected _buildBlock(state: NodeMaterialBuildState): void;
  100245. protected _dumpPropertiesCode(): string;
  100246. dispose(): void;
  100247. serialize(): any;
  100248. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  100249. }
  100250. }
  100251. declare module BABYLON {
  100252. /**
  100253. * Enum used to define the compatibility state between two connection points
  100254. */
  100255. export enum NodeMaterialConnectionPointCompatibilityStates {
  100256. /** Points are compatibles */
  100257. Compatible = 0,
  100258. /** Points are incompatible because of their types */
  100259. TypeIncompatible = 1,
  100260. /** Points are incompatible because of their targets (vertex vs fragment) */
  100261. TargetIncompatible = 2
  100262. }
  100263. /**
  100264. * Defines the direction of a connection point
  100265. */
  100266. export enum NodeMaterialConnectionPointDirection {
  100267. /** Input */
  100268. Input = 0,
  100269. /** Output */
  100270. Output = 1
  100271. }
  100272. /**
  100273. * Defines a connection point for a block
  100274. */
  100275. export class NodeMaterialConnectionPoint {
  100276. /** @hidden */
  100277. _ownerBlock: NodeMaterialBlock;
  100278. /** @hidden */
  100279. _connectedPoint: Nullable<NodeMaterialConnectionPoint>;
  100280. private _endpoints;
  100281. private _associatedVariableName;
  100282. private _direction;
  100283. /** @hidden */
  100284. _typeConnectionSource: Nullable<NodeMaterialConnectionPoint>;
  100285. /** @hidden */
  100286. _linkedConnectionSource: Nullable<NodeMaterialConnectionPoint>;
  100287. private _type;
  100288. /** @hidden */
  100289. _enforceAssociatedVariableName: boolean;
  100290. /** Gets the direction of the point */
  100291. get direction(): NodeMaterialConnectionPointDirection;
  100292. /** Indicates that this connection point needs dual validation before being connected to another point */
  100293. needDualDirectionValidation: boolean;
  100294. /**
  100295. * Gets or sets the additional types supported by this connection point
  100296. */
  100297. acceptedConnectionPointTypes: NodeMaterialBlockConnectionPointTypes[];
  100298. /**
  100299. * Gets or sets the additional types excluded by this connection point
  100300. */
  100301. excludedConnectionPointTypes: NodeMaterialBlockConnectionPointTypes[];
  100302. /**
  100303. * Observable triggered when this point is connected
  100304. */
  100305. onConnectionObservable: Observable<NodeMaterialConnectionPoint>;
  100306. /**
  100307. * Gets or sets the associated variable name in the shader
  100308. */
  100309. get associatedVariableName(): string;
  100310. set associatedVariableName(value: string);
  100311. /** Get the inner type (ie AutoDetect for instance instead of the inferred one) */
  100312. get innerType(): NodeMaterialBlockConnectionPointTypes;
  100313. /**
  100314. * Gets or sets the connection point type (default is float)
  100315. */
  100316. get type(): NodeMaterialBlockConnectionPointTypes;
  100317. set type(value: NodeMaterialBlockConnectionPointTypes);
  100318. /**
  100319. * Gets or sets the connection point name
  100320. */
  100321. name: string;
  100322. /**
  100323. * Gets or sets the connection point name
  100324. */
  100325. displayName: string;
  100326. /**
  100327. * Gets or sets a boolean indicating that this connection point can be omitted
  100328. */
  100329. isOptional: boolean;
  100330. /**
  100331. * Gets or sets a boolean indicating that this connection point is exposed on a frame
  100332. */
  100333. isExposedOnFrame: boolean;
  100334. /**
  100335. * Gets or sets a string indicating that this uniform must be defined under a #ifdef
  100336. */
  100337. define: string;
  100338. /** @hidden */
  100339. _prioritizeVertex: boolean;
  100340. private _target;
  100341. /** Gets or sets the target of that connection point */
  100342. get target(): NodeMaterialBlockTargets;
  100343. set target(value: NodeMaterialBlockTargets);
  100344. /**
  100345. * Gets a boolean indicating that the current point is connected to another NodeMaterialBlock
  100346. */
  100347. get isConnected(): boolean;
  100348. /**
  100349. * Gets a boolean indicating that the current point is connected to an input block
  100350. */
  100351. get isConnectedToInputBlock(): boolean;
  100352. /**
  100353. * Gets a the connected input block (if any)
  100354. */
  100355. get connectInputBlock(): Nullable<InputBlock>;
  100356. /** Get the other side of the connection (if any) */
  100357. get connectedPoint(): Nullable<NodeMaterialConnectionPoint>;
  100358. /** Get the block that owns this connection point */
  100359. get ownerBlock(): NodeMaterialBlock;
  100360. /** Get the block connected on the other side of this connection (if any) */
  100361. get sourceBlock(): Nullable<NodeMaterialBlock>;
  100362. /** Get the block connected on the endpoints of this connection (if any) */
  100363. get connectedBlocks(): Array<NodeMaterialBlock>;
  100364. /** Gets the list of connected endpoints */
  100365. get endpoints(): NodeMaterialConnectionPoint[];
  100366. /** Gets a boolean indicating if that output point is connected to at least one input */
  100367. get hasEndpoints(): boolean;
  100368. /** Gets a boolean indicating that this connection will be used in the vertex shader */
  100369. get isConnectedInVertexShader(): boolean;
  100370. /** Gets a boolean indicating that this connection will be used in the fragment shader */
  100371. get isConnectedInFragmentShader(): boolean;
  100372. /**
  100373. * Creates a block suitable to be used as an input for this input point.
  100374. * If null is returned, a block based on the point type will be created.
  100375. * @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
  100376. */
  100377. createCustomInputBlock(): Nullable<[NodeMaterialBlock, string]>;
  100378. /**
  100379. * Creates a new connection point
  100380. * @param name defines the connection point name
  100381. * @param ownerBlock defines the block hosting this connection point
  100382. * @param direction defines the direction of the connection point
  100383. */
  100384. constructor(name: string, ownerBlock: NodeMaterialBlock, direction: NodeMaterialConnectionPointDirection);
  100385. /**
  100386. * Gets the current class name e.g. "NodeMaterialConnectionPoint"
  100387. * @returns the class name
  100388. */
  100389. getClassName(): string;
  100390. /**
  100391. * Gets a boolean indicating if the current point can be connected to another point
  100392. * @param connectionPoint defines the other connection point
  100393. * @returns a boolean
  100394. */
  100395. canConnectTo(connectionPoint: NodeMaterialConnectionPoint): boolean;
  100396. /**
  100397. * Gets a number indicating if the current point can be connected to another point
  100398. * @param connectionPoint defines the other connection point
  100399. * @returns a number defining the compatibility state
  100400. */
  100401. checkCompatibilityState(connectionPoint: NodeMaterialConnectionPoint): NodeMaterialConnectionPointCompatibilityStates;
  100402. /**
  100403. * Connect this point to another connection point
  100404. * @param connectionPoint defines the other connection point
  100405. * @param ignoreConstraints defines if the system will ignore connection type constraints (default is false)
  100406. * @returns the current connection point
  100407. */
  100408. connectTo(connectionPoint: NodeMaterialConnectionPoint, ignoreConstraints?: boolean): NodeMaterialConnectionPoint;
  100409. /**
  100410. * Disconnect this point from one of his endpoint
  100411. * @param endpoint defines the other connection point
  100412. * @returns the current connection point
  100413. */
  100414. disconnectFrom(endpoint: NodeMaterialConnectionPoint): NodeMaterialConnectionPoint;
  100415. /**
  100416. * Serializes this point in a JSON representation
  100417. * @param isInput defines if the connection point is an input (default is true)
  100418. * @returns the serialized point object
  100419. */
  100420. serialize(isInput?: boolean): any;
  100421. /**
  100422. * Release resources
  100423. */
  100424. dispose(): void;
  100425. }
  100426. }
  100427. declare module BABYLON {
  100428. /**
  100429. * Enum used to define the material modes
  100430. */
  100431. export enum NodeMaterialModes {
  100432. /** Regular material */
  100433. Material = 0,
  100434. /** For post process */
  100435. PostProcess = 1,
  100436. /** For particle system */
  100437. Particle = 2
  100438. }
  100439. }
  100440. declare module BABYLON {
  100441. /**
  100442. * Block used to read a texture from a sampler
  100443. */
  100444. export class TextureBlock extends NodeMaterialBlock {
  100445. private _defineName;
  100446. private _linearDefineName;
  100447. private _gammaDefineName;
  100448. private _tempTextureRead;
  100449. private _samplerName;
  100450. private _transformedUVName;
  100451. private _textureTransformName;
  100452. private _textureInfoName;
  100453. private _mainUVName;
  100454. private _mainUVDefineName;
  100455. private _fragmentOnly;
  100456. /**
  100457. * Gets or sets the texture associated with the node
  100458. */
  100459. texture: Nullable<Texture>;
  100460. /**
  100461. * Gets or sets a boolean indicating if content needs to be converted to gamma space
  100462. */
  100463. convertToGammaSpace: boolean;
  100464. /**
  100465. * Gets or sets a boolean indicating if content needs to be converted to linear space
  100466. */
  100467. convertToLinearSpace: boolean;
  100468. /**
  100469. * Create a new TextureBlock
  100470. * @param name defines the block name
  100471. */
  100472. constructor(name: string, fragmentOnly?: boolean);
  100473. /**
  100474. * Gets the current class name
  100475. * @returns the class name
  100476. */
  100477. getClassName(): string;
  100478. /**
  100479. * Gets the uv input component
  100480. */
  100481. get uv(): NodeMaterialConnectionPoint;
  100482. /**
  100483. * Gets the rgba output component
  100484. */
  100485. get rgba(): NodeMaterialConnectionPoint;
  100486. /**
  100487. * Gets the rgb output component
  100488. */
  100489. get rgb(): NodeMaterialConnectionPoint;
  100490. /**
  100491. * Gets the r output component
  100492. */
  100493. get r(): NodeMaterialConnectionPoint;
  100494. /**
  100495. * Gets the g output component
  100496. */
  100497. get g(): NodeMaterialConnectionPoint;
  100498. /**
  100499. * Gets the b output component
  100500. */
  100501. get b(): NodeMaterialConnectionPoint;
  100502. /**
  100503. * Gets the a output component
  100504. */
  100505. get a(): NodeMaterialConnectionPoint;
  100506. get target(): NodeMaterialBlockTargets;
  100507. autoConfigure(material: NodeMaterial): void;
  100508. initializeDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  100509. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  100510. isReady(): boolean;
  100511. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  100512. private get _isMixed();
  100513. private _injectVertexCode;
  100514. private _writeTextureRead;
  100515. private _writeOutput;
  100516. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  100517. protected _dumpPropertiesCode(): string;
  100518. serialize(): any;
  100519. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  100520. }
  100521. }
  100522. declare module BABYLON {
  100523. /** @hidden */
  100524. export var reflectionFunction: {
  100525. name: string;
  100526. shader: string;
  100527. };
  100528. }
  100529. declare module BABYLON {
  100530. /**
  100531. * Base block used to read a reflection texture from a sampler
  100532. */
  100533. export abstract class ReflectionTextureBaseBlock extends NodeMaterialBlock {
  100534. /** @hidden */
  100535. _define3DName: string;
  100536. /** @hidden */
  100537. _defineCubicName: string;
  100538. /** @hidden */
  100539. _defineExplicitName: string;
  100540. /** @hidden */
  100541. _defineProjectionName: string;
  100542. /** @hidden */
  100543. _defineLocalCubicName: string;
  100544. /** @hidden */
  100545. _defineSphericalName: string;
  100546. /** @hidden */
  100547. _definePlanarName: string;
  100548. /** @hidden */
  100549. _defineEquirectangularName: string;
  100550. /** @hidden */
  100551. _defineMirroredEquirectangularFixedName: string;
  100552. /** @hidden */
  100553. _defineEquirectangularFixedName: string;
  100554. /** @hidden */
  100555. _defineSkyboxName: string;
  100556. /** @hidden */
  100557. _defineOppositeZ: string;
  100558. /** @hidden */
  100559. _cubeSamplerName: string;
  100560. /** @hidden */
  100561. _2DSamplerName: string;
  100562. protected _positionUVWName: string;
  100563. protected _directionWName: string;
  100564. protected _reflectionVectorName: string;
  100565. /** @hidden */
  100566. _reflectionCoordsName: string;
  100567. /** @hidden */
  100568. _reflectionMatrixName: string;
  100569. protected _reflectionColorName: string;
  100570. /**
  100571. * Gets or sets the texture associated with the node
  100572. */
  100573. texture: Nullable<BaseTexture>;
  100574. /**
  100575. * Create a new ReflectionTextureBaseBlock
  100576. * @param name defines the block name
  100577. */
  100578. constructor(name: string);
  100579. /**
  100580. * Gets the current class name
  100581. * @returns the class name
  100582. */
  100583. getClassName(): string;
  100584. /**
  100585. * Gets the world position input component
  100586. */
  100587. abstract get position(): NodeMaterialConnectionPoint;
  100588. /**
  100589. * Gets the world position input component
  100590. */
  100591. abstract get worldPosition(): NodeMaterialConnectionPoint;
  100592. /**
  100593. * Gets the world normal input component
  100594. */
  100595. abstract get worldNormal(): NodeMaterialConnectionPoint;
  100596. /**
  100597. * Gets the world input component
  100598. */
  100599. abstract get world(): NodeMaterialConnectionPoint;
  100600. /**
  100601. * Gets the camera (or eye) position component
  100602. */
  100603. abstract get cameraPosition(): NodeMaterialConnectionPoint;
  100604. /**
  100605. * Gets the view input component
  100606. */
  100607. abstract get view(): NodeMaterialConnectionPoint;
  100608. protected _getTexture(): Nullable<BaseTexture>;
  100609. autoConfigure(material: NodeMaterial): void;
  100610. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  100611. isReady(): boolean;
  100612. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  100613. /**
  100614. * Gets the code to inject in the vertex shader
  100615. * @param state current state of the node material building
  100616. * @returns the shader code
  100617. */
  100618. handleVertexSide(state: NodeMaterialBuildState): string;
  100619. /**
  100620. * Handles the inits for the fragment code path
  100621. * @param state node material build state
  100622. */
  100623. handleFragmentSideInits(state: NodeMaterialBuildState): void;
  100624. /**
  100625. * Generates the reflection coords code for the fragment code path
  100626. * @param worldNormalVarName name of the world normal variable
  100627. * @param worldPos name of the world position variable. If not provided, will use the world position connected to this block
  100628. * @param onlyReflectionVector if true, generates code only for the reflection vector computation, not for the reflection coordinates
  100629. * @returns the shader code
  100630. */
  100631. handleFragmentSideCodeReflectionCoords(worldNormalVarName: string, worldPos?: string, onlyReflectionVector?: boolean): string;
  100632. /**
  100633. * Generates the reflection color code for the fragment code path
  100634. * @param lodVarName name of the lod variable
  100635. * @param swizzleLookupTexture swizzle to use for the final color variable
  100636. * @returns the shader code
  100637. */
  100638. handleFragmentSideCodeReflectionColor(lodVarName?: string, swizzleLookupTexture?: string): string;
  100639. /**
  100640. * Generates the code corresponding to the connected output points
  100641. * @param state node material build state
  100642. * @param varName name of the variable to output
  100643. * @returns the shader code
  100644. */
  100645. writeOutputs(state: NodeMaterialBuildState, varName: string): string;
  100646. protected _buildBlock(state: NodeMaterialBuildState): this;
  100647. protected _dumpPropertiesCode(): string;
  100648. serialize(): any;
  100649. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  100650. }
  100651. }
  100652. declare module BABYLON {
  100653. /**
  100654. * Defines a connection point to be used for points with a custom object type
  100655. */
  100656. export class NodeMaterialConnectionPointCustomObject<T extends NodeMaterialBlock> extends NodeMaterialConnectionPoint {
  100657. private _blockType;
  100658. private _blockName;
  100659. private _nameForCheking?;
  100660. /**
  100661. * Creates a new connection point
  100662. * @param name defines the connection point name
  100663. * @param ownerBlock defines the block hosting this connection point
  100664. * @param direction defines the direction of the connection point
  100665. */
  100666. constructor(name: string, ownerBlock: NodeMaterialBlock, direction: NodeMaterialConnectionPointDirection, _blockType: new (...args: any[]) => T, _blockName: string, _nameForCheking?: string | undefined);
  100667. /**
  100668. * Gets a number indicating if the current point can be connected to another point
  100669. * @param connectionPoint defines the other connection point
  100670. * @returns a number defining the compatibility state
  100671. */
  100672. checkCompatibilityState(connectionPoint: NodeMaterialConnectionPoint): NodeMaterialConnectionPointCompatibilityStates;
  100673. /**
  100674. * Creates a block suitable to be used as an input for this input point.
  100675. * If null is returned, a block based on the point type will be created.
  100676. * @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
  100677. */
  100678. createCustomInputBlock(): Nullable<[NodeMaterialBlock, string]>;
  100679. }
  100680. }
  100681. declare module BABYLON {
  100682. /**
  100683. * Enum defining the type of properties that can be edited in the property pages in the NME
  100684. */
  100685. export enum PropertyTypeForEdition {
  100686. /** property is a boolean */
  100687. Boolean = 0,
  100688. /** property is a float */
  100689. Float = 1,
  100690. /** property is a Vector2 */
  100691. Vector2 = 2,
  100692. /** property is a list of values */
  100693. List = 3
  100694. }
  100695. /**
  100696. * Interface that defines an option in a variable of type list
  100697. */
  100698. export interface IEditablePropertyListOption {
  100699. /** label of the option */
  100700. "label": string;
  100701. /** value of the option */
  100702. "value": number;
  100703. }
  100704. /**
  100705. * Interface that defines the options available for an editable property
  100706. */
  100707. export interface IEditablePropertyOption {
  100708. /** min value */
  100709. "min"?: number;
  100710. /** max value */
  100711. "max"?: number;
  100712. /** notifiers: indicates which actions to take when the property is changed */
  100713. "notifiers"?: {
  100714. /** the material should be rebuilt */
  100715. "rebuild"?: boolean;
  100716. /** the preview should be updated */
  100717. "update"?: boolean;
  100718. };
  100719. /** list of the options for a variable of type list */
  100720. "options"?: IEditablePropertyListOption[];
  100721. }
  100722. /**
  100723. * Interface that describes an editable property
  100724. */
  100725. export interface IPropertyDescriptionForEdition {
  100726. /** name of the property */
  100727. "propertyName": string;
  100728. /** display name of the property */
  100729. "displayName": string;
  100730. /** type of the property */
  100731. "type": PropertyTypeForEdition;
  100732. /** group of the property - all properties with the same group value will be displayed in a specific section */
  100733. "groupName": string;
  100734. /** options for the property */
  100735. "options": IEditablePropertyOption;
  100736. }
  100737. /**
  100738. * Decorator that flags a property in a node material block as being editable
  100739. */
  100740. export function editableInPropertyPage(displayName: string, propertyType?: PropertyTypeForEdition, groupName?: string, options?: IEditablePropertyOption): (target: any, propertyKey: string) => void;
  100741. }
  100742. declare module BABYLON {
  100743. /**
  100744. * Block used to implement the refraction part of the sub surface module of the PBR material
  100745. */
  100746. export class RefractionBlock extends NodeMaterialBlock {
  100747. /** @hidden */
  100748. _define3DName: string;
  100749. /** @hidden */
  100750. _refractionMatrixName: string;
  100751. /** @hidden */
  100752. _defineLODRefractionAlpha: string;
  100753. /** @hidden */
  100754. _defineLinearSpecularRefraction: string;
  100755. /** @hidden */
  100756. _defineOppositeZ: string;
  100757. /** @hidden */
  100758. _cubeSamplerName: string;
  100759. /** @hidden */
  100760. _2DSamplerName: string;
  100761. /** @hidden */
  100762. _vRefractionMicrosurfaceInfosName: string;
  100763. /** @hidden */
  100764. _vRefractionInfosName: string;
  100765. private _scene;
  100766. /**
  100767. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  100768. * Materials half opaque for instance using refraction could benefit from this control.
  100769. */
  100770. linkRefractionWithTransparency: boolean;
  100771. /**
  100772. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  100773. */
  100774. invertRefractionY: boolean;
  100775. /**
  100776. * Gets or sets the texture associated with the node
  100777. */
  100778. texture: Nullable<BaseTexture>;
  100779. /**
  100780. * Create a new RefractionBlock
  100781. * @param name defines the block name
  100782. */
  100783. constructor(name: string);
  100784. /**
  100785. * Gets the current class name
  100786. * @returns the class name
  100787. */
  100788. getClassName(): string;
  100789. /**
  100790. * Gets the intensity input component
  100791. */
  100792. get intensity(): NodeMaterialConnectionPoint;
  100793. /**
  100794. * Gets the index of refraction input component
  100795. */
  100796. get indexOfRefraction(): NodeMaterialConnectionPoint;
  100797. /**
  100798. * Gets the tint at distance input component
  100799. */
  100800. get tintAtDistance(): NodeMaterialConnectionPoint;
  100801. /**
  100802. * Gets the view input component
  100803. */
  100804. get view(): NodeMaterialConnectionPoint;
  100805. /**
  100806. * Gets the refraction object output component
  100807. */
  100808. get refraction(): NodeMaterialConnectionPoint;
  100809. /**
  100810. * Returns true if the block has a texture
  100811. */
  100812. get hasTexture(): boolean;
  100813. protected _getTexture(): Nullable<BaseTexture>;
  100814. autoConfigure(material: NodeMaterial): void;
  100815. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  100816. isReady(): boolean;
  100817. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh, subMesh?: SubMesh): void;
  100818. /**
  100819. * Gets the main code of the block (fragment side)
  100820. * @param state current state of the node material building
  100821. * @returns the shader code
  100822. */
  100823. getCode(state: NodeMaterialBuildState): string;
  100824. protected _buildBlock(state: NodeMaterialBuildState): this;
  100825. protected _dumpPropertiesCode(): string;
  100826. serialize(): any;
  100827. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  100828. }
  100829. }
  100830. declare module BABYLON {
  100831. /**
  100832. * Base block used as input for post process
  100833. */
  100834. export class CurrentScreenBlock extends NodeMaterialBlock {
  100835. private _samplerName;
  100836. private _linearDefineName;
  100837. private _gammaDefineName;
  100838. private _mainUVName;
  100839. private _tempTextureRead;
  100840. /**
  100841. * Gets or sets the texture associated with the node
  100842. */
  100843. texture: Nullable<BaseTexture>;
  100844. /**
  100845. * Gets or sets a boolean indicating if content needs to be converted to gamma space
  100846. */
  100847. convertToGammaSpace: boolean;
  100848. /**
  100849. * Gets or sets a boolean indicating if content needs to be converted to linear space
  100850. */
  100851. convertToLinearSpace: boolean;
  100852. /**
  100853. * Create a new CurrentScreenBlock
  100854. * @param name defines the block name
  100855. */
  100856. constructor(name: string);
  100857. /**
  100858. * Gets the current class name
  100859. * @returns the class name
  100860. */
  100861. getClassName(): string;
  100862. /**
  100863. * Gets the uv input component
  100864. */
  100865. get uv(): NodeMaterialConnectionPoint;
  100866. /**
  100867. * Gets the rgba output component
  100868. */
  100869. get rgba(): NodeMaterialConnectionPoint;
  100870. /**
  100871. * Gets the rgb output component
  100872. */
  100873. get rgb(): NodeMaterialConnectionPoint;
  100874. /**
  100875. * Gets the r output component
  100876. */
  100877. get r(): NodeMaterialConnectionPoint;
  100878. /**
  100879. * Gets the g output component
  100880. */
  100881. get g(): NodeMaterialConnectionPoint;
  100882. /**
  100883. * Gets the b output component
  100884. */
  100885. get b(): NodeMaterialConnectionPoint;
  100886. /**
  100887. * Gets the a output component
  100888. */
  100889. get a(): NodeMaterialConnectionPoint;
  100890. /**
  100891. * Initialize the block and prepare the context for build
  100892. * @param state defines the state that will be used for the build
  100893. */
  100894. initialize(state: NodeMaterialBuildState): void;
  100895. get target(): NodeMaterialBlockTargets;
  100896. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  100897. isReady(): boolean;
  100898. private _injectVertexCode;
  100899. private _writeTextureRead;
  100900. private _writeOutput;
  100901. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  100902. serialize(): any;
  100903. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  100904. }
  100905. }
  100906. declare module BABYLON {
  100907. /**
  100908. * Base block used for the particle texture
  100909. */
  100910. export class ParticleTextureBlock extends NodeMaterialBlock {
  100911. private _samplerName;
  100912. private _linearDefineName;
  100913. private _gammaDefineName;
  100914. private _tempTextureRead;
  100915. /**
  100916. * Gets or sets the texture associated with the node
  100917. */
  100918. texture: Nullable<BaseTexture>;
  100919. /**
  100920. * Gets or sets a boolean indicating if content needs to be converted to gamma space
  100921. */
  100922. convertToGammaSpace: boolean;
  100923. /**
  100924. * Gets or sets a boolean indicating if content needs to be converted to linear space
  100925. */
  100926. convertToLinearSpace: boolean;
  100927. /**
  100928. * Create a new ParticleTextureBlock
  100929. * @param name defines the block name
  100930. */
  100931. constructor(name: string);
  100932. /**
  100933. * Gets the current class name
  100934. * @returns the class name
  100935. */
  100936. getClassName(): string;
  100937. /**
  100938. * Gets the uv input component
  100939. */
  100940. get uv(): NodeMaterialConnectionPoint;
  100941. /**
  100942. * Gets the rgba output component
  100943. */
  100944. get rgba(): NodeMaterialConnectionPoint;
  100945. /**
  100946. * Gets the rgb output component
  100947. */
  100948. get rgb(): NodeMaterialConnectionPoint;
  100949. /**
  100950. * Gets the r output component
  100951. */
  100952. get r(): NodeMaterialConnectionPoint;
  100953. /**
  100954. * Gets the g output component
  100955. */
  100956. get g(): NodeMaterialConnectionPoint;
  100957. /**
  100958. * Gets the b output component
  100959. */
  100960. get b(): NodeMaterialConnectionPoint;
  100961. /**
  100962. * Gets the a output component
  100963. */
  100964. get a(): NodeMaterialConnectionPoint;
  100965. /**
  100966. * Initialize the block and prepare the context for build
  100967. * @param state defines the state that will be used for the build
  100968. */
  100969. initialize(state: NodeMaterialBuildState): void;
  100970. autoConfigure(material: NodeMaterial): void;
  100971. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  100972. isReady(): boolean;
  100973. private _writeOutput;
  100974. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  100975. serialize(): any;
  100976. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  100977. }
  100978. }
  100979. declare module BABYLON {
  100980. /**
  100981. * Class used to store shared data between 2 NodeMaterialBuildState
  100982. */
  100983. export class NodeMaterialBuildStateSharedData {
  100984. /**
  100985. * Gets the list of emitted varyings
  100986. */
  100987. temps: string[];
  100988. /**
  100989. * Gets the list of emitted varyings
  100990. */
  100991. varyings: string[];
  100992. /**
  100993. * Gets the varying declaration string
  100994. */
  100995. varyingDeclaration: string;
  100996. /**
  100997. * Input blocks
  100998. */
  100999. inputBlocks: InputBlock[];
  101000. /**
  101001. * Input blocks
  101002. */
  101003. textureBlocks: (TextureBlock | ReflectionTextureBaseBlock | RefractionBlock | CurrentScreenBlock | ParticleTextureBlock)[];
  101004. /**
  101005. * Bindable blocks (Blocks that need to set data to the effect)
  101006. */
  101007. bindableBlocks: NodeMaterialBlock[];
  101008. /**
  101009. * List of blocks that can provide a compilation fallback
  101010. */
  101011. blocksWithFallbacks: NodeMaterialBlock[];
  101012. /**
  101013. * List of blocks that can provide a define update
  101014. */
  101015. blocksWithDefines: NodeMaterialBlock[];
  101016. /**
  101017. * List of blocks that can provide a repeatable content
  101018. */
  101019. repeatableContentBlocks: NodeMaterialBlock[];
  101020. /**
  101021. * List of blocks that can provide a dynamic list of uniforms
  101022. */
  101023. dynamicUniformBlocks: NodeMaterialBlock[];
  101024. /**
  101025. * List of blocks that can block the isReady function for the material
  101026. */
  101027. blockingBlocks: NodeMaterialBlock[];
  101028. /**
  101029. * Gets the list of animated inputs
  101030. */
  101031. animatedInputs: InputBlock[];
  101032. /**
  101033. * Build Id used to avoid multiple recompilations
  101034. */
  101035. buildId: number;
  101036. /** List of emitted variables */
  101037. variableNames: {
  101038. [key: string]: number;
  101039. };
  101040. /** List of emitted defines */
  101041. defineNames: {
  101042. [key: string]: number;
  101043. };
  101044. /** Should emit comments? */
  101045. emitComments: boolean;
  101046. /** Emit build activity */
  101047. verbose: boolean;
  101048. /** Gets or sets the hosting scene */
  101049. scene: Scene;
  101050. /**
  101051. * Gets the compilation hints emitted at compilation time
  101052. */
  101053. hints: {
  101054. needWorldViewMatrix: boolean;
  101055. needWorldViewProjectionMatrix: boolean;
  101056. needAlphaBlending: boolean;
  101057. needAlphaTesting: boolean;
  101058. };
  101059. /**
  101060. * List of compilation checks
  101061. */
  101062. checks: {
  101063. emitVertex: boolean;
  101064. emitFragment: boolean;
  101065. notConnectedNonOptionalInputs: NodeMaterialConnectionPoint[];
  101066. };
  101067. /**
  101068. * Is vertex program allowed to be empty?
  101069. */
  101070. allowEmptyVertexProgram: boolean;
  101071. /** Creates a new shared data */
  101072. constructor();
  101073. /**
  101074. * Emits console errors and exceptions if there is a failing check
  101075. */
  101076. emitErrors(): void;
  101077. }
  101078. }
  101079. declare module BABYLON {
  101080. /**
  101081. * Class used to store node based material build state
  101082. */
  101083. export class NodeMaterialBuildState {
  101084. /** Gets or sets a boolean indicating if the current state can emit uniform buffers */
  101085. supportUniformBuffers: boolean;
  101086. /**
  101087. * Gets the list of emitted attributes
  101088. */
  101089. attributes: string[];
  101090. /**
  101091. * Gets the list of emitted uniforms
  101092. */
  101093. uniforms: string[];
  101094. /**
  101095. * Gets the list of emitted constants
  101096. */
  101097. constants: string[];
  101098. /**
  101099. * Gets the list of emitted samplers
  101100. */
  101101. samplers: string[];
  101102. /**
  101103. * Gets the list of emitted functions
  101104. */
  101105. functions: {
  101106. [key: string]: string;
  101107. };
  101108. /**
  101109. * Gets the list of emitted extensions
  101110. */
  101111. extensions: {
  101112. [key: string]: string;
  101113. };
  101114. /**
  101115. * Gets the target of the compilation state
  101116. */
  101117. target: NodeMaterialBlockTargets;
  101118. /**
  101119. * Gets the list of emitted counters
  101120. */
  101121. counters: {
  101122. [key: string]: number;
  101123. };
  101124. /**
  101125. * Shared data between multiple NodeMaterialBuildState instances
  101126. */
  101127. sharedData: NodeMaterialBuildStateSharedData;
  101128. /** @hidden */
  101129. _vertexState: NodeMaterialBuildState;
  101130. /** @hidden */
  101131. _attributeDeclaration: string;
  101132. /** @hidden */
  101133. _uniformDeclaration: string;
  101134. /** @hidden */
  101135. _constantDeclaration: string;
  101136. /** @hidden */
  101137. _samplerDeclaration: string;
  101138. /** @hidden */
  101139. _varyingTransfer: string;
  101140. /** @hidden */
  101141. _injectAtEnd: string;
  101142. private _repeatableContentAnchorIndex;
  101143. /** @hidden */
  101144. _builtCompilationString: string;
  101145. /**
  101146. * Gets the emitted compilation strings
  101147. */
  101148. compilationString: string;
  101149. /**
  101150. * Finalize the compilation strings
  101151. * @param state defines the current compilation state
  101152. */
  101153. finalize(state: NodeMaterialBuildState): void;
  101154. /** @hidden */
  101155. get _repeatableContentAnchor(): string;
  101156. /** @hidden */
  101157. _getFreeVariableName(prefix: string): string;
  101158. /** @hidden */
  101159. _getFreeDefineName(prefix: string): string;
  101160. /** @hidden */
  101161. _excludeVariableName(name: string): void;
  101162. /** @hidden */
  101163. _emit2DSampler(name: string): void;
  101164. /** @hidden */
  101165. _getGLType(type: NodeMaterialBlockConnectionPointTypes): string;
  101166. /** @hidden */
  101167. _emitExtension(name: string, extension: string, define?: string): void;
  101168. /** @hidden */
  101169. _emitFunction(name: string, code: string, comments: string): void;
  101170. /** @hidden */
  101171. _emitCodeFromInclude(includeName: string, comments: string, options?: {
  101172. replaceStrings?: {
  101173. search: RegExp;
  101174. replace: string;
  101175. }[];
  101176. repeatKey?: string;
  101177. }): string;
  101178. /** @hidden */
  101179. _emitFunctionFromInclude(includeName: string, comments: string, options?: {
  101180. repeatKey?: string;
  101181. removeAttributes?: boolean;
  101182. removeUniforms?: boolean;
  101183. removeVaryings?: boolean;
  101184. removeIfDef?: boolean;
  101185. replaceStrings?: {
  101186. search: RegExp;
  101187. replace: string;
  101188. }[];
  101189. }, storeKey?: string): void;
  101190. /** @hidden */
  101191. _registerTempVariable(name: string): boolean;
  101192. /** @hidden */
  101193. _emitVaryingFromString(name: string, type: string, define?: string, notDefine?: boolean): boolean;
  101194. /** @hidden */
  101195. _emitUniformFromString(name: string, type: string, define?: string, notDefine?: boolean): void;
  101196. /** @hidden */
  101197. _emitFloat(value: number): string;
  101198. }
  101199. }
  101200. declare module BABYLON {
  101201. /**
  101202. * Helper class used to generate session unique ID
  101203. */
  101204. export class UniqueIdGenerator {
  101205. private static _UniqueIdCounter;
  101206. /**
  101207. * Gets an unique (relatively to the current scene) Id
  101208. */
  101209. static get UniqueId(): number;
  101210. }
  101211. }
  101212. declare module BABYLON {
  101213. /**
  101214. * Defines a block that can be used inside a node based material
  101215. */
  101216. export class NodeMaterialBlock {
  101217. private _buildId;
  101218. private _buildTarget;
  101219. private _target;
  101220. private _isFinalMerger;
  101221. private _isInput;
  101222. private _name;
  101223. protected _isUnique: boolean;
  101224. /** Gets or sets a boolean indicating that only one input can be connected at a time */
  101225. inputsAreExclusive: boolean;
  101226. /** @hidden */
  101227. _codeVariableName: string;
  101228. /** @hidden */
  101229. _inputs: NodeMaterialConnectionPoint[];
  101230. /** @hidden */
  101231. _outputs: NodeMaterialConnectionPoint[];
  101232. /** @hidden */
  101233. _preparationId: number;
  101234. /**
  101235. * Gets the name of the block
  101236. */
  101237. get name(): string;
  101238. /**
  101239. * Sets the name of the block. Will check if the name is valid.
  101240. */
  101241. set name(newName: string);
  101242. /**
  101243. * Gets or sets the unique id of the node
  101244. */
  101245. uniqueId: number;
  101246. /**
  101247. * Gets or sets the comments associated with this block
  101248. */
  101249. comments: string;
  101250. /**
  101251. * Gets a boolean indicating that this block can only be used once per NodeMaterial
  101252. */
  101253. get isUnique(): boolean;
  101254. /**
  101255. * Gets a boolean indicating that this block is an end block (e.g. it is generating a system value)
  101256. */
  101257. get isFinalMerger(): boolean;
  101258. /**
  101259. * Gets a boolean indicating that this block is an input (e.g. it sends data to the shader)
  101260. */
  101261. get isInput(): boolean;
  101262. /**
  101263. * Gets or sets the build Id
  101264. */
  101265. get buildId(): number;
  101266. set buildId(value: number);
  101267. /**
  101268. * Gets or sets the target of the block
  101269. */
  101270. get target(): NodeMaterialBlockTargets;
  101271. set target(value: NodeMaterialBlockTargets);
  101272. /**
  101273. * Gets the list of input points
  101274. */
  101275. get inputs(): NodeMaterialConnectionPoint[];
  101276. /** Gets the list of output points */
  101277. get outputs(): NodeMaterialConnectionPoint[];
  101278. /**
  101279. * Find an input by its name
  101280. * @param name defines the name of the input to look for
  101281. * @returns the input or null if not found
  101282. */
  101283. getInputByName(name: string): Nullable<NodeMaterialConnectionPoint>;
  101284. /**
  101285. * Find an output by its name
  101286. * @param name defines the name of the outputto look for
  101287. * @returns the output or null if not found
  101288. */
  101289. getOutputByName(name: string): Nullable<NodeMaterialConnectionPoint>;
  101290. /**
  101291. * Creates a new NodeMaterialBlock
  101292. * @param name defines the block name
  101293. * @param target defines the target of that block (Vertex by default)
  101294. * @param isFinalMerger defines a boolean indicating that this block is an end block (e.g. it is generating a system value). Default is false
  101295. * @param isInput defines a boolean indicating that this block is an input (e.g. it sends data to the shader). Default is false
  101296. */
  101297. constructor(name: string, target?: NodeMaterialBlockTargets, isFinalMerger?: boolean, isInput?: boolean);
  101298. /**
  101299. * Initialize the block and prepare the context for build
  101300. * @param state defines the state that will be used for the build
  101301. */
  101302. initialize(state: NodeMaterialBuildState): void;
  101303. /**
  101304. * Bind data to effect. Will only be called for blocks with isBindable === true
  101305. * @param effect defines the effect to bind data to
  101306. * @param nodeMaterial defines the hosting NodeMaterial
  101307. * @param mesh defines the mesh that will be rendered
  101308. * @param subMesh defines the submesh that will be rendered
  101309. */
  101310. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh, subMesh?: SubMesh): void;
  101311. protected _declareOutput(output: NodeMaterialConnectionPoint, state: NodeMaterialBuildState): string;
  101312. protected _writeVariable(currentPoint: NodeMaterialConnectionPoint): string;
  101313. protected _writeFloat(value: number): string;
  101314. /**
  101315. * Gets the current class name e.g. "NodeMaterialBlock"
  101316. * @returns the class name
  101317. */
  101318. getClassName(): string;
  101319. /**
  101320. * Register a new input. Must be called inside a block constructor
  101321. * @param name defines the connection point name
  101322. * @param type defines the connection point type
  101323. * @param isOptional defines a boolean indicating that this input can be omitted
  101324. * @param target defines the target to use to limit the connection point (will be VertexAndFragment by default)
  101325. * @param point an already created connection point. If not provided, create a new one
  101326. * @returns the current block
  101327. */
  101328. registerInput(name: string, type: NodeMaterialBlockConnectionPointTypes, isOptional?: boolean, target?: NodeMaterialBlockTargets, point?: NodeMaterialConnectionPoint): this;
  101329. /**
  101330. * Register a new output. Must be called inside a block constructor
  101331. * @param name defines the connection point name
  101332. * @param type defines the connection point type
  101333. * @param target defines the target to use to limit the connection point (will be VertexAndFragment by default)
  101334. * @param point an already created connection point. If not provided, create a new one
  101335. * @returns the current block
  101336. */
  101337. registerOutput(name: string, type: NodeMaterialBlockConnectionPointTypes, target?: NodeMaterialBlockTargets, point?: NodeMaterialConnectionPoint): this;
  101338. /**
  101339. * Will return the first available input e.g. the first one which is not an uniform or an attribute
  101340. * @param forOutput defines an optional connection point to check compatibility with
  101341. * @returns the first available input or null
  101342. */
  101343. getFirstAvailableInput(forOutput?: Nullable<NodeMaterialConnectionPoint>): Nullable<NodeMaterialConnectionPoint>;
  101344. /**
  101345. * Will return the first available output e.g. the first one which is not yet connected and not a varying
  101346. * @param forBlock defines an optional block to check compatibility with
  101347. * @returns the first available input or null
  101348. */
  101349. getFirstAvailableOutput(forBlock?: Nullable<NodeMaterialBlock>): Nullable<NodeMaterialConnectionPoint>;
  101350. /**
  101351. * Gets the sibling of the given output
  101352. * @param current defines the current output
  101353. * @returns the next output in the list or null
  101354. */
  101355. getSiblingOutput(current: NodeMaterialConnectionPoint): Nullable<NodeMaterialConnectionPoint>;
  101356. /**
  101357. * Connect current block with another block
  101358. * @param other defines the block to connect with
  101359. * @param options define the various options to help pick the right connections
  101360. * @returns the current block
  101361. */
  101362. connectTo(other: NodeMaterialBlock, options?: {
  101363. input?: string;
  101364. output?: string;
  101365. outputSwizzle?: string;
  101366. }): this | undefined;
  101367. protected _buildBlock(state: NodeMaterialBuildState): void;
  101368. /**
  101369. * Add uniforms, samplers and uniform buffers at compilation time
  101370. * @param state defines the state to update
  101371. * @param nodeMaterial defines the node material requesting the update
  101372. * @param defines defines the material defines to update
  101373. * @param uniformBuffers defines the list of uniform buffer names
  101374. */
  101375. updateUniformsAndSamples(state: NodeMaterialBuildState, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, uniformBuffers: string[]): void;
  101376. /**
  101377. * Add potential fallbacks if shader compilation fails
  101378. * @param mesh defines the mesh to be rendered
  101379. * @param fallbacks defines the current prioritized list of fallbacks
  101380. */
  101381. provideFallbacks(mesh: AbstractMesh, fallbacks: EffectFallbacks): void;
  101382. /**
  101383. * Initialize defines for shader compilation
  101384. * @param mesh defines the mesh to be rendered
  101385. * @param nodeMaterial defines the node material requesting the update
  101386. * @param defines defines the material defines to update
  101387. * @param useInstances specifies that instances should be used
  101388. */
  101389. initializeDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  101390. /**
  101391. * Update defines for shader compilation
  101392. * @param mesh defines the mesh to be rendered
  101393. * @param nodeMaterial defines the node material requesting the update
  101394. * @param defines defines the material defines to update
  101395. * @param useInstances specifies that instances should be used
  101396. * @param subMesh defines which submesh to render
  101397. */
  101398. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean, subMesh?: SubMesh): void;
  101399. /**
  101400. * Lets the block try to connect some inputs automatically
  101401. * @param material defines the hosting NodeMaterial
  101402. */
  101403. autoConfigure(material: NodeMaterial): void;
  101404. /**
  101405. * Function called when a block is declared as repeatable content generator
  101406. * @param vertexShaderState defines the current compilation state for the vertex shader
  101407. * @param fragmentShaderState defines the current compilation state for the fragment shader
  101408. * @param mesh defines the mesh to be rendered
  101409. * @param defines defines the material defines to update
  101410. */
  101411. replaceRepeatableContent(vertexShaderState: NodeMaterialBuildState, fragmentShaderState: NodeMaterialBuildState, mesh: AbstractMesh, defines: NodeMaterialDefines): void;
  101412. /**
  101413. * Checks if the block is ready
  101414. * @param mesh defines the mesh to be rendered
  101415. * @param nodeMaterial defines the node material requesting the update
  101416. * @param defines defines the material defines to update
  101417. * @param useInstances specifies that instances should be used
  101418. * @returns true if the block is ready
  101419. */
  101420. isReady(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): boolean;
  101421. protected _linkConnectionTypes(inputIndex0: number, inputIndex1: number): void;
  101422. private _processBuild;
  101423. /**
  101424. * Validates the new name for the block node.
  101425. * @param newName the new name to be given to the node.
  101426. * @returns false if the name is a reserve word, else true.
  101427. */
  101428. validateBlockName(newName: string): boolean;
  101429. /**
  101430. * Compile the current node and generate the shader code
  101431. * @param state defines the current compilation state (uniforms, samplers, current string)
  101432. * @param activeBlocks defines the list of active blocks (i.e. blocks to compile)
  101433. * @returns true if already built
  101434. */
  101435. build(state: NodeMaterialBuildState, activeBlocks: NodeMaterialBlock[]): boolean;
  101436. protected _inputRename(name: string): string;
  101437. protected _outputRename(name: string): string;
  101438. protected _dumpPropertiesCode(): string;
  101439. /** @hidden */
  101440. _dumpCode(uniqueNames: string[], alreadyDumped: NodeMaterialBlock[]): string;
  101441. /** @hidden */
  101442. _dumpCodeForOutputConnections(alreadyDumped: NodeMaterialBlock[]): string;
  101443. /**
  101444. * Clone the current block to a new identical block
  101445. * @param scene defines the hosting scene
  101446. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  101447. * @returns a copy of the current block
  101448. */
  101449. clone(scene: Scene, rootUrl?: string): Nullable<NodeMaterialBlock>;
  101450. /**
  101451. * Serializes this block in a JSON representation
  101452. * @returns the serialized block object
  101453. */
  101454. serialize(): any;
  101455. /** @hidden */
  101456. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  101457. private _deserializePortDisplayNamesAndExposedOnFrame;
  101458. /**
  101459. * Release resources
  101460. */
  101461. dispose(): void;
  101462. }
  101463. }
  101464. declare module BABYLON {
  101465. /**
  101466. * Base class of materials working in push mode in babylon JS
  101467. * @hidden
  101468. */
  101469. export class PushMaterial extends Material {
  101470. protected _activeEffect: Effect;
  101471. protected _normalMatrix: Matrix;
  101472. constructor(name: string, scene: Scene);
  101473. getEffect(): Effect;
  101474. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  101475. protected _isReadyForSubMesh(subMesh: SubMesh): boolean;
  101476. /**
  101477. * Binds the given world matrix to the active effect
  101478. *
  101479. * @param world the matrix to bind
  101480. */
  101481. bindOnlyWorldMatrix(world: Matrix): void;
  101482. /**
  101483. * Binds the given normal matrix to the active effect
  101484. *
  101485. * @param normalMatrix the matrix to bind
  101486. */
  101487. bindOnlyNormalMatrix(normalMatrix: Matrix): void;
  101488. bind(world: Matrix, mesh?: Mesh): void;
  101489. protected _afterBind(mesh: Mesh, effect?: Nullable<Effect>): void;
  101490. protected _mustRebind(scene: Scene, effect: Effect, visibility?: number): boolean;
  101491. }
  101492. }
  101493. declare module BABYLON {
  101494. /**
  101495. * Root class for all node material optimizers
  101496. */
  101497. export class NodeMaterialOptimizer {
  101498. /**
  101499. * Function used to optimize a NodeMaterial graph
  101500. * @param vertexOutputNodes defines the list of output nodes for the vertex shader
  101501. * @param fragmentOutputNodes defines the list of output nodes for the fragment shader
  101502. */
  101503. optimize(vertexOutputNodes: NodeMaterialBlock[], fragmentOutputNodes: NodeMaterialBlock[]): void;
  101504. }
  101505. }
  101506. declare module BABYLON {
  101507. /**
  101508. * Block used to transform a vector (2, 3 or 4) with a matrix. It will generate a Vector4
  101509. */
  101510. export class TransformBlock extends NodeMaterialBlock {
  101511. /**
  101512. * Defines the value to use to complement W value to transform it to a Vector4
  101513. */
  101514. complementW: number;
  101515. /**
  101516. * Defines the value to use to complement z value to transform it to a Vector4
  101517. */
  101518. complementZ: number;
  101519. /**
  101520. * Creates a new TransformBlock
  101521. * @param name defines the block name
  101522. */
  101523. constructor(name: string);
  101524. /**
  101525. * Gets the current class name
  101526. * @returns the class name
  101527. */
  101528. getClassName(): string;
  101529. /**
  101530. * Gets the vector input
  101531. */
  101532. get vector(): NodeMaterialConnectionPoint;
  101533. /**
  101534. * Gets the output component
  101535. */
  101536. get output(): NodeMaterialConnectionPoint;
  101537. /**
  101538. * Gets the xyz output component
  101539. */
  101540. get xyz(): NodeMaterialConnectionPoint;
  101541. /**
  101542. * Gets the matrix transform input
  101543. */
  101544. get transform(): NodeMaterialConnectionPoint;
  101545. protected _buildBlock(state: NodeMaterialBuildState): this;
  101546. /**
  101547. * Update defines for shader compilation
  101548. * @param mesh defines the mesh to be rendered
  101549. * @param nodeMaterial defines the node material requesting the update
  101550. * @param defines defines the material defines to update
  101551. * @param useInstances specifies that instances should be used
  101552. * @param subMesh defines which submesh to render
  101553. */
  101554. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean, subMesh?: SubMesh): void;
  101555. serialize(): any;
  101556. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  101557. protected _dumpPropertiesCode(): string;
  101558. }
  101559. }
  101560. declare module BABYLON {
  101561. /**
  101562. * Block used to output the vertex position
  101563. */
  101564. export class VertexOutputBlock extends NodeMaterialBlock {
  101565. /**
  101566. * Creates a new VertexOutputBlock
  101567. * @param name defines the block name
  101568. */
  101569. constructor(name: string);
  101570. /**
  101571. * Gets the current class name
  101572. * @returns the class name
  101573. */
  101574. getClassName(): string;
  101575. /**
  101576. * Gets the vector input component
  101577. */
  101578. get vector(): NodeMaterialConnectionPoint;
  101579. protected _buildBlock(state: NodeMaterialBuildState): this;
  101580. }
  101581. }
  101582. declare module BABYLON {
  101583. /**
  101584. * Block used to output the final color
  101585. */
  101586. export class FragmentOutputBlock extends NodeMaterialBlock {
  101587. /**
  101588. * Create a new FragmentOutputBlock
  101589. * @param name defines the block name
  101590. */
  101591. constructor(name: string);
  101592. /**
  101593. * Gets the current class name
  101594. * @returns the class name
  101595. */
  101596. getClassName(): string;
  101597. /**
  101598. * Gets the rgba input component
  101599. */
  101600. get rgba(): NodeMaterialConnectionPoint;
  101601. /**
  101602. * Gets the rgb input component
  101603. */
  101604. get rgb(): NodeMaterialConnectionPoint;
  101605. /**
  101606. * Gets the a input component
  101607. */
  101608. get a(): NodeMaterialConnectionPoint;
  101609. protected _buildBlock(state: NodeMaterialBuildState): this;
  101610. }
  101611. }
  101612. declare module BABYLON {
  101613. /**
  101614. * Block used for the particle ramp gradient section
  101615. */
  101616. export class ParticleRampGradientBlock extends NodeMaterialBlock {
  101617. /**
  101618. * Create a new ParticleRampGradientBlock
  101619. * @param name defines the block name
  101620. */
  101621. constructor(name: string);
  101622. /**
  101623. * Gets the current class name
  101624. * @returns the class name
  101625. */
  101626. getClassName(): string;
  101627. /**
  101628. * Gets the color input component
  101629. */
  101630. get color(): NodeMaterialConnectionPoint;
  101631. /**
  101632. * Gets the rampColor output component
  101633. */
  101634. get rampColor(): NodeMaterialConnectionPoint;
  101635. /**
  101636. * Initialize the block and prepare the context for build
  101637. * @param state defines the state that will be used for the build
  101638. */
  101639. initialize(state: NodeMaterialBuildState): void;
  101640. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  101641. }
  101642. }
  101643. declare module BABYLON {
  101644. /**
  101645. * Block used for the particle blend multiply section
  101646. */
  101647. export class ParticleBlendMultiplyBlock extends NodeMaterialBlock {
  101648. /**
  101649. * Create a new ParticleBlendMultiplyBlock
  101650. * @param name defines the block name
  101651. */
  101652. constructor(name: string);
  101653. /**
  101654. * Gets the current class name
  101655. * @returns the class name
  101656. */
  101657. getClassName(): string;
  101658. /**
  101659. * Gets the color input component
  101660. */
  101661. get color(): NodeMaterialConnectionPoint;
  101662. /**
  101663. * Gets the alphaTexture input component
  101664. */
  101665. get alphaTexture(): NodeMaterialConnectionPoint;
  101666. /**
  101667. * Gets the alphaColor input component
  101668. */
  101669. get alphaColor(): NodeMaterialConnectionPoint;
  101670. /**
  101671. * Gets the blendColor output component
  101672. */
  101673. get blendColor(): NodeMaterialConnectionPoint;
  101674. /**
  101675. * Initialize the block and prepare the context for build
  101676. * @param state defines the state that will be used for the build
  101677. */
  101678. initialize(state: NodeMaterialBuildState): void;
  101679. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  101680. }
  101681. }
  101682. declare module BABYLON {
  101683. /**
  101684. * Block used to create a Vector2/3/4 out of individual inputs (one for each component)
  101685. */
  101686. export class VectorMergerBlock extends NodeMaterialBlock {
  101687. /**
  101688. * Create a new VectorMergerBlock
  101689. * @param name defines the block name
  101690. */
  101691. constructor(name: string);
  101692. /**
  101693. * Gets the current class name
  101694. * @returns the class name
  101695. */
  101696. getClassName(): string;
  101697. /**
  101698. * Gets the xyz component (input)
  101699. */
  101700. get xyzIn(): NodeMaterialConnectionPoint;
  101701. /**
  101702. * Gets the xy component (input)
  101703. */
  101704. get xyIn(): NodeMaterialConnectionPoint;
  101705. /**
  101706. * Gets the x component (input)
  101707. */
  101708. get x(): NodeMaterialConnectionPoint;
  101709. /**
  101710. * Gets the y component (input)
  101711. */
  101712. get y(): NodeMaterialConnectionPoint;
  101713. /**
  101714. * Gets the z component (input)
  101715. */
  101716. get z(): NodeMaterialConnectionPoint;
  101717. /**
  101718. * Gets the w component (input)
  101719. */
  101720. get w(): NodeMaterialConnectionPoint;
  101721. /**
  101722. * Gets the xyzw component (output)
  101723. */
  101724. get xyzw(): NodeMaterialConnectionPoint;
  101725. /**
  101726. * Gets the xyz component (output)
  101727. */
  101728. get xyzOut(): NodeMaterialConnectionPoint;
  101729. /**
  101730. * Gets the xy component (output)
  101731. */
  101732. get xyOut(): NodeMaterialConnectionPoint;
  101733. /**
  101734. * Gets the xy component (output)
  101735. * @deprecated Please use xyOut instead.
  101736. */
  101737. get xy(): NodeMaterialConnectionPoint;
  101738. /**
  101739. * Gets the xyz component (output)
  101740. * @deprecated Please use xyzOut instead.
  101741. */
  101742. get xyz(): NodeMaterialConnectionPoint;
  101743. protected _buildBlock(state: NodeMaterialBuildState): this;
  101744. }
  101745. }
  101746. declare module BABYLON {
  101747. /**
  101748. * Block used to remap a float from a range to a new one
  101749. */
  101750. export class RemapBlock extends NodeMaterialBlock {
  101751. /**
  101752. * Gets or sets the source range
  101753. */
  101754. sourceRange: Vector2;
  101755. /**
  101756. * Gets or sets the target range
  101757. */
  101758. targetRange: Vector2;
  101759. /**
  101760. * Creates a new RemapBlock
  101761. * @param name defines the block name
  101762. */
  101763. constructor(name: string);
  101764. /**
  101765. * Gets the current class name
  101766. * @returns the class name
  101767. */
  101768. getClassName(): string;
  101769. /**
  101770. * Gets the input component
  101771. */
  101772. get input(): NodeMaterialConnectionPoint;
  101773. /**
  101774. * Gets the source min input component
  101775. */
  101776. get sourceMin(): NodeMaterialConnectionPoint;
  101777. /**
  101778. * Gets the source max input component
  101779. */
  101780. get sourceMax(): NodeMaterialConnectionPoint;
  101781. /**
  101782. * Gets the target min input component
  101783. */
  101784. get targetMin(): NodeMaterialConnectionPoint;
  101785. /**
  101786. * Gets the target max input component
  101787. */
  101788. get targetMax(): NodeMaterialConnectionPoint;
  101789. /**
  101790. * Gets the output component
  101791. */
  101792. get output(): NodeMaterialConnectionPoint;
  101793. protected _buildBlock(state: NodeMaterialBuildState): this;
  101794. protected _dumpPropertiesCode(): string;
  101795. serialize(): any;
  101796. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  101797. }
  101798. }
  101799. declare module BABYLON {
  101800. /**
  101801. * Block used to multiply 2 values
  101802. */
  101803. export class MultiplyBlock extends NodeMaterialBlock {
  101804. /**
  101805. * Creates a new MultiplyBlock
  101806. * @param name defines the block name
  101807. */
  101808. constructor(name: string);
  101809. /**
  101810. * Gets the current class name
  101811. * @returns the class name
  101812. */
  101813. getClassName(): string;
  101814. /**
  101815. * Gets the left operand input component
  101816. */
  101817. get left(): NodeMaterialConnectionPoint;
  101818. /**
  101819. * Gets the right operand input component
  101820. */
  101821. get right(): NodeMaterialConnectionPoint;
  101822. /**
  101823. * Gets the output component
  101824. */
  101825. get output(): NodeMaterialConnectionPoint;
  101826. protected _buildBlock(state: NodeMaterialBuildState): this;
  101827. }
  101828. }
  101829. declare module BABYLON {
  101830. /**
  101831. * Block used to expand a Color3/4 into 4 outputs (one for each component)
  101832. */
  101833. export class ColorSplitterBlock extends NodeMaterialBlock {
  101834. /**
  101835. * Create a new ColorSplitterBlock
  101836. * @param name defines the block name
  101837. */
  101838. constructor(name: string);
  101839. /**
  101840. * Gets the current class name
  101841. * @returns the class name
  101842. */
  101843. getClassName(): string;
  101844. /**
  101845. * Gets the rgba component (input)
  101846. */
  101847. get rgba(): NodeMaterialConnectionPoint;
  101848. /**
  101849. * Gets the rgb component (input)
  101850. */
  101851. get rgbIn(): NodeMaterialConnectionPoint;
  101852. /**
  101853. * Gets the rgb component (output)
  101854. */
  101855. get rgbOut(): NodeMaterialConnectionPoint;
  101856. /**
  101857. * Gets the r component (output)
  101858. */
  101859. get r(): NodeMaterialConnectionPoint;
  101860. /**
  101861. * Gets the g component (output)
  101862. */
  101863. get g(): NodeMaterialConnectionPoint;
  101864. /**
  101865. * Gets the b component (output)
  101866. */
  101867. get b(): NodeMaterialConnectionPoint;
  101868. /**
  101869. * Gets the a component (output)
  101870. */
  101871. get a(): NodeMaterialConnectionPoint;
  101872. protected _inputRename(name: string): string;
  101873. protected _outputRename(name: string): string;
  101874. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  101875. }
  101876. }
  101877. declare module BABYLON {
  101878. /**
  101879. * Interface used to configure the node material editor
  101880. */
  101881. export interface INodeMaterialEditorOptions {
  101882. /** Define the URl to load node editor script */
  101883. editorURL?: string;
  101884. }
  101885. /** @hidden */
  101886. export class NodeMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  101887. NORMAL: boolean;
  101888. TANGENT: boolean;
  101889. UV1: boolean;
  101890. /** BONES */
  101891. NUM_BONE_INFLUENCERS: number;
  101892. BonesPerMesh: number;
  101893. BONETEXTURE: boolean;
  101894. /** MORPH TARGETS */
  101895. MORPHTARGETS: boolean;
  101896. MORPHTARGETS_NORMAL: boolean;
  101897. MORPHTARGETS_TANGENT: boolean;
  101898. MORPHTARGETS_UV: boolean;
  101899. NUM_MORPH_INFLUENCERS: number;
  101900. /** IMAGE PROCESSING */
  101901. IMAGEPROCESSING: boolean;
  101902. VIGNETTE: boolean;
  101903. VIGNETTEBLENDMODEMULTIPLY: boolean;
  101904. VIGNETTEBLENDMODEOPAQUE: boolean;
  101905. TONEMAPPING: boolean;
  101906. TONEMAPPING_ACES: boolean;
  101907. CONTRAST: boolean;
  101908. EXPOSURE: boolean;
  101909. COLORCURVES: boolean;
  101910. COLORGRADING: boolean;
  101911. COLORGRADING3D: boolean;
  101912. SAMPLER3DGREENDEPTH: boolean;
  101913. SAMPLER3DBGRMAP: boolean;
  101914. IMAGEPROCESSINGPOSTPROCESS: boolean;
  101915. /** MISC. */
  101916. BUMPDIRECTUV: number;
  101917. constructor();
  101918. setValue(name: string, value: any, markAsUnprocessedIfDirty?: boolean): void;
  101919. }
  101920. /**
  101921. * Class used to configure NodeMaterial
  101922. */
  101923. export interface INodeMaterialOptions {
  101924. /**
  101925. * Defines if blocks should emit comments
  101926. */
  101927. emitComments: boolean;
  101928. }
  101929. /**
  101930. * Class used to create a node based material built by assembling shader blocks
  101931. */
  101932. export class NodeMaterial extends PushMaterial {
  101933. private static _BuildIdGenerator;
  101934. private _options;
  101935. private _vertexCompilationState;
  101936. private _fragmentCompilationState;
  101937. private _sharedData;
  101938. private _buildId;
  101939. private _buildWasSuccessful;
  101940. private _cachedWorldViewMatrix;
  101941. private _cachedWorldViewProjectionMatrix;
  101942. private _optimizers;
  101943. private _animationFrame;
  101944. /** Define the Url to load node editor script */
  101945. static EditorURL: string;
  101946. /** Define the Url to load snippets */
  101947. static SnippetUrl: string;
  101948. /** Gets or sets a boolean indicating that node materials should not deserialize textures from json / snippet content */
  101949. static IgnoreTexturesAtLoadTime: boolean;
  101950. private BJSNODEMATERIALEDITOR;
  101951. /** Get the inspector from bundle or global */
  101952. private _getGlobalNodeMaterialEditor;
  101953. /**
  101954. * Snippet ID if the material was created from the snippet server
  101955. */
  101956. snippetId: string;
  101957. /**
  101958. * Gets or sets data used by visual editor
  101959. * @see https://nme.babylonjs.com
  101960. */
  101961. editorData: any;
  101962. /**
  101963. * 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)
  101964. */
  101965. ignoreAlpha: boolean;
  101966. /**
  101967. * Defines the maximum number of lights that can be used in the material
  101968. */
  101969. maxSimultaneousLights: number;
  101970. /**
  101971. * Observable raised when the material is built
  101972. */
  101973. onBuildObservable: Observable<NodeMaterial>;
  101974. /**
  101975. * Gets or sets the root nodes of the material vertex shader
  101976. */
  101977. _vertexOutputNodes: NodeMaterialBlock[];
  101978. /**
  101979. * Gets or sets the root nodes of the material fragment (pixel) shader
  101980. */
  101981. _fragmentOutputNodes: NodeMaterialBlock[];
  101982. /** Gets or sets options to control the node material overall behavior */
  101983. get options(): INodeMaterialOptions;
  101984. set options(options: INodeMaterialOptions);
  101985. /**
  101986. * Default configuration related to image processing available in the standard Material.
  101987. */
  101988. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  101989. /**
  101990. * Gets the image processing configuration used either in this material.
  101991. */
  101992. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  101993. /**
  101994. * Sets the Default image processing configuration used either in the this material.
  101995. *
  101996. * If sets to null, the scene one is in use.
  101997. */
  101998. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  101999. /**
  102000. * Gets an array of blocks that needs to be serialized even if they are not yet connected
  102001. */
  102002. attachedBlocks: NodeMaterialBlock[];
  102003. /**
  102004. * Specifies the mode of the node material
  102005. * @hidden
  102006. */
  102007. _mode: NodeMaterialModes;
  102008. /**
  102009. * Gets the mode property
  102010. */
  102011. get mode(): NodeMaterialModes;
  102012. /**
  102013. * Create a new node based material
  102014. * @param name defines the material name
  102015. * @param scene defines the hosting scene
  102016. * @param options defines creation option
  102017. */
  102018. constructor(name: string, scene?: Scene, options?: Partial<INodeMaterialOptions>);
  102019. /**
  102020. * Gets the current class name of the material e.g. "NodeMaterial"
  102021. * @returns the class name
  102022. */
  102023. getClassName(): string;
  102024. /**
  102025. * Keep track of the image processing observer to allow dispose and replace.
  102026. */
  102027. private _imageProcessingObserver;
  102028. /**
  102029. * Attaches a new image processing configuration to the Standard Material.
  102030. * @param configuration
  102031. */
  102032. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  102033. /**
  102034. * Get a block by its name
  102035. * @param name defines the name of the block to retrieve
  102036. * @returns the required block or null if not found
  102037. */
  102038. getBlockByName(name: string): Nullable<NodeMaterialBlock>;
  102039. /**
  102040. * Get a block by its name
  102041. * @param predicate defines the predicate used to find the good candidate
  102042. * @returns the required block or null if not found
  102043. */
  102044. getBlockByPredicate(predicate: (block: NodeMaterialBlock) => boolean): Nullable<NodeMaterialBlock>;
  102045. /**
  102046. * Get an input block by its name
  102047. * @param predicate defines the predicate used to find the good candidate
  102048. * @returns the required input block or null if not found
  102049. */
  102050. getInputBlockByPredicate(predicate: (block: InputBlock) => boolean): Nullable<InputBlock>;
  102051. /**
  102052. * Gets the list of input blocks attached to this material
  102053. * @returns an array of InputBlocks
  102054. */
  102055. getInputBlocks(): InputBlock[];
  102056. /**
  102057. * Adds a new optimizer to the list of optimizers
  102058. * @param optimizer defines the optimizers to add
  102059. * @returns the current material
  102060. */
  102061. registerOptimizer(optimizer: NodeMaterialOptimizer): this | undefined;
  102062. /**
  102063. * Remove an optimizer from the list of optimizers
  102064. * @param optimizer defines the optimizers to remove
  102065. * @returns the current material
  102066. */
  102067. unregisterOptimizer(optimizer: NodeMaterialOptimizer): this | undefined;
  102068. /**
  102069. * Add a new block to the list of output nodes
  102070. * @param node defines the node to add
  102071. * @returns the current material
  102072. */
  102073. addOutputNode(node: NodeMaterialBlock): this;
  102074. /**
  102075. * Remove a block from the list of root nodes
  102076. * @param node defines the node to remove
  102077. * @returns the current material
  102078. */
  102079. removeOutputNode(node: NodeMaterialBlock): this;
  102080. private _addVertexOutputNode;
  102081. private _removeVertexOutputNode;
  102082. private _addFragmentOutputNode;
  102083. private _removeFragmentOutputNode;
  102084. /**
  102085. * Specifies if the material will require alpha blending
  102086. * @returns a boolean specifying if alpha blending is needed
  102087. */
  102088. needAlphaBlending(): boolean;
  102089. /**
  102090. * Specifies if this material should be rendered in alpha test mode
  102091. * @returns a boolean specifying if an alpha test is needed.
  102092. */
  102093. needAlphaTesting(): boolean;
  102094. private _initializeBlock;
  102095. private _resetDualBlocks;
  102096. /**
  102097. * Remove a block from the current node material
  102098. * @param block defines the block to remove
  102099. */
  102100. removeBlock(block: NodeMaterialBlock): void;
  102101. /**
  102102. * Build the material and generates the inner effect
  102103. * @param verbose defines if the build should log activity
  102104. */
  102105. build(verbose?: boolean): void;
  102106. /**
  102107. * Runs an otpimization phase to try to improve the shader code
  102108. */
  102109. optimize(): void;
  102110. private _prepareDefinesForAttributes;
  102111. /**
  102112. * Create a post process from the material
  102113. * @param camera The camera to apply the render pass to.
  102114. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  102115. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  102116. * @param engine The engine which the post process will be applied. (default: current engine)
  102117. * @param reusable If the post process can be reused on the same frame. (default: false)
  102118. * @param textureType Type of textures used when performing the post process. (default: 0)
  102119. * @param textureFormat Format of textures used when performing the post process. (default: TEXTUREFORMAT_RGBA)
  102120. * @returns the post process created
  102121. */
  102122. createPostProcess(camera: Nullable<Camera>, options?: number | PostProcessOptions, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, textureFormat?: number): PostProcess;
  102123. /**
  102124. * Create the post process effect from the material
  102125. * @param postProcess The post process to create the effect for
  102126. */
  102127. createEffectForPostProcess(postProcess: PostProcess): void;
  102128. private _createEffectOrPostProcess;
  102129. private _createEffectForParticles;
  102130. /**
  102131. * Create the effect to be used as the custom effect for a particle system
  102132. * @param particleSystem Particle system to create the effect for
  102133. * @param onCompiled defines a function to call when the effect creation is successful
  102134. * @param onError defines a function to call when the effect creation has failed
  102135. */
  102136. createEffectForParticles(particleSystem: IParticleSystem, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  102137. private _processDefines;
  102138. /**
  102139. * Get if the submesh is ready to be used and all its information available.
  102140. * Child classes can use it to update shaders
  102141. * @param mesh defines the mesh to check
  102142. * @param subMesh defines which submesh to check
  102143. * @param useInstances specifies that instances should be used
  102144. * @returns a boolean indicating that the submesh is ready or not
  102145. */
  102146. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  102147. /**
  102148. * Get a string representing the shaders built by the current node graph
  102149. */
  102150. get compiledShaders(): string;
  102151. /**
  102152. * Binds the world matrix to the material
  102153. * @param world defines the world transformation matrix
  102154. */
  102155. bindOnlyWorldMatrix(world: Matrix): void;
  102156. /**
  102157. * Binds the submesh to this material by preparing the effect and shader to draw
  102158. * @param world defines the world transformation matrix
  102159. * @param mesh defines the mesh containing the submesh
  102160. * @param subMesh defines the submesh to bind the material to
  102161. */
  102162. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  102163. /**
  102164. * Gets the active textures from the material
  102165. * @returns an array of textures
  102166. */
  102167. getActiveTextures(): BaseTexture[];
  102168. /**
  102169. * Gets the list of texture blocks
  102170. * @returns an array of texture blocks
  102171. */
  102172. getTextureBlocks(): (TextureBlock | ReflectionTextureBaseBlock | RefractionBlock | CurrentScreenBlock | ParticleTextureBlock)[];
  102173. /**
  102174. * Specifies if the material uses a texture
  102175. * @param texture defines the texture to check against the material
  102176. * @returns a boolean specifying if the material uses the texture
  102177. */
  102178. hasTexture(texture: BaseTexture): boolean;
  102179. /**
  102180. * Disposes the material
  102181. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  102182. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  102183. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  102184. */
  102185. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  102186. /** Creates the node editor window. */
  102187. private _createNodeEditor;
  102188. /**
  102189. * Launch the node material editor
  102190. * @param config Define the configuration of the editor
  102191. * @return a promise fulfilled when the node editor is visible
  102192. */
  102193. edit(config?: INodeMaterialEditorOptions): Promise<void>;
  102194. /**
  102195. * Clear the current material
  102196. */
  102197. clear(): void;
  102198. /**
  102199. * Clear the current material and set it to a default state
  102200. */
  102201. setToDefault(): void;
  102202. /**
  102203. * Clear the current material and set it to a default state for post process
  102204. */
  102205. setToDefaultPostProcess(): void;
  102206. /**
  102207. * Clear the current material and set it to a default state for particle
  102208. */
  102209. setToDefaultParticle(): void;
  102210. /**
  102211. * Loads the current Node Material from a url pointing to a file save by the Node Material Editor
  102212. * @param url defines the url to load from
  102213. * @returns a promise that will fullfil when the material is fully loaded
  102214. */
  102215. loadAsync(url: string): Promise<void>;
  102216. private _gatherBlocks;
  102217. /**
  102218. * Generate a string containing the code declaration required to create an equivalent of this material
  102219. * @returns a string
  102220. */
  102221. generateCode(): string;
  102222. /**
  102223. * Serializes this material in a JSON representation
  102224. * @returns the serialized material object
  102225. */
  102226. serialize(selectedBlocks?: NodeMaterialBlock[]): any;
  102227. private _restoreConnections;
  102228. /**
  102229. * Clear the current graph and load a new one from a serialization object
  102230. * @param source defines the JSON representation of the material
  102231. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  102232. * @param merge defines whether or not the source must be merged or replace the current content
  102233. */
  102234. loadFromSerialization(source: any, rootUrl?: string, merge?: boolean): void;
  102235. /**
  102236. * Makes a duplicate of the current material.
  102237. * @param name - name to use for the new material.
  102238. */
  102239. clone(name: string): NodeMaterial;
  102240. /**
  102241. * Creates a node material from parsed material data
  102242. * @param source defines the JSON representation of the material
  102243. * @param scene defines the hosting scene
  102244. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  102245. * @returns a new node material
  102246. */
  102247. static Parse(source: any, scene: Scene, rootUrl?: string): NodeMaterial;
  102248. /**
  102249. * Creates a node material from a snippet saved in a remote file
  102250. * @param name defines the name of the material to create
  102251. * @param url defines the url to load from
  102252. * @param scene defines the hosting scene
  102253. * @returns a promise that will resolve to the new node material
  102254. */
  102255. static ParseFromFileAsync(name: string, url: string, scene: Scene): Promise<NodeMaterial>;
  102256. /**
  102257. * Creates a node material from a snippet saved by the node material editor
  102258. * @param snippetId defines the snippet to load
  102259. * @param scene defines the hosting scene
  102260. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  102261. * @param nodeMaterial defines a node material to update (instead of creating a new one)
  102262. * @returns a promise that will resolve to the new node material
  102263. */
  102264. static ParseFromSnippetAsync(snippetId: string, scene: Scene, rootUrl?: string, nodeMaterial?: NodeMaterial): Promise<NodeMaterial>;
  102265. /**
  102266. * Creates a new node material set to default basic configuration
  102267. * @param name defines the name of the material
  102268. * @param scene defines the hosting scene
  102269. * @returns a new NodeMaterial
  102270. */
  102271. static CreateDefault(name: string, scene?: Scene): NodeMaterial;
  102272. }
  102273. }
  102274. declare module BABYLON {
  102275. /**
  102276. * Size options for a post process
  102277. */
  102278. export type PostProcessOptions = {
  102279. width: number;
  102280. height: number;
  102281. };
  102282. /**
  102283. * PostProcess can be used to apply a shader to a texture after it has been rendered
  102284. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  102285. */
  102286. export class PostProcess {
  102287. /**
  102288. * Gets or sets the unique id of the post process
  102289. */
  102290. uniqueId: number;
  102291. /** Name of the PostProcess. */
  102292. name: string;
  102293. /**
  102294. * Width of the texture to apply the post process on
  102295. */
  102296. width: number;
  102297. /**
  102298. * Height of the texture to apply the post process on
  102299. */
  102300. height: number;
  102301. /**
  102302. * Gets the node material used to create this postprocess (null if the postprocess was manually created)
  102303. */
  102304. nodeMaterialSource: Nullable<NodeMaterial>;
  102305. /**
  102306. * Internal, reference to the location where this postprocess was output to. (Typically the texture on the next postprocess in the chain)
  102307. * @hidden
  102308. */
  102309. _outputTexture: Nullable<InternalTexture>;
  102310. /**
  102311. * Sampling mode used by the shader
  102312. * See https://doc.babylonjs.com/classes/3.1/texture
  102313. */
  102314. renderTargetSamplingMode: number;
  102315. /**
  102316. * Clear color to use when screen clearing
  102317. */
  102318. clearColor: Color4;
  102319. /**
  102320. * If the buffer needs to be cleared before applying the post process. (default: true)
  102321. * Should be set to false if shader will overwrite all previous pixels.
  102322. */
  102323. autoClear: boolean;
  102324. /**
  102325. * Type of alpha mode to use when performing the post process (default: Engine.ALPHA_DISABLE)
  102326. */
  102327. alphaMode: number;
  102328. /**
  102329. * Sets the setAlphaBlendConstants of the babylon engine
  102330. */
  102331. alphaConstants: Color4;
  102332. /**
  102333. * Animations to be used for the post processing
  102334. */
  102335. animations: Animation[];
  102336. /**
  102337. * Enable Pixel Perfect mode where texture is not scaled to be power of 2.
  102338. * Can only be used on a single postprocess or on the last one of a chain. (default: false)
  102339. */
  102340. enablePixelPerfectMode: boolean;
  102341. /**
  102342. * Force the postprocess to be applied without taking in account viewport
  102343. */
  102344. forceFullscreenViewport: boolean;
  102345. /**
  102346. * List of inspectable custom properties (used by the Inspector)
  102347. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  102348. */
  102349. inspectableCustomProperties: IInspectable[];
  102350. /**
  102351. * Scale mode for the post process (default: Engine.SCALEMODE_FLOOR)
  102352. *
  102353. * | Value | Type | Description |
  102354. * | ----- | ----------------------------------- | ----------- |
  102355. * | 1 | SCALEMODE_FLOOR | [engine.scalemode_floor](https://doc.babylonjs.com/api/classes/babylon.engine#scalemode_floor) |
  102356. * | 2 | SCALEMODE_NEAREST | [engine.scalemode_nearest](https://doc.babylonjs.com/api/classes/babylon.engine#scalemode_nearest) |
  102357. * | 3 | SCALEMODE_CEILING | [engine.scalemode_ceiling](https://doc.babylonjs.com/api/classes/babylon.engine#scalemode_ceiling) |
  102358. *
  102359. */
  102360. scaleMode: number;
  102361. /**
  102362. * Force textures to be a power of two (default: false)
  102363. */
  102364. alwaysForcePOT: boolean;
  102365. private _samples;
  102366. /**
  102367. * Number of sample textures (default: 1)
  102368. */
  102369. get samples(): number;
  102370. set samples(n: number);
  102371. /**
  102372. * Modify the scale of the post process to be the same as the viewport (default: false)
  102373. */
  102374. adaptScaleToCurrentViewport: boolean;
  102375. private _camera;
  102376. protected _scene: Scene;
  102377. private _engine;
  102378. private _options;
  102379. private _reusable;
  102380. private _textureType;
  102381. private _textureFormat;
  102382. /**
  102383. * Smart array of input and output textures for the post process.
  102384. * @hidden
  102385. */
  102386. _textures: SmartArray<InternalTexture>;
  102387. /**
  102388. * The index in _textures that corresponds to the output texture.
  102389. * @hidden
  102390. */
  102391. _currentRenderTextureInd: number;
  102392. private _effect;
  102393. private _samplers;
  102394. private _fragmentUrl;
  102395. private _vertexUrl;
  102396. private _parameters;
  102397. private _scaleRatio;
  102398. protected _indexParameters: any;
  102399. private _shareOutputWithPostProcess;
  102400. private _texelSize;
  102401. private _forcedOutputTexture;
  102402. /**
  102403. * Returns the fragment url or shader name used in the post process.
  102404. * @returns the fragment url or name in the shader store.
  102405. */
  102406. getEffectName(): string;
  102407. /**
  102408. * An event triggered when the postprocess is activated.
  102409. */
  102410. onActivateObservable: Observable<Camera>;
  102411. private _onActivateObserver;
  102412. /**
  102413. * A function that is added to the onActivateObservable
  102414. */
  102415. set onActivate(callback: Nullable<(camera: Camera) => void>);
  102416. /**
  102417. * An event triggered when the postprocess changes its size.
  102418. */
  102419. onSizeChangedObservable: Observable<PostProcess>;
  102420. private _onSizeChangedObserver;
  102421. /**
  102422. * A function that is added to the onSizeChangedObservable
  102423. */
  102424. set onSizeChanged(callback: (postProcess: PostProcess) => void);
  102425. /**
  102426. * An event triggered when the postprocess applies its effect.
  102427. */
  102428. onApplyObservable: Observable<Effect>;
  102429. private _onApplyObserver;
  102430. /**
  102431. * A function that is added to the onApplyObservable
  102432. */
  102433. set onApply(callback: (effect: Effect) => void);
  102434. /**
  102435. * An event triggered before rendering the postprocess
  102436. */
  102437. onBeforeRenderObservable: Observable<Effect>;
  102438. private _onBeforeRenderObserver;
  102439. /**
  102440. * A function that is added to the onBeforeRenderObservable
  102441. */
  102442. set onBeforeRender(callback: (effect: Effect) => void);
  102443. /**
  102444. * An event triggered after rendering the postprocess
  102445. */
  102446. onAfterRenderObservable: Observable<Effect>;
  102447. private _onAfterRenderObserver;
  102448. /**
  102449. * A function that is added to the onAfterRenderObservable
  102450. */
  102451. set onAfterRender(callback: (efect: Effect) => void);
  102452. /**
  102453. * 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
  102454. * render it's output into this texture and this texture will be used as textureSampler in the fragment shader of this post process.
  102455. */
  102456. get inputTexture(): InternalTexture;
  102457. set inputTexture(value: InternalTexture);
  102458. /**
  102459. * Since inputTexture should always be defined, if we previously manually set `inputTexture`,
  102460. * the only way to unset it is to use this function to restore its internal state
  102461. */
  102462. restoreDefaultInputTexture(): void;
  102463. /**
  102464. * Gets the camera which post process is applied to.
  102465. * @returns The camera the post process is applied to.
  102466. */
  102467. getCamera(): Camera;
  102468. /**
  102469. * Gets the texel size of the postprocess.
  102470. * See https://en.wikipedia.org/wiki/Texel_(graphics)
  102471. */
  102472. get texelSize(): Vector2;
  102473. /**
  102474. * Creates a new instance PostProcess
  102475. * @param name The name of the PostProcess.
  102476. * @param fragmentUrl The url of the fragment shader to be used.
  102477. * @param parameters Array of the names of uniform non-sampler2D variables that will be passed to the shader.
  102478. * @param samplers Array of the names of uniform sampler2D variables that will be passed to the shader.
  102479. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  102480. * @param camera The camera to apply the render pass to.
  102481. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  102482. * @param engine The engine which the post process will be applied. (default: current engine)
  102483. * @param reusable If the post process can be reused on the same frame. (default: false)
  102484. * @param defines String of defines that will be set when running the fragment shader. (default: null)
  102485. * @param textureType Type of textures used when performing the post process. (default: 0)
  102486. * @param vertexUrl The url of the vertex shader to be used. (default: "postprocess")
  102487. * @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
  102488. * @param blockCompilation If the shader should not be compiled imediatly. (default: false)
  102489. * @param textureFormat Format of textures used when performing the post process. (default: TEXTUREFORMAT_RGBA)
  102490. */
  102491. 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);
  102492. /**
  102493. * Gets a string identifying the name of the class
  102494. * @returns "PostProcess" string
  102495. */
  102496. getClassName(): string;
  102497. /**
  102498. * Gets the engine which this post process belongs to.
  102499. * @returns The engine the post process was enabled with.
  102500. */
  102501. getEngine(): Engine;
  102502. /**
  102503. * The effect that is created when initializing the post process.
  102504. * @returns The created effect corresponding the the postprocess.
  102505. */
  102506. getEffect(): Effect;
  102507. /**
  102508. * To avoid multiple redundant textures for multiple post process, the output the output texture for this post process can be shared with another.
  102509. * @param postProcess The post process to share the output with.
  102510. * @returns This post process.
  102511. */
  102512. shareOutputWith(postProcess: PostProcess): PostProcess;
  102513. /**
  102514. * Reverses the effect of calling shareOutputWith and returns the post process back to its original state.
  102515. * This should be called if the post process that shares output with this post process is disabled/disposed.
  102516. */
  102517. useOwnOutput(): void;
  102518. /**
  102519. * Updates the effect with the current post process compile time values and recompiles the shader.
  102520. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  102521. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  102522. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  102523. * @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
  102524. * @param onCompiled Called when the shader has been compiled.
  102525. * @param onError Called if there is an error when compiling a shader.
  102526. * @param vertexUrl The url of the vertex shader to be used (default: the one given at construction time)
  102527. * @param fragmentUrl The url of the fragment shader to be used (default: the one given at construction time)
  102528. */
  102529. 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;
  102530. /**
  102531. * The post process is reusable if it can be used multiple times within one frame.
  102532. * @returns If the post process is reusable
  102533. */
  102534. isReusable(): boolean;
  102535. /** invalidate frameBuffer to hint the postprocess to create a depth buffer */
  102536. markTextureDirty(): void;
  102537. /**
  102538. * Activates the post process by intializing the textures to be used when executed. Notifies onActivateObservable.
  102539. * 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.
  102540. * @param camera The camera that will be used in the post process. This camera will be used when calling onActivateObservable.
  102541. * @param sourceTexture The source texture to be inspected to get the width and height if not specified in the post process constructor. (default: null)
  102542. * @param forceDepthStencil If true, a depth and stencil buffer will be generated. (default: false)
  102543. * @returns The target texture that was bound to be written to.
  102544. */
  102545. activate(camera: Nullable<Camera>, sourceTexture?: Nullable<InternalTexture>, forceDepthStencil?: boolean): InternalTexture;
  102546. /**
  102547. * If the post process is supported.
  102548. */
  102549. get isSupported(): boolean;
  102550. /**
  102551. * The aspect ratio of the output texture.
  102552. */
  102553. get aspectRatio(): number;
  102554. /**
  102555. * Get a value indicating if the post-process is ready to be used
  102556. * @returns true if the post-process is ready (shader is compiled)
  102557. */
  102558. isReady(): boolean;
  102559. /**
  102560. * Binds all textures and uniforms to the shader, this will be run on every pass.
  102561. * @returns the effect corresponding to this post process. Null if not compiled or not ready.
  102562. */
  102563. apply(): Nullable<Effect>;
  102564. private _disposeTextures;
  102565. /**
  102566. * Disposes the post process.
  102567. * @param camera The camera to dispose the post process on.
  102568. */
  102569. dispose(camera?: Camera): void;
  102570. /**
  102571. * Serializes the particle system to a JSON object
  102572. * @returns the JSON object
  102573. */
  102574. serialize(): any;
  102575. /**
  102576. * Creates a material from parsed material data
  102577. * @param parsedPostProcess defines parsed post process data
  102578. * @param scene defines the hosting scene
  102579. * @param rootUrl defines the root URL to use to load textures
  102580. * @returns a new post process
  102581. */
  102582. static Parse(parsedPostProcess: any, scene: Scene, rootUrl: string): Nullable<PostProcess>;
  102583. }
  102584. }
  102585. declare module BABYLON {
  102586. /** @hidden */
  102587. export var kernelBlurVaryingDeclaration: {
  102588. name: string;
  102589. shader: string;
  102590. };
  102591. }
  102592. declare module BABYLON {
  102593. /** @hidden */
  102594. export var kernelBlurFragment: {
  102595. name: string;
  102596. shader: string;
  102597. };
  102598. }
  102599. declare module BABYLON {
  102600. /** @hidden */
  102601. export var kernelBlurFragment2: {
  102602. name: string;
  102603. shader: string;
  102604. };
  102605. }
  102606. declare module BABYLON {
  102607. /** @hidden */
  102608. export var kernelBlurPixelShader: {
  102609. name: string;
  102610. shader: string;
  102611. };
  102612. }
  102613. declare module BABYLON {
  102614. /** @hidden */
  102615. export var kernelBlurVertex: {
  102616. name: string;
  102617. shader: string;
  102618. };
  102619. }
  102620. declare module BABYLON {
  102621. /** @hidden */
  102622. export var kernelBlurVertexShader: {
  102623. name: string;
  102624. shader: string;
  102625. };
  102626. }
  102627. declare module BABYLON {
  102628. /**
  102629. * The Blur Post Process which blurs an image based on a kernel and direction.
  102630. * Can be used twice in x and y directions to perform a guassian blur in two passes.
  102631. */
  102632. export class BlurPostProcess extends PostProcess {
  102633. private blockCompilation;
  102634. protected _kernel: number;
  102635. protected _idealKernel: number;
  102636. protected _packedFloat: boolean;
  102637. private _staticDefines;
  102638. /** The direction in which to blur the image. */
  102639. direction: Vector2;
  102640. /**
  102641. * Sets the length in pixels of the blur sample region
  102642. */
  102643. set kernel(v: number);
  102644. /**
  102645. * Gets the length in pixels of the blur sample region
  102646. */
  102647. get kernel(): number;
  102648. /**
  102649. * Sets wether or not the blur needs to unpack/repack floats
  102650. */
  102651. set packedFloat(v: boolean);
  102652. /**
  102653. * Gets wether or not the blur is unpacking/repacking floats
  102654. */
  102655. get packedFloat(): boolean;
  102656. /**
  102657. * Gets a string identifying the name of the class
  102658. * @returns "BlurPostProcess" string
  102659. */
  102660. getClassName(): string;
  102661. /**
  102662. * Creates a new instance BlurPostProcess
  102663. * @param name The name of the effect.
  102664. * @param direction The direction in which to blur the image.
  102665. * @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.
  102666. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  102667. * @param camera The camera to apply the render pass to.
  102668. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  102669. * @param engine The engine which the post process will be applied. (default: current engine)
  102670. * @param reusable If the post process can be reused on the same frame. (default: false)
  102671. * @param textureType Type of textures used when performing the post process. (default: 0)
  102672. * @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)
  102673. */
  102674. 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);
  102675. /**
  102676. * Updates the effect with the current post process compile time values and recompiles the shader.
  102677. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  102678. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  102679. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  102680. * @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
  102681. * @param onCompiled Called when the shader has been compiled.
  102682. * @param onError Called if there is an error when compiling a shader.
  102683. */
  102684. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  102685. protected _updateParameters(onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  102686. /**
  102687. * Best kernels are odd numbers that when divided by 2, their integer part is even, so 5, 9 or 13.
  102688. * Other odd kernels optimize correctly but require proportionally more samples, even kernels are
  102689. * possible but will produce minor visual artifacts. Since each new kernel requires a new shader we
  102690. * want to minimize kernel changes, having gaps between physical kernels is helpful in that regard.
  102691. * The gaps between physical kernels are compensated for in the weighting of the samples
  102692. * @param idealKernel Ideal blur kernel.
  102693. * @return Nearest best kernel.
  102694. */
  102695. protected _nearestBestKernel(idealKernel: number): number;
  102696. /**
  102697. * Calculates the value of a Gaussian distribution with sigma 3 at a given point.
  102698. * @param x The point on the Gaussian distribution to sample.
  102699. * @return the value of the Gaussian function at x.
  102700. */
  102701. protected _gaussianWeight(x: number): number;
  102702. /**
  102703. * Generates a string that can be used as a floating point number in GLSL.
  102704. * @param x Value to print.
  102705. * @param decimalFigures Number of decimal places to print the number to (excluding trailing 0s).
  102706. * @return GLSL float string.
  102707. */
  102708. protected _glslFloat(x: number, decimalFigures?: number): string;
  102709. /** @hidden */
  102710. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): Nullable<BlurPostProcess>;
  102711. }
  102712. }
  102713. declare module BABYLON {
  102714. /**
  102715. * Mirror texture can be used to simulate the view from a mirror in a scene.
  102716. * It will dynamically be rendered every frame to adapt to the camera point of view.
  102717. * You can then easily use it as a reflectionTexture on a flat surface.
  102718. * In case the surface is not a plane, please consider relying on reflection probes.
  102719. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  102720. */
  102721. export class MirrorTexture extends RenderTargetTexture {
  102722. private scene;
  102723. /**
  102724. * Define the reflection plane we want to use. The mirrorPlane is usually set to the constructed reflector.
  102725. * 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.
  102726. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  102727. */
  102728. mirrorPlane: Plane;
  102729. /**
  102730. * Define the blur ratio used to blur the reflection if needed.
  102731. */
  102732. set blurRatio(value: number);
  102733. get blurRatio(): number;
  102734. /**
  102735. * Define the adaptive blur kernel used to blur the reflection if needed.
  102736. * This will autocompute the closest best match for the `blurKernel`
  102737. */
  102738. set adaptiveBlurKernel(value: number);
  102739. /**
  102740. * Define the blur kernel used to blur the reflection if needed.
  102741. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  102742. */
  102743. set blurKernel(value: number);
  102744. /**
  102745. * Define the blur kernel on the X Axis used to blur the reflection if needed.
  102746. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  102747. */
  102748. set blurKernelX(value: number);
  102749. get blurKernelX(): number;
  102750. /**
  102751. * Define the blur kernel on the Y Axis used to blur the reflection if needed.
  102752. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  102753. */
  102754. set blurKernelY(value: number);
  102755. get blurKernelY(): number;
  102756. private _autoComputeBlurKernel;
  102757. protected _onRatioRescale(): void;
  102758. private _updateGammaSpace;
  102759. private _imageProcessingConfigChangeObserver;
  102760. private _transformMatrix;
  102761. private _mirrorMatrix;
  102762. private _savedViewMatrix;
  102763. private _blurX;
  102764. private _blurY;
  102765. private _adaptiveBlurKernel;
  102766. private _blurKernelX;
  102767. private _blurKernelY;
  102768. private _blurRatio;
  102769. /**
  102770. * Instantiates a Mirror Texture.
  102771. * Mirror texture can be used to simulate the view from a mirror in a scene.
  102772. * It will dynamically be rendered every frame to adapt to the camera point of view.
  102773. * You can then easily use it as a reflectionTexture on a flat surface.
  102774. * In case the surface is not a plane, please consider relying on reflection probes.
  102775. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  102776. * @param name
  102777. * @param size
  102778. * @param scene
  102779. * @param generateMipMaps
  102780. * @param type
  102781. * @param samplingMode
  102782. * @param generateDepthBuffer
  102783. */
  102784. constructor(name: string, size: number | {
  102785. width: number;
  102786. height: number;
  102787. } | {
  102788. ratio: number;
  102789. }, scene: Scene, generateMipMaps?: boolean, type?: number, samplingMode?: number, generateDepthBuffer?: boolean);
  102790. private _preparePostProcesses;
  102791. /**
  102792. * Clone the mirror texture.
  102793. * @returns the cloned texture
  102794. */
  102795. clone(): MirrorTexture;
  102796. /**
  102797. * Serialize the texture to a JSON representation you could use in Parse later on
  102798. * @returns the serialized JSON representation
  102799. */
  102800. serialize(): any;
  102801. /**
  102802. * Dispose the texture and release its associated resources.
  102803. */
  102804. dispose(): void;
  102805. }
  102806. }
  102807. declare module BABYLON {
  102808. /**
  102809. * This represents a texture in babylon. It can be easily loaded from a network, base64 or html input.
  102810. * @see https://doc.babylonjs.com/babylon101/materials#texture
  102811. */
  102812. export class Texture extends BaseTexture {
  102813. /**
  102814. * Gets or sets a general boolean used to indicate that textures containing direct data (buffers) must be saved as part of the serialization process
  102815. */
  102816. static SerializeBuffers: boolean;
  102817. /** @hidden */
  102818. static _CubeTextureParser: (jsonTexture: any, scene: Scene, rootUrl: string) => CubeTexture;
  102819. /** @hidden */
  102820. static _CreateMirror: (name: string, renderTargetSize: number, scene: Scene, generateMipMaps: boolean) => MirrorTexture;
  102821. /** @hidden */
  102822. static _CreateRenderTargetTexture: (name: string, renderTargetSize: number, scene: Scene, generateMipMaps: boolean) => RenderTargetTexture;
  102823. /** nearest is mag = nearest and min = nearest and mip = linear */
  102824. static readonly NEAREST_SAMPLINGMODE: number;
  102825. /** nearest is mag = nearest and min = nearest and mip = linear */
  102826. static readonly NEAREST_NEAREST_MIPLINEAR: number;
  102827. /** Bilinear is mag = linear and min = linear and mip = nearest */
  102828. static readonly BILINEAR_SAMPLINGMODE: number;
  102829. /** Bilinear is mag = linear and min = linear and mip = nearest */
  102830. static readonly LINEAR_LINEAR_MIPNEAREST: number;
  102831. /** Trilinear is mag = linear and min = linear and mip = linear */
  102832. static readonly TRILINEAR_SAMPLINGMODE: number;
  102833. /** Trilinear is mag = linear and min = linear and mip = linear */
  102834. static readonly LINEAR_LINEAR_MIPLINEAR: number;
  102835. /** mag = nearest and min = nearest and mip = nearest */
  102836. static readonly NEAREST_NEAREST_MIPNEAREST: number;
  102837. /** mag = nearest and min = linear and mip = nearest */
  102838. static readonly NEAREST_LINEAR_MIPNEAREST: number;
  102839. /** mag = nearest and min = linear and mip = linear */
  102840. static readonly NEAREST_LINEAR_MIPLINEAR: number;
  102841. /** mag = nearest and min = linear and mip = none */
  102842. static readonly NEAREST_LINEAR: number;
  102843. /** mag = nearest and min = nearest and mip = none */
  102844. static readonly NEAREST_NEAREST: number;
  102845. /** mag = linear and min = nearest and mip = nearest */
  102846. static readonly LINEAR_NEAREST_MIPNEAREST: number;
  102847. /** mag = linear and min = nearest and mip = linear */
  102848. static readonly LINEAR_NEAREST_MIPLINEAR: number;
  102849. /** mag = linear and min = linear and mip = none */
  102850. static readonly LINEAR_LINEAR: number;
  102851. /** mag = linear and min = nearest and mip = none */
  102852. static readonly LINEAR_NEAREST: number;
  102853. /** Explicit coordinates mode */
  102854. static readonly EXPLICIT_MODE: number;
  102855. /** Spherical coordinates mode */
  102856. static readonly SPHERICAL_MODE: number;
  102857. /** Planar coordinates mode */
  102858. static readonly PLANAR_MODE: number;
  102859. /** Cubic coordinates mode */
  102860. static readonly CUBIC_MODE: number;
  102861. /** Projection coordinates mode */
  102862. static readonly PROJECTION_MODE: number;
  102863. /** Inverse Cubic coordinates mode */
  102864. static readonly SKYBOX_MODE: number;
  102865. /** Inverse Cubic coordinates mode */
  102866. static readonly INVCUBIC_MODE: number;
  102867. /** Equirectangular coordinates mode */
  102868. static readonly EQUIRECTANGULAR_MODE: number;
  102869. /** Equirectangular Fixed coordinates mode */
  102870. static readonly FIXED_EQUIRECTANGULAR_MODE: number;
  102871. /** Equirectangular Fixed Mirrored coordinates mode */
  102872. static readonly FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  102873. /** Texture is not repeating outside of 0..1 UVs */
  102874. static readonly CLAMP_ADDRESSMODE: number;
  102875. /** Texture is repeating outside of 0..1 UVs */
  102876. static readonly WRAP_ADDRESSMODE: number;
  102877. /** Texture is repeating and mirrored */
  102878. static readonly MIRROR_ADDRESSMODE: number;
  102879. /**
  102880. * 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
  102881. */
  102882. static UseSerializedUrlIfAny: boolean;
  102883. /**
  102884. * Define the url of the texture.
  102885. */
  102886. url: Nullable<string>;
  102887. /**
  102888. * Define an offset on the texture to offset the u coordinates of the UVs
  102889. * @see https://doc.babylonjs.com/how_to/more_materials#offsetting
  102890. */
  102891. uOffset: number;
  102892. /**
  102893. * Define an offset on the texture to offset the v coordinates of the UVs
  102894. * @see https://doc.babylonjs.com/how_to/more_materials#offsetting
  102895. */
  102896. vOffset: number;
  102897. /**
  102898. * Define an offset on the texture to scale the u coordinates of the UVs
  102899. * @see https://doc.babylonjs.com/how_to/more_materials#tiling
  102900. */
  102901. uScale: number;
  102902. /**
  102903. * Define an offset on the texture to scale the v coordinates of the UVs
  102904. * @see https://doc.babylonjs.com/how_to/more_materials#tiling
  102905. */
  102906. vScale: number;
  102907. /**
  102908. * Define an offset on the texture to rotate around the u coordinates of the UVs
  102909. * @see https://doc.babylonjs.com/how_to/more_materials
  102910. */
  102911. uAng: number;
  102912. /**
  102913. * Define an offset on the texture to rotate around the v coordinates of the UVs
  102914. * @see https://doc.babylonjs.com/how_to/more_materials
  102915. */
  102916. vAng: number;
  102917. /**
  102918. * Define an offset on the texture to rotate around the w coordinates of the UVs (in case of 3d texture)
  102919. * @see https://doc.babylonjs.com/how_to/more_materials
  102920. */
  102921. wAng: number;
  102922. /**
  102923. * Defines the center of rotation (U)
  102924. */
  102925. uRotationCenter: number;
  102926. /**
  102927. * Defines the center of rotation (V)
  102928. */
  102929. vRotationCenter: number;
  102930. /**
  102931. * Defines the center of rotation (W)
  102932. */
  102933. wRotationCenter: number;
  102934. /**
  102935. * Are mip maps generated for this texture or not.
  102936. */
  102937. get noMipmap(): boolean;
  102938. /**
  102939. * List of inspectable custom properties (used by the Inspector)
  102940. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  102941. */
  102942. inspectableCustomProperties: Nullable<IInspectable[]>;
  102943. private _noMipmap;
  102944. /** @hidden */
  102945. _invertY: boolean;
  102946. private _rowGenerationMatrix;
  102947. private _cachedTextureMatrix;
  102948. private _projectionModeMatrix;
  102949. private _t0;
  102950. private _t1;
  102951. private _t2;
  102952. private _cachedUOffset;
  102953. private _cachedVOffset;
  102954. private _cachedUScale;
  102955. private _cachedVScale;
  102956. private _cachedUAng;
  102957. private _cachedVAng;
  102958. private _cachedWAng;
  102959. private _cachedProjectionMatrixId;
  102960. private _cachedCoordinatesMode;
  102961. /** @hidden */
  102962. protected _initialSamplingMode: number;
  102963. /** @hidden */
  102964. _buffer: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob | ImageBitmap>;
  102965. private _deleteBuffer;
  102966. protected _format: Nullable<number>;
  102967. private _delayedOnLoad;
  102968. private _delayedOnError;
  102969. private _mimeType?;
  102970. /** Returns the texture mime type if it was defined by a loader (undefined else) */
  102971. get mimeType(): string | undefined;
  102972. /**
  102973. * Observable triggered once the texture has been loaded.
  102974. */
  102975. onLoadObservable: Observable<Texture>;
  102976. protected _isBlocking: boolean;
  102977. /**
  102978. * Is the texture preventing material to render while loading.
  102979. * If false, a default texture will be used instead of the loading one during the preparation step.
  102980. */
  102981. set isBlocking(value: boolean);
  102982. get isBlocking(): boolean;
  102983. /**
  102984. * Get the current sampling mode associated with the texture.
  102985. */
  102986. get samplingMode(): number;
  102987. /**
  102988. * Gets a boolean indicating if the texture needs to be inverted on the y axis during loading
  102989. */
  102990. get invertY(): boolean;
  102991. /**
  102992. * Instantiates a new texture.
  102993. * This represents a texture in babylon. It can be easily loaded from a network, base64 or html input.
  102994. * @see https://doc.babylonjs.com/babylon101/materials#texture
  102995. * @param url defines the url of the picture to load as a texture
  102996. * @param sceneOrEngine defines the scene or engine the texture will belong to
  102997. * @param noMipmap defines if the texture will require mip maps or not
  102998. * @param invertY defines if the texture needs to be inverted on the y axis during loading
  102999. * @param samplingMode defines the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  103000. * @param onLoad defines a callback triggered when the texture has been loaded
  103001. * @param onError defines a callback triggered when an error occurred during the loading session
  103002. * @param buffer defines the buffer to load the texture from in case the texture is loaded from a buffer representation
  103003. * @param deleteBuffer defines if the buffer we are loading the texture from should be deleted after load
  103004. * @param format defines the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  103005. * @param mimeType defines an optional mime type information
  103006. */
  103007. 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);
  103008. /**
  103009. * Update the url (and optional buffer) of this texture if url was null during construction.
  103010. * @param url the url of the texture
  103011. * @param buffer the buffer of the texture (defaults to null)
  103012. * @param onLoad callback called when the texture is loaded (defaults to null)
  103013. */
  103014. updateURL(url: string, buffer?: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob>, onLoad?: () => void): void;
  103015. /**
  103016. * Finish the loading sequence of a texture flagged as delayed load.
  103017. * @hidden
  103018. */
  103019. delayLoad(): void;
  103020. private _prepareRowForTextureGeneration;
  103021. /**
  103022. * Get the current texture matrix which includes the requested offsetting, tiling and rotation components.
  103023. * @returns the transform matrix of the texture.
  103024. */
  103025. getTextureMatrix(uBase?: number): Matrix;
  103026. /**
  103027. * Get the current matrix used to apply reflection. This is useful to rotate an environment texture for instance.
  103028. * @returns The reflection texture transform
  103029. */
  103030. getReflectionTextureMatrix(): Matrix;
  103031. /**
  103032. * Clones the texture.
  103033. * @returns the cloned texture
  103034. */
  103035. clone(): Texture;
  103036. /**
  103037. * Serialize the texture to a JSON representation we can easily use in the resepective Parse function.
  103038. * @returns The JSON representation of the texture
  103039. */
  103040. serialize(): any;
  103041. /**
  103042. * Get the current class name of the texture useful for serialization or dynamic coding.
  103043. * @returns "Texture"
  103044. */
  103045. getClassName(): string;
  103046. /**
  103047. * Dispose the texture and release its associated resources.
  103048. */
  103049. dispose(): void;
  103050. /**
  103051. * Parse the JSON representation of a texture in order to recreate the texture in the given scene.
  103052. * @param parsedTexture Define the JSON representation of the texture
  103053. * @param scene Define the scene the parsed texture should be instantiated in
  103054. * @param rootUrl Define the root url of the parsing sequence in the case of relative dependencies
  103055. * @returns The parsed texture if successful
  103056. */
  103057. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<BaseTexture>;
  103058. /**
  103059. * Creates a texture from its base 64 representation.
  103060. * @param data Define the base64 payload without the data: prefix
  103061. * @param name Define the name of the texture in the scene useful fo caching purpose for instance
  103062. * @param scene Define the scene the texture should belong to
  103063. * @param noMipmap Forces the texture to not create mip map information if true
  103064. * @param invertY define if the texture needs to be inverted on the y axis during loading
  103065. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  103066. * @param onLoad define a callback triggered when the texture has been loaded
  103067. * @param onError define a callback triggered when an error occurred during the loading session
  103068. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  103069. * @returns the created texture
  103070. */
  103071. static CreateFromBase64String(data: string, name: string, scene: Scene, noMipmap?: boolean, invertY?: boolean, samplingMode?: number, onLoad?: Nullable<() => void>, onError?: Nullable<() => void>, format?: number): Texture;
  103072. /**
  103073. * Creates a texture from its data: representation. (data: will be added in case only the payload has been passed in)
  103074. * @param data Define the base64 payload without the data: prefix
  103075. * @param name Define the name of the texture in the scene useful fo caching purpose for instance
  103076. * @param buffer define the buffer to load the texture from in case the texture is loaded from a buffer representation
  103077. * @param scene Define the scene the texture should belong to
  103078. * @param deleteBuffer define if the buffer we are loading the texture from should be deleted after load
  103079. * @param noMipmap Forces the texture to not create mip map information if true
  103080. * @param invertY define if the texture needs to be inverted on the y axis during loading
  103081. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  103082. * @param onLoad define a callback triggered when the texture has been loaded
  103083. * @param onError define a callback triggered when an error occurred during the loading session
  103084. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  103085. * @returns the created texture
  103086. */
  103087. 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;
  103088. }
  103089. }
  103090. declare module BABYLON {
  103091. /**
  103092. * PostProcessManager is used to manage one or more post processes or post process pipelines
  103093. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  103094. */
  103095. export class PostProcessManager {
  103096. private _scene;
  103097. private _indexBuffer;
  103098. private _vertexBuffers;
  103099. /**
  103100. * Creates a new instance PostProcess
  103101. * @param scene The scene that the post process is associated with.
  103102. */
  103103. constructor(scene: Scene);
  103104. private _prepareBuffers;
  103105. private _buildIndexBuffer;
  103106. /**
  103107. * Rebuilds the vertex buffers of the manager.
  103108. * @hidden
  103109. */
  103110. _rebuild(): void;
  103111. /**
  103112. * Prepares a frame to be run through a post process.
  103113. * @param sourceTexture The input texture to the post procesess. (default: null)
  103114. * @param postProcesses An array of post processes to be run. (default: null)
  103115. * @returns True if the post processes were able to be run.
  103116. * @hidden
  103117. */
  103118. _prepareFrame(sourceTexture?: Nullable<InternalTexture>, postProcesses?: Nullable<PostProcess[]>): boolean;
  103119. /**
  103120. * Manually render a set of post processes to a texture.
  103121. * Please note, the frame buffer won't be unbound after the call in case you have more render to do.
  103122. * @param postProcesses An array of post processes to be run.
  103123. * @param targetTexture The target texture to render to.
  103124. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight
  103125. * @param faceIndex defines the face to render to if a cubemap is defined as the target
  103126. * @param lodLevel defines which lod of the texture to render to
  103127. * @param doNotBindFrambuffer If set to true, assumes that the framebuffer has been bound previously
  103128. */
  103129. directRender(postProcesses: PostProcess[], targetTexture?: Nullable<InternalTexture>, forceFullscreenViewport?: boolean, faceIndex?: number, lodLevel?: number, doNotBindFrambuffer?: boolean): void;
  103130. /**
  103131. * Finalize the result of the output of the postprocesses.
  103132. * @param doNotPresent If true the result will not be displayed to the screen.
  103133. * @param targetTexture The target texture to render to.
  103134. * @param faceIndex The index of the face to bind the target texture to.
  103135. * @param postProcesses The array of post processes to render.
  103136. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight (default: false)
  103137. * @hidden
  103138. */
  103139. _finalizeFrame(doNotPresent?: boolean, targetTexture?: InternalTexture, faceIndex?: number, postProcesses?: Array<PostProcess>, forceFullscreenViewport?: boolean): void;
  103140. /**
  103141. * Disposes of the post process manager.
  103142. */
  103143. dispose(): void;
  103144. }
  103145. }
  103146. declare module BABYLON {
  103147. /**
  103148. * This Helps creating a texture that will be created from a camera in your scene.
  103149. * It is basically a dynamic texture that could be used to create special effects for instance.
  103150. * Actually, It is the base of lot of effects in the framework like post process, shadows, effect layers and rendering pipelines...
  103151. */
  103152. export class RenderTargetTexture extends Texture {
  103153. /**
  103154. * The texture will only be rendered once which can be useful to improve performance if everything in your render is static for instance.
  103155. */
  103156. static readonly REFRESHRATE_RENDER_ONCE: number;
  103157. /**
  103158. * The texture will only be rendered rendered every frame and is recomended for dynamic contents.
  103159. */
  103160. static readonly REFRESHRATE_RENDER_ONEVERYFRAME: number;
  103161. /**
  103162. * The texture will be rendered every 2 frames which could be enough if your dynamic objects are not
  103163. * the central point of your effect and can save a lot of performances.
  103164. */
  103165. static readonly REFRESHRATE_RENDER_ONEVERYTWOFRAMES: number;
  103166. /**
  103167. * Use this predicate to dynamically define the list of mesh you want to render.
  103168. * If set, the renderList property will be overwritten.
  103169. */
  103170. renderListPredicate: (AbstractMesh: AbstractMesh) => boolean;
  103171. private _renderList;
  103172. /**
  103173. * Use this list to define the list of mesh you want to render.
  103174. */
  103175. get renderList(): Nullable<Array<AbstractMesh>>;
  103176. set renderList(value: Nullable<Array<AbstractMesh>>);
  103177. /**
  103178. * Use this function to overload the renderList array at rendering time.
  103179. * Return null to render with the curent renderList, else return the list of meshes to use for rendering.
  103180. * For 2DArray RTT, layerOrFace is the index of the layer that is going to be rendered, else it is the faceIndex of
  103181. * the cube (if the RTT is a cube, else layerOrFace=0).
  103182. * The renderList passed to the function is the current render list (the one that will be used if the function returns null).
  103183. * The length of this list is passed through renderListLength: don't use renderList.length directly because the array can
  103184. * hold dummy elements!
  103185. */
  103186. getCustomRenderList: (layerOrFace: number, renderList: Nullable<Immutable<Array<AbstractMesh>>>, renderListLength: number) => Nullable<Array<AbstractMesh>>;
  103187. private _hookArray;
  103188. /**
  103189. * Define if particles should be rendered in your texture.
  103190. */
  103191. renderParticles: boolean;
  103192. /**
  103193. * Define if sprites should be rendered in your texture.
  103194. */
  103195. renderSprites: boolean;
  103196. /**
  103197. * Define the camera used to render the texture.
  103198. */
  103199. activeCamera: Nullable<Camera>;
  103200. /**
  103201. * Override the mesh isReady function with your own one.
  103202. */
  103203. customIsReadyFunction: (mesh: AbstractMesh, refreshRate: number) => boolean;
  103204. /**
  103205. * Override the render function of the texture with your own one.
  103206. */
  103207. customRenderFunction: (opaqueSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>, beforeTransparents?: () => void) => void;
  103208. /**
  103209. * Define if camera post processes should be use while rendering the texture.
  103210. */
  103211. useCameraPostProcesses: boolean;
  103212. /**
  103213. * Define if the camera viewport should be respected while rendering the texture or if the render should be done to the entire texture.
  103214. */
  103215. ignoreCameraViewport: boolean;
  103216. private _postProcessManager;
  103217. private _postProcesses;
  103218. private _resizeObserver;
  103219. /**
  103220. * An event triggered when the texture is unbind.
  103221. */
  103222. onBeforeBindObservable: Observable<RenderTargetTexture>;
  103223. /**
  103224. * An event triggered when the texture is unbind.
  103225. */
  103226. onAfterUnbindObservable: Observable<RenderTargetTexture>;
  103227. private _onAfterUnbindObserver;
  103228. /**
  103229. * Set a after unbind callback in the texture.
  103230. * This has been kept for backward compatibility and use of onAfterUnbindObservable is recommended.
  103231. */
  103232. set onAfterUnbind(callback: () => void);
  103233. /**
  103234. * An event triggered before rendering the texture
  103235. */
  103236. onBeforeRenderObservable: Observable<number>;
  103237. private _onBeforeRenderObserver;
  103238. /**
  103239. * Set a before render callback in the texture.
  103240. * This has been kept for backward compatibility and use of onBeforeRenderObservable is recommended.
  103241. */
  103242. set onBeforeRender(callback: (faceIndex: number) => void);
  103243. /**
  103244. * An event triggered after rendering the texture
  103245. */
  103246. onAfterRenderObservable: Observable<number>;
  103247. private _onAfterRenderObserver;
  103248. /**
  103249. * Set a after render callback in the texture.
  103250. * This has been kept for backward compatibility and use of onAfterRenderObservable is recommended.
  103251. */
  103252. set onAfterRender(callback: (faceIndex: number) => void);
  103253. /**
  103254. * An event triggered after the texture clear
  103255. */
  103256. onClearObservable: Observable<Engine>;
  103257. private _onClearObserver;
  103258. /**
  103259. * Set a clear callback in the texture.
  103260. * This has been kept for backward compatibility and use of onClearObservable is recommended.
  103261. */
  103262. set onClear(callback: (Engine: Engine) => void);
  103263. /**
  103264. * An event triggered when the texture is resized.
  103265. */
  103266. onResizeObservable: Observable<RenderTargetTexture>;
  103267. /**
  103268. * Define the clear color of the Render Target if it should be different from the scene.
  103269. */
  103270. clearColor: Color4;
  103271. protected _size: number | {
  103272. width: number;
  103273. height: number;
  103274. layers?: number;
  103275. };
  103276. protected _initialSizeParameter: number | {
  103277. width: number;
  103278. height: number;
  103279. } | {
  103280. ratio: number;
  103281. };
  103282. protected _sizeRatio: Nullable<number>;
  103283. /** @hidden */
  103284. _generateMipMaps: boolean;
  103285. protected _renderingManager: RenderingManager;
  103286. /** @hidden */
  103287. _waitingRenderList?: string[];
  103288. protected _doNotChangeAspectRatio: boolean;
  103289. protected _currentRefreshId: number;
  103290. protected _refreshRate: number;
  103291. protected _textureMatrix: Matrix;
  103292. protected _samples: number;
  103293. protected _renderTargetOptions: RenderTargetCreationOptions;
  103294. /**
  103295. * Gets render target creation options that were used.
  103296. */
  103297. get renderTargetOptions(): RenderTargetCreationOptions;
  103298. protected _onRatioRescale(): void;
  103299. /**
  103300. * Gets or sets the center of the bounding box associated with the texture (when in cube mode)
  103301. * It must define where the camera used to render the texture is set
  103302. */
  103303. boundingBoxPosition: Vector3;
  103304. private _boundingBoxSize;
  103305. /**
  103306. * Gets or sets the size of the bounding box associated with the texture (when in cube mode)
  103307. * When defined, the cubemap will switch to local mode
  103308. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  103309. * @example https://www.babylonjs-playground.com/#RNASML
  103310. */
  103311. set boundingBoxSize(value: Vector3);
  103312. get boundingBoxSize(): Vector3;
  103313. /**
  103314. * In case the RTT has been created with a depth texture, get the associated
  103315. * depth texture.
  103316. * Otherwise, return null.
  103317. */
  103318. get depthStencilTexture(): Nullable<InternalTexture>;
  103319. /**
  103320. * Instantiate a render target texture. This is mainly used to render of screen the scene to for instance apply post processse
  103321. * or used a shadow, depth texture...
  103322. * @param name The friendly name of the texture
  103323. * @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)
  103324. * @param scene The scene the RTT belongs to. The latest created scene will be used if not precised.
  103325. * @param generateMipMaps True if mip maps need to be generated after render.
  103326. * @param doNotChangeAspectRatio True to not change the aspect ratio of the scene in the RTT
  103327. * @param type The type of the buffer in the RTT (int, half float, float...)
  103328. * @param isCube True if a cube texture needs to be created
  103329. * @param samplingMode The sampling mode to be usedwith the render target (Linear, Nearest...)
  103330. * @param generateDepthBuffer True to generate a depth buffer
  103331. * @param generateStencilBuffer True to generate a stencil buffer
  103332. * @param isMulti True if multiple textures need to be created (Draw Buffers)
  103333. * @param format The internal format of the buffer in the RTT (RED, RG, RGB, RGBA, ALPHA...)
  103334. * @param delayAllocation if the texture allocation should be delayed (default: false)
  103335. */
  103336. constructor(name: string, size: number | {
  103337. width: number;
  103338. height: number;
  103339. layers?: number;
  103340. } | {
  103341. ratio: number;
  103342. }, scene: Nullable<Scene>, generateMipMaps?: boolean, doNotChangeAspectRatio?: boolean, type?: number, isCube?: boolean, samplingMode?: number, generateDepthBuffer?: boolean, generateStencilBuffer?: boolean, isMulti?: boolean, format?: number, delayAllocation?: boolean);
  103343. /**
  103344. * Creates a depth stencil texture.
  103345. * This is only available in WebGL 2 or with the depth texture extension available.
  103346. * @param comparisonFunction Specifies the comparison function to set on the texture. If 0 or undefined, the texture is not in comparison mode
  103347. * @param bilinearFiltering Specifies whether or not bilinear filtering is enable on the texture
  103348. * @param generateStencil Specifies whether or not a stencil should be allocated in the texture
  103349. */
  103350. createDepthStencilTexture(comparisonFunction?: number, bilinearFiltering?: boolean, generateStencil?: boolean): void;
  103351. private _processSizeParameter;
  103352. /**
  103353. * Define the number of samples to use in case of MSAA.
  103354. * It defaults to one meaning no MSAA has been enabled.
  103355. */
  103356. get samples(): number;
  103357. set samples(value: number);
  103358. /**
  103359. * Resets the refresh counter of the texture and start bak from scratch.
  103360. * Could be useful to regenerate the texture if it is setup to render only once.
  103361. */
  103362. resetRefreshCounter(): void;
  103363. /**
  103364. * Define the refresh rate of the texture or the rendering frequency.
  103365. * Use 0 to render just once, 1 to render on every frame, 2 to render every two frames and so on...
  103366. */
  103367. get refreshRate(): number;
  103368. set refreshRate(value: number);
  103369. /**
  103370. * Adds a post process to the render target rendering passes.
  103371. * @param postProcess define the post process to add
  103372. */
  103373. addPostProcess(postProcess: PostProcess): void;
  103374. /**
  103375. * Clear all the post processes attached to the render target
  103376. * @param dispose define if the cleared post processesshould also be disposed (false by default)
  103377. */
  103378. clearPostProcesses(dispose?: boolean): void;
  103379. /**
  103380. * Remove one of the post process from the list of attached post processes to the texture
  103381. * @param postProcess define the post process to remove from the list
  103382. */
  103383. removePostProcess(postProcess: PostProcess): void;
  103384. /** @hidden */
  103385. _shouldRender(): boolean;
  103386. /**
  103387. * Gets the actual render size of the texture.
  103388. * @returns the width of the render size
  103389. */
  103390. getRenderSize(): number;
  103391. /**
  103392. * Gets the actual render width of the texture.
  103393. * @returns the width of the render size
  103394. */
  103395. getRenderWidth(): number;
  103396. /**
  103397. * Gets the actual render height of the texture.
  103398. * @returns the height of the render size
  103399. */
  103400. getRenderHeight(): number;
  103401. /**
  103402. * Gets the actual number of layers of the texture.
  103403. * @returns the number of layers
  103404. */
  103405. getRenderLayers(): number;
  103406. /**
  103407. * Get if the texture can be rescaled or not.
  103408. */
  103409. get canRescale(): boolean;
  103410. /**
  103411. * Resize the texture using a ratio.
  103412. * @param ratio the ratio to apply to the texture size in order to compute the new target size
  103413. */
  103414. scale(ratio: number): void;
  103415. /**
  103416. * Get the texture reflection matrix used to rotate/transform the reflection.
  103417. * @returns the reflection matrix
  103418. */
  103419. getReflectionTextureMatrix(): Matrix;
  103420. /**
  103421. * Resize the texture to a new desired size.
  103422. * Be carrefull as it will recreate all the data in the new texture.
  103423. * @param size Define the new size. It can be:
  103424. * - a number for squared texture,
  103425. * - an object containing { width: number, height: number }
  103426. * - or an object containing a ratio { ratio: number }
  103427. */
  103428. resize(size: number | {
  103429. width: number;
  103430. height: number;
  103431. } | {
  103432. ratio: number;
  103433. }): void;
  103434. private _defaultRenderListPrepared;
  103435. /**
  103436. * Renders all the objects from the render list into the texture.
  103437. * @param useCameraPostProcess Define if camera post processes should be used during the rendering
  103438. * @param dumpForDebug Define if the rendering result should be dumped (copied) for debugging purpose
  103439. */
  103440. render(useCameraPostProcess?: boolean, dumpForDebug?: boolean): void;
  103441. private _bestReflectionRenderTargetDimension;
  103442. private _prepareRenderingManager;
  103443. /**
  103444. * @hidden
  103445. * @param faceIndex face index to bind to if this is a cubetexture
  103446. * @param layer defines the index of the texture to bind in the array
  103447. */
  103448. _bindFrameBuffer(faceIndex?: number, layer?: number): void;
  103449. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  103450. private renderToTarget;
  103451. /**
  103452. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  103453. * This allowed control for front to back rendering or reversly depending of the special needs.
  103454. *
  103455. * @param renderingGroupId The rendering group id corresponding to its index
  103456. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  103457. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  103458. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  103459. */
  103460. 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;
  103461. /**
  103462. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  103463. *
  103464. * @param renderingGroupId The rendering group id corresponding to its index
  103465. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  103466. */
  103467. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  103468. /**
  103469. * Clones the texture.
  103470. * @returns the cloned texture
  103471. */
  103472. clone(): RenderTargetTexture;
  103473. /**
  103474. * Serialize the texture to a JSON representation we can easily use in the resepective Parse function.
  103475. * @returns The JSON representation of the texture
  103476. */
  103477. serialize(): any;
  103478. /**
  103479. * This will remove the attached framebuffer objects. The texture will not be able to be used as render target anymore
  103480. */
  103481. disposeFramebufferObjects(): void;
  103482. /**
  103483. * Dispose the texture and release its associated resources.
  103484. */
  103485. dispose(): void;
  103486. /** @hidden */
  103487. _rebuild(): void;
  103488. /**
  103489. * Clear the info related to rendering groups preventing retention point in material dispose.
  103490. */
  103491. freeRenderingGroups(): void;
  103492. /**
  103493. * Gets the number of views the corresponding to the texture (eg. a MultiviewRenderTarget will have > 1)
  103494. * @returns the view count
  103495. */
  103496. getViewCount(): number;
  103497. }
  103498. }
  103499. declare module BABYLON {
  103500. /**
  103501. * Class used to manipulate GUIDs
  103502. */
  103503. export class GUID {
  103504. /**
  103505. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  103506. * Be aware Math.random() could cause collisions, but:
  103507. * "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"
  103508. * @returns a pseudo random id
  103509. */
  103510. static RandomId(): string;
  103511. }
  103512. }
  103513. declare module BABYLON {
  103514. /**
  103515. * Options to be used when creating a shadow depth material
  103516. */
  103517. export interface IIOptionShadowDepthMaterial {
  103518. /** Variables in the vertex shader code that need to have their names remapped.
  103519. * The format is: ["var_name", "var_remapped_name", "var_name", "var_remapped_name", ...]
  103520. * "var_name" should be either: worldPos or vNormalW
  103521. * So, if the variable holding the world position in your vertex shader is not named worldPos, you must tell the system
  103522. * the name to use instead by using: ["worldPos", "myWorldPosVar"] assuming the variable is named myWorldPosVar in your code.
  103523. * If the normal must also be remapped: ["worldPos", "myWorldPosVar", "vNormalW", "myWorldNormal"]
  103524. */
  103525. remappedVariables?: string[];
  103526. /** Set standalone to true if the base material wrapped by ShadowDepthMaterial is not used for a regular object but for depth shadow generation only */
  103527. standalone?: boolean;
  103528. }
  103529. /**
  103530. * Class that can be used to wrap a base material to generate accurate shadows when using custom vertex/fragment code in the base material
  103531. */
  103532. export class ShadowDepthWrapper {
  103533. private _scene;
  103534. private _options?;
  103535. private _baseMaterial;
  103536. private _onEffectCreatedObserver;
  103537. private _subMeshToEffect;
  103538. private _subMeshToDepthEffect;
  103539. private _meshes;
  103540. /** @hidden */
  103541. _matriceNames: any;
  103542. /** Gets the standalone status of the wrapper */
  103543. get standalone(): boolean;
  103544. /** Gets the base material the wrapper is built upon */
  103545. get baseMaterial(): Material;
  103546. /**
  103547. * Instantiate a new shadow depth wrapper.
  103548. * It works by injecting some specific code in the vertex/fragment shaders of the base material and is used by a shadow generator to
  103549. * generate the shadow depth map. For more information, please refer to the documentation:
  103550. * https://doc.babylonjs.com/babylon101/shadows
  103551. * @param baseMaterial Material to wrap
  103552. * @param scene Define the scene the material belongs to
  103553. * @param options Options used to create the wrapper
  103554. */
  103555. constructor(baseMaterial: Material, scene: Scene, options?: IIOptionShadowDepthMaterial);
  103556. /**
  103557. * Gets the effect to use to generate the depth map
  103558. * @param subMesh subMesh to get the effect for
  103559. * @param shadowGenerator shadow generator to get the effect for
  103560. * @returns the effect to use to generate the depth map for the subMesh + shadow generator specified
  103561. */
  103562. getEffect(subMesh: Nullable<SubMesh>, shadowGenerator: ShadowGenerator): Nullable<Effect>;
  103563. /**
  103564. * Specifies that the submesh is ready to be used for depth rendering
  103565. * @param subMesh submesh to check
  103566. * @param defines the list of defines to take into account when checking the effect
  103567. * @param shadowGenerator combined with subMesh, it defines the effect to check
  103568. * @param useInstances specifies that instances should be used
  103569. * @returns a boolean indicating that the submesh is ready or not
  103570. */
  103571. isReadyForSubMesh(subMesh: SubMesh, defines: string[], shadowGenerator: ShadowGenerator, useInstances: boolean): boolean;
  103572. /**
  103573. * Disposes the resources
  103574. */
  103575. dispose(): void;
  103576. private _makeEffect;
  103577. }
  103578. }
  103579. declare module BABYLON {
  103580. interface ThinEngine {
  103581. /**
  103582. * Unbind a list of render target textures from the webGL context
  103583. * This is used only when drawBuffer extension or webGL2 are active
  103584. * @param textures defines the render target textures to unbind
  103585. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  103586. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  103587. */
  103588. unBindMultiColorAttachmentFramebuffer(textures: InternalTexture[], disableGenerateMipMaps: boolean, onBeforeUnbind?: () => void): void;
  103589. /**
  103590. * Create a multi render target texture
  103591. * @see https://doc.babylonjs.com/features/webgl2#multiple-render-target
  103592. * @param size defines the size of the texture
  103593. * @param options defines the creation options
  103594. * @returns the cube texture as an InternalTexture
  103595. */
  103596. createMultipleRenderTarget(size: any, options: IMultiRenderTargetOptions): InternalTexture[];
  103597. /**
  103598. * Update the sample count for a given multiple render target texture
  103599. * @see https://doc.babylonjs.com/features/webgl2#multisample-render-targets
  103600. * @param textures defines the textures to update
  103601. * @param samples defines the sample count to set
  103602. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  103603. */
  103604. updateMultipleRenderTargetTextureSampleCount(textures: Nullable<InternalTexture[]>, samples: number): number;
  103605. /**
  103606. * Select a subsets of attachments to draw to.
  103607. * @param attachments gl attachments
  103608. */
  103609. bindAttachments(attachments: number[]): void;
  103610. }
  103611. }
  103612. declare module BABYLON {
  103613. /**
  103614. * Creation options of the multi render target texture.
  103615. */
  103616. export interface IMultiRenderTargetOptions {
  103617. /**
  103618. * Define if the texture needs to create mip maps after render.
  103619. */
  103620. generateMipMaps?: boolean;
  103621. /**
  103622. * Define the types of all the draw buffers we want to create
  103623. */
  103624. types?: number[];
  103625. /**
  103626. * Define the sampling modes of all the draw buffers we want to create
  103627. */
  103628. samplingModes?: number[];
  103629. /**
  103630. * Define if a depth buffer is required
  103631. */
  103632. generateDepthBuffer?: boolean;
  103633. /**
  103634. * Define if a stencil buffer is required
  103635. */
  103636. generateStencilBuffer?: boolean;
  103637. /**
  103638. * Define if a depth texture is required instead of a depth buffer
  103639. */
  103640. generateDepthTexture?: boolean;
  103641. /**
  103642. * Define the number of desired draw buffers
  103643. */
  103644. textureCount?: number;
  103645. /**
  103646. * Define if aspect ratio should be adapted to the texture or stay the scene one
  103647. */
  103648. doNotChangeAspectRatio?: boolean;
  103649. /**
  103650. * Define the default type of the buffers we are creating
  103651. */
  103652. defaultType?: number;
  103653. }
  103654. /**
  103655. * A multi render target, like a render target provides the ability to render to a texture.
  103656. * Unlike the render target, it can render to several draw buffers in one draw.
  103657. * This is specially interesting in deferred rendering or for any effects requiring more than
  103658. * just one color from a single pass.
  103659. */
  103660. export class MultiRenderTarget extends RenderTargetTexture {
  103661. private _internalTextures;
  103662. private _textures;
  103663. private _multiRenderTargetOptions;
  103664. private _count;
  103665. /**
  103666. * Get if draw buffers are currently supported by the used hardware and browser.
  103667. */
  103668. get isSupported(): boolean;
  103669. /**
  103670. * Get the list of textures generated by the multi render target.
  103671. */
  103672. get textures(): Texture[];
  103673. /**
  103674. * Gets the number of textures in this MRT. This number can be different from `_textures.length` in case a depth texture is generated.
  103675. */
  103676. get count(): number;
  103677. /**
  103678. * Get the depth texture generated by the multi render target if options.generateDepthTexture has been set
  103679. */
  103680. get depthTexture(): Texture;
  103681. /**
  103682. * Set the wrapping mode on U of all the textures we are rendering to.
  103683. * Can be any of the Texture. (CLAMP_ADDRESSMODE, MIRROR_ADDRESSMODE or WRAP_ADDRESSMODE)
  103684. */
  103685. set wrapU(wrap: number);
  103686. /**
  103687. * Set the wrapping mode on V of all the textures we are rendering to.
  103688. * Can be any of the Texture. (CLAMP_ADDRESSMODE, MIRROR_ADDRESSMODE or WRAP_ADDRESSMODE)
  103689. */
  103690. set wrapV(wrap: number);
  103691. /**
  103692. * Instantiate a new multi render target texture.
  103693. * A multi render target, like a render target provides the ability to render to a texture.
  103694. * Unlike the render target, it can render to several draw buffers in one draw.
  103695. * This is specially interesting in deferred rendering or for any effects requiring more than
  103696. * just one color from a single pass.
  103697. * @param name Define the name of the texture
  103698. * @param size Define the size of the buffers to render to
  103699. * @param count Define the number of target we are rendering into
  103700. * @param scene Define the scene the texture belongs to
  103701. * @param options Define the options used to create the multi render target
  103702. */
  103703. constructor(name: string, size: any, count: number, scene: Scene, options?: IMultiRenderTargetOptions);
  103704. /** @hidden */
  103705. _rebuild(): void;
  103706. private _createInternalTextures;
  103707. private _createTextures;
  103708. /**
  103709. * Define the number of samples used if MSAA is enabled.
  103710. */
  103711. get samples(): number;
  103712. set samples(value: number);
  103713. /**
  103714. * Resize all the textures in the multi render target.
  103715. * Be carrefull as it will recreate all the data in the new texture.
  103716. * @param size Define the new size
  103717. */
  103718. resize(size: any): void;
  103719. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  103720. /**
  103721. * Dispose the render targets and their associated resources
  103722. */
  103723. dispose(): void;
  103724. /**
  103725. * Release all the underlying texture used as draw buffers.
  103726. */
  103727. releaseInternalTextures(): void;
  103728. }
  103729. }
  103730. declare module BABYLON {
  103731. /** @hidden */
  103732. export var imageProcessingPixelShader: {
  103733. name: string;
  103734. shader: string;
  103735. };
  103736. }
  103737. declare module BABYLON {
  103738. /**
  103739. * ImageProcessingPostProcess
  103740. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#imageprocessing
  103741. */
  103742. export class ImageProcessingPostProcess extends PostProcess {
  103743. /**
  103744. * Default configuration related to image processing available in the PBR Material.
  103745. */
  103746. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  103747. /**
  103748. * Gets the image processing configuration used either in this material.
  103749. */
  103750. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  103751. /**
  103752. * Sets the Default image processing configuration used either in the this material.
  103753. *
  103754. * If sets to null, the scene one is in use.
  103755. */
  103756. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  103757. /**
  103758. * Keep track of the image processing observer to allow dispose and replace.
  103759. */
  103760. private _imageProcessingObserver;
  103761. /**
  103762. * Attaches a new image processing configuration to the PBR Material.
  103763. * @param configuration
  103764. */
  103765. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>, doNotBuild?: boolean): void;
  103766. /**
  103767. * If the post process is supported.
  103768. */
  103769. get isSupported(): boolean;
  103770. /**
  103771. * Gets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  103772. */
  103773. get colorCurves(): Nullable<ColorCurves>;
  103774. /**
  103775. * Sets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  103776. */
  103777. set colorCurves(value: Nullable<ColorCurves>);
  103778. /**
  103779. * Gets wether the color curves effect is enabled.
  103780. */
  103781. get colorCurvesEnabled(): boolean;
  103782. /**
  103783. * Sets wether the color curves effect is enabled.
  103784. */
  103785. set colorCurvesEnabled(value: boolean);
  103786. /**
  103787. * Gets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  103788. */
  103789. get colorGradingTexture(): Nullable<BaseTexture>;
  103790. /**
  103791. * Sets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  103792. */
  103793. set colorGradingTexture(value: Nullable<BaseTexture>);
  103794. /**
  103795. * Gets wether the color grading effect is enabled.
  103796. */
  103797. get colorGradingEnabled(): boolean;
  103798. /**
  103799. * Gets wether the color grading effect is enabled.
  103800. */
  103801. set colorGradingEnabled(value: boolean);
  103802. /**
  103803. * Gets exposure used in the effect.
  103804. */
  103805. get exposure(): number;
  103806. /**
  103807. * Sets exposure used in the effect.
  103808. */
  103809. set exposure(value: number);
  103810. /**
  103811. * Gets wether tonemapping is enabled or not.
  103812. */
  103813. get toneMappingEnabled(): boolean;
  103814. /**
  103815. * Sets wether tonemapping is enabled or not
  103816. */
  103817. set toneMappingEnabled(value: boolean);
  103818. /**
  103819. * Gets the type of tone mapping effect.
  103820. */
  103821. get toneMappingType(): number;
  103822. /**
  103823. * Sets the type of tone mapping effect.
  103824. */
  103825. set toneMappingType(value: number);
  103826. /**
  103827. * Gets contrast used in the effect.
  103828. */
  103829. get contrast(): number;
  103830. /**
  103831. * Sets contrast used in the effect.
  103832. */
  103833. set contrast(value: number);
  103834. /**
  103835. * Gets Vignette stretch size.
  103836. */
  103837. get vignetteStretch(): number;
  103838. /**
  103839. * Sets Vignette stretch size.
  103840. */
  103841. set vignetteStretch(value: number);
  103842. /**
  103843. * Gets Vignette centre X Offset.
  103844. */
  103845. get vignetteCentreX(): number;
  103846. /**
  103847. * Sets Vignette centre X Offset.
  103848. */
  103849. set vignetteCentreX(value: number);
  103850. /**
  103851. * Gets Vignette centre Y Offset.
  103852. */
  103853. get vignetteCentreY(): number;
  103854. /**
  103855. * Sets Vignette centre Y Offset.
  103856. */
  103857. set vignetteCentreY(value: number);
  103858. /**
  103859. * Gets Vignette weight or intensity of the vignette effect.
  103860. */
  103861. get vignetteWeight(): number;
  103862. /**
  103863. * Sets Vignette weight or intensity of the vignette effect.
  103864. */
  103865. set vignetteWeight(value: number);
  103866. /**
  103867. * Gets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  103868. * if vignetteEnabled is set to true.
  103869. */
  103870. get vignetteColor(): Color4;
  103871. /**
  103872. * Sets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  103873. * if vignetteEnabled is set to true.
  103874. */
  103875. set vignetteColor(value: Color4);
  103876. /**
  103877. * Gets Camera field of view used by the Vignette effect.
  103878. */
  103879. get vignetteCameraFov(): number;
  103880. /**
  103881. * Sets Camera field of view used by the Vignette effect.
  103882. */
  103883. set vignetteCameraFov(value: number);
  103884. /**
  103885. * Gets the vignette blend mode allowing different kind of effect.
  103886. */
  103887. get vignetteBlendMode(): number;
  103888. /**
  103889. * Sets the vignette blend mode allowing different kind of effect.
  103890. */
  103891. set vignetteBlendMode(value: number);
  103892. /**
  103893. * Gets wether the vignette effect is enabled.
  103894. */
  103895. get vignetteEnabled(): boolean;
  103896. /**
  103897. * Sets wether the vignette effect is enabled.
  103898. */
  103899. set vignetteEnabled(value: boolean);
  103900. private _fromLinearSpace;
  103901. /**
  103902. * Gets wether the input of the processing is in Gamma or Linear Space.
  103903. */
  103904. get fromLinearSpace(): boolean;
  103905. /**
  103906. * Sets wether the input of the processing is in Gamma or Linear Space.
  103907. */
  103908. set fromLinearSpace(value: boolean);
  103909. /**
  103910. * Defines cache preventing GC.
  103911. */
  103912. private _defines;
  103913. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, imageProcessingConfiguration?: ImageProcessingConfiguration);
  103914. /**
  103915. * "ImageProcessingPostProcess"
  103916. * @returns "ImageProcessingPostProcess"
  103917. */
  103918. getClassName(): string;
  103919. /**
  103920. * @hidden
  103921. */
  103922. _updateParameters(): void;
  103923. dispose(camera?: Camera): void;
  103924. }
  103925. }
  103926. declare module BABYLON {
  103927. /** @hidden */
  103928. export var fibonacci: {
  103929. name: string;
  103930. shader: string;
  103931. };
  103932. }
  103933. declare module BABYLON {
  103934. /** @hidden */
  103935. export var subSurfaceScatteringFunctions: {
  103936. name: string;
  103937. shader: string;
  103938. };
  103939. }
  103940. declare module BABYLON {
  103941. /** @hidden */
  103942. export var diffusionProfile: {
  103943. name: string;
  103944. shader: string;
  103945. };
  103946. }
  103947. declare module BABYLON {
  103948. /** @hidden */
  103949. export var subSurfaceScatteringPixelShader: {
  103950. name: string;
  103951. shader: string;
  103952. };
  103953. }
  103954. declare module BABYLON {
  103955. /**
  103956. * Sub surface scattering post process
  103957. */
  103958. export class SubSurfaceScatteringPostProcess extends PostProcess {
  103959. /**
  103960. * Gets a string identifying the name of the class
  103961. * @returns "SubSurfaceScatteringPostProcess" string
  103962. */
  103963. getClassName(): string;
  103964. constructor(name: string, scene: Scene, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  103965. }
  103966. }
  103967. declare module BABYLON {
  103968. /**
  103969. * Interface for defining prepass effects in the prepass post-process pipeline
  103970. */
  103971. export interface PrePassEffectConfiguration {
  103972. /**
  103973. * Post process to attach for this effect
  103974. */
  103975. postProcess: PostProcess;
  103976. /**
  103977. * Is the effect enabled
  103978. */
  103979. enabled: boolean;
  103980. /**
  103981. * Disposes the effect configuration
  103982. */
  103983. dispose(): void;
  103984. /**
  103985. * Disposes the effect configuration
  103986. */
  103987. createPostProcess: () => PostProcess;
  103988. }
  103989. }
  103990. declare module BABYLON {
  103991. /**
  103992. * Contains all parameters needed for the prepass to perform
  103993. * screen space subsurface scattering
  103994. */
  103995. export class SubSurfaceConfiguration implements PrePassEffectConfiguration {
  103996. private _ssDiffusionS;
  103997. private _ssFilterRadii;
  103998. private _ssDiffusionD;
  103999. /**
  104000. * Post process to attach for screen space subsurface scattering
  104001. */
  104002. postProcess: SubSurfaceScatteringPostProcess;
  104003. /**
  104004. * Diffusion profile color for subsurface scattering
  104005. */
  104006. get ssDiffusionS(): number[];
  104007. /**
  104008. * Diffusion profile max color channel value for subsurface scattering
  104009. */
  104010. get ssDiffusionD(): number[];
  104011. /**
  104012. * Diffusion profile filter radius for subsurface scattering
  104013. */
  104014. get ssFilterRadii(): number[];
  104015. /**
  104016. * Is subsurface enabled
  104017. */
  104018. enabled: boolean;
  104019. /**
  104020. * Diffusion profile colors for subsurface scattering
  104021. * You can add one diffusion color using `addDiffusionProfile` on `scene.prePassRenderer`
  104022. * See ...
  104023. * Note that you can only store up to 5 of them
  104024. */
  104025. ssDiffusionProfileColors: Color3[];
  104026. /**
  104027. * Defines the ratio real world => scene units.
  104028. * Used for subsurface scattering
  104029. */
  104030. metersPerUnit: number;
  104031. private _scene;
  104032. /**
  104033. * Builds a subsurface configuration object
  104034. * @param scene The scene
  104035. */
  104036. constructor(scene: Scene);
  104037. /**
  104038. * Adds a new diffusion profile.
  104039. * Useful for more realistic subsurface scattering on diverse materials.
  104040. * @param color The color of the diffusion profile. Should be the average color of the material.
  104041. * @return The index of the diffusion profile for the material subsurface configuration
  104042. */
  104043. addDiffusionProfile(color: Color3): number;
  104044. /**
  104045. * Creates the sss post process
  104046. * @return The created post process
  104047. */
  104048. createPostProcess(): SubSurfaceScatteringPostProcess;
  104049. /**
  104050. * Deletes all diffusion profiles.
  104051. * Note that in order to render subsurface scattering, you should have at least 1 diffusion profile.
  104052. */
  104053. clearAllDiffusionProfiles(): void;
  104054. /**
  104055. * Disposes this object
  104056. */
  104057. dispose(): void;
  104058. /**
  104059. * @hidden
  104060. * https://zero-radiance.github.io/post/sampling-diffusion/
  104061. *
  104062. * Importance sample the normalized diffuse reflectance profile for the computed value of 's'.
  104063. * ------------------------------------------------------------------------------------
  104064. * R[r, phi, s] = s * (Exp[-r * s] + Exp[-r * s / 3]) / (8 * Pi * r)
  104065. * PDF[r, phi, s] = r * R[r, phi, s]
  104066. * CDF[r, s] = 1 - 1/4 * Exp[-r * s] - 3/4 * Exp[-r * s / 3]
  104067. * ------------------------------------------------------------------------------------
  104068. * We importance sample the color channel with the widest scattering distance.
  104069. */
  104070. getDiffusionProfileParameters(color: Color3): number;
  104071. /**
  104072. * Performs sampling of a Normalized Burley diffusion profile in polar coordinates.
  104073. * 'u' is the random number (the value of the CDF): [0, 1).
  104074. * rcp(s) = 1 / ShapeParam = ScatteringDistance.
  104075. * Returns the sampled radial distance, s.t. (u = 0 -> r = 0) and (u = 1 -> r = Inf).
  104076. */
  104077. private _sampleBurleyDiffusionProfile;
  104078. }
  104079. }
  104080. declare module BABYLON {
  104081. /**
  104082. * Renders a pre pass of the scene
  104083. * This means every mesh in the scene will be rendered to a render target texture
  104084. * And then this texture will be composited to the rendering canvas with post processes
  104085. * It is necessary for effects like subsurface scattering or deferred shading
  104086. */
  104087. export class PrePassRenderer {
  104088. /** @hidden */
  104089. static _SceneComponentInitialization: (scene: Scene) => void;
  104090. private _scene;
  104091. private _engine;
  104092. private _isDirty;
  104093. /**
  104094. * Number of textures in the multi render target texture where the scene is directly rendered
  104095. */
  104096. readonly mrtCount: number;
  104097. /**
  104098. * The render target where the scene is directly rendered
  104099. */
  104100. prePassRT: MultiRenderTarget;
  104101. private _mrtTypes;
  104102. private _multiRenderAttachments;
  104103. private _defaultAttachments;
  104104. private _clearAttachments;
  104105. private _postProcesses;
  104106. private readonly _clearColor;
  104107. /**
  104108. * Image processing post process for composition
  104109. */
  104110. imageProcessingPostProcess: ImageProcessingPostProcess;
  104111. /**
  104112. * Configuration for sub surface scattering post process
  104113. */
  104114. subSurfaceConfiguration: SubSurfaceConfiguration;
  104115. /**
  104116. * Should materials render their geometry on the MRT
  104117. */
  104118. materialsShouldRenderGeometry: boolean;
  104119. /**
  104120. * Should materials render the irradiance information on the MRT
  104121. */
  104122. materialsShouldRenderIrradiance: boolean;
  104123. private _enabled;
  104124. /**
  104125. * Indicates if the prepass is enabled
  104126. */
  104127. get enabled(): boolean;
  104128. /**
  104129. * How many samples are used for MSAA of the scene render target
  104130. */
  104131. get samples(): number;
  104132. set samples(n: number);
  104133. /**
  104134. * Instanciates a prepass renderer
  104135. * @param scene The scene
  104136. */
  104137. constructor(scene: Scene);
  104138. private _initializeAttachments;
  104139. private _createCompositionEffect;
  104140. /**
  104141. * Indicates if rendering a prepass is supported
  104142. */
  104143. get isSupported(): boolean;
  104144. /**
  104145. * Sets the proper output textures to draw in the engine.
  104146. * @param effect The effect that is drawn. It can be or not be compatible with drawing to several output textures.
  104147. */
  104148. bindAttachmentsForEffect(effect: Effect): void;
  104149. /**
  104150. * @hidden
  104151. */
  104152. _beforeCameraDraw(): void;
  104153. /**
  104154. * @hidden
  104155. */
  104156. _afterCameraDraw(): void;
  104157. private _checkRTSize;
  104158. private _bindFrameBuffer;
  104159. /**
  104160. * Clears the scene render target (in the sense of settings pixels to the scene clear color value)
  104161. */
  104162. clear(): void;
  104163. private _setState;
  104164. private _enable;
  104165. private _disable;
  104166. private _resetPostProcessChain;
  104167. private _bindPostProcessChain;
  104168. /**
  104169. * Marks the prepass renderer as dirty, triggering a check if the prepass is necessary for the next rendering.
  104170. */
  104171. markAsDirty(): void;
  104172. private _update;
  104173. /**
  104174. * Disposes the prepass renderer.
  104175. */
  104176. dispose(): void;
  104177. }
  104178. }
  104179. declare module BABYLON {
  104180. /**
  104181. * Options for compiling materials.
  104182. */
  104183. export interface IMaterialCompilationOptions {
  104184. /**
  104185. * Defines whether clip planes are enabled.
  104186. */
  104187. clipPlane: boolean;
  104188. /**
  104189. * Defines whether instances are enabled.
  104190. */
  104191. useInstances: boolean;
  104192. }
  104193. /**
  104194. * Options passed when calling customShaderNameResolve
  104195. */
  104196. export interface ICustomShaderNameResolveOptions {
  104197. /**
  104198. * 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
  104199. */
  104200. processFinalCode?: Nullable<(shaderType: string, code: string) => string>;
  104201. }
  104202. /**
  104203. * Base class for the main features of a material in Babylon.js
  104204. */
  104205. export class Material implements IAnimatable {
  104206. /**
  104207. * Returns the triangle fill mode
  104208. */
  104209. static readonly TriangleFillMode: number;
  104210. /**
  104211. * Returns the wireframe mode
  104212. */
  104213. static readonly WireFrameFillMode: number;
  104214. /**
  104215. * Returns the point fill mode
  104216. */
  104217. static readonly PointFillMode: number;
  104218. /**
  104219. * Returns the point list draw mode
  104220. */
  104221. static readonly PointListDrawMode: number;
  104222. /**
  104223. * Returns the line list draw mode
  104224. */
  104225. static readonly LineListDrawMode: number;
  104226. /**
  104227. * Returns the line loop draw mode
  104228. */
  104229. static readonly LineLoopDrawMode: number;
  104230. /**
  104231. * Returns the line strip draw mode
  104232. */
  104233. static readonly LineStripDrawMode: number;
  104234. /**
  104235. * Returns the triangle strip draw mode
  104236. */
  104237. static readonly TriangleStripDrawMode: number;
  104238. /**
  104239. * Returns the triangle fan draw mode
  104240. */
  104241. static readonly TriangleFanDrawMode: number;
  104242. /**
  104243. * Stores the clock-wise side orientation
  104244. */
  104245. static readonly ClockWiseSideOrientation: number;
  104246. /**
  104247. * Stores the counter clock-wise side orientation
  104248. */
  104249. static readonly CounterClockWiseSideOrientation: number;
  104250. /**
  104251. * The dirty texture flag value
  104252. */
  104253. static readonly TextureDirtyFlag: number;
  104254. /**
  104255. * The dirty light flag value
  104256. */
  104257. static readonly LightDirtyFlag: number;
  104258. /**
  104259. * The dirty fresnel flag value
  104260. */
  104261. static readonly FresnelDirtyFlag: number;
  104262. /**
  104263. * The dirty attribute flag value
  104264. */
  104265. static readonly AttributesDirtyFlag: number;
  104266. /**
  104267. * The dirty misc flag value
  104268. */
  104269. static readonly MiscDirtyFlag: number;
  104270. /**
  104271. * The all dirty flag value
  104272. */
  104273. static readonly AllDirtyFlag: number;
  104274. /**
  104275. * MaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  104276. */
  104277. static readonly MATERIAL_OPAQUE: number;
  104278. /**
  104279. * MaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  104280. */
  104281. static readonly MATERIAL_ALPHATEST: number;
  104282. /**
  104283. * MaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  104284. */
  104285. static readonly MATERIAL_ALPHABLEND: number;
  104286. /**
  104287. * MaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  104288. * They are also discarded below the alpha cutoff threshold to improve performances.
  104289. */
  104290. static readonly MATERIAL_ALPHATESTANDBLEND: number;
  104291. /**
  104292. * The Whiteout method is used to blend normals.
  104293. * Details of the algorithm can be found here: https://blog.selfshadow.com/publications/blending-in-detail/
  104294. */
  104295. static readonly MATERIAL_NORMALBLENDMETHOD_WHITEOUT: number;
  104296. /**
  104297. * The Reoriented Normal Mapping method is used to blend normals.
  104298. * Details of the algorithm can be found here: https://blog.selfshadow.com/publications/blending-in-detail/
  104299. */
  104300. static readonly MATERIAL_NORMALBLENDMETHOD_RNM: number;
  104301. /**
  104302. * Custom callback helping to override the default shader used in the material.
  104303. */
  104304. customShaderNameResolve: (shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: MaterialDefines | string[], attributes?: string[], options?: ICustomShaderNameResolveOptions) => string;
  104305. /**
  104306. * Custom shadow depth material to use for shadow rendering instead of the in-built one
  104307. */
  104308. shadowDepthWrapper: Nullable<ShadowDepthWrapper>;
  104309. /**
  104310. * Gets or sets a boolean indicating that the material is allowed (if supported) to do shader hot swapping.
  104311. * This means that the material can keep using a previous shader while a new one is being compiled.
  104312. * This is mostly used when shader parallel compilation is supported (true by default)
  104313. */
  104314. allowShaderHotSwapping: boolean;
  104315. /**
  104316. * The ID of the material
  104317. */
  104318. id: string;
  104319. /**
  104320. * Gets or sets the unique id of the material
  104321. */
  104322. uniqueId: number;
  104323. /**
  104324. * The name of the material
  104325. */
  104326. name: string;
  104327. /**
  104328. * Gets or sets user defined metadata
  104329. */
  104330. metadata: any;
  104331. /**
  104332. * For internal use only. Please do not use.
  104333. */
  104334. reservedDataStore: any;
  104335. /**
  104336. * Specifies if the ready state should be checked on each call
  104337. */
  104338. checkReadyOnEveryCall: boolean;
  104339. /**
  104340. * Specifies if the ready state should be checked once
  104341. */
  104342. checkReadyOnlyOnce: boolean;
  104343. /**
  104344. * The state of the material
  104345. */
  104346. state: string;
  104347. /**
  104348. * If the material can be rendered to several textures with MRT extension
  104349. */
  104350. get canRenderToMRT(): boolean;
  104351. /**
  104352. * The alpha value of the material
  104353. */
  104354. protected _alpha: number;
  104355. /**
  104356. * List of inspectable custom properties (used by the Inspector)
  104357. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  104358. */
  104359. inspectableCustomProperties: IInspectable[];
  104360. /**
  104361. * Sets the alpha value of the material
  104362. */
  104363. set alpha(value: number);
  104364. /**
  104365. * Gets the alpha value of the material
  104366. */
  104367. get alpha(): number;
  104368. /**
  104369. * Specifies if back face culling is enabled
  104370. */
  104371. protected _backFaceCulling: boolean;
  104372. /**
  104373. * Sets the back-face culling state
  104374. */
  104375. set backFaceCulling(value: boolean);
  104376. /**
  104377. * Gets the back-face culling state
  104378. */
  104379. get backFaceCulling(): boolean;
  104380. /**
  104381. * Stores the value for side orientation
  104382. */
  104383. sideOrientation: number;
  104384. /**
  104385. * Callback triggered when the material is compiled
  104386. */
  104387. onCompiled: Nullable<(effect: Effect) => void>;
  104388. /**
  104389. * Callback triggered when an error occurs
  104390. */
  104391. onError: Nullable<(effect: Effect, errors: string) => void>;
  104392. /**
  104393. * Callback triggered to get the render target textures
  104394. */
  104395. getRenderTargetTextures: Nullable<() => SmartArray<RenderTargetTexture>>;
  104396. /**
  104397. * Gets a boolean indicating that current material needs to register RTT
  104398. */
  104399. get hasRenderTargetTextures(): boolean;
  104400. /**
  104401. * Specifies if the material should be serialized
  104402. */
  104403. doNotSerialize: boolean;
  104404. /**
  104405. * @hidden
  104406. */
  104407. _storeEffectOnSubMeshes: boolean;
  104408. /**
  104409. * Stores the animations for the material
  104410. */
  104411. animations: Nullable<Array<Animation>>;
  104412. /**
  104413. * An event triggered when the material is disposed
  104414. */
  104415. onDisposeObservable: Observable<Material>;
  104416. /**
  104417. * An observer which watches for dispose events
  104418. */
  104419. private _onDisposeObserver;
  104420. private _onUnBindObservable;
  104421. /**
  104422. * Called during a dispose event
  104423. */
  104424. set onDispose(callback: () => void);
  104425. private _onBindObservable;
  104426. /**
  104427. * An event triggered when the material is bound
  104428. */
  104429. get onBindObservable(): Observable<AbstractMesh>;
  104430. /**
  104431. * An observer which watches for bind events
  104432. */
  104433. private _onBindObserver;
  104434. /**
  104435. * Called during a bind event
  104436. */
  104437. set onBind(callback: (Mesh: AbstractMesh) => void);
  104438. /**
  104439. * An event triggered when the material is unbound
  104440. */
  104441. get onUnBindObservable(): Observable<Material>;
  104442. protected _onEffectCreatedObservable: Nullable<Observable<{
  104443. effect: Effect;
  104444. subMesh: Nullable<SubMesh>;
  104445. }>>;
  104446. /**
  104447. * An event triggered when the effect is (re)created
  104448. */
  104449. get onEffectCreatedObservable(): Observable<{
  104450. effect: Effect;
  104451. subMesh: Nullable<SubMesh>;
  104452. }>;
  104453. /**
  104454. * Stores the value of the alpha mode
  104455. */
  104456. private _alphaMode;
  104457. /**
  104458. * Sets the value of the alpha mode.
  104459. *
  104460. * | Value | Type | Description |
  104461. * | --- | --- | --- |
  104462. * | 0 | ALPHA_DISABLE | |
  104463. * | 1 | ALPHA_ADD | |
  104464. * | 2 | ALPHA_COMBINE | |
  104465. * | 3 | ALPHA_SUBTRACT | |
  104466. * | 4 | ALPHA_MULTIPLY | |
  104467. * | 5 | ALPHA_MAXIMIZED | |
  104468. * | 6 | ALPHA_ONEONE | |
  104469. * | 7 | ALPHA_PREMULTIPLIED | |
  104470. * | 8 | ALPHA_PREMULTIPLIED_PORTERDUFF | |
  104471. * | 9 | ALPHA_INTERPOLATE | |
  104472. * | 10 | ALPHA_SCREENMODE | |
  104473. *
  104474. */
  104475. set alphaMode(value: number);
  104476. /**
  104477. * Gets the value of the alpha mode
  104478. */
  104479. get alphaMode(): number;
  104480. /**
  104481. * Stores the state of the need depth pre-pass value
  104482. */
  104483. private _needDepthPrePass;
  104484. /**
  104485. * Sets the need depth pre-pass value
  104486. */
  104487. set needDepthPrePass(value: boolean);
  104488. /**
  104489. * Gets the depth pre-pass value
  104490. */
  104491. get needDepthPrePass(): boolean;
  104492. /**
  104493. * Specifies if depth writing should be disabled
  104494. */
  104495. disableDepthWrite: boolean;
  104496. /**
  104497. * Specifies if color writing should be disabled
  104498. */
  104499. disableColorWrite: boolean;
  104500. /**
  104501. * Specifies if depth writing should be forced
  104502. */
  104503. forceDepthWrite: boolean;
  104504. /**
  104505. * Specifies the depth function that should be used. 0 means the default engine function
  104506. */
  104507. depthFunction: number;
  104508. /**
  104509. * Specifies if there should be a separate pass for culling
  104510. */
  104511. separateCullingPass: boolean;
  104512. /**
  104513. * Stores the state specifing if fog should be enabled
  104514. */
  104515. private _fogEnabled;
  104516. /**
  104517. * Sets the state for enabling fog
  104518. */
  104519. set fogEnabled(value: boolean);
  104520. /**
  104521. * Gets the value of the fog enabled state
  104522. */
  104523. get fogEnabled(): boolean;
  104524. /**
  104525. * Stores the size of points
  104526. */
  104527. pointSize: number;
  104528. /**
  104529. * Stores the z offset value
  104530. */
  104531. zOffset: number;
  104532. get wireframe(): boolean;
  104533. /**
  104534. * Sets the state of wireframe mode
  104535. */
  104536. set wireframe(value: boolean);
  104537. /**
  104538. * Gets the value specifying if point clouds are enabled
  104539. */
  104540. get pointsCloud(): boolean;
  104541. /**
  104542. * Sets the state of point cloud mode
  104543. */
  104544. set pointsCloud(value: boolean);
  104545. /**
  104546. * Gets the material fill mode
  104547. */
  104548. get fillMode(): number;
  104549. /**
  104550. * Sets the material fill mode
  104551. */
  104552. set fillMode(value: number);
  104553. /**
  104554. * @hidden
  104555. * Stores the effects for the material
  104556. */
  104557. _effect: Nullable<Effect>;
  104558. /**
  104559. * Specifies if uniform buffers should be used
  104560. */
  104561. private _useUBO;
  104562. /**
  104563. * Stores a reference to the scene
  104564. */
  104565. private _scene;
  104566. /**
  104567. * Stores the fill mode state
  104568. */
  104569. private _fillMode;
  104570. /**
  104571. * Specifies if the depth write state should be cached
  104572. */
  104573. private _cachedDepthWriteState;
  104574. /**
  104575. * Specifies if the color write state should be cached
  104576. */
  104577. private _cachedColorWriteState;
  104578. /**
  104579. * Specifies if the depth function state should be cached
  104580. */
  104581. private _cachedDepthFunctionState;
  104582. /**
  104583. * Stores the uniform buffer
  104584. */
  104585. protected _uniformBuffer: UniformBuffer;
  104586. /** @hidden */
  104587. _indexInSceneMaterialArray: number;
  104588. /** @hidden */
  104589. meshMap: Nullable<{
  104590. [id: string]: AbstractMesh | undefined;
  104591. }>;
  104592. /**
  104593. * Creates a material instance
  104594. * @param name defines the name of the material
  104595. * @param scene defines the scene to reference
  104596. * @param doNotAdd specifies if the material should be added to the scene
  104597. */
  104598. constructor(name: string, scene: Scene, doNotAdd?: boolean);
  104599. /**
  104600. * Returns a string representation of the current material
  104601. * @param fullDetails defines a boolean indicating which levels of logging is desired
  104602. * @returns a string with material information
  104603. */
  104604. toString(fullDetails?: boolean): string;
  104605. /**
  104606. * Gets the class name of the material
  104607. * @returns a string with the class name of the material
  104608. */
  104609. getClassName(): string;
  104610. /**
  104611. * Specifies if updates for the material been locked
  104612. */
  104613. get isFrozen(): boolean;
  104614. /**
  104615. * Locks updates for the material
  104616. */
  104617. freeze(): void;
  104618. /**
  104619. * Unlocks updates for the material
  104620. */
  104621. unfreeze(): void;
  104622. /**
  104623. * Specifies if the material is ready to be used
  104624. * @param mesh defines the mesh to check
  104625. * @param useInstances specifies if instances should be used
  104626. * @returns a boolean indicating if the material is ready to be used
  104627. */
  104628. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  104629. /**
  104630. * Specifies that the submesh is ready to be used
  104631. * @param mesh defines the mesh to check
  104632. * @param subMesh defines which submesh to check
  104633. * @param useInstances specifies that instances should be used
  104634. * @returns a boolean indicating that the submesh is ready or not
  104635. */
  104636. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  104637. /**
  104638. * Returns the material effect
  104639. * @returns the effect associated with the material
  104640. */
  104641. getEffect(): Nullable<Effect>;
  104642. /**
  104643. * Returns the current scene
  104644. * @returns a Scene
  104645. */
  104646. getScene(): Scene;
  104647. /**
  104648. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  104649. */
  104650. protected _forceAlphaTest: boolean;
  104651. /**
  104652. * The transparency mode of the material.
  104653. */
  104654. protected _transparencyMode: Nullable<number>;
  104655. /**
  104656. * Gets the current transparency mode.
  104657. */
  104658. get transparencyMode(): Nullable<number>;
  104659. /**
  104660. * Sets the transparency mode of the material.
  104661. *
  104662. * | Value | Type | Description |
  104663. * | ----- | ----------------------------------- | ----------- |
  104664. * | 0 | OPAQUE | |
  104665. * | 1 | ALPHATEST | |
  104666. * | 2 | ALPHABLEND | |
  104667. * | 3 | ALPHATESTANDBLEND | |
  104668. *
  104669. */
  104670. set transparencyMode(value: Nullable<number>);
  104671. /**
  104672. * Returns true if alpha blending should be disabled.
  104673. */
  104674. protected get _disableAlphaBlending(): boolean;
  104675. /**
  104676. * Specifies whether or not this material should be rendered in alpha blend mode.
  104677. * @returns a boolean specifying if alpha blending is needed
  104678. */
  104679. needAlphaBlending(): boolean;
  104680. /**
  104681. * Specifies if the mesh will require alpha blending
  104682. * @param mesh defines the mesh to check
  104683. * @returns a boolean specifying if alpha blending is needed for the mesh
  104684. */
  104685. needAlphaBlendingForMesh(mesh: AbstractMesh): boolean;
  104686. /**
  104687. * Specifies whether or not this material should be rendered in alpha test mode.
  104688. * @returns a boolean specifying if an alpha test is needed.
  104689. */
  104690. needAlphaTesting(): boolean;
  104691. /**
  104692. * Specifies if material alpha testing should be turned on for the mesh
  104693. * @param mesh defines the mesh to check
  104694. */
  104695. protected _shouldTurnAlphaTestOn(mesh: AbstractMesh): boolean;
  104696. /**
  104697. * Gets the texture used for the alpha test
  104698. * @returns the texture to use for alpha testing
  104699. */
  104700. getAlphaTestTexture(): Nullable<BaseTexture>;
  104701. /**
  104702. * Marks the material to indicate that it needs to be re-calculated
  104703. */
  104704. markDirty(): void;
  104705. /** @hidden */
  104706. _preBind(effect?: Effect, overrideOrientation?: Nullable<number>): boolean;
  104707. /**
  104708. * Binds the material to the mesh
  104709. * @param world defines the world transformation matrix
  104710. * @param mesh defines the mesh to bind the material to
  104711. */
  104712. bind(world: Matrix, mesh?: Mesh): void;
  104713. /**
  104714. * Binds the submesh to the material
  104715. * @param world defines the world transformation matrix
  104716. * @param mesh defines the mesh containing the submesh
  104717. * @param subMesh defines the submesh to bind the material to
  104718. */
  104719. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  104720. /**
  104721. * Binds the world matrix to the material
  104722. * @param world defines the world transformation matrix
  104723. */
  104724. bindOnlyWorldMatrix(world: Matrix): void;
  104725. /**
  104726. * Binds the scene's uniform buffer to the effect.
  104727. * @param effect defines the effect to bind to the scene uniform buffer
  104728. * @param sceneUbo defines the uniform buffer storing scene data
  104729. */
  104730. bindSceneUniformBuffer(effect: Effect, sceneUbo: UniformBuffer): void;
  104731. /**
  104732. * Binds the view matrix to the effect
  104733. * @param effect defines the effect to bind the view matrix to
  104734. */
  104735. bindView(effect: Effect): void;
  104736. /**
  104737. * Binds the view projection matrix to the effect
  104738. * @param effect defines the effect to bind the view projection matrix to
  104739. */
  104740. bindViewProjection(effect: Effect): void;
  104741. /**
  104742. * Processes to execute after binding the material to a mesh
  104743. * @param mesh defines the rendered mesh
  104744. */
  104745. protected _afterBind(mesh?: Mesh): void;
  104746. /**
  104747. * Unbinds the material from the mesh
  104748. */
  104749. unbind(): void;
  104750. /**
  104751. * Gets the active textures from the material
  104752. * @returns an array of textures
  104753. */
  104754. getActiveTextures(): BaseTexture[];
  104755. /**
  104756. * Specifies if the material uses a texture
  104757. * @param texture defines the texture to check against the material
  104758. * @returns a boolean specifying if the material uses the texture
  104759. */
  104760. hasTexture(texture: BaseTexture): boolean;
  104761. /**
  104762. * Makes a duplicate of the material, and gives it a new name
  104763. * @param name defines the new name for the duplicated material
  104764. * @returns the cloned material
  104765. */
  104766. clone(name: string): Nullable<Material>;
  104767. /**
  104768. * Gets the meshes bound to the material
  104769. * @returns an array of meshes bound to the material
  104770. */
  104771. getBindedMeshes(): AbstractMesh[];
  104772. /**
  104773. * Force shader compilation
  104774. * @param mesh defines the mesh associated with this material
  104775. * @param onCompiled defines a function to execute once the material is compiled
  104776. * @param options defines the options to configure the compilation
  104777. * @param onError defines a function to execute if the material fails compiling
  104778. */
  104779. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<IMaterialCompilationOptions>, onError?: (reason: string) => void): void;
  104780. /**
  104781. * Force shader compilation
  104782. * @param mesh defines the mesh that will use this material
  104783. * @param options defines additional options for compiling the shaders
  104784. * @returns a promise that resolves when the compilation completes
  104785. */
  104786. forceCompilationAsync(mesh: AbstractMesh, options?: Partial<IMaterialCompilationOptions>): Promise<void>;
  104787. private static readonly _AllDirtyCallBack;
  104788. private static readonly _ImageProcessingDirtyCallBack;
  104789. private static readonly _TextureDirtyCallBack;
  104790. private static readonly _FresnelDirtyCallBack;
  104791. private static readonly _MiscDirtyCallBack;
  104792. private static readonly _LightsDirtyCallBack;
  104793. private static readonly _AttributeDirtyCallBack;
  104794. private static _FresnelAndMiscDirtyCallBack;
  104795. private static _TextureAndMiscDirtyCallBack;
  104796. private static readonly _DirtyCallbackArray;
  104797. private static readonly _RunDirtyCallBacks;
  104798. /**
  104799. * Marks a define in the material to indicate that it needs to be re-computed
  104800. * @param flag defines a flag used to determine which parts of the material have to be marked as dirty
  104801. */
  104802. markAsDirty(flag: number): void;
  104803. /**
  104804. * Marks all submeshes of a material to indicate that their material defines need to be re-calculated
  104805. * @param func defines a function which checks material defines against the submeshes
  104806. */
  104807. protected _markAllSubMeshesAsDirty(func: (defines: MaterialDefines) => void): void;
  104808. /**
  104809. * Indicates that the scene should check if the rendering now needs a prepass
  104810. */
  104811. protected _markScenePrePassDirty(): void;
  104812. /**
  104813. * Indicates that we need to re-calculated for all submeshes
  104814. */
  104815. protected _markAllSubMeshesAsAllDirty(): void;
  104816. /**
  104817. * Indicates that image processing needs to be re-calculated for all submeshes
  104818. */
  104819. protected _markAllSubMeshesAsImageProcessingDirty(): void;
  104820. /**
  104821. * Indicates that textures need to be re-calculated for all submeshes
  104822. */
  104823. protected _markAllSubMeshesAsTexturesDirty(): void;
  104824. /**
  104825. * Indicates that fresnel needs to be re-calculated for all submeshes
  104826. */
  104827. protected _markAllSubMeshesAsFresnelDirty(): void;
  104828. /**
  104829. * Indicates that fresnel and misc need to be re-calculated for all submeshes
  104830. */
  104831. protected _markAllSubMeshesAsFresnelAndMiscDirty(): void;
  104832. /**
  104833. * Indicates that lights need to be re-calculated for all submeshes
  104834. */
  104835. protected _markAllSubMeshesAsLightsDirty(): void;
  104836. /**
  104837. * Indicates that attributes need to be re-calculated for all submeshes
  104838. */
  104839. protected _markAllSubMeshesAsAttributesDirty(): void;
  104840. /**
  104841. * Indicates that misc needs to be re-calculated for all submeshes
  104842. */
  104843. protected _markAllSubMeshesAsMiscDirty(): void;
  104844. /**
  104845. * Indicates that textures and misc need to be re-calculated for all submeshes
  104846. */
  104847. protected _markAllSubMeshesAsTexturesAndMiscDirty(): void;
  104848. /**
  104849. * Sets the required values to the prepass renderer.
  104850. * @param prePassRenderer defines the prepass renderer to setup.
  104851. * @returns true if the pre pass is needed.
  104852. */
  104853. setPrePassRenderer(prePassRenderer: PrePassRenderer): boolean;
  104854. /**
  104855. * Disposes the material
  104856. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  104857. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  104858. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  104859. */
  104860. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  104861. /** @hidden */
  104862. private releaseVertexArrayObject;
  104863. /**
  104864. * Serializes this material
  104865. * @returns the serialized material object
  104866. */
  104867. serialize(): any;
  104868. /**
  104869. * Creates a material from parsed material data
  104870. * @param parsedMaterial defines parsed material data
  104871. * @param scene defines the hosting scene
  104872. * @param rootUrl defines the root URL to use to load textures
  104873. * @returns a new material
  104874. */
  104875. static Parse(parsedMaterial: any, scene: Scene, rootUrl: string): Nullable<Material>;
  104876. }
  104877. }
  104878. declare module BABYLON {
  104879. /**
  104880. * A multi-material is used to apply different materials to different parts of the same object without the need of
  104881. * separate meshes. This can be use to improve performances.
  104882. * @see https://doc.babylonjs.com/how_to/multi_materials
  104883. */
  104884. export class MultiMaterial extends Material {
  104885. private _subMaterials;
  104886. /**
  104887. * Gets or Sets the list of Materials used within the multi material.
  104888. * They need to be ordered according to the submeshes order in the associated mesh
  104889. */
  104890. get subMaterials(): Nullable<Material>[];
  104891. set subMaterials(value: Nullable<Material>[]);
  104892. /**
  104893. * Function used to align with Node.getChildren()
  104894. * @returns the list of Materials used within the multi material
  104895. */
  104896. getChildren(): Nullable<Material>[];
  104897. /**
  104898. * Instantiates a new Multi Material
  104899. * A multi-material is used to apply different materials to different parts of the same object without the need of
  104900. * separate meshes. This can be use to improve performances.
  104901. * @see https://doc.babylonjs.com/how_to/multi_materials
  104902. * @param name Define the name in the scene
  104903. * @param scene Define the scene the material belongs to
  104904. */
  104905. constructor(name: string, scene: Scene);
  104906. private _hookArray;
  104907. /**
  104908. * Get one of the submaterial by its index in the submaterials array
  104909. * @param index The index to look the sub material at
  104910. * @returns The Material if the index has been defined
  104911. */
  104912. getSubMaterial(index: number): Nullable<Material>;
  104913. /**
  104914. * Get the list of active textures for the whole sub materials list.
  104915. * @returns All the textures that will be used during the rendering
  104916. */
  104917. getActiveTextures(): BaseTexture[];
  104918. /**
  104919. * Gets the current class name of the material e.g. "MultiMaterial"
  104920. * Mainly use in serialization.
  104921. * @returns the class name
  104922. */
  104923. getClassName(): string;
  104924. /**
  104925. * Checks if the material is ready to render the requested sub mesh
  104926. * @param mesh Define the mesh the submesh belongs to
  104927. * @param subMesh Define the sub mesh to look readyness for
  104928. * @param useInstances Define whether or not the material is used with instances
  104929. * @returns true if ready, otherwise false
  104930. */
  104931. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  104932. /**
  104933. * Clones the current material and its related sub materials
  104934. * @param name Define the name of the newly cloned material
  104935. * @param cloneChildren Define if submaterial will be cloned or shared with the parent instance
  104936. * @returns the cloned material
  104937. */
  104938. clone(name: string, cloneChildren?: boolean): MultiMaterial;
  104939. /**
  104940. * Serializes the materials into a JSON representation.
  104941. * @returns the JSON representation
  104942. */
  104943. serialize(): any;
  104944. /**
  104945. * Dispose the material and release its associated resources
  104946. * @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)
  104947. * @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)
  104948. * @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)
  104949. */
  104950. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, forceDisposeChildren?: boolean): void;
  104951. /**
  104952. * Creates a MultiMaterial from parsed MultiMaterial data.
  104953. * @param parsedMultiMaterial defines parsed MultiMaterial data.
  104954. * @param scene defines the hosting scene
  104955. * @returns a new MultiMaterial
  104956. */
  104957. static ParseMultiMaterial(parsedMultiMaterial: any, scene: Scene): MultiMaterial;
  104958. }
  104959. }
  104960. declare module BABYLON {
  104961. /**
  104962. * Defines a subdivision inside a mesh
  104963. */
  104964. export class SubMesh implements ICullable {
  104965. /** the material index to use */
  104966. materialIndex: number;
  104967. /** vertex index start */
  104968. verticesStart: number;
  104969. /** vertices count */
  104970. verticesCount: number;
  104971. /** index start */
  104972. indexStart: number;
  104973. /** indices count */
  104974. indexCount: number;
  104975. /** @hidden */
  104976. _materialDefines: Nullable<MaterialDefines>;
  104977. /** @hidden */
  104978. _materialEffect: Nullable<Effect>;
  104979. /** @hidden */
  104980. _effectOverride: Nullable<Effect>;
  104981. /**
  104982. * Gets material defines used by the effect associated to the sub mesh
  104983. */
  104984. get materialDefines(): Nullable<MaterialDefines>;
  104985. /**
  104986. * Sets material defines used by the effect associated to the sub mesh
  104987. */
  104988. set materialDefines(defines: Nullable<MaterialDefines>);
  104989. /**
  104990. * Gets associated effect
  104991. */
  104992. get effect(): Nullable<Effect>;
  104993. /**
  104994. * Sets associated effect (effect used to render this submesh)
  104995. * @param effect defines the effect to associate with
  104996. * @param defines defines the set of defines used to compile this effect
  104997. */
  104998. setEffect(effect: Nullable<Effect>, defines?: Nullable<MaterialDefines>): void;
  104999. /** @hidden */
  105000. _linesIndexCount: number;
  105001. private _mesh;
  105002. private _renderingMesh;
  105003. private _boundingInfo;
  105004. private _linesIndexBuffer;
  105005. /** @hidden */
  105006. _lastColliderWorldVertices: Nullable<Vector3[]>;
  105007. /** @hidden */
  105008. _trianglePlanes: Plane[];
  105009. /** @hidden */
  105010. _lastColliderTransformMatrix: Nullable<Matrix>;
  105011. /** @hidden */
  105012. _renderId: number;
  105013. /** @hidden */
  105014. _alphaIndex: number;
  105015. /** @hidden */
  105016. _distanceToCamera: number;
  105017. /** @hidden */
  105018. _id: number;
  105019. private _currentMaterial;
  105020. /**
  105021. * Add a new submesh to a mesh
  105022. * @param materialIndex defines the material index to use
  105023. * @param verticesStart defines vertex index start
  105024. * @param verticesCount defines vertices count
  105025. * @param indexStart defines index start
  105026. * @param indexCount defines indices count
  105027. * @param mesh defines the parent mesh
  105028. * @param renderingMesh defines an optional rendering mesh
  105029. * @param createBoundingBox defines if bounding box should be created for this submesh
  105030. * @returns the new submesh
  105031. */
  105032. static AddToMesh(materialIndex: number, verticesStart: number, verticesCount: number, indexStart: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox?: boolean): SubMesh;
  105033. /**
  105034. * Creates a new submesh
  105035. * @param materialIndex defines the material index to use
  105036. * @param verticesStart defines vertex index start
  105037. * @param verticesCount defines vertices count
  105038. * @param indexStart defines index start
  105039. * @param indexCount defines indices count
  105040. * @param mesh defines the parent mesh
  105041. * @param renderingMesh defines an optional rendering mesh
  105042. * @param createBoundingBox defines if bounding box should be created for this submesh
  105043. * @param addToMesh defines a boolean indicating that the submesh must be added to the mesh.subMeshes array (true by default)
  105044. */
  105045. constructor(
  105046. /** the material index to use */
  105047. materialIndex: number,
  105048. /** vertex index start */
  105049. verticesStart: number,
  105050. /** vertices count */
  105051. verticesCount: number,
  105052. /** index start */
  105053. indexStart: number,
  105054. /** indices count */
  105055. indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox?: boolean, addToMesh?: boolean);
  105056. /**
  105057. * Returns true if this submesh covers the entire parent mesh
  105058. * @ignorenaming
  105059. */
  105060. get IsGlobal(): boolean;
  105061. /**
  105062. * Returns the submesh BoudingInfo object
  105063. * @returns current bounding info (or mesh's one if the submesh is global)
  105064. */
  105065. getBoundingInfo(): BoundingInfo;
  105066. /**
  105067. * Sets the submesh BoundingInfo
  105068. * @param boundingInfo defines the new bounding info to use
  105069. * @returns the SubMesh
  105070. */
  105071. setBoundingInfo(boundingInfo: BoundingInfo): SubMesh;
  105072. /**
  105073. * Returns the mesh of the current submesh
  105074. * @return the parent mesh
  105075. */
  105076. getMesh(): AbstractMesh;
  105077. /**
  105078. * Returns the rendering mesh of the submesh
  105079. * @returns the rendering mesh (could be different from parent mesh)
  105080. */
  105081. getRenderingMesh(): Mesh;
  105082. /**
  105083. * Returns the replacement mesh of the submesh
  105084. * @returns the replacement mesh (could be different from parent mesh)
  105085. */
  105086. getReplacementMesh(): Nullable<AbstractMesh>;
  105087. /**
  105088. * Returns the effective mesh of the submesh
  105089. * @returns the effective mesh (could be different from parent mesh)
  105090. */
  105091. getEffectiveMesh(): AbstractMesh;
  105092. /**
  105093. * Returns the submesh material
  105094. * @returns null or the current material
  105095. */
  105096. getMaterial(): Nullable<Material>;
  105097. private _IsMultiMaterial;
  105098. /**
  105099. * Sets a new updated BoundingInfo object to the submesh
  105100. * @param data defines an optional position array to use to determine the bounding info
  105101. * @returns the SubMesh
  105102. */
  105103. refreshBoundingInfo(data?: Nullable<FloatArray>): SubMesh;
  105104. /** @hidden */
  105105. _checkCollision(collider: Collider): boolean;
  105106. /**
  105107. * Updates the submesh BoundingInfo
  105108. * @param world defines the world matrix to use to update the bounding info
  105109. * @returns the submesh
  105110. */
  105111. updateBoundingInfo(world: DeepImmutable<Matrix>): SubMesh;
  105112. /**
  105113. * True is the submesh bounding box intersects the frustum defined by the passed array of planes.
  105114. * @param frustumPlanes defines the frustum planes
  105115. * @returns true if the submesh is intersecting with the frustum
  105116. */
  105117. isInFrustum(frustumPlanes: Plane[]): boolean;
  105118. /**
  105119. * True is the submesh bounding box is completely inside the frustum defined by the passed array of planes
  105120. * @param frustumPlanes defines the frustum planes
  105121. * @returns true if the submesh is inside the frustum
  105122. */
  105123. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  105124. /**
  105125. * Renders the submesh
  105126. * @param enableAlphaMode defines if alpha needs to be used
  105127. * @returns the submesh
  105128. */
  105129. render(enableAlphaMode: boolean): SubMesh;
  105130. /**
  105131. * @hidden
  105132. */
  105133. _getLinesIndexBuffer(indices: IndicesArray, engine: Engine): DataBuffer;
  105134. /**
  105135. * Checks if the submesh intersects with a ray
  105136. * @param ray defines the ray to test
  105137. * @returns true is the passed ray intersects the submesh bounding box
  105138. */
  105139. canIntersects(ray: Ray): boolean;
  105140. /**
  105141. * Intersects current submesh with a ray
  105142. * @param ray defines the ray to test
  105143. * @param positions defines mesh's positions array
  105144. * @param indices defines mesh's indices array
  105145. * @param fastCheck defines if the first intersection will be used (and not the closest)
  105146. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  105147. * @returns intersection info or null if no intersection
  105148. */
  105149. intersects(ray: Ray, positions: Vector3[], indices: IndicesArray, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<IntersectionInfo>;
  105150. /** @hidden */
  105151. private _intersectLines;
  105152. /** @hidden */
  105153. private _intersectUnIndexedLines;
  105154. /** @hidden */
  105155. private _intersectTriangles;
  105156. /** @hidden */
  105157. private _intersectUnIndexedTriangles;
  105158. /** @hidden */
  105159. _rebuild(): void;
  105160. /**
  105161. * Creates a new submesh from the passed mesh
  105162. * @param newMesh defines the new hosting mesh
  105163. * @param newRenderingMesh defines an optional rendering mesh
  105164. * @returns the new submesh
  105165. */
  105166. clone(newMesh: AbstractMesh, newRenderingMesh?: Mesh): SubMesh;
  105167. /**
  105168. * Release associated resources
  105169. */
  105170. dispose(): void;
  105171. /**
  105172. * Gets the class name
  105173. * @returns the string "SubMesh".
  105174. */
  105175. getClassName(): string;
  105176. /**
  105177. * Creates a new submesh from indices data
  105178. * @param materialIndex the index of the main mesh material
  105179. * @param startIndex the index where to start the copy in the mesh indices array
  105180. * @param indexCount the number of indices to copy then from the startIndex
  105181. * @param mesh the main mesh to create the submesh from
  105182. * @param renderingMesh the optional rendering mesh
  105183. * @returns a new submesh
  105184. */
  105185. static CreateFromIndices(materialIndex: number, startIndex: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh): SubMesh;
  105186. }
  105187. }
  105188. declare module BABYLON {
  105189. /**
  105190. * Class used to represent data loading progression
  105191. */
  105192. export class SceneLoaderFlags {
  105193. private static _ForceFullSceneLoadingForIncremental;
  105194. private static _ShowLoadingScreen;
  105195. private static _CleanBoneMatrixWeights;
  105196. private static _loggingLevel;
  105197. /**
  105198. * Gets or sets a boolean indicating if entire scene must be loaded even if scene contains incremental data
  105199. */
  105200. static get ForceFullSceneLoadingForIncremental(): boolean;
  105201. static set ForceFullSceneLoadingForIncremental(value: boolean);
  105202. /**
  105203. * Gets or sets a boolean indicating if loading screen must be displayed while loading a scene
  105204. */
  105205. static get ShowLoadingScreen(): boolean;
  105206. static set ShowLoadingScreen(value: boolean);
  105207. /**
  105208. * Defines the current logging level (while loading the scene)
  105209. * @ignorenaming
  105210. */
  105211. static get loggingLevel(): number;
  105212. static set loggingLevel(value: number);
  105213. /**
  105214. * Gets or set a boolean indicating if matrix weights must be cleaned upon loading
  105215. */
  105216. static get CleanBoneMatrixWeights(): boolean;
  105217. static set CleanBoneMatrixWeights(value: boolean);
  105218. }
  105219. }
  105220. declare module BABYLON {
  105221. /**
  105222. * Class used to store geometry data (vertex buffers + index buffer)
  105223. */
  105224. export class Geometry implements IGetSetVerticesData {
  105225. /**
  105226. * Gets or sets the ID of the geometry
  105227. */
  105228. id: string;
  105229. /**
  105230. * Gets or sets the unique ID of the geometry
  105231. */
  105232. uniqueId: number;
  105233. /**
  105234. * Gets the delay loading state of the geometry (none by default which means not delayed)
  105235. */
  105236. delayLoadState: number;
  105237. /**
  105238. * Gets the file containing the data to load when running in delay load state
  105239. */
  105240. delayLoadingFile: Nullable<string>;
  105241. /**
  105242. * Callback called when the geometry is updated
  105243. */
  105244. onGeometryUpdated: (geometry: Geometry, kind?: string) => void;
  105245. private _scene;
  105246. private _engine;
  105247. private _meshes;
  105248. private _totalVertices;
  105249. /** @hidden */
  105250. _indices: IndicesArray;
  105251. /** @hidden */
  105252. _vertexBuffers: {
  105253. [key: string]: VertexBuffer;
  105254. };
  105255. private _isDisposed;
  105256. private _extend;
  105257. private _boundingBias;
  105258. /** @hidden */
  105259. _delayInfo: Array<string>;
  105260. private _indexBuffer;
  105261. private _indexBufferIsUpdatable;
  105262. /** @hidden */
  105263. _boundingInfo: Nullable<BoundingInfo>;
  105264. /** @hidden */
  105265. _delayLoadingFunction: Nullable<(any: any, geometry: Geometry) => void>;
  105266. /** @hidden */
  105267. _softwareSkinningFrameId: number;
  105268. private _vertexArrayObjects;
  105269. private _updatable;
  105270. /** @hidden */
  105271. _positions: Nullable<Vector3[]>;
  105272. /**
  105273. * 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
  105274. */
  105275. get boundingBias(): Vector2;
  105276. /**
  105277. * 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
  105278. */
  105279. set boundingBias(value: Vector2);
  105280. /**
  105281. * Static function used to attach a new empty geometry to a mesh
  105282. * @param mesh defines the mesh to attach the geometry to
  105283. * @returns the new Geometry
  105284. */
  105285. static CreateGeometryForMesh(mesh: Mesh): Geometry;
  105286. /** Get the list of meshes using this geometry */
  105287. get meshes(): Mesh[];
  105288. /**
  105289. * 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
  105290. * and won't be computed based on the vertex positions (which is what we get when useBoundingInfoFromGeometry = false)
  105291. */
  105292. useBoundingInfoFromGeometry: boolean;
  105293. /**
  105294. * Creates a new geometry
  105295. * @param id defines the unique ID
  105296. * @param scene defines the hosting scene
  105297. * @param vertexData defines the VertexData used to get geometry data
  105298. * @param updatable defines if geometry must be updatable (false by default)
  105299. * @param mesh defines the mesh that will be associated with the geometry
  105300. */
  105301. constructor(id: string, scene: Scene, vertexData?: VertexData, updatable?: boolean, mesh?: Nullable<Mesh>);
  105302. /**
  105303. * Gets the current extend of the geometry
  105304. */
  105305. get extend(): {
  105306. minimum: Vector3;
  105307. maximum: Vector3;
  105308. };
  105309. /**
  105310. * Gets the hosting scene
  105311. * @returns the hosting Scene
  105312. */
  105313. getScene(): Scene;
  105314. /**
  105315. * Gets the hosting engine
  105316. * @returns the hosting Engine
  105317. */
  105318. getEngine(): Engine;
  105319. /**
  105320. * Defines if the geometry is ready to use
  105321. * @returns true if the geometry is ready to be used
  105322. */
  105323. isReady(): boolean;
  105324. /**
  105325. * Gets a value indicating that the geometry should not be serialized
  105326. */
  105327. get doNotSerialize(): boolean;
  105328. /** @hidden */
  105329. _rebuild(): void;
  105330. /**
  105331. * Affects all geometry data in one call
  105332. * @param vertexData defines the geometry data
  105333. * @param updatable defines if the geometry must be flagged as updatable (false as default)
  105334. */
  105335. setAllVerticesData(vertexData: VertexData, updatable?: boolean): void;
  105336. /**
  105337. * Set specific vertex data
  105338. * @param kind defines the data kind (Position, normal, etc...)
  105339. * @param data defines the vertex data to use
  105340. * @param updatable defines if the vertex must be flagged as updatable (false as default)
  105341. * @param stride defines the stride to use (0 by default). This value is deduced from the kind value if not specified
  105342. */
  105343. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): void;
  105344. /**
  105345. * Removes a specific vertex data
  105346. * @param kind defines the data kind (Position, normal, etc...)
  105347. */
  105348. removeVerticesData(kind: string): void;
  105349. /**
  105350. * Affect a vertex buffer to the geometry. the vertexBuffer.getKind() function is used to determine where to store the data
  105351. * @param buffer defines the vertex buffer to use
  105352. * @param totalVertices defines the total number of vertices for position kind (could be null)
  105353. */
  105354. setVerticesBuffer(buffer: VertexBuffer, totalVertices?: Nullable<number>): void;
  105355. /**
  105356. * Update a specific vertex buffer
  105357. * This function will directly update the underlying DataBuffer according to the passed numeric array or Float32Array
  105358. * It will do nothing if the buffer is not updatable
  105359. * @param kind defines the data kind (Position, normal, etc...)
  105360. * @param data defines the data to use
  105361. * @param offset defines the offset in the target buffer where to store the data
  105362. * @param useBytes set to true if the offset is in bytes
  105363. */
  105364. updateVerticesDataDirectly(kind: string, data: DataArray, offset: number, useBytes?: boolean): void;
  105365. /**
  105366. * Update a specific vertex buffer
  105367. * This function will create a new buffer if the current one is not updatable
  105368. * @param kind defines the data kind (Position, normal, etc...)
  105369. * @param data defines the data to use
  105370. * @param updateExtends defines if the geometry extends must be recomputed (false by default)
  105371. */
  105372. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean): void;
  105373. private _updateBoundingInfo;
  105374. /** @hidden */
  105375. _bind(effect: Nullable<Effect>, indexToBind?: Nullable<DataBuffer>): void;
  105376. /**
  105377. * Gets total number of vertices
  105378. * @returns the total number of vertices
  105379. */
  105380. getTotalVertices(): number;
  105381. /**
  105382. * Gets a specific vertex data attached to this geometry. Float data is constructed if the vertex buffer data cannot be returned directly.
  105383. * @param kind defines the data kind (Position, normal, etc...)
  105384. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  105385. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  105386. * @returns a float array containing vertex data
  105387. */
  105388. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  105389. /**
  105390. * Returns a boolean defining if the vertex data for the requested `kind` is updatable
  105391. * @param kind defines the data kind (Position, normal, etc...)
  105392. * @returns true if the vertex buffer with the specified kind is updatable
  105393. */
  105394. isVertexBufferUpdatable(kind: string): boolean;
  105395. /**
  105396. * Gets a specific vertex buffer
  105397. * @param kind defines the data kind (Position, normal, etc...)
  105398. * @returns a VertexBuffer
  105399. */
  105400. getVertexBuffer(kind: string): Nullable<VertexBuffer>;
  105401. /**
  105402. * Returns all vertex buffers
  105403. * @return an object holding all vertex buffers indexed by kind
  105404. */
  105405. getVertexBuffers(): Nullable<{
  105406. [key: string]: VertexBuffer;
  105407. }>;
  105408. /**
  105409. * Gets a boolean indicating if specific vertex buffer is present
  105410. * @param kind defines the data kind (Position, normal, etc...)
  105411. * @returns true if data is present
  105412. */
  105413. isVerticesDataPresent(kind: string): boolean;
  105414. /**
  105415. * Gets a list of all attached data kinds (Position, normal, etc...)
  105416. * @returns a list of string containing all kinds
  105417. */
  105418. getVerticesDataKinds(): string[];
  105419. /**
  105420. * Update index buffer
  105421. * @param indices defines the indices to store in the index buffer
  105422. * @param offset defines the offset in the target buffer where to store the data
  105423. * @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)
  105424. */
  105425. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): void;
  105426. /**
  105427. * Creates a new index buffer
  105428. * @param indices defines the indices to store in the index buffer
  105429. * @param totalVertices defines the total number of vertices (could be null)
  105430. * @param updatable defines if the index buffer must be flagged as updatable (false by default)
  105431. */
  105432. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>, updatable?: boolean): void;
  105433. /**
  105434. * Return the total number of indices
  105435. * @returns the total number of indices
  105436. */
  105437. getTotalIndices(): number;
  105438. /**
  105439. * Gets the index buffer array
  105440. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  105441. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  105442. * @returns the index buffer array
  105443. */
  105444. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  105445. /**
  105446. * Gets the index buffer
  105447. * @return the index buffer
  105448. */
  105449. getIndexBuffer(): Nullable<DataBuffer>;
  105450. /** @hidden */
  105451. _releaseVertexArrayObject(effect?: Nullable<Effect>): void;
  105452. /**
  105453. * Release the associated resources for a specific mesh
  105454. * @param mesh defines the source mesh
  105455. * @param shouldDispose defines if the geometry must be disposed if there is no more mesh pointing to it
  105456. */
  105457. releaseForMesh(mesh: Mesh, shouldDispose?: boolean): void;
  105458. /**
  105459. * Apply current geometry to a given mesh
  105460. * @param mesh defines the mesh to apply geometry to
  105461. */
  105462. applyToMesh(mesh: Mesh): void;
  105463. private _updateExtend;
  105464. private _applyToMesh;
  105465. private notifyUpdate;
  105466. /**
  105467. * Load the geometry if it was flagged as delay loaded
  105468. * @param scene defines the hosting scene
  105469. * @param onLoaded defines a callback called when the geometry is loaded
  105470. */
  105471. load(scene: Scene, onLoaded?: () => void): void;
  105472. private _queueLoad;
  105473. /**
  105474. * Invert the geometry to move from a right handed system to a left handed one.
  105475. */
  105476. toLeftHanded(): void;
  105477. /** @hidden */
  105478. _resetPointsArrayCache(): void;
  105479. /** @hidden */
  105480. _generatePointsArray(): boolean;
  105481. /**
  105482. * Gets a value indicating if the geometry is disposed
  105483. * @returns true if the geometry was disposed
  105484. */
  105485. isDisposed(): boolean;
  105486. private _disposeVertexArrayObjects;
  105487. /**
  105488. * Free all associated resources
  105489. */
  105490. dispose(): void;
  105491. /**
  105492. * Clone the current geometry into a new geometry
  105493. * @param id defines the unique ID of the new geometry
  105494. * @returns a new geometry object
  105495. */
  105496. copy(id: string): Geometry;
  105497. /**
  105498. * Serialize the current geometry info (and not the vertices data) into a JSON object
  105499. * @return a JSON representation of the current geometry data (without the vertices data)
  105500. */
  105501. serialize(): any;
  105502. private toNumberArray;
  105503. /**
  105504. * Serialize all vertices data into a JSON oject
  105505. * @returns a JSON representation of the current geometry data
  105506. */
  105507. serializeVerticeData(): any;
  105508. /**
  105509. * Extracts a clone of a mesh geometry
  105510. * @param mesh defines the source mesh
  105511. * @param id defines the unique ID of the new geometry object
  105512. * @returns the new geometry object
  105513. */
  105514. static ExtractFromMesh(mesh: Mesh, id: string): Nullable<Geometry>;
  105515. /**
  105516. * You should now use Tools.RandomId(), this method is still here for legacy reasons.
  105517. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  105518. * Be aware Math.random() could cause collisions, but:
  105519. * "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"
  105520. * @returns a string containing a new GUID
  105521. */
  105522. static RandomId(): string;
  105523. /** @hidden */
  105524. static _ImportGeometry(parsedGeometry: any, mesh: Mesh): void;
  105525. private static _CleanMatricesWeights;
  105526. /**
  105527. * Create a new geometry from persisted data (Using .babylon file format)
  105528. * @param parsedVertexData defines the persisted data
  105529. * @param scene defines the hosting scene
  105530. * @param rootUrl defines the root url to use to load assets (like delayed data)
  105531. * @returns the new geometry object
  105532. */
  105533. static Parse(parsedVertexData: any, scene: Scene, rootUrl: string): Nullable<Geometry>;
  105534. }
  105535. }
  105536. declare module BABYLON {
  105537. /**
  105538. * Define an interface for all classes that will get and set the data on vertices
  105539. */
  105540. export interface IGetSetVerticesData {
  105541. /**
  105542. * Gets a boolean indicating if specific vertex data is present
  105543. * @param kind defines the vertex data kind to use
  105544. * @returns true is data kind is present
  105545. */
  105546. isVerticesDataPresent(kind: string): boolean;
  105547. /**
  105548. * Gets a specific vertex data attached to this geometry. Float data is constructed if the vertex buffer data cannot be returned directly.
  105549. * @param kind defines the data kind (Position, normal, etc...)
  105550. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  105551. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  105552. * @returns a float array containing vertex data
  105553. */
  105554. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  105555. /**
  105556. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  105557. * @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.
  105558. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  105559. * @returns the indices array or an empty array if the mesh has no geometry
  105560. */
  105561. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  105562. /**
  105563. * Set specific vertex data
  105564. * @param kind defines the data kind (Position, normal, etc...)
  105565. * @param data defines the vertex data to use
  105566. * @param updatable defines if the vertex must be flagged as updatable (false as default)
  105567. * @param stride defines the stride to use (0 by default). This value is deduced from the kind value if not specified
  105568. */
  105569. setVerticesData(kind: string, data: FloatArray, updatable: boolean): void;
  105570. /**
  105571. * Update a specific associated vertex buffer
  105572. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  105573. * - VertexBuffer.PositionKind
  105574. * - VertexBuffer.UVKind
  105575. * - VertexBuffer.UV2Kind
  105576. * - VertexBuffer.UV3Kind
  105577. * - VertexBuffer.UV4Kind
  105578. * - VertexBuffer.UV5Kind
  105579. * - VertexBuffer.UV6Kind
  105580. * - VertexBuffer.ColorKind
  105581. * - VertexBuffer.MatricesIndicesKind
  105582. * - VertexBuffer.MatricesIndicesExtraKind
  105583. * - VertexBuffer.MatricesWeightsKind
  105584. * - VertexBuffer.MatricesWeightsExtraKind
  105585. * @param data defines the data source
  105586. * @param updateExtends defines if extends info of the mesh must be updated (can be null). This is mostly useful for "position" kind
  105587. * @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)
  105588. */
  105589. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): void;
  105590. /**
  105591. * Creates a new index buffer
  105592. * @param indices defines the indices to store in the index buffer
  105593. * @param totalVertices defines the total number of vertices (could be null)
  105594. * @param updatable defines if the index buffer must be flagged as updatable (false by default)
  105595. */
  105596. setIndices(indices: IndicesArray, totalVertices: Nullable<number>, updatable?: boolean): void;
  105597. }
  105598. /**
  105599. * This class contains the various kinds of data on every vertex of a mesh used in determining its shape and appearance
  105600. */
  105601. export class VertexData {
  105602. /**
  105603. * Mesh side orientation : usually the external or front surface
  105604. */
  105605. static readonly FRONTSIDE: number;
  105606. /**
  105607. * Mesh side orientation : usually the internal or back surface
  105608. */
  105609. static readonly BACKSIDE: number;
  105610. /**
  105611. * Mesh side orientation : both internal and external or front and back surfaces
  105612. */
  105613. static readonly DOUBLESIDE: number;
  105614. /**
  105615. * Mesh side orientation : by default, `FRONTSIDE`
  105616. */
  105617. static readonly DEFAULTSIDE: number;
  105618. /**
  105619. * An array of the x, y, z position of each vertex [...., x, y, z, .....]
  105620. */
  105621. positions: Nullable<FloatArray>;
  105622. /**
  105623. * An array of the x, y, z normal vector of each vertex [...., x, y, z, .....]
  105624. */
  105625. normals: Nullable<FloatArray>;
  105626. /**
  105627. * An array of the x, y, z tangent vector of each vertex [...., x, y, z, .....]
  105628. */
  105629. tangents: Nullable<FloatArray>;
  105630. /**
  105631. * An array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  105632. */
  105633. uvs: Nullable<FloatArray>;
  105634. /**
  105635. * A second array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  105636. */
  105637. uvs2: Nullable<FloatArray>;
  105638. /**
  105639. * A third array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  105640. */
  105641. uvs3: Nullable<FloatArray>;
  105642. /**
  105643. * A fourth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  105644. */
  105645. uvs4: Nullable<FloatArray>;
  105646. /**
  105647. * A fifth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  105648. */
  105649. uvs5: Nullable<FloatArray>;
  105650. /**
  105651. * A sixth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  105652. */
  105653. uvs6: Nullable<FloatArray>;
  105654. /**
  105655. * An array of the r, g, b, a, color of each vertex [...., r, g, b, a, .....]
  105656. */
  105657. colors: Nullable<FloatArray>;
  105658. /**
  105659. * 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).
  105660. */
  105661. matricesIndices: Nullable<FloatArray>;
  105662. /**
  105663. * An array containing the list of weights defining the weight of each indexed matrix in the final computation
  105664. */
  105665. matricesWeights: Nullable<FloatArray>;
  105666. /**
  105667. * An array extending the number of possible indices
  105668. */
  105669. matricesIndicesExtra: Nullable<FloatArray>;
  105670. /**
  105671. * An array extending the number of possible weights when the number of indices is extended
  105672. */
  105673. matricesWeightsExtra: Nullable<FloatArray>;
  105674. /**
  105675. * An array of i, j, k the three vertex indices required for each triangular facet [...., i, j, k .....]
  105676. */
  105677. indices: Nullable<IndicesArray>;
  105678. /**
  105679. * Uses the passed data array to set the set the values for the specified kind of data
  105680. * @param data a linear array of floating numbers
  105681. * @param kind the type of data that is being set, eg positions, colors etc
  105682. */
  105683. set(data: FloatArray, kind: string): void;
  105684. /**
  105685. * Associates the vertexData to the passed Mesh.
  105686. * Sets it as updatable or not (default `false`)
  105687. * @param mesh the mesh the vertexData is applied to
  105688. * @param updatable when used and having the value true allows new data to update the vertexData
  105689. * @returns the VertexData
  105690. */
  105691. applyToMesh(mesh: Mesh, updatable?: boolean): VertexData;
  105692. /**
  105693. * Associates the vertexData to the passed Geometry.
  105694. * Sets it as updatable or not (default `false`)
  105695. * @param geometry the geometry the vertexData is applied to
  105696. * @param updatable when used and having the value true allows new data to update the vertexData
  105697. * @returns VertexData
  105698. */
  105699. applyToGeometry(geometry: Geometry, updatable?: boolean): VertexData;
  105700. /**
  105701. * Updates the associated mesh
  105702. * @param mesh the mesh to be updated
  105703. * @param updateExtends when true the mesh BoundingInfo will be renewed when and if position kind is updated, optional with default false
  105704. * @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
  105705. * @returns VertexData
  105706. */
  105707. updateMesh(mesh: Mesh): VertexData;
  105708. /**
  105709. * Updates the associated geometry
  105710. * @param geometry the geometry to be updated
  105711. * @param updateExtends when true BoundingInfo will be renewed when and if position kind is updated, optional with default false
  105712. * @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
  105713. * @returns VertexData.
  105714. */
  105715. updateGeometry(geometry: Geometry): VertexData;
  105716. private _applyTo;
  105717. private _update;
  105718. /**
  105719. * Transforms each position and each normal of the vertexData according to the passed Matrix
  105720. * @param matrix the transforming matrix
  105721. * @returns the VertexData
  105722. */
  105723. transform(matrix: Matrix): VertexData;
  105724. /**
  105725. * Merges the passed VertexData into the current one
  105726. * @param other the VertexData to be merged into the current one
  105727. * @param use32BitsIndices defines a boolean indicating if indices must be store in a 32 bits array
  105728. * @returns the modified VertexData
  105729. */
  105730. merge(other: VertexData, use32BitsIndices?: boolean): VertexData;
  105731. private _mergeElement;
  105732. private _validate;
  105733. /**
  105734. * Serializes the VertexData
  105735. * @returns a serialized object
  105736. */
  105737. serialize(): any;
  105738. /**
  105739. * Extracts the vertexData from a mesh
  105740. * @param mesh the mesh from which to extract the VertexData
  105741. * @param copyWhenShared defines if the VertexData must be cloned when shared between multiple meshes, optional, default false
  105742. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  105743. * @returns the object VertexData associated to the passed mesh
  105744. */
  105745. static ExtractFromMesh(mesh: Mesh, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  105746. /**
  105747. * Extracts the vertexData from the geometry
  105748. * @param geometry the geometry from which to extract the VertexData
  105749. * @param copyWhenShared defines if the VertexData must be cloned when the geometrty is shared between multiple meshes, optional, default false
  105750. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  105751. * @returns the object VertexData associated to the passed mesh
  105752. */
  105753. static ExtractFromGeometry(geometry: Geometry, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  105754. private static _ExtractFrom;
  105755. /**
  105756. * Creates the VertexData for a Ribbon
  105757. * @param options an object used to set the following optional parameters for the ribbon, required but can be empty
  105758. * * pathArray array of paths, each of which an array of successive Vector3
  105759. * * closeArray creates a seam between the first and the last paths of the pathArray, optional, default false
  105760. * * closePath creates a seam between the first and the last points of each path of the path array, optional, default false
  105761. * * 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
  105762. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  105763. * * 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)
  105764. * * 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)
  105765. * * invertUV swaps in the U and V coordinates when applying a texture, optional, default false
  105766. * * uvs a linear array, of length 2 * number of vertices, of custom UV values, optional
  105767. * * colors a linear array, of length 4 * number of vertices, of custom color values, optional
  105768. * @returns the VertexData of the ribbon
  105769. */
  105770. static CreateRibbon(options: {
  105771. pathArray: Vector3[][];
  105772. closeArray?: boolean;
  105773. closePath?: boolean;
  105774. offset?: number;
  105775. sideOrientation?: number;
  105776. frontUVs?: Vector4;
  105777. backUVs?: Vector4;
  105778. invertUV?: boolean;
  105779. uvs?: Vector2[];
  105780. colors?: Color4[];
  105781. }): VertexData;
  105782. /**
  105783. * Creates the VertexData for a box
  105784. * @param options an object used to set the following optional parameters for the box, required but can be empty
  105785. * * size sets the width, height and depth of the box to the value of size, optional default 1
  105786. * * width sets the width (x direction) of the box, overwrites the width set by size, optional, default size
  105787. * * height sets the height (y direction) of the box, overwrites the height set by size, optional, default size
  105788. * * depth sets the depth (z direction) of the box, overwrites the depth set by size, optional, default size
  105789. * * faceUV an array of 6 Vector4 elements used to set different images to each box side
  105790. * * faceColors an array of 6 Color3 elements used to set different colors to each box side
  105791. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  105792. * * 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)
  105793. * * 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)
  105794. * @returns the VertexData of the box
  105795. */
  105796. static CreateBox(options: {
  105797. size?: number;
  105798. width?: number;
  105799. height?: number;
  105800. depth?: number;
  105801. faceUV?: Vector4[];
  105802. faceColors?: Color4[];
  105803. sideOrientation?: number;
  105804. frontUVs?: Vector4;
  105805. backUVs?: Vector4;
  105806. }): VertexData;
  105807. /**
  105808. * Creates the VertexData for a tiled box
  105809. * @param options an object used to set the following optional parameters for the box, required but can be empty
  105810. * * faceTiles sets the pattern, tile size and number of tiles for a face
  105811. * * faceUV an array of 6 Vector4 elements used to set different images to each box side
  105812. * * faceColors an array of 6 Color3 elements used to set different colors to each box side
  105813. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  105814. * @returns the VertexData of the box
  105815. */
  105816. static CreateTiledBox(options: {
  105817. pattern?: number;
  105818. width?: number;
  105819. height?: number;
  105820. depth?: number;
  105821. tileSize?: number;
  105822. tileWidth?: number;
  105823. tileHeight?: number;
  105824. alignHorizontal?: number;
  105825. alignVertical?: number;
  105826. faceUV?: Vector4[];
  105827. faceColors?: Color4[];
  105828. sideOrientation?: number;
  105829. }): VertexData;
  105830. /**
  105831. * Creates the VertexData for a tiled plane
  105832. * @param options an object used to set the following optional parameters for the box, required but can be empty
  105833. * * pattern a limited pattern arrangement depending on the number
  105834. * * tileSize sets the width, height and depth of the tile to the value of size, optional default 1
  105835. * * tileWidth sets the width (x direction) of the tile, overwrites the width set by size, optional, default size
  105836. * * tileHeight sets the height (y direction) of the tile, overwrites the height set by size, optional, default size
  105837. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  105838. * * 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)
  105839. * * 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)
  105840. * @returns the VertexData of the tiled plane
  105841. */
  105842. static CreateTiledPlane(options: {
  105843. pattern?: number;
  105844. tileSize?: number;
  105845. tileWidth?: number;
  105846. tileHeight?: number;
  105847. size?: number;
  105848. width?: number;
  105849. height?: number;
  105850. alignHorizontal?: number;
  105851. alignVertical?: number;
  105852. sideOrientation?: number;
  105853. frontUVs?: Vector4;
  105854. backUVs?: Vector4;
  105855. }): VertexData;
  105856. /**
  105857. * Creates the VertexData for an ellipsoid, defaults to a sphere
  105858. * @param options an object used to set the following optional parameters for the box, required but can be empty
  105859. * * segments sets the number of horizontal strips optional, default 32
  105860. * * diameter sets the axes dimensions, diameterX, diameterY and diameterZ to the value of diameter, optional default 1
  105861. * * diameterX sets the diameterX (x direction) of the ellipsoid, overwrites the diameterX set by diameter, optional, default diameter
  105862. * * diameterY sets the diameterY (y direction) of the ellipsoid, overwrites the diameterY set by diameter, optional, default diameter
  105863. * * diameterZ sets the diameterZ (z direction) of the ellipsoid, overwrites the diameterZ set by diameter, optional, default diameter
  105864. * * 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
  105865. * * 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
  105866. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  105867. * * 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)
  105868. * * 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)
  105869. * @returns the VertexData of the ellipsoid
  105870. */
  105871. static CreateSphere(options: {
  105872. segments?: number;
  105873. diameter?: number;
  105874. diameterX?: number;
  105875. diameterY?: number;
  105876. diameterZ?: number;
  105877. arc?: number;
  105878. slice?: number;
  105879. sideOrientation?: number;
  105880. frontUVs?: Vector4;
  105881. backUVs?: Vector4;
  105882. }): VertexData;
  105883. /**
  105884. * Creates the VertexData for a cylinder, cone or prism
  105885. * @param options an object used to set the following optional parameters for the box, required but can be empty
  105886. * * height sets the height (y direction) of the cylinder, optional, default 2
  105887. * * diameterTop sets the diameter of the top of the cone, overwrites diameter, optional, default diameter
  105888. * * diameterBottom sets the diameter of the bottom of the cone, overwrites diameter, optional, default diameter
  105889. * * diameter sets the diameter of the top and bottom of the cone, optional default 1
  105890. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  105891. * * subdivisions` the number of rings along the cylinder height, optional, default 1
  105892. * * 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
  105893. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  105894. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  105895. * * hasRings when true makes each subdivision independantly treated as a face for faceUV and faceColors, optional, default false
  105896. * * enclose when true closes an open cylinder by adding extra flat faces between the height axis and vertical edges, think cut cake
  105897. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  105898. * * 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)
  105899. * * 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)
  105900. * @returns the VertexData of the cylinder, cone or prism
  105901. */
  105902. static CreateCylinder(options: {
  105903. height?: number;
  105904. diameterTop?: number;
  105905. diameterBottom?: number;
  105906. diameter?: number;
  105907. tessellation?: number;
  105908. subdivisions?: number;
  105909. arc?: number;
  105910. faceColors?: Color4[];
  105911. faceUV?: Vector4[];
  105912. hasRings?: boolean;
  105913. enclose?: boolean;
  105914. sideOrientation?: number;
  105915. frontUVs?: Vector4;
  105916. backUVs?: Vector4;
  105917. }): VertexData;
  105918. /**
  105919. * Creates the VertexData for a torus
  105920. * @param options an object used to set the following optional parameters for the box, required but can be empty
  105921. * * diameter the diameter of the torus, optional default 1
  105922. * * thickness the diameter of the tube forming the torus, optional default 0.5
  105923. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  105924. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  105925. * * 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)
  105926. * * 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)
  105927. * @returns the VertexData of the torus
  105928. */
  105929. static CreateTorus(options: {
  105930. diameter?: number;
  105931. thickness?: number;
  105932. tessellation?: number;
  105933. sideOrientation?: number;
  105934. frontUVs?: Vector4;
  105935. backUVs?: Vector4;
  105936. }): VertexData;
  105937. /**
  105938. * Creates the VertexData of the LineSystem
  105939. * @param options an object used to set the following optional parameters for the LineSystem, required but can be empty
  105940. * - lines an array of lines, each line being an array of successive Vector3
  105941. * - colors an array of line colors, each of the line colors being an array of successive Color4, one per line point
  105942. * @returns the VertexData of the LineSystem
  105943. */
  105944. static CreateLineSystem(options: {
  105945. lines: Vector3[][];
  105946. colors?: Nullable<Color4[][]>;
  105947. }): VertexData;
  105948. /**
  105949. * Create the VertexData for a DashedLines
  105950. * @param options an object used to set the following optional parameters for the DashedLines, required but can be empty
  105951. * - points an array successive Vector3
  105952. * - dashSize the size of the dashes relative to the dash number, optional, default 3
  105953. * - gapSize the size of the gap between two successive dashes relative to the dash number, optional, default 1
  105954. * - dashNb the intended total number of dashes, optional, default 200
  105955. * @returns the VertexData for the DashedLines
  105956. */
  105957. static CreateDashedLines(options: {
  105958. points: Vector3[];
  105959. dashSize?: number;
  105960. gapSize?: number;
  105961. dashNb?: number;
  105962. }): VertexData;
  105963. /**
  105964. * Creates the VertexData for a Ground
  105965. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  105966. * - width the width (x direction) of the ground, optional, default 1
  105967. * - height the height (z direction) of the ground, optional, default 1
  105968. * - subdivisions the number of subdivisions per side, optional, default 1
  105969. * @returns the VertexData of the Ground
  105970. */
  105971. static CreateGround(options: {
  105972. width?: number;
  105973. height?: number;
  105974. subdivisions?: number;
  105975. subdivisionsX?: number;
  105976. subdivisionsY?: number;
  105977. }): VertexData;
  105978. /**
  105979. * Creates the VertexData for a TiledGround by subdividing the ground into tiles
  105980. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  105981. * * xmin the ground minimum X coordinate, optional, default -1
  105982. * * zmin the ground minimum Z coordinate, optional, default -1
  105983. * * xmax the ground maximum X coordinate, optional, default 1
  105984. * * zmax the ground maximum Z coordinate, optional, default 1
  105985. * * 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}
  105986. * * 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}
  105987. * @returns the VertexData of the TiledGround
  105988. */
  105989. static CreateTiledGround(options: {
  105990. xmin: number;
  105991. zmin: number;
  105992. xmax: number;
  105993. zmax: number;
  105994. subdivisions?: {
  105995. w: number;
  105996. h: number;
  105997. };
  105998. precision?: {
  105999. w: number;
  106000. h: number;
  106001. };
  106002. }): VertexData;
  106003. /**
  106004. * Creates the VertexData of the Ground designed from a heightmap
  106005. * @param options an object used to set the following parameters for the Ground, required and provided by MeshBuilder.CreateGroundFromHeightMap
  106006. * * width the width (x direction) of the ground
  106007. * * height the height (z direction) of the ground
  106008. * * subdivisions the number of subdivisions per side
  106009. * * minHeight the minimum altitude on the ground, optional, default 0
  106010. * * maxHeight the maximum altitude on the ground, optional default 1
  106011. * * colorFilter the filter to apply to the image pixel colors to compute the height, optional Color3, default (0.3, 0.59, 0.11)
  106012. * * buffer the array holding the image color data
  106013. * * bufferWidth the width of image
  106014. * * bufferHeight the height of image
  106015. * * alphaFilter Remove any data where the alpha channel is below this value, defaults 0 (all data visible)
  106016. * @returns the VertexData of the Ground designed from a heightmap
  106017. */
  106018. static CreateGroundFromHeightMap(options: {
  106019. width: number;
  106020. height: number;
  106021. subdivisions: number;
  106022. minHeight: number;
  106023. maxHeight: number;
  106024. colorFilter: Color3;
  106025. buffer: Uint8Array;
  106026. bufferWidth: number;
  106027. bufferHeight: number;
  106028. alphaFilter: number;
  106029. }): VertexData;
  106030. /**
  106031. * Creates the VertexData for a Plane
  106032. * @param options an object used to set the following optional parameters for the plane, required but can be empty
  106033. * * size sets the width and height of the plane to the value of size, optional default 1
  106034. * * width sets the width (x direction) of the plane, overwrites the width set by size, optional, default size
  106035. * * height sets the height (y direction) of the plane, overwrites the height set by size, optional, default size
  106036. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  106037. * * 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)
  106038. * * 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)
  106039. * @returns the VertexData of the box
  106040. */
  106041. static CreatePlane(options: {
  106042. size?: number;
  106043. width?: number;
  106044. height?: number;
  106045. sideOrientation?: number;
  106046. frontUVs?: Vector4;
  106047. backUVs?: Vector4;
  106048. }): VertexData;
  106049. /**
  106050. * Creates the VertexData of the Disc or regular Polygon
  106051. * @param options an object used to set the following optional parameters for the disc, required but can be empty
  106052. * * radius the radius of the disc, optional default 0.5
  106053. * * tessellation the number of polygon sides, optional, default 64
  106054. * * 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
  106055. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  106056. * * 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)
  106057. * * 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)
  106058. * @returns the VertexData of the box
  106059. */
  106060. static CreateDisc(options: {
  106061. radius?: number;
  106062. tessellation?: number;
  106063. arc?: number;
  106064. sideOrientation?: number;
  106065. frontUVs?: Vector4;
  106066. backUVs?: Vector4;
  106067. }): VertexData;
  106068. /**
  106069. * Creates the VertexData for an irregular Polygon in the XoZ plane using a mesh built by polygonTriangulation.build()
  106070. * All parameters are provided by MeshBuilder.CreatePolygon as needed
  106071. * @param polygon a mesh built from polygonTriangulation.build()
  106072. * @param sideOrientation takes the values Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  106073. * @param fUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  106074. * @param fColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  106075. * @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)
  106076. * @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)
  106077. * @param wrap a boolean, default false, when true and fUVs used texture is wrapped around all sides, when false texture is applied side
  106078. * @returns the VertexData of the Polygon
  106079. */
  106080. static CreatePolygon(polygon: Mesh, sideOrientation: number, fUV?: Vector4[], fColors?: Color4[], frontUVs?: Vector4, backUVs?: Vector4, wrap?: boolean): VertexData;
  106081. /**
  106082. * Creates the VertexData of the IcoSphere
  106083. * @param options an object used to set the following optional parameters for the IcoSphere, required but can be empty
  106084. * * radius the radius of the IcoSphere, optional default 1
  106085. * * radiusX allows stretching in the x direction, optional, default radius
  106086. * * radiusY allows stretching in the y direction, optional, default radius
  106087. * * radiusZ allows stretching in the z direction, optional, default radius
  106088. * * flat when true creates a flat shaded mesh, optional, default true
  106089. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  106090. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  106091. * * 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)
  106092. * * 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)
  106093. * @returns the VertexData of the IcoSphere
  106094. */
  106095. static CreateIcoSphere(options: {
  106096. radius?: number;
  106097. radiusX?: number;
  106098. radiusY?: number;
  106099. radiusZ?: number;
  106100. flat?: boolean;
  106101. subdivisions?: number;
  106102. sideOrientation?: number;
  106103. frontUVs?: Vector4;
  106104. backUVs?: Vector4;
  106105. }): VertexData;
  106106. /**
  106107. * Creates the VertexData for a Polyhedron
  106108. * @param options an object used to set the following optional parameters for the polyhedron, required but can be empty
  106109. * * type provided types are:
  106110. * * 0 : Tetrahedron, 1 : Octahedron, 2 : Dodecahedron, 3 : Icosahedron, 4 : Rhombicuboctahedron, 5 : Triangular Prism, 6 : Pentagonal Prism, 7 : Hexagonal Prism, 8 : Square Pyramid (J1)
  106111. * * 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)
  106112. * * size the size of the IcoSphere, optional default 1
  106113. * * sizeX allows stretching in the x direction, optional, default size
  106114. * * sizeY allows stretching in the y direction, optional, default size
  106115. * * sizeZ allows stretching in the z direction, optional, default size
  106116. * * 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
  106117. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  106118. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  106119. * * flat when true creates a flat shaded mesh, optional, default true
  106120. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  106121. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  106122. * * 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)
  106123. * * 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)
  106124. * @returns the VertexData of the Polyhedron
  106125. */
  106126. static CreatePolyhedron(options: {
  106127. type?: number;
  106128. size?: number;
  106129. sizeX?: number;
  106130. sizeY?: number;
  106131. sizeZ?: number;
  106132. custom?: any;
  106133. faceUV?: Vector4[];
  106134. faceColors?: Color4[];
  106135. flat?: boolean;
  106136. sideOrientation?: number;
  106137. frontUVs?: Vector4;
  106138. backUVs?: Vector4;
  106139. }): VertexData;
  106140. /**
  106141. * Creates the VertexData for a TorusKnot
  106142. * @param options an object used to set the following optional parameters for the TorusKnot, required but can be empty
  106143. * * radius the radius of the torus knot, optional, default 2
  106144. * * tube the thickness of the tube, optional, default 0.5
  106145. * * radialSegments the number of sides on each tube segments, optional, default 32
  106146. * * tubularSegments the number of tubes to decompose the knot into, optional, default 32
  106147. * * p the number of windings around the z axis, optional, default 2
  106148. * * q the number of windings around the x axis, optional, default 3
  106149. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  106150. * * 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)
  106151. * * 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)
  106152. * @returns the VertexData of the Torus Knot
  106153. */
  106154. static CreateTorusKnot(options: {
  106155. radius?: number;
  106156. tube?: number;
  106157. radialSegments?: number;
  106158. tubularSegments?: number;
  106159. p?: number;
  106160. q?: number;
  106161. sideOrientation?: number;
  106162. frontUVs?: Vector4;
  106163. backUVs?: Vector4;
  106164. }): VertexData;
  106165. /**
  106166. * Compute normals for given positions and indices
  106167. * @param positions an array of vertex positions, [...., x, y, z, ......]
  106168. * @param indices an array of indices in groups of three for each triangular facet, [...., i, j, k, ......]
  106169. * @param normals an array of vertex normals, [...., x, y, z, ......]
  106170. * @param options an object used to set the following optional parameters for the TorusKnot, optional
  106171. * * facetNormals : optional array of facet normals (vector3)
  106172. * * facetPositions : optional array of facet positions (vector3)
  106173. * * facetPartitioning : optional partitioning array. facetPositions is required for facetPartitioning computation
  106174. * * ratio : optional partitioning ratio / bounding box, required for facetPartitioning computation
  106175. * * bInfo : optional bounding info, required for facetPartitioning computation
  106176. * * bbSize : optional bounding box size data, required for facetPartitioning computation
  106177. * * subDiv : optional partitioning data about subdivsions on each axis (int), required for facetPartitioning computation
  106178. * * useRightHandedSystem: optional boolean to for right handed system computation
  106179. * * depthSort : optional boolean to enable the facet depth sort computation
  106180. * * distanceTo : optional Vector3 to compute the facet depth from this location
  106181. * * depthSortedFacets : optional array of depthSortedFacets to store the facet distances from the reference location
  106182. */
  106183. static ComputeNormals(positions: any, indices: any, normals: any, options?: {
  106184. facetNormals?: any;
  106185. facetPositions?: any;
  106186. facetPartitioning?: any;
  106187. ratio?: number;
  106188. bInfo?: any;
  106189. bbSize?: Vector3;
  106190. subDiv?: any;
  106191. useRightHandedSystem?: boolean;
  106192. depthSort?: boolean;
  106193. distanceTo?: Vector3;
  106194. depthSortedFacets?: any;
  106195. }): void;
  106196. /** @hidden */
  106197. static _ComputeSides(sideOrientation: number, positions: FloatArray, indices: FloatArray, normals: FloatArray, uvs: FloatArray, frontUVs?: Vector4, backUVs?: Vector4): void;
  106198. /**
  106199. * Applies VertexData created from the imported parameters to the geometry
  106200. * @param parsedVertexData the parsed data from an imported file
  106201. * @param geometry the geometry to apply the VertexData to
  106202. */
  106203. static ImportVertexData(parsedVertexData: any, geometry: Geometry): void;
  106204. }
  106205. }
  106206. declare module BABYLON {
  106207. /**
  106208. * Defines a target to use with MorphTargetManager
  106209. * @see https://doc.babylonjs.com/how_to/how_to_use_morphtargets
  106210. */
  106211. export class MorphTarget implements IAnimatable {
  106212. /** defines the name of the target */
  106213. name: string;
  106214. /**
  106215. * Gets or sets the list of animations
  106216. */
  106217. animations: Animation[];
  106218. private _scene;
  106219. private _positions;
  106220. private _normals;
  106221. private _tangents;
  106222. private _uvs;
  106223. private _influence;
  106224. private _uniqueId;
  106225. /**
  106226. * Observable raised when the influence changes
  106227. */
  106228. onInfluenceChanged: Observable<boolean>;
  106229. /** @hidden */
  106230. _onDataLayoutChanged: Observable<void>;
  106231. /**
  106232. * Gets or sets the influence of this target (ie. its weight in the overall morphing)
  106233. */
  106234. get influence(): number;
  106235. set influence(influence: number);
  106236. /**
  106237. * Gets or sets the id of the morph Target
  106238. */
  106239. id: string;
  106240. private _animationPropertiesOverride;
  106241. /**
  106242. * Gets or sets the animation properties override
  106243. */
  106244. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  106245. set animationPropertiesOverride(value: Nullable<AnimationPropertiesOverride>);
  106246. /**
  106247. * Creates a new MorphTarget
  106248. * @param name defines the name of the target
  106249. * @param influence defines the influence to use
  106250. * @param scene defines the scene the morphtarget belongs to
  106251. */
  106252. constructor(
  106253. /** defines the name of the target */
  106254. name: string, influence?: number, scene?: Nullable<Scene>);
  106255. /**
  106256. * Gets the unique ID of this manager
  106257. */
  106258. get uniqueId(): number;
  106259. /**
  106260. * Gets a boolean defining if the target contains position data
  106261. */
  106262. get hasPositions(): boolean;
  106263. /**
  106264. * Gets a boolean defining if the target contains normal data
  106265. */
  106266. get hasNormals(): boolean;
  106267. /**
  106268. * Gets a boolean defining if the target contains tangent data
  106269. */
  106270. get hasTangents(): boolean;
  106271. /**
  106272. * Gets a boolean defining if the target contains texture coordinates data
  106273. */
  106274. get hasUVs(): boolean;
  106275. /**
  106276. * Affects position data to this target
  106277. * @param data defines the position data to use
  106278. */
  106279. setPositions(data: Nullable<FloatArray>): void;
  106280. /**
  106281. * Gets the position data stored in this target
  106282. * @returns a FloatArray containing the position data (or null if not present)
  106283. */
  106284. getPositions(): Nullable<FloatArray>;
  106285. /**
  106286. * Affects normal data to this target
  106287. * @param data defines the normal data to use
  106288. */
  106289. setNormals(data: Nullable<FloatArray>): void;
  106290. /**
  106291. * Gets the normal data stored in this target
  106292. * @returns a FloatArray containing the normal data (or null if not present)
  106293. */
  106294. getNormals(): Nullable<FloatArray>;
  106295. /**
  106296. * Affects tangent data to this target
  106297. * @param data defines the tangent data to use
  106298. */
  106299. setTangents(data: Nullable<FloatArray>): void;
  106300. /**
  106301. * Gets the tangent data stored in this target
  106302. * @returns a FloatArray containing the tangent data (or null if not present)
  106303. */
  106304. getTangents(): Nullable<FloatArray>;
  106305. /**
  106306. * Affects texture coordinates data to this target
  106307. * @param data defines the texture coordinates data to use
  106308. */
  106309. setUVs(data: Nullable<FloatArray>): void;
  106310. /**
  106311. * Gets the texture coordinates data stored in this target
  106312. * @returns a FloatArray containing the texture coordinates data (or null if not present)
  106313. */
  106314. getUVs(): Nullable<FloatArray>;
  106315. /**
  106316. * Clone the current target
  106317. * @returns a new MorphTarget
  106318. */
  106319. clone(): MorphTarget;
  106320. /**
  106321. * Serializes the current target into a Serialization object
  106322. * @returns the serialized object
  106323. */
  106324. serialize(): any;
  106325. /**
  106326. * Returns the string "MorphTarget"
  106327. * @returns "MorphTarget"
  106328. */
  106329. getClassName(): string;
  106330. /**
  106331. * Creates a new target from serialized data
  106332. * @param serializationObject defines the serialized data to use
  106333. * @returns a new MorphTarget
  106334. */
  106335. static Parse(serializationObject: any): MorphTarget;
  106336. /**
  106337. * Creates a MorphTarget from mesh data
  106338. * @param mesh defines the source mesh
  106339. * @param name defines the name to use for the new target
  106340. * @param influence defines the influence to attach to the target
  106341. * @returns a new MorphTarget
  106342. */
  106343. static FromMesh(mesh: AbstractMesh, name?: string, influence?: number): MorphTarget;
  106344. }
  106345. }
  106346. declare module BABYLON {
  106347. /**
  106348. * This class is used to deform meshes using morphing between different targets
  106349. * @see https://doc.babylonjs.com/how_to/how_to_use_morphtargets
  106350. */
  106351. export class MorphTargetManager {
  106352. private _targets;
  106353. private _targetInfluenceChangedObservers;
  106354. private _targetDataLayoutChangedObservers;
  106355. private _activeTargets;
  106356. private _scene;
  106357. private _influences;
  106358. private _supportsNormals;
  106359. private _supportsTangents;
  106360. private _supportsUVs;
  106361. private _vertexCount;
  106362. private _uniqueId;
  106363. private _tempInfluences;
  106364. /**
  106365. * Gets or sets a boolean indicating if normals must be morphed
  106366. */
  106367. enableNormalMorphing: boolean;
  106368. /**
  106369. * Gets or sets a boolean indicating if tangents must be morphed
  106370. */
  106371. enableTangentMorphing: boolean;
  106372. /**
  106373. * Gets or sets a boolean indicating if UV must be morphed
  106374. */
  106375. enableUVMorphing: boolean;
  106376. /**
  106377. * Creates a new MorphTargetManager
  106378. * @param scene defines the current scene
  106379. */
  106380. constructor(scene?: Nullable<Scene>);
  106381. /**
  106382. * Gets the unique ID of this manager
  106383. */
  106384. get uniqueId(): number;
  106385. /**
  106386. * Gets the number of vertices handled by this manager
  106387. */
  106388. get vertexCount(): number;
  106389. /**
  106390. * Gets a boolean indicating if this manager supports morphing of normals
  106391. */
  106392. get supportsNormals(): boolean;
  106393. /**
  106394. * Gets a boolean indicating if this manager supports morphing of tangents
  106395. */
  106396. get supportsTangents(): boolean;
  106397. /**
  106398. * Gets a boolean indicating if this manager supports morphing of texture coordinates
  106399. */
  106400. get supportsUVs(): boolean;
  106401. /**
  106402. * Gets the number of targets stored in this manager
  106403. */
  106404. get numTargets(): number;
  106405. /**
  106406. * Gets the number of influencers (ie. the number of targets with influences > 0)
  106407. */
  106408. get numInfluencers(): number;
  106409. /**
  106410. * Gets the list of influences (one per target)
  106411. */
  106412. get influences(): Float32Array;
  106413. /**
  106414. * Gets the active target at specified index. An active target is a target with an influence > 0
  106415. * @param index defines the index to check
  106416. * @returns the requested target
  106417. */
  106418. getActiveTarget(index: number): MorphTarget;
  106419. /**
  106420. * Gets the target at specified index
  106421. * @param index defines the index to check
  106422. * @returns the requested target
  106423. */
  106424. getTarget(index: number): MorphTarget;
  106425. /**
  106426. * Add a new target to this manager
  106427. * @param target defines the target to add
  106428. */
  106429. addTarget(target: MorphTarget): void;
  106430. /**
  106431. * Removes a target from the manager
  106432. * @param target defines the target to remove
  106433. */
  106434. removeTarget(target: MorphTarget): void;
  106435. /**
  106436. * Clone the current manager
  106437. * @returns a new MorphTargetManager
  106438. */
  106439. clone(): MorphTargetManager;
  106440. /**
  106441. * Serializes the current manager into a Serialization object
  106442. * @returns the serialized object
  106443. */
  106444. serialize(): any;
  106445. private _syncActiveTargets;
  106446. /**
  106447. * Syncrhonize the targets with all the meshes using this morph target manager
  106448. */
  106449. synchronize(): void;
  106450. /**
  106451. * Creates a new MorphTargetManager from serialized data
  106452. * @param serializationObject defines the serialized data
  106453. * @param scene defines the hosting scene
  106454. * @returns the new MorphTargetManager
  106455. */
  106456. static Parse(serializationObject: any, scene: Scene): MorphTargetManager;
  106457. }
  106458. }
  106459. declare module BABYLON {
  106460. /**
  106461. * Class used to represent a specific level of detail of a mesh
  106462. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  106463. */
  106464. export class MeshLODLevel {
  106465. /** Defines the distance where this level should start being displayed */
  106466. distance: number;
  106467. /** Defines the mesh to use to render this level */
  106468. mesh: Nullable<Mesh>;
  106469. /**
  106470. * Creates a new LOD level
  106471. * @param distance defines the distance where this level should star being displayed
  106472. * @param mesh defines the mesh to use to render this level
  106473. */
  106474. constructor(
  106475. /** Defines the distance where this level should start being displayed */
  106476. distance: number,
  106477. /** Defines the mesh to use to render this level */
  106478. mesh: Nullable<Mesh>);
  106479. }
  106480. }
  106481. declare module BABYLON {
  106482. /**
  106483. * Helper class used to generate a canvas to manipulate images
  106484. */
  106485. export class CanvasGenerator {
  106486. /**
  106487. * Create a new canvas (or offscreen canvas depending on the context)
  106488. * @param width defines the expected width
  106489. * @param height defines the expected height
  106490. * @return a new canvas or offscreen canvas
  106491. */
  106492. static CreateCanvas(width: number, height: number): HTMLCanvasElement | OffscreenCanvas;
  106493. }
  106494. }
  106495. declare module BABYLON {
  106496. /**
  106497. * Mesh representing the gorund
  106498. */
  106499. export class GroundMesh extends Mesh {
  106500. /** If octree should be generated */
  106501. generateOctree: boolean;
  106502. private _heightQuads;
  106503. /** @hidden */
  106504. _subdivisionsX: number;
  106505. /** @hidden */
  106506. _subdivisionsY: number;
  106507. /** @hidden */
  106508. _width: number;
  106509. /** @hidden */
  106510. _height: number;
  106511. /** @hidden */
  106512. _minX: number;
  106513. /** @hidden */
  106514. _maxX: number;
  106515. /** @hidden */
  106516. _minZ: number;
  106517. /** @hidden */
  106518. _maxZ: number;
  106519. constructor(name: string, scene: Scene);
  106520. /**
  106521. * "GroundMesh"
  106522. * @returns "GroundMesh"
  106523. */
  106524. getClassName(): string;
  106525. /**
  106526. * The minimum of x and y subdivisions
  106527. */
  106528. get subdivisions(): number;
  106529. /**
  106530. * X subdivisions
  106531. */
  106532. get subdivisionsX(): number;
  106533. /**
  106534. * Y subdivisions
  106535. */
  106536. get subdivisionsY(): number;
  106537. /**
  106538. * This function will update an octree to help to select the right submeshes for rendering, picking and collision computations.
  106539. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  106540. * @param chunksCount the number of subdivisions for x and y
  106541. * @param octreeBlocksSize (Default: 32)
  106542. */
  106543. optimize(chunksCount: number, octreeBlocksSize?: number): void;
  106544. /**
  106545. * Returns a height (y) value in the Worl system :
  106546. * the ground altitude at the coordinates (x, z) expressed in the World system.
  106547. * @param x x coordinate
  106548. * @param z z coordinate
  106549. * @returns the ground y position if (x, z) are outside the ground surface.
  106550. */
  106551. getHeightAtCoordinates(x: number, z: number): number;
  106552. /**
  106553. * Returns a normalized vector (Vector3) orthogonal to the ground
  106554. * at the ground coordinates (x, z) expressed in the World system.
  106555. * @param x x coordinate
  106556. * @param z z coordinate
  106557. * @returns Vector3(0.0, 1.0, 0.0) if (x, z) are outside the ground surface.
  106558. */
  106559. getNormalAtCoordinates(x: number, z: number): Vector3;
  106560. /**
  106561. * Updates the Vector3 passed a reference with a normalized vector orthogonal to the ground
  106562. * at the ground coordinates (x, z) expressed in the World system.
  106563. * Doesn't uptade the reference Vector3 if (x, z) are outside the ground surface.
  106564. * @param x x coordinate
  106565. * @param z z coordinate
  106566. * @param ref vector to store the result
  106567. * @returns the GroundMesh.
  106568. */
  106569. getNormalAtCoordinatesToRef(x: number, z: number, ref: Vector3): GroundMesh;
  106570. /**
  106571. * Force the heights to be recomputed for getHeightAtCoordinates() or getNormalAtCoordinates()
  106572. * if the ground has been updated.
  106573. * This can be used in the render loop.
  106574. * @returns the GroundMesh.
  106575. */
  106576. updateCoordinateHeights(): GroundMesh;
  106577. private _getFacetAt;
  106578. private _initHeightQuads;
  106579. private _computeHeightQuads;
  106580. /**
  106581. * Serializes this ground mesh
  106582. * @param serializationObject object to write serialization to
  106583. */
  106584. serialize(serializationObject: any): void;
  106585. /**
  106586. * Parses a serialized ground mesh
  106587. * @param parsedMesh the serialized mesh
  106588. * @param scene the scene to create the ground mesh in
  106589. * @returns the created ground mesh
  106590. */
  106591. static Parse(parsedMesh: any, scene: Scene): GroundMesh;
  106592. }
  106593. }
  106594. declare module BABYLON {
  106595. /**
  106596. * Interface for Physics-Joint data
  106597. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  106598. */
  106599. export interface PhysicsJointData {
  106600. /**
  106601. * The main pivot of the joint
  106602. */
  106603. mainPivot?: Vector3;
  106604. /**
  106605. * The connected pivot of the joint
  106606. */
  106607. connectedPivot?: Vector3;
  106608. /**
  106609. * The main axis of the joint
  106610. */
  106611. mainAxis?: Vector3;
  106612. /**
  106613. * The connected axis of the joint
  106614. */
  106615. connectedAxis?: Vector3;
  106616. /**
  106617. * The collision of the joint
  106618. */
  106619. collision?: boolean;
  106620. /**
  106621. * Native Oimo/Cannon/Energy data
  106622. */
  106623. nativeParams?: any;
  106624. }
  106625. /**
  106626. * This is a holder class for the physics joint created by the physics plugin
  106627. * It holds a set of functions to control the underlying joint
  106628. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  106629. */
  106630. export class PhysicsJoint {
  106631. /**
  106632. * The type of the physics joint
  106633. */
  106634. type: number;
  106635. /**
  106636. * The data for the physics joint
  106637. */
  106638. jointData: PhysicsJointData;
  106639. private _physicsJoint;
  106640. protected _physicsPlugin: IPhysicsEnginePlugin;
  106641. /**
  106642. * Initializes the physics joint
  106643. * @param type The type of the physics joint
  106644. * @param jointData The data for the physics joint
  106645. */
  106646. constructor(
  106647. /**
  106648. * The type of the physics joint
  106649. */
  106650. type: number,
  106651. /**
  106652. * The data for the physics joint
  106653. */
  106654. jointData: PhysicsJointData);
  106655. /**
  106656. * Gets the physics joint
  106657. */
  106658. get physicsJoint(): any;
  106659. /**
  106660. * Sets the physics joint
  106661. */
  106662. set physicsJoint(newJoint: any);
  106663. /**
  106664. * Sets the physics plugin
  106665. */
  106666. set physicsPlugin(physicsPlugin: IPhysicsEnginePlugin);
  106667. /**
  106668. * Execute a function that is physics-plugin specific.
  106669. * @param {Function} func the function that will be executed.
  106670. * It accepts two parameters: the physics world and the physics joint
  106671. */
  106672. executeNativeFunction(func: (world: any, physicsJoint: any) => void): void;
  106673. /**
  106674. * Distance-Joint type
  106675. */
  106676. static DistanceJoint: number;
  106677. /**
  106678. * Hinge-Joint type
  106679. */
  106680. static HingeJoint: number;
  106681. /**
  106682. * Ball-and-Socket joint type
  106683. */
  106684. static BallAndSocketJoint: number;
  106685. /**
  106686. * Wheel-Joint type
  106687. */
  106688. static WheelJoint: number;
  106689. /**
  106690. * Slider-Joint type
  106691. */
  106692. static SliderJoint: number;
  106693. /**
  106694. * Prismatic-Joint type
  106695. */
  106696. static PrismaticJoint: number;
  106697. /**
  106698. * Universal-Joint type
  106699. * ENERGY FTW! (compare with this - @see http://ode-wiki.org/wiki/index.php?title=Manual:_Joint_Types_and_Functions)
  106700. */
  106701. static UniversalJoint: number;
  106702. /**
  106703. * Hinge-Joint 2 type
  106704. */
  106705. static Hinge2Joint: number;
  106706. /**
  106707. * Point to Point Joint type. Similar to a Ball-Joint. Different in parameters
  106708. */
  106709. static PointToPointJoint: number;
  106710. /**
  106711. * Spring-Joint type
  106712. */
  106713. static SpringJoint: number;
  106714. /**
  106715. * Lock-Joint type
  106716. */
  106717. static LockJoint: number;
  106718. }
  106719. /**
  106720. * A class representing a physics distance joint
  106721. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  106722. */
  106723. export class DistanceJoint extends PhysicsJoint {
  106724. /**
  106725. *
  106726. * @param jointData The data for the Distance-Joint
  106727. */
  106728. constructor(jointData: DistanceJointData);
  106729. /**
  106730. * Update the predefined distance.
  106731. * @param maxDistance The maximum preferred distance
  106732. * @param minDistance The minimum preferred distance
  106733. */
  106734. updateDistance(maxDistance: number, minDistance?: number): void;
  106735. }
  106736. /**
  106737. * Represents a Motor-Enabled Joint
  106738. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  106739. */
  106740. export class MotorEnabledJoint extends PhysicsJoint implements IMotorEnabledJoint {
  106741. /**
  106742. * Initializes the Motor-Enabled Joint
  106743. * @param type The type of the joint
  106744. * @param jointData The physica joint data for the joint
  106745. */
  106746. constructor(type: number, jointData: PhysicsJointData);
  106747. /**
  106748. * Set the motor values.
  106749. * Attention, this function is plugin specific. Engines won't react 100% the same.
  106750. * @param force the force to apply
  106751. * @param maxForce max force for this motor.
  106752. */
  106753. setMotor(force?: number, maxForce?: number): void;
  106754. /**
  106755. * Set the motor's limits.
  106756. * Attention, this function is plugin specific. Engines won't react 100% the same.
  106757. * @param upperLimit The upper limit of the motor
  106758. * @param lowerLimit The lower limit of the motor
  106759. */
  106760. setLimit(upperLimit: number, lowerLimit?: number): void;
  106761. }
  106762. /**
  106763. * This class represents a single physics Hinge-Joint
  106764. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  106765. */
  106766. export class HingeJoint extends MotorEnabledJoint {
  106767. /**
  106768. * Initializes the Hinge-Joint
  106769. * @param jointData The joint data for the Hinge-Joint
  106770. */
  106771. constructor(jointData: PhysicsJointData);
  106772. /**
  106773. * Set the motor values.
  106774. * Attention, this function is plugin specific. Engines won't react 100% the same.
  106775. * @param {number} force the force to apply
  106776. * @param {number} maxForce max force for this motor.
  106777. */
  106778. setMotor(force?: number, maxForce?: number): void;
  106779. /**
  106780. * Set the motor's limits.
  106781. * Attention, this function is plugin specific. Engines won't react 100% the same.
  106782. * @param upperLimit The upper limit of the motor
  106783. * @param lowerLimit The lower limit of the motor
  106784. */
  106785. setLimit(upperLimit: number, lowerLimit?: number): void;
  106786. }
  106787. /**
  106788. * This class represents a dual hinge physics joint (same as wheel joint)
  106789. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  106790. */
  106791. export class Hinge2Joint extends MotorEnabledJoint {
  106792. /**
  106793. * Initializes the Hinge2-Joint
  106794. * @param jointData The joint data for the Hinge2-Joint
  106795. */
  106796. constructor(jointData: PhysicsJointData);
  106797. /**
  106798. * Set the motor values.
  106799. * Attention, this function is plugin specific. Engines won't react 100% the same.
  106800. * @param {number} targetSpeed the speed the motor is to reach
  106801. * @param {number} maxForce max force for this motor.
  106802. * @param {motorIndex} the motor's index, 0 or 1.
  106803. */
  106804. setMotor(targetSpeed?: number, maxForce?: number, motorIndex?: number): void;
  106805. /**
  106806. * Set the motor limits.
  106807. * Attention, this function is plugin specific. Engines won't react 100% the same.
  106808. * @param {number} upperLimit the upper limit
  106809. * @param {number} lowerLimit lower limit
  106810. * @param {motorIndex} the motor's index, 0 or 1.
  106811. */
  106812. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  106813. }
  106814. /**
  106815. * Interface for a motor enabled joint
  106816. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  106817. */
  106818. export interface IMotorEnabledJoint {
  106819. /**
  106820. * Physics joint
  106821. */
  106822. physicsJoint: any;
  106823. /**
  106824. * Sets the motor of the motor-enabled joint
  106825. * @param force The force of the motor
  106826. * @param maxForce The maximum force of the motor
  106827. * @param motorIndex The index of the motor
  106828. */
  106829. setMotor(force?: number, maxForce?: number, motorIndex?: number): void;
  106830. /**
  106831. * Sets the limit of the motor
  106832. * @param upperLimit The upper limit of the motor
  106833. * @param lowerLimit The lower limit of the motor
  106834. * @param motorIndex The index of the motor
  106835. */
  106836. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  106837. }
  106838. /**
  106839. * Joint data for a Distance-Joint
  106840. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  106841. */
  106842. export interface DistanceJointData extends PhysicsJointData {
  106843. /**
  106844. * Max distance the 2 joint objects can be apart
  106845. */
  106846. maxDistance: number;
  106847. }
  106848. /**
  106849. * Joint data from a spring joint
  106850. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  106851. */
  106852. export interface SpringJointData extends PhysicsJointData {
  106853. /**
  106854. * Length of the spring
  106855. */
  106856. length: number;
  106857. /**
  106858. * Stiffness of the spring
  106859. */
  106860. stiffness: number;
  106861. /**
  106862. * Damping of the spring
  106863. */
  106864. damping: number;
  106865. /** this callback will be called when applying the force to the impostors. */
  106866. forceApplicationCallback: () => void;
  106867. }
  106868. }
  106869. declare module BABYLON {
  106870. /**
  106871. * Holds the data for the raycast result
  106872. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  106873. */
  106874. export class PhysicsRaycastResult {
  106875. private _hasHit;
  106876. private _hitDistance;
  106877. private _hitNormalWorld;
  106878. private _hitPointWorld;
  106879. private _rayFromWorld;
  106880. private _rayToWorld;
  106881. /**
  106882. * Gets if there was a hit
  106883. */
  106884. get hasHit(): boolean;
  106885. /**
  106886. * Gets the distance from the hit
  106887. */
  106888. get hitDistance(): number;
  106889. /**
  106890. * Gets the hit normal/direction in the world
  106891. */
  106892. get hitNormalWorld(): Vector3;
  106893. /**
  106894. * Gets the hit point in the world
  106895. */
  106896. get hitPointWorld(): Vector3;
  106897. /**
  106898. * Gets the ray "start point" of the ray in the world
  106899. */
  106900. get rayFromWorld(): Vector3;
  106901. /**
  106902. * Gets the ray "end point" of the ray in the world
  106903. */
  106904. get rayToWorld(): Vector3;
  106905. /**
  106906. * Sets the hit data (normal & point in world space)
  106907. * @param hitNormalWorld defines the normal in world space
  106908. * @param hitPointWorld defines the point in world space
  106909. */
  106910. setHitData(hitNormalWorld: IXYZ, hitPointWorld: IXYZ): void;
  106911. /**
  106912. * Sets the distance from the start point to the hit point
  106913. * @param distance
  106914. */
  106915. setHitDistance(distance: number): void;
  106916. /**
  106917. * Calculates the distance manually
  106918. */
  106919. calculateHitDistance(): void;
  106920. /**
  106921. * Resets all the values to default
  106922. * @param from The from point on world space
  106923. * @param to The to point on world space
  106924. */
  106925. reset(from?: Vector3, to?: Vector3): void;
  106926. }
  106927. /**
  106928. * Interface for the size containing width and height
  106929. */
  106930. interface IXYZ {
  106931. /**
  106932. * X
  106933. */
  106934. x: number;
  106935. /**
  106936. * Y
  106937. */
  106938. y: number;
  106939. /**
  106940. * Z
  106941. */
  106942. z: number;
  106943. }
  106944. }
  106945. declare module BABYLON {
  106946. /**
  106947. * Interface used to describe a physics joint
  106948. */
  106949. export interface PhysicsImpostorJoint {
  106950. /** Defines the main impostor to which the joint is linked */
  106951. mainImpostor: PhysicsImpostor;
  106952. /** Defines the impostor that is connected to the main impostor using this joint */
  106953. connectedImpostor: PhysicsImpostor;
  106954. /** Defines the joint itself */
  106955. joint: PhysicsJoint;
  106956. }
  106957. /** @hidden */
  106958. export interface IPhysicsEnginePlugin {
  106959. world: any;
  106960. name: string;
  106961. setGravity(gravity: Vector3): void;
  106962. setTimeStep(timeStep: number): void;
  106963. getTimeStep(): number;
  106964. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  106965. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  106966. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  106967. generatePhysicsBody(impostor: PhysicsImpostor): void;
  106968. removePhysicsBody(impostor: PhysicsImpostor): void;
  106969. generateJoint(joint: PhysicsImpostorJoint): void;
  106970. removeJoint(joint: PhysicsImpostorJoint): void;
  106971. isSupported(): boolean;
  106972. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  106973. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  106974. setLinearVelocity(impostor: PhysicsImpostor, velocity: Nullable<Vector3>): void;
  106975. setAngularVelocity(impostor: PhysicsImpostor, velocity: Nullable<Vector3>): void;
  106976. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  106977. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  106978. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  106979. getBodyMass(impostor: PhysicsImpostor): number;
  106980. getBodyFriction(impostor: PhysicsImpostor): number;
  106981. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  106982. getBodyRestitution(impostor: PhysicsImpostor): number;
  106983. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  106984. getBodyPressure?(impostor: PhysicsImpostor): number;
  106985. setBodyPressure?(impostor: PhysicsImpostor, pressure: number): void;
  106986. getBodyStiffness?(impostor: PhysicsImpostor): number;
  106987. setBodyStiffness?(impostor: PhysicsImpostor, stiffness: number): void;
  106988. getBodyVelocityIterations?(impostor: PhysicsImpostor): number;
  106989. setBodyVelocityIterations?(impostor: PhysicsImpostor, velocityIterations: number): void;
  106990. getBodyPositionIterations?(impostor: PhysicsImpostor): number;
  106991. setBodyPositionIterations?(impostor: PhysicsImpostor, positionIterations: number): void;
  106992. appendAnchor?(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, width: number, height: number, influence: number, noCollisionBetweenLinkedBodies: boolean): void;
  106993. appendHook?(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, length: number, influence: number, noCollisionBetweenLinkedBodies: boolean): void;
  106994. sleepBody(impostor: PhysicsImpostor): void;
  106995. wakeUpBody(impostor: PhysicsImpostor): void;
  106996. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  106997. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  106998. setMotor(joint: IMotorEnabledJoint, speed: number, maxForce?: number, motorIndex?: number): void;
  106999. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  107000. getRadius(impostor: PhysicsImpostor): number;
  107001. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  107002. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  107003. dispose(): void;
  107004. }
  107005. /**
  107006. * Interface used to define a physics engine
  107007. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  107008. */
  107009. export interface IPhysicsEngine {
  107010. /**
  107011. * Gets the gravity vector used by the simulation
  107012. */
  107013. gravity: Vector3;
  107014. /**
  107015. * Sets the gravity vector used by the simulation
  107016. * @param gravity defines the gravity vector to use
  107017. */
  107018. setGravity(gravity: Vector3): void;
  107019. /**
  107020. * Set the time step of the physics engine.
  107021. * Default is 1/60.
  107022. * To slow it down, enter 1/600 for example.
  107023. * To speed it up, 1/30
  107024. * @param newTimeStep the new timestep to apply to this world.
  107025. */
  107026. setTimeStep(newTimeStep: number): void;
  107027. /**
  107028. * Get the time step of the physics engine.
  107029. * @returns the current time step
  107030. */
  107031. getTimeStep(): number;
  107032. /**
  107033. * Set the sub time step of the physics engine.
  107034. * Default is 0 meaning there is no sub steps
  107035. * To increase physics resolution precision, set a small value (like 1 ms)
  107036. * @param subTimeStep defines the new sub timestep used for physics resolution.
  107037. */
  107038. setSubTimeStep(subTimeStep: number): void;
  107039. /**
  107040. * Get the sub time step of the physics engine.
  107041. * @returns the current sub time step
  107042. */
  107043. getSubTimeStep(): number;
  107044. /**
  107045. * Release all resources
  107046. */
  107047. dispose(): void;
  107048. /**
  107049. * Gets the name of the current physics plugin
  107050. * @returns the name of the plugin
  107051. */
  107052. getPhysicsPluginName(): string;
  107053. /**
  107054. * Adding a new impostor for the impostor tracking.
  107055. * This will be done by the impostor itself.
  107056. * @param impostor the impostor to add
  107057. */
  107058. addImpostor(impostor: PhysicsImpostor): void;
  107059. /**
  107060. * Remove an impostor from the engine.
  107061. * This impostor and its mesh will not longer be updated by the physics engine.
  107062. * @param impostor the impostor to remove
  107063. */
  107064. removeImpostor(impostor: PhysicsImpostor): void;
  107065. /**
  107066. * Add a joint to the physics engine
  107067. * @param mainImpostor defines the main impostor to which the joint is added.
  107068. * @param connectedImpostor defines the impostor that is connected to the main impostor using this joint
  107069. * @param joint defines the joint that will connect both impostors.
  107070. */
  107071. addJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  107072. /**
  107073. * Removes a joint from the simulation
  107074. * @param mainImpostor defines the impostor used with the joint
  107075. * @param connectedImpostor defines the other impostor connected to the main one by the joint
  107076. * @param joint defines the joint to remove
  107077. */
  107078. removeJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  107079. /**
  107080. * Gets the current plugin used to run the simulation
  107081. * @returns current plugin
  107082. */
  107083. getPhysicsPlugin(): IPhysicsEnginePlugin;
  107084. /**
  107085. * Gets the list of physic impostors
  107086. * @returns an array of PhysicsImpostor
  107087. */
  107088. getImpostors(): Array<PhysicsImpostor>;
  107089. /**
  107090. * Gets the impostor for a physics enabled object
  107091. * @param object defines the object impersonated by the impostor
  107092. * @returns the PhysicsImpostor or null if not found
  107093. */
  107094. getImpostorForPhysicsObject(object: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  107095. /**
  107096. * Gets the impostor for a physics body object
  107097. * @param body defines physics body used by the impostor
  107098. * @returns the PhysicsImpostor or null if not found
  107099. */
  107100. getImpostorWithPhysicsBody(body: any): Nullable<PhysicsImpostor>;
  107101. /**
  107102. * Does a raycast in the physics world
  107103. * @param from when should the ray start?
  107104. * @param to when should the ray end?
  107105. * @returns PhysicsRaycastResult
  107106. */
  107107. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  107108. /**
  107109. * Called by the scene. No need to call it.
  107110. * @param delta defines the timespam between frames
  107111. */
  107112. _step(delta: number): void;
  107113. }
  107114. }
  107115. declare module BABYLON {
  107116. /**
  107117. * The interface for the physics imposter parameters
  107118. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  107119. */
  107120. export interface PhysicsImpostorParameters {
  107121. /**
  107122. * The mass of the physics imposter
  107123. */
  107124. mass: number;
  107125. /**
  107126. * The friction of the physics imposter
  107127. */
  107128. friction?: number;
  107129. /**
  107130. * The coefficient of restitution of the physics imposter
  107131. */
  107132. restitution?: number;
  107133. /**
  107134. * The native options of the physics imposter
  107135. */
  107136. nativeOptions?: any;
  107137. /**
  107138. * Specifies if the parent should be ignored
  107139. */
  107140. ignoreParent?: boolean;
  107141. /**
  107142. * Specifies if bi-directional transformations should be disabled
  107143. */
  107144. disableBidirectionalTransformation?: boolean;
  107145. /**
  107146. * The pressure inside the physics imposter, soft object only
  107147. */
  107148. pressure?: number;
  107149. /**
  107150. * The stiffness the physics imposter, soft object only
  107151. */
  107152. stiffness?: number;
  107153. /**
  107154. * The number of iterations used in maintaining consistent vertex velocities, soft object only
  107155. */
  107156. velocityIterations?: number;
  107157. /**
  107158. * The number of iterations used in maintaining consistent vertex positions, soft object only
  107159. */
  107160. positionIterations?: number;
  107161. /**
  107162. * The number used to fix points on a cloth (0, 1, 2, 4, 8) or rope (0, 1, 2) only
  107163. * 0 None, 1, back left or top, 2, back right or bottom, 4, front left, 8, front right
  107164. * Add to fix multiple points
  107165. */
  107166. fixedPoints?: number;
  107167. /**
  107168. * The collision margin around a soft object
  107169. */
  107170. margin?: number;
  107171. /**
  107172. * The collision margin around a soft object
  107173. */
  107174. damping?: number;
  107175. /**
  107176. * The path for a rope based on an extrusion
  107177. */
  107178. path?: any;
  107179. /**
  107180. * The shape of an extrusion used for a rope based on an extrusion
  107181. */
  107182. shape?: any;
  107183. }
  107184. /**
  107185. * Interface for a physics-enabled object
  107186. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  107187. */
  107188. export interface IPhysicsEnabledObject {
  107189. /**
  107190. * The position of the physics-enabled object
  107191. */
  107192. position: Vector3;
  107193. /**
  107194. * The rotation of the physics-enabled object
  107195. */
  107196. rotationQuaternion: Nullable<Quaternion>;
  107197. /**
  107198. * The scale of the physics-enabled object
  107199. */
  107200. scaling: Vector3;
  107201. /**
  107202. * The rotation of the physics-enabled object
  107203. */
  107204. rotation?: Vector3;
  107205. /**
  107206. * The parent of the physics-enabled object
  107207. */
  107208. parent?: any;
  107209. /**
  107210. * The bounding info of the physics-enabled object
  107211. * @returns The bounding info of the physics-enabled object
  107212. */
  107213. getBoundingInfo(): BoundingInfo;
  107214. /**
  107215. * Computes the world matrix
  107216. * @param force Specifies if the world matrix should be computed by force
  107217. * @returns A world matrix
  107218. */
  107219. computeWorldMatrix(force: boolean): Matrix;
  107220. /**
  107221. * Gets the world matrix
  107222. * @returns A world matrix
  107223. */
  107224. getWorldMatrix?(): Matrix;
  107225. /**
  107226. * Gets the child meshes
  107227. * @param directDescendantsOnly Specifies if only direct-descendants should be obtained
  107228. * @returns An array of abstract meshes
  107229. */
  107230. getChildMeshes?(directDescendantsOnly?: boolean): Array<AbstractMesh>;
  107231. /**
  107232. * Gets the vertex data
  107233. * @param kind The type of vertex data
  107234. * @returns A nullable array of numbers, or a float32 array
  107235. */
  107236. getVerticesData(kind: string): Nullable<Array<number> | Float32Array>;
  107237. /**
  107238. * Gets the indices from the mesh
  107239. * @returns A nullable array of index arrays
  107240. */
  107241. getIndices?(): Nullable<IndicesArray>;
  107242. /**
  107243. * Gets the scene from the mesh
  107244. * @returns the indices array or null
  107245. */
  107246. getScene?(): Scene;
  107247. /**
  107248. * Gets the absolute position from the mesh
  107249. * @returns the absolute position
  107250. */
  107251. getAbsolutePosition(): Vector3;
  107252. /**
  107253. * Gets the absolute pivot point from the mesh
  107254. * @returns the absolute pivot point
  107255. */
  107256. getAbsolutePivotPoint(): Vector3;
  107257. /**
  107258. * Rotates the mesh
  107259. * @param axis The axis of rotation
  107260. * @param amount The amount of rotation
  107261. * @param space The space of the rotation
  107262. * @returns The rotation transform node
  107263. */
  107264. rotate(axis: Vector3, amount: number, space?: Space): TransformNode;
  107265. /**
  107266. * Translates the mesh
  107267. * @param axis The axis of translation
  107268. * @param distance The distance of translation
  107269. * @param space The space of the translation
  107270. * @returns The transform node
  107271. */
  107272. translate(axis: Vector3, distance: number, space?: Space): TransformNode;
  107273. /**
  107274. * Sets the absolute position of the mesh
  107275. * @param absolutePosition The absolute position of the mesh
  107276. * @returns The transform node
  107277. */
  107278. setAbsolutePosition(absolutePosition: Vector3): TransformNode;
  107279. /**
  107280. * Gets the class name of the mesh
  107281. * @returns The class name
  107282. */
  107283. getClassName(): string;
  107284. }
  107285. /**
  107286. * Represents a physics imposter
  107287. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  107288. */
  107289. export class PhysicsImpostor {
  107290. /**
  107291. * The physics-enabled object used as the physics imposter
  107292. */
  107293. object: IPhysicsEnabledObject;
  107294. /**
  107295. * The type of the physics imposter
  107296. */
  107297. type: number;
  107298. private _options;
  107299. private _scene?;
  107300. /**
  107301. * The default object size of the imposter
  107302. */
  107303. static DEFAULT_OBJECT_SIZE: Vector3;
  107304. /**
  107305. * The identity quaternion of the imposter
  107306. */
  107307. static IDENTITY_QUATERNION: Quaternion;
  107308. /** @hidden */
  107309. _pluginData: any;
  107310. private _physicsEngine;
  107311. private _physicsBody;
  107312. private _bodyUpdateRequired;
  107313. private _onBeforePhysicsStepCallbacks;
  107314. private _onAfterPhysicsStepCallbacks;
  107315. /** @hidden */
  107316. _onPhysicsCollideCallbacks: Array<{
  107317. callback: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor) => void;
  107318. otherImpostors: Array<PhysicsImpostor>;
  107319. }>;
  107320. private _deltaPosition;
  107321. private _deltaRotation;
  107322. private _deltaRotationConjugated;
  107323. /** @hidden */
  107324. _isFromLine: boolean;
  107325. private _parent;
  107326. private _isDisposed;
  107327. private static _tmpVecs;
  107328. private static _tmpQuat;
  107329. /**
  107330. * Specifies if the physics imposter is disposed
  107331. */
  107332. get isDisposed(): boolean;
  107333. /**
  107334. * Gets the mass of the physics imposter
  107335. */
  107336. get mass(): number;
  107337. set mass(value: number);
  107338. /**
  107339. * Gets the coefficient of friction
  107340. */
  107341. get friction(): number;
  107342. /**
  107343. * Sets the coefficient of friction
  107344. */
  107345. set friction(value: number);
  107346. /**
  107347. * Gets the coefficient of restitution
  107348. */
  107349. get restitution(): number;
  107350. /**
  107351. * Sets the coefficient of restitution
  107352. */
  107353. set restitution(value: number);
  107354. /**
  107355. * Gets the pressure of a soft body; only supported by the AmmoJSPlugin
  107356. */
  107357. get pressure(): number;
  107358. /**
  107359. * Sets the pressure of a soft body; only supported by the AmmoJSPlugin
  107360. */
  107361. set pressure(value: number);
  107362. /**
  107363. * Gets the stiffness of a soft body; only supported by the AmmoJSPlugin
  107364. */
  107365. get stiffness(): number;
  107366. /**
  107367. * Sets the stiffness of a soft body; only supported by the AmmoJSPlugin
  107368. */
  107369. set stiffness(value: number);
  107370. /**
  107371. * Gets the velocityIterations of a soft body; only supported by the AmmoJSPlugin
  107372. */
  107373. get velocityIterations(): number;
  107374. /**
  107375. * Sets the velocityIterations of a soft body; only supported by the AmmoJSPlugin
  107376. */
  107377. set velocityIterations(value: number);
  107378. /**
  107379. * Gets the positionIterations of a soft body; only supported by the AmmoJSPlugin
  107380. */
  107381. get positionIterations(): number;
  107382. /**
  107383. * Sets the positionIterations of a soft body; only supported by the AmmoJSPlugin
  107384. */
  107385. set positionIterations(value: number);
  107386. /**
  107387. * The unique id of the physics imposter
  107388. * set by the physics engine when adding this impostor to the array
  107389. */
  107390. uniqueId: number;
  107391. /**
  107392. * @hidden
  107393. */
  107394. soft: boolean;
  107395. /**
  107396. * @hidden
  107397. */
  107398. segments: number;
  107399. private _joints;
  107400. /**
  107401. * Initializes the physics imposter
  107402. * @param object The physics-enabled object used as the physics imposter
  107403. * @param type The type of the physics imposter
  107404. * @param _options The options for the physics imposter
  107405. * @param _scene The Babylon scene
  107406. */
  107407. constructor(
  107408. /**
  107409. * The physics-enabled object used as the physics imposter
  107410. */
  107411. object: IPhysicsEnabledObject,
  107412. /**
  107413. * The type of the physics imposter
  107414. */
  107415. type: number, _options?: PhysicsImpostorParameters, _scene?: Scene | undefined);
  107416. /**
  107417. * This function will completly initialize this impostor.
  107418. * It will create a new body - but only if this mesh has no parent.
  107419. * If it has, this impostor will not be used other than to define the impostor
  107420. * of the child mesh.
  107421. * @hidden
  107422. */
  107423. _init(): void;
  107424. private _getPhysicsParent;
  107425. /**
  107426. * Should a new body be generated.
  107427. * @returns boolean specifying if body initialization is required
  107428. */
  107429. isBodyInitRequired(): boolean;
  107430. /**
  107431. * Sets the updated scaling
  107432. * @param updated Specifies if the scaling is updated
  107433. */
  107434. setScalingUpdated(): void;
  107435. /**
  107436. * Force a regeneration of this or the parent's impostor's body.
  107437. * Use under cautious - This will remove all joints already implemented.
  107438. */
  107439. forceUpdate(): void;
  107440. /**
  107441. * Gets the body that holds this impostor. Either its own, or its parent.
  107442. */
  107443. get physicsBody(): any;
  107444. /**
  107445. * Get the parent of the physics imposter
  107446. * @returns Physics imposter or null
  107447. */
  107448. get parent(): Nullable<PhysicsImpostor>;
  107449. /**
  107450. * Sets the parent of the physics imposter
  107451. */
  107452. set parent(value: Nullable<PhysicsImpostor>);
  107453. /**
  107454. * Set the physics body. Used mainly by the physics engine/plugin
  107455. */
  107456. set physicsBody(physicsBody: any);
  107457. /**
  107458. * Resets the update flags
  107459. */
  107460. resetUpdateFlags(): void;
  107461. /**
  107462. * Gets the object extend size
  107463. * @returns the object extend size
  107464. */
  107465. getObjectExtendSize(): Vector3;
  107466. /**
  107467. * Gets the object center
  107468. * @returns The object center
  107469. */
  107470. getObjectCenter(): Vector3;
  107471. /**
  107472. * Get a specific parameter from the options parameters
  107473. * @param paramName The object parameter name
  107474. * @returns The object parameter
  107475. */
  107476. getParam(paramName: string): any;
  107477. /**
  107478. * Sets a specific parameter in the options given to the physics plugin
  107479. * @param paramName The parameter name
  107480. * @param value The value of the parameter
  107481. */
  107482. setParam(paramName: string, value: number): void;
  107483. /**
  107484. * Specifically change the body's mass option. Won't recreate the physics body object
  107485. * @param mass The mass of the physics imposter
  107486. */
  107487. setMass(mass: number): void;
  107488. /**
  107489. * Gets the linear velocity
  107490. * @returns linear velocity or null
  107491. */
  107492. getLinearVelocity(): Nullable<Vector3>;
  107493. /**
  107494. * Sets the linear velocity
  107495. * @param velocity linear velocity or null
  107496. */
  107497. setLinearVelocity(velocity: Nullable<Vector3>): void;
  107498. /**
  107499. * Gets the angular velocity
  107500. * @returns angular velocity or null
  107501. */
  107502. getAngularVelocity(): Nullable<Vector3>;
  107503. /**
  107504. * Sets the angular velocity
  107505. * @param velocity The velocity or null
  107506. */
  107507. setAngularVelocity(velocity: Nullable<Vector3>): void;
  107508. /**
  107509. * Execute a function with the physics plugin native code
  107510. * Provide a function the will have two variables - the world object and the physics body object
  107511. * @param func The function to execute with the physics plugin native code
  107512. */
  107513. executeNativeFunction(func: (world: any, physicsBody: any) => void): void;
  107514. /**
  107515. * Register a function that will be executed before the physics world is stepping forward
  107516. * @param func The function to execute before the physics world is stepped forward
  107517. */
  107518. registerBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  107519. /**
  107520. * Unregister a function that will be executed before the physics world is stepping forward
  107521. * @param func The function to execute before the physics world is stepped forward
  107522. */
  107523. unregisterBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  107524. /**
  107525. * Register a function that will be executed after the physics step
  107526. * @param func The function to execute after physics step
  107527. */
  107528. registerAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  107529. /**
  107530. * Unregisters a function that will be executed after the physics step
  107531. * @param func The function to execute after physics step
  107532. */
  107533. unregisterAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  107534. /**
  107535. * register a function that will be executed when this impostor collides against a different body
  107536. * @param collideAgainst Physics imposter, or array of physics imposters to collide against
  107537. * @param func Callback that is executed on collision
  107538. */
  107539. registerOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor) => void): void;
  107540. /**
  107541. * Unregisters the physics imposter on contact
  107542. * @param collideAgainst The physics object to collide against
  107543. * @param func Callback to execute on collision
  107544. */
  107545. unregisterOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor | Array<PhysicsImpostor>) => void): void;
  107546. private _tmpQuat;
  107547. private _tmpQuat2;
  107548. /**
  107549. * Get the parent rotation
  107550. * @returns The parent rotation
  107551. */
  107552. getParentsRotation(): Quaternion;
  107553. /**
  107554. * this function is executed by the physics engine.
  107555. */
  107556. beforeStep: () => void;
  107557. /**
  107558. * this function is executed by the physics engine
  107559. */
  107560. afterStep: () => void;
  107561. /**
  107562. * Legacy collision detection event support
  107563. */
  107564. onCollideEvent: Nullable<(collider: PhysicsImpostor, collidedWith: PhysicsImpostor) => void>;
  107565. /**
  107566. * event and body object due to cannon's event-based architecture.
  107567. */
  107568. onCollide: (e: {
  107569. body: any;
  107570. }) => void;
  107571. /**
  107572. * Apply a force
  107573. * @param force The force to apply
  107574. * @param contactPoint The contact point for the force
  107575. * @returns The physics imposter
  107576. */
  107577. applyForce(force: Vector3, contactPoint: Vector3): PhysicsImpostor;
  107578. /**
  107579. * Apply an impulse
  107580. * @param force The impulse force
  107581. * @param contactPoint The contact point for the impulse force
  107582. * @returns The physics imposter
  107583. */
  107584. applyImpulse(force: Vector3, contactPoint: Vector3): PhysicsImpostor;
  107585. /**
  107586. * A help function to create a joint
  107587. * @param otherImpostor A physics imposter used to create a joint
  107588. * @param jointType The type of joint
  107589. * @param jointData The data for the joint
  107590. * @returns The physics imposter
  107591. */
  107592. createJoint(otherImpostor: PhysicsImpostor, jointType: number, jointData: PhysicsJointData): PhysicsImpostor;
  107593. /**
  107594. * Add a joint to this impostor with a different impostor
  107595. * @param otherImpostor A physics imposter used to add a joint
  107596. * @param joint The joint to add
  107597. * @returns The physics imposter
  107598. */
  107599. addJoint(otherImpostor: PhysicsImpostor, joint: PhysicsJoint): PhysicsImpostor;
  107600. /**
  107601. * Add an anchor to a cloth impostor
  107602. * @param otherImpostor rigid impostor to anchor to
  107603. * @param width ratio across width from 0 to 1
  107604. * @param height ratio up height from 0 to 1
  107605. * @param influence the elasticity between cloth impostor and anchor from 0, very stretchy to 1, little strech
  107606. * @param noCollisionBetweenLinkedBodies when true collisions between cloth impostor and anchor are ignored; default false
  107607. * @returns impostor the soft imposter
  107608. */
  107609. addAnchor(otherImpostor: PhysicsImpostor, width: number, height: number, influence: number, noCollisionBetweenLinkedBodies: boolean): PhysicsImpostor;
  107610. /**
  107611. * Add a hook to a rope impostor
  107612. * @param otherImpostor rigid impostor to anchor to
  107613. * @param length ratio across rope from 0 to 1
  107614. * @param influence the elasticity between rope impostor and anchor from 0, very stretchy to 1, little strech
  107615. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  107616. * @returns impostor the rope imposter
  107617. */
  107618. addHook(otherImpostor: PhysicsImpostor, length: number, influence: number, noCollisionBetweenLinkedBodies: boolean): PhysicsImpostor;
  107619. /**
  107620. * Will keep this body still, in a sleep mode.
  107621. * @returns the physics imposter
  107622. */
  107623. sleep(): PhysicsImpostor;
  107624. /**
  107625. * Wake the body up.
  107626. * @returns The physics imposter
  107627. */
  107628. wakeUp(): PhysicsImpostor;
  107629. /**
  107630. * Clones the physics imposter
  107631. * @param newObject The physics imposter clones to this physics-enabled object
  107632. * @returns A nullable physics imposter
  107633. */
  107634. clone(newObject: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  107635. /**
  107636. * Disposes the physics imposter
  107637. */
  107638. dispose(): void;
  107639. /**
  107640. * Sets the delta position
  107641. * @param position The delta position amount
  107642. */
  107643. setDeltaPosition(position: Vector3): void;
  107644. /**
  107645. * Sets the delta rotation
  107646. * @param rotation The delta rotation amount
  107647. */
  107648. setDeltaRotation(rotation: Quaternion): void;
  107649. /**
  107650. * Gets the box size of the physics imposter and stores the result in the input parameter
  107651. * @param result Stores the box size
  107652. * @returns The physics imposter
  107653. */
  107654. getBoxSizeToRef(result: Vector3): PhysicsImpostor;
  107655. /**
  107656. * Gets the radius of the physics imposter
  107657. * @returns Radius of the physics imposter
  107658. */
  107659. getRadius(): number;
  107660. /**
  107661. * Sync a bone with this impostor
  107662. * @param bone The bone to sync to the impostor.
  107663. * @param boneMesh The mesh that the bone is influencing.
  107664. * @param jointPivot The pivot of the joint / bone in local space.
  107665. * @param distToJoint Optional distance from the impostor to the joint.
  107666. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  107667. */
  107668. syncBoneWithImpostor(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion): void;
  107669. /**
  107670. * Sync impostor to a bone
  107671. * @param bone The bone that the impostor will be synced to.
  107672. * @param boneMesh The mesh that the bone is influencing.
  107673. * @param jointPivot The pivot of the joint / bone in local space.
  107674. * @param distToJoint Optional distance from the impostor to the joint.
  107675. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  107676. * @param boneAxis Optional vector3 axis the bone is aligned with
  107677. */
  107678. syncImpostorWithBone(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion, boneAxis?: Vector3): void;
  107679. /**
  107680. * No-Imposter type
  107681. */
  107682. static NoImpostor: number;
  107683. /**
  107684. * Sphere-Imposter type
  107685. */
  107686. static SphereImpostor: number;
  107687. /**
  107688. * Box-Imposter type
  107689. */
  107690. static BoxImpostor: number;
  107691. /**
  107692. * Plane-Imposter type
  107693. */
  107694. static PlaneImpostor: number;
  107695. /**
  107696. * Mesh-imposter type
  107697. */
  107698. static MeshImpostor: number;
  107699. /**
  107700. * Capsule-Impostor type (Ammo.js plugin only)
  107701. */
  107702. static CapsuleImpostor: number;
  107703. /**
  107704. * Cylinder-Imposter type
  107705. */
  107706. static CylinderImpostor: number;
  107707. /**
  107708. * Particle-Imposter type
  107709. */
  107710. static ParticleImpostor: number;
  107711. /**
  107712. * Heightmap-Imposter type
  107713. */
  107714. static HeightmapImpostor: number;
  107715. /**
  107716. * ConvexHull-Impostor type (Ammo.js plugin only)
  107717. */
  107718. static ConvexHullImpostor: number;
  107719. /**
  107720. * Custom-Imposter type (Ammo.js plugin only)
  107721. */
  107722. static CustomImpostor: number;
  107723. /**
  107724. * Rope-Imposter type
  107725. */
  107726. static RopeImpostor: number;
  107727. /**
  107728. * Cloth-Imposter type
  107729. */
  107730. static ClothImpostor: number;
  107731. /**
  107732. * Softbody-Imposter type
  107733. */
  107734. static SoftbodyImpostor: number;
  107735. }
  107736. }
  107737. declare module BABYLON {
  107738. /**
  107739. * @hidden
  107740. **/
  107741. export class _CreationDataStorage {
  107742. closePath?: boolean;
  107743. closeArray?: boolean;
  107744. idx: number[];
  107745. dashSize: number;
  107746. gapSize: number;
  107747. path3D: Path3D;
  107748. pathArray: Vector3[][];
  107749. arc: number;
  107750. radius: number;
  107751. cap: number;
  107752. tessellation: number;
  107753. }
  107754. /**
  107755. * @hidden
  107756. **/
  107757. class _InstanceDataStorage {
  107758. visibleInstances: any;
  107759. batchCache: _InstancesBatch;
  107760. instancesBufferSize: number;
  107761. instancesBuffer: Nullable<Buffer>;
  107762. instancesData: Float32Array;
  107763. overridenInstanceCount: number;
  107764. isFrozen: boolean;
  107765. previousBatch: Nullable<_InstancesBatch>;
  107766. hardwareInstancedRendering: boolean;
  107767. sideOrientation: number;
  107768. manualUpdate: boolean;
  107769. }
  107770. /**
  107771. * @hidden
  107772. **/
  107773. export class _InstancesBatch {
  107774. mustReturn: boolean;
  107775. visibleInstances: Nullable<InstancedMesh[]>[];
  107776. renderSelf: boolean[];
  107777. hardwareInstancedRendering: boolean[];
  107778. }
  107779. /**
  107780. * @hidden
  107781. **/
  107782. class _ThinInstanceDataStorage {
  107783. instancesCount: number;
  107784. matrixBuffer: Nullable<Buffer>;
  107785. matrixBufferSize: number;
  107786. matrixData: Nullable<Float32Array>;
  107787. boundingVectors: Array<Vector3>;
  107788. worldMatrices: Nullable<Matrix[]>;
  107789. }
  107790. /**
  107791. * Class used to represent renderable models
  107792. */
  107793. export class Mesh extends AbstractMesh implements IGetSetVerticesData {
  107794. /**
  107795. * Mesh side orientation : usually the external or front surface
  107796. */
  107797. static readonly FRONTSIDE: number;
  107798. /**
  107799. * Mesh side orientation : usually the internal or back surface
  107800. */
  107801. static readonly BACKSIDE: number;
  107802. /**
  107803. * Mesh side orientation : both internal and external or front and back surfaces
  107804. */
  107805. static readonly DOUBLESIDE: number;
  107806. /**
  107807. * Mesh side orientation : by default, `FRONTSIDE`
  107808. */
  107809. static readonly DEFAULTSIDE: number;
  107810. /**
  107811. * Mesh cap setting : no cap
  107812. */
  107813. static readonly NO_CAP: number;
  107814. /**
  107815. * Mesh cap setting : one cap at the beginning of the mesh
  107816. */
  107817. static readonly CAP_START: number;
  107818. /**
  107819. * Mesh cap setting : one cap at the end of the mesh
  107820. */
  107821. static readonly CAP_END: number;
  107822. /**
  107823. * Mesh cap setting : two caps, one at the beginning and one at the end of the mesh
  107824. */
  107825. static readonly CAP_ALL: number;
  107826. /**
  107827. * Mesh pattern setting : no flip or rotate
  107828. */
  107829. static readonly NO_FLIP: number;
  107830. /**
  107831. * Mesh pattern setting : flip (reflect in y axis) alternate tiles on each row or column
  107832. */
  107833. static readonly FLIP_TILE: number;
  107834. /**
  107835. * Mesh pattern setting : rotate (180degs) alternate tiles on each row or column
  107836. */
  107837. static readonly ROTATE_TILE: number;
  107838. /**
  107839. * Mesh pattern setting : flip (reflect in y axis) all tiles on alternate rows
  107840. */
  107841. static readonly FLIP_ROW: number;
  107842. /**
  107843. * Mesh pattern setting : rotate (180degs) all tiles on alternate rows
  107844. */
  107845. static readonly ROTATE_ROW: number;
  107846. /**
  107847. * Mesh pattern setting : flip and rotate alternate tiles on each row or column
  107848. */
  107849. static readonly FLIP_N_ROTATE_TILE: number;
  107850. /**
  107851. * Mesh pattern setting : rotate pattern and rotate
  107852. */
  107853. static readonly FLIP_N_ROTATE_ROW: number;
  107854. /**
  107855. * Mesh tile positioning : part tiles same on left/right or top/bottom
  107856. */
  107857. static readonly CENTER: number;
  107858. /**
  107859. * Mesh tile positioning : part tiles on left
  107860. */
  107861. static readonly LEFT: number;
  107862. /**
  107863. * Mesh tile positioning : part tiles on right
  107864. */
  107865. static readonly RIGHT: number;
  107866. /**
  107867. * Mesh tile positioning : part tiles on top
  107868. */
  107869. static readonly TOP: number;
  107870. /**
  107871. * Mesh tile positioning : part tiles on bottom
  107872. */
  107873. static readonly BOTTOM: number;
  107874. /**
  107875. * Gets the default side orientation.
  107876. * @param orientation the orientation to value to attempt to get
  107877. * @returns the default orientation
  107878. * @hidden
  107879. */
  107880. static _GetDefaultSideOrientation(orientation?: number): number;
  107881. private _internalMeshDataInfo;
  107882. get computeBonesUsingShaders(): boolean;
  107883. set computeBonesUsingShaders(value: boolean);
  107884. /**
  107885. * An event triggered before rendering the mesh
  107886. */
  107887. get onBeforeRenderObservable(): Observable<Mesh>;
  107888. /**
  107889. * An event triggered before binding the mesh
  107890. */
  107891. get onBeforeBindObservable(): Observable<Mesh>;
  107892. /**
  107893. * An event triggered after rendering the mesh
  107894. */
  107895. get onAfterRenderObservable(): Observable<Mesh>;
  107896. /**
  107897. * An event triggered before drawing the mesh
  107898. */
  107899. get onBeforeDrawObservable(): Observable<Mesh>;
  107900. private _onBeforeDrawObserver;
  107901. /**
  107902. * Sets a callback to call before drawing the mesh. It is recommended to use onBeforeDrawObservable instead
  107903. */
  107904. set onBeforeDraw(callback: () => void);
  107905. get hasInstances(): boolean;
  107906. get hasThinInstances(): boolean;
  107907. /**
  107908. * Gets the delay loading state of the mesh (when delay loading is turned on)
  107909. * @see https://doc.babylonjs.com/how_to/using_the_incremental_loading_system
  107910. */
  107911. delayLoadState: number;
  107912. /**
  107913. * Gets the list of instances created from this mesh
  107914. * it is not supposed to be modified manually.
  107915. * Note also that the order of the InstancedMesh wihin the array is not significant and might change.
  107916. * @see https://doc.babylonjs.com/how_to/how_to_use_instances
  107917. */
  107918. instances: InstancedMesh[];
  107919. /**
  107920. * Gets the file containing delay loading data for this mesh
  107921. */
  107922. delayLoadingFile: string;
  107923. /** @hidden */
  107924. _binaryInfo: any;
  107925. /**
  107926. * User defined function used to change how LOD level selection is done
  107927. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  107928. */
  107929. onLODLevelSelection: (distance: number, mesh: Mesh, selectedLevel: Nullable<Mesh>) => void;
  107930. /**
  107931. * Gets or sets the morph target manager
  107932. * @see https://doc.babylonjs.com/how_to/how_to_use_morphtargets
  107933. */
  107934. get morphTargetManager(): Nullable<MorphTargetManager>;
  107935. set morphTargetManager(value: Nullable<MorphTargetManager>);
  107936. /** @hidden */
  107937. _creationDataStorage: Nullable<_CreationDataStorage>;
  107938. /** @hidden */
  107939. _geometry: Nullable<Geometry>;
  107940. /** @hidden */
  107941. _delayInfo: Array<string>;
  107942. /** @hidden */
  107943. _delayLoadingFunction: (any: any, mesh: Mesh) => void;
  107944. /** @hidden */
  107945. _instanceDataStorage: _InstanceDataStorage;
  107946. /** @hidden */
  107947. _thinInstanceDataStorage: _ThinInstanceDataStorage;
  107948. private _effectiveMaterial;
  107949. /** @hidden */
  107950. _shouldGenerateFlatShading: boolean;
  107951. /** @hidden */
  107952. _originalBuilderSideOrientation: number;
  107953. /**
  107954. * Use this property to change the original side orientation defined at construction time
  107955. */
  107956. overrideMaterialSideOrientation: Nullable<number>;
  107957. /**
  107958. * Gets the source mesh (the one used to clone this one from)
  107959. */
  107960. get source(): Nullable<Mesh>;
  107961. /**
  107962. * Gets the list of clones of this mesh
  107963. * The scene must have been constructed with useClonedMeshMap=true for this to work!
  107964. * Note that useClonedMeshMap=true is the default setting
  107965. */
  107966. get cloneMeshMap(): Nullable<{
  107967. [id: string]: Mesh | undefined;
  107968. }>;
  107969. /**
  107970. * Gets or sets a boolean indicating that this mesh does not use index buffer
  107971. */
  107972. get isUnIndexed(): boolean;
  107973. set isUnIndexed(value: boolean);
  107974. /** Gets the array buffer used to store the instanced buffer used for instances' world matrices */
  107975. get worldMatrixInstancedBuffer(): Float32Array;
  107976. /** Gets or sets a boolean indicating that the update of the instance buffer of the world matrices is manual */
  107977. get manualUpdateOfWorldMatrixInstancedBuffer(): boolean;
  107978. set manualUpdateOfWorldMatrixInstancedBuffer(value: boolean);
  107979. /**
  107980. * @constructor
  107981. * @param name The value used by scene.getMeshByName() to do a lookup.
  107982. * @param scene The scene to add this mesh to.
  107983. * @param parent The parent of this mesh, if it has one
  107984. * @param source An optional Mesh from which geometry is shared, cloned.
  107985. * @param doNotCloneChildren When cloning, skip cloning child meshes of source, default False.
  107986. * When false, achieved by calling a clone(), also passing False.
  107987. * This will make creation of children, recursive.
  107988. * @param clonePhysicsImpostor When cloning, include cloning mesh physics impostor, default True.
  107989. */
  107990. constructor(name: string, scene?: Nullable<Scene>, parent?: Nullable<Node>, source?: Nullable<Mesh>, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean);
  107991. instantiateHierarchy(newParent?: Nullable<TransformNode>, options?: {
  107992. doNotInstantiate: boolean;
  107993. }, onNewNodeCreated?: (source: TransformNode, clone: TransformNode) => void): Nullable<TransformNode>;
  107994. /**
  107995. * Gets the class name
  107996. * @returns the string "Mesh".
  107997. */
  107998. getClassName(): string;
  107999. /** @hidden */
  108000. get _isMesh(): boolean;
  108001. /**
  108002. * Returns a description of this mesh
  108003. * @param fullDetails define if full details about this mesh must be used
  108004. * @returns a descriptive string representing this mesh
  108005. */
  108006. toString(fullDetails?: boolean): string;
  108007. /** @hidden */
  108008. _unBindEffect(): void;
  108009. /**
  108010. * Gets a boolean indicating if this mesh has LOD
  108011. */
  108012. get hasLODLevels(): boolean;
  108013. /**
  108014. * Gets the list of MeshLODLevel associated with the current mesh
  108015. * @returns an array of MeshLODLevel
  108016. */
  108017. getLODLevels(): MeshLODLevel[];
  108018. private _sortLODLevels;
  108019. /**
  108020. * Add a mesh as LOD level triggered at the given distance.
  108021. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  108022. * @param distance The distance from the center of the object to show this level
  108023. * @param mesh The mesh to be added as LOD level (can be null)
  108024. * @return This mesh (for chaining)
  108025. */
  108026. addLODLevel(distance: number, mesh: Nullable<Mesh>): Mesh;
  108027. /**
  108028. * Returns the LOD level mesh at the passed distance or null if not found.
  108029. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  108030. * @param distance The distance from the center of the object to show this level
  108031. * @returns a Mesh or `null`
  108032. */
  108033. getLODLevelAtDistance(distance: number): Nullable<Mesh>;
  108034. /**
  108035. * Remove a mesh from the LOD array
  108036. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  108037. * @param mesh defines the mesh to be removed
  108038. * @return This mesh (for chaining)
  108039. */
  108040. removeLODLevel(mesh: Mesh): Mesh;
  108041. /**
  108042. * Returns the registered LOD mesh distant from the parameter `camera` position if any, else returns the current mesh.
  108043. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  108044. * @param camera defines the camera to use to compute distance
  108045. * @param boundingSphere defines a custom bounding sphere to use instead of the one from this mesh
  108046. * @return This mesh (for chaining)
  108047. */
  108048. getLOD(camera: Camera, boundingSphere?: BoundingSphere): Nullable<AbstractMesh>;
  108049. /**
  108050. * Gets the mesh internal Geometry object
  108051. */
  108052. get geometry(): Nullable<Geometry>;
  108053. /**
  108054. * Returns the total number of vertices within the mesh geometry or zero if the mesh has no geometry.
  108055. * @returns the total number of vertices
  108056. */
  108057. getTotalVertices(): number;
  108058. /**
  108059. * Returns the content of an associated vertex buffer
  108060. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  108061. * - VertexBuffer.PositionKind
  108062. * - VertexBuffer.UVKind
  108063. * - VertexBuffer.UV2Kind
  108064. * - VertexBuffer.UV3Kind
  108065. * - VertexBuffer.UV4Kind
  108066. * - VertexBuffer.UV5Kind
  108067. * - VertexBuffer.UV6Kind
  108068. * - VertexBuffer.ColorKind
  108069. * - VertexBuffer.MatricesIndicesKind
  108070. * - VertexBuffer.MatricesIndicesExtraKind
  108071. * - VertexBuffer.MatricesWeightsKind
  108072. * - VertexBuffer.MatricesWeightsExtraKind
  108073. * @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
  108074. * @param forceCopy defines a boolean forcing the copy of the buffer no matter what the value of copyWhenShared is
  108075. * @returns a FloatArray or null if the mesh has no geometry or no vertex buffer for this kind.
  108076. */
  108077. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  108078. /**
  108079. * Returns the mesh VertexBuffer object from the requested `kind`
  108080. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  108081. * - VertexBuffer.PositionKind
  108082. * - VertexBuffer.NormalKind
  108083. * - VertexBuffer.UVKind
  108084. * - VertexBuffer.UV2Kind
  108085. * - VertexBuffer.UV3Kind
  108086. * - VertexBuffer.UV4Kind
  108087. * - VertexBuffer.UV5Kind
  108088. * - VertexBuffer.UV6Kind
  108089. * - VertexBuffer.ColorKind
  108090. * - VertexBuffer.MatricesIndicesKind
  108091. * - VertexBuffer.MatricesIndicesExtraKind
  108092. * - VertexBuffer.MatricesWeightsKind
  108093. * - VertexBuffer.MatricesWeightsExtraKind
  108094. * @returns a FloatArray or null if the mesh has no vertex buffer for this kind.
  108095. */
  108096. getVertexBuffer(kind: string): Nullable<VertexBuffer>;
  108097. /**
  108098. * Tests if a specific vertex buffer is associated with this mesh
  108099. * @param kind defines which buffer to check (positions, indices, normals, etc). Possible `kind` values :
  108100. * - VertexBuffer.PositionKind
  108101. * - VertexBuffer.NormalKind
  108102. * - VertexBuffer.UVKind
  108103. * - VertexBuffer.UV2Kind
  108104. * - VertexBuffer.UV3Kind
  108105. * - VertexBuffer.UV4Kind
  108106. * - VertexBuffer.UV5Kind
  108107. * - VertexBuffer.UV6Kind
  108108. * - VertexBuffer.ColorKind
  108109. * - VertexBuffer.MatricesIndicesKind
  108110. * - VertexBuffer.MatricesIndicesExtraKind
  108111. * - VertexBuffer.MatricesWeightsKind
  108112. * - VertexBuffer.MatricesWeightsExtraKind
  108113. * @returns a boolean
  108114. */
  108115. isVerticesDataPresent(kind: string): boolean;
  108116. /**
  108117. * Returns a boolean defining if the vertex data for the requested `kind` is updatable.
  108118. * @param kind defines which buffer to check (positions, indices, normals, etc). Possible `kind` values :
  108119. * - VertexBuffer.PositionKind
  108120. * - VertexBuffer.UVKind
  108121. * - VertexBuffer.UV2Kind
  108122. * - VertexBuffer.UV3Kind
  108123. * - VertexBuffer.UV4Kind
  108124. * - VertexBuffer.UV5Kind
  108125. * - VertexBuffer.UV6Kind
  108126. * - VertexBuffer.ColorKind
  108127. * - VertexBuffer.MatricesIndicesKind
  108128. * - VertexBuffer.MatricesIndicesExtraKind
  108129. * - VertexBuffer.MatricesWeightsKind
  108130. * - VertexBuffer.MatricesWeightsExtraKind
  108131. * @returns a boolean
  108132. */
  108133. isVertexBufferUpdatable(kind: string): boolean;
  108134. /**
  108135. * Returns a string which contains the list of existing `kinds` of Vertex Data associated with this mesh.
  108136. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  108137. * - VertexBuffer.PositionKind
  108138. * - VertexBuffer.NormalKind
  108139. * - VertexBuffer.UVKind
  108140. * - VertexBuffer.UV2Kind
  108141. * - VertexBuffer.UV3Kind
  108142. * - VertexBuffer.UV4Kind
  108143. * - VertexBuffer.UV5Kind
  108144. * - VertexBuffer.UV6Kind
  108145. * - VertexBuffer.ColorKind
  108146. * - VertexBuffer.MatricesIndicesKind
  108147. * - VertexBuffer.MatricesIndicesExtraKind
  108148. * - VertexBuffer.MatricesWeightsKind
  108149. * - VertexBuffer.MatricesWeightsExtraKind
  108150. * @returns an array of strings
  108151. */
  108152. getVerticesDataKinds(): string[];
  108153. /**
  108154. * Returns a positive integer : the total number of indices in this mesh geometry.
  108155. * @returns the numner of indices or zero if the mesh has no geometry.
  108156. */
  108157. getTotalIndices(): number;
  108158. /**
  108159. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  108160. * @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.
  108161. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  108162. * @returns the indices array or an empty array if the mesh has no geometry
  108163. */
  108164. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  108165. get isBlocked(): boolean;
  108166. /**
  108167. * Determine if the current mesh is ready to be rendered
  108168. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  108169. * @param forceInstanceSupport will check if the mesh will be ready when used with instances (false by default)
  108170. * @returns true if all associated assets are ready (material, textures, shaders)
  108171. */
  108172. isReady(completeCheck?: boolean, forceInstanceSupport?: boolean): boolean;
  108173. /**
  108174. * 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.
  108175. */
  108176. get areNormalsFrozen(): boolean;
  108177. /**
  108178. * 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.
  108179. * @returns the current mesh
  108180. */
  108181. freezeNormals(): Mesh;
  108182. /**
  108183. * 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
  108184. * @returns the current mesh
  108185. */
  108186. unfreezeNormals(): Mesh;
  108187. /**
  108188. * Sets a value overriding the instance count. Only applicable when custom instanced InterleavedVertexBuffer are used rather than InstancedMeshs
  108189. */
  108190. set overridenInstanceCount(count: number);
  108191. /** @hidden */
  108192. _preActivate(): Mesh;
  108193. /** @hidden */
  108194. _preActivateForIntermediateRendering(renderId: number): Mesh;
  108195. /** @hidden */
  108196. _registerInstanceForRenderId(instance: InstancedMesh, renderId: number): Mesh;
  108197. protected _afterComputeWorldMatrix(): void;
  108198. /** @hidden */
  108199. _postActivate(): void;
  108200. /**
  108201. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  108202. * This means the mesh underlying bounding box and sphere are recomputed.
  108203. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  108204. * @returns the current mesh
  108205. */
  108206. refreshBoundingInfo(applySkeleton?: boolean): Mesh;
  108207. /** @hidden */
  108208. _createGlobalSubMesh(force: boolean): Nullable<SubMesh>;
  108209. /**
  108210. * This function will subdivide the mesh into multiple submeshes
  108211. * @param count defines the expected number of submeshes
  108212. */
  108213. subdivide(count: number): void;
  108214. /**
  108215. * Copy a FloatArray into a specific associated vertex buffer
  108216. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  108217. * - VertexBuffer.PositionKind
  108218. * - VertexBuffer.UVKind
  108219. * - VertexBuffer.UV2Kind
  108220. * - VertexBuffer.UV3Kind
  108221. * - VertexBuffer.UV4Kind
  108222. * - VertexBuffer.UV5Kind
  108223. * - VertexBuffer.UV6Kind
  108224. * - VertexBuffer.ColorKind
  108225. * - VertexBuffer.MatricesIndicesKind
  108226. * - VertexBuffer.MatricesIndicesExtraKind
  108227. * - VertexBuffer.MatricesWeightsKind
  108228. * - VertexBuffer.MatricesWeightsExtraKind
  108229. * @param data defines the data source
  108230. * @param updatable defines if the updated vertex buffer must be flagged as updatable
  108231. * @param stride defines the data stride size (can be null)
  108232. * @returns the current mesh
  108233. */
  108234. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  108235. /**
  108236. * Delete a vertex buffer associated with this mesh
  108237. * @param kind defines which buffer to delete (positions, indices, normals, etc). Possible `kind` values :
  108238. * - VertexBuffer.PositionKind
  108239. * - VertexBuffer.UVKind
  108240. * - VertexBuffer.UV2Kind
  108241. * - VertexBuffer.UV3Kind
  108242. * - VertexBuffer.UV4Kind
  108243. * - VertexBuffer.UV5Kind
  108244. * - VertexBuffer.UV6Kind
  108245. * - VertexBuffer.ColorKind
  108246. * - VertexBuffer.MatricesIndicesKind
  108247. * - VertexBuffer.MatricesIndicesExtraKind
  108248. * - VertexBuffer.MatricesWeightsKind
  108249. * - VertexBuffer.MatricesWeightsExtraKind
  108250. */
  108251. removeVerticesData(kind: string): void;
  108252. /**
  108253. * Flags an associated vertex buffer as updatable
  108254. * @param kind defines which buffer to use (positions, indices, normals, etc). Possible `kind` values :
  108255. * - VertexBuffer.PositionKind
  108256. * - VertexBuffer.UVKind
  108257. * - VertexBuffer.UV2Kind
  108258. * - VertexBuffer.UV3Kind
  108259. * - VertexBuffer.UV4Kind
  108260. * - VertexBuffer.UV5Kind
  108261. * - VertexBuffer.UV6Kind
  108262. * - VertexBuffer.ColorKind
  108263. * - VertexBuffer.MatricesIndicesKind
  108264. * - VertexBuffer.MatricesIndicesExtraKind
  108265. * - VertexBuffer.MatricesWeightsKind
  108266. * - VertexBuffer.MatricesWeightsExtraKind
  108267. * @param updatable defines if the updated vertex buffer must be flagged as updatable
  108268. */
  108269. markVerticesDataAsUpdatable(kind: string, updatable?: boolean): void;
  108270. /**
  108271. * Sets the mesh global Vertex Buffer
  108272. * @param buffer defines the buffer to use
  108273. * @returns the current mesh
  108274. */
  108275. setVerticesBuffer(buffer: VertexBuffer): Mesh;
  108276. /**
  108277. * Update a specific associated vertex buffer
  108278. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  108279. * - VertexBuffer.PositionKind
  108280. * - VertexBuffer.UVKind
  108281. * - VertexBuffer.UV2Kind
  108282. * - VertexBuffer.UV3Kind
  108283. * - VertexBuffer.UV4Kind
  108284. * - VertexBuffer.UV5Kind
  108285. * - VertexBuffer.UV6Kind
  108286. * - VertexBuffer.ColorKind
  108287. * - VertexBuffer.MatricesIndicesKind
  108288. * - VertexBuffer.MatricesIndicesExtraKind
  108289. * - VertexBuffer.MatricesWeightsKind
  108290. * - VertexBuffer.MatricesWeightsExtraKind
  108291. * @param data defines the data source
  108292. * @param updateExtends defines if extends info of the mesh must be updated (can be null). This is mostly useful for "position" kind
  108293. * @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)
  108294. * @returns the current mesh
  108295. */
  108296. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): AbstractMesh;
  108297. /**
  108298. * This method updates the vertex positions of an updatable mesh according to the `positionFunction` returned values.
  108299. * @see https://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh#other-shapes-updatemeshpositions
  108300. * @param positionFunction is a simple JS function what is passed the mesh `positions` array. It doesn't need to return anything
  108301. * @param computeNormals is a boolean (default true) to enable/disable the mesh normal recomputation after the vertex position update
  108302. * @returns the current mesh
  108303. */
  108304. updateMeshPositions(positionFunction: (data: FloatArray) => void, computeNormals?: boolean): Mesh;
  108305. /**
  108306. * Creates a un-shared specific occurence of the geometry for the mesh.
  108307. * @returns the current mesh
  108308. */
  108309. makeGeometryUnique(): Mesh;
  108310. /**
  108311. * Set the index buffer of this mesh
  108312. * @param indices defines the source data
  108313. * @param totalVertices defines the total number of vertices referenced by this index data (can be null)
  108314. * @param updatable defines if the updated index buffer must be flagged as updatable (default is false)
  108315. * @returns the current mesh
  108316. */
  108317. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>, updatable?: boolean): AbstractMesh;
  108318. /**
  108319. * Update the current index buffer
  108320. * @param indices defines the source data
  108321. * @param offset defines the offset in the index buffer where to store the new data (can be null)
  108322. * @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)
  108323. * @returns the current mesh
  108324. */
  108325. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): AbstractMesh;
  108326. /**
  108327. * Invert the geometry to move from a right handed system to a left handed one.
  108328. * @returns the current mesh
  108329. */
  108330. toLeftHanded(): Mesh;
  108331. /** @hidden */
  108332. _bind(subMesh: SubMesh, effect: Effect, fillMode: number): Mesh;
  108333. /** @hidden */
  108334. _draw(subMesh: SubMesh, fillMode: number, instancesCount?: number): Mesh;
  108335. /**
  108336. * Registers for this mesh a javascript function called just before the rendering process
  108337. * @param func defines the function to call before rendering this mesh
  108338. * @returns the current mesh
  108339. */
  108340. registerBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  108341. /**
  108342. * Disposes a previously registered javascript function called before the rendering
  108343. * @param func defines the function to remove
  108344. * @returns the current mesh
  108345. */
  108346. unregisterBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  108347. /**
  108348. * Registers for this mesh a javascript function called just after the rendering is complete
  108349. * @param func defines the function to call after rendering this mesh
  108350. * @returns the current mesh
  108351. */
  108352. registerAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  108353. /**
  108354. * Disposes a previously registered javascript function called after the rendering.
  108355. * @param func defines the function to remove
  108356. * @returns the current mesh
  108357. */
  108358. unregisterAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  108359. /** @hidden */
  108360. _getInstancesRenderList(subMeshId: number, isReplacementMode?: boolean): _InstancesBatch;
  108361. /** @hidden */
  108362. _renderWithInstances(subMesh: SubMesh, fillMode: number, batch: _InstancesBatch, effect: Effect, engine: Engine): Mesh;
  108363. /** @hidden */
  108364. _renderWithThinInstances(subMesh: SubMesh, fillMode: number, effect: Effect, engine: Engine): void;
  108365. /** @hidden */
  108366. _processInstancedBuffers(visibleInstances: InstancedMesh[], renderSelf: boolean): void;
  108367. /** @hidden */
  108368. _processRendering(renderingMesh: AbstractMesh, subMesh: SubMesh, effect: Effect, fillMode: number, batch: _InstancesBatch, hardwareInstancedRendering: boolean, onBeforeDraw: (isInstance: boolean, world: Matrix, effectiveMaterial?: Material) => void, effectiveMaterial?: Material): Mesh;
  108369. /** @hidden */
  108370. _rebuild(): void;
  108371. /** @hidden */
  108372. _freeze(): void;
  108373. /** @hidden */
  108374. _unFreeze(): void;
  108375. /**
  108376. * 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
  108377. * @param subMesh defines the subMesh to render
  108378. * @param enableAlphaMode defines if alpha mode can be changed
  108379. * @param effectiveMeshReplacement defines an optional mesh used to provide info for the rendering
  108380. * @returns the current mesh
  108381. */
  108382. render(subMesh: SubMesh, enableAlphaMode: boolean, effectiveMeshReplacement?: AbstractMesh): Mesh;
  108383. private _onBeforeDraw;
  108384. /**
  108385. * Renormalize the mesh and patch it up if there are no weights
  108386. * Similar to normalization by adding the weights compute the reciprocal and multiply all elements, this wil ensure that everything adds to 1.
  108387. * However in the case of zero weights then we set just a single influence to 1.
  108388. * We check in the function for extra's present and if so we use the normalizeSkinWeightsWithExtras rather than the FourWeights version.
  108389. */
  108390. cleanMatrixWeights(): void;
  108391. private normalizeSkinFourWeights;
  108392. private normalizeSkinWeightsAndExtra;
  108393. /**
  108394. * ValidateSkinning is used to determine that a mesh has valid skinning data along with skin metrics, if missing weights,
  108395. * or not normalized it is returned as invalid mesh the string can be used for console logs, or on screen messages to let
  108396. * the user know there was an issue with importing the mesh
  108397. * @returns a validation object with skinned, valid and report string
  108398. */
  108399. validateSkinning(): {
  108400. skinned: boolean;
  108401. valid: boolean;
  108402. report: string;
  108403. };
  108404. /** @hidden */
  108405. _checkDelayState(): Mesh;
  108406. private _queueLoad;
  108407. /**
  108408. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  108409. * A mesh is in the frustum if its bounding box intersects the frustum
  108410. * @param frustumPlanes defines the frustum to test
  108411. * @returns true if the mesh is in the frustum planes
  108412. */
  108413. isInFrustum(frustumPlanes: Plane[]): boolean;
  108414. /**
  108415. * Sets the mesh material by the material or multiMaterial `id` property
  108416. * @param id is a string identifying the material or the multiMaterial
  108417. * @returns the current mesh
  108418. */
  108419. setMaterialByID(id: string): Mesh;
  108420. /**
  108421. * Returns as a new array populated with the mesh material and/or skeleton, if any.
  108422. * @returns an array of IAnimatable
  108423. */
  108424. getAnimatables(): IAnimatable[];
  108425. /**
  108426. * Modifies the mesh geometry according to the passed transformation matrix.
  108427. * This method returns nothing but it really modifies the mesh even if it's originally not set as updatable.
  108428. * The mesh normals are modified using the same transformation.
  108429. * Note that, under the hood, this method sets a new VertexBuffer each call.
  108430. * @param transform defines the transform matrix to use
  108431. * @see https://doc.babylonjs.com/resources/baking_transformations
  108432. * @returns the current mesh
  108433. */
  108434. bakeTransformIntoVertices(transform: Matrix): Mesh;
  108435. /**
  108436. * Modifies the mesh geometry according to its own current World Matrix.
  108437. * The mesh World Matrix is then reset.
  108438. * This method returns nothing but really modifies the mesh even if it's originally not set as updatable.
  108439. * Note that, under the hood, this method sets a new VertexBuffer each call.
  108440. * @see https://doc.babylonjs.com/resources/baking_transformations
  108441. * @param bakeIndependenlyOfChildren indicates whether to preserve all child nodes' World Matrix during baking
  108442. * @returns the current mesh
  108443. */
  108444. bakeCurrentTransformIntoVertices(bakeIndependenlyOfChildren?: boolean): Mesh;
  108445. /** @hidden */
  108446. get _positions(): Nullable<Vector3[]>;
  108447. /** @hidden */
  108448. _resetPointsArrayCache(): Mesh;
  108449. /** @hidden */
  108450. _generatePointsArray(): boolean;
  108451. /**
  108452. * Returns a new Mesh object generated from the current mesh properties.
  108453. * This method must not get confused with createInstance()
  108454. * @param name is a string, the name given to the new mesh
  108455. * @param newParent can be any Node object (default `null`)
  108456. * @param doNotCloneChildren allows/denies the recursive cloning of the original mesh children if any (default `false`)
  108457. * @param clonePhysicsImpostor allows/denies the cloning in the same time of the original mesh `body` used by the physics engine, if any (default `true`)
  108458. * @returns a new mesh
  108459. */
  108460. clone(name?: string, newParent?: Nullable<Node>, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean): Mesh;
  108461. /**
  108462. * Releases resources associated with this mesh.
  108463. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  108464. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  108465. */
  108466. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  108467. /** @hidden */
  108468. _disposeInstanceSpecificData(): void;
  108469. /** @hidden */
  108470. _disposeThinInstanceSpecificData(): void;
  108471. /**
  108472. * Modifies the mesh geometry according to a displacement map.
  108473. * 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.
  108474. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  108475. * @param url is a string, the URL from the image file is to be downloaded.
  108476. * @param minHeight is the lower limit of the displacement.
  108477. * @param maxHeight is the upper limit of the displacement.
  108478. * @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.
  108479. * @param uvOffset is an optional vector2 used to offset UV.
  108480. * @param uvScale is an optional vector2 used to scale UV.
  108481. * @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.
  108482. * @returns the Mesh.
  108483. */
  108484. applyDisplacementMap(url: string, minHeight: number, maxHeight: number, onSuccess?: (mesh: Mesh) => void, uvOffset?: Vector2, uvScale?: Vector2, forceUpdate?: boolean): Mesh;
  108485. /**
  108486. * Modifies the mesh geometry according to a displacementMap buffer.
  108487. * 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.
  108488. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  108489. * @param buffer is a `Uint8Array` buffer containing series of `Uint8` lower than 255, the red, green, blue and alpha values of each successive pixel.
  108490. * @param heightMapWidth is the width of the buffer image.
  108491. * @param heightMapHeight is the height of the buffer image.
  108492. * @param minHeight is the lower limit of the displacement.
  108493. * @param maxHeight is the upper limit of the displacement.
  108494. * @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.
  108495. * @param uvOffset is an optional vector2 used to offset UV.
  108496. * @param uvScale is an optional vector2 used to scale UV.
  108497. * @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.
  108498. * @returns the Mesh.
  108499. */
  108500. applyDisplacementMapFromBuffer(buffer: Uint8Array, heightMapWidth: number, heightMapHeight: number, minHeight: number, maxHeight: number, uvOffset?: Vector2, uvScale?: Vector2, forceUpdate?: boolean): Mesh;
  108501. /**
  108502. * Modify the mesh to get a flat shading rendering.
  108503. * This means each mesh facet will then have its own normals. Usually new vertices are added in the mesh geometry to get this result.
  108504. * Warning : the mesh is really modified even if not set originally as updatable and, under the hood, a new VertexBuffer is allocated.
  108505. * @returns current mesh
  108506. */
  108507. convertToFlatShadedMesh(): Mesh;
  108508. /**
  108509. * This method removes all the mesh indices and add new vertices (duplication) in order to unfold facets into buffers.
  108510. * In other words, more vertices, no more indices and a single bigger VBO.
  108511. * The mesh is really modified even if not set originally as updatable. Under the hood, a new VertexBuffer is allocated.
  108512. * @returns current mesh
  108513. */
  108514. convertToUnIndexedMesh(): Mesh;
  108515. /**
  108516. * Inverses facet orientations.
  108517. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  108518. * @param flipNormals will also inverts the normals
  108519. * @returns current mesh
  108520. */
  108521. flipFaces(flipNormals?: boolean): Mesh;
  108522. /**
  108523. * Increase the number of facets and hence vertices in a mesh
  108524. * Vertex normals are interpolated from existing vertex normals
  108525. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  108526. * @param numberPerEdge the number of new vertices to add to each edge of a facet, optional default 1
  108527. */
  108528. increaseVertices(numberPerEdge: number): void;
  108529. /**
  108530. * Force adjacent facets to share vertices and remove any facets that have all vertices in a line
  108531. * This will undo any application of covertToFlatShadedMesh
  108532. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  108533. */
  108534. forceSharedVertices(): void;
  108535. /** @hidden */
  108536. static _instancedMeshFactory(name: string, mesh: Mesh): InstancedMesh;
  108537. /** @hidden */
  108538. static _PhysicsImpostorParser(scene: Scene, physicObject: IPhysicsEnabledObject, jsonObject: any): PhysicsImpostor;
  108539. /**
  108540. * Creates a new InstancedMesh object from the mesh model.
  108541. * @see https://doc.babylonjs.com/how_to/how_to_use_instances
  108542. * @param name defines the name of the new instance
  108543. * @returns a new InstancedMesh
  108544. */
  108545. createInstance(name: string): InstancedMesh;
  108546. /**
  108547. * Synchronises all the mesh instance submeshes to the current mesh submeshes, if any.
  108548. * After this call, all the mesh instances have the same submeshes than the current mesh.
  108549. * @returns the current mesh
  108550. */
  108551. synchronizeInstances(): Mesh;
  108552. /**
  108553. * Optimization of the mesh's indices, in case a mesh has duplicated vertices.
  108554. * The function will only reorder the indices and will not remove unused vertices to avoid problems with submeshes.
  108555. * This should be used together with the simplification to avoid disappearing triangles.
  108556. * @param successCallback an optional success callback to be called after the optimization finished.
  108557. * @returns the current mesh
  108558. */
  108559. optimizeIndices(successCallback?: (mesh?: Mesh) => void): Mesh;
  108560. /**
  108561. * Serialize current mesh
  108562. * @param serializationObject defines the object which will receive the serialization data
  108563. */
  108564. serialize(serializationObject: any): void;
  108565. /** @hidden */
  108566. _syncGeometryWithMorphTargetManager(): void;
  108567. /** @hidden */
  108568. static _GroundMeshParser: (parsedMesh: any, scene: Scene) => Mesh;
  108569. /**
  108570. * Returns a new Mesh object parsed from the source provided.
  108571. * @param parsedMesh is the source
  108572. * @param scene defines the hosting scene
  108573. * @param rootUrl is the root URL to prefix the `delayLoadingFile` property with
  108574. * @returns a new Mesh
  108575. */
  108576. static Parse(parsedMesh: any, scene: Scene, rootUrl: string): Mesh;
  108577. /**
  108578. * Creates a ribbon mesh. Please consider using the same method from the MeshBuilder class instead
  108579. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  108580. * @param name defines the name of the mesh to create
  108581. * @param pathArray is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry.
  108582. * @param closeArray creates a seam between the first and the last paths of the path array (default is false)
  108583. * @param closePath creates a seam between the first and the last points of each path of the path array
  108584. * @param offset is taken in account only if the `pathArray` is containing a single path
  108585. * @param scene defines the hosting scene
  108586. * @param updatable defines if the mesh must be flagged as updatable
  108587. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  108588. * @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)
  108589. * @returns a new Mesh
  108590. */
  108591. static CreateRibbon(name: string, pathArray: Vector3[][], closeArray: boolean, closePath: boolean, offset: number, scene?: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  108592. /**
  108593. * Creates a plane polygonal mesh. By default, this is a disc. Please consider using the same method from the MeshBuilder class instead
  108594. * @param name defines the name of the mesh to create
  108595. * @param radius sets the radius size (float) of the polygon (default 0.5)
  108596. * @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
  108597. * @param scene defines the hosting scene
  108598. * @param updatable defines if the mesh must be flagged as updatable
  108599. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  108600. * @returns a new Mesh
  108601. */
  108602. static CreateDisc(name: string, radius: number, tessellation: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  108603. /**
  108604. * Creates a box mesh. Please consider using the same method from the MeshBuilder class instead
  108605. * @param name defines the name of the mesh to create
  108606. * @param size sets the size (float) of each box side (default 1)
  108607. * @param scene defines the hosting scene
  108608. * @param updatable defines if the mesh must be flagged as updatable
  108609. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  108610. * @returns a new Mesh
  108611. */
  108612. static CreateBox(name: string, size: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  108613. /**
  108614. * Creates a sphere mesh. Please consider using the same method from the MeshBuilder class instead
  108615. * @param name defines the name of the mesh to create
  108616. * @param segments sets the sphere number of horizontal stripes (positive integer, default 32)
  108617. * @param diameter sets the diameter size (float) of the sphere (default 1)
  108618. * @param scene defines the hosting scene
  108619. * @param updatable defines if the mesh must be flagged as updatable
  108620. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  108621. * @returns a new Mesh
  108622. */
  108623. static CreateSphere(name: string, segments: number, diameter: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  108624. /**
  108625. * Creates a hemisphere mesh. Please consider using the same method from the MeshBuilder class instead
  108626. * @param name defines the name of the mesh to create
  108627. * @param segments sets the sphere number of horizontal stripes (positive integer, default 32)
  108628. * @param diameter sets the diameter size (float) of the sphere (default 1)
  108629. * @param scene defines the hosting scene
  108630. * @returns a new Mesh
  108631. */
  108632. static CreateHemisphere(name: string, segments: number, diameter: number, scene?: Scene): Mesh;
  108633. /**
  108634. * Creates a cylinder or a cone mesh. Please consider using the same method from the MeshBuilder class instead
  108635. * @param name defines the name of the mesh to create
  108636. * @param height sets the height size (float) of the cylinder/cone (float, default 2)
  108637. * @param diameterTop set the top cap diameter (floats, default 1)
  108638. * @param diameterBottom set the bottom cap diameter (floats, default 1). This value can't be zero
  108639. * @param tessellation sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance
  108640. * @param subdivisions sets the number of rings along the cylinder height (positive integer, default 1)
  108641. * @param scene defines the hosting scene
  108642. * @param updatable defines if the mesh must be flagged as updatable
  108643. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  108644. * @returns a new Mesh
  108645. */
  108646. static CreateCylinder(name: string, height: number, diameterTop: number, diameterBottom: number, tessellation: number, subdivisions: any, scene?: Scene, updatable?: any, sideOrientation?: number): Mesh;
  108647. /**
  108648. * Creates a torus mesh. Please consider using the same method from the MeshBuilder class instead
  108649. * @param name defines the name of the mesh to create
  108650. * @param diameter sets the diameter size (float) of the torus (default 1)
  108651. * @param thickness sets the diameter size of the tube of the torus (float, default 0.5)
  108652. * @param tessellation sets the number of torus sides (postive integer, default 16)
  108653. * @param scene defines the hosting scene
  108654. * @param updatable defines if the mesh must be flagged as updatable
  108655. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  108656. * @returns a new Mesh
  108657. */
  108658. static CreateTorus(name: string, diameter: number, thickness: number, tessellation: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  108659. /**
  108660. * Creates a torus knot mesh. Please consider using the same method from the MeshBuilder class instead
  108661. * @param name defines the name of the mesh to create
  108662. * @param radius sets the global radius size (float) of the torus knot (default 2)
  108663. * @param tube sets the diameter size of the tube of the torus (float, default 0.5)
  108664. * @param radialSegments sets the number of sides on each tube segments (positive integer, default 32)
  108665. * @param tubularSegments sets the number of tubes to decompose the knot into (positive integer, default 32)
  108666. * @param p the number of windings on X axis (positive integers, default 2)
  108667. * @param q the number of windings on Y axis (positive integers, default 3)
  108668. * @param scene defines the hosting scene
  108669. * @param updatable defines if the mesh must be flagged as updatable
  108670. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  108671. * @returns a new Mesh
  108672. */
  108673. static CreateTorusKnot(name: string, radius: number, tube: number, radialSegments: number, tubularSegments: number, p: number, q: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  108674. /**
  108675. * Creates a line mesh. Please consider using the same method from the MeshBuilder class instead.
  108676. * @param name defines the name of the mesh to create
  108677. * @param points is an array successive Vector3
  108678. * @param scene defines the hosting scene
  108679. * @param updatable defines if the mesh must be flagged as updatable
  108680. * @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).
  108681. * @returns a new Mesh
  108682. */
  108683. static CreateLines(name: string, points: Vector3[], scene?: Nullable<Scene>, updatable?: boolean, instance?: Nullable<LinesMesh>): LinesMesh;
  108684. /**
  108685. * Creates a dashed line mesh. Please consider using the same method from the MeshBuilder class instead
  108686. * @param name defines the name of the mesh to create
  108687. * @param points is an array successive Vector3
  108688. * @param dashSize is the size of the dashes relatively the dash number (positive float, default 3)
  108689. * @param gapSize is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  108690. * @param dashNb is the intended total number of dashes (positive integer, default 200)
  108691. * @param scene defines the hosting scene
  108692. * @param updatable defines if the mesh must be flagged as updatable
  108693. * @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)
  108694. * @returns a new Mesh
  108695. */
  108696. static CreateDashedLines(name: string, points: Vector3[], dashSize: number, gapSize: number, dashNb: number, scene?: Nullable<Scene>, updatable?: boolean, instance?: LinesMesh): LinesMesh;
  108697. /**
  108698. * Creates a polygon mesh.Please consider using the same method from the MeshBuilder class instead
  108699. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh.
  108700. * 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.
  108701. * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  108702. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  108703. * Remember you can only change the shape positions, not their number when updating a polygon.
  108704. * @see https://doc.babylonjs.com/how_to/parametric_shapes#non-regular-polygon
  108705. * @param name defines the name of the mesh to create
  108706. * @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
  108707. * @param scene defines the hosting scene
  108708. * @param holes is a required array of arrays of successive Vector3 used to defines holes in the polygon
  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. * @param earcutInjection can be used to inject your own earcut reference
  108712. * @returns a new Mesh
  108713. */
  108714. static CreatePolygon(name: string, shape: Vector3[], scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number, earcutInjection?: any): Mesh;
  108715. /**
  108716. * Creates an extruded polygon mesh, with depth in the Y direction. Please consider using the same method from the MeshBuilder class instead.
  108717. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-non-regular-polygon
  108718. * @param name defines the name of the mesh to create
  108719. * @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
  108720. * @param depth defines the height of extrusion
  108721. * @param scene defines the hosting scene
  108722. * @param holes is a required array of arrays of successive Vector3 used to defines holes in the polygon
  108723. * @param updatable defines if the mesh must be flagged as updatable
  108724. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  108725. * @param earcutInjection can be used to inject your own earcut reference
  108726. * @returns a new Mesh
  108727. */
  108728. static ExtrudePolygon(name: string, shape: Vector3[], depth: number, scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number, earcutInjection?: any): Mesh;
  108729. /**
  108730. * Creates an extruded shape mesh.
  108731. * 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
  108732. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  108733. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  108734. * @param name defines the name of the mesh to create
  108735. * @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
  108736. * @param path is a required array of successive Vector3. This is the axis curve the shape is extruded along
  108737. * @param scale is the value to scale the shape
  108738. * @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
  108739. * @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
  108740. * @param scene defines the hosting scene
  108741. * @param updatable defines if the mesh must be flagged as updatable
  108742. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  108743. * @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)
  108744. * @returns a new Mesh
  108745. */
  108746. static ExtrudeShape(name: string, shape: Vector3[], path: Vector3[], scale: number, rotation: number, cap: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  108747. /**
  108748. * Creates an custom extruded shape mesh.
  108749. * The custom extrusion is a parametric shape.
  108750. * It has no predefined shape. Its final shape will depend on the input parameters.
  108751. * Please consider using the same method from the MeshBuilder class instead
  108752. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  108753. * @param name defines the name of the mesh to create
  108754. * @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
  108755. * @param path is a required array of successive Vector3. This is the axis curve the shape is extruded along
  108756. * @param scaleFunction is a custom Javascript function called on each path point
  108757. * @param rotationFunction is a custom Javascript function called on each path point
  108758. * @param ribbonCloseArray forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  108759. * @param ribbonClosePath forces the extrusion underlying ribbon to close its `pathArray`
  108760. * @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
  108761. * @param scene defines the hosting scene
  108762. * @param updatable defines if the mesh must be flagged as updatable
  108763. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  108764. * @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)
  108765. * @returns a new Mesh
  108766. */
  108767. 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;
  108768. /**
  108769. * Creates lathe mesh.
  108770. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe.
  108771. * Please consider using the same method from the MeshBuilder class instead
  108772. * @param name defines the name of the mesh to create
  108773. * @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
  108774. * @param radius is the radius value of the lathe
  108775. * @param tessellation is the side number of the lathe.
  108776. * @param scene defines the hosting scene
  108777. * @param updatable defines if the mesh must be flagged as updatable
  108778. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  108779. * @returns a new Mesh
  108780. */
  108781. static CreateLathe(name: string, shape: Vector3[], radius: number, tessellation: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  108782. /**
  108783. * Creates a plane mesh. Please consider using the same method from the MeshBuilder class instead
  108784. * @param name defines the name of the mesh to create
  108785. * @param size sets the size (float) of both sides of the plane at once (default 1)
  108786. * @param scene defines the hosting scene
  108787. * @param updatable defines if the mesh must be flagged as updatable
  108788. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  108789. * @returns a new Mesh
  108790. */
  108791. static CreatePlane(name: string, size: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  108792. /**
  108793. * Creates a ground mesh.
  108794. * Please consider using the same method from the MeshBuilder class instead
  108795. * @param name defines the name of the mesh to create
  108796. * @param width set the width of the ground
  108797. * @param height set the height of the ground
  108798. * @param subdivisions sets the number of subdivisions per side
  108799. * @param scene defines the hosting scene
  108800. * @param updatable defines if the mesh must be flagged as updatable
  108801. * @returns a new Mesh
  108802. */
  108803. static CreateGround(name: string, width: number, height: number, subdivisions: number, scene?: Scene, updatable?: boolean): Mesh;
  108804. /**
  108805. * Creates a tiled ground mesh.
  108806. * Please consider using the same method from the MeshBuilder class instead
  108807. * @param name defines the name of the mesh to create
  108808. * @param xmin set the ground minimum X coordinate
  108809. * @param zmin set the ground minimum Y coordinate
  108810. * @param xmax set the ground maximum X coordinate
  108811. * @param zmax set the ground maximum Z coordinate
  108812. * @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
  108813. * @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
  108814. * @param scene defines the hosting scene
  108815. * @param updatable defines if the mesh must be flagged as updatable
  108816. * @returns a new Mesh
  108817. */
  108818. static CreateTiledGround(name: string, xmin: number, zmin: number, xmax: number, zmax: number, subdivisions: {
  108819. w: number;
  108820. h: number;
  108821. }, precision: {
  108822. w: number;
  108823. h: number;
  108824. }, scene: Scene, updatable?: boolean): Mesh;
  108825. /**
  108826. * Creates a ground mesh from a height map.
  108827. * Please consider using the same method from the MeshBuilder class instead
  108828. * @see https://doc.babylonjs.com/babylon101/height_map
  108829. * @param name defines the name of the mesh to create
  108830. * @param url sets the URL of the height map image resource
  108831. * @param width set the ground width size
  108832. * @param height set the ground height size
  108833. * @param subdivisions sets the number of subdivision per side
  108834. * @param minHeight is the minimum altitude on the ground
  108835. * @param maxHeight is the maximum altitude on the ground
  108836. * @param scene defines the hosting scene
  108837. * @param updatable defines if the mesh must be flagged as updatable
  108838. * @param onReady is a callback function that will be called once the mesh is built (the height map download can last some time)
  108839. * @param alphaFilter will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  108840. * @returns a new Mesh
  108841. */
  108842. 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;
  108843. /**
  108844. * Creates a tube mesh.
  108845. * The tube is a parametric shape.
  108846. * It has no predefined shape. Its final shape will depend on the input parameters.
  108847. * Please consider using the same method from the MeshBuilder class instead
  108848. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  108849. * @param name defines the name of the mesh to create
  108850. * @param path is a required array of successive Vector3. It is the curve used as the axis of the tube
  108851. * @param radius sets the tube radius size
  108852. * @param tessellation is the number of sides on the tubular surface
  108853. * @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
  108854. * @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
  108855. * @param scene defines the hosting scene
  108856. * @param updatable defines if the mesh must be flagged as updatable
  108857. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  108858. * @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)
  108859. * @returns a new Mesh
  108860. */
  108861. static CreateTube(name: string, path: Vector3[], radius: number, tessellation: number, radiusFunction: {
  108862. (i: number, distance: number): number;
  108863. }, cap: number, scene: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  108864. /**
  108865. * Creates a polyhedron mesh.
  108866. * Please consider using the same method from the MeshBuilder class instead.
  108867. * * 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
  108868. * * The parameter `size` (positive float, default 1) sets the polygon size
  108869. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  108870. * * 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`
  108871. * * 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
  108872. * * 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)`)
  108873. * * 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
  108874. * * 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
  108875. * * You can also set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  108876. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  108877. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  108878. * @param name defines the name of the mesh to create
  108879. * @param options defines the options used to create the mesh
  108880. * @param scene defines the hosting scene
  108881. * @returns a new Mesh
  108882. */
  108883. static CreatePolyhedron(name: string, options: {
  108884. type?: number;
  108885. size?: number;
  108886. sizeX?: number;
  108887. sizeY?: number;
  108888. sizeZ?: number;
  108889. custom?: any;
  108890. faceUV?: Vector4[];
  108891. faceColors?: Color4[];
  108892. updatable?: boolean;
  108893. sideOrientation?: number;
  108894. }, scene: Scene): Mesh;
  108895. /**
  108896. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  108897. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  108898. * * 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`)
  108899. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  108900. * * 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
  108901. * * You can also set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  108902. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  108903. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  108904. * @param name defines the name of the mesh
  108905. * @param options defines the options used to create the mesh
  108906. * @param scene defines the hosting scene
  108907. * @returns a new Mesh
  108908. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  108909. */
  108910. static CreateIcoSphere(name: string, options: {
  108911. radius?: number;
  108912. flat?: boolean;
  108913. subdivisions?: number;
  108914. sideOrientation?: number;
  108915. updatable?: boolean;
  108916. }, scene: Scene): Mesh;
  108917. /**
  108918. * Creates a decal mesh.
  108919. * Please consider using the same method from the MeshBuilder class instead.
  108920. * A decal is a mesh usually applied as a model onto the surface of another mesh
  108921. * @param name defines the name of the mesh
  108922. * @param sourceMesh defines the mesh receiving the decal
  108923. * @param position sets the position of the decal in world coordinates
  108924. * @param normal sets the normal of the mesh where the decal is applied onto in world coordinates
  108925. * @param size sets the decal scaling
  108926. * @param angle sets the angle to rotate the decal
  108927. * @returns a new Mesh
  108928. */
  108929. static CreateDecal(name: string, sourceMesh: AbstractMesh, position: Vector3, normal: Vector3, size: Vector3, angle: number): Mesh;
  108930. /**
  108931. * Prepare internal position array for software CPU skinning
  108932. * @returns original positions used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh
  108933. */
  108934. setPositionsForCPUSkinning(): Float32Array;
  108935. /**
  108936. * Prepare internal normal array for software CPU skinning
  108937. * @returns original normals used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh.
  108938. */
  108939. setNormalsForCPUSkinning(): Float32Array;
  108940. /**
  108941. * Updates the vertex buffer by applying transformation from the bones
  108942. * @param skeleton defines the skeleton to apply to current mesh
  108943. * @returns the current mesh
  108944. */
  108945. applySkeleton(skeleton: Skeleton): Mesh;
  108946. /**
  108947. * 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
  108948. * @param meshes defines the list of meshes to scan
  108949. * @returns an object `{min:` Vector3`, max:` Vector3`}`
  108950. */
  108951. static MinMax(meshes: AbstractMesh[]): {
  108952. min: Vector3;
  108953. max: Vector3;
  108954. };
  108955. /**
  108956. * Returns the center of the `{min:` Vector3`, max:` Vector3`}` or the center of MinMax vector3 computed from a mesh array
  108957. * @param meshesOrMinMaxVector could be an array of meshes or a `{min:` Vector3`, max:` Vector3`}` object
  108958. * @returns a vector3
  108959. */
  108960. static Center(meshesOrMinMaxVector: {
  108961. min: Vector3;
  108962. max: Vector3;
  108963. } | AbstractMesh[]): Vector3;
  108964. /**
  108965. * Merge the array of meshes into a single mesh for performance reasons.
  108966. * @param meshes defines he vertices source. They should all be of the same material. Entries can empty
  108967. * @param disposeSource when true (default), dispose of the vertices from the source meshes
  108968. * @param allow32BitsIndices when the sum of the vertices > 64k, this must be set to true
  108969. * @param meshSubclass when set, vertices inserted into this Mesh. Meshes can then be merged into a Mesh sub-class.
  108970. * @param subdivideWithSubMeshes when true (false default), subdivide mesh to his subMesh array with meshes source.
  108971. * @param multiMultiMaterials when true (false default), subdivide mesh and accept multiple multi materials, ignores subdivideWithSubMeshes.
  108972. * @returns a new mesh
  108973. */
  108974. static MergeMeshes(meshes: Array<Mesh>, disposeSource?: boolean, allow32BitsIndices?: boolean, meshSubclass?: Mesh, subdivideWithSubMeshes?: boolean, multiMultiMaterials?: boolean): Nullable<Mesh>;
  108975. /** @hidden */
  108976. addInstance(instance: InstancedMesh): void;
  108977. /** @hidden */
  108978. removeInstance(instance: InstancedMesh): void;
  108979. }
  108980. }
  108981. declare module BABYLON {
  108982. /**
  108983. * This is the base class of all the camera used in the application.
  108984. * @see https://doc.babylonjs.com/features/cameras
  108985. */
  108986. export class Camera extends Node {
  108987. /** @hidden */
  108988. static _createDefaultParsedCamera: (name: string, scene: Scene) => Camera;
  108989. /**
  108990. * This is the default projection mode used by the cameras.
  108991. * It helps recreating a feeling of perspective and better appreciate depth.
  108992. * This is the best way to simulate real life cameras.
  108993. */
  108994. static readonly PERSPECTIVE_CAMERA: number;
  108995. /**
  108996. * This helps creating camera with an orthographic mode.
  108997. * 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.
  108998. */
  108999. static readonly ORTHOGRAPHIC_CAMERA: number;
  109000. /**
  109001. * This is the default FOV mode for perspective cameras.
  109002. * This setting aligns the upper and lower bounds of the viewport to the upper and lower bounds of the camera frustum.
  109003. */
  109004. static readonly FOVMODE_VERTICAL_FIXED: number;
  109005. /**
  109006. * This setting aligns the left and right bounds of the viewport to the left and right bounds of the camera frustum.
  109007. */
  109008. static readonly FOVMODE_HORIZONTAL_FIXED: number;
  109009. /**
  109010. * This specifies ther is no need for a camera rig.
  109011. * Basically only one eye is rendered corresponding to the camera.
  109012. */
  109013. static readonly RIG_MODE_NONE: number;
  109014. /**
  109015. * Simulates a camera Rig with one blue eye and one red eye.
  109016. * This can be use with 3d blue and red glasses.
  109017. */
  109018. static readonly RIG_MODE_STEREOSCOPIC_ANAGLYPH: number;
  109019. /**
  109020. * Defines that both eyes of the camera will be rendered side by side with a parallel target.
  109021. */
  109022. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_PARALLEL: number;
  109023. /**
  109024. * Defines that both eyes of the camera will be rendered side by side with a none parallel target.
  109025. */
  109026. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_CROSSEYED: number;
  109027. /**
  109028. * Defines that both eyes of the camera will be rendered over under each other.
  109029. */
  109030. static readonly RIG_MODE_STEREOSCOPIC_OVERUNDER: number;
  109031. /**
  109032. * Defines that both eyes of the camera will be rendered on successive lines interlaced for passive 3d monitors.
  109033. */
  109034. static readonly RIG_MODE_STEREOSCOPIC_INTERLACED: number;
  109035. /**
  109036. * Defines that both eyes of the camera should be renderered in a VR mode (carbox).
  109037. */
  109038. static readonly RIG_MODE_VR: number;
  109039. /**
  109040. * Defines that both eyes of the camera should be renderered in a VR mode (webVR).
  109041. */
  109042. static readonly RIG_MODE_WEBVR: number;
  109043. /**
  109044. * Custom rig mode allowing rig cameras to be populated manually with any number of cameras
  109045. */
  109046. static readonly RIG_MODE_CUSTOM: number;
  109047. /**
  109048. * Defines if by default attaching controls should prevent the default javascript event to continue.
  109049. */
  109050. static ForceAttachControlToAlwaysPreventDefault: boolean;
  109051. /**
  109052. * Define the input manager associated with the camera.
  109053. */
  109054. inputs: CameraInputsManager<Camera>;
  109055. /** @hidden */
  109056. _position: Vector3;
  109057. /**
  109058. * Define the current local position of the camera in the scene
  109059. */
  109060. get position(): Vector3;
  109061. set position(newPosition: Vector3);
  109062. protected _upVector: Vector3;
  109063. /**
  109064. * The vector the camera should consider as up.
  109065. * (default is Vector3(0, 1, 0) aka Vector3.Up())
  109066. */
  109067. set upVector(vec: Vector3);
  109068. get upVector(): Vector3;
  109069. /**
  109070. * Define the current limit on the left side for an orthographic camera
  109071. * In scene unit
  109072. */
  109073. orthoLeft: Nullable<number>;
  109074. /**
  109075. * Define the current limit on the right side for an orthographic camera
  109076. * In scene unit
  109077. */
  109078. orthoRight: Nullable<number>;
  109079. /**
  109080. * Define the current limit on the bottom side for an orthographic camera
  109081. * In scene unit
  109082. */
  109083. orthoBottom: Nullable<number>;
  109084. /**
  109085. * Define the current limit on the top side for an orthographic camera
  109086. * In scene unit
  109087. */
  109088. orthoTop: Nullable<number>;
  109089. /**
  109090. * Field Of View is set in Radians. (default is 0.8)
  109091. */
  109092. fov: number;
  109093. /**
  109094. * Define the minimum distance the camera can see from.
  109095. * This is important to note that the depth buffer are not infinite and the closer it starts
  109096. * the more your scene might encounter depth fighting issue.
  109097. */
  109098. minZ: number;
  109099. /**
  109100. * Define the maximum distance the camera can see to.
  109101. * This is important to note that the depth buffer are not infinite and the further it end
  109102. * the more your scene might encounter depth fighting issue.
  109103. */
  109104. maxZ: number;
  109105. /**
  109106. * Define the default inertia of the camera.
  109107. * This helps giving a smooth feeling to the camera movement.
  109108. */
  109109. inertia: number;
  109110. /**
  109111. * Define the mode of the camera (Camera.PERSPECTIVE_CAMERA or Camera.ORTHOGRAPHIC_CAMERA)
  109112. */
  109113. mode: number;
  109114. /**
  109115. * Define whether the camera is intermediate.
  109116. * This is useful to not present the output directly to the screen in case of rig without post process for instance
  109117. */
  109118. isIntermediate: boolean;
  109119. /**
  109120. * Define the viewport of the camera.
  109121. * This correspond to the portion of the screen the camera will render to in normalized 0 to 1 unit.
  109122. */
  109123. viewport: Viewport;
  109124. /**
  109125. * Restricts the camera to viewing objects with the same layerMask.
  109126. * A camera with a layerMask of 1 will render mesh.layerMask & camera.layerMask!== 0
  109127. */
  109128. layerMask: number;
  109129. /**
  109130. * fovMode sets the camera frustum bounds to the viewport bounds. (default is FOVMODE_VERTICAL_FIXED)
  109131. */
  109132. fovMode: number;
  109133. /**
  109134. * Rig mode of the camera.
  109135. * This is useful to create the camera with two "eyes" instead of one to create VR or stereoscopic scenes.
  109136. * This is normally controlled byt the camera themselves as internal use.
  109137. */
  109138. cameraRigMode: number;
  109139. /**
  109140. * Defines the distance between both "eyes" in case of a RIG
  109141. */
  109142. interaxialDistance: number;
  109143. /**
  109144. * Defines if stereoscopic rendering is done side by side or over under.
  109145. */
  109146. isStereoscopicSideBySide: boolean;
  109147. /**
  109148. * 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
  109149. * This is pretty helpfull if you wish to make a camera render to a texture you could reuse somewhere
  109150. * else in the scene. (Eg. security camera)
  109151. *
  109152. * 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)
  109153. */
  109154. customRenderTargets: RenderTargetTexture[];
  109155. /**
  109156. * When set, the camera will render to this render target instead of the default canvas
  109157. *
  109158. * If the desire is to use the output of a camera as a texture in the scene consider using camera.customRenderTargets instead
  109159. */
  109160. outputRenderTarget: Nullable<RenderTargetTexture>;
  109161. /**
  109162. * Observable triggered when the camera view matrix has changed.
  109163. */
  109164. onViewMatrixChangedObservable: Observable<Camera>;
  109165. /**
  109166. * Observable triggered when the camera Projection matrix has changed.
  109167. */
  109168. onProjectionMatrixChangedObservable: Observable<Camera>;
  109169. /**
  109170. * Observable triggered when the inputs have been processed.
  109171. */
  109172. onAfterCheckInputsObservable: Observable<Camera>;
  109173. /**
  109174. * Observable triggered when reset has been called and applied to the camera.
  109175. */
  109176. onRestoreStateObservable: Observable<Camera>;
  109177. /**
  109178. * Is this camera a part of a rig system?
  109179. */
  109180. isRigCamera: boolean;
  109181. /**
  109182. * If isRigCamera set to true this will be set with the parent camera.
  109183. * The parent camera is not (!) necessarily the .parent of this camera (like in the case of XR)
  109184. */
  109185. rigParent?: Camera;
  109186. /** @hidden */
  109187. _cameraRigParams: any;
  109188. /** @hidden */
  109189. _rigCameras: Camera[];
  109190. /** @hidden */
  109191. _rigPostProcess: Nullable<PostProcess>;
  109192. protected _webvrViewMatrix: Matrix;
  109193. /** @hidden */
  109194. _skipRendering: boolean;
  109195. /** @hidden */
  109196. _projectionMatrix: Matrix;
  109197. /** @hidden */
  109198. _postProcesses: Nullable<PostProcess>[];
  109199. /** @hidden */
  109200. _activeMeshes: SmartArray<AbstractMesh>;
  109201. protected _globalPosition: Vector3;
  109202. /** @hidden */
  109203. _computedViewMatrix: Matrix;
  109204. private _doNotComputeProjectionMatrix;
  109205. private _transformMatrix;
  109206. private _frustumPlanes;
  109207. private _refreshFrustumPlanes;
  109208. private _storedFov;
  109209. private _stateStored;
  109210. /**
  109211. * Instantiates a new camera object.
  109212. * This should not be used directly but through the inherited cameras: ArcRotate, Free...
  109213. * @see https://doc.babylonjs.com/features/cameras
  109214. * @param name Defines the name of the camera in the scene
  109215. * @param position Defines the position of the camera
  109216. * @param scene Defines the scene the camera belongs too
  109217. * @param setActiveOnSceneIfNoneActive Defines if the camera should be set as active after creation if no other camera have been defined in the scene
  109218. */
  109219. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  109220. /**
  109221. * Store current camera state (fov, position, etc..)
  109222. * @returns the camera
  109223. */
  109224. storeState(): Camera;
  109225. /**
  109226. * Restores the camera state values if it has been stored. You must call storeState() first
  109227. */
  109228. protected _restoreStateValues(): boolean;
  109229. /**
  109230. * Restored camera state. You must call storeState() first.
  109231. * @returns true if restored and false otherwise
  109232. */
  109233. restoreState(): boolean;
  109234. /**
  109235. * Gets the class name of the camera.
  109236. * @returns the class name
  109237. */
  109238. getClassName(): string;
  109239. /** @hidden */
  109240. readonly _isCamera: boolean;
  109241. /**
  109242. * Gets a string representation of the camera useful for debug purpose.
  109243. * @param fullDetails Defines that a more verboe level of logging is required
  109244. * @returns the string representation
  109245. */
  109246. toString(fullDetails?: boolean): string;
  109247. /**
  109248. * Gets the current world space position of the camera.
  109249. */
  109250. get globalPosition(): Vector3;
  109251. /**
  109252. * Gets the list of active meshes this frame (meshes no culled or excluded by lod s in the frame)
  109253. * @returns the active meshe list
  109254. */
  109255. getActiveMeshes(): SmartArray<AbstractMesh>;
  109256. /**
  109257. * Check whether a mesh is part of the current active mesh list of the camera
  109258. * @param mesh Defines the mesh to check
  109259. * @returns true if active, false otherwise
  109260. */
  109261. isActiveMesh(mesh: Mesh): boolean;
  109262. /**
  109263. * Is this camera ready to be used/rendered
  109264. * @param completeCheck defines if a complete check (including post processes) has to be done (false by default)
  109265. * @return true if the camera is ready
  109266. */
  109267. isReady(completeCheck?: boolean): boolean;
  109268. /** @hidden */
  109269. _initCache(): void;
  109270. /** @hidden */
  109271. _updateCache(ignoreParentClass?: boolean): void;
  109272. /** @hidden */
  109273. _isSynchronized(): boolean;
  109274. /** @hidden */
  109275. _isSynchronizedViewMatrix(): boolean;
  109276. /** @hidden */
  109277. _isSynchronizedProjectionMatrix(): boolean;
  109278. /**
  109279. * Attach the input controls to a specific dom element to get the input from.
  109280. * @param element Defines the element the controls should be listened from
  109281. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  109282. */
  109283. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  109284. /**
  109285. * Detach the current controls from the specified dom element.
  109286. * @param element Defines the element to stop listening the inputs from
  109287. */
  109288. detachControl(element: HTMLElement): void;
  109289. /**
  109290. * Update the camera state according to the different inputs gathered during the frame.
  109291. */
  109292. update(): void;
  109293. /** @hidden */
  109294. _checkInputs(): void;
  109295. /** @hidden */
  109296. get rigCameras(): Camera[];
  109297. /**
  109298. * Gets the post process used by the rig cameras
  109299. */
  109300. get rigPostProcess(): Nullable<PostProcess>;
  109301. /**
  109302. * Internal, gets the first post proces.
  109303. * @returns the first post process to be run on this camera.
  109304. */
  109305. _getFirstPostProcess(): Nullable<PostProcess>;
  109306. private _cascadePostProcessesToRigCams;
  109307. /**
  109308. * Attach a post process to the camera.
  109309. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#attach-postprocess
  109310. * @param postProcess The post process to attach to the camera
  109311. * @param insertAt The position of the post process in case several of them are in use in the scene
  109312. * @returns the position the post process has been inserted at
  109313. */
  109314. attachPostProcess(postProcess: PostProcess, insertAt?: Nullable<number>): number;
  109315. /**
  109316. * Detach a post process to the camera.
  109317. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#attach-postprocess
  109318. * @param postProcess The post process to detach from the camera
  109319. */
  109320. detachPostProcess(postProcess: PostProcess): void;
  109321. /**
  109322. * Gets the current world matrix of the camera
  109323. */
  109324. getWorldMatrix(): Matrix;
  109325. /** @hidden */
  109326. _getViewMatrix(): Matrix;
  109327. /**
  109328. * Gets the current view matrix of the camera.
  109329. * @param force forces the camera to recompute the matrix without looking at the cached state
  109330. * @returns the view matrix
  109331. */
  109332. getViewMatrix(force?: boolean): Matrix;
  109333. /**
  109334. * Freeze the projection matrix.
  109335. * It will prevent the cache check of the camera projection compute and can speed up perf
  109336. * if no parameter of the camera are meant to change
  109337. * @param projection Defines manually a projection if necessary
  109338. */
  109339. freezeProjectionMatrix(projection?: Matrix): void;
  109340. /**
  109341. * Unfreeze the projection matrix if it has previously been freezed by freezeProjectionMatrix.
  109342. */
  109343. unfreezeProjectionMatrix(): void;
  109344. /**
  109345. * Gets the current projection matrix of the camera.
  109346. * @param force forces the camera to recompute the matrix without looking at the cached state
  109347. * @returns the projection matrix
  109348. */
  109349. getProjectionMatrix(force?: boolean): Matrix;
  109350. /**
  109351. * Gets the transformation matrix (ie. the multiplication of view by projection matrices)
  109352. * @returns a Matrix
  109353. */
  109354. getTransformationMatrix(): Matrix;
  109355. private _updateFrustumPlanes;
  109356. /**
  109357. * Checks if a cullable object (mesh...) is in the camera frustum
  109358. * This checks the bounding box center. See isCompletelyInFrustum for a full bounding check
  109359. * @param target The object to check
  109360. * @param checkRigCameras If the rig cameras should be checked (eg. with webVR camera both eyes should be checked) (Default: false)
  109361. * @returns true if the object is in frustum otherwise false
  109362. */
  109363. isInFrustum(target: ICullable, checkRigCameras?: boolean): boolean;
  109364. /**
  109365. * Checks if a cullable object (mesh...) is in the camera frustum
  109366. * Unlike isInFrustum this cheks the full bounding box
  109367. * @param target The object to check
  109368. * @returns true if the object is in frustum otherwise false
  109369. */
  109370. isCompletelyInFrustum(target: ICullable): boolean;
  109371. /**
  109372. * Gets a ray in the forward direction from the camera.
  109373. * @param length Defines the length of the ray to create
  109374. * @param transform Defines the transform to apply to the ray, by default the world matrx is used to create a workd space ray
  109375. * @param origin Defines the start point of the ray which defaults to the camera position
  109376. * @returns the forward ray
  109377. */
  109378. getForwardRay(length?: number, transform?: Matrix, origin?: Vector3): Ray;
  109379. /**
  109380. * Gets a ray in the forward direction from the camera.
  109381. * @param refRay the ray to (re)use when setting the values
  109382. * @param length Defines the length of the ray to create
  109383. * @param transform Defines the transform to apply to the ray, by default the world matrx is used to create a workd space ray
  109384. * @param origin Defines the start point of the ray which defaults to the camera position
  109385. * @returns the forward ray
  109386. */
  109387. getForwardRayToRef(refRay: Ray, length?: number, transform?: Matrix, origin?: Vector3): Ray;
  109388. /**
  109389. * Releases resources associated with this node.
  109390. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  109391. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  109392. */
  109393. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  109394. /** @hidden */
  109395. _isLeftCamera: boolean;
  109396. /**
  109397. * Gets the left camera of a rig setup in case of Rigged Camera
  109398. */
  109399. get isLeftCamera(): boolean;
  109400. /** @hidden */
  109401. _isRightCamera: boolean;
  109402. /**
  109403. * Gets the right camera of a rig setup in case of Rigged Camera
  109404. */
  109405. get isRightCamera(): boolean;
  109406. /**
  109407. * Gets the left camera of a rig setup in case of Rigged Camera
  109408. */
  109409. get leftCamera(): Nullable<FreeCamera>;
  109410. /**
  109411. * Gets the right camera of a rig setup in case of Rigged Camera
  109412. */
  109413. get rightCamera(): Nullable<FreeCamera>;
  109414. /**
  109415. * Gets the left camera target of a rig setup in case of Rigged Camera
  109416. * @returns the target position
  109417. */
  109418. getLeftTarget(): Nullable<Vector3>;
  109419. /**
  109420. * Gets the right camera target of a rig setup in case of Rigged Camera
  109421. * @returns the target position
  109422. */
  109423. getRightTarget(): Nullable<Vector3>;
  109424. /**
  109425. * @hidden
  109426. */
  109427. setCameraRigMode(mode: number, rigParams: any): void;
  109428. /** @hidden */
  109429. static _setStereoscopicRigMode(camera: Camera): void;
  109430. /** @hidden */
  109431. static _setStereoscopicAnaglyphRigMode(camera: Camera): void;
  109432. /** @hidden */
  109433. static _setVRRigMode(camera: Camera, rigParams: any): void;
  109434. /** @hidden */
  109435. static _setWebVRRigMode(camera: Camera, rigParams: any): void;
  109436. /** @hidden */
  109437. _getVRProjectionMatrix(): Matrix;
  109438. protected _updateCameraRotationMatrix(): void;
  109439. protected _updateWebVRCameraRotationMatrix(): void;
  109440. /**
  109441. * This function MUST be overwritten by the different WebVR cameras available.
  109442. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  109443. * @hidden
  109444. */
  109445. _getWebVRProjectionMatrix(): Matrix;
  109446. /**
  109447. * This function MUST be overwritten by the different WebVR cameras available.
  109448. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  109449. * @hidden
  109450. */
  109451. _getWebVRViewMatrix(): Matrix;
  109452. /** @hidden */
  109453. setCameraRigParameter(name: string, value: any): void;
  109454. /**
  109455. * needs to be overridden by children so sub has required properties to be copied
  109456. * @hidden
  109457. */
  109458. createRigCamera(name: string, cameraIndex: number): Nullable<Camera>;
  109459. /**
  109460. * May need to be overridden by children
  109461. * @hidden
  109462. */
  109463. _updateRigCameras(): void;
  109464. /** @hidden */
  109465. _setupInputs(): void;
  109466. /**
  109467. * Serialiaze the camera setup to a json represention
  109468. * @returns the JSON representation
  109469. */
  109470. serialize(): any;
  109471. /**
  109472. * Clones the current camera.
  109473. * @param name The cloned camera name
  109474. * @returns the cloned camera
  109475. */
  109476. clone(name: string): Camera;
  109477. /**
  109478. * Gets the direction of the camera relative to a given local axis.
  109479. * @param localAxis Defines the reference axis to provide a relative direction.
  109480. * @return the direction
  109481. */
  109482. getDirection(localAxis: Vector3): Vector3;
  109483. /**
  109484. * Returns the current camera absolute rotation
  109485. */
  109486. get absoluteRotation(): Quaternion;
  109487. /**
  109488. * Gets the direction of the camera relative to a given local axis into a passed vector.
  109489. * @param localAxis Defines the reference axis to provide a relative direction.
  109490. * @param result Defines the vector to store the result in
  109491. */
  109492. getDirectionToRef(localAxis: Vector3, result: Vector3): void;
  109493. /**
  109494. * Gets a camera constructor for a given camera type
  109495. * @param type The type of the camera to construct (should be equal to one of the camera class name)
  109496. * @param name The name of the camera the result will be able to instantiate
  109497. * @param scene The scene the result will construct the camera in
  109498. * @param interaxial_distance In case of stereoscopic setup, the distance between both eyes
  109499. * @param isStereoscopicSideBySide In case of stereoscopic setup, should the sereo be side b side
  109500. * @returns a factory method to construc the camera
  109501. */
  109502. static GetConstructorFromName(type: string, name: string, scene: Scene, interaxial_distance?: number, isStereoscopicSideBySide?: boolean): () => Camera;
  109503. /**
  109504. * Compute the world matrix of the camera.
  109505. * @returns the camera world matrix
  109506. */
  109507. computeWorldMatrix(): Matrix;
  109508. /**
  109509. * Parse a JSON and creates the camera from the parsed information
  109510. * @param parsedCamera The JSON to parse
  109511. * @param scene The scene to instantiate the camera in
  109512. * @returns the newly constructed camera
  109513. */
  109514. static Parse(parsedCamera: any, scene: Scene): Camera;
  109515. }
  109516. }
  109517. declare module BABYLON {
  109518. /**
  109519. * Class containing static functions to help procedurally build meshes
  109520. */
  109521. export class DiscBuilder {
  109522. /**
  109523. * Creates a plane polygonal mesh. By default, this is a disc
  109524. * * The parameter `radius` sets the radius size (float) of the polygon (default 0.5)
  109525. * * 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
  109526. * * 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
  109527. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  109528. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  109529. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  109530. * @param name defines the name of the mesh
  109531. * @param options defines the options used to create the mesh
  109532. * @param scene defines the hosting scene
  109533. * @returns the plane polygonal mesh
  109534. * @see https://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  109535. */
  109536. static CreateDisc(name: string, options: {
  109537. radius?: number;
  109538. tessellation?: number;
  109539. arc?: number;
  109540. updatable?: boolean;
  109541. sideOrientation?: number;
  109542. frontUVs?: Vector4;
  109543. backUVs?: Vector4;
  109544. }, scene?: Nullable<Scene>): Mesh;
  109545. }
  109546. }
  109547. declare module BABYLON {
  109548. /**
  109549. * Options to be used when creating a FresnelParameters.
  109550. */
  109551. export type IFresnelParametersCreationOptions = {
  109552. /**
  109553. * Define the color used on edges (grazing angle)
  109554. */
  109555. leftColor?: Color3;
  109556. /**
  109557. * Define the color used on center
  109558. */
  109559. rightColor?: Color3;
  109560. /**
  109561. * Define bias applied to computed fresnel term
  109562. */
  109563. bias?: number;
  109564. /**
  109565. * Defined the power exponent applied to fresnel term
  109566. */
  109567. power?: number;
  109568. /**
  109569. * Define if the fresnel effect is enable or not.
  109570. */
  109571. isEnabled?: boolean;
  109572. };
  109573. /**
  109574. * Serialized format for FresnelParameters.
  109575. */
  109576. export type IFresnelParametersSerialized = {
  109577. /**
  109578. * Define the color used on edges (grazing angle) [as an array]
  109579. */
  109580. leftColor: number[];
  109581. /**
  109582. * Define the color used on center [as an array]
  109583. */
  109584. rightColor: number[];
  109585. /**
  109586. * Define bias applied to computed fresnel term
  109587. */
  109588. bias: number;
  109589. /**
  109590. * Defined the power exponent applied to fresnel term
  109591. */
  109592. power?: number;
  109593. /**
  109594. * Define if the fresnel effect is enable or not.
  109595. */
  109596. isEnabled: boolean;
  109597. };
  109598. /**
  109599. * This represents all the required information to add a fresnel effect on a material:
  109600. * @see https://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  109601. */
  109602. export class FresnelParameters {
  109603. private _isEnabled;
  109604. /**
  109605. * Define if the fresnel effect is enable or not.
  109606. */
  109607. get isEnabled(): boolean;
  109608. set isEnabled(value: boolean);
  109609. /**
  109610. * Define the color used on edges (grazing angle)
  109611. */
  109612. leftColor: Color3;
  109613. /**
  109614. * Define the color used on center
  109615. */
  109616. rightColor: Color3;
  109617. /**
  109618. * Define bias applied to computed fresnel term
  109619. */
  109620. bias: number;
  109621. /**
  109622. * Defined the power exponent applied to fresnel term
  109623. */
  109624. power: number;
  109625. /**
  109626. * Creates a new FresnelParameters object.
  109627. *
  109628. * @param options provide your own settings to optionally to override defaults
  109629. */
  109630. constructor(options?: IFresnelParametersCreationOptions);
  109631. /**
  109632. * Clones the current fresnel and its valuues
  109633. * @returns a clone fresnel configuration
  109634. */
  109635. clone(): FresnelParameters;
  109636. /**
  109637. * Determines equality between FresnelParameters objects
  109638. * @param otherFresnelParameters defines the second operand
  109639. * @returns true if the power, bias, leftColor, rightColor and isEnabled values are equal to the given ones
  109640. */
  109641. equals(otherFresnelParameters: DeepImmutable<FresnelParameters>): boolean;
  109642. /**
  109643. * Serializes the current fresnel parameters to a JSON representation.
  109644. * @return the JSON serialization
  109645. */
  109646. serialize(): IFresnelParametersSerialized;
  109647. /**
  109648. * Parse a JSON object and deserialize it to a new Fresnel parameter object.
  109649. * @param parsedFresnelParameters Define the JSON representation
  109650. * @returns the parsed parameters
  109651. */
  109652. static Parse(parsedFresnelParameters: IFresnelParametersSerialized): FresnelParameters;
  109653. }
  109654. }
  109655. declare module BABYLON {
  109656. /**
  109657. * This groups all the flags used to control the materials channel.
  109658. */
  109659. export class MaterialFlags {
  109660. private static _DiffuseTextureEnabled;
  109661. /**
  109662. * Are diffuse textures enabled in the application.
  109663. */
  109664. static get DiffuseTextureEnabled(): boolean;
  109665. static set DiffuseTextureEnabled(value: boolean);
  109666. private static _DetailTextureEnabled;
  109667. /**
  109668. * Are detail textures enabled in the application.
  109669. */
  109670. static get DetailTextureEnabled(): boolean;
  109671. static set DetailTextureEnabled(value: boolean);
  109672. private static _AmbientTextureEnabled;
  109673. /**
  109674. * Are ambient textures enabled in the application.
  109675. */
  109676. static get AmbientTextureEnabled(): boolean;
  109677. static set AmbientTextureEnabled(value: boolean);
  109678. private static _OpacityTextureEnabled;
  109679. /**
  109680. * Are opacity textures enabled in the application.
  109681. */
  109682. static get OpacityTextureEnabled(): boolean;
  109683. static set OpacityTextureEnabled(value: boolean);
  109684. private static _ReflectionTextureEnabled;
  109685. /**
  109686. * Are reflection textures enabled in the application.
  109687. */
  109688. static get ReflectionTextureEnabled(): boolean;
  109689. static set ReflectionTextureEnabled(value: boolean);
  109690. private static _EmissiveTextureEnabled;
  109691. /**
  109692. * Are emissive textures enabled in the application.
  109693. */
  109694. static get EmissiveTextureEnabled(): boolean;
  109695. static set EmissiveTextureEnabled(value: boolean);
  109696. private static _SpecularTextureEnabled;
  109697. /**
  109698. * Are specular textures enabled in the application.
  109699. */
  109700. static get SpecularTextureEnabled(): boolean;
  109701. static set SpecularTextureEnabled(value: boolean);
  109702. private static _BumpTextureEnabled;
  109703. /**
  109704. * Are bump textures enabled in the application.
  109705. */
  109706. static get BumpTextureEnabled(): boolean;
  109707. static set BumpTextureEnabled(value: boolean);
  109708. private static _LightmapTextureEnabled;
  109709. /**
  109710. * Are lightmap textures enabled in the application.
  109711. */
  109712. static get LightmapTextureEnabled(): boolean;
  109713. static set LightmapTextureEnabled(value: boolean);
  109714. private static _RefractionTextureEnabled;
  109715. /**
  109716. * Are refraction textures enabled in the application.
  109717. */
  109718. static get RefractionTextureEnabled(): boolean;
  109719. static set RefractionTextureEnabled(value: boolean);
  109720. private static _ColorGradingTextureEnabled;
  109721. /**
  109722. * Are color grading textures enabled in the application.
  109723. */
  109724. static get ColorGradingTextureEnabled(): boolean;
  109725. static set ColorGradingTextureEnabled(value: boolean);
  109726. private static _FresnelEnabled;
  109727. /**
  109728. * Are fresnels enabled in the application.
  109729. */
  109730. static get FresnelEnabled(): boolean;
  109731. static set FresnelEnabled(value: boolean);
  109732. private static _ClearCoatTextureEnabled;
  109733. /**
  109734. * Are clear coat textures enabled in the application.
  109735. */
  109736. static get ClearCoatTextureEnabled(): boolean;
  109737. static set ClearCoatTextureEnabled(value: boolean);
  109738. private static _ClearCoatBumpTextureEnabled;
  109739. /**
  109740. * Are clear coat bump textures enabled in the application.
  109741. */
  109742. static get ClearCoatBumpTextureEnabled(): boolean;
  109743. static set ClearCoatBumpTextureEnabled(value: boolean);
  109744. private static _ClearCoatTintTextureEnabled;
  109745. /**
  109746. * Are clear coat tint textures enabled in the application.
  109747. */
  109748. static get ClearCoatTintTextureEnabled(): boolean;
  109749. static set ClearCoatTintTextureEnabled(value: boolean);
  109750. private static _SheenTextureEnabled;
  109751. /**
  109752. * Are sheen textures enabled in the application.
  109753. */
  109754. static get SheenTextureEnabled(): boolean;
  109755. static set SheenTextureEnabled(value: boolean);
  109756. private static _AnisotropicTextureEnabled;
  109757. /**
  109758. * Are anisotropic textures enabled in the application.
  109759. */
  109760. static get AnisotropicTextureEnabled(): boolean;
  109761. static set AnisotropicTextureEnabled(value: boolean);
  109762. private static _ThicknessTextureEnabled;
  109763. /**
  109764. * Are thickness textures enabled in the application.
  109765. */
  109766. static get ThicknessTextureEnabled(): boolean;
  109767. static set ThicknessTextureEnabled(value: boolean);
  109768. }
  109769. }
  109770. declare module BABYLON {
  109771. /** @hidden */
  109772. export var defaultFragmentDeclaration: {
  109773. name: string;
  109774. shader: string;
  109775. };
  109776. }
  109777. declare module BABYLON {
  109778. /** @hidden */
  109779. export var defaultUboDeclaration: {
  109780. name: string;
  109781. shader: string;
  109782. };
  109783. }
  109784. declare module BABYLON {
  109785. /** @hidden */
  109786. export var prePassDeclaration: {
  109787. name: string;
  109788. shader: string;
  109789. };
  109790. }
  109791. declare module BABYLON {
  109792. /** @hidden */
  109793. export var lightFragmentDeclaration: {
  109794. name: string;
  109795. shader: string;
  109796. };
  109797. }
  109798. declare module BABYLON {
  109799. /** @hidden */
  109800. export var lightUboDeclaration: {
  109801. name: string;
  109802. shader: string;
  109803. };
  109804. }
  109805. declare module BABYLON {
  109806. /** @hidden */
  109807. export var lightsFragmentFunctions: {
  109808. name: string;
  109809. shader: string;
  109810. };
  109811. }
  109812. declare module BABYLON {
  109813. /** @hidden */
  109814. export var shadowsFragmentFunctions: {
  109815. name: string;
  109816. shader: string;
  109817. };
  109818. }
  109819. declare module BABYLON {
  109820. /** @hidden */
  109821. export var fresnelFunction: {
  109822. name: string;
  109823. shader: string;
  109824. };
  109825. }
  109826. declare module BABYLON {
  109827. /** @hidden */
  109828. export var bumpFragmentMainFunctions: {
  109829. name: string;
  109830. shader: string;
  109831. };
  109832. }
  109833. declare module BABYLON {
  109834. /** @hidden */
  109835. export var bumpFragmentFunctions: {
  109836. name: string;
  109837. shader: string;
  109838. };
  109839. }
  109840. declare module BABYLON {
  109841. /** @hidden */
  109842. export var logDepthDeclaration: {
  109843. name: string;
  109844. shader: string;
  109845. };
  109846. }
  109847. declare module BABYLON {
  109848. /** @hidden */
  109849. export var bumpFragment: {
  109850. name: string;
  109851. shader: string;
  109852. };
  109853. }
  109854. declare module BABYLON {
  109855. /** @hidden */
  109856. export var depthPrePass: {
  109857. name: string;
  109858. shader: string;
  109859. };
  109860. }
  109861. declare module BABYLON {
  109862. /** @hidden */
  109863. export var lightFragment: {
  109864. name: string;
  109865. shader: string;
  109866. };
  109867. }
  109868. declare module BABYLON {
  109869. /** @hidden */
  109870. export var logDepthFragment: {
  109871. name: string;
  109872. shader: string;
  109873. };
  109874. }
  109875. declare module BABYLON {
  109876. /** @hidden */
  109877. export var defaultPixelShader: {
  109878. name: string;
  109879. shader: string;
  109880. };
  109881. }
  109882. declare module BABYLON {
  109883. /** @hidden */
  109884. export var defaultVertexDeclaration: {
  109885. name: string;
  109886. shader: string;
  109887. };
  109888. }
  109889. declare module BABYLON {
  109890. /** @hidden */
  109891. export var bumpVertexDeclaration: {
  109892. name: string;
  109893. shader: string;
  109894. };
  109895. }
  109896. declare module BABYLON {
  109897. /** @hidden */
  109898. export var bumpVertex: {
  109899. name: string;
  109900. shader: string;
  109901. };
  109902. }
  109903. declare module BABYLON {
  109904. /** @hidden */
  109905. export var fogVertex: {
  109906. name: string;
  109907. shader: string;
  109908. };
  109909. }
  109910. declare module BABYLON {
  109911. /** @hidden */
  109912. export var shadowsVertex: {
  109913. name: string;
  109914. shader: string;
  109915. };
  109916. }
  109917. declare module BABYLON {
  109918. /** @hidden */
  109919. export var pointCloudVertex: {
  109920. name: string;
  109921. shader: string;
  109922. };
  109923. }
  109924. declare module BABYLON {
  109925. /** @hidden */
  109926. export var logDepthVertex: {
  109927. name: string;
  109928. shader: string;
  109929. };
  109930. }
  109931. declare module BABYLON {
  109932. /** @hidden */
  109933. export var defaultVertexShader: {
  109934. name: string;
  109935. shader: string;
  109936. };
  109937. }
  109938. declare module BABYLON {
  109939. /**
  109940. * @hidden
  109941. */
  109942. export interface IMaterialDetailMapDefines {
  109943. DETAIL: boolean;
  109944. DETAILDIRECTUV: number;
  109945. DETAIL_NORMALBLENDMETHOD: number;
  109946. /** @hidden */
  109947. _areTexturesDirty: boolean;
  109948. }
  109949. /**
  109950. * Define the code related to the detail map parameters of a material
  109951. *
  109952. * Inspired from:
  109953. * 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
  109954. * Unreal: https://docs.unrealengine.com/en-US/Engine/Rendering/Materials/HowTo/DetailTexturing/index.html
  109955. * Cryengine: https://docs.cryengine.com/display/SDKDOC2/Detail+Maps
  109956. */
  109957. export class DetailMapConfiguration {
  109958. private _texture;
  109959. /**
  109960. * The detail texture of the material.
  109961. */
  109962. texture: Nullable<BaseTexture>;
  109963. /**
  109964. * Defines how strongly the detail diffuse/albedo channel is blended with the regular diffuse/albedo texture
  109965. * Bigger values mean stronger blending
  109966. */
  109967. diffuseBlendLevel: number;
  109968. /**
  109969. * Defines how strongly the detail roughness channel is blended with the regular roughness value
  109970. * Bigger values mean stronger blending. Only used with PBR materials
  109971. */
  109972. roughnessBlendLevel: number;
  109973. /**
  109974. * Defines how strong the bump effect from the detail map is
  109975. * Bigger values mean stronger effect
  109976. */
  109977. bumpLevel: number;
  109978. private _normalBlendMethod;
  109979. /**
  109980. * The method used to blend the bump and detail normals together
  109981. */
  109982. normalBlendMethod: number;
  109983. private _isEnabled;
  109984. /**
  109985. * Enable or disable the detail map on this material
  109986. */
  109987. isEnabled: boolean;
  109988. /** @hidden */
  109989. private _internalMarkAllSubMeshesAsTexturesDirty;
  109990. /** @hidden */
  109991. _markAllSubMeshesAsTexturesDirty(): void;
  109992. /**
  109993. * Instantiate a new detail map
  109994. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  109995. */
  109996. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  109997. /**
  109998. * Gets whether the submesh is ready to be used or not.
  109999. * @param defines the list of "defines" to update.
  110000. * @param scene defines the scene the material belongs to.
  110001. * @returns - boolean indicating that the submesh is ready or not.
  110002. */
  110003. isReadyForSubMesh(defines: IMaterialDetailMapDefines, scene: Scene): boolean;
  110004. /**
  110005. * Update the defines for detail map usage
  110006. * @param defines the list of "defines" to update.
  110007. * @param scene defines the scene the material belongs to.
  110008. */
  110009. prepareDefines(defines: IMaterialDetailMapDefines, scene: Scene): void;
  110010. /**
  110011. * Binds the material data.
  110012. * @param uniformBuffer defines the Uniform buffer to fill in.
  110013. * @param scene defines the scene the material belongs to.
  110014. * @param isFrozen defines whether the material is frozen or not.
  110015. */
  110016. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean): void;
  110017. /**
  110018. * Checks to see if a texture is used in the material.
  110019. * @param texture - Base texture to use.
  110020. * @returns - Boolean specifying if a texture is used in the material.
  110021. */
  110022. hasTexture(texture: BaseTexture): boolean;
  110023. /**
  110024. * Returns an array of the actively used textures.
  110025. * @param activeTextures Array of BaseTextures
  110026. */
  110027. getActiveTextures(activeTextures: BaseTexture[]): void;
  110028. /**
  110029. * Returns the animatable textures.
  110030. * @param animatables Array of animatable textures.
  110031. */
  110032. getAnimatables(animatables: IAnimatable[]): void;
  110033. /**
  110034. * Disposes the resources of the material.
  110035. * @param forceDisposeTextures - Forces the disposal of all textures.
  110036. */
  110037. dispose(forceDisposeTextures?: boolean): void;
  110038. /**
  110039. * Get the current class name useful for serialization or dynamic coding.
  110040. * @returns "DetailMap"
  110041. */
  110042. getClassName(): string;
  110043. /**
  110044. * Add the required uniforms to the current list.
  110045. * @param uniforms defines the current uniform list.
  110046. */
  110047. static AddUniforms(uniforms: string[]): void;
  110048. /**
  110049. * Add the required samplers to the current list.
  110050. * @param samplers defines the current sampler list.
  110051. */
  110052. static AddSamplers(samplers: string[]): void;
  110053. /**
  110054. * Add the required uniforms to the current buffer.
  110055. * @param uniformBuffer defines the current uniform buffer.
  110056. */
  110057. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  110058. /**
  110059. * Makes a duplicate of the current instance into another one.
  110060. * @param detailMap define the instance where to copy the info
  110061. */
  110062. copyTo(detailMap: DetailMapConfiguration): void;
  110063. /**
  110064. * Serializes this detail map instance
  110065. * @returns - An object with the serialized instance.
  110066. */
  110067. serialize(): any;
  110068. /**
  110069. * Parses a detail map setting from a serialized object.
  110070. * @param source - Serialized object.
  110071. * @param scene Defines the scene we are parsing for
  110072. * @param rootUrl Defines the rootUrl to load from
  110073. */
  110074. parse(source: any, scene: Scene, rootUrl: string): void;
  110075. }
  110076. }
  110077. declare module BABYLON {
  110078. /** @hidden */
  110079. export class StandardMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines, IMaterialDetailMapDefines {
  110080. MAINUV1: boolean;
  110081. MAINUV2: boolean;
  110082. DIFFUSE: boolean;
  110083. DIFFUSEDIRECTUV: number;
  110084. DETAIL: boolean;
  110085. DETAILDIRECTUV: number;
  110086. DETAIL_NORMALBLENDMETHOD: number;
  110087. AMBIENT: boolean;
  110088. AMBIENTDIRECTUV: number;
  110089. OPACITY: boolean;
  110090. OPACITYDIRECTUV: number;
  110091. OPACITYRGB: boolean;
  110092. REFLECTION: boolean;
  110093. EMISSIVE: boolean;
  110094. EMISSIVEDIRECTUV: number;
  110095. SPECULAR: boolean;
  110096. SPECULARDIRECTUV: number;
  110097. BUMP: boolean;
  110098. BUMPDIRECTUV: number;
  110099. PARALLAX: boolean;
  110100. PARALLAXOCCLUSION: boolean;
  110101. SPECULAROVERALPHA: boolean;
  110102. CLIPPLANE: boolean;
  110103. CLIPPLANE2: boolean;
  110104. CLIPPLANE3: boolean;
  110105. CLIPPLANE4: boolean;
  110106. CLIPPLANE5: boolean;
  110107. CLIPPLANE6: boolean;
  110108. ALPHATEST: boolean;
  110109. DEPTHPREPASS: boolean;
  110110. ALPHAFROMDIFFUSE: boolean;
  110111. POINTSIZE: boolean;
  110112. FOG: boolean;
  110113. SPECULARTERM: boolean;
  110114. DIFFUSEFRESNEL: boolean;
  110115. OPACITYFRESNEL: boolean;
  110116. REFLECTIONFRESNEL: boolean;
  110117. REFRACTIONFRESNEL: boolean;
  110118. EMISSIVEFRESNEL: boolean;
  110119. FRESNEL: boolean;
  110120. NORMAL: boolean;
  110121. UV1: boolean;
  110122. UV2: boolean;
  110123. VERTEXCOLOR: boolean;
  110124. VERTEXALPHA: boolean;
  110125. NUM_BONE_INFLUENCERS: number;
  110126. BonesPerMesh: number;
  110127. BONETEXTURE: boolean;
  110128. INSTANCES: boolean;
  110129. THIN_INSTANCES: boolean;
  110130. GLOSSINESS: boolean;
  110131. ROUGHNESS: boolean;
  110132. EMISSIVEASILLUMINATION: boolean;
  110133. LINKEMISSIVEWITHDIFFUSE: boolean;
  110134. REFLECTIONFRESNELFROMSPECULAR: boolean;
  110135. LIGHTMAP: boolean;
  110136. LIGHTMAPDIRECTUV: number;
  110137. OBJECTSPACE_NORMALMAP: boolean;
  110138. USELIGHTMAPASSHADOWMAP: boolean;
  110139. REFLECTIONMAP_3D: boolean;
  110140. REFLECTIONMAP_SPHERICAL: boolean;
  110141. REFLECTIONMAP_PLANAR: boolean;
  110142. REFLECTIONMAP_CUBIC: boolean;
  110143. USE_LOCAL_REFLECTIONMAP_CUBIC: boolean;
  110144. REFLECTIONMAP_PROJECTION: boolean;
  110145. REFLECTIONMAP_SKYBOX: boolean;
  110146. REFLECTIONMAP_EXPLICIT: boolean;
  110147. REFLECTIONMAP_EQUIRECTANGULAR: boolean;
  110148. REFLECTIONMAP_EQUIRECTANGULAR_FIXED: boolean;
  110149. REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED: boolean;
  110150. INVERTCUBICMAP: boolean;
  110151. LOGARITHMICDEPTH: boolean;
  110152. REFRACTION: boolean;
  110153. REFRACTIONMAP_3D: boolean;
  110154. REFLECTIONOVERALPHA: boolean;
  110155. TWOSIDEDLIGHTING: boolean;
  110156. SHADOWFLOAT: boolean;
  110157. MORPHTARGETS: boolean;
  110158. MORPHTARGETS_NORMAL: boolean;
  110159. MORPHTARGETS_TANGENT: boolean;
  110160. MORPHTARGETS_UV: boolean;
  110161. NUM_MORPH_INFLUENCERS: number;
  110162. NONUNIFORMSCALING: boolean;
  110163. PREMULTIPLYALPHA: boolean;
  110164. ALPHATEST_AFTERALLALPHACOMPUTATIONS: boolean;
  110165. ALPHABLEND: boolean;
  110166. PREPASS: boolean;
  110167. SCENE_MRT_COUNT: number;
  110168. RGBDLIGHTMAP: boolean;
  110169. RGBDREFLECTION: boolean;
  110170. RGBDREFRACTION: boolean;
  110171. IMAGEPROCESSING: boolean;
  110172. VIGNETTE: boolean;
  110173. VIGNETTEBLENDMODEMULTIPLY: boolean;
  110174. VIGNETTEBLENDMODEOPAQUE: boolean;
  110175. TONEMAPPING: boolean;
  110176. TONEMAPPING_ACES: boolean;
  110177. CONTRAST: boolean;
  110178. COLORCURVES: boolean;
  110179. COLORGRADING: boolean;
  110180. COLORGRADING3D: boolean;
  110181. SAMPLER3DGREENDEPTH: boolean;
  110182. SAMPLER3DBGRMAP: boolean;
  110183. IMAGEPROCESSINGPOSTPROCESS: boolean;
  110184. MULTIVIEW: boolean;
  110185. /**
  110186. * If the reflection texture on this material is in linear color space
  110187. * @hidden
  110188. */
  110189. IS_REFLECTION_LINEAR: boolean;
  110190. /**
  110191. * If the refraction texture on this material is in linear color space
  110192. * @hidden
  110193. */
  110194. IS_REFRACTION_LINEAR: boolean;
  110195. EXPOSURE: boolean;
  110196. constructor();
  110197. setReflectionMode(modeToEnable: string): void;
  110198. }
  110199. /**
  110200. * This is the default material used in Babylon. It is the best trade off between quality
  110201. * and performances.
  110202. * @see https://doc.babylonjs.com/babylon101/materials
  110203. */
  110204. export class StandardMaterial extends PushMaterial {
  110205. private _diffuseTexture;
  110206. /**
  110207. * The basic texture of the material as viewed under a light.
  110208. */
  110209. diffuseTexture: Nullable<BaseTexture>;
  110210. private _ambientTexture;
  110211. /**
  110212. * AKA Occlusion Texture in other nomenclature, it helps adding baked shadows into your material.
  110213. */
  110214. ambientTexture: Nullable<BaseTexture>;
  110215. private _opacityTexture;
  110216. /**
  110217. * Define the transparency of the material from a texture.
  110218. * The final alpha value can be read either from the red channel (if texture.getAlphaFromRGB is false)
  110219. * or from the luminance or the current texel (if texture.getAlphaFromRGB is true)
  110220. */
  110221. opacityTexture: Nullable<BaseTexture>;
  110222. private _reflectionTexture;
  110223. /**
  110224. * Define the texture used to display the reflection.
  110225. * @see https://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  110226. */
  110227. reflectionTexture: Nullable<BaseTexture>;
  110228. private _emissiveTexture;
  110229. /**
  110230. * Define texture of the material as if self lit.
  110231. * This will be mixed in the final result even in the absence of light.
  110232. */
  110233. emissiveTexture: Nullable<BaseTexture>;
  110234. private _specularTexture;
  110235. /**
  110236. * Define how the color and intensity of the highlight given by the light in the material.
  110237. */
  110238. specularTexture: Nullable<BaseTexture>;
  110239. private _bumpTexture;
  110240. /**
  110241. * Bump mapping is a technique to simulate bump and dents on a rendered surface.
  110242. * 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.
  110243. * @see https://doc.babylonjs.com/how_to/more_materials#bump-map
  110244. */
  110245. bumpTexture: Nullable<BaseTexture>;
  110246. private _lightmapTexture;
  110247. /**
  110248. * Complex lighting can be computationally expensive to compute at runtime.
  110249. * To save on computation, lightmaps may be used to store calculated lighting in a texture which will be applied to a given mesh.
  110250. * @see https://doc.babylonjs.com/babylon101/lights#lightmaps
  110251. */
  110252. lightmapTexture: Nullable<BaseTexture>;
  110253. private _refractionTexture;
  110254. /**
  110255. * Define the texture used to display the refraction.
  110256. * @see https://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  110257. */
  110258. refractionTexture: Nullable<BaseTexture>;
  110259. /**
  110260. * The color of the material lit by the environmental background lighting.
  110261. * @see https://doc.babylonjs.com/babylon101/materials#ambient-color-example
  110262. */
  110263. ambientColor: Color3;
  110264. /**
  110265. * The basic color of the material as viewed under a light.
  110266. */
  110267. diffuseColor: Color3;
  110268. /**
  110269. * Define how the color and intensity of the highlight given by the light in the material.
  110270. */
  110271. specularColor: Color3;
  110272. /**
  110273. * Define the color of the material as if self lit.
  110274. * This will be mixed in the final result even in the absence of light.
  110275. */
  110276. emissiveColor: Color3;
  110277. /**
  110278. * Defines how sharp are the highlights in the material.
  110279. * The bigger the value the sharper giving a more glossy feeling to the result.
  110280. * Reversely, the smaller the value the blurrier giving a more rough feeling to the result.
  110281. */
  110282. specularPower: number;
  110283. private _useAlphaFromDiffuseTexture;
  110284. /**
  110285. * Does the transparency come from the diffuse texture alpha channel.
  110286. */
  110287. useAlphaFromDiffuseTexture: boolean;
  110288. private _useEmissiveAsIllumination;
  110289. /**
  110290. * If true, the emissive value is added into the end result, otherwise it is multiplied in.
  110291. */
  110292. useEmissiveAsIllumination: boolean;
  110293. private _linkEmissiveWithDiffuse;
  110294. /**
  110295. * If true, some kind of energy conservation will prevent the end result to be more than 1 by reducing
  110296. * the emissive level when the final color is close to one.
  110297. */
  110298. linkEmissiveWithDiffuse: boolean;
  110299. private _useSpecularOverAlpha;
  110300. /**
  110301. * Specifies that the material will keep the specular highlights over a transparent surface (only the most limunous ones).
  110302. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  110303. */
  110304. useSpecularOverAlpha: boolean;
  110305. private _useReflectionOverAlpha;
  110306. /**
  110307. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  110308. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  110309. */
  110310. useReflectionOverAlpha: boolean;
  110311. private _disableLighting;
  110312. /**
  110313. * Does lights from the scene impacts this material.
  110314. * It can be a nice trick for performance to disable lighting on a fully emissive material.
  110315. */
  110316. disableLighting: boolean;
  110317. private _useObjectSpaceNormalMap;
  110318. /**
  110319. * Allows using an object space normal map (instead of tangent space).
  110320. */
  110321. useObjectSpaceNormalMap: boolean;
  110322. private _useParallax;
  110323. /**
  110324. * Is parallax enabled or not.
  110325. * @see https://doc.babylonjs.com/how_to/using_parallax_mapping
  110326. */
  110327. useParallax: boolean;
  110328. private _useParallaxOcclusion;
  110329. /**
  110330. * Is parallax occlusion enabled or not.
  110331. * If true, the outcome is way more realistic than traditional Parallax but you can expect a performance hit that worthes consideration.
  110332. * @see https://doc.babylonjs.com/how_to/using_parallax_mapping
  110333. */
  110334. useParallaxOcclusion: boolean;
  110335. /**
  110336. * 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.
  110337. */
  110338. parallaxScaleBias: number;
  110339. private _roughness;
  110340. /**
  110341. * Helps to define how blurry the reflections should appears in the material.
  110342. */
  110343. roughness: number;
  110344. /**
  110345. * In case of refraction, define the value of the index of refraction.
  110346. * @see https://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  110347. */
  110348. indexOfRefraction: number;
  110349. /**
  110350. * Invert the refraction texture alongside the y axis.
  110351. * It can be useful with procedural textures or probe for instance.
  110352. * @see https://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  110353. */
  110354. invertRefractionY: boolean;
  110355. /**
  110356. * Defines the alpha limits in alpha test mode.
  110357. */
  110358. alphaCutOff: number;
  110359. private _useLightmapAsShadowmap;
  110360. /**
  110361. * In case of light mapping, define whether the map contains light or shadow informations.
  110362. */
  110363. useLightmapAsShadowmap: boolean;
  110364. private _diffuseFresnelParameters;
  110365. /**
  110366. * Define the diffuse fresnel parameters of the material.
  110367. * @see https://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  110368. */
  110369. diffuseFresnelParameters: FresnelParameters;
  110370. private _opacityFresnelParameters;
  110371. /**
  110372. * Define the opacity fresnel parameters of the material.
  110373. * @see https://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  110374. */
  110375. opacityFresnelParameters: FresnelParameters;
  110376. private _reflectionFresnelParameters;
  110377. /**
  110378. * Define the reflection fresnel parameters of the material.
  110379. * @see https://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  110380. */
  110381. reflectionFresnelParameters: FresnelParameters;
  110382. private _refractionFresnelParameters;
  110383. /**
  110384. * Define the refraction fresnel parameters of the material.
  110385. * @see https://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  110386. */
  110387. refractionFresnelParameters: FresnelParameters;
  110388. private _emissiveFresnelParameters;
  110389. /**
  110390. * Define the emissive fresnel parameters of the material.
  110391. * @see https://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  110392. */
  110393. emissiveFresnelParameters: FresnelParameters;
  110394. private _useReflectionFresnelFromSpecular;
  110395. /**
  110396. * If true automatically deducts the fresnels values from the material specularity.
  110397. * @see https://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  110398. */
  110399. useReflectionFresnelFromSpecular: boolean;
  110400. private _useGlossinessFromSpecularMapAlpha;
  110401. /**
  110402. * Defines if the glossiness/roughness of the material should be read from the specular map alpha channel
  110403. */
  110404. useGlossinessFromSpecularMapAlpha: boolean;
  110405. private _maxSimultaneousLights;
  110406. /**
  110407. * Defines the maximum number of lights that can be used in the material
  110408. */
  110409. maxSimultaneousLights: number;
  110410. private _invertNormalMapX;
  110411. /**
  110412. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  110413. */
  110414. invertNormalMapX: boolean;
  110415. private _invertNormalMapY;
  110416. /**
  110417. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  110418. */
  110419. invertNormalMapY: boolean;
  110420. private _twoSidedLighting;
  110421. /**
  110422. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  110423. */
  110424. twoSidedLighting: boolean;
  110425. /**
  110426. * Default configuration related to image processing available in the standard Material.
  110427. */
  110428. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  110429. /**
  110430. * Gets the image processing configuration used either in this material.
  110431. */
  110432. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  110433. /**
  110434. * Sets the Default image processing configuration used either in the this material.
  110435. *
  110436. * If sets to null, the scene one is in use.
  110437. */
  110438. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  110439. /**
  110440. * Keep track of the image processing observer to allow dispose and replace.
  110441. */
  110442. private _imageProcessingObserver;
  110443. /**
  110444. * Attaches a new image processing configuration to the Standard Material.
  110445. * @param configuration
  110446. */
  110447. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  110448. /**
  110449. * Gets wether the color curves effect is enabled.
  110450. */
  110451. get cameraColorCurvesEnabled(): boolean;
  110452. /**
  110453. * Sets wether the color curves effect is enabled.
  110454. */
  110455. set cameraColorCurvesEnabled(value: boolean);
  110456. /**
  110457. * Gets wether the color grading effect is enabled.
  110458. */
  110459. get cameraColorGradingEnabled(): boolean;
  110460. /**
  110461. * Gets wether the color grading effect is enabled.
  110462. */
  110463. set cameraColorGradingEnabled(value: boolean);
  110464. /**
  110465. * Gets wether tonemapping is enabled or not.
  110466. */
  110467. get cameraToneMappingEnabled(): boolean;
  110468. /**
  110469. * Sets wether tonemapping is enabled or not
  110470. */
  110471. set cameraToneMappingEnabled(value: boolean);
  110472. /**
  110473. * The camera exposure used on this material.
  110474. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  110475. * This corresponds to a photographic exposure.
  110476. */
  110477. get cameraExposure(): number;
  110478. /**
  110479. * The camera exposure used on this material.
  110480. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  110481. * This corresponds to a photographic exposure.
  110482. */
  110483. set cameraExposure(value: number);
  110484. /**
  110485. * Gets The camera contrast used on this material.
  110486. */
  110487. get cameraContrast(): number;
  110488. /**
  110489. * Sets The camera contrast used on this material.
  110490. */
  110491. set cameraContrast(value: number);
  110492. /**
  110493. * Gets the Color Grading 2D Lookup Texture.
  110494. */
  110495. get cameraColorGradingTexture(): Nullable<BaseTexture>;
  110496. /**
  110497. * Sets the Color Grading 2D Lookup Texture.
  110498. */
  110499. set cameraColorGradingTexture(value: Nullable<BaseTexture>);
  110500. /**
  110501. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  110502. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  110503. * 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;
  110504. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  110505. */
  110506. get cameraColorCurves(): Nullable<ColorCurves>;
  110507. /**
  110508. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  110509. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  110510. * 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;
  110511. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  110512. */
  110513. set cameraColorCurves(value: Nullable<ColorCurves>);
  110514. /**
  110515. * Can this material render to several textures at once
  110516. */
  110517. get canRenderToMRT(): boolean;
  110518. /**
  110519. * Defines the detail map parameters for the material.
  110520. */
  110521. readonly detailMap: DetailMapConfiguration;
  110522. protected _renderTargets: SmartArray<RenderTargetTexture>;
  110523. protected _worldViewProjectionMatrix: Matrix;
  110524. protected _globalAmbientColor: Color3;
  110525. protected _useLogarithmicDepth: boolean;
  110526. protected _rebuildInParallel: boolean;
  110527. /**
  110528. * Instantiates a new standard material.
  110529. * This is the default material used in Babylon. It is the best trade off between quality
  110530. * and performances.
  110531. * @see https://doc.babylonjs.com/babylon101/materials
  110532. * @param name Define the name of the material in the scene
  110533. * @param scene Define the scene the material belong to
  110534. */
  110535. constructor(name: string, scene: Scene);
  110536. /**
  110537. * Gets a boolean indicating that current material needs to register RTT
  110538. */
  110539. get hasRenderTargetTextures(): boolean;
  110540. /**
  110541. * Gets the current class name of the material e.g. "StandardMaterial"
  110542. * Mainly use in serialization.
  110543. * @returns the class name
  110544. */
  110545. getClassName(): string;
  110546. /**
  110547. * In case the depth buffer does not allow enough depth precision for your scene (might be the case in large scenes)
  110548. * You can try switching to logarithmic depth.
  110549. * @see https://doc.babylonjs.com/how_to/using_logarithmic_depth_buffer
  110550. */
  110551. get useLogarithmicDepth(): boolean;
  110552. set useLogarithmicDepth(value: boolean);
  110553. /**
  110554. * Specifies if the material will require alpha blending
  110555. * @returns a boolean specifying if alpha blending is needed
  110556. */
  110557. needAlphaBlending(): boolean;
  110558. /**
  110559. * Specifies if this material should be rendered in alpha test mode
  110560. * @returns a boolean specifying if an alpha test is needed.
  110561. */
  110562. needAlphaTesting(): boolean;
  110563. protected _shouldUseAlphaFromDiffuseTexture(): boolean;
  110564. /**
  110565. * Get the texture used for alpha test purpose.
  110566. * @returns the diffuse texture in case of the standard material.
  110567. */
  110568. getAlphaTestTexture(): Nullable<BaseTexture>;
  110569. /**
  110570. * Get if the submesh is ready to be used and all its information available.
  110571. * Child classes can use it to update shaders
  110572. * @param mesh defines the mesh to check
  110573. * @param subMesh defines which submesh to check
  110574. * @param useInstances specifies that instances should be used
  110575. * @returns a boolean indicating that the submesh is ready or not
  110576. */
  110577. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  110578. /**
  110579. * Builds the material UBO layouts.
  110580. * Used internally during the effect preparation.
  110581. */
  110582. buildUniformLayout(): void;
  110583. /**
  110584. * Unbinds the material from the mesh
  110585. */
  110586. unbind(): void;
  110587. /**
  110588. * Binds the submesh to this material by preparing the effect and shader to draw
  110589. * @param world defines the world transformation matrix
  110590. * @param mesh defines the mesh containing the submesh
  110591. * @param subMesh defines the submesh to bind the material to
  110592. */
  110593. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  110594. /**
  110595. * Get the list of animatables in the material.
  110596. * @returns the list of animatables object used in the material
  110597. */
  110598. getAnimatables(): IAnimatable[];
  110599. /**
  110600. * Gets the active textures from the material
  110601. * @returns an array of textures
  110602. */
  110603. getActiveTextures(): BaseTexture[];
  110604. /**
  110605. * Specifies if the material uses a texture
  110606. * @param texture defines the texture to check against the material
  110607. * @returns a boolean specifying if the material uses the texture
  110608. */
  110609. hasTexture(texture: BaseTexture): boolean;
  110610. /**
  110611. * Disposes the material
  110612. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  110613. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  110614. */
  110615. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  110616. /**
  110617. * Makes a duplicate of the material, and gives it a new name
  110618. * @param name defines the new name for the duplicated material
  110619. * @returns the cloned material
  110620. */
  110621. clone(name: string): StandardMaterial;
  110622. /**
  110623. * Serializes this material in a JSON representation
  110624. * @returns the serialized material object
  110625. */
  110626. serialize(): any;
  110627. /**
  110628. * Creates a standard material from parsed material data
  110629. * @param source defines the JSON representation of the material
  110630. * @param scene defines the hosting scene
  110631. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  110632. * @returns a new standard material
  110633. */
  110634. static Parse(source: any, scene: Scene, rootUrl: string): StandardMaterial;
  110635. /**
  110636. * Are diffuse textures enabled in the application.
  110637. */
  110638. static get DiffuseTextureEnabled(): boolean;
  110639. static set DiffuseTextureEnabled(value: boolean);
  110640. /**
  110641. * Are detail textures enabled in the application.
  110642. */
  110643. static get DetailTextureEnabled(): boolean;
  110644. static set DetailTextureEnabled(value: boolean);
  110645. /**
  110646. * Are ambient textures enabled in the application.
  110647. */
  110648. static get AmbientTextureEnabled(): boolean;
  110649. static set AmbientTextureEnabled(value: boolean);
  110650. /**
  110651. * Are opacity textures enabled in the application.
  110652. */
  110653. static get OpacityTextureEnabled(): boolean;
  110654. static set OpacityTextureEnabled(value: boolean);
  110655. /**
  110656. * Are reflection textures enabled in the application.
  110657. */
  110658. static get ReflectionTextureEnabled(): boolean;
  110659. static set ReflectionTextureEnabled(value: boolean);
  110660. /**
  110661. * Are emissive textures enabled in the application.
  110662. */
  110663. static get EmissiveTextureEnabled(): boolean;
  110664. static set EmissiveTextureEnabled(value: boolean);
  110665. /**
  110666. * Are specular textures enabled in the application.
  110667. */
  110668. static get SpecularTextureEnabled(): boolean;
  110669. static set SpecularTextureEnabled(value: boolean);
  110670. /**
  110671. * Are bump textures enabled in the application.
  110672. */
  110673. static get BumpTextureEnabled(): boolean;
  110674. static set BumpTextureEnabled(value: boolean);
  110675. /**
  110676. * Are lightmap textures enabled in the application.
  110677. */
  110678. static get LightmapTextureEnabled(): boolean;
  110679. static set LightmapTextureEnabled(value: boolean);
  110680. /**
  110681. * Are refraction textures enabled in the application.
  110682. */
  110683. static get RefractionTextureEnabled(): boolean;
  110684. static set RefractionTextureEnabled(value: boolean);
  110685. /**
  110686. * Are color grading textures enabled in the application.
  110687. */
  110688. static get ColorGradingTextureEnabled(): boolean;
  110689. static set ColorGradingTextureEnabled(value: boolean);
  110690. /**
  110691. * Are fresnels enabled in the application.
  110692. */
  110693. static get FresnelEnabled(): boolean;
  110694. static set FresnelEnabled(value: boolean);
  110695. }
  110696. }
  110697. declare module BABYLON {
  110698. /**
  110699. * The SPS is a single updatable mesh. The solid particles are simply separate parts or faces fo this big mesh.
  110700. *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.
  110701. * The SPS is also a particle system. It provides some methods to manage the particles.
  110702. * However it is behavior agnostic. This means it has no emitter, no particle physics, no particle recycler. You have to implement your own behavior.
  110703. *
  110704. * Full documentation here : https://doc.babylonjs.com/how_to/Solid_Particle_System
  110705. */
  110706. export class SolidParticleSystem implements IDisposable {
  110707. /**
  110708. * The SPS array of Solid Particle objects. Just access each particle as with any classic array.
  110709. * Example : var p = SPS.particles[i];
  110710. */
  110711. particles: SolidParticle[];
  110712. /**
  110713. * The SPS total number of particles. Read only. Use SPS.counter instead if you need to set your own value.
  110714. */
  110715. nbParticles: number;
  110716. /**
  110717. * If the particles must ever face the camera (default false). Useful for planar particles.
  110718. */
  110719. billboard: boolean;
  110720. /**
  110721. * Recompute normals when adding a shape
  110722. */
  110723. recomputeNormals: boolean;
  110724. /**
  110725. * This a counter ofr your own usage. It's not set by any SPS functions.
  110726. */
  110727. counter: number;
  110728. /**
  110729. * The SPS name. This name is also given to the underlying mesh.
  110730. */
  110731. name: string;
  110732. /**
  110733. * The SPS mesh. It's a standard BJS Mesh, so all the methods from the Mesh class are avalaible.
  110734. */
  110735. mesh: Mesh;
  110736. /**
  110737. * This empty object is intended to store some SPS specific or temporary values in order to lower the Garbage Collector activity.
  110738. * Please read : https://doc.babylonjs.com/how_to/Solid_Particle_System#garbage-collector-concerns
  110739. */
  110740. vars: any;
  110741. /**
  110742. * This array is populated when the SPS is set as 'pickable'.
  110743. * Each key of this array is a `faceId` value that you can get from a pickResult object.
  110744. * Each element of this array is an object `{idx: int, faceId: int}`.
  110745. * `idx` is the picked particle index in the `SPS.particles` array
  110746. * `faceId` is the picked face index counted within this particle.
  110747. * This array is the first element of the pickedBySubMesh array : sps.pickBySubMesh[0].
  110748. * It's not pertinent to use it when using a SPS with the support for MultiMaterial enabled.
  110749. * Use the method SPS.pickedParticle(pickingInfo) instead.
  110750. * Please read : https://doc.babylonjs.com/how_to/Solid_Particle_System#pickable-particles
  110751. */
  110752. pickedParticles: {
  110753. idx: number;
  110754. faceId: number;
  110755. }[];
  110756. /**
  110757. * This array is populated when the SPS is set as 'pickable'
  110758. * Each key of this array is a submesh index.
  110759. * Each element of this array is a second array defined like this :
  110760. * Each key of this second array is a `faceId` value that you can get from a pickResult object.
  110761. * Each element of this second array is an object `{idx: int, faceId: int}`.
  110762. * `idx` is the picked particle index in the `SPS.particles` array
  110763. * `faceId` is the picked face index counted within this particle.
  110764. * It's better to use the method SPS.pickedParticle(pickingInfo) rather than using directly this array.
  110765. * Please read : https://doc.babylonjs.com/how_to/Solid_Particle_System#pickable-particles
  110766. */
  110767. pickedBySubMesh: {
  110768. idx: number;
  110769. faceId: number;
  110770. }[][];
  110771. /**
  110772. * This array is populated when `enableDepthSort` is set to true.
  110773. * Each element of this array is an instance of the class DepthSortedParticle.
  110774. */
  110775. depthSortedParticles: DepthSortedParticle[];
  110776. /**
  110777. * If the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster). (Internal use only)
  110778. * @hidden
  110779. */
  110780. _bSphereOnly: boolean;
  110781. /**
  110782. * A number to multiply the boundind sphere radius by in order to reduce it for instance. (Internal use only)
  110783. * @hidden
  110784. */
  110785. _bSphereRadiusFactor: number;
  110786. private _scene;
  110787. private _positions;
  110788. private _indices;
  110789. private _normals;
  110790. private _colors;
  110791. private _uvs;
  110792. private _indices32;
  110793. private _positions32;
  110794. private _normals32;
  110795. private _fixedNormal32;
  110796. private _colors32;
  110797. private _uvs32;
  110798. private _index;
  110799. private _updatable;
  110800. private _pickable;
  110801. private _isVisibilityBoxLocked;
  110802. private _alwaysVisible;
  110803. private _depthSort;
  110804. private _expandable;
  110805. private _shapeCounter;
  110806. private _copy;
  110807. private _color;
  110808. private _computeParticleColor;
  110809. private _computeParticleTexture;
  110810. private _computeParticleRotation;
  110811. private _computeParticleVertex;
  110812. private _computeBoundingBox;
  110813. private _depthSortParticles;
  110814. private _camera;
  110815. private _mustUnrotateFixedNormals;
  110816. private _particlesIntersect;
  110817. private _needs32Bits;
  110818. private _isNotBuilt;
  110819. private _lastParticleId;
  110820. private _idxOfId;
  110821. private _multimaterialEnabled;
  110822. private _useModelMaterial;
  110823. private _indicesByMaterial;
  110824. private _materialIndexes;
  110825. private _depthSortFunction;
  110826. private _materialSortFunction;
  110827. private _materials;
  110828. private _multimaterial;
  110829. private _materialIndexesById;
  110830. private _defaultMaterial;
  110831. private _autoUpdateSubMeshes;
  110832. private _tmpVertex;
  110833. /**
  110834. * Creates a SPS (Solid Particle System) object.
  110835. * @param name (String) is the SPS name, this will be the underlying mesh name.
  110836. * @param scene (Scene) is the scene in which the SPS is added.
  110837. * @param options defines the options of the sps e.g.
  110838. * * updatable (optional boolean, default true) : if the SPS must be updatable or immutable.
  110839. * * isPickable (optional boolean, default false) : if the solid particles must be pickable.
  110840. * * enableDepthSort (optional boolean, default false) : if the solid particles must be sorted in the geometry according to their distance to the camera.
  110841. * * 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.
  110842. * * enableMultiMaterial (optional boolean, default false) : if the solid particles can be given different materials.
  110843. * * expandable (optional boolean, default false) : if particles can still be added after the initial SPS mesh creation.
  110844. * * particleIntersection (optional boolean, default false) : if the solid particle intersections must be computed.
  110845. * * boundingSphereOnly (optional boolean, default false) : if the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster).
  110846. * * bSphereRadiusFactor (optional float, default 1.0) : a number to multiply the boundind sphere radius by in order to reduce it for instance.
  110847. * @example bSphereRadiusFactor = 1.0 / Math.sqrt(3.0) => the bounding sphere exactly matches a spherical mesh.
  110848. */
  110849. constructor(name: string, scene: Scene, options?: {
  110850. updatable?: boolean;
  110851. isPickable?: boolean;
  110852. enableDepthSort?: boolean;
  110853. particleIntersection?: boolean;
  110854. boundingSphereOnly?: boolean;
  110855. bSphereRadiusFactor?: number;
  110856. expandable?: boolean;
  110857. useModelMaterial?: boolean;
  110858. enableMultiMaterial?: boolean;
  110859. });
  110860. /**
  110861. * Builds the SPS underlying mesh. Returns a standard Mesh.
  110862. * If no model shape was added to the SPS, the returned mesh is just a single triangular plane.
  110863. * @returns the created mesh
  110864. */
  110865. buildMesh(): Mesh;
  110866. /**
  110867. * Digests the mesh and generates as many solid particles in the system as wanted. Returns the SPS.
  110868. * These particles will have the same geometry than the mesh parts and will be positioned at the same localisation than the mesh original places.
  110869. * Thus the particles generated from `digest()` have their property `position` set yet.
  110870. * @param mesh ( Mesh ) is the mesh to be digested
  110871. * @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
  110872. * {delta} (optional integer, default 0) is the random extra number of facets per particle , each particle will have between `facetNb` and `facetNb + delta` facets
  110873. * {number} (optional positive integer) is the wanted number of particles : each particle is built with `mesh_total_facets / number` facets
  110874. * {storage} (optional existing array) is an array where the particles will be stored for a further use instead of being inserted in the SPS.
  110875. * @returns the current SPS
  110876. */
  110877. digest(mesh: Mesh, options?: {
  110878. facetNb?: number;
  110879. number?: number;
  110880. delta?: number;
  110881. storage?: [];
  110882. }): SolidParticleSystem;
  110883. /**
  110884. * Unrotate the fixed normals in case the mesh was built with pre-rotated particles, ex : use of positionFunction in addShape()
  110885. * @hidden
  110886. */
  110887. private _unrotateFixedNormals;
  110888. /**
  110889. * Resets the temporary working copy particle
  110890. * @hidden
  110891. */
  110892. private _resetCopy;
  110893. /**
  110894. * Inserts the shape model geometry in the global SPS mesh by updating the positions, indices, normals, colors, uvs arrays
  110895. * @param p the current index in the positions array to be updated
  110896. * @param ind the current index in the indices array
  110897. * @param shape a Vector3 array, the shape geometry
  110898. * @param positions the positions array to be updated
  110899. * @param meshInd the shape indices array
  110900. * @param indices the indices array to be updated
  110901. * @param meshUV the shape uv array
  110902. * @param uvs the uv array to be updated
  110903. * @param meshCol the shape color array
  110904. * @param colors the color array to be updated
  110905. * @param meshNor the shape normals array
  110906. * @param normals the normals array to be updated
  110907. * @param idx the particle index
  110908. * @param idxInShape the particle index in its shape
  110909. * @param options the addShape() method passed options
  110910. * @model the particle model
  110911. * @hidden
  110912. */
  110913. private _meshBuilder;
  110914. /**
  110915. * Returns a shape Vector3 array from positions float array
  110916. * @param positions float array
  110917. * @returns a vector3 array
  110918. * @hidden
  110919. */
  110920. private _posToShape;
  110921. /**
  110922. * Returns a shapeUV array from a float uvs (array deep copy)
  110923. * @param uvs as a float array
  110924. * @returns a shapeUV array
  110925. * @hidden
  110926. */
  110927. private _uvsToShapeUV;
  110928. /**
  110929. * Adds a new particle object in the particles array
  110930. * @param idx particle index in particles array
  110931. * @param id particle id
  110932. * @param idxpos positionIndex : the starting index of the particle vertices in the SPS "positions" array
  110933. * @param idxind indiceIndex : he starting index of the particle indices in the SPS "indices" array
  110934. * @param model particle ModelShape object
  110935. * @param shapeId model shape identifier
  110936. * @param idxInShape index of the particle in the current model
  110937. * @param bInfo model bounding info object
  110938. * @param storage target storage array, if any
  110939. * @hidden
  110940. */
  110941. private _addParticle;
  110942. /**
  110943. * Adds some particles to the SPS from the model shape. Returns the shape id.
  110944. * Please read the doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#create-an-immutable-sps
  110945. * @param mesh is any Mesh object that will be used as a model for the solid particles.
  110946. * @param nb (positive integer) the number of particles to be created from this model
  110947. * @param options {positionFunction} is an optional javascript function to called for each particle on SPS creation.
  110948. * {vertexFunction} is an optional javascript function to called for each vertex of each particle on SPS creation
  110949. * {storage} (optional existing array) is an array where the particles will be stored for a further use instead of being inserted in the SPS.
  110950. * @returns the number of shapes in the system
  110951. */
  110952. addShape(mesh: Mesh, nb: number, options?: {
  110953. positionFunction?: any;
  110954. vertexFunction?: any;
  110955. storage?: [];
  110956. }): number;
  110957. /**
  110958. * Rebuilds a particle back to its just built status : if needed, recomputes the custom positions and vertices
  110959. * @hidden
  110960. */
  110961. private _rebuildParticle;
  110962. /**
  110963. * Rebuilds the whole mesh and updates the VBO : custom positions and vertices are recomputed if needed.
  110964. * @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.
  110965. * @returns the SPS.
  110966. */
  110967. rebuildMesh(reset?: boolean): SolidParticleSystem;
  110968. /** Removes the particles from the start-th to the end-th included from an expandable SPS (required).
  110969. * Returns an array with the removed particles.
  110970. * 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.
  110971. * The SPS can't be empty so at least one particle needs to remain in place.
  110972. * Under the hood, the VertexData array, so the VBO buffer, is recreated each call.
  110973. * @param start index of the first particle to remove
  110974. * @param end index of the last particle to remove (included)
  110975. * @returns an array populated with the removed particles
  110976. */
  110977. removeParticles(start: number, end: number): SolidParticle[];
  110978. /**
  110979. * Inserts some pre-created particles in the solid particle system so that they can be managed by setParticles().
  110980. * @param solidParticleArray an array populated with Solid Particles objects
  110981. * @returns the SPS
  110982. */
  110983. insertParticlesFromArray(solidParticleArray: SolidParticle[]): SolidParticleSystem;
  110984. /**
  110985. * Creates a new particle and modifies the SPS mesh geometry :
  110986. * - calls _meshBuilder() to increase the SPS mesh geometry step by step
  110987. * - calls _addParticle() to populate the particle array
  110988. * factorized code from addShape() and insertParticlesFromArray()
  110989. * @param idx particle index in the particles array
  110990. * @param i particle index in its shape
  110991. * @param modelShape particle ModelShape object
  110992. * @param shape shape vertex array
  110993. * @param meshInd shape indices array
  110994. * @param meshUV shape uv array
  110995. * @param meshCol shape color array
  110996. * @param meshNor shape normals array
  110997. * @param bbInfo shape bounding info
  110998. * @param storage target particle storage
  110999. * @options addShape() passed options
  111000. * @hidden
  111001. */
  111002. private _insertNewParticle;
  111003. /**
  111004. * Sets all the particles : this method actually really updates the mesh according to the particle positions, rotations, colors, textures, etc.
  111005. * This method calls `updateParticle()` for each particle of the SPS.
  111006. * For an animated SPS, it is usually called within the render loop.
  111007. * 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.
  111008. * @param start The particle index in the particle array where to start to compute the particle property values _(default 0)_
  111009. * @param end The particle index in the particle array where to stop to compute the particle property values _(default nbParticle - 1)_
  111010. * @param update If the mesh must be finally updated on this call after all the particle computations _(default true)_
  111011. * @returns the SPS.
  111012. */
  111013. setParticles(start?: number, end?: number, update?: boolean): SolidParticleSystem;
  111014. /**
  111015. * Disposes the SPS.
  111016. */
  111017. dispose(): void;
  111018. /** Returns an object {idx: numbern faceId: number} for the picked particle from the passed pickingInfo object.
  111019. * idx is the particle index in the SPS
  111020. * faceId is the picked face index counted within this particle.
  111021. * Returns null if the pickInfo can't identify a picked particle.
  111022. * @param pickingInfo (PickingInfo object)
  111023. * @returns {idx: number, faceId: number} or null
  111024. */
  111025. pickedParticle(pickingInfo: PickingInfo): Nullable<{
  111026. idx: number;
  111027. faceId: number;
  111028. }>;
  111029. /**
  111030. * Returns a SolidParticle object from its identifier : particle.id
  111031. * @param id (integer) the particle Id
  111032. * @returns the searched particle or null if not found in the SPS.
  111033. */
  111034. getParticleById(id: number): Nullable<SolidParticle>;
  111035. /**
  111036. * Returns a new array populated with the particles having the passed shapeId.
  111037. * @param shapeId (integer) the shape identifier
  111038. * @returns a new solid particle array
  111039. */
  111040. getParticlesByShapeId(shapeId: number): SolidParticle[];
  111041. /**
  111042. * Populates the passed array "ref" with the particles having the passed shapeId.
  111043. * @param shapeId the shape identifier
  111044. * @returns the SPS
  111045. * @param ref
  111046. */
  111047. getParticlesByShapeIdToRef(shapeId: number, ref: SolidParticle[]): SolidParticleSystem;
  111048. /**
  111049. * Computes the required SubMeshes according the materials assigned to the particles.
  111050. * @returns the solid particle system.
  111051. * Does nothing if called before the SPS mesh is built.
  111052. */
  111053. computeSubMeshes(): SolidParticleSystem;
  111054. /**
  111055. * Sorts the solid particles by material when MultiMaterial is enabled.
  111056. * Updates the indices32 array.
  111057. * Updates the indicesByMaterial array.
  111058. * Updates the mesh indices array.
  111059. * @returns the SPS
  111060. * @hidden
  111061. */
  111062. private _sortParticlesByMaterial;
  111063. /**
  111064. * Sets the material indexes by id materialIndexesById[id] = materialIndex
  111065. * @hidden
  111066. */
  111067. private _setMaterialIndexesById;
  111068. /**
  111069. * Returns an array with unique values of Materials from the passed array
  111070. * @param array the material array to be checked and filtered
  111071. * @hidden
  111072. */
  111073. private _filterUniqueMaterialId;
  111074. /**
  111075. * Sets a new Standard Material as _defaultMaterial if not already set.
  111076. * @hidden
  111077. */
  111078. private _setDefaultMaterial;
  111079. /**
  111080. * Visibilty helper : Recomputes the visible size according to the mesh bounding box
  111081. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  111082. * @returns the SPS.
  111083. */
  111084. refreshVisibleSize(): SolidParticleSystem;
  111085. /**
  111086. * Visibility helper : Sets the size of a visibility box, this sets the underlying mesh bounding box.
  111087. * @param size the size (float) of the visibility box
  111088. * note : this doesn't lock the SPS mesh bounding box.
  111089. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  111090. */
  111091. setVisibilityBox(size: number): void;
  111092. /**
  111093. * Gets whether the SPS as always visible or not
  111094. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  111095. */
  111096. get isAlwaysVisible(): boolean;
  111097. /**
  111098. * Sets the SPS as always visible or not
  111099. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  111100. */
  111101. set isAlwaysVisible(val: boolean);
  111102. /**
  111103. * Sets the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  111104. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  111105. */
  111106. set isVisibilityBoxLocked(val: boolean);
  111107. /**
  111108. * Gets if the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  111109. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  111110. */
  111111. get isVisibilityBoxLocked(): boolean;
  111112. /**
  111113. * Tells to `setParticles()` to compute the particle rotations or not.
  111114. * Default value : true. The SPS is faster when it's set to false.
  111115. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  111116. */
  111117. set computeParticleRotation(val: boolean);
  111118. /**
  111119. * Tells to `setParticles()` to compute the particle colors or not.
  111120. * Default value : true. The SPS is faster when it's set to false.
  111121. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  111122. */
  111123. set computeParticleColor(val: boolean);
  111124. set computeParticleTexture(val: boolean);
  111125. /**
  111126. * Tells to `setParticles()` to call the vertex function for each vertex of each particle, or not.
  111127. * Default value : false. The SPS is faster when it's set to false.
  111128. * Note : the particle custom vertex positions aren't stored values.
  111129. */
  111130. set computeParticleVertex(val: boolean);
  111131. /**
  111132. * Tells to `setParticles()` to compute or not the mesh bounding box when computing the particle positions.
  111133. */
  111134. set computeBoundingBox(val: boolean);
  111135. /**
  111136. * Tells to `setParticles()` to sort or not the distance between each particle and the camera.
  111137. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  111138. * Default : `true`
  111139. */
  111140. set depthSortParticles(val: boolean);
  111141. /**
  111142. * Gets if `setParticles()` computes the particle rotations or not.
  111143. * Default value : true. The SPS is faster when it's set to false.
  111144. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  111145. */
  111146. get computeParticleRotation(): boolean;
  111147. /**
  111148. * Gets if `setParticles()` computes the particle colors or not.
  111149. * Default value : true. The SPS is faster when it's set to false.
  111150. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  111151. */
  111152. get computeParticleColor(): boolean;
  111153. /**
  111154. * Gets if `setParticles()` computes the particle textures or not.
  111155. * Default value : true. The SPS is faster when it's set to false.
  111156. * Note : the particle textures are stored values, so setting `computeParticleTexture` to false will keep yet the last colors set.
  111157. */
  111158. get computeParticleTexture(): boolean;
  111159. /**
  111160. * Gets if `setParticles()` calls the vertex function for each vertex of each particle, or not.
  111161. * Default value : false. The SPS is faster when it's set to false.
  111162. * Note : the particle custom vertex positions aren't stored values.
  111163. */
  111164. get computeParticleVertex(): boolean;
  111165. /**
  111166. * Gets if `setParticles()` computes or not the mesh bounding box when computing the particle positions.
  111167. */
  111168. get computeBoundingBox(): boolean;
  111169. /**
  111170. * Gets if `setParticles()` sorts or not the distance between each particle and the camera.
  111171. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  111172. * Default : `true`
  111173. */
  111174. get depthSortParticles(): boolean;
  111175. /**
  111176. * Gets if the SPS is created as expandable at construction time.
  111177. * Default : `false`
  111178. */
  111179. get expandable(): boolean;
  111180. /**
  111181. * Gets if the SPS supports the Multi Materials
  111182. */
  111183. get multimaterialEnabled(): boolean;
  111184. /**
  111185. * Gets if the SPS uses the model materials for its own multimaterial.
  111186. */
  111187. get useModelMaterial(): boolean;
  111188. /**
  111189. * The SPS used material array.
  111190. */
  111191. get materials(): Material[];
  111192. /**
  111193. * Sets the SPS MultiMaterial from the passed materials.
  111194. * Note : the passed array is internally copied and not used then by reference.
  111195. * @param materials an array of material objects. This array indexes are the materialIndex values of the particles.
  111196. */
  111197. setMultiMaterial(materials: Material[]): void;
  111198. /**
  111199. * The SPS computed multimaterial object
  111200. */
  111201. get multimaterial(): MultiMaterial;
  111202. set multimaterial(mm: MultiMaterial);
  111203. /**
  111204. * If the subMeshes must be updated on the next call to setParticles()
  111205. */
  111206. get autoUpdateSubMeshes(): boolean;
  111207. set autoUpdateSubMeshes(val: boolean);
  111208. /**
  111209. * This function does nothing. It may be overwritten to set all the particle first values.
  111210. * The SPS doesn't call this function, you may have to call it by your own.
  111211. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  111212. */
  111213. initParticles(): void;
  111214. /**
  111215. * This function does nothing. It may be overwritten to recycle a particle.
  111216. * The SPS doesn't call this function, you may have to call it by your own.
  111217. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  111218. * @param particle The particle to recycle
  111219. * @returns the recycled particle
  111220. */
  111221. recycleParticle(particle: SolidParticle): SolidParticle;
  111222. /**
  111223. * Updates a particle : this function should be overwritten by the user.
  111224. * It is called on each particle by `setParticles()`. This is the place to code each particle behavior.
  111225. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  111226. * @example : just set a particle position or velocity and recycle conditions
  111227. * @param particle The particle to update
  111228. * @returns the updated particle
  111229. */
  111230. updateParticle(particle: SolidParticle): SolidParticle;
  111231. /**
  111232. * Updates a vertex of a particle : it can be overwritten by the user.
  111233. * This will be called on each vertex particle by `setParticles()` if `computeParticleVertex` is set to true only.
  111234. * @param particle the current particle
  111235. * @param vertex the current vertex of the current particle : a SolidParticleVertex object
  111236. * @param pt the index of the current vertex in the particle shape
  111237. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#update-each-particle-shape
  111238. * @example : just set a vertex particle position or color
  111239. * @returns the sps
  111240. */
  111241. updateParticleVertex(particle: SolidParticle, vertex: SolidParticleVertex, pt: number): SolidParticleSystem;
  111242. /**
  111243. * This will be called before any other treatment by `setParticles()` and will be passed three parameters.
  111244. * This does nothing and may be overwritten by the user.
  111245. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  111246. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  111247. * @param update the boolean update value actually passed to setParticles()
  111248. */
  111249. beforeUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  111250. /**
  111251. * This will be called by `setParticles()` after all the other treatments and just before the actual mesh update.
  111252. * This will be passed three parameters.
  111253. * This does nothing and may be overwritten by the user.
  111254. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  111255. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  111256. * @param update the boolean update value actually passed to setParticles()
  111257. */
  111258. afterUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  111259. }
  111260. }
  111261. declare module BABYLON {
  111262. /**
  111263. * Represents one particle of a solid particle system.
  111264. */
  111265. export class SolidParticle {
  111266. /**
  111267. * particle global index
  111268. */
  111269. idx: number;
  111270. /**
  111271. * particle identifier
  111272. */
  111273. id: number;
  111274. /**
  111275. * The color of the particle
  111276. */
  111277. color: Nullable<Color4>;
  111278. /**
  111279. * The world space position of the particle.
  111280. */
  111281. position: Vector3;
  111282. /**
  111283. * The world space rotation of the particle. (Not use if rotationQuaternion is set)
  111284. */
  111285. rotation: Vector3;
  111286. /**
  111287. * The world space rotation quaternion of the particle.
  111288. */
  111289. rotationQuaternion: Nullable<Quaternion>;
  111290. /**
  111291. * The scaling of the particle.
  111292. */
  111293. scaling: Vector3;
  111294. /**
  111295. * The uvs of the particle.
  111296. */
  111297. uvs: Vector4;
  111298. /**
  111299. * The current speed of the particle.
  111300. */
  111301. velocity: Vector3;
  111302. /**
  111303. * The pivot point in the particle local space.
  111304. */
  111305. pivot: Vector3;
  111306. /**
  111307. * Must the particle be translated from its pivot point in its local space ?
  111308. * In this case, the pivot point is set at the origin of the particle local space and the particle is translated.
  111309. * Default : false
  111310. */
  111311. translateFromPivot: boolean;
  111312. /**
  111313. * Is the particle active or not ?
  111314. */
  111315. alive: boolean;
  111316. /**
  111317. * Is the particle visible or not ?
  111318. */
  111319. isVisible: boolean;
  111320. /**
  111321. * Index of this particle in the global "positions" array (Internal use)
  111322. * @hidden
  111323. */
  111324. _pos: number;
  111325. /**
  111326. * @hidden Index of this particle in the global "indices" array (Internal use)
  111327. */
  111328. _ind: number;
  111329. /**
  111330. * @hidden ModelShape of this particle (Internal use)
  111331. */
  111332. _model: ModelShape;
  111333. /**
  111334. * ModelShape id of this particle
  111335. */
  111336. shapeId: number;
  111337. /**
  111338. * Index of the particle in its shape id
  111339. */
  111340. idxInShape: number;
  111341. /**
  111342. * @hidden Reference to the shape model BoundingInfo object (Internal use)
  111343. */
  111344. _modelBoundingInfo: BoundingInfo;
  111345. /**
  111346. * @hidden Particle BoundingInfo object (Internal use)
  111347. */
  111348. _boundingInfo: BoundingInfo;
  111349. /**
  111350. * @hidden Reference to the SPS what the particle belongs to (Internal use)
  111351. */
  111352. _sps: SolidParticleSystem;
  111353. /**
  111354. * @hidden Still set as invisible in order to skip useless computations (Internal use)
  111355. */
  111356. _stillInvisible: boolean;
  111357. /**
  111358. * @hidden Last computed particle rotation matrix
  111359. */
  111360. _rotationMatrix: number[];
  111361. /**
  111362. * Parent particle Id, if any.
  111363. * Default null.
  111364. */
  111365. parentId: Nullable<number>;
  111366. /**
  111367. * The particle material identifier (integer) when MultiMaterials are enabled in the SPS.
  111368. */
  111369. materialIndex: Nullable<number>;
  111370. /**
  111371. * Custom object or properties.
  111372. */
  111373. props: Nullable<any>;
  111374. /**
  111375. * The culling strategy to use to check whether the solid particle must be culled or not when using isInFrustum().
  111376. * The possible values are :
  111377. * - AbstractMesh.CULLINGSTRATEGY_STANDARD
  111378. * - AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  111379. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION
  111380. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY
  111381. * The default value for solid particles is AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  111382. * Please read each static variable documentation in the class AbstractMesh to get details about the culling process.
  111383. * */
  111384. cullingStrategy: number;
  111385. /**
  111386. * @hidden Internal global position in the SPS.
  111387. */
  111388. _globalPosition: Vector3;
  111389. /**
  111390. * Creates a Solid Particle object.
  111391. * Don't create particles manually, use instead the Solid Particle System internal tools like _addParticle()
  111392. * @param particleIndex (integer) is the particle index in the Solid Particle System pool.
  111393. * @param particleId (integer) is the particle identifier. Unless some particles are removed from the SPS, it's the same value than the particle idx.
  111394. * @param positionIndex (integer) is the starting index of the particle vertices in the SPS "positions" array.
  111395. * @param indiceIndex (integer) is the starting index of the particle indices in the SPS "indices" array.
  111396. * @param model (ModelShape) is a reference to the model shape on what the particle is designed.
  111397. * @param shapeId (integer) is the model shape identifier in the SPS.
  111398. * @param idxInShape (integer) is the index of the particle in the current model (ex: the 10th box of addShape(box, 30))
  111399. * @param sps defines the sps it is associated to
  111400. * @param modelBoundingInfo is the reference to the model BoundingInfo used for intersection computations.
  111401. * @param materialIndex is the particle material identifier (integer) when the MultiMaterials are enabled in the SPS.
  111402. */
  111403. constructor(particleIndex: number, particleId: number, positionIndex: number, indiceIndex: number, model: Nullable<ModelShape>, shapeId: number, idxInShape: number, sps: SolidParticleSystem, modelBoundingInfo?: Nullable<BoundingInfo>, materialIndex?: Nullable<number>);
  111404. /**
  111405. * Copies the particle property values into the existing target : position, rotation, scaling, uvs, colors, pivot, parent, visibility, alive
  111406. * @param target the particle target
  111407. * @returns the current particle
  111408. */
  111409. copyToRef(target: SolidParticle): SolidParticle;
  111410. /**
  111411. * Legacy support, changed scale to scaling
  111412. */
  111413. get scale(): Vector3;
  111414. /**
  111415. * Legacy support, changed scale to scaling
  111416. */
  111417. set scale(scale: Vector3);
  111418. /**
  111419. * Legacy support, changed quaternion to rotationQuaternion
  111420. */
  111421. get quaternion(): Nullable<Quaternion>;
  111422. /**
  111423. * Legacy support, changed quaternion to rotationQuaternion
  111424. */
  111425. set quaternion(q: Nullable<Quaternion>);
  111426. /**
  111427. * Returns a boolean. True if the particle intersects another particle or another mesh, else false.
  111428. * The intersection is computed on the particle bounding sphere and Axis Aligned Bounding Box (AABB)
  111429. * @param target is the object (solid particle or mesh) what the intersection is computed against.
  111430. * @returns true if it intersects
  111431. */
  111432. intersectsMesh(target: Mesh | SolidParticle): boolean;
  111433. /**
  111434. * Returns `true` if the solid particle is within the frustum defined by the passed array of planes.
  111435. * A particle is in the frustum if its bounding box intersects the frustum
  111436. * @param frustumPlanes defines the frustum to test
  111437. * @returns true if the particle is in the frustum planes
  111438. */
  111439. isInFrustum(frustumPlanes: Plane[]): boolean;
  111440. /**
  111441. * get the rotation matrix of the particle
  111442. * @hidden
  111443. */
  111444. getRotationMatrix(m: Matrix): void;
  111445. }
  111446. /**
  111447. * Represents the shape of the model used by one particle of a solid particle system.
  111448. * SPS internal tool, don't use it manually.
  111449. */
  111450. export class ModelShape {
  111451. /**
  111452. * The shape id
  111453. * @hidden
  111454. */
  111455. shapeID: number;
  111456. /**
  111457. * flat array of model positions (internal use)
  111458. * @hidden
  111459. */
  111460. _shape: Vector3[];
  111461. /**
  111462. * flat array of model UVs (internal use)
  111463. * @hidden
  111464. */
  111465. _shapeUV: number[];
  111466. /**
  111467. * color array of the model
  111468. * @hidden
  111469. */
  111470. _shapeColors: number[];
  111471. /**
  111472. * indices array of the model
  111473. * @hidden
  111474. */
  111475. _indices: number[];
  111476. /**
  111477. * normals array of the model
  111478. * @hidden
  111479. */
  111480. _normals: number[];
  111481. /**
  111482. * length of the shape in the model indices array (internal use)
  111483. * @hidden
  111484. */
  111485. _indicesLength: number;
  111486. /**
  111487. * Custom position function (internal use)
  111488. * @hidden
  111489. */
  111490. _positionFunction: Nullable<(particle: SolidParticle, i: number, s: number) => void>;
  111491. /**
  111492. * Custom vertex function (internal use)
  111493. * @hidden
  111494. */
  111495. _vertexFunction: Nullable<(particle: SolidParticle, vertex: Vector3, i: number) => void>;
  111496. /**
  111497. * Model material (internal use)
  111498. * @hidden
  111499. */
  111500. _material: Nullable<Material>;
  111501. /**
  111502. * 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.
  111503. * SPS internal tool, don't use it manually.
  111504. * @hidden
  111505. */
  111506. 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>);
  111507. }
  111508. /**
  111509. * Represents a Depth Sorted Particle in the solid particle system.
  111510. * @hidden
  111511. */
  111512. export class DepthSortedParticle {
  111513. /**
  111514. * Particle index
  111515. */
  111516. idx: number;
  111517. /**
  111518. * Index of the particle in the "indices" array
  111519. */
  111520. ind: number;
  111521. /**
  111522. * Length of the particle shape in the "indices" array
  111523. */
  111524. indicesLength: number;
  111525. /**
  111526. * Squared distance from the particle to the camera
  111527. */
  111528. sqDistance: number;
  111529. /**
  111530. * Material index when used with MultiMaterials
  111531. */
  111532. materialIndex: number;
  111533. /**
  111534. * Creates a new sorted particle
  111535. * @param materialIndex
  111536. */
  111537. constructor(idx: number, ind: number, indLength: number, materialIndex: number);
  111538. }
  111539. /**
  111540. * Represents a solid particle vertex
  111541. */
  111542. export class SolidParticleVertex {
  111543. /**
  111544. * Vertex position
  111545. */
  111546. position: Vector3;
  111547. /**
  111548. * Vertex color
  111549. */
  111550. color: Color4;
  111551. /**
  111552. * Vertex UV
  111553. */
  111554. uv: Vector2;
  111555. /**
  111556. * Creates a new solid particle vertex
  111557. */
  111558. constructor();
  111559. /** Vertex x coordinate */
  111560. get x(): number;
  111561. set x(val: number);
  111562. /** Vertex y coordinate */
  111563. get y(): number;
  111564. set y(val: number);
  111565. /** Vertex z coordinate */
  111566. get z(): number;
  111567. set z(val: number);
  111568. }
  111569. }
  111570. declare module BABYLON {
  111571. /**
  111572. * @hidden
  111573. */
  111574. export class _MeshCollisionData {
  111575. _checkCollisions: boolean;
  111576. _collisionMask: number;
  111577. _collisionGroup: number;
  111578. _surroundingMeshes: Nullable<AbstractMesh[]>;
  111579. _collider: Nullable<Collider>;
  111580. _oldPositionForCollisions: Vector3;
  111581. _diffPositionForCollisions: Vector3;
  111582. _onCollideObserver: Nullable<Observer<AbstractMesh>>;
  111583. _onCollisionPositionChangeObserver: Nullable<Observer<Vector3>>;
  111584. }
  111585. }
  111586. declare module BABYLON {
  111587. /** @hidden */
  111588. class _FacetDataStorage {
  111589. facetPositions: Vector3[];
  111590. facetNormals: Vector3[];
  111591. facetPartitioning: number[][];
  111592. facetNb: number;
  111593. partitioningSubdivisions: number;
  111594. partitioningBBoxRatio: number;
  111595. facetDataEnabled: boolean;
  111596. facetParameters: any;
  111597. bbSize: Vector3;
  111598. subDiv: {
  111599. max: number;
  111600. X: number;
  111601. Y: number;
  111602. Z: number;
  111603. };
  111604. facetDepthSort: boolean;
  111605. facetDepthSortEnabled: boolean;
  111606. depthSortedIndices: IndicesArray;
  111607. depthSortedFacets: {
  111608. ind: number;
  111609. sqDistance: number;
  111610. }[];
  111611. facetDepthSortFunction: (f1: {
  111612. ind: number;
  111613. sqDistance: number;
  111614. }, f2: {
  111615. ind: number;
  111616. sqDistance: number;
  111617. }) => number;
  111618. facetDepthSortFrom: Vector3;
  111619. facetDepthSortOrigin: Vector3;
  111620. invertedMatrix: Matrix;
  111621. }
  111622. /**
  111623. * @hidden
  111624. **/
  111625. class _InternalAbstractMeshDataInfo {
  111626. _hasVertexAlpha: boolean;
  111627. _useVertexColors: boolean;
  111628. _numBoneInfluencers: number;
  111629. _applyFog: boolean;
  111630. _receiveShadows: boolean;
  111631. _facetData: _FacetDataStorage;
  111632. _visibility: number;
  111633. _skeleton: Nullable<Skeleton>;
  111634. _layerMask: number;
  111635. _computeBonesUsingShaders: boolean;
  111636. _isActive: boolean;
  111637. _onlyForInstances: boolean;
  111638. _isActiveIntermediate: boolean;
  111639. _onlyForInstancesIntermediate: boolean;
  111640. _actAsRegularMesh: boolean;
  111641. }
  111642. /**
  111643. * Class used to store all common mesh properties
  111644. */
  111645. export class AbstractMesh extends TransformNode implements IDisposable, ICullable, IGetSetVerticesData {
  111646. /** No occlusion */
  111647. static OCCLUSION_TYPE_NONE: number;
  111648. /** Occlusion set to optimisitic */
  111649. static OCCLUSION_TYPE_OPTIMISTIC: number;
  111650. /** Occlusion set to strict */
  111651. static OCCLUSION_TYPE_STRICT: number;
  111652. /** Use an accurante occlusion algorithm */
  111653. static OCCLUSION_ALGORITHM_TYPE_ACCURATE: number;
  111654. /** Use a conservative occlusion algorithm */
  111655. static OCCLUSION_ALGORITHM_TYPE_CONSERVATIVE: number;
  111656. /** Default culling strategy : this is an exclusion test and it's the more accurate.
  111657. * Test order :
  111658. * Is the bounding sphere outside the frustum ?
  111659. * If not, are the bounding box vertices outside the frustum ?
  111660. * It not, then the cullable object is in the frustum.
  111661. */
  111662. static readonly CULLINGSTRATEGY_STANDARD: number;
  111663. /** Culling strategy : Bounding Sphere Only.
  111664. * This is an exclusion test. It's faster than the standard strategy because the bounding box is not tested.
  111665. * It's also less accurate than the standard because some not visible objects can still be selected.
  111666. * Test : is the bounding sphere outside the frustum ?
  111667. * If not, then the cullable object is in the frustum.
  111668. */
  111669. static readonly CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY: number;
  111670. /** Culling strategy : Optimistic Inclusion.
  111671. * This in an inclusion test first, then the standard exclusion test.
  111672. * This can be faster when a cullable object is expected to be almost always in the camera frustum.
  111673. * 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.
  111674. * Anyway, it's as accurate as the standard strategy.
  111675. * Test :
  111676. * Is the cullable object bounding sphere center in the frustum ?
  111677. * If not, apply the default culling strategy.
  111678. */
  111679. static readonly CULLINGSTRATEGY_OPTIMISTIC_INCLUSION: number;
  111680. /** Culling strategy : Optimistic Inclusion then Bounding Sphere Only.
  111681. * This in an inclusion test first, then the bounding sphere only exclusion test.
  111682. * This can be the fastest test when a cullable object is expected to be almost always in the camera frustum.
  111683. * 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.
  111684. * It's less accurate than the standard strategy and as accurate as the BoundingSphereOnly strategy.
  111685. * Test :
  111686. * Is the cullable object bounding sphere center in the frustum ?
  111687. * If not, apply the Bounding Sphere Only strategy. No Bounding Box is tested here.
  111688. */
  111689. static readonly CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY: number;
  111690. /**
  111691. * No billboard
  111692. */
  111693. static get BILLBOARDMODE_NONE(): number;
  111694. /** Billboard on X axis */
  111695. static get BILLBOARDMODE_X(): number;
  111696. /** Billboard on Y axis */
  111697. static get BILLBOARDMODE_Y(): number;
  111698. /** Billboard on Z axis */
  111699. static get BILLBOARDMODE_Z(): number;
  111700. /** Billboard on all axes */
  111701. static get BILLBOARDMODE_ALL(): number;
  111702. /** Billboard on using position instead of orientation */
  111703. static get BILLBOARDMODE_USE_POSITION(): number;
  111704. /** @hidden */
  111705. _internalAbstractMeshDataInfo: _InternalAbstractMeshDataInfo;
  111706. /**
  111707. * The culling strategy to use to check whether the mesh must be rendered or not.
  111708. * This value can be changed at any time and will be used on the next render mesh selection.
  111709. * The possible values are :
  111710. * - AbstractMesh.CULLINGSTRATEGY_STANDARD
  111711. * - AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  111712. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION
  111713. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY
  111714. * Please read each static variable documentation to get details about the culling process.
  111715. * */
  111716. cullingStrategy: number;
  111717. /**
  111718. * Gets the number of facets in the mesh
  111719. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  111720. */
  111721. get facetNb(): number;
  111722. /**
  111723. * Gets or set the number (integer) of subdivisions per axis in the partioning space
  111724. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  111725. */
  111726. get partitioningSubdivisions(): number;
  111727. set partitioningSubdivisions(nb: number);
  111728. /**
  111729. * The ratio (float) to apply to the bouding box size to set to the partioning space.
  111730. * Ex : 1.01 (default) the partioning space is 1% bigger than the bounding box
  111731. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  111732. */
  111733. get partitioningBBoxRatio(): number;
  111734. set partitioningBBoxRatio(ratio: number);
  111735. /**
  111736. * Gets or sets a boolean indicating that the facets must be depth sorted on next call to `updateFacetData()`.
  111737. * Works only for updatable meshes.
  111738. * Doesn't work with multi-materials
  111739. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  111740. */
  111741. get mustDepthSortFacets(): boolean;
  111742. set mustDepthSortFacets(sort: boolean);
  111743. /**
  111744. * The location (Vector3) where the facet depth sort must be computed from.
  111745. * By default, the active camera position.
  111746. * Used only when facet depth sort is enabled
  111747. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  111748. */
  111749. get facetDepthSortFrom(): Vector3;
  111750. set facetDepthSortFrom(location: Vector3);
  111751. /**
  111752. * gets a boolean indicating if facetData is enabled
  111753. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  111754. */
  111755. get isFacetDataEnabled(): boolean;
  111756. /** @hidden */
  111757. _updateNonUniformScalingState(value: boolean): boolean;
  111758. /**
  111759. * An event triggered when this mesh collides with another one
  111760. */
  111761. onCollideObservable: Observable<AbstractMesh>;
  111762. /** Set a function to call when this mesh collides with another one */
  111763. set onCollide(callback: () => void);
  111764. /**
  111765. * An event triggered when the collision's position changes
  111766. */
  111767. onCollisionPositionChangeObservable: Observable<Vector3>;
  111768. /** Set a function to call when the collision's position changes */
  111769. set onCollisionPositionChange(callback: () => void);
  111770. /**
  111771. * An event triggered when material is changed
  111772. */
  111773. onMaterialChangedObservable: Observable<AbstractMesh>;
  111774. /**
  111775. * Gets or sets the orientation for POV movement & rotation
  111776. */
  111777. definedFacingForward: boolean;
  111778. /** @hidden */
  111779. _occlusionQuery: Nullable<WebGLQuery>;
  111780. /** @hidden */
  111781. _renderingGroup: Nullable<RenderingGroup>;
  111782. /**
  111783. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  111784. */
  111785. get visibility(): number;
  111786. /**
  111787. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  111788. */
  111789. set visibility(value: number);
  111790. /** Gets or sets the alpha index used to sort transparent meshes
  111791. * @see https://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#alpha-index
  111792. */
  111793. alphaIndex: number;
  111794. /**
  111795. * Gets or sets a boolean indicating if the mesh is visible (renderable). Default is true
  111796. */
  111797. isVisible: boolean;
  111798. /**
  111799. * Gets or sets a boolean indicating if the mesh can be picked (by scene.pick for instance or through actions). Default is true
  111800. */
  111801. isPickable: boolean;
  111802. /** Gets or sets a boolean indicating that bounding boxes of subMeshes must be rendered as well (false by default) */
  111803. showSubMeshesBoundingBox: boolean;
  111804. /** Gets or sets a boolean indicating if the mesh must be considered as a ray blocker for lens flares (false by default)
  111805. * @see https://doc.babylonjs.com/how_to/how_to_use_lens_flares
  111806. */
  111807. isBlocker: boolean;
  111808. /**
  111809. * Gets or sets a boolean indicating that pointer move events must be supported on this mesh (false by default)
  111810. */
  111811. enablePointerMoveEvents: boolean;
  111812. private _renderingGroupId;
  111813. /**
  111814. * Specifies the rendering group id for this mesh (0 by default)
  111815. * @see https://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#rendering-groups
  111816. */
  111817. get renderingGroupId(): number;
  111818. set renderingGroupId(value: number);
  111819. private _material;
  111820. /** Gets or sets current material */
  111821. get material(): Nullable<Material>;
  111822. set material(value: Nullable<Material>);
  111823. /**
  111824. * Gets or sets a boolean indicating that this mesh can receive realtime shadows
  111825. * @see https://doc.babylonjs.com/babylon101/shadows
  111826. */
  111827. get receiveShadows(): boolean;
  111828. set receiveShadows(value: boolean);
  111829. /** Defines color to use when rendering outline */
  111830. outlineColor: Color3;
  111831. /** Define width to use when rendering outline */
  111832. outlineWidth: number;
  111833. /** Defines color to use when rendering overlay */
  111834. overlayColor: Color3;
  111835. /** Defines alpha to use when rendering overlay */
  111836. overlayAlpha: number;
  111837. /** Gets or sets a boolean indicating that this mesh contains vertex color data with alpha values */
  111838. get hasVertexAlpha(): boolean;
  111839. set hasVertexAlpha(value: boolean);
  111840. /** 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) */
  111841. get useVertexColors(): boolean;
  111842. set useVertexColors(value: boolean);
  111843. /**
  111844. * Gets or sets a boolean indicating that bone animations must be computed by the CPU (false by default)
  111845. */
  111846. get computeBonesUsingShaders(): boolean;
  111847. set computeBonesUsingShaders(value: boolean);
  111848. /** Gets or sets the number of allowed bone influences per vertex (4 by default) */
  111849. get numBoneInfluencers(): number;
  111850. set numBoneInfluencers(value: number);
  111851. /** Gets or sets a boolean indicating that this mesh will allow fog to be rendered on it (true by default) */
  111852. get applyFog(): boolean;
  111853. set applyFog(value: boolean);
  111854. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes selection (true by default) */
  111855. useOctreeForRenderingSelection: boolean;
  111856. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes picking (true by default) */
  111857. useOctreeForPicking: boolean;
  111858. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes collision (true by default) */
  111859. useOctreeForCollisions: boolean;
  111860. /**
  111861. * Gets or sets the current layer mask (default is 0x0FFFFFFF)
  111862. * @see https://doc.babylonjs.com/how_to/layermasks_and_multi-cam_textures
  111863. */
  111864. get layerMask(): number;
  111865. set layerMask(value: number);
  111866. /**
  111867. * True if the mesh must be rendered in any case (this will shortcut the frustum clipping phase)
  111868. */
  111869. alwaysSelectAsActiveMesh: boolean;
  111870. /**
  111871. * Gets or sets a boolean indicating that the bounding info does not need to be kept in sync (for performance reason)
  111872. */
  111873. doNotSyncBoundingInfo: boolean;
  111874. /**
  111875. * Gets or sets the current action manager
  111876. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  111877. */
  111878. actionManager: Nullable<AbstractActionManager>;
  111879. private _meshCollisionData;
  111880. /**
  111881. * Gets or sets the ellipsoid used to impersonate this mesh when using collision engine (default is (0.5, 1, 0.5))
  111882. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  111883. */
  111884. ellipsoid: Vector3;
  111885. /**
  111886. * Gets or sets the ellipsoid offset used to impersonate this mesh when using collision engine (default is (0, 0, 0))
  111887. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  111888. */
  111889. ellipsoidOffset: Vector3;
  111890. /**
  111891. * Gets or sets a collision mask used to mask collisions (default is -1).
  111892. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  111893. */
  111894. get collisionMask(): number;
  111895. set collisionMask(mask: number);
  111896. /**
  111897. * Gets or sets the current collision group mask (-1 by default).
  111898. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  111899. */
  111900. get collisionGroup(): number;
  111901. set collisionGroup(mask: number);
  111902. /**
  111903. * Gets or sets current surrounding meshes (null by default).
  111904. *
  111905. * By default collision detection is tested against every mesh in the scene.
  111906. * It is possible to set surroundingMeshes to a defined list of meshes and then only these specified
  111907. * meshes will be tested for the collision.
  111908. *
  111909. * Note: if set to an empty array no collision will happen when this mesh is moved.
  111910. */
  111911. get surroundingMeshes(): Nullable<AbstractMesh[]>;
  111912. set surroundingMeshes(meshes: Nullable<AbstractMesh[]>);
  111913. /**
  111914. * Defines edge width used when edgesRenderer is enabled
  111915. * @see https://www.babylonjs-playground.com/#10OJSG#13
  111916. */
  111917. edgesWidth: number;
  111918. /**
  111919. * Defines edge color used when edgesRenderer is enabled
  111920. * @see https://www.babylonjs-playground.com/#10OJSG#13
  111921. */
  111922. edgesColor: Color4;
  111923. /** @hidden */
  111924. _edgesRenderer: Nullable<IEdgesRenderer>;
  111925. /** @hidden */
  111926. _masterMesh: Nullable<AbstractMesh>;
  111927. /** @hidden */
  111928. _boundingInfo: Nullable<BoundingInfo>;
  111929. /** @hidden */
  111930. _renderId: number;
  111931. /**
  111932. * Gets or sets the list of subMeshes
  111933. * @see https://doc.babylonjs.com/how_to/multi_materials
  111934. */
  111935. subMeshes: SubMesh[];
  111936. /** @hidden */
  111937. _intersectionsInProgress: AbstractMesh[];
  111938. /** @hidden */
  111939. _unIndexed: boolean;
  111940. /** @hidden */
  111941. _lightSources: Light[];
  111942. /** Gets the list of lights affecting that mesh */
  111943. get lightSources(): Light[];
  111944. /** @hidden */
  111945. get _positions(): Nullable<Vector3[]>;
  111946. /** @hidden */
  111947. _waitingData: {
  111948. lods: Nullable<any>;
  111949. actions: Nullable<any>;
  111950. freezeWorldMatrix: Nullable<boolean>;
  111951. };
  111952. /** @hidden */
  111953. _bonesTransformMatrices: Nullable<Float32Array>;
  111954. /** @hidden */
  111955. _transformMatrixTexture: Nullable<RawTexture>;
  111956. /**
  111957. * Gets or sets a skeleton to apply skining transformations
  111958. * @see https://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  111959. */
  111960. set skeleton(value: Nullable<Skeleton>);
  111961. get skeleton(): Nullable<Skeleton>;
  111962. /**
  111963. * An event triggered when the mesh is rebuilt.
  111964. */
  111965. onRebuildObservable: Observable<AbstractMesh>;
  111966. /**
  111967. * Creates a new AbstractMesh
  111968. * @param name defines the name of the mesh
  111969. * @param scene defines the hosting scene
  111970. */
  111971. constructor(name: string, scene?: Nullable<Scene>);
  111972. /**
  111973. * Returns the string "AbstractMesh"
  111974. * @returns "AbstractMesh"
  111975. */
  111976. getClassName(): string;
  111977. /**
  111978. * Gets a string representation of the current mesh
  111979. * @param fullDetails defines a boolean indicating if full details must be included
  111980. * @returns a string representation of the current mesh
  111981. */
  111982. toString(fullDetails?: boolean): string;
  111983. /**
  111984. * @hidden
  111985. */
  111986. protected _getEffectiveParent(): Nullable<Node>;
  111987. /** @hidden */
  111988. _getActionManagerForTrigger(trigger?: number, initialCall?: boolean): Nullable<AbstractActionManager>;
  111989. /** @hidden */
  111990. _rebuild(): void;
  111991. /** @hidden */
  111992. _resyncLightSources(): void;
  111993. /** @hidden */
  111994. _resyncLightSource(light: Light): void;
  111995. /** @hidden */
  111996. _unBindEffect(): void;
  111997. /** @hidden */
  111998. _removeLightSource(light: Light, dispose: boolean): void;
  111999. private _markSubMeshesAsDirty;
  112000. /** @hidden */
  112001. _markSubMeshesAsLightDirty(dispose?: boolean): void;
  112002. /** @hidden */
  112003. _markSubMeshesAsAttributesDirty(): void;
  112004. /** @hidden */
  112005. _markSubMeshesAsMiscDirty(): void;
  112006. /**
  112007. * Gets or sets a Vector3 depicting the mesh scaling along each local axis X, Y, Z. Default is (1.0, 1.0, 1.0)
  112008. */
  112009. get scaling(): Vector3;
  112010. set scaling(newScaling: Vector3);
  112011. /**
  112012. * Returns true if the mesh is blocked. Implemented by child classes
  112013. */
  112014. get isBlocked(): boolean;
  112015. /**
  112016. * Returns the mesh itself by default. Implemented by child classes
  112017. * @param camera defines the camera to use to pick the right LOD level
  112018. * @returns the currentAbstractMesh
  112019. */
  112020. getLOD(camera: Camera): Nullable<AbstractMesh>;
  112021. /**
  112022. * Returns 0 by default. Implemented by child classes
  112023. * @returns an integer
  112024. */
  112025. getTotalVertices(): number;
  112026. /**
  112027. * Returns a positive integer : the total number of indices in this mesh geometry.
  112028. * @returns the numner of indices or zero if the mesh has no geometry.
  112029. */
  112030. getTotalIndices(): number;
  112031. /**
  112032. * Returns null by default. Implemented by child classes
  112033. * @returns null
  112034. */
  112035. getIndices(): Nullable<IndicesArray>;
  112036. /**
  112037. * Returns the array of the requested vertex data kind. Implemented by child classes
  112038. * @param kind defines the vertex data kind to use
  112039. * @returns null
  112040. */
  112041. getVerticesData(kind: string): Nullable<FloatArray>;
  112042. /**
  112043. * Sets the vertex data of the mesh geometry for the requested `kind`.
  112044. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  112045. * Note that a new underlying VertexBuffer object is created each call.
  112046. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  112047. * @param kind defines vertex data kind:
  112048. * * VertexBuffer.PositionKind
  112049. * * VertexBuffer.UVKind
  112050. * * VertexBuffer.UV2Kind
  112051. * * VertexBuffer.UV3Kind
  112052. * * VertexBuffer.UV4Kind
  112053. * * VertexBuffer.UV5Kind
  112054. * * VertexBuffer.UV6Kind
  112055. * * VertexBuffer.ColorKind
  112056. * * VertexBuffer.MatricesIndicesKind
  112057. * * VertexBuffer.MatricesIndicesExtraKind
  112058. * * VertexBuffer.MatricesWeightsKind
  112059. * * VertexBuffer.MatricesWeightsExtraKind
  112060. * @param data defines the data source
  112061. * @param updatable defines if the data must be flagged as updatable (or static)
  112062. * @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
  112063. * @returns the current mesh
  112064. */
  112065. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  112066. /**
  112067. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  112068. * If the mesh has no geometry, it is simply returned as it is.
  112069. * @param kind defines vertex data kind:
  112070. * * VertexBuffer.PositionKind
  112071. * * VertexBuffer.UVKind
  112072. * * VertexBuffer.UV2Kind
  112073. * * VertexBuffer.UV3Kind
  112074. * * VertexBuffer.UV4Kind
  112075. * * VertexBuffer.UV5Kind
  112076. * * VertexBuffer.UV6Kind
  112077. * * VertexBuffer.ColorKind
  112078. * * VertexBuffer.MatricesIndicesKind
  112079. * * VertexBuffer.MatricesIndicesExtraKind
  112080. * * VertexBuffer.MatricesWeightsKind
  112081. * * VertexBuffer.MatricesWeightsExtraKind
  112082. * @param data defines the data source
  112083. * @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
  112084. * @param makeItUnique If true, a new global geometry is created from this data and is set to the mesh
  112085. * @returns the current mesh
  112086. */
  112087. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): AbstractMesh;
  112088. /**
  112089. * Sets the mesh indices,
  112090. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  112091. * @param indices Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array)
  112092. * @param totalVertices Defines the total number of vertices
  112093. * @returns the current mesh
  112094. */
  112095. setIndices(indices: IndicesArray, totalVertices: Nullable<number>): AbstractMesh;
  112096. /**
  112097. * Gets a boolean indicating if specific vertex data is present
  112098. * @param kind defines the vertex data kind to use
  112099. * @returns true is data kind is present
  112100. */
  112101. isVerticesDataPresent(kind: string): boolean;
  112102. /**
  112103. * Returns the mesh BoundingInfo object or creates a new one and returns if it was undefined.
  112104. * Note that it returns a shallow bounding of the mesh (i.e. it does not include children).
  112105. * To get the full bounding of all children, call `getHierarchyBoundingVectors` instead.
  112106. * @returns a BoundingInfo
  112107. */
  112108. getBoundingInfo(): BoundingInfo;
  112109. /**
  112110. * Uniformly scales the mesh to fit inside of a unit cube (1 X 1 X 1 units)
  112111. * @param includeDescendants Use the hierarchy's bounding box instead of the mesh's bounding box. Default is false
  112112. * @param ignoreRotation ignore rotation when computing the scale (ie. object will be axis aligned). Default is false
  112113. * @param predicate predicate that is passed in to getHierarchyBoundingVectors when selecting which object should be included when scaling
  112114. * @returns the current mesh
  112115. */
  112116. normalizeToUnitCube(includeDescendants?: boolean, ignoreRotation?: boolean, predicate?: Nullable<(node: AbstractMesh) => boolean>): AbstractMesh;
  112117. /**
  112118. * Overwrite the current bounding info
  112119. * @param boundingInfo defines the new bounding info
  112120. * @returns the current mesh
  112121. */
  112122. setBoundingInfo(boundingInfo: BoundingInfo): AbstractMesh;
  112123. /** Gets a boolean indicating if this mesh has skinning data and an attached skeleton */
  112124. get useBones(): boolean;
  112125. /** @hidden */
  112126. _preActivate(): void;
  112127. /** @hidden */
  112128. _preActivateForIntermediateRendering(renderId: number): void;
  112129. /** @hidden */
  112130. _activate(renderId: number, intermediateRendering: boolean): boolean;
  112131. /** @hidden */
  112132. _postActivate(): void;
  112133. /** @hidden */
  112134. _freeze(): void;
  112135. /** @hidden */
  112136. _unFreeze(): void;
  112137. /**
  112138. * Gets the current world matrix
  112139. * @returns a Matrix
  112140. */
  112141. getWorldMatrix(): Matrix;
  112142. /** @hidden */
  112143. _getWorldMatrixDeterminant(): number;
  112144. /**
  112145. * Gets a boolean indicating if this mesh is an instance or a regular mesh
  112146. */
  112147. get isAnInstance(): boolean;
  112148. /**
  112149. * Gets a boolean indicating if this mesh has instances
  112150. */
  112151. get hasInstances(): boolean;
  112152. /**
  112153. * Gets a boolean indicating if this mesh has thin instances
  112154. */
  112155. get hasThinInstances(): boolean;
  112156. /**
  112157. * Perform relative position change from the point of view of behind the front of the mesh.
  112158. * This is performed taking into account the meshes current rotation, so you do not have to care.
  112159. * Supports definition of mesh facing forward or backward
  112160. * @param amountRight defines the distance on the right axis
  112161. * @param amountUp defines the distance on the up axis
  112162. * @param amountForward defines the distance on the forward axis
  112163. * @returns the current mesh
  112164. */
  112165. movePOV(amountRight: number, amountUp: number, amountForward: number): AbstractMesh;
  112166. /**
  112167. * Calculate relative position change from the point of view of behind the front of the mesh.
  112168. * This is performed taking into account the meshes current rotation, so you do not have to care.
  112169. * Supports definition of mesh facing forward or backward
  112170. * @param amountRight defines the distance on the right axis
  112171. * @param amountUp defines the distance on the up axis
  112172. * @param amountForward defines the distance on the forward axis
  112173. * @returns the new displacement vector
  112174. */
  112175. calcMovePOV(amountRight: number, amountUp: number, amountForward: number): Vector3;
  112176. /**
  112177. * Perform relative rotation change from the point of view of behind the front of the mesh.
  112178. * Supports definition of mesh facing forward or backward
  112179. * @param flipBack defines the flip
  112180. * @param twirlClockwise defines the twirl
  112181. * @param tiltRight defines the tilt
  112182. * @returns the current mesh
  112183. */
  112184. rotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): AbstractMesh;
  112185. /**
  112186. * Calculate relative rotation change from the point of view of behind the front of the mesh.
  112187. * Supports definition of mesh facing forward or backward.
  112188. * @param flipBack defines the flip
  112189. * @param twirlClockwise defines the twirl
  112190. * @param tiltRight defines the tilt
  112191. * @returns the new rotation vector
  112192. */
  112193. calcRotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): Vector3;
  112194. /**
  112195. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  112196. * This means the mesh underlying bounding box and sphere are recomputed.
  112197. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  112198. * @returns the current mesh
  112199. */
  112200. refreshBoundingInfo(applySkeleton?: boolean): AbstractMesh;
  112201. /** @hidden */
  112202. _refreshBoundingInfo(data: Nullable<FloatArray>, bias: Nullable<Vector2>): void;
  112203. /** @hidden */
  112204. _getPositionData(applySkeleton: boolean): Nullable<FloatArray>;
  112205. /** @hidden */
  112206. _updateBoundingInfo(): AbstractMesh;
  112207. /** @hidden */
  112208. _updateSubMeshesBoundingInfo(matrix: DeepImmutable<Matrix>): AbstractMesh;
  112209. /** @hidden */
  112210. protected _afterComputeWorldMatrix(): void;
  112211. /** @hidden */
  112212. get _effectiveMesh(): AbstractMesh;
  112213. /**
  112214. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  112215. * A mesh is in the frustum if its bounding box intersects the frustum
  112216. * @param frustumPlanes defines the frustum to test
  112217. * @returns true if the mesh is in the frustum planes
  112218. */
  112219. isInFrustum(frustumPlanes: Plane[]): boolean;
  112220. /**
  112221. * Returns `true` if the mesh is completely in the frustum defined be the passed array of planes.
  112222. * A mesh is completely in the frustum if its bounding box it completely inside the frustum.
  112223. * @param frustumPlanes defines the frustum to test
  112224. * @returns true if the mesh is completely in the frustum planes
  112225. */
  112226. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  112227. /**
  112228. * True if the mesh intersects another mesh or a SolidParticle object
  112229. * @param mesh defines a target mesh or SolidParticle to test
  112230. * @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)
  112231. * @param includeDescendants Can be set to true to test if the mesh defined in parameters intersects with the current mesh or any child meshes
  112232. * @returns true if there is an intersection
  112233. */
  112234. intersectsMesh(mesh: AbstractMesh | SolidParticle, precise?: boolean, includeDescendants?: boolean): boolean;
  112235. /**
  112236. * Returns true if the passed point (Vector3) is inside the mesh bounding box
  112237. * @param point defines the point to test
  112238. * @returns true if there is an intersection
  112239. */
  112240. intersectsPoint(point: Vector3): boolean;
  112241. /**
  112242. * Gets or sets a boolean indicating that this mesh can be used in the collision engine
  112243. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  112244. */
  112245. get checkCollisions(): boolean;
  112246. set checkCollisions(collisionEnabled: boolean);
  112247. /**
  112248. * Gets Collider object used to compute collisions (not physics)
  112249. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  112250. */
  112251. get collider(): Nullable<Collider>;
  112252. /**
  112253. * Move the mesh using collision engine
  112254. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  112255. * @param displacement defines the requested displacement vector
  112256. * @returns the current mesh
  112257. */
  112258. moveWithCollisions(displacement: Vector3): AbstractMesh;
  112259. private _onCollisionPositionChange;
  112260. /** @hidden */
  112261. _collideForSubMesh(subMesh: SubMesh, transformMatrix: Matrix, collider: Collider): AbstractMesh;
  112262. /** @hidden */
  112263. _processCollisionsForSubMeshes(collider: Collider, transformMatrix: Matrix): AbstractMesh;
  112264. /** @hidden */
  112265. _checkCollision(collider: Collider): AbstractMesh;
  112266. /** @hidden */
  112267. _generatePointsArray(): boolean;
  112268. /**
  112269. * Checks if the passed Ray intersects with the mesh
  112270. * @param ray defines the ray to use
  112271. * @param fastCheck defines if fast mode (but less precise) must be used (false by default)
  112272. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  112273. * @param onlyBoundingInfo defines a boolean indicating if picking should only happen using bounding info (false by default)
  112274. * @param worldToUse defines the world matrix to use to get the world coordinate of the intersection point
  112275. * @returns the picking info
  112276. * @see https://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  112277. */
  112278. intersects(ray: Ray, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate, onlyBoundingInfo?: boolean, worldToUse?: Matrix): PickingInfo;
  112279. /**
  112280. * Clones the current mesh
  112281. * @param name defines the mesh name
  112282. * @param newParent defines the new mesh parent
  112283. * @param doNotCloneChildren defines a boolean indicating that children must not be cloned (false by default)
  112284. * @returns the new mesh
  112285. */
  112286. clone(name: string, newParent: Nullable<Node>, doNotCloneChildren?: boolean): Nullable<AbstractMesh>;
  112287. /**
  112288. * Disposes all the submeshes of the current meshnp
  112289. * @returns the current mesh
  112290. */
  112291. releaseSubMeshes(): AbstractMesh;
  112292. /**
  112293. * Releases resources associated with this abstract mesh.
  112294. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  112295. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  112296. */
  112297. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  112298. /**
  112299. * Adds the passed mesh as a child to the current mesh
  112300. * @param mesh defines the child mesh
  112301. * @returns the current mesh
  112302. */
  112303. addChild(mesh: AbstractMesh): AbstractMesh;
  112304. /**
  112305. * Removes the passed mesh from the current mesh children list
  112306. * @param mesh defines the child mesh
  112307. * @returns the current mesh
  112308. */
  112309. removeChild(mesh: AbstractMesh): AbstractMesh;
  112310. /** @hidden */
  112311. private _initFacetData;
  112312. /**
  112313. * Updates the mesh facetData arrays and the internal partitioning when the mesh is morphed or updated.
  112314. * This method can be called within the render loop.
  112315. * 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
  112316. * @returns the current mesh
  112317. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  112318. */
  112319. updateFacetData(): AbstractMesh;
  112320. /**
  112321. * Returns the facetLocalNormals array.
  112322. * The normals are expressed in the mesh local spac
  112323. * @returns an array of Vector3
  112324. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  112325. */
  112326. getFacetLocalNormals(): Vector3[];
  112327. /**
  112328. * Returns the facetLocalPositions array.
  112329. * The facet positions are expressed in the mesh local space
  112330. * @returns an array of Vector3
  112331. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  112332. */
  112333. getFacetLocalPositions(): Vector3[];
  112334. /**
  112335. * Returns the facetLocalPartioning array
  112336. * @returns an array of array of numbers
  112337. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  112338. */
  112339. getFacetLocalPartitioning(): number[][];
  112340. /**
  112341. * Returns the i-th facet position in the world system.
  112342. * This method allocates a new Vector3 per call
  112343. * @param i defines the facet index
  112344. * @returns a new Vector3
  112345. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  112346. */
  112347. getFacetPosition(i: number): Vector3;
  112348. /**
  112349. * Sets the reference Vector3 with the i-th facet position in the world system
  112350. * @param i defines the facet index
  112351. * @param ref defines the target vector
  112352. * @returns the current mesh
  112353. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  112354. */
  112355. getFacetPositionToRef(i: number, ref: Vector3): AbstractMesh;
  112356. /**
  112357. * Returns the i-th facet normal in the world system.
  112358. * This method allocates a new Vector3 per call
  112359. * @param i defines the facet index
  112360. * @returns a new Vector3
  112361. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  112362. */
  112363. getFacetNormal(i: number): Vector3;
  112364. /**
  112365. * Sets the reference Vector3 with the i-th facet normal in the world system
  112366. * @param i defines the facet index
  112367. * @param ref defines the target vector
  112368. * @returns the current mesh
  112369. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  112370. */
  112371. getFacetNormalToRef(i: number, ref: Vector3): this;
  112372. /**
  112373. * 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)
  112374. * @param x defines x coordinate
  112375. * @param y defines y coordinate
  112376. * @param z defines z coordinate
  112377. * @returns the array of facet indexes
  112378. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  112379. */
  112380. getFacetsAtLocalCoordinates(x: number, y: number, z: number): Nullable<number[]>;
  112381. /**
  112382. * Returns the closest mesh facet index at (x,y,z) World coordinates, null if not found
  112383. * @param projected sets as the (x,y,z) world projection on the facet
  112384. * @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
  112385. * @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
  112386. * @param x defines x coordinate
  112387. * @param y defines y coordinate
  112388. * @param z defines z coordinate
  112389. * @returns the face index if found (or null instead)
  112390. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  112391. */
  112392. getClosestFacetAtCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  112393. /**
  112394. * Returns the closest mesh facet index at (x,y,z) local coordinates, null if not found
  112395. * @param projected sets as the (x,y,z) local projection on the facet
  112396. * @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
  112397. * @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
  112398. * @param x defines x coordinate
  112399. * @param y defines y coordinate
  112400. * @param z defines z coordinate
  112401. * @returns the face index if found (or null instead)
  112402. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  112403. */
  112404. getClosestFacetAtLocalCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  112405. /**
  112406. * Returns the object "parameter" set with all the expected parameters for facetData computation by ComputeNormals()
  112407. * @returns the parameters
  112408. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  112409. */
  112410. getFacetDataParameters(): any;
  112411. /**
  112412. * Disables the feature FacetData and frees the related memory
  112413. * @returns the current mesh
  112414. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  112415. */
  112416. disableFacetData(): AbstractMesh;
  112417. /**
  112418. * Updates the AbstractMesh indices array
  112419. * @param indices defines the data source
  112420. * @param offset defines the offset in the index buffer where to store the new data (can be null)
  112421. * @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)
  112422. * @returns the current mesh
  112423. */
  112424. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): AbstractMesh;
  112425. /**
  112426. * Creates new normals data for the mesh
  112427. * @param updatable defines if the normal vertex buffer must be flagged as updatable
  112428. * @returns the current mesh
  112429. */
  112430. createNormals(updatable: boolean): AbstractMesh;
  112431. /**
  112432. * Align the mesh with a normal
  112433. * @param normal defines the normal to use
  112434. * @param upDirection can be used to redefined the up vector to use (will use the (0, 1, 0) by default)
  112435. * @returns the current mesh
  112436. */
  112437. alignWithNormal(normal: Vector3, upDirection?: Vector3): AbstractMesh;
  112438. /** @hidden */
  112439. _checkOcclusionQuery(): boolean;
  112440. /**
  112441. * Disables the mesh edge rendering mode
  112442. * @returns the currentAbstractMesh
  112443. */
  112444. disableEdgesRendering(): AbstractMesh;
  112445. /**
  112446. * Enables the edge rendering mode on the mesh.
  112447. * This mode makes the mesh edges visible
  112448. * @param epsilon defines the maximal distance between two angles to detect a face
  112449. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  112450. * @returns the currentAbstractMesh
  112451. * @see https://www.babylonjs-playground.com/#19O9TU#0
  112452. */
  112453. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): AbstractMesh;
  112454. /**
  112455. * This function returns all of the particle systems in the scene that use the mesh as an emitter.
  112456. * @returns an array of particle systems in the scene that use the mesh as an emitter
  112457. */
  112458. getConnectedParticleSystems(): IParticleSystem[];
  112459. }
  112460. }
  112461. declare module BABYLON {
  112462. /**
  112463. * Interface used to define ActionEvent
  112464. */
  112465. export interface IActionEvent {
  112466. /** The mesh or sprite that triggered the action */
  112467. source: any;
  112468. /** The X mouse cursor position at the time of the event */
  112469. pointerX: number;
  112470. /** The Y mouse cursor position at the time of the event */
  112471. pointerY: number;
  112472. /** The mesh that is currently pointed at (can be null) */
  112473. meshUnderPointer: Nullable<AbstractMesh>;
  112474. /** the original (browser) event that triggered the ActionEvent */
  112475. sourceEvent?: any;
  112476. /** additional data for the event */
  112477. additionalData?: any;
  112478. }
  112479. /**
  112480. * ActionEvent is the event being sent when an action is triggered.
  112481. */
  112482. export class ActionEvent implements IActionEvent {
  112483. /** The mesh or sprite that triggered the action */
  112484. source: any;
  112485. /** The X mouse cursor position at the time of the event */
  112486. pointerX: number;
  112487. /** The Y mouse cursor position at the time of the event */
  112488. pointerY: number;
  112489. /** The mesh that is currently pointed at (can be null) */
  112490. meshUnderPointer: Nullable<AbstractMesh>;
  112491. /** the original (browser) event that triggered the ActionEvent */
  112492. sourceEvent?: any;
  112493. /** additional data for the event */
  112494. additionalData?: any;
  112495. /**
  112496. * Creates a new ActionEvent
  112497. * @param source The mesh or sprite that triggered the action
  112498. * @param pointerX The X mouse cursor position at the time of the event
  112499. * @param pointerY The Y mouse cursor position at the time of the event
  112500. * @param meshUnderPointer The mesh that is currently pointed at (can be null)
  112501. * @param sourceEvent the original (browser) event that triggered the ActionEvent
  112502. * @param additionalData additional data for the event
  112503. */
  112504. constructor(
  112505. /** The mesh or sprite that triggered the action */
  112506. source: any,
  112507. /** The X mouse cursor position at the time of the event */
  112508. pointerX: number,
  112509. /** The Y mouse cursor position at the time of the event */
  112510. pointerY: number,
  112511. /** The mesh that is currently pointed at (can be null) */
  112512. meshUnderPointer: Nullable<AbstractMesh>,
  112513. /** the original (browser) event that triggered the ActionEvent */
  112514. sourceEvent?: any,
  112515. /** additional data for the event */
  112516. additionalData?: any);
  112517. /**
  112518. * Helper function to auto-create an ActionEvent from a source mesh.
  112519. * @param source The source mesh that triggered the event
  112520. * @param evt The original (browser) event
  112521. * @param additionalData additional data for the event
  112522. * @returns the new ActionEvent
  112523. */
  112524. static CreateNew(source: AbstractMesh, evt?: Event, additionalData?: any): ActionEvent;
  112525. /**
  112526. * Helper function to auto-create an ActionEvent from a source sprite
  112527. * @param source The source sprite that triggered the event
  112528. * @param scene Scene associated with the sprite
  112529. * @param evt The original (browser) event
  112530. * @param additionalData additional data for the event
  112531. * @returns the new ActionEvent
  112532. */
  112533. static CreateNewFromSprite(source: Sprite, scene: Scene, evt?: Event, additionalData?: any): ActionEvent;
  112534. /**
  112535. * Helper function to auto-create an ActionEvent from a scene. If triggered by a mesh use ActionEvent.CreateNew
  112536. * @param scene the scene where the event occurred
  112537. * @param evt The original (browser) event
  112538. * @returns the new ActionEvent
  112539. */
  112540. static CreateNewFromScene(scene: Scene, evt: Event): ActionEvent;
  112541. /**
  112542. * Helper function to auto-create an ActionEvent from a primitive
  112543. * @param prim defines the target primitive
  112544. * @param pointerPos defines the pointer position
  112545. * @param evt The original (browser) event
  112546. * @param additionalData additional data for the event
  112547. * @returns the new ActionEvent
  112548. */
  112549. static CreateNewFromPrimitive(prim: any, pointerPos: Vector2, evt?: Event, additionalData?: any): ActionEvent;
  112550. }
  112551. }
  112552. declare module BABYLON {
  112553. /**
  112554. * Abstract class used to decouple action Manager from scene and meshes.
  112555. * Do not instantiate.
  112556. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  112557. */
  112558. export abstract class AbstractActionManager implements IDisposable {
  112559. /** Gets the list of active triggers */
  112560. static Triggers: {
  112561. [key: string]: number;
  112562. };
  112563. /** Gets the cursor to use when hovering items */
  112564. hoverCursor: string;
  112565. /** Gets the list of actions */
  112566. actions: IAction[];
  112567. /**
  112568. * Gets or sets a boolean indicating that the manager is recursive meaning that it can trigger action from children
  112569. */
  112570. isRecursive: boolean;
  112571. /**
  112572. * Releases all associated resources
  112573. */
  112574. abstract dispose(): void;
  112575. /**
  112576. * Does this action manager has pointer triggers
  112577. */
  112578. abstract get hasPointerTriggers(): boolean;
  112579. /**
  112580. * Does this action manager has pick triggers
  112581. */
  112582. abstract get hasPickTriggers(): boolean;
  112583. /**
  112584. * Process a specific trigger
  112585. * @param trigger defines the trigger to process
  112586. * @param evt defines the event details to be processed
  112587. */
  112588. abstract processTrigger(trigger: number, evt?: IActionEvent): void;
  112589. /**
  112590. * Does this action manager handles actions of any of the given triggers
  112591. * @param triggers defines the triggers to be tested
  112592. * @return a boolean indicating whether one (or more) of the triggers is handled
  112593. */
  112594. abstract hasSpecificTriggers(triggers: number[]): boolean;
  112595. /**
  112596. * Does this action manager handles actions of any of the given triggers. This function takes two arguments for
  112597. * speed.
  112598. * @param triggerA defines the trigger to be tested
  112599. * @param triggerB defines the trigger to be tested
  112600. * @return a boolean indicating whether one (or more) of the triggers is handled
  112601. */
  112602. abstract hasSpecificTriggers2(triggerA: number, triggerB: number): boolean;
  112603. /**
  112604. * Does this action manager handles actions of a given trigger
  112605. * @param trigger defines the trigger to be tested
  112606. * @param parameterPredicate defines an optional predicate to filter triggers by parameter
  112607. * @return whether the trigger is handled
  112608. */
  112609. abstract hasSpecificTrigger(trigger: number, parameterPredicate?: (parameter: any) => boolean): boolean;
  112610. /**
  112611. * Serialize this manager to a JSON object
  112612. * @param name defines the property name to store this manager
  112613. * @returns a JSON representation of this manager
  112614. */
  112615. abstract serialize(name: string): any;
  112616. /**
  112617. * Registers an action to this action manager
  112618. * @param action defines the action to be registered
  112619. * @return the action amended (prepared) after registration
  112620. */
  112621. abstract registerAction(action: IAction): Nullable<IAction>;
  112622. /**
  112623. * Unregisters an action to this action manager
  112624. * @param action defines the action to be unregistered
  112625. * @return a boolean indicating whether the action has been unregistered
  112626. */
  112627. abstract unregisterAction(action: IAction): Boolean;
  112628. /**
  112629. * Does exist one action manager with at least one trigger
  112630. **/
  112631. static get HasTriggers(): boolean;
  112632. /**
  112633. * Does exist one action manager with at least one pick trigger
  112634. **/
  112635. static get HasPickTriggers(): boolean;
  112636. /**
  112637. * Does exist one action manager that handles actions of a given trigger
  112638. * @param trigger defines the trigger to be tested
  112639. * @return a boolean indicating whether the trigger is handeled by at least one action manager
  112640. **/
  112641. static HasSpecificTrigger(trigger: number): boolean;
  112642. }
  112643. }
  112644. declare module BABYLON {
  112645. /**
  112646. * Defines how a node can be built from a string name.
  112647. */
  112648. export type NodeConstructor = (name: string, scene: Scene, options?: any) => () => Node;
  112649. /**
  112650. * Node is the basic class for all scene objects (Mesh, Light, Camera.)
  112651. */
  112652. export class Node implements IBehaviorAware<Node> {
  112653. /** @hidden */
  112654. static _AnimationRangeFactory: (name: string, from: number, to: number) => AnimationRange;
  112655. private static _NodeConstructors;
  112656. /**
  112657. * Add a new node constructor
  112658. * @param type defines the type name of the node to construct
  112659. * @param constructorFunc defines the constructor function
  112660. */
  112661. static AddNodeConstructor(type: string, constructorFunc: NodeConstructor): void;
  112662. /**
  112663. * Returns a node constructor based on type name
  112664. * @param type defines the type name
  112665. * @param name defines the new node name
  112666. * @param scene defines the hosting scene
  112667. * @param options defines optional options to transmit to constructors
  112668. * @returns the new constructor or null
  112669. */
  112670. static Construct(type: string, name: string, scene: Scene, options?: any): Nullable<() => Node>;
  112671. /**
  112672. * Gets or sets the name of the node
  112673. */
  112674. name: string;
  112675. /**
  112676. * Gets or sets the id of the node
  112677. */
  112678. id: string;
  112679. /**
  112680. * Gets or sets the unique id of the node
  112681. */
  112682. uniqueId: number;
  112683. /**
  112684. * Gets or sets a string used to store user defined state for the node
  112685. */
  112686. state: string;
  112687. /**
  112688. * Gets or sets an object used to store user defined information for the node
  112689. */
  112690. metadata: any;
  112691. /**
  112692. * For internal use only. Please do not use.
  112693. */
  112694. reservedDataStore: any;
  112695. /**
  112696. * List of inspectable custom properties (used by the Inspector)
  112697. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  112698. */
  112699. inspectableCustomProperties: IInspectable[];
  112700. private _doNotSerialize;
  112701. /**
  112702. * Gets or sets a boolean used to define if the node must be serialized
  112703. */
  112704. get doNotSerialize(): boolean;
  112705. set doNotSerialize(value: boolean);
  112706. /** @hidden */
  112707. _isDisposed: boolean;
  112708. /**
  112709. * Gets a list of Animations associated with the node
  112710. */
  112711. animations: Animation[];
  112712. protected _ranges: {
  112713. [name: string]: Nullable<AnimationRange>;
  112714. };
  112715. /**
  112716. * Callback raised when the node is ready to be used
  112717. */
  112718. onReady: Nullable<(node: Node) => void>;
  112719. private _isEnabled;
  112720. private _isParentEnabled;
  112721. private _isReady;
  112722. /** @hidden */
  112723. _currentRenderId: number;
  112724. private _parentUpdateId;
  112725. /** @hidden */
  112726. _childUpdateId: number;
  112727. /** @hidden */
  112728. _waitingParentId: Nullable<string>;
  112729. /** @hidden */
  112730. _scene: Scene;
  112731. /** @hidden */
  112732. _cache: any;
  112733. private _parentNode;
  112734. private _children;
  112735. /** @hidden */
  112736. _worldMatrix: Matrix;
  112737. /** @hidden */
  112738. _worldMatrixDeterminant: number;
  112739. /** @hidden */
  112740. _worldMatrixDeterminantIsDirty: boolean;
  112741. /** @hidden */
  112742. private _sceneRootNodesIndex;
  112743. /**
  112744. * Gets a boolean indicating if the node has been disposed
  112745. * @returns true if the node was disposed
  112746. */
  112747. isDisposed(): boolean;
  112748. /**
  112749. * Gets or sets the parent of the node (without keeping the current position in the scene)
  112750. * @see https://doc.babylonjs.com/how_to/parenting
  112751. */
  112752. set parent(parent: Nullable<Node>);
  112753. get parent(): Nullable<Node>;
  112754. /** @hidden */
  112755. _addToSceneRootNodes(): void;
  112756. /** @hidden */
  112757. _removeFromSceneRootNodes(): void;
  112758. private _animationPropertiesOverride;
  112759. /**
  112760. * Gets or sets the animation properties override
  112761. */
  112762. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  112763. set animationPropertiesOverride(value: Nullable<AnimationPropertiesOverride>);
  112764. /**
  112765. * Gets a string identifying the name of the class
  112766. * @returns "Node" string
  112767. */
  112768. getClassName(): string;
  112769. /** @hidden */
  112770. readonly _isNode: boolean;
  112771. /**
  112772. * An event triggered when the mesh is disposed
  112773. */
  112774. onDisposeObservable: Observable<Node>;
  112775. private _onDisposeObserver;
  112776. /**
  112777. * Sets a callback that will be raised when the node will be disposed
  112778. */
  112779. set onDispose(callback: () => void);
  112780. /**
  112781. * Creates a new Node
  112782. * @param name the name and id to be given to this node
  112783. * @param scene the scene this node will be added to
  112784. */
  112785. constructor(name: string, scene?: Nullable<Scene>);
  112786. /**
  112787. * Gets the scene of the node
  112788. * @returns a scene
  112789. */
  112790. getScene(): Scene;
  112791. /**
  112792. * Gets the engine of the node
  112793. * @returns a Engine
  112794. */
  112795. getEngine(): Engine;
  112796. private _behaviors;
  112797. /**
  112798. * Attach a behavior to the node
  112799. * @see https://doc.babylonjs.com/features/behaviour
  112800. * @param behavior defines the behavior to attach
  112801. * @param attachImmediately defines that the behavior must be attached even if the scene is still loading
  112802. * @returns the current Node
  112803. */
  112804. addBehavior(behavior: Behavior<Node>, attachImmediately?: boolean): Node;
  112805. /**
  112806. * Remove an attached behavior
  112807. * @see https://doc.babylonjs.com/features/behaviour
  112808. * @param behavior defines the behavior to attach
  112809. * @returns the current Node
  112810. */
  112811. removeBehavior(behavior: Behavior<Node>): Node;
  112812. /**
  112813. * Gets the list of attached behaviors
  112814. * @see https://doc.babylonjs.com/features/behaviour
  112815. */
  112816. get behaviors(): Behavior<Node>[];
  112817. /**
  112818. * Gets an attached behavior by name
  112819. * @param name defines the name of the behavior to look for
  112820. * @see https://doc.babylonjs.com/features/behaviour
  112821. * @returns null if behavior was not found else the requested behavior
  112822. */
  112823. getBehaviorByName(name: string): Nullable<Behavior<Node>>;
  112824. /**
  112825. * Returns the latest update of the World matrix
  112826. * @returns a Matrix
  112827. */
  112828. getWorldMatrix(): Matrix;
  112829. /** @hidden */
  112830. _getWorldMatrixDeterminant(): number;
  112831. /**
  112832. * Returns directly the latest state of the mesh World matrix.
  112833. * A Matrix is returned.
  112834. */
  112835. get worldMatrixFromCache(): Matrix;
  112836. /** @hidden */
  112837. _initCache(): void;
  112838. /** @hidden */
  112839. updateCache(force?: boolean): void;
  112840. /** @hidden */
  112841. _getActionManagerForTrigger(trigger?: number, initialCall?: boolean): Nullable<AbstractActionManager>;
  112842. /** @hidden */
  112843. _updateCache(ignoreParentClass?: boolean): void;
  112844. /** @hidden */
  112845. _isSynchronized(): boolean;
  112846. /** @hidden */
  112847. _markSyncedWithParent(): void;
  112848. /** @hidden */
  112849. isSynchronizedWithParent(): boolean;
  112850. /** @hidden */
  112851. isSynchronized(): boolean;
  112852. /**
  112853. * Is this node ready to be used/rendered
  112854. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  112855. * @return true if the node is ready
  112856. */
  112857. isReady(completeCheck?: boolean): boolean;
  112858. /**
  112859. * Is this node enabled?
  112860. * 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
  112861. * @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
  112862. * @return whether this node (and its parent) is enabled
  112863. */
  112864. isEnabled(checkAncestors?: boolean): boolean;
  112865. /** @hidden */
  112866. protected _syncParentEnabledState(): void;
  112867. /**
  112868. * Set the enabled state of this node
  112869. * @param value defines the new enabled state
  112870. */
  112871. setEnabled(value: boolean): void;
  112872. /**
  112873. * Is this node a descendant of the given node?
  112874. * The function will iterate up the hierarchy until the ancestor was found or no more parents defined
  112875. * @param ancestor defines the parent node to inspect
  112876. * @returns a boolean indicating if this node is a descendant of the given node
  112877. */
  112878. isDescendantOf(ancestor: Node): boolean;
  112879. /** @hidden */
  112880. _getDescendants(results: Node[], directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): void;
  112881. /**
  112882. * Will return all nodes that have this node as ascendant
  112883. * @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
  112884. * @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
  112885. * @return all children nodes of all types
  112886. */
  112887. getDescendants(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): Node[];
  112888. /**
  112889. * Get all child-meshes of this node
  112890. * @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)
  112891. * @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
  112892. * @returns an array of AbstractMesh
  112893. */
  112894. getChildMeshes(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): AbstractMesh[];
  112895. /**
  112896. * Get all direct children of this node
  112897. * @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
  112898. * @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)
  112899. * @returns an array of Node
  112900. */
  112901. getChildren(predicate?: (node: Node) => boolean, directDescendantsOnly?: boolean): Node[];
  112902. /** @hidden */
  112903. _setReady(state: boolean): void;
  112904. /**
  112905. * Get an animation by name
  112906. * @param name defines the name of the animation to look for
  112907. * @returns null if not found else the requested animation
  112908. */
  112909. getAnimationByName(name: string): Nullable<Animation>;
  112910. /**
  112911. * Creates an animation range for this node
  112912. * @param name defines the name of the range
  112913. * @param from defines the starting key
  112914. * @param to defines the end key
  112915. */
  112916. createAnimationRange(name: string, from: number, to: number): void;
  112917. /**
  112918. * Delete a specific animation range
  112919. * @param name defines the name of the range to delete
  112920. * @param deleteFrames defines if animation frames from the range must be deleted as well
  112921. */
  112922. deleteAnimationRange(name: string, deleteFrames?: boolean): void;
  112923. /**
  112924. * Get an animation range by name
  112925. * @param name defines the name of the animation range to look for
  112926. * @returns null if not found else the requested animation range
  112927. */
  112928. getAnimationRange(name: string): Nullable<AnimationRange>;
  112929. /**
  112930. * Gets the list of all animation ranges defined on this node
  112931. * @returns an array
  112932. */
  112933. getAnimationRanges(): Nullable<AnimationRange>[];
  112934. /**
  112935. * Will start the animation sequence
  112936. * @param name defines the range frames for animation sequence
  112937. * @param loop defines if the animation should loop (false by default)
  112938. * @param speedRatio defines the speed factor in which to run the animation (1 by default)
  112939. * @param onAnimationEnd defines a function to be executed when the animation ended (undefined by default)
  112940. * @returns the object created for this animation. If range does not exist, it will return null
  112941. */
  112942. beginAnimation(name: string, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Nullable<Animatable>;
  112943. /**
  112944. * Serialize animation ranges into a JSON compatible object
  112945. * @returns serialization object
  112946. */
  112947. serializeAnimationRanges(): any;
  112948. /**
  112949. * Computes the world matrix of the node
  112950. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  112951. * @returns the world matrix
  112952. */
  112953. computeWorldMatrix(force?: boolean): Matrix;
  112954. /**
  112955. * Releases resources associated with this node.
  112956. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  112957. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  112958. */
  112959. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  112960. /**
  112961. * Parse animation range data from a serialization object and store them into a given node
  112962. * @param node defines where to store the animation ranges
  112963. * @param parsedNode defines the serialization object to read data from
  112964. * @param scene defines the hosting scene
  112965. */
  112966. static ParseAnimationRanges(node: Node, parsedNode: any, scene: Scene): void;
  112967. /**
  112968. * Return the minimum and maximum world vectors of the entire hierarchy under current node
  112969. * @param includeDescendants Include bounding info from descendants as well (true by default)
  112970. * @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
  112971. * @returns the new bounding vectors
  112972. */
  112973. getHierarchyBoundingVectors(includeDescendants?: boolean, predicate?: Nullable<(abstractMesh: AbstractMesh) => boolean>): {
  112974. min: Vector3;
  112975. max: Vector3;
  112976. };
  112977. }
  112978. }
  112979. declare module BABYLON {
  112980. /**
  112981. * @hidden
  112982. */
  112983. export class _IAnimationState {
  112984. key: number;
  112985. repeatCount: number;
  112986. workValue?: any;
  112987. loopMode?: number;
  112988. offsetValue?: any;
  112989. highLimitValue?: any;
  112990. }
  112991. /**
  112992. * Class used to store any kind of animation
  112993. */
  112994. export class Animation {
  112995. /**Name of the animation */
  112996. name: string;
  112997. /**Property to animate */
  112998. targetProperty: string;
  112999. /**The frames per second of the animation */
  113000. framePerSecond: number;
  113001. /**The data type of the animation */
  113002. dataType: number;
  113003. /**The loop mode of the animation */
  113004. loopMode?: number | undefined;
  113005. /**Specifies if blending should be enabled */
  113006. enableBlending?: boolean | undefined;
  113007. /**
  113008. * Use matrix interpolation instead of using direct key value when animating matrices
  113009. */
  113010. static AllowMatricesInterpolation: boolean;
  113011. /**
  113012. * When matrix interpolation is enabled, this boolean forces the system to use Matrix.DecomposeLerp instead of Matrix.Lerp. Interpolation is more precise but slower
  113013. */
  113014. static AllowMatrixDecomposeForInterpolation: boolean;
  113015. /** Define the Url to load snippets */
  113016. static SnippetUrl: string;
  113017. /** Snippet ID if the animation was created from the snippet server */
  113018. snippetId: string;
  113019. /**
  113020. * Stores the key frames of the animation
  113021. */
  113022. private _keys;
  113023. /**
  113024. * Stores the easing function of the animation
  113025. */
  113026. private _easingFunction;
  113027. /**
  113028. * @hidden Internal use only
  113029. */
  113030. _runtimeAnimations: RuntimeAnimation[];
  113031. /**
  113032. * The set of event that will be linked to this animation
  113033. */
  113034. private _events;
  113035. /**
  113036. * Stores an array of target property paths
  113037. */
  113038. targetPropertyPath: string[];
  113039. /**
  113040. * Stores the blending speed of the animation
  113041. */
  113042. blendingSpeed: number;
  113043. /**
  113044. * Stores the animation ranges for the animation
  113045. */
  113046. private _ranges;
  113047. /**
  113048. * @hidden Internal use
  113049. */
  113050. static _PrepareAnimation(name: string, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction): Nullable<Animation>;
  113051. /**
  113052. * Sets up an animation
  113053. * @param property The property to animate
  113054. * @param animationType The animation type to apply
  113055. * @param framePerSecond The frames per second of the animation
  113056. * @param easingFunction The easing function used in the animation
  113057. * @returns The created animation
  113058. */
  113059. static CreateAnimation(property: string, animationType: number, framePerSecond: number, easingFunction: EasingFunction): Animation;
  113060. /**
  113061. * Create and start an animation on a node
  113062. * @param name defines the name of the global animation that will be run on all nodes
  113063. * @param node defines the root node where the animation will take place
  113064. * @param targetProperty defines property to animate
  113065. * @param framePerSecond defines the number of frame per second yo use
  113066. * @param totalFrame defines the number of frames in total
  113067. * @param from defines the initial value
  113068. * @param to defines the final value
  113069. * @param loopMode defines which loop mode you want to use (off by default)
  113070. * @param easingFunction defines the easing function to use (linear by default)
  113071. * @param onAnimationEnd defines the callback to call when animation end
  113072. * @returns the animatable created for this animation
  113073. */
  113074. static CreateAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  113075. /**
  113076. * Create and start an animation on a node and its descendants
  113077. * @param name defines the name of the global animation that will be run on all nodes
  113078. * @param node defines the root node where the animation will take place
  113079. * @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
  113080. * @param targetProperty defines property to animate
  113081. * @param framePerSecond defines the number of frame per second to use
  113082. * @param totalFrame defines the number of frames in total
  113083. * @param from defines the initial value
  113084. * @param to defines the final value
  113085. * @param loopMode defines which loop mode you want to use (off by default)
  113086. * @param easingFunction defines the easing function to use (linear by default)
  113087. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  113088. * @returns the list of animatables created for all nodes
  113089. * @example https://www.babylonjs-playground.com/#MH0VLI
  113090. */
  113091. 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[]>;
  113092. /**
  113093. * Creates a new animation, merges it with the existing animations and starts it
  113094. * @param name Name of the animation
  113095. * @param node Node which contains the scene that begins the animations
  113096. * @param targetProperty Specifies which property to animate
  113097. * @param framePerSecond The frames per second of the animation
  113098. * @param totalFrame The total number of frames
  113099. * @param from The frame at the beginning of the animation
  113100. * @param to The frame at the end of the animation
  113101. * @param loopMode Specifies the loop mode of the animation
  113102. * @param easingFunction (Optional) The easing function of the animation, which allow custom mathematical formulas for animations
  113103. * @param onAnimationEnd Callback to run once the animation is complete
  113104. * @returns Nullable animation
  113105. */
  113106. static CreateMergeAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  113107. /**
  113108. * Convert the keyframes for all animations belonging to the group to be relative to a given reference frame.
  113109. * @param sourceAnimation defines the Animation containing keyframes to convert
  113110. * @param referenceFrame defines the frame that keyframes in the range will be relative to
  113111. * @param range defines the name of the AnimationRange belonging to the Animation to convert
  113112. * @param cloneOriginal defines whether or not to clone the animation and convert the clone or convert the original animation (default is false)
  113113. * @param clonedName defines the name of the resulting cloned Animation if cloneOriginal is true
  113114. * @returns a new Animation if cloneOriginal is true or the original Animation if cloneOriginal is false
  113115. */
  113116. static MakeAnimationAdditive(sourceAnimation: Animation, referenceFrame?: number, range?: string, cloneOriginal?: boolean, clonedName?: string): Animation;
  113117. /**
  113118. * Transition property of an host to the target Value
  113119. * @param property The property to transition
  113120. * @param targetValue The target Value of the property
  113121. * @param host The object where the property to animate belongs
  113122. * @param scene Scene used to run the animation
  113123. * @param frameRate Framerate (in frame/s) to use
  113124. * @param transition The transition type we want to use
  113125. * @param duration The duration of the animation, in milliseconds
  113126. * @param onAnimationEnd Callback trigger at the end of the animation
  113127. * @returns Nullable animation
  113128. */
  113129. static TransitionTo(property: string, targetValue: any, host: any, scene: Scene, frameRate: number, transition: Animation, duration: number, onAnimationEnd?: Nullable<() => void>): Nullable<Animatable>;
  113130. /**
  113131. * Return the array of runtime animations currently using this animation
  113132. */
  113133. get runtimeAnimations(): RuntimeAnimation[];
  113134. /**
  113135. * Specifies if any of the runtime animations are currently running
  113136. */
  113137. get hasRunningRuntimeAnimations(): boolean;
  113138. /**
  113139. * Initializes the animation
  113140. * @param name Name of the animation
  113141. * @param targetProperty Property to animate
  113142. * @param framePerSecond The frames per second of the animation
  113143. * @param dataType The data type of the animation
  113144. * @param loopMode The loop mode of the animation
  113145. * @param enableBlending Specifies if blending should be enabled
  113146. */
  113147. constructor(
  113148. /**Name of the animation */
  113149. name: string,
  113150. /**Property to animate */
  113151. targetProperty: string,
  113152. /**The frames per second of the animation */
  113153. framePerSecond: number,
  113154. /**The data type of the animation */
  113155. dataType: number,
  113156. /**The loop mode of the animation */
  113157. loopMode?: number | undefined,
  113158. /**Specifies if blending should be enabled */
  113159. enableBlending?: boolean | undefined);
  113160. /**
  113161. * Converts the animation to a string
  113162. * @param fullDetails support for multiple levels of logging within scene loading
  113163. * @returns String form of the animation
  113164. */
  113165. toString(fullDetails?: boolean): string;
  113166. /**
  113167. * Add an event to this animation
  113168. * @param event Event to add
  113169. */
  113170. addEvent(event: AnimationEvent): void;
  113171. /**
  113172. * Remove all events found at the given frame
  113173. * @param frame The frame to remove events from
  113174. */
  113175. removeEvents(frame: number): void;
  113176. /**
  113177. * Retrieves all the events from the animation
  113178. * @returns Events from the animation
  113179. */
  113180. getEvents(): AnimationEvent[];
  113181. /**
  113182. * Creates an animation range
  113183. * @param name Name of the animation range
  113184. * @param from Starting frame of the animation range
  113185. * @param to Ending frame of the animation
  113186. */
  113187. createRange(name: string, from: number, to: number): void;
  113188. /**
  113189. * Deletes an animation range by name
  113190. * @param name Name of the animation range to delete
  113191. * @param deleteFrames Specifies if the key frames for the range should also be deleted (true) or not (false)
  113192. */
  113193. deleteRange(name: string, deleteFrames?: boolean): void;
  113194. /**
  113195. * Gets the animation range by name, or null if not defined
  113196. * @param name Name of the animation range
  113197. * @returns Nullable animation range
  113198. */
  113199. getRange(name: string): Nullable<AnimationRange>;
  113200. /**
  113201. * Gets the key frames from the animation
  113202. * @returns The key frames of the animation
  113203. */
  113204. getKeys(): Array<IAnimationKey>;
  113205. /**
  113206. * Gets the highest frame rate of the animation
  113207. * @returns Highest frame rate of the animation
  113208. */
  113209. getHighestFrame(): number;
  113210. /**
  113211. * Gets the easing function of the animation
  113212. * @returns Easing function of the animation
  113213. */
  113214. getEasingFunction(): IEasingFunction;
  113215. /**
  113216. * Sets the easing function of the animation
  113217. * @param easingFunction A custom mathematical formula for animation
  113218. */
  113219. setEasingFunction(easingFunction: EasingFunction): void;
  113220. /**
  113221. * Interpolates a scalar linearly
  113222. * @param startValue Start value of the animation curve
  113223. * @param endValue End value of the animation curve
  113224. * @param gradient Scalar amount to interpolate
  113225. * @returns Interpolated scalar value
  113226. */
  113227. floatInterpolateFunction(startValue: number, endValue: number, gradient: number): number;
  113228. /**
  113229. * Interpolates a scalar cubically
  113230. * @param startValue Start value of the animation curve
  113231. * @param outTangent End tangent of the animation
  113232. * @param endValue End value of the animation curve
  113233. * @param inTangent Start tangent of the animation curve
  113234. * @param gradient Scalar amount to interpolate
  113235. * @returns Interpolated scalar value
  113236. */
  113237. floatInterpolateFunctionWithTangents(startValue: number, outTangent: number, endValue: number, inTangent: number, gradient: number): number;
  113238. /**
  113239. * Interpolates a quaternion using a spherical linear interpolation
  113240. * @param startValue Start value of the animation curve
  113241. * @param endValue End value of the animation curve
  113242. * @param gradient Scalar amount to interpolate
  113243. * @returns Interpolated quaternion value
  113244. */
  113245. quaternionInterpolateFunction(startValue: Quaternion, endValue: Quaternion, gradient: number): Quaternion;
  113246. /**
  113247. * Interpolates a quaternion cubically
  113248. * @param startValue Start value of the animation curve
  113249. * @param outTangent End tangent of the animation curve
  113250. * @param endValue End value of the animation curve
  113251. * @param inTangent Start tangent of the animation curve
  113252. * @param gradient Scalar amount to interpolate
  113253. * @returns Interpolated quaternion value
  113254. */
  113255. quaternionInterpolateFunctionWithTangents(startValue: Quaternion, outTangent: Quaternion, endValue: Quaternion, inTangent: Quaternion, gradient: number): Quaternion;
  113256. /**
  113257. * Interpolates a Vector3 linearl
  113258. * @param startValue Start value of the animation curve
  113259. * @param endValue End value of the animation curve
  113260. * @param gradient Scalar amount to interpolate
  113261. * @returns Interpolated scalar value
  113262. */
  113263. vector3InterpolateFunction(startValue: Vector3, endValue: Vector3, gradient: number): Vector3;
  113264. /**
  113265. * Interpolates a Vector3 cubically
  113266. * @param startValue Start value of the animation curve
  113267. * @param outTangent End tangent of the animation
  113268. * @param endValue End value of the animation curve
  113269. * @param inTangent Start tangent of the animation curve
  113270. * @param gradient Scalar amount to interpolate
  113271. * @returns InterpolatedVector3 value
  113272. */
  113273. vector3InterpolateFunctionWithTangents(startValue: Vector3, outTangent: Vector3, endValue: Vector3, inTangent: Vector3, gradient: number): Vector3;
  113274. /**
  113275. * Interpolates a Vector2 linearly
  113276. * @param startValue Start value of the animation curve
  113277. * @param endValue End value of the animation curve
  113278. * @param gradient Scalar amount to interpolate
  113279. * @returns Interpolated Vector2 value
  113280. */
  113281. vector2InterpolateFunction(startValue: Vector2, endValue: Vector2, gradient: number): Vector2;
  113282. /**
  113283. * Interpolates a Vector2 cubically
  113284. * @param startValue Start value of the animation curve
  113285. * @param outTangent End tangent of the animation
  113286. * @param endValue End value of the animation curve
  113287. * @param inTangent Start tangent of the animation curve
  113288. * @param gradient Scalar amount to interpolate
  113289. * @returns Interpolated Vector2 value
  113290. */
  113291. vector2InterpolateFunctionWithTangents(startValue: Vector2, outTangent: Vector2, endValue: Vector2, inTangent: Vector2, gradient: number): Vector2;
  113292. /**
  113293. * Interpolates a size linearly
  113294. * @param startValue Start value of the animation curve
  113295. * @param endValue End value of the animation curve
  113296. * @param gradient Scalar amount to interpolate
  113297. * @returns Interpolated Size value
  113298. */
  113299. sizeInterpolateFunction(startValue: Size, endValue: Size, gradient: number): Size;
  113300. /**
  113301. * Interpolates a Color3 linearly
  113302. * @param startValue Start value of the animation curve
  113303. * @param endValue End value of the animation curve
  113304. * @param gradient Scalar amount to interpolate
  113305. * @returns Interpolated Color3 value
  113306. */
  113307. color3InterpolateFunction(startValue: Color3, endValue: Color3, gradient: number): Color3;
  113308. /**
  113309. * Interpolates a Color4 linearly
  113310. * @param startValue Start value of the animation curve
  113311. * @param endValue End value of the animation curve
  113312. * @param gradient Scalar amount to interpolate
  113313. * @returns Interpolated Color3 value
  113314. */
  113315. color4InterpolateFunction(startValue: Color4, endValue: Color4, gradient: number): Color4;
  113316. /**
  113317. * @hidden Internal use only
  113318. */
  113319. _getKeyValue(value: any): any;
  113320. /**
  113321. * @hidden Internal use only
  113322. */
  113323. _interpolate(currentFrame: number, state: _IAnimationState): any;
  113324. /**
  113325. * Defines the function to use to interpolate matrices
  113326. * @param startValue defines the start matrix
  113327. * @param endValue defines the end matrix
  113328. * @param gradient defines the gradient between both matrices
  113329. * @param result defines an optional target matrix where to store the interpolation
  113330. * @returns the interpolated matrix
  113331. */
  113332. matrixInterpolateFunction(startValue: Matrix, endValue: Matrix, gradient: number, result?: Matrix): Matrix;
  113333. /**
  113334. * Makes a copy of the animation
  113335. * @returns Cloned animation
  113336. */
  113337. clone(): Animation;
  113338. /**
  113339. * Sets the key frames of the animation
  113340. * @param values The animation key frames to set
  113341. */
  113342. setKeys(values: Array<IAnimationKey>): void;
  113343. /**
  113344. * Serializes the animation to an object
  113345. * @returns Serialized object
  113346. */
  113347. serialize(): any;
  113348. /**
  113349. * Float animation type
  113350. */
  113351. static readonly ANIMATIONTYPE_FLOAT: number;
  113352. /**
  113353. * Vector3 animation type
  113354. */
  113355. static readonly ANIMATIONTYPE_VECTOR3: number;
  113356. /**
  113357. * Quaternion animation type
  113358. */
  113359. static readonly ANIMATIONTYPE_QUATERNION: number;
  113360. /**
  113361. * Matrix animation type
  113362. */
  113363. static readonly ANIMATIONTYPE_MATRIX: number;
  113364. /**
  113365. * Color3 animation type
  113366. */
  113367. static readonly ANIMATIONTYPE_COLOR3: number;
  113368. /**
  113369. * Color3 animation type
  113370. */
  113371. static readonly ANIMATIONTYPE_COLOR4: number;
  113372. /**
  113373. * Vector2 animation type
  113374. */
  113375. static readonly ANIMATIONTYPE_VECTOR2: number;
  113376. /**
  113377. * Size animation type
  113378. */
  113379. static readonly ANIMATIONTYPE_SIZE: number;
  113380. /**
  113381. * Relative Loop Mode
  113382. */
  113383. static readonly ANIMATIONLOOPMODE_RELATIVE: number;
  113384. /**
  113385. * Cycle Loop Mode
  113386. */
  113387. static readonly ANIMATIONLOOPMODE_CYCLE: number;
  113388. /**
  113389. * Constant Loop Mode
  113390. */
  113391. static readonly ANIMATIONLOOPMODE_CONSTANT: number;
  113392. /** @hidden */
  113393. static _UniversalLerp(left: any, right: any, amount: number): any;
  113394. /**
  113395. * Parses an animation object and creates an animation
  113396. * @param parsedAnimation Parsed animation object
  113397. * @returns Animation object
  113398. */
  113399. static Parse(parsedAnimation: any): Animation;
  113400. /**
  113401. * Appends the serialized animations from the source animations
  113402. * @param source Source containing the animations
  113403. * @param destination Target to store the animations
  113404. */
  113405. static AppendSerializedAnimations(source: IAnimatable, destination: any): void;
  113406. /**
  113407. * Creates a new animation or an array of animations from a snippet saved in a remote file
  113408. * @param name defines the name of the animation to create (can be null or empty to use the one from the json data)
  113409. * @param url defines the url to load from
  113410. * @returns a promise that will resolve to the new animation or an array of animations
  113411. */
  113412. static ParseFromFileAsync(name: Nullable<string>, url: string): Promise<Animation | Array<Animation>>;
  113413. /**
  113414. * Creates an animation or an array of animations from a snippet saved by the Inspector
  113415. * @param snippetId defines the snippet to load
  113416. * @returns a promise that will resolve to the new animation or a new array of animations
  113417. */
  113418. static CreateFromSnippetAsync(snippetId: string): Promise<Animation | Array<Animation>>;
  113419. }
  113420. }
  113421. declare module BABYLON {
  113422. /**
  113423. * Interface containing an array of animations
  113424. */
  113425. export interface IAnimatable {
  113426. /**
  113427. * Array of animations
  113428. */
  113429. animations: Nullable<Array<Animation>>;
  113430. }
  113431. }
  113432. declare module BABYLON {
  113433. export function expandToProperty(callback: string, targetKey?: Nullable<string>): (target: any, propertyKey: string) => void;
  113434. export function serialize(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  113435. export function serializeAsTexture(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  113436. export function serializeAsColor3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  113437. export function serializeAsFresnelParameters(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  113438. export function serializeAsVector2(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  113439. export function serializeAsVector3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  113440. export function serializeAsMeshReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  113441. export function serializeAsColorCurves(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  113442. export function serializeAsColor4(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  113443. export function serializeAsImageProcessingConfiguration(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  113444. export function serializeAsQuaternion(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  113445. export function serializeAsMatrix(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  113446. /**
  113447. * Decorator used to define property that can be serialized as reference to a camera
  113448. * @param sourceName defines the name of the property to decorate
  113449. */
  113450. export function serializeAsCameraReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  113451. /**
  113452. * Class used to help serialization objects
  113453. */
  113454. export class SerializationHelper {
  113455. /** @hidden */
  113456. static _ImageProcessingConfigurationParser: (sourceProperty: any) => ImageProcessingConfiguration;
  113457. /** @hidden */
  113458. static _FresnelParametersParser: (sourceProperty: any) => FresnelParameters;
  113459. /** @hidden */
  113460. static _ColorCurvesParser: (sourceProperty: any) => ColorCurves;
  113461. /** @hidden */
  113462. static _TextureParser: (sourceProperty: any, scene: Scene, rootUrl: string) => Nullable<BaseTexture>;
  113463. /**
  113464. * Appends the serialized animations from the source animations
  113465. * @param source Source containing the animations
  113466. * @param destination Target to store the animations
  113467. */
  113468. static AppendSerializedAnimations(source: IAnimatable, destination: any): void;
  113469. /**
  113470. * Static function used to serialized a specific entity
  113471. * @param entity defines the entity to serialize
  113472. * @param serializationObject defines the optional target obecjt where serialization data will be stored
  113473. * @returns a JSON compatible object representing the serialization of the entity
  113474. */
  113475. static Serialize<T>(entity: T, serializationObject?: any): any;
  113476. /**
  113477. * Creates a new entity from a serialization data object
  113478. * @param creationFunction defines a function used to instanciated the new entity
  113479. * @param source defines the source serialization data
  113480. * @param scene defines the hosting scene
  113481. * @param rootUrl defines the root url for resources
  113482. * @returns a new entity
  113483. */
  113484. static Parse<T>(creationFunction: () => T, source: any, scene: Nullable<Scene>, rootUrl?: Nullable<string>): T;
  113485. /**
  113486. * Clones an object
  113487. * @param creationFunction defines the function used to instanciate the new object
  113488. * @param source defines the source object
  113489. * @returns the cloned object
  113490. */
  113491. static Clone<T>(creationFunction: () => T, source: T): T;
  113492. /**
  113493. * Instanciates a new object based on a source one (some data will be shared between both object)
  113494. * @param creationFunction defines the function used to instanciate the new object
  113495. * @param source defines the source object
  113496. * @returns the new object
  113497. */
  113498. static Instanciate<T>(creationFunction: () => T, source: T): T;
  113499. }
  113500. }
  113501. declare module BABYLON {
  113502. /**
  113503. * Base class of all the textures in babylon.
  113504. * It groups all the common properties the materials, post process, lights... might need
  113505. * in order to make a correct use of the texture.
  113506. */
  113507. export class BaseTexture implements IAnimatable {
  113508. /**
  113509. * Default anisotropic filtering level for the application.
  113510. * It is set to 4 as a good tradeoff between perf and quality.
  113511. */
  113512. static DEFAULT_ANISOTROPIC_FILTERING_LEVEL: number;
  113513. /**
  113514. * Gets or sets the unique id of the texture
  113515. */
  113516. uniqueId: number;
  113517. /**
  113518. * Define the name of the texture.
  113519. */
  113520. name: string;
  113521. /**
  113522. * Gets or sets an object used to store user defined information.
  113523. */
  113524. metadata: any;
  113525. /**
  113526. * For internal use only. Please do not use.
  113527. */
  113528. reservedDataStore: any;
  113529. private _hasAlpha;
  113530. /**
  113531. * Define if the texture is having a usable alpha value (can be use for transparency or glossiness for instance).
  113532. */
  113533. set hasAlpha(value: boolean);
  113534. get hasAlpha(): boolean;
  113535. /**
  113536. * Defines if the alpha value should be determined via the rgb values.
  113537. * If true the luminance of the pixel might be used to find the corresponding alpha value.
  113538. */
  113539. getAlphaFromRGB: boolean;
  113540. /**
  113541. * Intensity or strength of the texture.
  113542. * It is commonly used by materials to fine tune the intensity of the texture
  113543. */
  113544. level: number;
  113545. /**
  113546. * Define the UV chanel to use starting from 0 and defaulting to 0.
  113547. * This is part of the texture as textures usually maps to one uv set.
  113548. */
  113549. coordinatesIndex: number;
  113550. protected _coordinatesMode: number;
  113551. /**
  113552. * How a texture is mapped.
  113553. *
  113554. * | Value | Type | Description |
  113555. * | ----- | ----------------------------------- | ----------- |
  113556. * | 0 | EXPLICIT_MODE | |
  113557. * | 1 | SPHERICAL_MODE | |
  113558. * | 2 | PLANAR_MODE | |
  113559. * | 3 | CUBIC_MODE | |
  113560. * | 4 | PROJECTION_MODE | |
  113561. * | 5 | SKYBOX_MODE | |
  113562. * | 6 | INVCUBIC_MODE | |
  113563. * | 7 | EQUIRECTANGULAR_MODE | |
  113564. * | 8 | FIXED_EQUIRECTANGULAR_MODE | |
  113565. * | 9 | FIXED_EQUIRECTANGULAR_MIRRORED_MODE | |
  113566. */
  113567. set coordinatesMode(value: number);
  113568. get coordinatesMode(): number;
  113569. private _wrapU;
  113570. /**
  113571. * | Value | Type | Description |
  113572. * | ----- | ------------------ | ----------- |
  113573. * | 0 | CLAMP_ADDRESSMODE | |
  113574. * | 1 | WRAP_ADDRESSMODE | |
  113575. * | 2 | MIRROR_ADDRESSMODE | |
  113576. */
  113577. get wrapU(): number;
  113578. set wrapU(value: number);
  113579. private _wrapV;
  113580. /**
  113581. * | Value | Type | Description |
  113582. * | ----- | ------------------ | ----------- |
  113583. * | 0 | CLAMP_ADDRESSMODE | |
  113584. * | 1 | WRAP_ADDRESSMODE | |
  113585. * | 2 | MIRROR_ADDRESSMODE | |
  113586. */
  113587. get wrapV(): number;
  113588. set wrapV(value: number);
  113589. /**
  113590. * | Value | Type | Description |
  113591. * | ----- | ------------------ | ----------- |
  113592. * | 0 | CLAMP_ADDRESSMODE | |
  113593. * | 1 | WRAP_ADDRESSMODE | |
  113594. * | 2 | MIRROR_ADDRESSMODE | |
  113595. */
  113596. wrapR: number;
  113597. /**
  113598. * With compliant hardware and browser (supporting anisotropic filtering)
  113599. * this defines the level of anisotropic filtering in the texture.
  113600. * The higher the better but the slower. This defaults to 4 as it seems to be the best tradeoff.
  113601. */
  113602. anisotropicFilteringLevel: number;
  113603. /**
  113604. * Define if the texture is a cube texture or if false a 2d texture.
  113605. */
  113606. get isCube(): boolean;
  113607. set isCube(value: boolean);
  113608. /**
  113609. * Define if the texture is a 3d texture (webgl 2) or if false a 2d texture.
  113610. */
  113611. get is3D(): boolean;
  113612. set is3D(value: boolean);
  113613. /**
  113614. * Define if the texture is a 2d array texture (webgl 2) or if false a 2d texture.
  113615. */
  113616. get is2DArray(): boolean;
  113617. set is2DArray(value: boolean);
  113618. /**
  113619. * Define if the texture contains data in gamma space (most of the png/jpg aside bump).
  113620. * HDR texture are usually stored in linear space.
  113621. * This only impacts the PBR and Background materials
  113622. */
  113623. gammaSpace: boolean;
  113624. /**
  113625. * Gets or sets whether or not the texture contains RGBD data.
  113626. */
  113627. get isRGBD(): boolean;
  113628. set isRGBD(value: boolean);
  113629. /**
  113630. * Is Z inverted in the texture (useful in a cube texture).
  113631. */
  113632. invertZ: boolean;
  113633. /**
  113634. * Are mip maps generated for this texture or not.
  113635. */
  113636. get noMipmap(): boolean;
  113637. /**
  113638. * @hidden
  113639. */
  113640. lodLevelInAlpha: boolean;
  113641. /**
  113642. * With prefiltered texture, defined the offset used during the prefiltering steps.
  113643. */
  113644. get lodGenerationOffset(): number;
  113645. set lodGenerationOffset(value: number);
  113646. /**
  113647. * With prefiltered texture, defined the scale used during the prefiltering steps.
  113648. */
  113649. get lodGenerationScale(): number;
  113650. set lodGenerationScale(value: number);
  113651. /**
  113652. * With prefiltered texture, defined if the specular generation is based on a linear ramp.
  113653. * By default we are using a log2 of the linear roughness helping to keep a better resolution for
  113654. * average roughness values.
  113655. */
  113656. get linearSpecularLOD(): boolean;
  113657. set linearSpecularLOD(value: boolean);
  113658. /**
  113659. * In case a better definition than spherical harmonics is required for the diffuse part of the environment.
  113660. * You can set the irradiance texture to rely on a texture instead of the spherical approach.
  113661. * This texture need to have the same characteristics than its parent (Cube vs 2d, coordinates mode, Gamma/Linear, RGBD).
  113662. */
  113663. get irradianceTexture(): Nullable<BaseTexture>;
  113664. set irradianceTexture(value: Nullable<BaseTexture>);
  113665. /**
  113666. * Define if the texture is a render target.
  113667. */
  113668. isRenderTarget: boolean;
  113669. /**
  113670. * Define the unique id of the texture in the scene.
  113671. */
  113672. get uid(): string;
  113673. /** @hidden */
  113674. _prefiltered: boolean;
  113675. /**
  113676. * Return a string representation of the texture.
  113677. * @returns the texture as a string
  113678. */
  113679. toString(): string;
  113680. /**
  113681. * Get the class name of the texture.
  113682. * @returns "BaseTexture"
  113683. */
  113684. getClassName(): string;
  113685. /**
  113686. * Define the list of animation attached to the texture.
  113687. */
  113688. animations: Animation[];
  113689. /**
  113690. * An event triggered when the texture is disposed.
  113691. */
  113692. onDisposeObservable: Observable<BaseTexture>;
  113693. private _onDisposeObserver;
  113694. /**
  113695. * Callback triggered when the texture has been disposed.
  113696. * Kept for back compatibility, you can use the onDisposeObservable instead.
  113697. */
  113698. set onDispose(callback: () => void);
  113699. /**
  113700. * Define the current state of the loading sequence when in delayed load mode.
  113701. */
  113702. delayLoadState: number;
  113703. protected _scene: Nullable<Scene>;
  113704. protected _engine: Nullable<ThinEngine>;
  113705. /** @hidden */
  113706. _texture: Nullable<InternalTexture>;
  113707. private _uid;
  113708. /**
  113709. * Define if the texture is preventinga material to render or not.
  113710. * If not and the texture is not ready, the engine will use a default black texture instead.
  113711. */
  113712. get isBlocking(): boolean;
  113713. /**
  113714. * Instantiates a new BaseTexture.
  113715. * Base class of all the textures in babylon.
  113716. * It groups all the common properties the materials, post process, lights... might need
  113717. * in order to make a correct use of the texture.
  113718. * @param sceneOrEngine Define the scene or engine the texture blongs to
  113719. */
  113720. constructor(sceneOrEngine: Nullable<Scene | ThinEngine>);
  113721. /**
  113722. * Get the scene the texture belongs to.
  113723. * @returns the scene or null if undefined
  113724. */
  113725. getScene(): Nullable<Scene>;
  113726. /** @hidden */
  113727. protected _getEngine(): Nullable<ThinEngine>;
  113728. /**
  113729. * Get the texture transform matrix used to offset tile the texture for istance.
  113730. * @returns the transformation matrix
  113731. */
  113732. getTextureMatrix(): Matrix;
  113733. /**
  113734. * Get the texture reflection matrix used to rotate/transform the reflection.
  113735. * @returns the reflection matrix
  113736. */
  113737. getReflectionTextureMatrix(): Matrix;
  113738. /**
  113739. * Get the underlying lower level texture from Babylon.
  113740. * @returns the insternal texture
  113741. */
  113742. getInternalTexture(): Nullable<InternalTexture>;
  113743. /**
  113744. * Get if the texture is ready to be consumed (either it is ready or it is not blocking)
  113745. * @returns true if ready or not blocking
  113746. */
  113747. isReadyOrNotBlocking(): boolean;
  113748. /**
  113749. * Get if the texture is ready to be used (downloaded, converted, mip mapped...).
  113750. * @returns true if fully ready
  113751. */
  113752. isReady(): boolean;
  113753. private _cachedSize;
  113754. /**
  113755. * Get the size of the texture.
  113756. * @returns the texture size.
  113757. */
  113758. getSize(): ISize;
  113759. /**
  113760. * Get the base size of the texture.
  113761. * It can be different from the size if the texture has been resized for POT for instance
  113762. * @returns the base size
  113763. */
  113764. getBaseSize(): ISize;
  113765. /**
  113766. * Update the sampling mode of the texture.
  113767. * Default is Trilinear mode.
  113768. *
  113769. * | Value | Type | Description |
  113770. * | ----- | ------------------ | ----------- |
  113771. * | 1 | NEAREST_SAMPLINGMODE or NEAREST_NEAREST_MIPLINEAR | Nearest is: mag = nearest, min = nearest, mip = linear |
  113772. * | 2 | BILINEAR_SAMPLINGMODE or LINEAR_LINEAR_MIPNEAREST | Bilinear is: mag = linear, min = linear, mip = nearest |
  113773. * | 3 | TRILINEAR_SAMPLINGMODE or LINEAR_LINEAR_MIPLINEAR | Trilinear is: mag = linear, min = linear, mip = linear |
  113774. * | 4 | NEAREST_NEAREST_MIPNEAREST | |
  113775. * | 5 | NEAREST_LINEAR_MIPNEAREST | |
  113776. * | 6 | NEAREST_LINEAR_MIPLINEAR | |
  113777. * | 7 | NEAREST_LINEAR | |
  113778. * | 8 | NEAREST_NEAREST | |
  113779. * | 9 | LINEAR_NEAREST_MIPNEAREST | |
  113780. * | 10 | LINEAR_NEAREST_MIPLINEAR | |
  113781. * | 11 | LINEAR_LINEAR | |
  113782. * | 12 | LINEAR_NEAREST | |
  113783. *
  113784. * > _mag_: magnification filter (close to the viewer)
  113785. * > _min_: minification filter (far from the viewer)
  113786. * > _mip_: filter used between mip map levels
  113787. *@param samplingMode Define the new sampling mode of the texture
  113788. */
  113789. updateSamplingMode(samplingMode: number): void;
  113790. /**
  113791. * Scales the texture if is `canRescale()`
  113792. * @param ratio the resize factor we want to use to rescale
  113793. */
  113794. scale(ratio: number): void;
  113795. /**
  113796. * Get if the texture can rescale.
  113797. */
  113798. get canRescale(): boolean;
  113799. /** @hidden */
  113800. _getFromCache(url: Nullable<string>, noMipmap: boolean, sampling?: number, invertY?: boolean): Nullable<InternalTexture>;
  113801. /** @hidden */
  113802. _rebuild(): void;
  113803. /**
  113804. * Triggers the load sequence in delayed load mode.
  113805. */
  113806. delayLoad(): void;
  113807. /**
  113808. * Clones the texture.
  113809. * @returns the cloned texture
  113810. */
  113811. clone(): Nullable<BaseTexture>;
  113812. /**
  113813. * Get the texture underlying type (INT, FLOAT...)
  113814. */
  113815. get textureType(): number;
  113816. /**
  113817. * Get the texture underlying format (RGB, RGBA...)
  113818. */
  113819. get textureFormat(): number;
  113820. /**
  113821. * Indicates that textures need to be re-calculated for all materials
  113822. */
  113823. protected _markAllSubMeshesAsTexturesDirty(): void;
  113824. /**
  113825. * Reads the pixels stored in the webgl texture and returns them as an ArrayBuffer.
  113826. * This will returns an RGBA array buffer containing either in values (0-255) or
  113827. * float values (0-1) depending of the underlying buffer type.
  113828. * @param faceIndex defines the face of the texture to read (in case of cube texture)
  113829. * @param level defines the LOD level of the texture to read (in case of Mip Maps)
  113830. * @param buffer defines a user defined buffer to fill with data (can be null)
  113831. * @returns The Array buffer containing the pixels data.
  113832. */
  113833. readPixels(faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>): Nullable<ArrayBufferView>;
  113834. /**
  113835. * Release and destroy the underlying lower level texture aka internalTexture.
  113836. */
  113837. releaseInternalTexture(): void;
  113838. /** @hidden */
  113839. get _lodTextureHigh(): Nullable<BaseTexture>;
  113840. /** @hidden */
  113841. get _lodTextureMid(): Nullable<BaseTexture>;
  113842. /** @hidden */
  113843. get _lodTextureLow(): Nullable<BaseTexture>;
  113844. /**
  113845. * Dispose the texture and release its associated resources.
  113846. */
  113847. dispose(): void;
  113848. /**
  113849. * Serialize the texture into a JSON representation that can be parsed later on.
  113850. * @returns the JSON representation of the texture
  113851. */
  113852. serialize(): any;
  113853. /**
  113854. * Helper function to be called back once a list of texture contains only ready textures.
  113855. * @param textures Define the list of textures to wait for
  113856. * @param callback Define the callback triggered once the entire list will be ready
  113857. */
  113858. static WhenAllReady(textures: BaseTexture[], callback: () => void): void;
  113859. private static _isScene;
  113860. }
  113861. }
  113862. declare module BABYLON {
  113863. /**
  113864. * Options to be used when creating an effect.
  113865. */
  113866. export interface IEffectCreationOptions {
  113867. /**
  113868. * Atrributes that will be used in the shader.
  113869. */
  113870. attributes: string[];
  113871. /**
  113872. * Uniform varible names that will be set in the shader.
  113873. */
  113874. uniformsNames: string[];
  113875. /**
  113876. * Uniform buffer variable names that will be set in the shader.
  113877. */
  113878. uniformBuffersNames: string[];
  113879. /**
  113880. * Sampler texture variable names that will be set in the shader.
  113881. */
  113882. samplers: string[];
  113883. /**
  113884. * Define statements that will be set in the shader.
  113885. */
  113886. defines: any;
  113887. /**
  113888. * Possible fallbacks for this effect to improve performance when needed.
  113889. */
  113890. fallbacks: Nullable<IEffectFallbacks>;
  113891. /**
  113892. * Callback that will be called when the shader is compiled.
  113893. */
  113894. onCompiled: Nullable<(effect: Effect) => void>;
  113895. /**
  113896. * Callback that will be called if an error occurs during shader compilation.
  113897. */
  113898. onError: Nullable<(effect: Effect, errors: string) => void>;
  113899. /**
  113900. * Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  113901. */
  113902. indexParameters?: any;
  113903. /**
  113904. * Max number of lights that can be used in the shader.
  113905. */
  113906. maxSimultaneousLights?: number;
  113907. /**
  113908. * See https://developer.mozilla.org/en-US/docs/Web/API/WebGL2RenderingContext/transformFeedbackVaryings
  113909. */
  113910. transformFeedbackVaryings?: Nullable<string[]>;
  113911. /**
  113912. * 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
  113913. */
  113914. processFinalCode?: Nullable<(shaderType: string, code: string) => string>;
  113915. /**
  113916. * Is this effect rendering to several color attachments ?
  113917. */
  113918. multiTarget?: boolean;
  113919. }
  113920. /**
  113921. * Effect containing vertex and fragment shader that can be executed on an object.
  113922. */
  113923. export class Effect implements IDisposable {
  113924. /**
  113925. * Gets or sets the relative url used to load shaders if using the engine in non-minified mode
  113926. */
  113927. static ShadersRepository: string;
  113928. /**
  113929. * Enable logging of the shader code when a compilation error occurs
  113930. */
  113931. static LogShaderCodeOnCompilationError: boolean;
  113932. /**
  113933. * Name of the effect.
  113934. */
  113935. name: any;
  113936. /**
  113937. * String container all the define statements that should be set on the shader.
  113938. */
  113939. defines: string;
  113940. /**
  113941. * Callback that will be called when the shader is compiled.
  113942. */
  113943. onCompiled: Nullable<(effect: Effect) => void>;
  113944. /**
  113945. * Callback that will be called if an error occurs during shader compilation.
  113946. */
  113947. onError: Nullable<(effect: Effect, errors: string) => void>;
  113948. /**
  113949. * Callback that will be called when effect is bound.
  113950. */
  113951. onBind: Nullable<(effect: Effect) => void>;
  113952. /**
  113953. * Unique ID of the effect.
  113954. */
  113955. uniqueId: number;
  113956. /**
  113957. * Observable that will be called when the shader is compiled.
  113958. * It is recommended to use executeWhenCompile() or to make sure that scene.isReady() is called to get this observable raised.
  113959. */
  113960. onCompileObservable: Observable<Effect>;
  113961. /**
  113962. * Observable that will be called if an error occurs during shader compilation.
  113963. */
  113964. onErrorObservable: Observable<Effect>;
  113965. /** @hidden */
  113966. _onBindObservable: Nullable<Observable<Effect>>;
  113967. /**
  113968. * @hidden
  113969. * Specifies if the effect was previously ready
  113970. */
  113971. _wasPreviouslyReady: boolean;
  113972. /**
  113973. * Observable that will be called when effect is bound.
  113974. */
  113975. get onBindObservable(): Observable<Effect>;
  113976. /** @hidden */
  113977. _bonesComputationForcedToCPU: boolean;
  113978. /** @hidden */
  113979. _multiTarget: boolean;
  113980. private static _uniqueIdSeed;
  113981. private _engine;
  113982. private _uniformBuffersNames;
  113983. private _uniformBuffersNamesList;
  113984. private _uniformsNames;
  113985. private _samplerList;
  113986. private _samplers;
  113987. private _isReady;
  113988. private _compilationError;
  113989. private _allFallbacksProcessed;
  113990. private _attributesNames;
  113991. private _attributes;
  113992. private _attributeLocationByName;
  113993. private _uniforms;
  113994. /**
  113995. * Key for the effect.
  113996. * @hidden
  113997. */
  113998. _key: string;
  113999. private _indexParameters;
  114000. private _fallbacks;
  114001. private _vertexSourceCode;
  114002. private _fragmentSourceCode;
  114003. private _vertexSourceCodeOverride;
  114004. private _fragmentSourceCodeOverride;
  114005. private _transformFeedbackVaryings;
  114006. /**
  114007. * Compiled shader to webGL program.
  114008. * @hidden
  114009. */
  114010. _pipelineContext: Nullable<IPipelineContext>;
  114011. private _valueCache;
  114012. private static _baseCache;
  114013. /**
  114014. * Instantiates an effect.
  114015. * An effect can be used to create/manage/execute vertex and fragment shaders.
  114016. * @param baseName Name of the effect.
  114017. * @param attributesNamesOrOptions List of attribute names that will be passed to the shader or set of all options to create the effect.
  114018. * @param uniformsNamesOrEngine List of uniform variable names that will be passed to the shader or the engine that will be used to render effect.
  114019. * @param samplers List of sampler variables that will be passed to the shader.
  114020. * @param engine Engine to be used to render the effect
  114021. * @param defines Define statements to be added to the shader.
  114022. * @param fallbacks Possible fallbacks for this effect to improve performance when needed.
  114023. * @param onCompiled Callback that will be called when the shader is compiled.
  114024. * @param onError Callback that will be called if an error occurs during shader compilation.
  114025. * @param indexParameters Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  114026. */
  114027. 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);
  114028. private _useFinalCode;
  114029. /**
  114030. * Unique key for this effect
  114031. */
  114032. get key(): string;
  114033. /**
  114034. * If the effect has been compiled and prepared.
  114035. * @returns if the effect is compiled and prepared.
  114036. */
  114037. isReady(): boolean;
  114038. private _isReadyInternal;
  114039. /**
  114040. * The engine the effect was initialized with.
  114041. * @returns the engine.
  114042. */
  114043. getEngine(): Engine;
  114044. /**
  114045. * The pipeline context for this effect
  114046. * @returns the associated pipeline context
  114047. */
  114048. getPipelineContext(): Nullable<IPipelineContext>;
  114049. /**
  114050. * The set of names of attribute variables for the shader.
  114051. * @returns An array of attribute names.
  114052. */
  114053. getAttributesNames(): string[];
  114054. /**
  114055. * Returns the attribute at the given index.
  114056. * @param index The index of the attribute.
  114057. * @returns The location of the attribute.
  114058. */
  114059. getAttributeLocation(index: number): number;
  114060. /**
  114061. * Returns the attribute based on the name of the variable.
  114062. * @param name of the attribute to look up.
  114063. * @returns the attribute location.
  114064. */
  114065. getAttributeLocationByName(name: string): number;
  114066. /**
  114067. * The number of attributes.
  114068. * @returns the numnber of attributes.
  114069. */
  114070. getAttributesCount(): number;
  114071. /**
  114072. * Gets the index of a uniform variable.
  114073. * @param uniformName of the uniform to look up.
  114074. * @returns the index.
  114075. */
  114076. getUniformIndex(uniformName: string): number;
  114077. /**
  114078. * Returns the attribute based on the name of the variable.
  114079. * @param uniformName of the uniform to look up.
  114080. * @returns the location of the uniform.
  114081. */
  114082. getUniform(uniformName: string): Nullable<WebGLUniformLocation>;
  114083. /**
  114084. * Returns an array of sampler variable names
  114085. * @returns The array of sampler variable names.
  114086. */
  114087. getSamplers(): string[];
  114088. /**
  114089. * Returns an array of uniform variable names
  114090. * @returns The array of uniform variable names.
  114091. */
  114092. getUniformNames(): string[];
  114093. /**
  114094. * Returns an array of uniform buffer variable names
  114095. * @returns The array of uniform buffer variable names.
  114096. */
  114097. getUniformBuffersNames(): string[];
  114098. /**
  114099. * Returns the index parameters used to create the effect
  114100. * @returns The index parameters object
  114101. */
  114102. getIndexParameters(): any;
  114103. /**
  114104. * The error from the last compilation.
  114105. * @returns the error string.
  114106. */
  114107. getCompilationError(): string;
  114108. /**
  114109. * Gets a boolean indicating that all fallbacks were used during compilation
  114110. * @returns true if all fallbacks were used
  114111. */
  114112. allFallbacksProcessed(): boolean;
  114113. /**
  114114. * Adds a callback to the onCompiled observable and call the callback imediatly if already ready.
  114115. * @param func The callback to be used.
  114116. */
  114117. executeWhenCompiled(func: (effect: Effect) => void): void;
  114118. private _checkIsReady;
  114119. private _loadShader;
  114120. /**
  114121. * Gets the vertex shader source code of this effect
  114122. */
  114123. get vertexSourceCode(): string;
  114124. /**
  114125. * Gets the fragment shader source code of this effect
  114126. */
  114127. get fragmentSourceCode(): string;
  114128. /**
  114129. * Recompiles the webGL program
  114130. * @param vertexSourceCode The source code for the vertex shader.
  114131. * @param fragmentSourceCode The source code for the fragment shader.
  114132. * @param onCompiled Callback called when completed.
  114133. * @param onError Callback called on error.
  114134. * @hidden
  114135. */
  114136. _rebuildProgram(vertexSourceCode: string, fragmentSourceCode: string, onCompiled: (pipelineContext: IPipelineContext) => void, onError: (message: string) => void): void;
  114137. /**
  114138. * Prepares the effect
  114139. * @hidden
  114140. */
  114141. _prepareEffect(): void;
  114142. private _getShaderCodeAndErrorLine;
  114143. private _processCompilationErrors;
  114144. /**
  114145. * Checks if the effect is supported. (Must be called after compilation)
  114146. */
  114147. get isSupported(): boolean;
  114148. /**
  114149. * Binds a texture to the engine to be used as output of the shader.
  114150. * @param channel Name of the output variable.
  114151. * @param texture Texture to bind.
  114152. * @hidden
  114153. */
  114154. _bindTexture(channel: string, texture: Nullable<InternalTexture>): void;
  114155. /**
  114156. * Sets a texture on the engine to be used in the shader.
  114157. * @param channel Name of the sampler variable.
  114158. * @param texture Texture to set.
  114159. */
  114160. setTexture(channel: string, texture: Nullable<BaseTexture>): void;
  114161. /**
  114162. * Sets a depth stencil texture from a render target on the engine to be used in the shader.
  114163. * @param channel Name of the sampler variable.
  114164. * @param texture Texture to set.
  114165. */
  114166. setDepthStencilTexture(channel: string, texture: Nullable<RenderTargetTexture>): void;
  114167. /**
  114168. * Sets an array of textures on the engine to be used in the shader.
  114169. * @param channel Name of the variable.
  114170. * @param textures Textures to set.
  114171. */
  114172. setTextureArray(channel: string, textures: BaseTexture[]): void;
  114173. /**
  114174. * 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)
  114175. * @param channel Name of the sampler variable.
  114176. * @param postProcess Post process to get the input texture from.
  114177. */
  114178. setTextureFromPostProcess(channel: string, postProcess: Nullable<PostProcess>): void;
  114179. /**
  114180. * (Warning! setTextureFromPostProcessOutput may be desired instead)
  114181. * 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)
  114182. * @param channel Name of the sampler variable.
  114183. * @param postProcess Post process to get the output texture from.
  114184. */
  114185. setTextureFromPostProcessOutput(channel: string, postProcess: Nullable<PostProcess>): void;
  114186. /** @hidden */
  114187. _cacheMatrix(uniformName: string, matrix: IMatrixLike): boolean;
  114188. /** @hidden */
  114189. _cacheFloat2(uniformName: string, x: number, y: number): boolean;
  114190. /** @hidden */
  114191. _cacheFloat3(uniformName: string, x: number, y: number, z: number): boolean;
  114192. /** @hidden */
  114193. _cacheFloat4(uniformName: string, x: number, y: number, z: number, w: number): boolean;
  114194. /**
  114195. * Binds a buffer to a uniform.
  114196. * @param buffer Buffer to bind.
  114197. * @param name Name of the uniform variable to bind to.
  114198. */
  114199. bindUniformBuffer(buffer: DataBuffer, name: string): void;
  114200. /**
  114201. * Binds block to a uniform.
  114202. * @param blockName Name of the block to bind.
  114203. * @param index Index to bind.
  114204. */
  114205. bindUniformBlock(blockName: string, index: number): void;
  114206. /**
  114207. * Sets an interger value on a uniform variable.
  114208. * @param uniformName Name of the variable.
  114209. * @param value Value to be set.
  114210. * @returns this effect.
  114211. */
  114212. setInt(uniformName: string, value: number): Effect;
  114213. /**
  114214. * Sets an int array on a uniform variable.
  114215. * @param uniformName Name of the variable.
  114216. * @param array array to be set.
  114217. * @returns this effect.
  114218. */
  114219. setIntArray(uniformName: string, array: Int32Array): Effect;
  114220. /**
  114221. * 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)
  114222. * @param uniformName Name of the variable.
  114223. * @param array array to be set.
  114224. * @returns this effect.
  114225. */
  114226. setIntArray2(uniformName: string, array: Int32Array): Effect;
  114227. /**
  114228. * 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)
  114229. * @param uniformName Name of the variable.
  114230. * @param array array to be set.
  114231. * @returns this effect.
  114232. */
  114233. setIntArray3(uniformName: string, array: Int32Array): Effect;
  114234. /**
  114235. * 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)
  114236. * @param uniformName Name of the variable.
  114237. * @param array array to be set.
  114238. * @returns this effect.
  114239. */
  114240. setIntArray4(uniformName: string, array: Int32Array): Effect;
  114241. /**
  114242. * Sets an float array on a uniform variable.
  114243. * @param uniformName Name of the variable.
  114244. * @param array array to be set.
  114245. * @returns this effect.
  114246. */
  114247. setFloatArray(uniformName: string, array: Float32Array): Effect;
  114248. /**
  114249. * 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)
  114250. * @param uniformName Name of the variable.
  114251. * @param array array to be set.
  114252. * @returns this effect.
  114253. */
  114254. setFloatArray2(uniformName: string, array: Float32Array): Effect;
  114255. /**
  114256. * 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)
  114257. * @param uniformName Name of the variable.
  114258. * @param array array to be set.
  114259. * @returns this effect.
  114260. */
  114261. setFloatArray3(uniformName: string, array: Float32Array): Effect;
  114262. /**
  114263. * 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)
  114264. * @param uniformName Name of the variable.
  114265. * @param array array to be set.
  114266. * @returns this effect.
  114267. */
  114268. setFloatArray4(uniformName: string, array: Float32Array): Effect;
  114269. /**
  114270. * Sets an array on a uniform variable.
  114271. * @param uniformName Name of the variable.
  114272. * @param array array to be set.
  114273. * @returns this effect.
  114274. */
  114275. setArray(uniformName: string, array: number[]): Effect;
  114276. /**
  114277. * 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)
  114278. * @param uniformName Name of the variable.
  114279. * @param array array to be set.
  114280. * @returns this effect.
  114281. */
  114282. setArray2(uniformName: string, array: number[]): Effect;
  114283. /**
  114284. * 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)
  114285. * @param uniformName Name of the variable.
  114286. * @param array array to be set.
  114287. * @returns this effect.
  114288. */
  114289. setArray3(uniformName: string, array: number[]): Effect;
  114290. /**
  114291. * 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)
  114292. * @param uniformName Name of the variable.
  114293. * @param array array to be set.
  114294. * @returns this effect.
  114295. */
  114296. setArray4(uniformName: string, array: number[]): Effect;
  114297. /**
  114298. * Sets matrices on a uniform variable.
  114299. * @param uniformName Name of the variable.
  114300. * @param matrices matrices to be set.
  114301. * @returns this effect.
  114302. */
  114303. setMatrices(uniformName: string, matrices: Float32Array | Array<number>): Effect;
  114304. /**
  114305. * Sets matrix on a uniform variable.
  114306. * @param uniformName Name of the variable.
  114307. * @param matrix matrix to be set.
  114308. * @returns this effect.
  114309. */
  114310. setMatrix(uniformName: string, matrix: IMatrixLike): Effect;
  114311. /**
  114312. * 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)
  114313. * @param uniformName Name of the variable.
  114314. * @param matrix matrix to be set.
  114315. * @returns this effect.
  114316. */
  114317. setMatrix3x3(uniformName: string, matrix: Float32Array | Array<number>): Effect;
  114318. /**
  114319. * Sets a 2x2 matrix on a uniform variable. (Speicified as [1,2,3,4] will result in [1,2][3,4] matrix)
  114320. * @param uniformName Name of the variable.
  114321. * @param matrix matrix to be set.
  114322. * @returns this effect.
  114323. */
  114324. setMatrix2x2(uniformName: string, matrix: Float32Array | Array<number>): Effect;
  114325. /**
  114326. * Sets a float on a uniform variable.
  114327. * @param uniformName Name of the variable.
  114328. * @param value value to be set.
  114329. * @returns this effect.
  114330. */
  114331. setFloat(uniformName: string, value: number): Effect;
  114332. /**
  114333. * Sets a boolean on a uniform variable.
  114334. * @param uniformName Name of the variable.
  114335. * @param bool value to be set.
  114336. * @returns this effect.
  114337. */
  114338. setBool(uniformName: string, bool: boolean): Effect;
  114339. /**
  114340. * Sets a Vector2 on a uniform variable.
  114341. * @param uniformName Name of the variable.
  114342. * @param vector2 vector2 to be set.
  114343. * @returns this effect.
  114344. */
  114345. setVector2(uniformName: string, vector2: IVector2Like): Effect;
  114346. /**
  114347. * Sets a float2 on a uniform variable.
  114348. * @param uniformName Name of the variable.
  114349. * @param x First float in float2.
  114350. * @param y Second float in float2.
  114351. * @returns this effect.
  114352. */
  114353. setFloat2(uniformName: string, x: number, y: number): Effect;
  114354. /**
  114355. * Sets a Vector3 on a uniform variable.
  114356. * @param uniformName Name of the variable.
  114357. * @param vector3 Value to be set.
  114358. * @returns this effect.
  114359. */
  114360. setVector3(uniformName: string, vector3: IVector3Like): Effect;
  114361. /**
  114362. * Sets a float3 on a uniform variable.
  114363. * @param uniformName Name of the variable.
  114364. * @param x First float in float3.
  114365. * @param y Second float in float3.
  114366. * @param z Third float in float3.
  114367. * @returns this effect.
  114368. */
  114369. setFloat3(uniformName: string, x: number, y: number, z: number): Effect;
  114370. /**
  114371. * Sets a Vector4 on a uniform variable.
  114372. * @param uniformName Name of the variable.
  114373. * @param vector4 Value to be set.
  114374. * @returns this effect.
  114375. */
  114376. setVector4(uniformName: string, vector4: IVector4Like): Effect;
  114377. /**
  114378. * Sets a float4 on a uniform variable.
  114379. * @param uniformName Name of the variable.
  114380. * @param x First float in float4.
  114381. * @param y Second float in float4.
  114382. * @param z Third float in float4.
  114383. * @param w Fourth float in float4.
  114384. * @returns this effect.
  114385. */
  114386. setFloat4(uniformName: string, x: number, y: number, z: number, w: number): Effect;
  114387. /**
  114388. * Sets a Color3 on a uniform variable.
  114389. * @param uniformName Name of the variable.
  114390. * @param color3 Value to be set.
  114391. * @returns this effect.
  114392. */
  114393. setColor3(uniformName: string, color3: IColor3Like): Effect;
  114394. /**
  114395. * Sets a Color4 on a uniform variable.
  114396. * @param uniformName Name of the variable.
  114397. * @param color3 Value to be set.
  114398. * @param alpha Alpha value to be set.
  114399. * @returns this effect.
  114400. */
  114401. setColor4(uniformName: string, color3: IColor3Like, alpha: number): Effect;
  114402. /**
  114403. * Sets a Color4 on a uniform variable
  114404. * @param uniformName defines the name of the variable
  114405. * @param color4 defines the value to be set
  114406. * @returns this effect.
  114407. */
  114408. setDirectColor4(uniformName: string, color4: IColor4Like): Effect;
  114409. /** Release all associated resources */
  114410. dispose(): void;
  114411. /**
  114412. * This function will add a new shader to the shader store
  114413. * @param name the name of the shader
  114414. * @param pixelShader optional pixel shader content
  114415. * @param vertexShader optional vertex shader content
  114416. */
  114417. static RegisterShader(name: string, pixelShader?: string, vertexShader?: string): void;
  114418. /**
  114419. * Store of each shader (The can be looked up using effect.key)
  114420. */
  114421. static ShadersStore: {
  114422. [key: string]: string;
  114423. };
  114424. /**
  114425. * Store of each included file for a shader (The can be looked up using effect.key)
  114426. */
  114427. static IncludesShadersStore: {
  114428. [key: string]: string;
  114429. };
  114430. /**
  114431. * Resets the cache of effects.
  114432. */
  114433. static ResetCache(): void;
  114434. }
  114435. }
  114436. declare module BABYLON {
  114437. /**
  114438. * Interface used to describe the capabilities of the engine relatively to the current browser
  114439. */
  114440. export interface EngineCapabilities {
  114441. /** Maximum textures units per fragment shader */
  114442. maxTexturesImageUnits: number;
  114443. /** Maximum texture units per vertex shader */
  114444. maxVertexTextureImageUnits: number;
  114445. /** Maximum textures units in the entire pipeline */
  114446. maxCombinedTexturesImageUnits: number;
  114447. /** Maximum texture size */
  114448. maxTextureSize: number;
  114449. /** Maximum texture samples */
  114450. maxSamples?: number;
  114451. /** Maximum cube texture size */
  114452. maxCubemapTextureSize: number;
  114453. /** Maximum render texture size */
  114454. maxRenderTextureSize: number;
  114455. /** Maximum number of vertex attributes */
  114456. maxVertexAttribs: number;
  114457. /** Maximum number of varyings */
  114458. maxVaryingVectors: number;
  114459. /** Maximum number of uniforms per vertex shader */
  114460. maxVertexUniformVectors: number;
  114461. /** Maximum number of uniforms per fragment shader */
  114462. maxFragmentUniformVectors: number;
  114463. /** Defines if standard derivates (dx/dy) are supported */
  114464. standardDerivatives: boolean;
  114465. /** Defines if s3tc texture compression is supported */
  114466. s3tc?: WEBGL_compressed_texture_s3tc;
  114467. /** Defines if pvrtc texture compression is supported */
  114468. pvrtc: any;
  114469. /** Defines if etc1 texture compression is supported */
  114470. etc1: any;
  114471. /** Defines if etc2 texture compression is supported */
  114472. etc2: any;
  114473. /** Defines if astc texture compression is supported */
  114474. astc: any;
  114475. /** Defines if float textures are supported */
  114476. textureFloat: boolean;
  114477. /** Defines if vertex array objects are supported */
  114478. vertexArrayObject: boolean;
  114479. /** Gets the webgl extension for anisotropic filtering (null if not supported) */
  114480. textureAnisotropicFilterExtension?: EXT_texture_filter_anisotropic;
  114481. /** Gets the maximum level of anisotropy supported */
  114482. maxAnisotropy: number;
  114483. /** Defines if instancing is supported */
  114484. instancedArrays: boolean;
  114485. /** Defines if 32 bits indices are supported */
  114486. uintIndices: boolean;
  114487. /** Defines if high precision shaders are supported */
  114488. highPrecisionShaderSupported: boolean;
  114489. /** Defines if depth reading in the fragment shader is supported */
  114490. fragmentDepthSupported: boolean;
  114491. /** Defines if float texture linear filtering is supported*/
  114492. textureFloatLinearFiltering: boolean;
  114493. /** Defines if rendering to float textures is supported */
  114494. textureFloatRender: boolean;
  114495. /** Defines if half float textures are supported*/
  114496. textureHalfFloat: boolean;
  114497. /** Defines if half float texture linear filtering is supported*/
  114498. textureHalfFloatLinearFiltering: boolean;
  114499. /** Defines if rendering to half float textures is supported */
  114500. textureHalfFloatRender: boolean;
  114501. /** Defines if textureLOD shader command is supported */
  114502. textureLOD: boolean;
  114503. /** Defines if draw buffers extension is supported */
  114504. drawBuffersExtension: boolean;
  114505. /** Defines if depth textures are supported */
  114506. depthTextureExtension: boolean;
  114507. /** Defines if float color buffer are supported */
  114508. colorBufferFloat: boolean;
  114509. /** Gets disjoint timer query extension (null if not supported) */
  114510. timerQuery?: EXT_disjoint_timer_query;
  114511. /** Defines if timestamp can be used with timer query */
  114512. canUseTimestampForTimerQuery: boolean;
  114513. /** Defines if multiview is supported (https://www.khronos.org/registry/webgl/extensions/WEBGL_multiview/) */
  114514. multiview?: any;
  114515. /** Defines if oculus multiview is supported (https://developer.oculus.com/documentation/oculus-browser/latest/concepts/browser-multiview/) */
  114516. oculusMultiview?: any;
  114517. /** Function used to let the system compiles shaders in background */
  114518. parallelShaderCompile?: {
  114519. COMPLETION_STATUS_KHR: number;
  114520. };
  114521. /** Max number of texture samples for MSAA */
  114522. maxMSAASamples: number;
  114523. /** Defines if the blend min max extension is supported */
  114524. blendMinMax: boolean;
  114525. }
  114526. }
  114527. declare module BABYLON {
  114528. /**
  114529. * @hidden
  114530. **/
  114531. export class DepthCullingState {
  114532. private _isDepthTestDirty;
  114533. private _isDepthMaskDirty;
  114534. private _isDepthFuncDirty;
  114535. private _isCullFaceDirty;
  114536. private _isCullDirty;
  114537. private _isZOffsetDirty;
  114538. private _isFrontFaceDirty;
  114539. private _depthTest;
  114540. private _depthMask;
  114541. private _depthFunc;
  114542. private _cull;
  114543. private _cullFace;
  114544. private _zOffset;
  114545. private _frontFace;
  114546. /**
  114547. * Initializes the state.
  114548. */
  114549. constructor();
  114550. get isDirty(): boolean;
  114551. get zOffset(): number;
  114552. set zOffset(value: number);
  114553. get cullFace(): Nullable<number>;
  114554. set cullFace(value: Nullable<number>);
  114555. get cull(): Nullable<boolean>;
  114556. set cull(value: Nullable<boolean>);
  114557. get depthFunc(): Nullable<number>;
  114558. set depthFunc(value: Nullable<number>);
  114559. get depthMask(): boolean;
  114560. set depthMask(value: boolean);
  114561. get depthTest(): boolean;
  114562. set depthTest(value: boolean);
  114563. get frontFace(): Nullable<number>;
  114564. set frontFace(value: Nullable<number>);
  114565. reset(): void;
  114566. apply(gl: WebGLRenderingContext): void;
  114567. }
  114568. }
  114569. declare module BABYLON {
  114570. /**
  114571. * @hidden
  114572. **/
  114573. export class StencilState {
  114574. /** 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 */
  114575. static readonly ALWAYS: number;
  114576. /** Passed to stencilOperation to specify that stencil value must be kept */
  114577. static readonly KEEP: number;
  114578. /** Passed to stencilOperation to specify that stencil value must be replaced */
  114579. static readonly REPLACE: number;
  114580. private _isStencilTestDirty;
  114581. private _isStencilMaskDirty;
  114582. private _isStencilFuncDirty;
  114583. private _isStencilOpDirty;
  114584. private _stencilTest;
  114585. private _stencilMask;
  114586. private _stencilFunc;
  114587. private _stencilFuncRef;
  114588. private _stencilFuncMask;
  114589. private _stencilOpStencilFail;
  114590. private _stencilOpDepthFail;
  114591. private _stencilOpStencilDepthPass;
  114592. get isDirty(): boolean;
  114593. get stencilFunc(): number;
  114594. set stencilFunc(value: number);
  114595. get stencilFuncRef(): number;
  114596. set stencilFuncRef(value: number);
  114597. get stencilFuncMask(): number;
  114598. set stencilFuncMask(value: number);
  114599. get stencilOpStencilFail(): number;
  114600. set stencilOpStencilFail(value: number);
  114601. get stencilOpDepthFail(): number;
  114602. set stencilOpDepthFail(value: number);
  114603. get stencilOpStencilDepthPass(): number;
  114604. set stencilOpStencilDepthPass(value: number);
  114605. get stencilMask(): number;
  114606. set stencilMask(value: number);
  114607. get stencilTest(): boolean;
  114608. set stencilTest(value: boolean);
  114609. constructor();
  114610. reset(): void;
  114611. apply(gl: WebGLRenderingContext): void;
  114612. }
  114613. }
  114614. declare module BABYLON {
  114615. /**
  114616. * @hidden
  114617. **/
  114618. export class AlphaState {
  114619. private _isAlphaBlendDirty;
  114620. private _isBlendFunctionParametersDirty;
  114621. private _isBlendEquationParametersDirty;
  114622. private _isBlendConstantsDirty;
  114623. private _alphaBlend;
  114624. private _blendFunctionParameters;
  114625. private _blendEquationParameters;
  114626. private _blendConstants;
  114627. /**
  114628. * Initializes the state.
  114629. */
  114630. constructor();
  114631. get isDirty(): boolean;
  114632. get alphaBlend(): boolean;
  114633. set alphaBlend(value: boolean);
  114634. setAlphaBlendConstants(r: number, g: number, b: number, a: number): void;
  114635. setAlphaBlendFunctionParameters(value0: number, value1: number, value2: number, value3: number): void;
  114636. setAlphaEquationParameters(rgb: number, alpha: number): void;
  114637. reset(): void;
  114638. apply(gl: WebGLRenderingContext): void;
  114639. }
  114640. }
  114641. declare module BABYLON {
  114642. /** @hidden */
  114643. export class WebGL2ShaderProcessor implements IShaderProcessor {
  114644. attributeProcessor(attribute: string): string;
  114645. varyingProcessor(varying: string, isFragment: boolean): string;
  114646. postProcessor(code: string, defines: string[], isFragment: boolean): string;
  114647. }
  114648. }
  114649. declare module BABYLON {
  114650. /**
  114651. * Interface for attribute information associated with buffer instanciation
  114652. */
  114653. export interface InstancingAttributeInfo {
  114654. /**
  114655. * Name of the GLSL attribute
  114656. * if attribute index is not specified, this is used to retrieve the index from the effect
  114657. */
  114658. attributeName: string;
  114659. /**
  114660. * Index/offset of the attribute in the vertex shader
  114661. * if not specified, this will be computes from the name.
  114662. */
  114663. index?: number;
  114664. /**
  114665. * size of the attribute, 1, 2, 3 or 4
  114666. */
  114667. attributeSize: number;
  114668. /**
  114669. * Offset of the data in the Vertex Buffer acting as the instancing buffer
  114670. */
  114671. offset: number;
  114672. /**
  114673. * Modifies the rate at which generic vertex attributes advance when rendering multiple instances
  114674. * default to 1
  114675. */
  114676. divisor?: number;
  114677. /**
  114678. * type of the attribute, gl.BYTE, gl.UNSIGNED_BYTE, gl.SHORT, gl.UNSIGNED_SHORT, gl.FIXED, gl.FLOAT.
  114679. * default is FLOAT
  114680. */
  114681. attributeType?: number;
  114682. /**
  114683. * normalization of fixed-point data. behavior unclear, use FALSE, default is FALSE
  114684. */
  114685. normalized?: boolean;
  114686. }
  114687. }
  114688. declare module BABYLON {
  114689. interface ThinEngine {
  114690. /**
  114691. * Update a video texture
  114692. * @param texture defines the texture to update
  114693. * @param video defines the video element to use
  114694. * @param invertY defines if data must be stored with Y axis inverted
  114695. */
  114696. updateVideoTexture(texture: Nullable<InternalTexture>, video: HTMLVideoElement, invertY: boolean): void;
  114697. }
  114698. }
  114699. declare module BABYLON {
  114700. interface ThinEngine {
  114701. /**
  114702. * Creates a dynamic texture
  114703. * @param width defines the width of the texture
  114704. * @param height defines the height of the texture
  114705. * @param generateMipMaps defines if the engine should generate the mip levels
  114706. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  114707. * @returns the dynamic texture inside an InternalTexture
  114708. */
  114709. createDynamicTexture(width: number, height: number, generateMipMaps: boolean, samplingMode: number): InternalTexture;
  114710. /**
  114711. * Update the content of a dynamic texture
  114712. * @param texture defines the texture to update
  114713. * @param canvas defines the canvas containing the source
  114714. * @param invertY defines if data must be stored with Y axis inverted
  114715. * @param premulAlpha defines if alpha is stored as premultiplied
  114716. * @param format defines the format of the data
  114717. * @param forceBindTexture if the texture should be forced to be bound eg. after a graphics context loss (Default: false)
  114718. */
  114719. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement | OffscreenCanvas, invertY: boolean, premulAlpha?: boolean, format?: number, forceBindTexture?: boolean): void;
  114720. }
  114721. }
  114722. declare module BABYLON {
  114723. /**
  114724. * Settings for finer control over video usage
  114725. */
  114726. export interface VideoTextureSettings {
  114727. /**
  114728. * Applies `autoplay` to video, if specified
  114729. */
  114730. autoPlay?: boolean;
  114731. /**
  114732. * Applies `loop` to video, if specified
  114733. */
  114734. loop?: boolean;
  114735. /**
  114736. * Automatically updates internal texture from video at every frame in the render loop
  114737. */
  114738. autoUpdateTexture: boolean;
  114739. /**
  114740. * Image src displayed during the video loading or until the user interacts with the video.
  114741. */
  114742. poster?: string;
  114743. }
  114744. /**
  114745. * If you want to display a video in your scene, this is the special texture for that.
  114746. * This special texture works similar to other textures, with the exception of a few parameters.
  114747. * @see https://doc.babylonjs.com/how_to/video_texture
  114748. */
  114749. export class VideoTexture extends Texture {
  114750. /**
  114751. * Tells whether textures will be updated automatically or user is required to call `updateTexture` manually
  114752. */
  114753. readonly autoUpdateTexture: boolean;
  114754. /**
  114755. * The video instance used by the texture internally
  114756. */
  114757. readonly video: HTMLVideoElement;
  114758. private _onUserActionRequestedObservable;
  114759. /**
  114760. * Event triggerd when a dom action is required by the user to play the video.
  114761. * This happens due to recent changes in browser policies preventing video to auto start.
  114762. */
  114763. get onUserActionRequestedObservable(): Observable<Texture>;
  114764. private _generateMipMaps;
  114765. private _stillImageCaptured;
  114766. private _displayingPosterTexture;
  114767. private _settings;
  114768. private _createInternalTextureOnEvent;
  114769. private _frameId;
  114770. private _currentSrc;
  114771. /**
  114772. * Creates a video texture.
  114773. * If you want to display a video in your scene, this is the special texture for that.
  114774. * This special texture works similar to other textures, with the exception of a few parameters.
  114775. * @see https://doc.babylonjs.com/how_to/video_texture
  114776. * @param name optional name, will detect from video source, if not defined
  114777. * @param src can be used to provide an url, array of urls or an already setup HTML video element.
  114778. * @param scene is obviously the current scene.
  114779. * @param generateMipMaps can be used to turn on mipmaps (Can be expensive for videoTextures because they are often updated).
  114780. * @param invertY is false by default but can be used to invert video on Y axis
  114781. * @param samplingMode controls the sampling method and is set to TRILINEAR_SAMPLINGMODE by default
  114782. * @param settings allows finer control over video usage
  114783. */
  114784. constructor(name: Nullable<string>, src: string | string[] | HTMLVideoElement, scene: Nullable<Scene>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, settings?: VideoTextureSettings);
  114785. private _getName;
  114786. private _getVideo;
  114787. private _createInternalTexture;
  114788. private reset;
  114789. /**
  114790. * @hidden Internal method to initiate `update`.
  114791. */
  114792. _rebuild(): void;
  114793. /**
  114794. * Update Texture in the `auto` mode. Does not do anything if `settings.autoUpdateTexture` is false.
  114795. */
  114796. update(): void;
  114797. /**
  114798. * Update Texture in `manual` mode. Does not do anything if not visible or paused.
  114799. * @param isVisible Visibility state, detected by user using `scene.getActiveMeshes()` or othervise.
  114800. */
  114801. updateTexture(isVisible: boolean): void;
  114802. protected _updateInternalTexture: () => void;
  114803. /**
  114804. * Change video content. Changing video instance or setting multiple urls (as in constructor) is not supported.
  114805. * @param url New url.
  114806. */
  114807. updateURL(url: string): void;
  114808. /**
  114809. * Clones the texture.
  114810. * @returns the cloned texture
  114811. */
  114812. clone(): VideoTexture;
  114813. /**
  114814. * Dispose the texture and release its associated resources.
  114815. */
  114816. dispose(): void;
  114817. /**
  114818. * Creates a video texture straight from a stream.
  114819. * @param scene Define the scene the texture should be created in
  114820. * @param stream Define the stream the texture should be created from
  114821. * @returns The created video texture as a promise
  114822. */
  114823. static CreateFromStreamAsync(scene: Scene, stream: MediaStream): Promise<VideoTexture>;
  114824. /**
  114825. * Creates a video texture straight from your WebCam video feed.
  114826. * @param scene Define the scene the texture should be created in
  114827. * @param constraints Define the constraints to use to create the web cam feed from WebRTC
  114828. * @param audioConstaints Define the audio constraints to use to create the web cam feed from WebRTC
  114829. * @returns The created video texture as a promise
  114830. */
  114831. static CreateFromWebCamAsync(scene: Scene, constraints: {
  114832. minWidth: number;
  114833. maxWidth: number;
  114834. minHeight: number;
  114835. maxHeight: number;
  114836. deviceId: string;
  114837. } & MediaTrackConstraints, audioConstaints?: boolean | MediaTrackConstraints): Promise<VideoTexture>;
  114838. /**
  114839. * Creates a video texture straight from your WebCam video feed.
  114840. * @param scene Define the scene the texture should be created in
  114841. * @param onReady Define a callback to triggered once the texture will be ready
  114842. * @param constraints Define the constraints to use to create the web cam feed from WebRTC
  114843. * @param audioConstaints Define the audio constraints to use to create the web cam feed from WebRTC
  114844. */
  114845. static CreateFromWebCam(scene: Scene, onReady: (videoTexture: VideoTexture) => void, constraints: {
  114846. minWidth: number;
  114847. maxWidth: number;
  114848. minHeight: number;
  114849. maxHeight: number;
  114850. deviceId: string;
  114851. } & MediaTrackConstraints, audioConstaints?: boolean | MediaTrackConstraints): void;
  114852. }
  114853. }
  114854. declare module BABYLON {
  114855. /**
  114856. * Defines the interface used by objects working like Scene
  114857. * @hidden
  114858. */
  114859. export interface ISceneLike {
  114860. _addPendingData(data: any): void;
  114861. _removePendingData(data: any): void;
  114862. offlineProvider: IOfflineProvider;
  114863. }
  114864. /**
  114865. * Information about the current host
  114866. */
  114867. export interface HostInformation {
  114868. /**
  114869. * Defines if the current host is a mobile
  114870. */
  114871. isMobile: boolean;
  114872. }
  114873. /** Interface defining initialization parameters for Engine class */
  114874. export interface EngineOptions extends WebGLContextAttributes {
  114875. /**
  114876. * Defines if the engine should no exceed a specified device ratio
  114877. * @see https://developer.mozilla.org/en-US/docs/Web/API/Window/devicePixelRatio
  114878. */
  114879. limitDeviceRatio?: number;
  114880. /**
  114881. * Defines if webvr should be enabled automatically
  114882. * @see https://doc.babylonjs.com/how_to/webvr_camera
  114883. */
  114884. autoEnableWebVR?: boolean;
  114885. /**
  114886. * Defines if webgl2 should be turned off even if supported
  114887. * @see https://doc.babylonjs.com/features/webgl2
  114888. */
  114889. disableWebGL2Support?: boolean;
  114890. /**
  114891. * Defines if webaudio should be initialized as well
  114892. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  114893. */
  114894. audioEngine?: boolean;
  114895. /**
  114896. * Defines if animations should run using a deterministic lock step
  114897. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  114898. */
  114899. deterministicLockstep?: boolean;
  114900. /** Defines the maximum steps to use with deterministic lock step mode */
  114901. lockstepMaxSteps?: number;
  114902. /** Defines the seconds between each deterministic lock step */
  114903. timeStep?: number;
  114904. /**
  114905. * Defines that engine should ignore context lost events
  114906. * If this event happens when this parameter is true, you will have to reload the page to restore rendering
  114907. */
  114908. doNotHandleContextLost?: boolean;
  114909. /**
  114910. * Defines that engine should ignore modifying touch action attribute and style
  114911. * If not handle, you might need to set it up on your side for expected touch devices behavior.
  114912. */
  114913. doNotHandleTouchAction?: boolean;
  114914. /**
  114915. * Defines that engine should compile shaders with high precision floats (if supported). True by default
  114916. */
  114917. useHighPrecisionFloats?: boolean;
  114918. /**
  114919. * Make the canvas XR Compatible for XR sessions
  114920. */
  114921. xrCompatible?: boolean;
  114922. /**
  114923. * Make the matrix computations to be performed in 64 bits instead of 32 bits. False by default
  114924. */
  114925. useHighPrecisionMatrix?: boolean;
  114926. }
  114927. /**
  114928. * The base engine class (root of all engines)
  114929. */
  114930. export class ThinEngine {
  114931. /** Use this array to turn off some WebGL2 features on known buggy browsers version */
  114932. static ExceptionList: ({
  114933. key: string;
  114934. capture: string;
  114935. captureConstraint: number;
  114936. targets: string[];
  114937. } | {
  114938. key: string;
  114939. capture: null;
  114940. captureConstraint: null;
  114941. targets: string[];
  114942. })[];
  114943. /** @hidden */
  114944. static _TextureLoaders: IInternalTextureLoader[];
  114945. /**
  114946. * Returns the current npm package of the sdk
  114947. */
  114948. static get NpmPackage(): string;
  114949. /**
  114950. * Returns the current version of the framework
  114951. */
  114952. static get Version(): string;
  114953. /**
  114954. * Returns a string describing the current engine
  114955. */
  114956. get description(): string;
  114957. /**
  114958. * Gets or sets the epsilon value used by collision engine
  114959. */
  114960. static CollisionsEpsilon: number;
  114961. /**
  114962. * Gets or sets the relative url used to load shaders if using the engine in non-minified mode
  114963. */
  114964. static get ShadersRepository(): string;
  114965. static set ShadersRepository(value: string);
  114966. /** @hidden */
  114967. _shaderProcessor: IShaderProcessor;
  114968. /**
  114969. * Gets or sets a boolean that indicates if textures must be forced to power of 2 size even if not required
  114970. */
  114971. forcePOTTextures: boolean;
  114972. /**
  114973. * Gets a boolean indicating if the engine is currently rendering in fullscreen mode
  114974. */
  114975. isFullscreen: boolean;
  114976. /**
  114977. * Gets or sets a boolean indicating if back faces must be culled (true by default)
  114978. */
  114979. cullBackFaces: boolean;
  114980. /**
  114981. * Gets or sets a boolean indicating if the engine must keep rendering even if the window is not in foregroun
  114982. */
  114983. renderEvenInBackground: boolean;
  114984. /**
  114985. * Gets or sets a boolean indicating that cache can be kept between frames
  114986. */
  114987. preventCacheWipeBetweenFrames: boolean;
  114988. /** Gets or sets a boolean indicating if the engine should validate programs after compilation */
  114989. validateShaderPrograms: boolean;
  114990. /**
  114991. * Gets or sets a boolean indicating if depth buffer should be reverse, going from far to near.
  114992. * This can provide greater z depth for distant objects.
  114993. */
  114994. useReverseDepthBuffer: boolean;
  114995. /**
  114996. * Gets or sets a boolean indicating that uniform buffers must be disabled even if they are supported
  114997. */
  114998. disableUniformBuffers: boolean;
  114999. /** @hidden */
  115000. _uniformBuffers: UniformBuffer[];
  115001. /**
  115002. * Gets a boolean indicating that the engine supports uniform buffers
  115003. * @see https://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  115004. */
  115005. get supportsUniformBuffers(): boolean;
  115006. /** @hidden */
  115007. _gl: WebGLRenderingContext;
  115008. /** @hidden */
  115009. _webGLVersion: number;
  115010. protected _renderingCanvas: Nullable<HTMLCanvasElement>;
  115011. protected _windowIsBackground: boolean;
  115012. protected _creationOptions: EngineOptions;
  115013. protected _highPrecisionShadersAllowed: boolean;
  115014. /** @hidden */
  115015. get _shouldUseHighPrecisionShader(): boolean;
  115016. /**
  115017. * Gets a boolean indicating that only power of 2 textures are supported
  115018. * Please note that you can still use non power of 2 textures but in this case the engine will forcefully convert them
  115019. */
  115020. get needPOTTextures(): boolean;
  115021. /** @hidden */
  115022. _badOS: boolean;
  115023. /** @hidden */
  115024. _badDesktopOS: boolean;
  115025. private _hardwareScalingLevel;
  115026. /** @hidden */
  115027. _caps: EngineCapabilities;
  115028. private _isStencilEnable;
  115029. private _glVersion;
  115030. private _glRenderer;
  115031. private _glVendor;
  115032. /** @hidden */
  115033. _videoTextureSupported: boolean;
  115034. protected _renderingQueueLaunched: boolean;
  115035. protected _activeRenderLoops: (() => void)[];
  115036. /**
  115037. * Observable signaled when a context lost event is raised
  115038. */
  115039. onContextLostObservable: Observable<ThinEngine>;
  115040. /**
  115041. * Observable signaled when a context restored event is raised
  115042. */
  115043. onContextRestoredObservable: Observable<ThinEngine>;
  115044. private _onContextLost;
  115045. private _onContextRestored;
  115046. protected _contextWasLost: boolean;
  115047. /** @hidden */
  115048. _doNotHandleContextLost: boolean;
  115049. /**
  115050. * Gets or sets a boolean indicating if resources should be retained to be able to handle context lost events
  115051. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#handling-webgl-context-lost
  115052. */
  115053. get doNotHandleContextLost(): boolean;
  115054. set doNotHandleContextLost(value: boolean);
  115055. /**
  115056. * Gets or sets a boolean indicating that vertex array object must be disabled even if they are supported
  115057. */
  115058. disableVertexArrayObjects: boolean;
  115059. /** @hidden */
  115060. protected _colorWrite: boolean;
  115061. /** @hidden */
  115062. protected _colorWriteChanged: boolean;
  115063. /** @hidden */
  115064. protected _depthCullingState: DepthCullingState;
  115065. /** @hidden */
  115066. protected _stencilState: StencilState;
  115067. /** @hidden */
  115068. _alphaState: AlphaState;
  115069. /** @hidden */
  115070. _alphaMode: number;
  115071. /** @hidden */
  115072. _alphaEquation: number;
  115073. /** @hidden */
  115074. _internalTexturesCache: InternalTexture[];
  115075. /** @hidden */
  115076. protected _activeChannel: number;
  115077. private _currentTextureChannel;
  115078. /** @hidden */
  115079. protected _boundTexturesCache: {
  115080. [key: string]: Nullable<InternalTexture>;
  115081. };
  115082. /** @hidden */
  115083. protected _currentEffect: Nullable<Effect>;
  115084. /** @hidden */
  115085. protected _currentProgram: Nullable<WebGLProgram>;
  115086. private _compiledEffects;
  115087. private _vertexAttribArraysEnabled;
  115088. /** @hidden */
  115089. protected _cachedViewport: Nullable<IViewportLike>;
  115090. private _cachedVertexArrayObject;
  115091. /** @hidden */
  115092. protected _cachedVertexBuffers: any;
  115093. /** @hidden */
  115094. protected _cachedIndexBuffer: Nullable<DataBuffer>;
  115095. /** @hidden */
  115096. protected _cachedEffectForVertexBuffers: Nullable<Effect>;
  115097. /** @hidden */
  115098. _currentRenderTarget: Nullable<InternalTexture>;
  115099. private _uintIndicesCurrentlySet;
  115100. protected _currentBoundBuffer: Nullable<WebGLBuffer>[];
  115101. /** @hidden */
  115102. _currentFramebuffer: Nullable<WebGLFramebuffer>;
  115103. /** @hidden */
  115104. _dummyFramebuffer: Nullable<WebGLFramebuffer>;
  115105. private _currentBufferPointers;
  115106. private _currentInstanceLocations;
  115107. private _currentInstanceBuffers;
  115108. private _textureUnits;
  115109. /** @hidden */
  115110. _workingCanvas: Nullable<HTMLCanvasElement | OffscreenCanvas>;
  115111. /** @hidden */
  115112. _workingContext: Nullable<CanvasRenderingContext2D | OffscreenCanvasRenderingContext2D>;
  115113. /** @hidden */
  115114. _boundRenderFunction: any;
  115115. private _vaoRecordInProgress;
  115116. private _mustWipeVertexAttributes;
  115117. private _emptyTexture;
  115118. private _emptyCubeTexture;
  115119. private _emptyTexture3D;
  115120. private _emptyTexture2DArray;
  115121. /** @hidden */
  115122. _frameHandler: number;
  115123. private _nextFreeTextureSlots;
  115124. private _maxSimultaneousTextures;
  115125. private _activeRequests;
  115126. /** @hidden */
  115127. _transformTextureUrl: Nullable<(url: string) => string>;
  115128. /**
  115129. * Gets information about the current host
  115130. */
  115131. hostInformation: HostInformation;
  115132. protected get _supportsHardwareTextureRescaling(): boolean;
  115133. private _framebufferDimensionsObject;
  115134. /**
  115135. * sets the object from which width and height will be taken from when getting render width and height
  115136. * Will fallback to the gl object
  115137. * @param dimensions the framebuffer width and height that will be used.
  115138. */
  115139. set framebufferDimensionsObject(dimensions: Nullable<{
  115140. framebufferWidth: number;
  115141. framebufferHeight: number;
  115142. }>);
  115143. /**
  115144. * Gets the current viewport
  115145. */
  115146. get currentViewport(): Nullable<IViewportLike>;
  115147. /**
  115148. * Gets the default empty texture
  115149. */
  115150. get emptyTexture(): InternalTexture;
  115151. /**
  115152. * Gets the default empty 3D texture
  115153. */
  115154. get emptyTexture3D(): InternalTexture;
  115155. /**
  115156. * Gets the default empty 2D array texture
  115157. */
  115158. get emptyTexture2DArray(): InternalTexture;
  115159. /**
  115160. * Gets the default empty cube texture
  115161. */
  115162. get emptyCubeTexture(): InternalTexture;
  115163. /**
  115164. * Defines whether the engine has been created with the premultipliedAlpha option on or not.
  115165. */
  115166. readonly premultipliedAlpha: boolean;
  115167. /**
  115168. * Observable event triggered before each texture is initialized
  115169. */
  115170. onBeforeTextureInitObservable: Observable<Texture>;
  115171. /**
  115172. * Creates a new engine
  115173. * @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
  115174. * @param antialias defines enable antialiasing (default: false)
  115175. * @param options defines further options to be sent to the getContext() function
  115176. * @param adaptToDeviceRatio defines whether to adapt to the device's viewport characteristics (default: false)
  115177. */
  115178. constructor(canvasOrContext: Nullable<HTMLCanvasElement | WebGLRenderingContext | WebGL2RenderingContext>, antialias?: boolean, options?: EngineOptions, adaptToDeviceRatio?: boolean);
  115179. private _rebuildInternalTextures;
  115180. private _rebuildEffects;
  115181. /**
  115182. * Gets a boolean indicating if all created effects are ready
  115183. * @returns true if all effects are ready
  115184. */
  115185. areAllEffectsReady(): boolean;
  115186. protected _rebuildBuffers(): void;
  115187. protected _initGLContext(): void;
  115188. /**
  115189. * Gets version of the current webGL context
  115190. */
  115191. get webGLVersion(): number;
  115192. /**
  115193. * Gets a string identifying the name of the class
  115194. * @returns "Engine" string
  115195. */
  115196. getClassName(): string;
  115197. /**
  115198. * Returns true if the stencil buffer has been enabled through the creation option of the context.
  115199. */
  115200. get isStencilEnable(): boolean;
  115201. /** @hidden */
  115202. _prepareWorkingCanvas(): void;
  115203. /**
  115204. * Reset the texture cache to empty state
  115205. */
  115206. resetTextureCache(): void;
  115207. /**
  115208. * Gets an object containing information about the current webGL context
  115209. * @returns an object containing the vender, the renderer and the version of the current webGL context
  115210. */
  115211. getGlInfo(): {
  115212. vendor: string;
  115213. renderer: string;
  115214. version: string;
  115215. };
  115216. /**
  115217. * Defines the hardware scaling level.
  115218. * By default the hardware scaling level is computed from the window device ratio.
  115219. * 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.
  115220. * @param level defines the level to use
  115221. */
  115222. setHardwareScalingLevel(level: number): void;
  115223. /**
  115224. * Gets the current hardware scaling level.
  115225. * By default the hardware scaling level is computed from the window device ratio.
  115226. * 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.
  115227. * @returns a number indicating the current hardware scaling level
  115228. */
  115229. getHardwareScalingLevel(): number;
  115230. /**
  115231. * Gets the list of loaded textures
  115232. * @returns an array containing all loaded textures
  115233. */
  115234. getLoadedTexturesCache(): InternalTexture[];
  115235. /**
  115236. * Gets the object containing all engine capabilities
  115237. * @returns the EngineCapabilities object
  115238. */
  115239. getCaps(): EngineCapabilities;
  115240. /**
  115241. * stop executing a render loop function and remove it from the execution array
  115242. * @param renderFunction defines the function to be removed. If not provided all functions will be removed.
  115243. */
  115244. stopRenderLoop(renderFunction?: () => void): void;
  115245. /** @hidden */
  115246. _renderLoop(): void;
  115247. /**
  115248. * Gets the HTML canvas attached with the current webGL context
  115249. * @returns a HTML canvas
  115250. */
  115251. getRenderingCanvas(): Nullable<HTMLCanvasElement>;
  115252. /**
  115253. * Gets host window
  115254. * @returns the host window object
  115255. */
  115256. getHostWindow(): Nullable<Window>;
  115257. /**
  115258. * Gets the current render width
  115259. * @param useScreen defines if screen size must be used (or the current render target if any)
  115260. * @returns a number defining the current render width
  115261. */
  115262. getRenderWidth(useScreen?: boolean): number;
  115263. /**
  115264. * Gets the current render height
  115265. * @param useScreen defines if screen size must be used (or the current render target if any)
  115266. * @returns a number defining the current render height
  115267. */
  115268. getRenderHeight(useScreen?: boolean): number;
  115269. /**
  115270. * Can be used to override the current requestAnimationFrame requester.
  115271. * @hidden
  115272. */
  115273. protected _queueNewFrame(bindedRenderFunction: any, requester?: any): number;
  115274. /**
  115275. * Register and execute a render loop. The engine can have more than one render function
  115276. * @param renderFunction defines the function to continuously execute
  115277. */
  115278. runRenderLoop(renderFunction: () => void): void;
  115279. /**
  115280. * Clear the current render buffer or the current render target (if any is set up)
  115281. * @param color defines the color to use
  115282. * @param backBuffer defines if the back buffer must be cleared
  115283. * @param depth defines if the depth buffer must be cleared
  115284. * @param stencil defines if the stencil buffer must be cleared
  115285. */
  115286. clear(color: Nullable<IColor4Like>, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  115287. private _viewportCached;
  115288. /** @hidden */
  115289. _viewport(x: number, y: number, width: number, height: number): void;
  115290. /**
  115291. * Set the WebGL's viewport
  115292. * @param viewport defines the viewport element to be used
  115293. * @param requiredWidth defines the width required for rendering. If not provided the rendering canvas' width is used
  115294. * @param requiredHeight defines the height required for rendering. If not provided the rendering canvas' height is used
  115295. */
  115296. setViewport(viewport: IViewportLike, requiredWidth?: number, requiredHeight?: number): void;
  115297. /**
  115298. * Begin a new frame
  115299. */
  115300. beginFrame(): void;
  115301. /**
  115302. * Enf the current frame
  115303. */
  115304. endFrame(): void;
  115305. /**
  115306. * Resize the view according to the canvas' size
  115307. */
  115308. resize(): void;
  115309. /**
  115310. * Force a specific size of the canvas
  115311. * @param width defines the new canvas' width
  115312. * @param height defines the new canvas' height
  115313. * @returns true if the size was changed
  115314. */
  115315. setSize(width: number, height: number): boolean;
  115316. /**
  115317. * Binds the frame buffer to the specified texture.
  115318. * @param texture The texture to render to or null for the default canvas
  115319. * @param faceIndex The face of the texture to render to in case of cube texture
  115320. * @param requiredWidth The width of the target to render to
  115321. * @param requiredHeight The height of the target to render to
  115322. * @param forceFullscreenViewport Forces the viewport to be the entire texture/screen if true
  115323. * @param lodLevel defines the lod level to bind to the frame buffer
  115324. * @param layer defines the 2d array index to bind to frame buffer to
  115325. */
  115326. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean, lodLevel?: number, layer?: number): void;
  115327. /** @hidden */
  115328. _bindUnboundFramebuffer(framebuffer: Nullable<WebGLFramebuffer>): void;
  115329. /**
  115330. * Unbind the current render target texture from the webGL context
  115331. * @param texture defines the render target texture to unbind
  115332. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  115333. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  115334. */
  115335. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  115336. /**
  115337. * Force a webGL flush (ie. a flush of all waiting webGL commands)
  115338. */
  115339. flushFramebuffer(): void;
  115340. /**
  115341. * Unbind the current render target and bind the default framebuffer
  115342. */
  115343. restoreDefaultFramebuffer(): void;
  115344. /** @hidden */
  115345. protected _resetVertexBufferBinding(): void;
  115346. /**
  115347. * Creates a vertex buffer
  115348. * @param data the data for the vertex buffer
  115349. * @returns the new WebGL static buffer
  115350. */
  115351. createVertexBuffer(data: DataArray): DataBuffer;
  115352. private _createVertexBuffer;
  115353. /**
  115354. * Creates a dynamic vertex buffer
  115355. * @param data the data for the dynamic vertex buffer
  115356. * @returns the new WebGL dynamic buffer
  115357. */
  115358. createDynamicVertexBuffer(data: DataArray): DataBuffer;
  115359. protected _resetIndexBufferBinding(): void;
  115360. /**
  115361. * Creates a new index buffer
  115362. * @param indices defines the content of the index buffer
  115363. * @param updatable defines if the index buffer must be updatable
  115364. * @returns a new webGL buffer
  115365. */
  115366. createIndexBuffer(indices: IndicesArray, updatable?: boolean): DataBuffer;
  115367. protected _normalizeIndexData(indices: IndicesArray): Uint16Array | Uint32Array;
  115368. /**
  115369. * Bind a webGL buffer to the webGL context
  115370. * @param buffer defines the buffer to bind
  115371. */
  115372. bindArrayBuffer(buffer: Nullable<DataBuffer>): void;
  115373. protected bindIndexBuffer(buffer: Nullable<DataBuffer>): void;
  115374. private bindBuffer;
  115375. /**
  115376. * update the bound buffer with the given data
  115377. * @param data defines the data to update
  115378. */
  115379. updateArrayBuffer(data: Float32Array): void;
  115380. private _vertexAttribPointer;
  115381. /** @hidden */
  115382. _bindIndexBufferWithCache(indexBuffer: Nullable<DataBuffer>): void;
  115383. private _bindVertexBuffersAttributes;
  115384. /**
  115385. * Records a vertex array object
  115386. * @see https://doc.babylonjs.com/features/webgl2#vertex-array-objects
  115387. * @param vertexBuffers defines the list of vertex buffers to store
  115388. * @param indexBuffer defines the index buffer to store
  115389. * @param effect defines the effect to store
  115390. * @returns the new vertex array object
  115391. */
  115392. recordVertexArrayObject(vertexBuffers: {
  115393. [key: string]: VertexBuffer;
  115394. }, indexBuffer: Nullable<DataBuffer>, effect: Effect): WebGLVertexArrayObject;
  115395. /**
  115396. * Bind a specific vertex array object
  115397. * @see https://doc.babylonjs.com/features/webgl2#vertex-array-objects
  115398. * @param vertexArrayObject defines the vertex array object to bind
  115399. * @param indexBuffer defines the index buffer to bind
  115400. */
  115401. bindVertexArrayObject(vertexArrayObject: WebGLVertexArrayObject, indexBuffer: Nullable<DataBuffer>): void;
  115402. /**
  115403. * Bind webGl buffers directly to the webGL context
  115404. * @param vertexBuffer defines the vertex buffer to bind
  115405. * @param indexBuffer defines the index buffer to bind
  115406. * @param vertexDeclaration defines the vertex declaration to use with the vertex buffer
  115407. * @param vertexStrideSize defines the vertex stride of the vertex buffer
  115408. * @param effect defines the effect associated with the vertex buffer
  115409. */
  115410. bindBuffersDirectly(vertexBuffer: DataBuffer, indexBuffer: DataBuffer, vertexDeclaration: number[], vertexStrideSize: number, effect: Effect): void;
  115411. private _unbindVertexArrayObject;
  115412. /**
  115413. * Bind a list of vertex buffers to the webGL context
  115414. * @param vertexBuffers defines the list of vertex buffers to bind
  115415. * @param indexBuffer defines the index buffer to bind
  115416. * @param effect defines the effect associated with the vertex buffers
  115417. */
  115418. bindBuffers(vertexBuffers: {
  115419. [key: string]: Nullable<VertexBuffer>;
  115420. }, indexBuffer: Nullable<DataBuffer>, effect: Effect): void;
  115421. /**
  115422. * Unbind all instance attributes
  115423. */
  115424. unbindInstanceAttributes(): void;
  115425. /**
  115426. * Release and free the memory of a vertex array object
  115427. * @param vao defines the vertex array object to delete
  115428. */
  115429. releaseVertexArrayObject(vao: WebGLVertexArrayObject): void;
  115430. /** @hidden */
  115431. _releaseBuffer(buffer: DataBuffer): boolean;
  115432. protected _deleteBuffer(buffer: DataBuffer): void;
  115433. /**
  115434. * Update the content of a webGL buffer used with instanciation and bind it to the webGL context
  115435. * @param instancesBuffer defines the webGL buffer to update and bind
  115436. * @param data defines the data to store in the buffer
  115437. * @param offsetLocations defines the offsets or attributes information used to determine where data must be stored in the buffer
  115438. */
  115439. updateAndBindInstancesBuffer(instancesBuffer: DataBuffer, data: Float32Array, offsetLocations: number[] | InstancingAttributeInfo[]): void;
  115440. /**
  115441. * Bind the content of a webGL buffer used with instantiation
  115442. * @param instancesBuffer defines the webGL buffer to bind
  115443. * @param attributesInfo defines the offsets or attributes information used to determine where data must be stored in the buffer
  115444. * @param computeStride defines Whether to compute the strides from the info or use the default 0
  115445. */
  115446. bindInstancesBuffer(instancesBuffer: DataBuffer, attributesInfo: InstancingAttributeInfo[], computeStride?: boolean): void;
  115447. /**
  115448. * Disable the instance attribute corresponding to the name in parameter
  115449. * @param name defines the name of the attribute to disable
  115450. */
  115451. disableInstanceAttributeByName(name: string): void;
  115452. /**
  115453. * Disable the instance attribute corresponding to the location in parameter
  115454. * @param attributeLocation defines the attribute location of the attribute to disable
  115455. */
  115456. disableInstanceAttribute(attributeLocation: number): void;
  115457. /**
  115458. * Disable the attribute corresponding to the location in parameter
  115459. * @param attributeLocation defines the attribute location of the attribute to disable
  115460. */
  115461. disableAttributeByIndex(attributeLocation: number): void;
  115462. /**
  115463. * Send a draw order
  115464. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  115465. * @param indexStart defines the starting index
  115466. * @param indexCount defines the number of index to draw
  115467. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  115468. */
  115469. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  115470. /**
  115471. * Draw a list of points
  115472. * @param verticesStart defines the index of first vertex to draw
  115473. * @param verticesCount defines the count of vertices to draw
  115474. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  115475. */
  115476. drawPointClouds(verticesStart: number, verticesCount: number, instancesCount?: number): void;
  115477. /**
  115478. * Draw a list of unindexed primitives
  115479. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  115480. * @param verticesStart defines the index of first vertex to draw
  115481. * @param verticesCount defines the count of vertices to draw
  115482. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  115483. */
  115484. drawUnIndexed(useTriangles: boolean, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  115485. /**
  115486. * Draw a list of indexed primitives
  115487. * @param fillMode defines the primitive to use
  115488. * @param indexStart defines the starting index
  115489. * @param indexCount defines the number of index to draw
  115490. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  115491. */
  115492. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  115493. /**
  115494. * Draw a list of unindexed primitives
  115495. * @param fillMode defines the primitive to use
  115496. * @param verticesStart defines the index of first vertex to draw
  115497. * @param verticesCount defines the count of vertices to draw
  115498. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  115499. */
  115500. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  115501. private _drawMode;
  115502. /** @hidden */
  115503. protected _reportDrawCall(): void;
  115504. /** @hidden */
  115505. _releaseEffect(effect: Effect): void;
  115506. /** @hidden */
  115507. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  115508. /**
  115509. * Create a new effect (used to store vertex/fragment shaders)
  115510. * @param baseName defines the base name of the effect (The name of file without .fragment.fx or .vertex.fx)
  115511. * @param attributesNamesOrOptions defines either a list of attribute names or an IEffectCreationOptions object
  115512. * @param uniformsNamesOrEngine defines either a list of uniform names or the engine to use
  115513. * @param samplers defines an array of string used to represent textures
  115514. * @param defines defines the string containing the defines to use to compile the shaders
  115515. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  115516. * @param onCompiled defines a function to call when the effect creation is successful
  115517. * @param onError defines a function to call when the effect creation has failed
  115518. * @param indexParameters defines an object containing the index values to use to compile shaders (like the maximum number of simultaneous lights)
  115519. * @returns the new Effect
  115520. */
  115521. 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;
  115522. protected static _ConcatenateShader(source: string, defines: Nullable<string>, shaderVersion?: string): string;
  115523. private _compileShader;
  115524. private _compileRawShader;
  115525. /** @hidden */
  115526. _getShaderSource(shader: WebGLShader): Nullable<string>;
  115527. /**
  115528. * Directly creates a webGL program
  115529. * @param pipelineContext defines the pipeline context to attach to
  115530. * @param vertexCode defines the vertex shader code to use
  115531. * @param fragmentCode defines the fragment shader code to use
  115532. * @param context defines the webGL context to use (if not set, the current one will be used)
  115533. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  115534. * @returns the new webGL program
  115535. */
  115536. createRawShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  115537. /**
  115538. * Creates a webGL program
  115539. * @param pipelineContext defines the pipeline context to attach to
  115540. * @param vertexCode defines the vertex shader code to use
  115541. * @param fragmentCode defines the fragment shader code to use
  115542. * @param defines defines the string containing the defines to use to compile the shaders
  115543. * @param context defines the webGL context to use (if not set, the current one will be used)
  115544. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  115545. * @returns the new webGL program
  115546. */
  115547. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  115548. /**
  115549. * Creates a new pipeline context
  115550. * @returns the new pipeline
  115551. */
  115552. createPipelineContext(): IPipelineContext;
  115553. protected _createShaderProgram(pipelineContext: WebGLPipelineContext, vertexShader: WebGLShader, fragmentShader: WebGLShader, context: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  115554. protected _finalizePipelineContext(pipelineContext: WebGLPipelineContext): void;
  115555. /** @hidden */
  115556. _preparePipelineContext(pipelineContext: IPipelineContext, vertexSourceCode: string, fragmentSourceCode: string, createAsRaw: boolean, rebuildRebind: any, defines: Nullable<string>, transformFeedbackVaryings: Nullable<string[]>): void;
  115557. /** @hidden */
  115558. _isRenderingStateCompiled(pipelineContext: IPipelineContext): boolean;
  115559. /** @hidden */
  115560. _executeWhenRenderingStateIsCompiled(pipelineContext: IPipelineContext, action: () => void): void;
  115561. /**
  115562. * Gets the list of webGL uniform locations associated with a specific program based on a list of uniform names
  115563. * @param pipelineContext defines the pipeline context to use
  115564. * @param uniformsNames defines the list of uniform names
  115565. * @returns an array of webGL uniform locations
  115566. */
  115567. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): Nullable<WebGLUniformLocation>[];
  115568. /**
  115569. * Gets the lsit of active attributes for a given webGL program
  115570. * @param pipelineContext defines the pipeline context to use
  115571. * @param attributesNames defines the list of attribute names to get
  115572. * @returns an array of indices indicating the offset of each attribute
  115573. */
  115574. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  115575. /**
  115576. * Activates an effect, mkaing it the current one (ie. the one used for rendering)
  115577. * @param effect defines the effect to activate
  115578. */
  115579. enableEffect(effect: Nullable<Effect>): void;
  115580. /**
  115581. * Set the value of an uniform to a number (int)
  115582. * @param uniform defines the webGL uniform location where to store the value
  115583. * @param value defines the int number to store
  115584. */
  115585. setInt(uniform: Nullable<WebGLUniformLocation>, value: number): void;
  115586. /**
  115587. * Set the value of an uniform to an array of int32
  115588. * @param uniform defines the webGL uniform location where to store the value
  115589. * @param array defines the array of int32 to store
  115590. */
  115591. setIntArray(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  115592. /**
  115593. * Set the value of an uniform to an array of int32 (stored as vec2)
  115594. * @param uniform defines the webGL uniform location where to store the value
  115595. * @param array defines the array of int32 to store
  115596. */
  115597. setIntArray2(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  115598. /**
  115599. * Set the value of an uniform to an array of int32 (stored as vec3)
  115600. * @param uniform defines the webGL uniform location where to store the value
  115601. * @param array defines the array of int32 to store
  115602. */
  115603. setIntArray3(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  115604. /**
  115605. * Set the value of an uniform to an array of int32 (stored as vec4)
  115606. * @param uniform defines the webGL uniform location where to store the value
  115607. * @param array defines the array of int32 to store
  115608. */
  115609. setIntArray4(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  115610. /**
  115611. * Set the value of an uniform to an array of number
  115612. * @param uniform defines the webGL uniform location where to store the value
  115613. * @param array defines the array of number to store
  115614. */
  115615. setArray(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): void;
  115616. /**
  115617. * Set the value of an uniform to an array of number (stored as vec2)
  115618. * @param uniform defines the webGL uniform location where to store the value
  115619. * @param array defines the array of number to store
  115620. */
  115621. setArray2(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): void;
  115622. /**
  115623. * Set the value of an uniform to an array of number (stored as vec3)
  115624. * @param uniform defines the webGL uniform location where to store the value
  115625. * @param array defines the array of number to store
  115626. */
  115627. setArray3(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): void;
  115628. /**
  115629. * Set the value of an uniform to an array of number (stored as vec4)
  115630. * @param uniform defines the webGL uniform location where to store the value
  115631. * @param array defines the array of number to store
  115632. */
  115633. setArray4(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): void;
  115634. /**
  115635. * Set the value of an uniform to an array of float32 (stored as matrices)
  115636. * @param uniform defines the webGL uniform location where to store the value
  115637. * @param matrices defines the array of float32 to store
  115638. */
  115639. setMatrices(uniform: Nullable<WebGLUniformLocation>, matrices: Float32Array): void;
  115640. /**
  115641. * Set the value of an uniform to a matrix (3x3)
  115642. * @param uniform defines the webGL uniform location where to store the value
  115643. * @param matrix defines the Float32Array representing the 3x3 matrix to store
  115644. */
  115645. setMatrix3x3(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): void;
  115646. /**
  115647. * Set the value of an uniform to a matrix (2x2)
  115648. * @param uniform defines the webGL uniform location where to store the value
  115649. * @param matrix defines the Float32Array representing the 2x2 matrix to store
  115650. */
  115651. setMatrix2x2(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): void;
  115652. /**
  115653. * Set the value of an uniform to a number (float)
  115654. * @param uniform defines the webGL uniform location where to store the value
  115655. * @param value defines the float number to store
  115656. */
  115657. setFloat(uniform: Nullable<WebGLUniformLocation>, value: number): void;
  115658. /**
  115659. * Set the value of an uniform to a vec2
  115660. * @param uniform defines the webGL uniform location where to store the value
  115661. * @param x defines the 1st component of the value
  115662. * @param y defines the 2nd component of the value
  115663. */
  115664. setFloat2(uniform: Nullable<WebGLUniformLocation>, x: number, y: number): void;
  115665. /**
  115666. * Set the value of an uniform to a vec3
  115667. * @param uniform defines the webGL uniform location where to store the value
  115668. * @param x defines the 1st component of the value
  115669. * @param y defines the 2nd component of the value
  115670. * @param z defines the 3rd component of the value
  115671. */
  115672. setFloat3(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number): void;
  115673. /**
  115674. * Set the value of an uniform to a vec4
  115675. * @param uniform defines the webGL uniform location where to store the value
  115676. * @param x defines the 1st component of the value
  115677. * @param y defines the 2nd component of the value
  115678. * @param z defines the 3rd component of the value
  115679. * @param w defines the 4th component of the value
  115680. */
  115681. setFloat4(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number, w: number): void;
  115682. /**
  115683. * Apply all cached states (depth, culling, stencil and alpha)
  115684. */
  115685. applyStates(): void;
  115686. /**
  115687. * Enable or disable color writing
  115688. * @param enable defines the state to set
  115689. */
  115690. setColorWrite(enable: boolean): void;
  115691. /**
  115692. * Gets a boolean indicating if color writing is enabled
  115693. * @returns the current color writing state
  115694. */
  115695. getColorWrite(): boolean;
  115696. /**
  115697. * Gets the depth culling state manager
  115698. */
  115699. get depthCullingState(): DepthCullingState;
  115700. /**
  115701. * Gets the alpha state manager
  115702. */
  115703. get alphaState(): AlphaState;
  115704. /**
  115705. * Gets the stencil state manager
  115706. */
  115707. get stencilState(): StencilState;
  115708. /**
  115709. * Clears the list of texture accessible through engine.
  115710. * This can help preventing texture load conflict due to name collision.
  115711. */
  115712. clearInternalTexturesCache(): void;
  115713. /**
  115714. * Force the entire cache to be cleared
  115715. * You should not have to use this function unless your engine needs to share the webGL context with another engine
  115716. * @param bruteForce defines a boolean to force clearing ALL caches (including stencil, detoh and alpha states)
  115717. */
  115718. wipeCaches(bruteForce?: boolean): void;
  115719. /** @hidden */
  115720. _getSamplingParameters(samplingMode: number, generateMipMaps: boolean): {
  115721. min: number;
  115722. mag: number;
  115723. };
  115724. /** @hidden */
  115725. _createTexture(): WebGLTexture;
  115726. /**
  115727. * Usually called from Texture.ts.
  115728. * Passed information to create a WebGLTexture
  115729. * @param url defines a value which contains one of the following:
  115730. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  115731. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  115732. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  115733. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  115734. * @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)
  115735. * @param scene needed for loading to the correct scene
  115736. * @param samplingMode mode with should be used sample / access the texture (Default: Texture.TRILINEAR_SAMPLINGMODE)
  115737. * @param onLoad optional callback to be called upon successful completion
  115738. * @param onError optional callback to be called upon failure
  115739. * @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
  115740. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  115741. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  115742. * @param forcedExtension defines the extension to use to pick the right loader
  115743. * @param mimeType defines an optional mime type
  115744. * @returns a InternalTexture for assignment back into BABYLON.Texture
  115745. */
  115746. 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;
  115747. /**
  115748. * Loads an image as an HTMLImageElement.
  115749. * @param input url string, ArrayBuffer, or Blob to load
  115750. * @param onLoad callback called when the image successfully loads
  115751. * @param onError callback called when the image fails to load
  115752. * @param offlineProvider offline provider for caching
  115753. * @param mimeType optional mime type
  115754. * @returns the HTMLImageElement of the loaded image
  115755. * @hidden
  115756. */
  115757. 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>;
  115758. /**
  115759. * @hidden
  115760. */
  115761. _rescaleTexture(source: InternalTexture, destination: InternalTexture, scene: Nullable<any>, internalFormat: number, onComplete: () => void): void;
  115762. private _unpackFlipYCached;
  115763. /**
  115764. * In case you are sharing the context with other applications, it might
  115765. * be interested to not cache the unpack flip y state to ensure a consistent
  115766. * value would be set.
  115767. */
  115768. enableUnpackFlipYCached: boolean;
  115769. /** @hidden */
  115770. _unpackFlipY(value: boolean): void;
  115771. /** @hidden */
  115772. _getUnpackAlignement(): number;
  115773. private _getTextureTarget;
  115774. /**
  115775. * Update the sampling mode of a given texture
  115776. * @param samplingMode defines the required sampling mode
  115777. * @param texture defines the texture to update
  115778. * @param generateMipMaps defines whether to generate mipmaps for the texture
  115779. */
  115780. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture, generateMipMaps?: boolean): void;
  115781. /**
  115782. * Update the sampling mode of a given texture
  115783. * @param texture defines the texture to update
  115784. * @param wrapU defines the texture wrap mode of the u coordinates
  115785. * @param wrapV defines the texture wrap mode of the v coordinates
  115786. * @param wrapR defines the texture wrap mode of the r coordinates
  115787. */
  115788. updateTextureWrappingMode(texture: InternalTexture, wrapU: Nullable<number>, wrapV?: Nullable<number>, wrapR?: Nullable<number>): void;
  115789. /** @hidden */
  115790. _setupDepthStencilTexture(internalTexture: InternalTexture, size: number | {
  115791. width: number;
  115792. height: number;
  115793. layers?: number;
  115794. }, generateStencil: boolean, bilinearFiltering: boolean, comparisonFunction: number): void;
  115795. /** @hidden */
  115796. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  115797. /** @hidden */
  115798. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number, babylonInternalFormat?: number, useTextureWidthAndHeight?: boolean): void;
  115799. /**
  115800. * Update a portion of an internal texture
  115801. * @param texture defines the texture to update
  115802. * @param imageData defines the data to store into the texture
  115803. * @param xOffset defines the x coordinates of the update rectangle
  115804. * @param yOffset defines the y coordinates of the update rectangle
  115805. * @param width defines the width of the update rectangle
  115806. * @param height defines the height of the update rectangle
  115807. * @param faceIndex defines the face index if texture is a cube (0 by default)
  115808. * @param lod defines the lod level to update (0 by default)
  115809. */
  115810. updateTextureData(texture: InternalTexture, imageData: ArrayBufferView, xOffset: number, yOffset: number, width: number, height: number, faceIndex?: number, lod?: number): void;
  115811. /** @hidden */
  115812. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  115813. protected _prepareWebGLTextureContinuation(texture: InternalTexture, scene: Nullable<ISceneLike>, noMipmap: boolean, isCompressed: boolean, samplingMode: number): void;
  115814. private _prepareWebGLTexture;
  115815. /** @hidden */
  115816. _setupFramebufferDepthAttachments(generateStencilBuffer: boolean, generateDepthBuffer: boolean, width: number, height: number, samples?: number): Nullable<WebGLRenderbuffer>;
  115817. private _getDepthStencilBuffer;
  115818. /** @hidden */
  115819. _releaseFramebufferObjects(texture: InternalTexture): void;
  115820. /** @hidden */
  115821. _releaseTexture(texture: InternalTexture): void;
  115822. protected _deleteTexture(texture: Nullable<WebGLTexture>): void;
  115823. protected _setProgram(program: WebGLProgram): void;
  115824. protected _boundUniforms: {
  115825. [key: number]: WebGLUniformLocation;
  115826. };
  115827. /**
  115828. * Binds an effect to the webGL context
  115829. * @param effect defines the effect to bind
  115830. */
  115831. bindSamplers(effect: Effect): void;
  115832. private _activateCurrentTexture;
  115833. /** @hidden */
  115834. _bindTextureDirectly(target: number, texture: Nullable<InternalTexture>, forTextureDataUpdate?: boolean, force?: boolean): boolean;
  115835. /** @hidden */
  115836. _bindTexture(channel: number, texture: Nullable<InternalTexture>): void;
  115837. /**
  115838. * Unbind all textures from the webGL context
  115839. */
  115840. unbindAllTextures(): void;
  115841. /**
  115842. * Sets a texture to the according uniform.
  115843. * @param channel The texture channel
  115844. * @param uniform The uniform to set
  115845. * @param texture The texture to apply
  115846. */
  115847. setTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<BaseTexture>): void;
  115848. private _bindSamplerUniformToChannel;
  115849. private _getTextureWrapMode;
  115850. protected _setTexture(channel: number, texture: Nullable<BaseTexture>, isPartOfTextureArray?: boolean, depthStencilTexture?: boolean): boolean;
  115851. /**
  115852. * Sets an array of texture to the webGL context
  115853. * @param channel defines the channel where the texture array must be set
  115854. * @param uniform defines the associated uniform location
  115855. * @param textures defines the array of textures to bind
  115856. */
  115857. setTextureArray(channel: number, uniform: Nullable<WebGLUniformLocation>, textures: BaseTexture[]): void;
  115858. /** @hidden */
  115859. _setAnisotropicLevel(target: number, internalTexture: InternalTexture, anisotropicFilteringLevel: number): void;
  115860. private _setTextureParameterFloat;
  115861. private _setTextureParameterInteger;
  115862. /**
  115863. * Unbind all vertex attributes from the webGL context
  115864. */
  115865. unbindAllAttributes(): void;
  115866. /**
  115867. * 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
  115868. */
  115869. releaseEffects(): void;
  115870. /**
  115871. * Dispose and release all associated resources
  115872. */
  115873. dispose(): void;
  115874. /**
  115875. * Attach a new callback raised when context lost event is fired
  115876. * @param callback defines the callback to call
  115877. */
  115878. attachContextLostEvent(callback: ((event: WebGLContextEvent) => void)): void;
  115879. /**
  115880. * Attach a new callback raised when context restored event is fired
  115881. * @param callback defines the callback to call
  115882. */
  115883. attachContextRestoredEvent(callback: ((event: WebGLContextEvent) => void)): void;
  115884. /**
  115885. * Get the current error code of the webGL context
  115886. * @returns the error code
  115887. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  115888. */
  115889. getError(): number;
  115890. private _canRenderToFloatFramebuffer;
  115891. private _canRenderToHalfFloatFramebuffer;
  115892. private _canRenderToFramebuffer;
  115893. /** @hidden */
  115894. _getWebGLTextureType(type: number): number;
  115895. /** @hidden */
  115896. _getInternalFormat(format: number): number;
  115897. /** @hidden */
  115898. _getRGBABufferInternalSizedFormat(type: number, format?: number): number;
  115899. /** @hidden */
  115900. _getRGBAMultiSampleBufferFormat(type: number): number;
  115901. /** @hidden */
  115902. _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;
  115903. /**
  115904. * Loads a file from a url
  115905. * @param url url to load
  115906. * @param onSuccess callback called when the file successfully loads
  115907. * @param onProgress callback called while file is loading (if the server supports this mode)
  115908. * @param offlineProvider defines the offline provider for caching
  115909. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  115910. * @param onError callback called when the file fails to load
  115911. * @returns a file request object
  115912. * @hidden
  115913. */
  115914. 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;
  115915. /**
  115916. * Reads pixels from the current frame buffer. Please note that this function can be slow
  115917. * @param x defines the x coordinate of the rectangle where pixels must be read
  115918. * @param y defines the y coordinate of the rectangle where pixels must be read
  115919. * @param width defines the width of the rectangle where pixels must be read
  115920. * @param height defines the height of the rectangle where pixels must be read
  115921. * @param hasAlpha defines whether the output should have alpha or not (defaults to true)
  115922. * @returns a Uint8Array containing RGBA colors
  115923. */
  115924. readPixels(x: number, y: number, width: number, height: number, hasAlpha?: boolean): Uint8Array;
  115925. private static _isSupported;
  115926. /**
  115927. * Gets a boolean indicating if the engine can be instanciated (ie. if a webGL context can be found)
  115928. * @returns true if the engine can be created
  115929. * @ignorenaming
  115930. */
  115931. static isSupported(): boolean;
  115932. /**
  115933. * Find the next highest power of two.
  115934. * @param x Number to start search from.
  115935. * @return Next highest power of two.
  115936. */
  115937. static CeilingPOT(x: number): number;
  115938. /**
  115939. * Find the next lowest power of two.
  115940. * @param x Number to start search from.
  115941. * @return Next lowest power of two.
  115942. */
  115943. static FloorPOT(x: number): number;
  115944. /**
  115945. * Find the nearest power of two.
  115946. * @param x Number to start search from.
  115947. * @return Next nearest power of two.
  115948. */
  115949. static NearestPOT(x: number): number;
  115950. /**
  115951. * Get the closest exponent of two
  115952. * @param value defines the value to approximate
  115953. * @param max defines the maximum value to return
  115954. * @param mode defines how to define the closest value
  115955. * @returns closest exponent of two of the given value
  115956. */
  115957. static GetExponentOfTwo(value: number, max: number, mode?: number): number;
  115958. /**
  115959. * Queue a new function into the requested animation frame pool (ie. this function will be executed byt the browser for the next frame)
  115960. * @param func - the function to be called
  115961. * @param requester - the object that will request the next frame. Falls back to window.
  115962. * @returns frame number
  115963. */
  115964. static QueueNewFrame(func: () => void, requester?: any): number;
  115965. /**
  115966. * Gets host document
  115967. * @returns the host document object
  115968. */
  115969. getHostDocument(): Nullable<Document>;
  115970. }
  115971. }
  115972. declare module BABYLON {
  115973. /**
  115974. * Class representing spherical harmonics coefficients to the 3rd degree
  115975. */
  115976. export class SphericalHarmonics {
  115977. /**
  115978. * Defines whether or not the harmonics have been prescaled for rendering.
  115979. */
  115980. preScaled: boolean;
  115981. /**
  115982. * The l0,0 coefficients of the spherical harmonics
  115983. */
  115984. l00: Vector3;
  115985. /**
  115986. * The l1,-1 coefficients of the spherical harmonics
  115987. */
  115988. l1_1: Vector3;
  115989. /**
  115990. * The l1,0 coefficients of the spherical harmonics
  115991. */
  115992. l10: Vector3;
  115993. /**
  115994. * The l1,1 coefficients of the spherical harmonics
  115995. */
  115996. l11: Vector3;
  115997. /**
  115998. * The l2,-2 coefficients of the spherical harmonics
  115999. */
  116000. l2_2: Vector3;
  116001. /**
  116002. * The l2,-1 coefficients of the spherical harmonics
  116003. */
  116004. l2_1: Vector3;
  116005. /**
  116006. * The l2,0 coefficients of the spherical harmonics
  116007. */
  116008. l20: Vector3;
  116009. /**
  116010. * The l2,1 coefficients of the spherical harmonics
  116011. */
  116012. l21: Vector3;
  116013. /**
  116014. * The l2,2 coefficients of the spherical harmonics
  116015. */
  116016. l22: Vector3;
  116017. /**
  116018. * Adds a light to the spherical harmonics
  116019. * @param direction the direction of the light
  116020. * @param color the color of the light
  116021. * @param deltaSolidAngle the delta solid angle of the light
  116022. */
  116023. addLight(direction: Vector3, color: Color3, deltaSolidAngle: number): void;
  116024. /**
  116025. * Scales the spherical harmonics by the given amount
  116026. * @param scale the amount to scale
  116027. */
  116028. scaleInPlace(scale: number): void;
  116029. /**
  116030. * Convert from incident radiance (Li) to irradiance (E) by applying convolution with the cosine-weighted hemisphere.
  116031. *
  116032. * ```
  116033. * E_lm = A_l * L_lm
  116034. * ```
  116035. *
  116036. * In spherical harmonics this convolution amounts to scaling factors for each frequency band.
  116037. * This corresponds to equation 5 in "An Efficient Representation for Irradiance Environment Maps", where
  116038. * the scaling factors are given in equation 9.
  116039. */
  116040. convertIncidentRadianceToIrradiance(): void;
  116041. /**
  116042. * Convert from irradiance to outgoing radiance for Lambertian BDRF, suitable for efficient shader evaluation.
  116043. *
  116044. * ```
  116045. * L = (1/pi) * E * rho
  116046. * ```
  116047. *
  116048. * This is done by an additional scale by 1/pi, so is a fairly trivial operation but important conceptually.
  116049. */
  116050. convertIrradianceToLambertianRadiance(): void;
  116051. /**
  116052. * Integrates the reconstruction coefficients directly in to the SH preventing further
  116053. * required operations at run time.
  116054. *
  116055. * This is simply done by scaling back the SH with Ylm constants parameter.
  116056. * The trigonometric part being applied by the shader at run time.
  116057. */
  116058. preScaleForRendering(): void;
  116059. /**
  116060. * Constructs a spherical harmonics from an array.
  116061. * @param data defines the 9x3 coefficients (l00, l1-1, l10, l11, l2-2, l2-1, l20, l21, l22)
  116062. * @returns the spherical harmonics
  116063. */
  116064. static FromArray(data: ArrayLike<ArrayLike<number>>): SphericalHarmonics;
  116065. /**
  116066. * Gets the spherical harmonics from polynomial
  116067. * @param polynomial the spherical polynomial
  116068. * @returns the spherical harmonics
  116069. */
  116070. static FromPolynomial(polynomial: SphericalPolynomial): SphericalHarmonics;
  116071. }
  116072. /**
  116073. * Class representing spherical polynomial coefficients to the 3rd degree
  116074. */
  116075. export class SphericalPolynomial {
  116076. private _harmonics;
  116077. /**
  116078. * The spherical harmonics used to create the polynomials.
  116079. */
  116080. get preScaledHarmonics(): SphericalHarmonics;
  116081. /**
  116082. * The x coefficients of the spherical polynomial
  116083. */
  116084. x: Vector3;
  116085. /**
  116086. * The y coefficients of the spherical polynomial
  116087. */
  116088. y: Vector3;
  116089. /**
  116090. * The z coefficients of the spherical polynomial
  116091. */
  116092. z: Vector3;
  116093. /**
  116094. * The xx coefficients of the spherical polynomial
  116095. */
  116096. xx: Vector3;
  116097. /**
  116098. * The yy coefficients of the spherical polynomial
  116099. */
  116100. yy: Vector3;
  116101. /**
  116102. * The zz coefficients of the spherical polynomial
  116103. */
  116104. zz: Vector3;
  116105. /**
  116106. * The xy coefficients of the spherical polynomial
  116107. */
  116108. xy: Vector3;
  116109. /**
  116110. * The yz coefficients of the spherical polynomial
  116111. */
  116112. yz: Vector3;
  116113. /**
  116114. * The zx coefficients of the spherical polynomial
  116115. */
  116116. zx: Vector3;
  116117. /**
  116118. * Adds an ambient color to the spherical polynomial
  116119. * @param color the color to add
  116120. */
  116121. addAmbient(color: Color3): void;
  116122. /**
  116123. * Scales the spherical polynomial by the given amount
  116124. * @param scale the amount to scale
  116125. */
  116126. scaleInPlace(scale: number): void;
  116127. /**
  116128. * Gets the spherical polynomial from harmonics
  116129. * @param harmonics the spherical harmonics
  116130. * @returns the spherical polynomial
  116131. */
  116132. static FromHarmonics(harmonics: SphericalHarmonics): SphericalPolynomial;
  116133. /**
  116134. * Constructs a spherical polynomial from an array.
  116135. * @param data defines the 9x3 coefficients (x, y, z, xx, yy, zz, yz, zx, xy)
  116136. * @returns the spherical polynomial
  116137. */
  116138. static FromArray(data: ArrayLike<ArrayLike<number>>): SphericalPolynomial;
  116139. }
  116140. }
  116141. declare module BABYLON {
  116142. /**
  116143. * Defines the source of the internal texture
  116144. */
  116145. export enum InternalTextureSource {
  116146. /**
  116147. * The source of the texture data is unknown
  116148. */
  116149. Unknown = 0,
  116150. /**
  116151. * Texture data comes from an URL
  116152. */
  116153. Url = 1,
  116154. /**
  116155. * Texture data is only used for temporary storage
  116156. */
  116157. Temp = 2,
  116158. /**
  116159. * Texture data comes from raw data (ArrayBuffer)
  116160. */
  116161. Raw = 3,
  116162. /**
  116163. * Texture content is dynamic (video or dynamic texture)
  116164. */
  116165. Dynamic = 4,
  116166. /**
  116167. * Texture content is generated by rendering to it
  116168. */
  116169. RenderTarget = 5,
  116170. /**
  116171. * Texture content is part of a multi render target process
  116172. */
  116173. MultiRenderTarget = 6,
  116174. /**
  116175. * Texture data comes from a cube data file
  116176. */
  116177. Cube = 7,
  116178. /**
  116179. * Texture data comes from a raw cube data
  116180. */
  116181. CubeRaw = 8,
  116182. /**
  116183. * Texture data come from a prefiltered cube data file
  116184. */
  116185. CubePrefiltered = 9,
  116186. /**
  116187. * Texture content is raw 3D data
  116188. */
  116189. Raw3D = 10,
  116190. /**
  116191. * Texture content is raw 2D array data
  116192. */
  116193. Raw2DArray = 11,
  116194. /**
  116195. * Texture content is a depth texture
  116196. */
  116197. Depth = 12,
  116198. /**
  116199. * Texture data comes from a raw cube data encoded with RGBD
  116200. */
  116201. CubeRawRGBD = 13
  116202. }
  116203. /**
  116204. * Class used to store data associated with WebGL texture data for the engine
  116205. * This class should not be used directly
  116206. */
  116207. export class InternalTexture {
  116208. /** @hidden */
  116209. static _UpdateRGBDAsync: (internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number) => Promise<void>;
  116210. /**
  116211. * Defines if the texture is ready
  116212. */
  116213. isReady: boolean;
  116214. /**
  116215. * Defines if the texture is a cube texture
  116216. */
  116217. isCube: boolean;
  116218. /**
  116219. * Defines if the texture contains 3D data
  116220. */
  116221. is3D: boolean;
  116222. /**
  116223. * Defines if the texture contains 2D array data
  116224. */
  116225. is2DArray: boolean;
  116226. /**
  116227. * Defines if the texture contains multiview data
  116228. */
  116229. isMultiview: boolean;
  116230. /**
  116231. * Gets the URL used to load this texture
  116232. */
  116233. url: string;
  116234. /**
  116235. * Gets the sampling mode of the texture
  116236. */
  116237. samplingMode: number;
  116238. /**
  116239. * Gets a boolean indicating if the texture needs mipmaps generation
  116240. */
  116241. generateMipMaps: boolean;
  116242. /**
  116243. * Gets the number of samples used by the texture (WebGL2+ only)
  116244. */
  116245. samples: number;
  116246. /**
  116247. * Gets the type of the texture (int, float...)
  116248. */
  116249. type: number;
  116250. /**
  116251. * Gets the format of the texture (RGB, RGBA...)
  116252. */
  116253. format: number;
  116254. /**
  116255. * Observable called when the texture is loaded
  116256. */
  116257. onLoadedObservable: Observable<InternalTexture>;
  116258. /**
  116259. * Gets the width of the texture
  116260. */
  116261. width: number;
  116262. /**
  116263. * Gets the height of the texture
  116264. */
  116265. height: number;
  116266. /**
  116267. * Gets the depth of the texture
  116268. */
  116269. depth: number;
  116270. /**
  116271. * Gets the initial width of the texture (It could be rescaled if the current system does not support non power of two textures)
  116272. */
  116273. baseWidth: number;
  116274. /**
  116275. * Gets the initial height of the texture (It could be rescaled if the current system does not support non power of two textures)
  116276. */
  116277. baseHeight: number;
  116278. /**
  116279. * Gets the initial depth of the texture (It could be rescaled if the current system does not support non power of two textures)
  116280. */
  116281. baseDepth: number;
  116282. /**
  116283. * Gets a boolean indicating if the texture is inverted on Y axis
  116284. */
  116285. invertY: boolean;
  116286. /** @hidden */
  116287. _invertVScale: boolean;
  116288. /** @hidden */
  116289. _associatedChannel: number;
  116290. /** @hidden */
  116291. _source: InternalTextureSource;
  116292. /** @hidden */
  116293. _buffer: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob | ImageBitmap>;
  116294. /** @hidden */
  116295. _bufferView: Nullable<ArrayBufferView>;
  116296. /** @hidden */
  116297. _bufferViewArray: Nullable<ArrayBufferView[]>;
  116298. /** @hidden */
  116299. _bufferViewArrayArray: Nullable<ArrayBufferView[][]>;
  116300. /** @hidden */
  116301. _size: number;
  116302. /** @hidden */
  116303. _extension: string;
  116304. /** @hidden */
  116305. _files: Nullable<string[]>;
  116306. /** @hidden */
  116307. _workingCanvas: Nullable<HTMLCanvasElement | OffscreenCanvas>;
  116308. /** @hidden */
  116309. _workingContext: Nullable<CanvasRenderingContext2D | OffscreenCanvasRenderingContext2D>;
  116310. /** @hidden */
  116311. _framebuffer: Nullable<WebGLFramebuffer>;
  116312. /** @hidden */
  116313. _depthStencilBuffer: Nullable<WebGLRenderbuffer>;
  116314. /** @hidden */
  116315. _MSAAFramebuffer: Nullable<WebGLFramebuffer>;
  116316. /** @hidden */
  116317. _MSAARenderBuffer: Nullable<WebGLRenderbuffer>;
  116318. /** @hidden */
  116319. _attachments: Nullable<number[]>;
  116320. /** @hidden */
  116321. _textureArray: Nullable<InternalTexture[]>;
  116322. /** @hidden */
  116323. _cachedCoordinatesMode: Nullable<number>;
  116324. /** @hidden */
  116325. _cachedWrapU: Nullable<number>;
  116326. /** @hidden */
  116327. _cachedWrapV: Nullable<number>;
  116328. /** @hidden */
  116329. _cachedWrapR: Nullable<number>;
  116330. /** @hidden */
  116331. _cachedAnisotropicFilteringLevel: Nullable<number>;
  116332. /** @hidden */
  116333. _isDisabled: boolean;
  116334. /** @hidden */
  116335. _compression: Nullable<string>;
  116336. /** @hidden */
  116337. _generateStencilBuffer: boolean;
  116338. /** @hidden */
  116339. _generateDepthBuffer: boolean;
  116340. /** @hidden */
  116341. _comparisonFunction: number;
  116342. /** @hidden */
  116343. _sphericalPolynomial: Nullable<SphericalPolynomial>;
  116344. /** @hidden */
  116345. _lodGenerationScale: number;
  116346. /** @hidden */
  116347. _lodGenerationOffset: number;
  116348. /** @hidden */
  116349. _depthStencilTexture: Nullable<InternalTexture>;
  116350. /** @hidden */
  116351. _colorTextureArray: Nullable<WebGLTexture>;
  116352. /** @hidden */
  116353. _depthStencilTextureArray: Nullable<WebGLTexture>;
  116354. /** @hidden */
  116355. _lodTextureHigh: Nullable<BaseTexture>;
  116356. /** @hidden */
  116357. _lodTextureMid: Nullable<BaseTexture>;
  116358. /** @hidden */
  116359. _lodTextureLow: Nullable<BaseTexture>;
  116360. /** @hidden */
  116361. _isRGBD: boolean;
  116362. /** @hidden */
  116363. _linearSpecularLOD: boolean;
  116364. /** @hidden */
  116365. _irradianceTexture: Nullable<BaseTexture>;
  116366. /** @hidden */
  116367. _webGLTexture: Nullable<WebGLTexture>;
  116368. /** @hidden */
  116369. _references: number;
  116370. private _engine;
  116371. /**
  116372. * Gets the Engine the texture belongs to.
  116373. * @returns The babylon engine
  116374. */
  116375. getEngine(): ThinEngine;
  116376. /**
  116377. * Gets the data source type of the texture
  116378. */
  116379. get source(): InternalTextureSource;
  116380. /**
  116381. * Creates a new InternalTexture
  116382. * @param engine defines the engine to use
  116383. * @param source defines the type of data that will be used
  116384. * @param delayAllocation if the texture allocation should be delayed (default: false)
  116385. */
  116386. constructor(engine: ThinEngine, source: InternalTextureSource, delayAllocation?: boolean);
  116387. /**
  116388. * Increments the number of references (ie. the number of Texture that point to it)
  116389. */
  116390. incrementReferences(): void;
  116391. /**
  116392. * Change the size of the texture (not the size of the content)
  116393. * @param width defines the new width
  116394. * @param height defines the new height
  116395. * @param depth defines the new depth (1 by default)
  116396. */
  116397. updateSize(width: int, height: int, depth?: int): void;
  116398. /** @hidden */
  116399. _rebuild(): void;
  116400. /** @hidden */
  116401. _swapAndDie(target: InternalTexture): void;
  116402. /**
  116403. * Dispose the current allocated resources
  116404. */
  116405. dispose(): void;
  116406. }
  116407. }
  116408. declare module BABYLON {
  116409. /**
  116410. * Class used to work with sound analyzer using fast fourier transform (FFT)
  116411. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  116412. */
  116413. export class Analyser {
  116414. /**
  116415. * Gets or sets the smoothing
  116416. * @ignorenaming
  116417. */
  116418. SMOOTHING: number;
  116419. /**
  116420. * Gets or sets the FFT table size
  116421. * @ignorenaming
  116422. */
  116423. FFT_SIZE: number;
  116424. /**
  116425. * Gets or sets the bar graph amplitude
  116426. * @ignorenaming
  116427. */
  116428. BARGRAPHAMPLITUDE: number;
  116429. /**
  116430. * Gets or sets the position of the debug canvas
  116431. * @ignorenaming
  116432. */
  116433. DEBUGCANVASPOS: {
  116434. x: number;
  116435. y: number;
  116436. };
  116437. /**
  116438. * Gets or sets the debug canvas size
  116439. * @ignorenaming
  116440. */
  116441. DEBUGCANVASSIZE: {
  116442. width: number;
  116443. height: number;
  116444. };
  116445. private _byteFreqs;
  116446. private _byteTime;
  116447. private _floatFreqs;
  116448. private _webAudioAnalyser;
  116449. private _debugCanvas;
  116450. private _debugCanvasContext;
  116451. private _scene;
  116452. private _registerFunc;
  116453. private _audioEngine;
  116454. /**
  116455. * Creates a new analyser
  116456. * @param scene defines hosting scene
  116457. */
  116458. constructor(scene: Scene);
  116459. /**
  116460. * Get the number of data values you will have to play with for the visualization
  116461. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/frequencyBinCount
  116462. * @returns a number
  116463. */
  116464. getFrequencyBinCount(): number;
  116465. /**
  116466. * Gets the current frequency data as a byte array
  116467. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  116468. * @returns a Uint8Array
  116469. */
  116470. getByteFrequencyData(): Uint8Array;
  116471. /**
  116472. * Gets the current waveform as a byte array
  116473. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteTimeDomainData
  116474. * @returns a Uint8Array
  116475. */
  116476. getByteTimeDomainData(): Uint8Array;
  116477. /**
  116478. * Gets the current frequency data as a float array
  116479. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  116480. * @returns a Float32Array
  116481. */
  116482. getFloatFrequencyData(): Float32Array;
  116483. /**
  116484. * Renders the debug canvas
  116485. */
  116486. drawDebugCanvas(): void;
  116487. /**
  116488. * Stops rendering the debug canvas and removes it
  116489. */
  116490. stopDebugCanvas(): void;
  116491. /**
  116492. * Connects two audio nodes
  116493. * @param inputAudioNode defines first node to connect
  116494. * @param outputAudioNode defines second node to connect
  116495. */
  116496. connectAudioNodes(inputAudioNode: AudioNode, outputAudioNode: AudioNode): void;
  116497. /**
  116498. * Releases all associated resources
  116499. */
  116500. dispose(): void;
  116501. }
  116502. }
  116503. declare module BABYLON {
  116504. /**
  116505. * This represents an audio engine and it is responsible
  116506. * to play, synchronize and analyse sounds throughout the application.
  116507. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  116508. */
  116509. export interface IAudioEngine extends IDisposable {
  116510. /**
  116511. * Gets whether the current host supports Web Audio and thus could create AudioContexts.
  116512. */
  116513. readonly canUseWebAudio: boolean;
  116514. /**
  116515. * Gets the current AudioContext if available.
  116516. */
  116517. readonly audioContext: Nullable<AudioContext>;
  116518. /**
  116519. * The master gain node defines the global audio volume of your audio engine.
  116520. */
  116521. readonly masterGain: GainNode;
  116522. /**
  116523. * Gets whether or not mp3 are supported by your browser.
  116524. */
  116525. readonly isMP3supported: boolean;
  116526. /**
  116527. * Gets whether or not ogg are supported by your browser.
  116528. */
  116529. readonly isOGGsupported: boolean;
  116530. /**
  116531. * Defines if Babylon should emit a warning if WebAudio is not supported.
  116532. * @ignoreNaming
  116533. */
  116534. WarnedWebAudioUnsupported: boolean;
  116535. /**
  116536. * Defines if the audio engine relies on a custom unlocked button.
  116537. * In this case, the embedded button will not be displayed.
  116538. */
  116539. useCustomUnlockedButton: boolean;
  116540. /**
  116541. * Gets whether or not the audio engine is unlocked (require first a user gesture on some browser).
  116542. */
  116543. readonly unlocked: boolean;
  116544. /**
  116545. * Event raised when audio has been unlocked on the browser.
  116546. */
  116547. onAudioUnlockedObservable: Observable<AudioEngine>;
  116548. /**
  116549. * Event raised when audio has been locked on the browser.
  116550. */
  116551. onAudioLockedObservable: Observable<AudioEngine>;
  116552. /**
  116553. * Flags the audio engine in Locked state.
  116554. * This happens due to new browser policies preventing audio to autoplay.
  116555. */
  116556. lock(): void;
  116557. /**
  116558. * Unlocks the audio engine once a user action has been done on the dom.
  116559. * This is helpful to resume play once browser policies have been satisfied.
  116560. */
  116561. unlock(): void;
  116562. /**
  116563. * Gets the global volume sets on the master gain.
  116564. * @returns the global volume if set or -1 otherwise
  116565. */
  116566. getGlobalVolume(): number;
  116567. /**
  116568. * Sets the global volume of your experience (sets on the master gain).
  116569. * @param newVolume Defines the new global volume of the application
  116570. */
  116571. setGlobalVolume(newVolume: number): void;
  116572. /**
  116573. * Connect the audio engine to an audio analyser allowing some amazing
  116574. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  116575. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  116576. * @param analyser The analyser to connect to the engine
  116577. */
  116578. connectToAnalyser(analyser: Analyser): void;
  116579. }
  116580. /**
  116581. * This represents the default audio engine used in babylon.
  116582. * It is responsible to play, synchronize and analyse sounds throughout the application.
  116583. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  116584. */
  116585. export class AudioEngine implements IAudioEngine {
  116586. private _audioContext;
  116587. private _audioContextInitialized;
  116588. private _muteButton;
  116589. private _hostElement;
  116590. /**
  116591. * Gets whether the current host supports Web Audio and thus could create AudioContexts.
  116592. */
  116593. canUseWebAudio: boolean;
  116594. /**
  116595. * The master gain node defines the global audio volume of your audio engine.
  116596. */
  116597. masterGain: GainNode;
  116598. /**
  116599. * Defines if Babylon should emit a warning if WebAudio is not supported.
  116600. * @ignoreNaming
  116601. */
  116602. WarnedWebAudioUnsupported: boolean;
  116603. /**
  116604. * Gets whether or not mp3 are supported by your browser.
  116605. */
  116606. isMP3supported: boolean;
  116607. /**
  116608. * Gets whether or not ogg are supported by your browser.
  116609. */
  116610. isOGGsupported: boolean;
  116611. /**
  116612. * Gets whether audio has been unlocked on the device.
  116613. * Some Browsers have strong restrictions about Audio and won t autoplay unless
  116614. * a user interaction has happened.
  116615. */
  116616. unlocked: boolean;
  116617. /**
  116618. * Defines if the audio engine relies on a custom unlocked button.
  116619. * In this case, the embedded button will not be displayed.
  116620. */
  116621. useCustomUnlockedButton: boolean;
  116622. /**
  116623. * Event raised when audio has been unlocked on the browser.
  116624. */
  116625. onAudioUnlockedObservable: Observable<AudioEngine>;
  116626. /**
  116627. * Event raised when audio has been locked on the browser.
  116628. */
  116629. onAudioLockedObservable: Observable<AudioEngine>;
  116630. /**
  116631. * Gets the current AudioContext if available.
  116632. */
  116633. get audioContext(): Nullable<AudioContext>;
  116634. private _connectedAnalyser;
  116635. /**
  116636. * Instantiates a new audio engine.
  116637. *
  116638. * There should be only one per page as some browsers restrict the number
  116639. * of audio contexts you can create.
  116640. * @param hostElement defines the host element where to display the mute icon if necessary
  116641. */
  116642. constructor(hostElement?: Nullable<HTMLElement>);
  116643. /**
  116644. * Flags the audio engine in Locked state.
  116645. * This happens due to new browser policies preventing audio to autoplay.
  116646. */
  116647. lock(): void;
  116648. /**
  116649. * Unlocks the audio engine once a user action has been done on the dom.
  116650. * This is helpful to resume play once browser policies have been satisfied.
  116651. */
  116652. unlock(): void;
  116653. private _resumeAudioContext;
  116654. private _initializeAudioContext;
  116655. private _tryToRun;
  116656. private _triggerRunningState;
  116657. private _triggerSuspendedState;
  116658. private _displayMuteButton;
  116659. private _moveButtonToTopLeft;
  116660. private _onResize;
  116661. private _hideMuteButton;
  116662. /**
  116663. * Destroy and release the resources associated with the audio ccontext.
  116664. */
  116665. dispose(): void;
  116666. /**
  116667. * Gets the global volume sets on the master gain.
  116668. * @returns the global volume if set or -1 otherwise
  116669. */
  116670. getGlobalVolume(): number;
  116671. /**
  116672. * Sets the global volume of your experience (sets on the master gain).
  116673. * @param newVolume Defines the new global volume of the application
  116674. */
  116675. setGlobalVolume(newVolume: number): void;
  116676. /**
  116677. * Connect the audio engine to an audio analyser allowing some amazing
  116678. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  116679. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  116680. * @param analyser The analyser to connect to the engine
  116681. */
  116682. connectToAnalyser(analyser: Analyser): void;
  116683. }
  116684. }
  116685. declare module BABYLON {
  116686. /**
  116687. * Interface used to present a loading screen while loading a scene
  116688. * @see https://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  116689. */
  116690. export interface ILoadingScreen {
  116691. /**
  116692. * Function called to display the loading screen
  116693. */
  116694. displayLoadingUI: () => void;
  116695. /**
  116696. * Function called to hide the loading screen
  116697. */
  116698. hideLoadingUI: () => void;
  116699. /**
  116700. * Gets or sets the color to use for the background
  116701. */
  116702. loadingUIBackgroundColor: string;
  116703. /**
  116704. * Gets or sets the text to display while loading
  116705. */
  116706. loadingUIText: string;
  116707. }
  116708. /**
  116709. * Class used for the default loading screen
  116710. * @see https://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  116711. */
  116712. export class DefaultLoadingScreen implements ILoadingScreen {
  116713. private _renderingCanvas;
  116714. private _loadingText;
  116715. private _loadingDivBackgroundColor;
  116716. private _loadingDiv;
  116717. private _loadingTextDiv;
  116718. /** Gets or sets the logo url to use for the default loading screen */
  116719. static DefaultLogoUrl: string;
  116720. /** Gets or sets the spinner url to use for the default loading screen */
  116721. static DefaultSpinnerUrl: string;
  116722. /**
  116723. * Creates a new default loading screen
  116724. * @param _renderingCanvas defines the canvas used to render the scene
  116725. * @param _loadingText defines the default text to display
  116726. * @param _loadingDivBackgroundColor defines the default background color
  116727. */
  116728. constructor(_renderingCanvas: HTMLCanvasElement, _loadingText?: string, _loadingDivBackgroundColor?: string);
  116729. /**
  116730. * Function called to display the loading screen
  116731. */
  116732. displayLoadingUI(): void;
  116733. /**
  116734. * Function called to hide the loading screen
  116735. */
  116736. hideLoadingUI(): void;
  116737. /**
  116738. * Gets or sets the text to display while loading
  116739. */
  116740. set loadingUIText(text: string);
  116741. get loadingUIText(): string;
  116742. /**
  116743. * Gets or sets the color to use for the background
  116744. */
  116745. get loadingUIBackgroundColor(): string;
  116746. set loadingUIBackgroundColor(color: string);
  116747. private _resizeLoadingUI;
  116748. }
  116749. }
  116750. declare module BABYLON {
  116751. /**
  116752. * Interface for any object that can request an animation frame
  116753. */
  116754. export interface ICustomAnimationFrameRequester {
  116755. /**
  116756. * This function will be called when the render loop is ready. If this is not populated, the engine's renderloop function will be called
  116757. */
  116758. renderFunction?: Function;
  116759. /**
  116760. * Called to request the next frame to render to
  116761. * @see https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame
  116762. */
  116763. requestAnimationFrame: Function;
  116764. /**
  116765. * You can pass this value to cancelAnimationFrame() to cancel the refresh callback request
  116766. * @see https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame#Return_value
  116767. */
  116768. requestID?: number;
  116769. }
  116770. }
  116771. declare module BABYLON {
  116772. /**
  116773. * Performance monitor tracks rolling average frame-time and frame-time variance over a user defined sliding-window
  116774. */
  116775. export class PerformanceMonitor {
  116776. private _enabled;
  116777. private _rollingFrameTime;
  116778. private _lastFrameTimeMs;
  116779. /**
  116780. * constructor
  116781. * @param frameSampleSize The number of samples required to saturate the sliding window
  116782. */
  116783. constructor(frameSampleSize?: number);
  116784. /**
  116785. * Samples current frame
  116786. * @param timeMs A timestamp in milliseconds of the current frame to compare with other frames
  116787. */
  116788. sampleFrame(timeMs?: number): void;
  116789. /**
  116790. * Returns the average frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  116791. */
  116792. get averageFrameTime(): number;
  116793. /**
  116794. * Returns the variance frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  116795. */
  116796. get averageFrameTimeVariance(): number;
  116797. /**
  116798. * Returns the frame time of the most recent frame
  116799. */
  116800. get instantaneousFrameTime(): number;
  116801. /**
  116802. * Returns the average framerate in frames per second over the sliding window (or the subset of frames sampled so far)
  116803. */
  116804. get averageFPS(): number;
  116805. /**
  116806. * Returns the average framerate in frames per second using the most recent frame time
  116807. */
  116808. get instantaneousFPS(): number;
  116809. /**
  116810. * Returns true if enough samples have been taken to completely fill the sliding window
  116811. */
  116812. get isSaturated(): boolean;
  116813. /**
  116814. * Enables contributions to the sliding window sample set
  116815. */
  116816. enable(): void;
  116817. /**
  116818. * Disables contributions to the sliding window sample set
  116819. * Samples will not be interpolated over the disabled period
  116820. */
  116821. disable(): void;
  116822. /**
  116823. * Returns true if sampling is enabled
  116824. */
  116825. get isEnabled(): boolean;
  116826. /**
  116827. * Resets performance monitor
  116828. */
  116829. reset(): void;
  116830. }
  116831. /**
  116832. * RollingAverage
  116833. *
  116834. * Utility to efficiently compute the rolling average and variance over a sliding window of samples
  116835. */
  116836. export class RollingAverage {
  116837. /**
  116838. * Current average
  116839. */
  116840. average: number;
  116841. /**
  116842. * Current variance
  116843. */
  116844. variance: number;
  116845. protected _samples: Array<number>;
  116846. protected _sampleCount: number;
  116847. protected _pos: number;
  116848. protected _m2: number;
  116849. /**
  116850. * constructor
  116851. * @param length The number of samples required to saturate the sliding window
  116852. */
  116853. constructor(length: number);
  116854. /**
  116855. * Adds a sample to the sample set
  116856. * @param v The sample value
  116857. */
  116858. add(v: number): void;
  116859. /**
  116860. * Returns previously added values or null if outside of history or outside the sliding window domain
  116861. * @param i Index in history. For example, pass 0 for the most recent value and 1 for the value before that
  116862. * @return Value previously recorded with add() or null if outside of range
  116863. */
  116864. history(i: number): number;
  116865. /**
  116866. * Returns true if enough samples have been taken to completely fill the sliding window
  116867. * @return true if sample-set saturated
  116868. */
  116869. isSaturated(): boolean;
  116870. /**
  116871. * Resets the rolling average (equivalent to 0 samples taken so far)
  116872. */
  116873. reset(): void;
  116874. /**
  116875. * Wraps a value around the sample range boundaries
  116876. * @param i Position in sample range, for example if the sample length is 5, and i is -3, then 2 will be returned.
  116877. * @return Wrapped position in sample range
  116878. */
  116879. protected _wrapPosition(i: number): number;
  116880. }
  116881. }
  116882. declare module BABYLON {
  116883. /**
  116884. * This class is used to track a performance counter which is number based.
  116885. * The user has access to many properties which give statistics of different nature.
  116886. *
  116887. * The implementer can track two kinds of Performance Counter: time and count.
  116888. * 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.
  116889. * 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.
  116890. */
  116891. export class PerfCounter {
  116892. /**
  116893. * Gets or sets a global boolean to turn on and off all the counters
  116894. */
  116895. static Enabled: boolean;
  116896. /**
  116897. * Returns the smallest value ever
  116898. */
  116899. get min(): number;
  116900. /**
  116901. * Returns the biggest value ever
  116902. */
  116903. get max(): number;
  116904. /**
  116905. * Returns the average value since the performance counter is running
  116906. */
  116907. get average(): number;
  116908. /**
  116909. * Returns the average value of the last second the counter was monitored
  116910. */
  116911. get lastSecAverage(): number;
  116912. /**
  116913. * Returns the current value
  116914. */
  116915. get current(): number;
  116916. /**
  116917. * Gets the accumulated total
  116918. */
  116919. get total(): number;
  116920. /**
  116921. * Gets the total value count
  116922. */
  116923. get count(): number;
  116924. /**
  116925. * Creates a new counter
  116926. */
  116927. constructor();
  116928. /**
  116929. * Call this method to start monitoring a new frame.
  116930. * 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.
  116931. */
  116932. fetchNewFrame(): void;
  116933. /**
  116934. * Call this method to monitor a count of something (e.g. mesh drawn in viewport count)
  116935. * @param newCount the count value to add to the monitored count
  116936. * @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.
  116937. */
  116938. addCount(newCount: number, fetchResult: boolean): void;
  116939. /**
  116940. * Start monitoring this performance counter
  116941. */
  116942. beginMonitoring(): void;
  116943. /**
  116944. * Compute the time lapsed since the previous beginMonitoring() call.
  116945. * @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
  116946. */
  116947. endMonitoring(newFrame?: boolean): void;
  116948. private _fetchResult;
  116949. private _startMonitoringTime;
  116950. private _min;
  116951. private _max;
  116952. private _average;
  116953. private _current;
  116954. private _totalValueCount;
  116955. private _totalAccumulated;
  116956. private _lastSecAverage;
  116957. private _lastSecAccumulated;
  116958. private _lastSecTime;
  116959. private _lastSecValueCount;
  116960. }
  116961. }
  116962. declare module BABYLON {
  116963. interface ThinEngine {
  116964. /** @hidden */
  116965. _readTexturePixels(texture: InternalTexture, width: number, height: number, faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>): ArrayBufferView;
  116966. }
  116967. }
  116968. declare module BABYLON {
  116969. /**
  116970. * Defines the interface used by display changed events
  116971. */
  116972. export interface IDisplayChangedEventArgs {
  116973. /** Gets the vrDisplay object (if any) */
  116974. vrDisplay: Nullable<any>;
  116975. /** Gets a boolean indicating if webVR is supported */
  116976. vrSupported: boolean;
  116977. }
  116978. /**
  116979. * Defines the interface used by objects containing a viewport (like a camera)
  116980. */
  116981. interface IViewportOwnerLike {
  116982. /**
  116983. * Gets or sets the viewport
  116984. */
  116985. viewport: IViewportLike;
  116986. }
  116987. /**
  116988. * The engine class is responsible for interfacing with all lower-level APIs such as WebGL and Audio
  116989. */
  116990. export class Engine extends ThinEngine {
  116991. /** Defines that alpha blending is disabled */
  116992. static readonly ALPHA_DISABLE: number;
  116993. /** Defines that alpha blending to SRC ALPHA * SRC + DEST */
  116994. static readonly ALPHA_ADD: number;
  116995. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC ALPHA) * DEST */
  116996. static readonly ALPHA_COMBINE: number;
  116997. /** Defines that alpha blending to DEST - SRC * DEST */
  116998. static readonly ALPHA_SUBTRACT: number;
  116999. /** Defines that alpha blending to SRC * DEST */
  117000. static readonly ALPHA_MULTIPLY: number;
  117001. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC) * DEST */
  117002. static readonly ALPHA_MAXIMIZED: number;
  117003. /** Defines that alpha blending to SRC + DEST */
  117004. static readonly ALPHA_ONEONE: number;
  117005. /** Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST */
  117006. static readonly ALPHA_PREMULTIPLIED: number;
  117007. /**
  117008. * Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST
  117009. * Alpha will be set to (1 - SRC ALPHA) * DEST ALPHA
  117010. */
  117011. static readonly ALPHA_PREMULTIPLIED_PORTERDUFF: number;
  117012. /** Defines that alpha blending to CST * SRC + (1 - CST) * DEST */
  117013. static readonly ALPHA_INTERPOLATE: number;
  117014. /**
  117015. * Defines that alpha blending to SRC + (1 - SRC) * DEST
  117016. * Alpha will be set to SRC ALPHA + (1 - SRC ALPHA) * DEST ALPHA
  117017. */
  117018. static readonly ALPHA_SCREENMODE: number;
  117019. /** Defines that the ressource is not delayed*/
  117020. static readonly DELAYLOADSTATE_NONE: number;
  117021. /** Defines that the ressource was successfully delay loaded */
  117022. static readonly DELAYLOADSTATE_LOADED: number;
  117023. /** Defines that the ressource is currently delay loading */
  117024. static readonly DELAYLOADSTATE_LOADING: number;
  117025. /** Defines that the ressource is delayed and has not started loading */
  117026. static readonly DELAYLOADSTATE_NOTLOADED: number;
  117027. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will never pass. i.e. Nothing will be drawn */
  117028. static readonly NEVER: number;
  117029. /** 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 */
  117030. static readonly ALWAYS: number;
  117031. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is less than the stored value */
  117032. static readonly LESS: number;
  117033. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is equals to the stored value */
  117034. static readonly EQUAL: number;
  117035. /** 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 */
  117036. static readonly LEQUAL: number;
  117037. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is greater than the stored value */
  117038. static readonly GREATER: number;
  117039. /** 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 */
  117040. static readonly GEQUAL: number;
  117041. /** 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 */
  117042. static readonly NOTEQUAL: number;
  117043. /** Passed to stencilOperation to specify that stencil value must be kept */
  117044. static readonly KEEP: number;
  117045. /** Passed to stencilOperation to specify that stencil value must be replaced */
  117046. static readonly REPLACE: number;
  117047. /** Passed to stencilOperation to specify that stencil value must be incremented */
  117048. static readonly INCR: number;
  117049. /** Passed to stencilOperation to specify that stencil value must be decremented */
  117050. static readonly DECR: number;
  117051. /** Passed to stencilOperation to specify that stencil value must be inverted */
  117052. static readonly INVERT: number;
  117053. /** Passed to stencilOperation to specify that stencil value must be incremented with wrapping */
  117054. static readonly INCR_WRAP: number;
  117055. /** Passed to stencilOperation to specify that stencil value must be decremented with wrapping */
  117056. static readonly DECR_WRAP: number;
  117057. /** Texture is not repeating outside of 0..1 UVs */
  117058. static readonly TEXTURE_CLAMP_ADDRESSMODE: number;
  117059. /** Texture is repeating outside of 0..1 UVs */
  117060. static readonly TEXTURE_WRAP_ADDRESSMODE: number;
  117061. /** Texture is repeating and mirrored */
  117062. static readonly TEXTURE_MIRROR_ADDRESSMODE: number;
  117063. /** ALPHA */
  117064. static readonly TEXTUREFORMAT_ALPHA: number;
  117065. /** LUMINANCE */
  117066. static readonly TEXTUREFORMAT_LUMINANCE: number;
  117067. /** LUMINANCE_ALPHA */
  117068. static readonly TEXTUREFORMAT_LUMINANCE_ALPHA: number;
  117069. /** RGB */
  117070. static readonly TEXTUREFORMAT_RGB: number;
  117071. /** RGBA */
  117072. static readonly TEXTUREFORMAT_RGBA: number;
  117073. /** RED */
  117074. static readonly TEXTUREFORMAT_RED: number;
  117075. /** RED (2nd reference) */
  117076. static readonly TEXTUREFORMAT_R: number;
  117077. /** RG */
  117078. static readonly TEXTUREFORMAT_RG: number;
  117079. /** RED_INTEGER */
  117080. static readonly TEXTUREFORMAT_RED_INTEGER: number;
  117081. /** RED_INTEGER (2nd reference) */
  117082. static readonly TEXTUREFORMAT_R_INTEGER: number;
  117083. /** RG_INTEGER */
  117084. static readonly TEXTUREFORMAT_RG_INTEGER: number;
  117085. /** RGB_INTEGER */
  117086. static readonly TEXTUREFORMAT_RGB_INTEGER: number;
  117087. /** RGBA_INTEGER */
  117088. static readonly TEXTUREFORMAT_RGBA_INTEGER: number;
  117089. /** UNSIGNED_BYTE */
  117090. static readonly TEXTURETYPE_UNSIGNED_BYTE: number;
  117091. /** UNSIGNED_BYTE (2nd reference) */
  117092. static readonly TEXTURETYPE_UNSIGNED_INT: number;
  117093. /** FLOAT */
  117094. static readonly TEXTURETYPE_FLOAT: number;
  117095. /** HALF_FLOAT */
  117096. static readonly TEXTURETYPE_HALF_FLOAT: number;
  117097. /** BYTE */
  117098. static readonly TEXTURETYPE_BYTE: number;
  117099. /** SHORT */
  117100. static readonly TEXTURETYPE_SHORT: number;
  117101. /** UNSIGNED_SHORT */
  117102. static readonly TEXTURETYPE_UNSIGNED_SHORT: number;
  117103. /** INT */
  117104. static readonly TEXTURETYPE_INT: number;
  117105. /** UNSIGNED_INT */
  117106. static readonly TEXTURETYPE_UNSIGNED_INTEGER: number;
  117107. /** UNSIGNED_SHORT_4_4_4_4 */
  117108. static readonly TEXTURETYPE_UNSIGNED_SHORT_4_4_4_4: number;
  117109. /** UNSIGNED_SHORT_5_5_5_1 */
  117110. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_5_5_1: number;
  117111. /** UNSIGNED_SHORT_5_6_5 */
  117112. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_6_5: number;
  117113. /** UNSIGNED_INT_2_10_10_10_REV */
  117114. static readonly TEXTURETYPE_UNSIGNED_INT_2_10_10_10_REV: number;
  117115. /** UNSIGNED_INT_24_8 */
  117116. static readonly TEXTURETYPE_UNSIGNED_INT_24_8: number;
  117117. /** UNSIGNED_INT_10F_11F_11F_REV */
  117118. static readonly TEXTURETYPE_UNSIGNED_INT_10F_11F_11F_REV: number;
  117119. /** UNSIGNED_INT_5_9_9_9_REV */
  117120. static readonly TEXTURETYPE_UNSIGNED_INT_5_9_9_9_REV: number;
  117121. /** FLOAT_32_UNSIGNED_INT_24_8_REV */
  117122. static readonly TEXTURETYPE_FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  117123. /** nearest is mag = nearest and min = nearest and mip = linear */
  117124. static readonly TEXTURE_NEAREST_SAMPLINGMODE: number;
  117125. /** Bilinear is mag = linear and min = linear and mip = nearest */
  117126. static readonly TEXTURE_BILINEAR_SAMPLINGMODE: number;
  117127. /** Trilinear is mag = linear and min = linear and mip = linear */
  117128. static readonly TEXTURE_TRILINEAR_SAMPLINGMODE: number;
  117129. /** nearest is mag = nearest and min = nearest and mip = linear */
  117130. static readonly TEXTURE_NEAREST_NEAREST_MIPLINEAR: number;
  117131. /** Bilinear is mag = linear and min = linear and mip = nearest */
  117132. static readonly TEXTURE_LINEAR_LINEAR_MIPNEAREST: number;
  117133. /** Trilinear is mag = linear and min = linear and mip = linear */
  117134. static readonly TEXTURE_LINEAR_LINEAR_MIPLINEAR: number;
  117135. /** mag = nearest and min = nearest and mip = nearest */
  117136. static readonly TEXTURE_NEAREST_NEAREST_MIPNEAREST: number;
  117137. /** mag = nearest and min = linear and mip = nearest */
  117138. static readonly TEXTURE_NEAREST_LINEAR_MIPNEAREST: number;
  117139. /** mag = nearest and min = linear and mip = linear */
  117140. static readonly TEXTURE_NEAREST_LINEAR_MIPLINEAR: number;
  117141. /** mag = nearest and min = linear and mip = none */
  117142. static readonly TEXTURE_NEAREST_LINEAR: number;
  117143. /** mag = nearest and min = nearest and mip = none */
  117144. static readonly TEXTURE_NEAREST_NEAREST: number;
  117145. /** mag = linear and min = nearest and mip = nearest */
  117146. static readonly TEXTURE_LINEAR_NEAREST_MIPNEAREST: number;
  117147. /** mag = linear and min = nearest and mip = linear */
  117148. static readonly TEXTURE_LINEAR_NEAREST_MIPLINEAR: number;
  117149. /** mag = linear and min = linear and mip = none */
  117150. static readonly TEXTURE_LINEAR_LINEAR: number;
  117151. /** mag = linear and min = nearest and mip = none */
  117152. static readonly TEXTURE_LINEAR_NEAREST: number;
  117153. /** Explicit coordinates mode */
  117154. static readonly TEXTURE_EXPLICIT_MODE: number;
  117155. /** Spherical coordinates mode */
  117156. static readonly TEXTURE_SPHERICAL_MODE: number;
  117157. /** Planar coordinates mode */
  117158. static readonly TEXTURE_PLANAR_MODE: number;
  117159. /** Cubic coordinates mode */
  117160. static readonly TEXTURE_CUBIC_MODE: number;
  117161. /** Projection coordinates mode */
  117162. static readonly TEXTURE_PROJECTION_MODE: number;
  117163. /** Skybox coordinates mode */
  117164. static readonly TEXTURE_SKYBOX_MODE: number;
  117165. /** Inverse Cubic coordinates mode */
  117166. static readonly TEXTURE_INVCUBIC_MODE: number;
  117167. /** Equirectangular coordinates mode */
  117168. static readonly TEXTURE_EQUIRECTANGULAR_MODE: number;
  117169. /** Equirectangular Fixed coordinates mode */
  117170. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MODE: number;
  117171. /** Equirectangular Fixed Mirrored coordinates mode */
  117172. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  117173. /** Defines that texture rescaling will use a floor to find the closer power of 2 size */
  117174. static readonly SCALEMODE_FLOOR: number;
  117175. /** Defines that texture rescaling will look for the nearest power of 2 size */
  117176. static readonly SCALEMODE_NEAREST: number;
  117177. /** Defines that texture rescaling will use a ceil to find the closer power of 2 size */
  117178. static readonly SCALEMODE_CEILING: number;
  117179. /**
  117180. * Returns the current npm package of the sdk
  117181. */
  117182. static get NpmPackage(): string;
  117183. /**
  117184. * Returns the current version of the framework
  117185. */
  117186. static get Version(): string;
  117187. /** Gets the list of created engines */
  117188. static get Instances(): Engine[];
  117189. /**
  117190. * Gets the latest created engine
  117191. */
  117192. static get LastCreatedEngine(): Nullable<Engine>;
  117193. /**
  117194. * Gets the latest created scene
  117195. */
  117196. static get LastCreatedScene(): Nullable<Scene>;
  117197. /**
  117198. * Will flag all materials in all scenes in all engines as dirty to trigger new shader compilation
  117199. * @param flag defines which part of the materials must be marked as dirty
  117200. * @param predicate defines a predicate used to filter which materials should be affected
  117201. */
  117202. static MarkAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  117203. /**
  117204. * Method called to create the default loading screen.
  117205. * This can be overriden in your own app.
  117206. * @param canvas The rendering canvas element
  117207. * @returns The loading screen
  117208. */
  117209. static DefaultLoadingScreenFactory(canvas: HTMLCanvasElement): ILoadingScreen;
  117210. /**
  117211. * Method called to create the default rescale post process on each engine.
  117212. */
  117213. static _RescalePostProcessFactory: Nullable<(engine: Engine) => PostProcess>;
  117214. /**
  117215. * Gets or sets a boolean to enable/disable IndexedDB support and avoid XHR on .manifest
  117216. **/
  117217. enableOfflineSupport: boolean;
  117218. /**
  117219. * 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)
  117220. **/
  117221. disableManifestCheck: boolean;
  117222. /**
  117223. * Gets the list of created scenes
  117224. */
  117225. scenes: Scene[];
  117226. /**
  117227. * Event raised when a new scene is created
  117228. */
  117229. onNewSceneAddedObservable: Observable<Scene>;
  117230. /**
  117231. * Gets the list of created postprocesses
  117232. */
  117233. postProcesses: PostProcess[];
  117234. /**
  117235. * Gets a boolean indicating if the pointer is currently locked
  117236. */
  117237. isPointerLock: boolean;
  117238. /**
  117239. * Observable event triggered each time the rendering canvas is resized
  117240. */
  117241. onResizeObservable: Observable<Engine>;
  117242. /**
  117243. * Observable event triggered each time the canvas loses focus
  117244. */
  117245. onCanvasBlurObservable: Observable<Engine>;
  117246. /**
  117247. * Observable event triggered each time the canvas gains focus
  117248. */
  117249. onCanvasFocusObservable: Observable<Engine>;
  117250. /**
  117251. * Observable event triggered each time the canvas receives pointerout event
  117252. */
  117253. onCanvasPointerOutObservable: Observable<PointerEvent>;
  117254. /**
  117255. * Observable raised when the engine begins a new frame
  117256. */
  117257. onBeginFrameObservable: Observable<Engine>;
  117258. /**
  117259. * If set, will be used to request the next animation frame for the render loop
  117260. */
  117261. customAnimationFrameRequester: Nullable<ICustomAnimationFrameRequester>;
  117262. /**
  117263. * Observable raised when the engine ends the current frame
  117264. */
  117265. onEndFrameObservable: Observable<Engine>;
  117266. /**
  117267. * Observable raised when the engine is about to compile a shader
  117268. */
  117269. onBeforeShaderCompilationObservable: Observable<Engine>;
  117270. /**
  117271. * Observable raised when the engine has jsut compiled a shader
  117272. */
  117273. onAfterShaderCompilationObservable: Observable<Engine>;
  117274. /**
  117275. * Gets the audio engine
  117276. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  117277. * @ignorenaming
  117278. */
  117279. static audioEngine: IAudioEngine;
  117280. /**
  117281. * Default AudioEngine factory responsible of creating the Audio Engine.
  117282. * By default, this will create a BabylonJS Audio Engine if the workload has been embedded.
  117283. */
  117284. static AudioEngineFactory: (hostElement: Nullable<HTMLElement>) => IAudioEngine;
  117285. /**
  117286. * Default offline support factory responsible of creating a tool used to store data locally.
  117287. * By default, this will create a Database object if the workload has been embedded.
  117288. */
  117289. static OfflineProviderFactory: (urlToScene: string, callbackManifestChecked: (checked: boolean) => any, disableManifestCheck: boolean) => IOfflineProvider;
  117290. private _loadingScreen;
  117291. private _pointerLockRequested;
  117292. private _rescalePostProcess;
  117293. private _deterministicLockstep;
  117294. private _lockstepMaxSteps;
  117295. private _timeStep;
  117296. protected get _supportsHardwareTextureRescaling(): boolean;
  117297. private _fps;
  117298. private _deltaTime;
  117299. /** @hidden */
  117300. _drawCalls: PerfCounter;
  117301. /** 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 */
  117302. canvasTabIndex: number;
  117303. /**
  117304. * Turn this value on if you want to pause FPS computation when in background
  117305. */
  117306. disablePerformanceMonitorInBackground: boolean;
  117307. private _performanceMonitor;
  117308. /**
  117309. * Gets the performance monitor attached to this engine
  117310. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  117311. */
  117312. get performanceMonitor(): PerformanceMonitor;
  117313. private _onFocus;
  117314. private _onBlur;
  117315. private _onCanvasPointerOut;
  117316. private _onCanvasBlur;
  117317. private _onCanvasFocus;
  117318. private _onFullscreenChange;
  117319. private _onPointerLockChange;
  117320. /**
  117321. * Gets the HTML element used to attach event listeners
  117322. * @returns a HTML element
  117323. */
  117324. getInputElement(): Nullable<HTMLElement>;
  117325. /**
  117326. * Creates a new engine
  117327. * @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
  117328. * @param antialias defines enable antialiasing (default: false)
  117329. * @param options defines further options to be sent to the getContext() function
  117330. * @param adaptToDeviceRatio defines whether to adapt to the device's viewport characteristics (default: false)
  117331. */
  117332. constructor(canvasOrContext: Nullable<HTMLCanvasElement | WebGLRenderingContext>, antialias?: boolean, options?: EngineOptions, adaptToDeviceRatio?: boolean);
  117333. /**
  117334. * Gets current aspect ratio
  117335. * @param viewportOwner defines the camera to use to get the aspect ratio
  117336. * @param useScreen defines if screen size must be used (or the current render target if any)
  117337. * @returns a number defining the aspect ratio
  117338. */
  117339. getAspectRatio(viewportOwner: IViewportOwnerLike, useScreen?: boolean): number;
  117340. /**
  117341. * Gets current screen aspect ratio
  117342. * @returns a number defining the aspect ratio
  117343. */
  117344. getScreenAspectRatio(): number;
  117345. /**
  117346. * Gets the client rect of the HTML canvas attached with the current webGL context
  117347. * @returns a client rectanglee
  117348. */
  117349. getRenderingCanvasClientRect(): Nullable<ClientRect>;
  117350. /**
  117351. * Gets the client rect of the HTML element used for events
  117352. * @returns a client rectanglee
  117353. */
  117354. getInputElementClientRect(): Nullable<ClientRect>;
  117355. /**
  117356. * Gets a boolean indicating that the engine is running in deterministic lock step mode
  117357. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  117358. * @returns true if engine is in deterministic lock step mode
  117359. */
  117360. isDeterministicLockStep(): boolean;
  117361. /**
  117362. * Gets the max steps when engine is running in deterministic lock step
  117363. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  117364. * @returns the max steps
  117365. */
  117366. getLockstepMaxSteps(): number;
  117367. /**
  117368. * Returns the time in ms between steps when using deterministic lock step.
  117369. * @returns time step in (ms)
  117370. */
  117371. getTimeStep(): number;
  117372. /**
  117373. * Force the mipmap generation for the given render target texture
  117374. * @param texture defines the render target texture to use
  117375. * @param unbind defines whether or not to unbind the texture after generation. Defaults to true.
  117376. */
  117377. generateMipMapsForCubemap(texture: InternalTexture, unbind?: boolean): void;
  117378. /** States */
  117379. /**
  117380. * Set various states to the webGL context
  117381. * @param culling defines backface culling state
  117382. * @param zOffset defines the value to apply to zOffset (0 by default)
  117383. * @param force defines if states must be applied even if cache is up to date
  117384. * @param reverseSide defines if culling must be reversed (CCW instead of CW and CW instead of CCW)
  117385. */
  117386. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  117387. /**
  117388. * Set the z offset to apply to current rendering
  117389. * @param value defines the offset to apply
  117390. */
  117391. setZOffset(value: number): void;
  117392. /**
  117393. * Gets the current value of the zOffset
  117394. * @returns the current zOffset state
  117395. */
  117396. getZOffset(): number;
  117397. /**
  117398. * Enable or disable depth buffering
  117399. * @param enable defines the state to set
  117400. */
  117401. setDepthBuffer(enable: boolean): void;
  117402. /**
  117403. * Gets a boolean indicating if depth writing is enabled
  117404. * @returns the current depth writing state
  117405. */
  117406. getDepthWrite(): boolean;
  117407. /**
  117408. * Enable or disable depth writing
  117409. * @param enable defines the state to set
  117410. */
  117411. setDepthWrite(enable: boolean): void;
  117412. /**
  117413. * Gets a boolean indicating if stencil buffer is enabled
  117414. * @returns the current stencil buffer state
  117415. */
  117416. getStencilBuffer(): boolean;
  117417. /**
  117418. * Enable or disable the stencil buffer
  117419. * @param enable defines if the stencil buffer must be enabled or disabled
  117420. */
  117421. setStencilBuffer(enable: boolean): void;
  117422. /**
  117423. * Gets the current stencil mask
  117424. * @returns a number defining the new stencil mask to use
  117425. */
  117426. getStencilMask(): number;
  117427. /**
  117428. * Sets the current stencil mask
  117429. * @param mask defines the new stencil mask to use
  117430. */
  117431. setStencilMask(mask: number): void;
  117432. /**
  117433. * Gets the current stencil function
  117434. * @returns a number defining the stencil function to use
  117435. */
  117436. getStencilFunction(): number;
  117437. /**
  117438. * Gets the current stencil reference value
  117439. * @returns a number defining the stencil reference value to use
  117440. */
  117441. getStencilFunctionReference(): number;
  117442. /**
  117443. * Gets the current stencil mask
  117444. * @returns a number defining the stencil mask to use
  117445. */
  117446. getStencilFunctionMask(): number;
  117447. /**
  117448. * Sets the current stencil function
  117449. * @param stencilFunc defines the new stencil function to use
  117450. */
  117451. setStencilFunction(stencilFunc: number): void;
  117452. /**
  117453. * Sets the current stencil reference
  117454. * @param reference defines the new stencil reference to use
  117455. */
  117456. setStencilFunctionReference(reference: number): void;
  117457. /**
  117458. * Sets the current stencil mask
  117459. * @param mask defines the new stencil mask to use
  117460. */
  117461. setStencilFunctionMask(mask: number): void;
  117462. /**
  117463. * Gets the current stencil operation when stencil fails
  117464. * @returns a number defining stencil operation to use when stencil fails
  117465. */
  117466. getStencilOperationFail(): number;
  117467. /**
  117468. * Gets the current stencil operation when depth fails
  117469. * @returns a number defining stencil operation to use when depth fails
  117470. */
  117471. getStencilOperationDepthFail(): number;
  117472. /**
  117473. * Gets the current stencil operation when stencil passes
  117474. * @returns a number defining stencil operation to use when stencil passes
  117475. */
  117476. getStencilOperationPass(): number;
  117477. /**
  117478. * Sets the stencil operation to use when stencil fails
  117479. * @param operation defines the stencil operation to use when stencil fails
  117480. */
  117481. setStencilOperationFail(operation: number): void;
  117482. /**
  117483. * Sets the stencil operation to use when depth fails
  117484. * @param operation defines the stencil operation to use when depth fails
  117485. */
  117486. setStencilOperationDepthFail(operation: number): void;
  117487. /**
  117488. * Sets the stencil operation to use when stencil passes
  117489. * @param operation defines the stencil operation to use when stencil passes
  117490. */
  117491. setStencilOperationPass(operation: number): void;
  117492. /**
  117493. * Sets a boolean indicating if the dithering state is enabled or disabled
  117494. * @param value defines the dithering state
  117495. */
  117496. setDitheringState(value: boolean): void;
  117497. /**
  117498. * Sets a boolean indicating if the rasterizer state is enabled or disabled
  117499. * @param value defines the rasterizer state
  117500. */
  117501. setRasterizerState(value: boolean): void;
  117502. /**
  117503. * Gets the current depth function
  117504. * @returns a number defining the depth function
  117505. */
  117506. getDepthFunction(): Nullable<number>;
  117507. /**
  117508. * Sets the current depth function
  117509. * @param depthFunc defines the function to use
  117510. */
  117511. setDepthFunction(depthFunc: number): void;
  117512. /**
  117513. * Sets the current depth function to GREATER
  117514. */
  117515. setDepthFunctionToGreater(): void;
  117516. /**
  117517. * Sets the current depth function to GEQUAL
  117518. */
  117519. setDepthFunctionToGreaterOrEqual(): void;
  117520. /**
  117521. * Sets the current depth function to LESS
  117522. */
  117523. setDepthFunctionToLess(): void;
  117524. /**
  117525. * Sets the current depth function to LEQUAL
  117526. */
  117527. setDepthFunctionToLessOrEqual(): void;
  117528. private _cachedStencilBuffer;
  117529. private _cachedStencilFunction;
  117530. private _cachedStencilMask;
  117531. private _cachedStencilOperationPass;
  117532. private _cachedStencilOperationFail;
  117533. private _cachedStencilOperationDepthFail;
  117534. private _cachedStencilReference;
  117535. /**
  117536. * Caches the the state of the stencil buffer
  117537. */
  117538. cacheStencilState(): void;
  117539. /**
  117540. * Restores the state of the stencil buffer
  117541. */
  117542. restoreStencilState(): void;
  117543. /**
  117544. * Directly set the WebGL Viewport
  117545. * @param x defines the x coordinate of the viewport (in screen space)
  117546. * @param y defines the y coordinate of the viewport (in screen space)
  117547. * @param width defines the width of the viewport (in screen space)
  117548. * @param height defines the height of the viewport (in screen space)
  117549. * @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
  117550. */
  117551. setDirectViewport(x: number, y: number, width: number, height: number): Nullable<IViewportLike>;
  117552. /**
  117553. * Executes a scissor clear (ie. a clear on a specific portion of the screen)
  117554. * @param x defines the x-coordinate of the top left corner of the clear rectangle
  117555. * @param y defines the y-coordinate of the corner of the clear rectangle
  117556. * @param width defines the width of the clear rectangle
  117557. * @param height defines the height of the clear rectangle
  117558. * @param clearColor defines the clear color
  117559. */
  117560. scissorClear(x: number, y: number, width: number, height: number, clearColor: IColor4Like): void;
  117561. /**
  117562. * Enable scissor test on a specific rectangle (ie. render will only be executed on a specific portion of the screen)
  117563. * @param x defines the x-coordinate of the top left corner of the clear rectangle
  117564. * @param y defines the y-coordinate of the corner of the clear rectangle
  117565. * @param width defines the width of the clear rectangle
  117566. * @param height defines the height of the clear rectangle
  117567. */
  117568. enableScissor(x: number, y: number, width: number, height: number): void;
  117569. /**
  117570. * Disable previously set scissor test rectangle
  117571. */
  117572. disableScissor(): void;
  117573. protected _reportDrawCall(): void;
  117574. /**
  117575. * Initializes a webVR display and starts listening to display change events
  117576. * The onVRDisplayChangedObservable will be notified upon these changes
  117577. * @returns The onVRDisplayChangedObservable
  117578. */
  117579. initWebVR(): Observable<IDisplayChangedEventArgs>;
  117580. /** @hidden */
  117581. _prepareVRComponent(): void;
  117582. /** @hidden */
  117583. _connectVREvents(canvas?: HTMLCanvasElement, document?: any): void;
  117584. /** @hidden */
  117585. _submitVRFrame(): void;
  117586. /**
  117587. * Call this function to leave webVR mode
  117588. * Will do nothing if webVR is not supported or if there is no webVR device
  117589. * @see https://doc.babylonjs.com/how_to/webvr_camera
  117590. */
  117591. disableVR(): void;
  117592. /**
  117593. * Gets a boolean indicating that the system is in VR mode and is presenting
  117594. * @returns true if VR mode is engaged
  117595. */
  117596. isVRPresenting(): boolean;
  117597. /** @hidden */
  117598. _requestVRFrame(): void;
  117599. /** @hidden */
  117600. _loadFileAsync(url: string, offlineProvider?: IOfflineProvider, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  117601. /**
  117602. * Gets the source code of the vertex shader associated with a specific webGL program
  117603. * @param program defines the program to use
  117604. * @returns a string containing the source code of the vertex shader associated with the program
  117605. */
  117606. getVertexShaderSource(program: WebGLProgram): Nullable<string>;
  117607. /**
  117608. * Gets the source code of the fragment shader associated with a specific webGL program
  117609. * @param program defines the program to use
  117610. * @returns a string containing the source code of the fragment shader associated with the program
  117611. */
  117612. getFragmentShaderSource(program: WebGLProgram): Nullable<string>;
  117613. /**
  117614. * Sets a depth stencil texture from a render target to the according uniform.
  117615. * @param channel The texture channel
  117616. * @param uniform The uniform to set
  117617. * @param texture The render target texture containing the depth stencil texture to apply
  117618. */
  117619. setDepthStencilTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<RenderTargetTexture>): void;
  117620. /**
  117621. * Sets a texture to the webGL context from a postprocess
  117622. * @param channel defines the channel to use
  117623. * @param postProcess defines the source postprocess
  117624. */
  117625. setTextureFromPostProcess(channel: number, postProcess: Nullable<PostProcess>): void;
  117626. /**
  117627. * Binds the output of the passed in post process to the texture channel specified
  117628. * @param channel The channel the texture should be bound to
  117629. * @param postProcess The post process which's output should be bound
  117630. */
  117631. setTextureFromPostProcessOutput(channel: number, postProcess: Nullable<PostProcess>): void;
  117632. protected _rebuildBuffers(): void;
  117633. /** @hidden */
  117634. _renderFrame(): void;
  117635. _renderLoop(): void;
  117636. /** @hidden */
  117637. _renderViews(): boolean;
  117638. /**
  117639. * Toggle full screen mode
  117640. * @param requestPointerLock defines if a pointer lock should be requested from the user
  117641. */
  117642. switchFullscreen(requestPointerLock: boolean): void;
  117643. /**
  117644. * Enters full screen mode
  117645. * @param requestPointerLock defines if a pointer lock should be requested from the user
  117646. */
  117647. enterFullscreen(requestPointerLock: boolean): void;
  117648. /**
  117649. * Exits full screen mode
  117650. */
  117651. exitFullscreen(): void;
  117652. /**
  117653. * Enters Pointerlock mode
  117654. */
  117655. enterPointerlock(): void;
  117656. /**
  117657. * Exits Pointerlock mode
  117658. */
  117659. exitPointerlock(): void;
  117660. /**
  117661. * Begin a new frame
  117662. */
  117663. beginFrame(): void;
  117664. /**
  117665. * Enf the current frame
  117666. */
  117667. endFrame(): void;
  117668. resize(): void;
  117669. /**
  117670. * Force a specific size of the canvas
  117671. * @param width defines the new canvas' width
  117672. * @param height defines the new canvas' height
  117673. * @returns true if the size was changed
  117674. */
  117675. setSize(width: number, height: number): boolean;
  117676. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  117677. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  117678. protected _createShaderProgram(pipelineContext: WebGLPipelineContext, vertexShader: WebGLShader, fragmentShader: WebGLShader, context: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  117679. _releaseTexture(texture: InternalTexture): void;
  117680. /**
  117681. * @hidden
  117682. * Rescales a texture
  117683. * @param source input texutre
  117684. * @param destination destination texture
  117685. * @param scene scene to use to render the resize
  117686. * @param internalFormat format to use when resizing
  117687. * @param onComplete callback to be called when resize has completed
  117688. */
  117689. _rescaleTexture(source: InternalTexture, destination: InternalTexture, scene: Nullable<any>, internalFormat: number, onComplete: () => void): void;
  117690. /**
  117691. * Gets the current framerate
  117692. * @returns a number representing the framerate
  117693. */
  117694. getFps(): number;
  117695. /**
  117696. * Gets the time spent between current and previous frame
  117697. * @returns a number representing the delta time in ms
  117698. */
  117699. getDeltaTime(): number;
  117700. private _measureFps;
  117701. /** @hidden */
  117702. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement | ImageBitmap, faceIndex?: number, lod?: number): void;
  117703. /**
  117704. * Updates the sample count of a render target texture
  117705. * @see https://doc.babylonjs.com/features/webgl2#multisample-render-targets
  117706. * @param texture defines the texture to update
  117707. * @param samples defines the sample count to set
  117708. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  117709. */
  117710. updateRenderTargetTextureSampleCount(texture: Nullable<InternalTexture>, samples: number): number;
  117711. /**
  117712. * Updates a depth texture Comparison Mode and Function.
  117713. * If the comparison Function is equal to 0, the mode will be set to none.
  117714. * Otherwise, this only works in webgl 2 and requires a shadow sampler in the shader.
  117715. * @param texture The texture to set the comparison function for
  117716. * @param comparisonFunction The comparison function to set, 0 if no comparison required
  117717. */
  117718. updateTextureComparisonFunction(texture: InternalTexture, comparisonFunction: number): void;
  117719. /**
  117720. * Creates a webGL buffer to use with instanciation
  117721. * @param capacity defines the size of the buffer
  117722. * @returns the webGL buffer
  117723. */
  117724. createInstancesBuffer(capacity: number): DataBuffer;
  117725. /**
  117726. * Delete a webGL buffer used with instanciation
  117727. * @param buffer defines the webGL buffer to delete
  117728. */
  117729. deleteInstancesBuffer(buffer: WebGLBuffer): void;
  117730. private _clientWaitAsync;
  117731. /** @hidden */
  117732. _readPixelsAsync(x: number, y: number, w: number, h: number, format: number, type: number, outputBuffer: ArrayBufferView): Promise<ArrayBufferView> | null;
  117733. dispose(): void;
  117734. private _disableTouchAction;
  117735. /**
  117736. * Display the loading screen
  117737. * @see https://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  117738. */
  117739. displayLoadingUI(): void;
  117740. /**
  117741. * Hide the loading screen
  117742. * @see https://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  117743. */
  117744. hideLoadingUI(): void;
  117745. /**
  117746. * Gets the current loading screen object
  117747. * @see https://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  117748. */
  117749. get loadingScreen(): ILoadingScreen;
  117750. /**
  117751. * Sets the current loading screen object
  117752. * @see https://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  117753. */
  117754. set loadingScreen(loadingScreen: ILoadingScreen);
  117755. /**
  117756. * Sets the current loading screen text
  117757. * @see https://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  117758. */
  117759. set loadingUIText(text: string);
  117760. /**
  117761. * Sets the current loading screen background color
  117762. * @see https://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  117763. */
  117764. set loadingUIBackgroundColor(color: string);
  117765. /** Pointerlock and fullscreen */
  117766. /**
  117767. * Ask the browser to promote the current element to pointerlock mode
  117768. * @param element defines the DOM element to promote
  117769. */
  117770. static _RequestPointerlock(element: HTMLElement): void;
  117771. /**
  117772. * Asks the browser to exit pointerlock mode
  117773. */
  117774. static _ExitPointerlock(): void;
  117775. /**
  117776. * Ask the browser to promote the current element to fullscreen rendering mode
  117777. * @param element defines the DOM element to promote
  117778. */
  117779. static _RequestFullscreen(element: HTMLElement): void;
  117780. /**
  117781. * Asks the browser to exit fullscreen mode
  117782. */
  117783. static _ExitFullscreen(): void;
  117784. }
  117785. }
  117786. declare module BABYLON {
  117787. /**
  117788. * The engine store class is responsible to hold all the instances of Engine and Scene created
  117789. * during the life time of the application.
  117790. */
  117791. export class EngineStore {
  117792. /** Gets the list of created engines */
  117793. static Instances: Engine[];
  117794. /** @hidden */
  117795. static _LastCreatedScene: Nullable<Scene>;
  117796. /**
  117797. * Gets the latest created engine
  117798. */
  117799. static get LastCreatedEngine(): Nullable<Engine>;
  117800. /**
  117801. * Gets the latest created scene
  117802. */
  117803. static get LastCreatedScene(): Nullable<Scene>;
  117804. /**
  117805. * Gets or sets a global variable indicating if fallback texture must be used when a texture cannot be loaded
  117806. * @ignorenaming
  117807. */
  117808. static UseFallbackTexture: boolean;
  117809. /**
  117810. * Texture content used if a texture cannot loaded
  117811. * @ignorenaming
  117812. */
  117813. static FallbackTexture: string;
  117814. }
  117815. }
  117816. declare module BABYLON {
  117817. /**
  117818. * Helper class that provides a small promise polyfill
  117819. */
  117820. export class PromisePolyfill {
  117821. /**
  117822. * Static function used to check if the polyfill is required
  117823. * If this is the case then the function will inject the polyfill to window.Promise
  117824. * @param force defines a boolean used to force the injection (mostly for testing purposes)
  117825. */
  117826. static Apply(force?: boolean): void;
  117827. }
  117828. }
  117829. declare module BABYLON {
  117830. /**
  117831. * Interface for screenshot methods with describe argument called `size` as object with options
  117832. * @link https://doc.babylonjs.com/api/classes/babylon.screenshottools
  117833. */
  117834. export interface IScreenshotSize {
  117835. /**
  117836. * number in pixels for canvas height
  117837. */
  117838. height?: number;
  117839. /**
  117840. * multiplier allowing render at a higher or lower resolution
  117841. * If value is defined then height and width will be ignored and taken from camera
  117842. */
  117843. precision?: number;
  117844. /**
  117845. * number in pixels for canvas width
  117846. */
  117847. width?: number;
  117848. }
  117849. }
  117850. declare module BABYLON {
  117851. interface IColor4Like {
  117852. r: float;
  117853. g: float;
  117854. b: float;
  117855. a: float;
  117856. }
  117857. /**
  117858. * Class containing a set of static utilities functions
  117859. */
  117860. export class Tools {
  117861. /**
  117862. * Gets or sets the base URL to use to load assets
  117863. */
  117864. static get BaseUrl(): string;
  117865. static set BaseUrl(value: string);
  117866. /**
  117867. * Enable/Disable Custom HTTP Request Headers globally.
  117868. * default = false
  117869. * @see CustomRequestHeaders
  117870. */
  117871. static UseCustomRequestHeaders: boolean;
  117872. /**
  117873. * Custom HTTP Request Headers to be sent with XMLHttpRequests
  117874. * i.e. when loading files, where the server/service expects an Authorization header
  117875. */
  117876. static CustomRequestHeaders: {
  117877. [key: string]: string;
  117878. };
  117879. /**
  117880. * Gets or sets the retry strategy to apply when an error happens while loading an asset
  117881. */
  117882. static get DefaultRetryStrategy(): (url: string, request: WebRequest, retryIndex: number) => number;
  117883. static set DefaultRetryStrategy(strategy: (url: string, request: WebRequest, retryIndex: number) => number);
  117884. /**
  117885. * Default behaviour for cors in the application.
  117886. * It can be a string if the expected behavior is identical in the entire app.
  117887. * Or a callback to be able to set it per url or on a group of them (in case of Video source for instance)
  117888. */
  117889. static get CorsBehavior(): string | ((url: string | string[]) => string);
  117890. static set CorsBehavior(value: string | ((url: string | string[]) => string));
  117891. /**
  117892. * Gets or sets a global variable indicating if fallback texture must be used when a texture cannot be loaded
  117893. * @ignorenaming
  117894. */
  117895. static get UseFallbackTexture(): boolean;
  117896. static set UseFallbackTexture(value: boolean);
  117897. /**
  117898. * Use this object to register external classes like custom textures or material
  117899. * to allow the laoders to instantiate them
  117900. */
  117901. static get RegisteredExternalClasses(): {
  117902. [key: string]: Object;
  117903. };
  117904. static set RegisteredExternalClasses(classes: {
  117905. [key: string]: Object;
  117906. });
  117907. /**
  117908. * Texture content used if a texture cannot loaded
  117909. * @ignorenaming
  117910. */
  117911. static get fallbackTexture(): string;
  117912. static set fallbackTexture(value: string);
  117913. /**
  117914. * Read the content of a byte array at a specified coordinates (taking in account wrapping)
  117915. * @param u defines the coordinate on X axis
  117916. * @param v defines the coordinate on Y axis
  117917. * @param width defines the width of the source data
  117918. * @param height defines the height of the source data
  117919. * @param pixels defines the source byte array
  117920. * @param color defines the output color
  117921. */
  117922. static FetchToRef(u: number, v: number, width: number, height: number, pixels: Uint8Array, color: IColor4Like): void;
  117923. /**
  117924. * Interpolates between a and b via alpha
  117925. * @param a The lower value (returned when alpha = 0)
  117926. * @param b The upper value (returned when alpha = 1)
  117927. * @param alpha The interpolation-factor
  117928. * @return The mixed value
  117929. */
  117930. static Mix(a: number, b: number, alpha: number): number;
  117931. /**
  117932. * Tries to instantiate a new object from a given class name
  117933. * @param className defines the class name to instantiate
  117934. * @returns the new object or null if the system was not able to do the instantiation
  117935. */
  117936. static Instantiate(className: string): any;
  117937. /**
  117938. * Provides a slice function that will work even on IE
  117939. * @param data defines the array to slice
  117940. * @param start defines the start of the data (optional)
  117941. * @param end defines the end of the data (optional)
  117942. * @returns the new sliced array
  117943. */
  117944. static Slice<T>(data: T, start?: number, end?: number): T;
  117945. /**
  117946. * Polyfill for setImmediate
  117947. * @param action defines the action to execute after the current execution block
  117948. */
  117949. static SetImmediate(action: () => void): void;
  117950. /**
  117951. * Function indicating if a number is an exponent of 2
  117952. * @param value defines the value to test
  117953. * @returns true if the value is an exponent of 2
  117954. */
  117955. static IsExponentOfTwo(value: number): boolean;
  117956. private static _tmpFloatArray;
  117957. /**
  117958. * Returns the nearest 32-bit single precision float representation of a Number
  117959. * @param value A Number. If the parameter is of a different type, it will get converted
  117960. * to a number or to NaN if it cannot be converted
  117961. * @returns number
  117962. */
  117963. static FloatRound(value: number): number;
  117964. /**
  117965. * Extracts the filename from a path
  117966. * @param path defines the path to use
  117967. * @returns the filename
  117968. */
  117969. static GetFilename(path: string): string;
  117970. /**
  117971. * Extracts the "folder" part of a path (everything before the filename).
  117972. * @param uri The URI to extract the info from
  117973. * @param returnUnchangedIfNoSlash Do not touch the URI if no slashes are present
  117974. * @returns The "folder" part of the path
  117975. */
  117976. static GetFolderPath(uri: string, returnUnchangedIfNoSlash?: boolean): string;
  117977. /**
  117978. * Extracts text content from a DOM element hierarchy
  117979. * Back Compat only, please use DomManagement.GetDOMTextContent instead.
  117980. */
  117981. static GetDOMTextContent: typeof DomManagement.GetDOMTextContent;
  117982. /**
  117983. * Convert an angle in radians to degrees
  117984. * @param angle defines the angle to convert
  117985. * @returns the angle in degrees
  117986. */
  117987. static ToDegrees(angle: number): number;
  117988. /**
  117989. * Convert an angle in degrees to radians
  117990. * @param angle defines the angle to convert
  117991. * @returns the angle in radians
  117992. */
  117993. static ToRadians(angle: number): number;
  117994. /**
  117995. * Returns an array if obj is not an array
  117996. * @param obj defines the object to evaluate as an array
  117997. * @param allowsNullUndefined defines a boolean indicating if obj is allowed to be null or undefined
  117998. * @returns either obj directly if obj is an array or a new array containing obj
  117999. */
  118000. static MakeArray(obj: any, allowsNullUndefined?: boolean): Nullable<Array<any>>;
  118001. /**
  118002. * Gets the pointer prefix to use
  118003. * @param engine defines the engine we are finding the prefix for
  118004. * @returns "pointer" if touch is enabled. Else returns "mouse"
  118005. */
  118006. static GetPointerPrefix(engine: Engine): string;
  118007. /**
  118008. * Sets the cors behavior on a dom element. This will add the required Tools.CorsBehavior to the element.
  118009. * @param url define the url we are trying
  118010. * @param element define the dom element where to configure the cors policy
  118011. */
  118012. static SetCorsBehavior(url: string | string[], element: {
  118013. crossOrigin: string | null;
  118014. }): void;
  118015. /**
  118016. * Removes unwanted characters from an url
  118017. * @param url defines the url to clean
  118018. * @returns the cleaned url
  118019. */
  118020. static CleanUrl(url: string): string;
  118021. /**
  118022. * Gets or sets a function used to pre-process url before using them to load assets
  118023. */
  118024. static get PreprocessUrl(): (url: string) => string;
  118025. static set PreprocessUrl(processor: (url: string) => string);
  118026. /**
  118027. * Loads an image as an HTMLImageElement.
  118028. * @param input url string, ArrayBuffer, or Blob to load
  118029. * @param onLoad callback called when the image successfully loads
  118030. * @param onError callback called when the image fails to load
  118031. * @param offlineProvider offline provider for caching
  118032. * @param mimeType optional mime type
  118033. * @returns the HTMLImageElement of the loaded image
  118034. */
  118035. static LoadImage(input: string | ArrayBuffer | Blob, onLoad: (img: HTMLImageElement | ImageBitmap) => void, onError: (message?: string, exception?: any) => void, offlineProvider: Nullable<IOfflineProvider>, mimeType?: string): Nullable<HTMLImageElement>;
  118036. /**
  118037. * Loads a file from a url
  118038. * @param url url string, ArrayBuffer, or Blob to load
  118039. * @param onSuccess callback called when the file successfully loads
  118040. * @param onProgress callback called while file is loading (if the server supports this mode)
  118041. * @param offlineProvider defines the offline provider for caching
  118042. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  118043. * @param onError callback called when the file fails to load
  118044. * @returns a file request object
  118045. */
  118046. 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;
  118047. /**
  118048. * Loads a file from a url
  118049. * @param url the file url to load
  118050. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  118051. * @returns a promise containing an ArrayBuffer corresponding to the loaded file
  118052. */
  118053. static LoadFileAsync(url: string, useArrayBuffer?: boolean): Promise<ArrayBuffer | string>;
  118054. /**
  118055. * Load a script (identified by an url). When the url returns, the
  118056. * content of this file is added into a new script element, attached to the DOM (body element)
  118057. * @param scriptUrl defines the url of the script to laod
  118058. * @param onSuccess defines the callback called when the script is loaded
  118059. * @param onError defines the callback to call if an error occurs
  118060. * @param scriptId defines the id of the script element
  118061. */
  118062. static LoadScript(scriptUrl: string, onSuccess: () => void, onError?: (message?: string, exception?: any) => void, scriptId?: string): void;
  118063. /**
  118064. * Load an asynchronous script (identified by an url). When the url returns, the
  118065. * content of this file is added into a new script element, attached to the DOM (body element)
  118066. * @param scriptUrl defines the url of the script to laod
  118067. * @param scriptId defines the id of the script element
  118068. * @returns a promise request object
  118069. */
  118070. static LoadScriptAsync(scriptUrl: string, scriptId?: string): Promise<void>;
  118071. /**
  118072. * Loads a file from a blob
  118073. * @param fileToLoad defines the blob to use
  118074. * @param callback defines the callback to call when data is loaded
  118075. * @param progressCallback defines the callback to call during loading process
  118076. * @returns a file request object
  118077. */
  118078. static ReadFileAsDataURL(fileToLoad: Blob, callback: (data: any) => void, progressCallback: (ev: ProgressEvent) => any): IFileRequest;
  118079. /**
  118080. * Reads a file from a File object
  118081. * @param file defines the file to load
  118082. * @param onSuccess defines the callback to call when data is loaded
  118083. * @param onProgress defines the callback to call during loading process
  118084. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  118085. * @param onError defines the callback to call when an error occurs
  118086. * @returns a file request object
  118087. */
  118088. static ReadFile(file: File, onSuccess: (data: any) => void, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: ReadFileError) => void): IFileRequest;
  118089. /**
  118090. * Creates a data url from a given string content
  118091. * @param content defines the content to convert
  118092. * @returns the new data url link
  118093. */
  118094. static FileAsURL(content: string): string;
  118095. /**
  118096. * Format the given number to a specific decimal format
  118097. * @param value defines the number to format
  118098. * @param decimals defines the number of decimals to use
  118099. * @returns the formatted string
  118100. */
  118101. static Format(value: number, decimals?: number): string;
  118102. /**
  118103. * Tries to copy an object by duplicating every property
  118104. * @param source defines the source object
  118105. * @param destination defines the target object
  118106. * @param doNotCopyList defines a list of properties to avoid
  118107. * @param mustCopyList defines a list of properties to copy (even if they start with _)
  118108. */
  118109. static DeepCopy(source: any, destination: any, doNotCopyList?: string[], mustCopyList?: string[]): void;
  118110. /**
  118111. * Gets a boolean indicating if the given object has no own property
  118112. * @param obj defines the object to test
  118113. * @returns true if object has no own property
  118114. */
  118115. static IsEmpty(obj: any): boolean;
  118116. /**
  118117. * Function used to register events at window level
  118118. * @param windowElement defines the Window object to use
  118119. * @param events defines the events to register
  118120. */
  118121. static RegisterTopRootEvents(windowElement: Window, events: {
  118122. name: string;
  118123. handler: Nullable<(e: FocusEvent) => any>;
  118124. }[]): void;
  118125. /**
  118126. * Function used to unregister events from window level
  118127. * @param windowElement defines the Window object to use
  118128. * @param events defines the events to unregister
  118129. */
  118130. static UnregisterTopRootEvents(windowElement: Window, events: {
  118131. name: string;
  118132. handler: Nullable<(e: FocusEvent) => any>;
  118133. }[]): void;
  118134. /**
  118135. * @ignore
  118136. */
  118137. static _ScreenshotCanvas: HTMLCanvasElement;
  118138. /**
  118139. * Dumps the current bound framebuffer
  118140. * @param width defines the rendering width
  118141. * @param height defines the rendering height
  118142. * @param engine defines the hosting engine
  118143. * @param successCallback defines the callback triggered once the data are available
  118144. * @param mimeType defines the mime type of the result
  118145. * @param fileName defines the filename to download. If present, the result will automatically be downloaded
  118146. */
  118147. static DumpFramebuffer(width: number, height: number, engine: Engine, successCallback?: (data: string) => void, mimeType?: string, fileName?: string): void;
  118148. /**
  118149. * Converts the canvas data to blob.
  118150. * This acts as a polyfill for browsers not supporting the to blob function.
  118151. * @param canvas Defines the canvas to extract the data from
  118152. * @param successCallback Defines the callback triggered once the data are available
  118153. * @param mimeType Defines the mime type of the result
  118154. */
  118155. static ToBlob(canvas: HTMLCanvasElement, successCallback: (blob: Nullable<Blob>) => void, mimeType?: string): void;
  118156. /**
  118157. * Encodes the canvas data to base 64 or automatically download the result if filename is defined
  118158. * @param successCallback defines the callback triggered once the data are available
  118159. * @param mimeType defines the mime type of the result
  118160. * @param fileName defines he filename to download. If present, the result will automatically be downloaded
  118161. */
  118162. static EncodeScreenshotCanvasData(successCallback?: (data: string) => void, mimeType?: string, fileName?: string): void;
  118163. /**
  118164. * Downloads a blob in the browser
  118165. * @param blob defines the blob to download
  118166. * @param fileName defines the name of the downloaded file
  118167. */
  118168. static Download(blob: Blob, fileName: string): void;
  118169. /**
  118170. * Captures a screenshot of the current rendering
  118171. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_png
  118172. * @param engine defines the rendering engine
  118173. * @param camera defines the source camera
  118174. * @param size This parameter can be set to a single number or to an object with the
  118175. * following (optional) properties: precision, width, height. If a single number is passed,
  118176. * it will be used for both width and height. If an object is passed, the screenshot size
  118177. * will be derived from the parameters. The precision property is a multiplier allowing
  118178. * rendering at a higher or lower resolution
  118179. * @param successCallback defines the callback receives a single parameter which contains the
  118180. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  118181. * src parameter of an <img> to display it
  118182. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  118183. * Check your browser for supported MIME types
  118184. */
  118185. static CreateScreenshot(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string): void;
  118186. /**
  118187. * Captures a screenshot of the current rendering
  118188. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_png
  118189. * @param engine defines the rendering engine
  118190. * @param camera defines the source camera
  118191. * @param size This parameter can be set to a single number or to an object with the
  118192. * following (optional) properties: precision, width, height. If a single number is passed,
  118193. * it will be used for both width and height. If an object is passed, the screenshot size
  118194. * will be derived from the parameters. The precision property is a multiplier allowing
  118195. * rendering at a higher or lower resolution
  118196. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  118197. * Check your browser for supported MIME types
  118198. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  118199. * to the src parameter of an <img> to display it
  118200. */
  118201. static CreateScreenshotAsync(engine: Engine, camera: Camera, size: IScreenshotSize | number, mimeType?: string): Promise<string>;
  118202. /**
  118203. * Generates an image screenshot from the specified camera.
  118204. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_png
  118205. * @param engine The engine to use for rendering
  118206. * @param camera The camera to use for rendering
  118207. * @param size This parameter can be set to a single number or to an object with the
  118208. * following (optional) properties: precision, width, height. If a single number is passed,
  118209. * it will be used for both width and height. If an object is passed, the screenshot size
  118210. * will be derived from the parameters. The precision property is a multiplier allowing
  118211. * rendering at a higher or lower resolution
  118212. * @param successCallback The callback receives a single parameter which contains the
  118213. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  118214. * src parameter of an <img> to display it
  118215. * @param mimeType The MIME type of the screenshot image (default: image/png).
  118216. * Check your browser for supported MIME types
  118217. * @param samples Texture samples (default: 1)
  118218. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  118219. * @param fileName A name for for the downloaded file.
  118220. */
  118221. static CreateScreenshotUsingRenderTarget(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): void;
  118222. /**
  118223. * Generates an image screenshot from the specified camera.
  118224. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_png
  118225. * @param engine The engine to use for rendering
  118226. * @param camera The camera to use for rendering
  118227. * @param size This parameter can be set to a single number or to an object with the
  118228. * following (optional) properties: precision, width, height. If a single number is passed,
  118229. * it will be used for both width and height. If an object is passed, the screenshot size
  118230. * will be derived from the parameters. The precision property is a multiplier allowing
  118231. * rendering at a higher or lower resolution
  118232. * @param mimeType The MIME type of the screenshot image (default: image/png).
  118233. * Check your browser for supported MIME types
  118234. * @param samples Texture samples (default: 1)
  118235. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  118236. * @param fileName A name for for the downloaded file.
  118237. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  118238. * to the src parameter of an <img> to display it
  118239. */
  118240. static CreateScreenshotUsingRenderTargetAsync(engine: Engine, camera: Camera, size: IScreenshotSize | number, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): Promise<string>;
  118241. /**
  118242. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  118243. * Be aware Math.random() could cause collisions, but:
  118244. * "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"
  118245. * @returns a pseudo random id
  118246. */
  118247. static RandomId(): string;
  118248. /**
  118249. * Test if the given uri is a base64 string
  118250. * @param uri The uri to test
  118251. * @return True if the uri is a base64 string or false otherwise
  118252. */
  118253. static IsBase64(uri: string): boolean;
  118254. /**
  118255. * Decode the given base64 uri.
  118256. * @param uri The uri to decode
  118257. * @return The decoded base64 data.
  118258. */
  118259. static DecodeBase64(uri: string): ArrayBuffer;
  118260. /**
  118261. * Gets the absolute url.
  118262. * @param url the input url
  118263. * @return the absolute url
  118264. */
  118265. static GetAbsoluteUrl(url: string): string;
  118266. /**
  118267. * No log
  118268. */
  118269. static readonly NoneLogLevel: number;
  118270. /**
  118271. * Only message logs
  118272. */
  118273. static readonly MessageLogLevel: number;
  118274. /**
  118275. * Only warning logs
  118276. */
  118277. static readonly WarningLogLevel: number;
  118278. /**
  118279. * Only error logs
  118280. */
  118281. static readonly ErrorLogLevel: number;
  118282. /**
  118283. * All logs
  118284. */
  118285. static readonly AllLogLevel: number;
  118286. /**
  118287. * Gets a value indicating the number of loading errors
  118288. * @ignorenaming
  118289. */
  118290. static get errorsCount(): number;
  118291. /**
  118292. * Callback called when a new log is added
  118293. */
  118294. static OnNewCacheEntry: (entry: string) => void;
  118295. /**
  118296. * Log a message to the console
  118297. * @param message defines the message to log
  118298. */
  118299. static Log(message: string): void;
  118300. /**
  118301. * Write a warning message to the console
  118302. * @param message defines the message to log
  118303. */
  118304. static Warn(message: string): void;
  118305. /**
  118306. * Write an error message to the console
  118307. * @param message defines the message to log
  118308. */
  118309. static Error(message: string): void;
  118310. /**
  118311. * Gets current log cache (list of logs)
  118312. */
  118313. static get LogCache(): string;
  118314. /**
  118315. * Clears the log cache
  118316. */
  118317. static ClearLogCache(): void;
  118318. /**
  118319. * Sets the current log level (MessageLogLevel / WarningLogLevel / ErrorLogLevel)
  118320. */
  118321. static set LogLevels(level: number);
  118322. /**
  118323. * Checks if the window object exists
  118324. * Back Compat only, please use DomManagement.IsWindowObjectExist instead.
  118325. */
  118326. static IsWindowObjectExist: typeof DomManagement.IsWindowObjectExist;
  118327. /**
  118328. * No performance log
  118329. */
  118330. static readonly PerformanceNoneLogLevel: number;
  118331. /**
  118332. * Use user marks to log performance
  118333. */
  118334. static readonly PerformanceUserMarkLogLevel: number;
  118335. /**
  118336. * Log performance to the console
  118337. */
  118338. static readonly PerformanceConsoleLogLevel: number;
  118339. private static _performance;
  118340. /**
  118341. * Sets the current performance log level
  118342. */
  118343. static set PerformanceLogLevel(level: number);
  118344. private static _StartPerformanceCounterDisabled;
  118345. private static _EndPerformanceCounterDisabled;
  118346. private static _StartUserMark;
  118347. private static _EndUserMark;
  118348. private static _StartPerformanceConsole;
  118349. private static _EndPerformanceConsole;
  118350. /**
  118351. * Starts a performance counter
  118352. */
  118353. static StartPerformanceCounter: (counterName: string, condition?: boolean) => void;
  118354. /**
  118355. * Ends a specific performance coutner
  118356. */
  118357. static EndPerformanceCounter: (counterName: string, condition?: boolean) => void;
  118358. /**
  118359. * Gets either window.performance.now() if supported or Date.now() else
  118360. */
  118361. static get Now(): number;
  118362. /**
  118363. * This method will return the name of the class used to create the instance of the given object.
  118364. * It will works only on Javascript basic data types (number, string, ...) and instance of class declared with the @className decorator.
  118365. * @param object the object to get the class name from
  118366. * @param isType defines if the object is actually a type
  118367. * @returns the name of the class, will be "object" for a custom data type not using the @className decorator
  118368. */
  118369. static GetClassName(object: any, isType?: boolean): string;
  118370. /**
  118371. * Gets the first element of an array satisfying a given predicate
  118372. * @param array defines the array to browse
  118373. * @param predicate defines the predicate to use
  118374. * @returns null if not found or the element
  118375. */
  118376. static First<T>(array: Array<T>, predicate: (item: T) => boolean): Nullable<T>;
  118377. /**
  118378. * This method will return the name of the full name of the class, including its owning module (if any).
  118379. * 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).
  118380. * @param object the object to get the class name from
  118381. * @param isType defines if the object is actually a type
  118382. * @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.
  118383. * @ignorenaming
  118384. */
  118385. static getFullClassName(object: any, isType?: boolean): Nullable<string>;
  118386. /**
  118387. * Returns a promise that resolves after the given amount of time.
  118388. * @param delay Number of milliseconds to delay
  118389. * @returns Promise that resolves after the given amount of time
  118390. */
  118391. static DelayAsync(delay: number): Promise<void>;
  118392. /**
  118393. * Utility function to detect if the current user agent is Safari
  118394. * @returns whether or not the current user agent is safari
  118395. */
  118396. static IsSafari(): boolean;
  118397. }
  118398. /**
  118399. * Use this className as a decorator on a given class definition to add it a name and optionally its module.
  118400. * You can then use the Tools.getClassName(obj) on an instance to retrieve its class name.
  118401. * This method is the only way to get it done in all cases, even if the .js file declaring the class is minified
  118402. * @param name The name of the class, case should be preserved
  118403. * @param module The name of the Module hosting the class, optional, but strongly recommended to specify if possible. Case should be preserved.
  118404. */
  118405. export function className(name: string, module?: string): (target: Object) => void;
  118406. /**
  118407. * An implementation of a loop for asynchronous functions.
  118408. */
  118409. export class AsyncLoop {
  118410. /**
  118411. * Defines the number of iterations for the loop
  118412. */
  118413. iterations: number;
  118414. /**
  118415. * Defines the current index of the loop.
  118416. */
  118417. index: number;
  118418. private _done;
  118419. private _fn;
  118420. private _successCallback;
  118421. /**
  118422. * Constructor.
  118423. * @param iterations the number of iterations.
  118424. * @param func the function to run each iteration
  118425. * @param successCallback the callback that will be called upon succesful execution
  118426. * @param offset starting offset.
  118427. */
  118428. constructor(
  118429. /**
  118430. * Defines the number of iterations for the loop
  118431. */
  118432. iterations: number, func: (asyncLoop: AsyncLoop) => void, successCallback: () => void, offset?: number);
  118433. /**
  118434. * Execute the next iteration. Must be called after the last iteration was finished.
  118435. */
  118436. executeNext(): void;
  118437. /**
  118438. * Break the loop and run the success callback.
  118439. */
  118440. breakLoop(): void;
  118441. /**
  118442. * Create and run an async loop.
  118443. * @param iterations the number of iterations.
  118444. * @param fn the function to run each iteration
  118445. * @param successCallback the callback that will be called upon succesful execution
  118446. * @param offset starting offset.
  118447. * @returns the created async loop object
  118448. */
  118449. static Run(iterations: number, fn: (asyncLoop: AsyncLoop) => void, successCallback: () => void, offset?: number): AsyncLoop;
  118450. /**
  118451. * A for-loop that will run a given number of iterations synchronous and the rest async.
  118452. * @param iterations total number of iterations
  118453. * @param syncedIterations number of synchronous iterations in each async iteration.
  118454. * @param fn the function to call each iteration.
  118455. * @param callback a success call back that will be called when iterating stops.
  118456. * @param breakFunction a break condition (optional)
  118457. * @param timeout timeout settings for the setTimeout function. default - 0.
  118458. * @returns the created async loop object
  118459. */
  118460. static SyncAsyncForLoop(iterations: number, syncedIterations: number, fn: (iteration: number) => void, callback: () => void, breakFunction?: () => boolean, timeout?: number): AsyncLoop;
  118461. }
  118462. }
  118463. declare module BABYLON {
  118464. /**
  118465. * This class implement a typical dictionary using a string as key and the generic type T as value.
  118466. * The underlying implementation relies on an associative array to ensure the best performances.
  118467. * The value can be anything including 'null' but except 'undefined'
  118468. */
  118469. export class StringDictionary<T> {
  118470. /**
  118471. * This will clear this dictionary and copy the content from the 'source' one.
  118472. * If the T value is a custom object, it won't be copied/cloned, the same object will be used
  118473. * @param source the dictionary to take the content from and copy to this dictionary
  118474. */
  118475. copyFrom(source: StringDictionary<T>): void;
  118476. /**
  118477. * Get a value based from its key
  118478. * @param key the given key to get the matching value from
  118479. * @return the value if found, otherwise undefined is returned
  118480. */
  118481. get(key: string): T | undefined;
  118482. /**
  118483. * Get a value from its key or add it if it doesn't exist.
  118484. * This method will ensure you that a given key/data will be present in the dictionary.
  118485. * @param key the given key to get the matching value from
  118486. * @param factory the factory that will create the value if the key is not present in the dictionary.
  118487. * The factory will only be invoked if there's no data for the given key.
  118488. * @return the value corresponding to the key.
  118489. */
  118490. getOrAddWithFactory(key: string, factory: (key: string) => T): T;
  118491. /**
  118492. * Get a value from its key if present in the dictionary otherwise add it
  118493. * @param key the key to get the value from
  118494. * @param val if there's no such key/value pair in the dictionary add it with this value
  118495. * @return the value corresponding to the key
  118496. */
  118497. getOrAdd(key: string, val: T): T;
  118498. /**
  118499. * Check if there's a given key in the dictionary
  118500. * @param key the key to check for
  118501. * @return true if the key is present, false otherwise
  118502. */
  118503. contains(key: string): boolean;
  118504. /**
  118505. * Add a new key and its corresponding value
  118506. * @param key the key to add
  118507. * @param value the value corresponding to the key
  118508. * @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
  118509. */
  118510. add(key: string, value: T): boolean;
  118511. /**
  118512. * Update a specific value associated to a key
  118513. * @param key defines the key to use
  118514. * @param value defines the value to store
  118515. * @returns true if the value was updated (or false if the key was not found)
  118516. */
  118517. set(key: string, value: T): boolean;
  118518. /**
  118519. * Get the element of the given key and remove it from the dictionary
  118520. * @param key defines the key to search
  118521. * @returns the value associated with the key or null if not found
  118522. */
  118523. getAndRemove(key: string): Nullable<T>;
  118524. /**
  118525. * Remove a key/value from the dictionary.
  118526. * @param key the key to remove
  118527. * @return true if the item was successfully deleted, false if no item with such key exist in the dictionary
  118528. */
  118529. remove(key: string): boolean;
  118530. /**
  118531. * Clear the whole content of the dictionary
  118532. */
  118533. clear(): void;
  118534. /**
  118535. * Gets the current count
  118536. */
  118537. get count(): number;
  118538. /**
  118539. * Execute a callback on each key/val of the dictionary.
  118540. * Note that you can remove any element in this dictionary in the callback implementation
  118541. * @param callback the callback to execute on a given key/value pair
  118542. */
  118543. forEach(callback: (key: string, val: T) => void): void;
  118544. /**
  118545. * Execute a callback on every occurrence of the dictionary until it returns a valid TRes object.
  118546. * If the callback returns null or undefined the method will iterate to the next key/value pair
  118547. * Note that you can remove any element in this dictionary in the callback implementation
  118548. * @param callback the callback to execute, if it return a valid T instanced object the enumeration will stop and the object will be returned
  118549. * @returns the first item
  118550. */
  118551. first<TRes>(callback: (key: string, val: T) => TRes): TRes | null;
  118552. private _count;
  118553. private _data;
  118554. }
  118555. }
  118556. declare module BABYLON {
  118557. /** @hidden */
  118558. export interface ICollisionCoordinator {
  118559. createCollider(): Collider;
  118560. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: Nullable<AbstractMesh>, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  118561. init(scene: Scene): void;
  118562. }
  118563. /** @hidden */
  118564. export class DefaultCollisionCoordinator implements ICollisionCoordinator {
  118565. private _scene;
  118566. private _scaledPosition;
  118567. private _scaledVelocity;
  118568. private _finalPosition;
  118569. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: AbstractMesh, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  118570. createCollider(): Collider;
  118571. init(scene: Scene): void;
  118572. private _collideWithWorld;
  118573. }
  118574. }
  118575. declare module BABYLON {
  118576. /**
  118577. * Class used to manage all inputs for the scene.
  118578. */
  118579. export class InputManager {
  118580. /** The distance in pixel that you have to move to prevent some events */
  118581. static DragMovementThreshold: number;
  118582. /** Time in milliseconds to wait to raise long press events if button is still pressed */
  118583. static LongPressDelay: number;
  118584. /** Time in milliseconds with two consecutive clicks will be considered as a double click */
  118585. static DoubleClickDelay: number;
  118586. /** If you need to check double click without raising a single click at first click, enable this flag */
  118587. static ExclusiveDoubleClickMode: boolean;
  118588. /** 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. */
  118589. private _alreadyAttached;
  118590. private _wheelEventName;
  118591. private _onPointerMove;
  118592. private _onPointerDown;
  118593. private _onPointerUp;
  118594. private _initClickEvent;
  118595. private _initActionManager;
  118596. private _delayedSimpleClick;
  118597. private _delayedSimpleClickTimeout;
  118598. private _previousDelayedSimpleClickTimeout;
  118599. private _meshPickProceed;
  118600. private _previousButtonPressed;
  118601. private _currentPickResult;
  118602. private _previousPickResult;
  118603. private _totalPointersPressed;
  118604. private _doubleClickOccured;
  118605. private _pointerOverMesh;
  118606. private _pickedDownMesh;
  118607. private _pickedUpMesh;
  118608. private _pointerX;
  118609. private _pointerY;
  118610. private _unTranslatedPointerX;
  118611. private _unTranslatedPointerY;
  118612. private _startingPointerPosition;
  118613. private _previousStartingPointerPosition;
  118614. private _startingPointerTime;
  118615. private _previousStartingPointerTime;
  118616. private _pointerCaptures;
  118617. private _meshUnderPointerId;
  118618. private _onKeyDown;
  118619. private _onKeyUp;
  118620. private _onCanvasFocusObserver;
  118621. private _onCanvasBlurObserver;
  118622. private _scene;
  118623. /**
  118624. * Creates a new InputManager
  118625. * @param scene defines the hosting scene
  118626. */
  118627. constructor(scene: Scene);
  118628. /**
  118629. * Gets the mesh that is currently under the pointer
  118630. */
  118631. get meshUnderPointer(): Nullable<AbstractMesh>;
  118632. /**
  118633. * When using more than one pointer (for example in XR) you can get the mesh under the specific pointer
  118634. * @param pointerId the pointer id to use
  118635. * @returns The mesh under this pointer id or null if not found
  118636. */
  118637. getMeshUnderPointerByPointerId(pointerId: number): Nullable<AbstractMesh>;
  118638. /**
  118639. * Gets the pointer coordinates in 2D without any translation (ie. straight out of the pointer event)
  118640. */
  118641. get unTranslatedPointer(): Vector2;
  118642. /**
  118643. * Gets or sets the current on-screen X position of the pointer
  118644. */
  118645. get pointerX(): number;
  118646. set pointerX(value: number);
  118647. /**
  118648. * Gets or sets the current on-screen Y position of the pointer
  118649. */
  118650. get pointerY(): number;
  118651. set pointerY(value: number);
  118652. private _updatePointerPosition;
  118653. private _processPointerMove;
  118654. private _setRayOnPointerInfo;
  118655. private _checkPrePointerObservable;
  118656. /**
  118657. * Use this method to simulate a pointer move on a mesh
  118658. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  118659. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  118660. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  118661. */
  118662. simulatePointerMove(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): void;
  118663. /**
  118664. * Use this method to simulate a pointer down on a mesh
  118665. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  118666. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  118667. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  118668. */
  118669. simulatePointerDown(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): void;
  118670. private _processPointerDown;
  118671. /** @hidden */
  118672. _isPointerSwiping(): boolean;
  118673. /**
  118674. * Use this method to simulate a pointer up on a mesh
  118675. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  118676. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  118677. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  118678. * @param doubleTap indicates that the pointer up event should be considered as part of a double click (false by default)
  118679. */
  118680. simulatePointerUp(pickResult: PickingInfo, pointerEventInit?: PointerEventInit, doubleTap?: boolean): void;
  118681. private _processPointerUp;
  118682. /**
  118683. * Gets a boolean indicating if the current pointer event is captured (meaning that the scene has already handled the pointer down)
  118684. * @param pointerId defines the pointer id to use in a multi-touch scenario (0 by default)
  118685. * @returns true if the pointer was captured
  118686. */
  118687. isPointerCaptured(pointerId?: number): boolean;
  118688. /**
  118689. * Attach events to the canvas (To handle actionManagers triggers and raise onPointerMove, onPointerDown and onPointerUp
  118690. * @param attachUp defines if you want to attach events to pointerup
  118691. * @param attachDown defines if you want to attach events to pointerdown
  118692. * @param attachMove defines if you want to attach events to pointermove
  118693. * @param elementToAttachTo defines the target DOM element to attach to (will use the canvas by default)
  118694. */
  118695. attachControl(attachUp?: boolean, attachDown?: boolean, attachMove?: boolean, elementToAttachTo?: Nullable<HTMLElement>): void;
  118696. /**
  118697. * Detaches all event handlers
  118698. */
  118699. detachControl(): void;
  118700. /**
  118701. * Force the value of meshUnderPointer
  118702. * @param mesh defines the mesh to use
  118703. * @param pointerId optional pointer id when using more than one pointer. Defaults to 0
  118704. */
  118705. setPointerOverMesh(mesh: Nullable<AbstractMesh>, pointerId?: number): void;
  118706. /**
  118707. * Gets the mesh under the pointer
  118708. * @returns a Mesh or null if no mesh is under the pointer
  118709. */
  118710. getPointerOverMesh(): Nullable<AbstractMesh>;
  118711. }
  118712. }
  118713. declare module BABYLON {
  118714. /**
  118715. * This class defines the direct association between an animation and a target
  118716. */
  118717. export class TargetedAnimation {
  118718. /**
  118719. * Animation to perform
  118720. */
  118721. animation: Animation;
  118722. /**
  118723. * Target to animate
  118724. */
  118725. target: any;
  118726. /**
  118727. * Returns the string "TargetedAnimation"
  118728. * @returns "TargetedAnimation"
  118729. */
  118730. getClassName(): string;
  118731. /**
  118732. * Serialize the object
  118733. * @returns the JSON object representing the current entity
  118734. */
  118735. serialize(): any;
  118736. }
  118737. /**
  118738. * Use this class to create coordinated animations on multiple targets
  118739. */
  118740. export class AnimationGroup implements IDisposable {
  118741. /** The name of the animation group */
  118742. name: string;
  118743. private _scene;
  118744. private _targetedAnimations;
  118745. private _animatables;
  118746. private _from;
  118747. private _to;
  118748. private _isStarted;
  118749. private _isPaused;
  118750. private _speedRatio;
  118751. private _loopAnimation;
  118752. private _isAdditive;
  118753. /**
  118754. * Gets or sets the unique id of the node
  118755. */
  118756. uniqueId: number;
  118757. /**
  118758. * This observable will notify when one animation have ended
  118759. */
  118760. onAnimationEndObservable: Observable<TargetedAnimation>;
  118761. /**
  118762. * Observer raised when one animation loops
  118763. */
  118764. onAnimationLoopObservable: Observable<TargetedAnimation>;
  118765. /**
  118766. * Observer raised when all animations have looped
  118767. */
  118768. onAnimationGroupLoopObservable: Observable<AnimationGroup>;
  118769. /**
  118770. * This observable will notify when all animations have ended.
  118771. */
  118772. onAnimationGroupEndObservable: Observable<AnimationGroup>;
  118773. /**
  118774. * This observable will notify when all animations have paused.
  118775. */
  118776. onAnimationGroupPauseObservable: Observable<AnimationGroup>;
  118777. /**
  118778. * This observable will notify when all animations are playing.
  118779. */
  118780. onAnimationGroupPlayObservable: Observable<AnimationGroup>;
  118781. /**
  118782. * Gets the first frame
  118783. */
  118784. get from(): number;
  118785. /**
  118786. * Gets the last frame
  118787. */
  118788. get to(): number;
  118789. /**
  118790. * Define if the animations are started
  118791. */
  118792. get isStarted(): boolean;
  118793. /**
  118794. * Gets a value indicating that the current group is playing
  118795. */
  118796. get isPlaying(): boolean;
  118797. /**
  118798. * Gets or sets the speed ratio to use for all animations
  118799. */
  118800. get speedRatio(): number;
  118801. /**
  118802. * Gets or sets the speed ratio to use for all animations
  118803. */
  118804. set speedRatio(value: number);
  118805. /**
  118806. * Gets or sets if all animations should loop or not
  118807. */
  118808. get loopAnimation(): boolean;
  118809. set loopAnimation(value: boolean);
  118810. /**
  118811. * Gets or sets if all animations should be evaluated additively
  118812. */
  118813. get isAdditive(): boolean;
  118814. set isAdditive(value: boolean);
  118815. /**
  118816. * Gets the targeted animations for this animation group
  118817. */
  118818. get targetedAnimations(): Array<TargetedAnimation>;
  118819. /**
  118820. * returning the list of animatables controlled by this animation group.
  118821. */
  118822. get animatables(): Array<Animatable>;
  118823. /**
  118824. * Gets the list of target animations
  118825. */
  118826. get children(): TargetedAnimation[];
  118827. /**
  118828. * Instantiates a new Animation Group.
  118829. * This helps managing several animations at once.
  118830. * @see https://doc.babylonjs.com/how_to/group
  118831. * @param name Defines the name of the group
  118832. * @param scene Defines the scene the group belongs to
  118833. */
  118834. constructor(
  118835. /** The name of the animation group */
  118836. name: string, scene?: Nullable<Scene>);
  118837. /**
  118838. * Add an animation (with its target) in the group
  118839. * @param animation defines the animation we want to add
  118840. * @param target defines the target of the animation
  118841. * @returns the TargetedAnimation object
  118842. */
  118843. addTargetedAnimation(animation: Animation, target: any): TargetedAnimation;
  118844. /**
  118845. * This function will normalize every animation in the group to make sure they all go from beginFrame to endFrame
  118846. * It can add constant keys at begin or end
  118847. * @param beginFrame defines the new begin frame for all animations or the smallest begin frame of all animations if null (defaults to null)
  118848. * @param endFrame defines the new end frame for all animations or the largest end frame of all animations if null (defaults to null)
  118849. * @returns the animation group
  118850. */
  118851. normalize(beginFrame?: Nullable<number>, endFrame?: Nullable<number>): AnimationGroup;
  118852. private _animationLoopCount;
  118853. private _animationLoopFlags;
  118854. private _processLoop;
  118855. /**
  118856. * Start all animations on given targets
  118857. * @param loop defines if animations must loop
  118858. * @param speedRatio defines the ratio to apply to animation speed (1 by default)
  118859. * @param from defines the from key (optional)
  118860. * @param to defines the to key (optional)
  118861. * @param isAdditive defines the additive state for the resulting animatables (optional)
  118862. * @returns the current animation group
  118863. */
  118864. start(loop?: boolean, speedRatio?: number, from?: number, to?: number, isAdditive?: boolean): AnimationGroup;
  118865. /**
  118866. * Pause all animations
  118867. * @returns the animation group
  118868. */
  118869. pause(): AnimationGroup;
  118870. /**
  118871. * Play all animations to initial state
  118872. * This function will start() the animations if they were not started or will restart() them if they were paused
  118873. * @param loop defines if animations must loop
  118874. * @returns the animation group
  118875. */
  118876. play(loop?: boolean): AnimationGroup;
  118877. /**
  118878. * Reset all animations to initial state
  118879. * @returns the animation group
  118880. */
  118881. reset(): AnimationGroup;
  118882. /**
  118883. * Restart animations from key 0
  118884. * @returns the animation group
  118885. */
  118886. restart(): AnimationGroup;
  118887. /**
  118888. * Stop all animations
  118889. * @returns the animation group
  118890. */
  118891. stop(): AnimationGroup;
  118892. /**
  118893. * Set animation weight for all animatables
  118894. * @param weight defines the weight to use
  118895. * @return the animationGroup
  118896. * @see https://doc.babylonjs.com/babylon101/animations#animation-weights
  118897. */
  118898. setWeightForAllAnimatables(weight: number): AnimationGroup;
  118899. /**
  118900. * Synchronize and normalize all animatables with a source animatable
  118901. * @param root defines the root animatable to synchronize with
  118902. * @return the animationGroup
  118903. * @see https://doc.babylonjs.com/babylon101/animations#animation-weights
  118904. */
  118905. syncAllAnimationsWith(root: Animatable): AnimationGroup;
  118906. /**
  118907. * Goes to a specific frame in this animation group
  118908. * @param frame the frame number to go to
  118909. * @return the animationGroup
  118910. */
  118911. goToFrame(frame: number): AnimationGroup;
  118912. /**
  118913. * Dispose all associated resources
  118914. */
  118915. dispose(): void;
  118916. private _checkAnimationGroupEnded;
  118917. /**
  118918. * Clone the current animation group and returns a copy
  118919. * @param newName defines the name of the new group
  118920. * @param targetConverter defines an optional function used to convert current animation targets to new ones
  118921. * @returns the new aniamtion group
  118922. */
  118923. clone(newName: string, targetConverter?: (oldTarget: any) => any): AnimationGroup;
  118924. /**
  118925. * Serializes the animationGroup to an object
  118926. * @returns Serialized object
  118927. */
  118928. serialize(): any;
  118929. /**
  118930. * Returns a new AnimationGroup object parsed from the source provided.
  118931. * @param parsedAnimationGroup defines the source
  118932. * @param scene defines the scene that will receive the animationGroup
  118933. * @returns a new AnimationGroup
  118934. */
  118935. static Parse(parsedAnimationGroup: any, scene: Scene): AnimationGroup;
  118936. /**
  118937. * Convert the keyframes for all animations belonging to the group to be relative to a given reference frame.
  118938. * @param sourceAnimationGroup defines the AnimationGroup containing animations to convert
  118939. * @param referenceFrame defines the frame that keyframes in the range will be relative to
  118940. * @param range defines the name of the AnimationRange belonging to the animations in the group to convert
  118941. * @param cloneOriginal defines whether or not to clone the group and convert the clone or convert the original group (default is false)
  118942. * @param clonedName defines the name of the resulting cloned AnimationGroup if cloneOriginal is true
  118943. * @returns a new AnimationGroup if cloneOriginal is true or the original AnimationGroup if cloneOriginal is false
  118944. */
  118945. static MakeAnimationAdditive(sourceAnimationGroup: AnimationGroup, referenceFrame?: number, range?: string, cloneOriginal?: boolean, clonedName?: string): AnimationGroup;
  118946. /**
  118947. * Returns the string "AnimationGroup"
  118948. * @returns "AnimationGroup"
  118949. */
  118950. getClassName(): string;
  118951. /**
  118952. * Creates a detailled string about the object
  118953. * @param fullDetails defines if the output string will support multiple levels of logging within scene loading
  118954. * @returns a string representing the object
  118955. */
  118956. toString(fullDetails?: boolean): string;
  118957. }
  118958. }
  118959. declare module BABYLON {
  118960. /**
  118961. * Define an interface for all classes that will hold resources
  118962. */
  118963. export interface IDisposable {
  118964. /**
  118965. * Releases all held resources
  118966. */
  118967. dispose(): void;
  118968. }
  118969. /** Interface defining initialization parameters for Scene class */
  118970. export interface SceneOptions {
  118971. /**
  118972. * Defines that scene should keep up-to-date a map of geometry to enable fast look-up by uniqueId
  118973. * It will improve performance when the number of geometries becomes important.
  118974. */
  118975. useGeometryUniqueIdsMap?: boolean;
  118976. /**
  118977. * Defines that each material of the scene should keep up-to-date a map of referencing meshes for fast diposing
  118978. * It will improve performance when the number of mesh becomes important, but might consume a bit more memory
  118979. */
  118980. useMaterialMeshMap?: boolean;
  118981. /**
  118982. * Defines that each mesh of the scene should keep up-to-date a map of referencing cloned meshes for fast diposing
  118983. * It will improve performance when the number of mesh becomes important, but might consume a bit more memory
  118984. */
  118985. useClonedMeshMap?: boolean;
  118986. /** Defines if the creation of the scene should impact the engine (Eg. UtilityLayer's scene) */
  118987. virtual?: boolean;
  118988. }
  118989. /**
  118990. * Represents a scene to be rendered by the engine.
  118991. * @see https://doc.babylonjs.com/features/scene
  118992. */
  118993. export class Scene extends AbstractScene implements IAnimatable, IClipPlanesHolder {
  118994. /** The fog is deactivated */
  118995. static readonly FOGMODE_NONE: number;
  118996. /** The fog density is following an exponential function */
  118997. static readonly FOGMODE_EXP: number;
  118998. /** The fog density is following an exponential function faster than FOGMODE_EXP */
  118999. static readonly FOGMODE_EXP2: number;
  119000. /** The fog density is following a linear function. */
  119001. static readonly FOGMODE_LINEAR: number;
  119002. /**
  119003. * Gets or sets the minimum deltatime when deterministic lock step is enabled
  119004. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  119005. */
  119006. static MinDeltaTime: number;
  119007. /**
  119008. * Gets or sets the maximum deltatime when deterministic lock step is enabled
  119009. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  119010. */
  119011. static MaxDeltaTime: number;
  119012. /**
  119013. * Factory used to create the default material.
  119014. * @param name The name of the material to create
  119015. * @param scene The scene to create the material for
  119016. * @returns The default material
  119017. */
  119018. static DefaultMaterialFactory(scene: Scene): Material;
  119019. /**
  119020. * Factory used to create the a collision coordinator.
  119021. * @returns The collision coordinator
  119022. */
  119023. static CollisionCoordinatorFactory(): ICollisionCoordinator;
  119024. /** @hidden */
  119025. _inputManager: InputManager;
  119026. /** Define this parameter if you are using multiple cameras and you want to specify which one should be used for pointer position */
  119027. cameraToUseForPointers: Nullable<Camera>;
  119028. /** @hidden */
  119029. readonly _isScene: boolean;
  119030. /** @hidden */
  119031. _blockEntityCollection: boolean;
  119032. /**
  119033. * Gets or sets a boolean that indicates if the scene must clear the render buffer before rendering a frame
  119034. */
  119035. autoClear: boolean;
  119036. /**
  119037. * Gets or sets a boolean that indicates if the scene must clear the depth and stencil buffers before rendering a frame
  119038. */
  119039. autoClearDepthAndStencil: boolean;
  119040. /**
  119041. * Defines the color used to clear the render buffer (Default is (0.2, 0.2, 0.3, 1.0))
  119042. */
  119043. clearColor: Color4;
  119044. /**
  119045. * Defines the color used to simulate the ambient color (Default is (0, 0, 0))
  119046. */
  119047. ambientColor: Color3;
  119048. /**
  119049. * This is use to store the default BRDF lookup for PBR materials in your scene.
  119050. * It should only be one of the following (if not the default embedded one):
  119051. * * For uncorrelated BRDF (pbr.brdf.useEnergyConservation = false and pbr.brdf.useSmithVisibilityHeightCorrelated = false) : https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds
  119052. * * For correlated BRDF (pbr.brdf.useEnergyConservation = false and pbr.brdf.useSmithVisibilityHeightCorrelated = true) : https://assets.babylonjs.com/environments/correlatedBRDF.dds
  119053. * * For correlated multi scattering BRDF (pbr.brdf.useEnergyConservation = true and pbr.brdf.useSmithVisibilityHeightCorrelated = true) : https://assets.babylonjs.com/environments/correlatedMSBRDF.dds
  119054. * The material properties need to be setup according to the type of texture in use.
  119055. */
  119056. environmentBRDFTexture: BaseTexture;
  119057. /**
  119058. * Texture used in all pbr material as the reflection texture.
  119059. * As in the majority of the scene they are the same (exception for multi room and so on),
  119060. * this is easier to reference from here than from all the materials.
  119061. */
  119062. get environmentTexture(): Nullable<BaseTexture>;
  119063. /**
  119064. * Texture used in all pbr material as the reflection texture.
  119065. * As in the majority of the scene they are the same (exception for multi room and so on),
  119066. * this is easier to set here than in all the materials.
  119067. */
  119068. set environmentTexture(value: Nullable<BaseTexture>);
  119069. /** @hidden */
  119070. protected _environmentIntensity: number;
  119071. /**
  119072. * Intensity of the environment in all pbr material.
  119073. * This dims or reinforces the IBL lighting overall (reflection and diffuse).
  119074. * As in the majority of the scene they are the same (exception for multi room and so on),
  119075. * this is easier to reference from here than from all the materials.
  119076. */
  119077. get environmentIntensity(): number;
  119078. /**
  119079. * Intensity of the environment in all pbr material.
  119080. * This dims or reinforces the IBL lighting overall (reflection and diffuse).
  119081. * As in the majority of the scene they are the same (exception for multi room and so on),
  119082. * this is easier to set here than in all the materials.
  119083. */
  119084. set environmentIntensity(value: number);
  119085. /** @hidden */
  119086. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  119087. /**
  119088. * Default image processing configuration used either in the rendering
  119089. * Forward main pass or through the imageProcessingPostProcess if present.
  119090. * As in the majority of the scene they are the same (exception for multi camera),
  119091. * this is easier to reference from here than from all the materials and post process.
  119092. *
  119093. * No setter as we it is a shared configuration, you can set the values instead.
  119094. */
  119095. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  119096. private _forceWireframe;
  119097. /**
  119098. * Gets or sets a boolean indicating if all rendering must be done in wireframe
  119099. */
  119100. set forceWireframe(value: boolean);
  119101. get forceWireframe(): boolean;
  119102. private _skipFrustumClipping;
  119103. /**
  119104. * Gets or sets a boolean indicating if we should skip the frustum clipping part of the active meshes selection
  119105. */
  119106. set skipFrustumClipping(value: boolean);
  119107. get skipFrustumClipping(): boolean;
  119108. private _forcePointsCloud;
  119109. /**
  119110. * Gets or sets a boolean indicating if all rendering must be done in point cloud
  119111. */
  119112. set forcePointsCloud(value: boolean);
  119113. get forcePointsCloud(): boolean;
  119114. /**
  119115. * Gets or sets the active clipplane 1
  119116. */
  119117. clipPlane: Nullable<Plane>;
  119118. /**
  119119. * Gets or sets the active clipplane 2
  119120. */
  119121. clipPlane2: Nullable<Plane>;
  119122. /**
  119123. * Gets or sets the active clipplane 3
  119124. */
  119125. clipPlane3: Nullable<Plane>;
  119126. /**
  119127. * Gets or sets the active clipplane 4
  119128. */
  119129. clipPlane4: Nullable<Plane>;
  119130. /**
  119131. * Gets or sets the active clipplane 5
  119132. */
  119133. clipPlane5: Nullable<Plane>;
  119134. /**
  119135. * Gets or sets the active clipplane 6
  119136. */
  119137. clipPlane6: Nullable<Plane>;
  119138. /**
  119139. * Gets or sets a boolean indicating if animations are enabled
  119140. */
  119141. animationsEnabled: boolean;
  119142. private _animationPropertiesOverride;
  119143. /**
  119144. * Gets or sets the animation properties override
  119145. */
  119146. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  119147. set animationPropertiesOverride(value: Nullable<AnimationPropertiesOverride>);
  119148. /**
  119149. * Gets or sets a boolean indicating if a constant deltatime has to be used
  119150. * This is mostly useful for testing purposes when you do not want the animations to scale with the framerate
  119151. */
  119152. useConstantAnimationDeltaTime: boolean;
  119153. /**
  119154. * Gets or sets a boolean indicating if the scene must keep the meshUnderPointer property updated
  119155. * Please note that it requires to run a ray cast through the scene on every frame
  119156. */
  119157. constantlyUpdateMeshUnderPointer: boolean;
  119158. /**
  119159. * Defines the HTML cursor to use when hovering over interactive elements
  119160. */
  119161. hoverCursor: string;
  119162. /**
  119163. * Defines the HTML default cursor to use (empty by default)
  119164. */
  119165. defaultCursor: string;
  119166. /**
  119167. * Defines whether cursors are handled by the scene.
  119168. */
  119169. doNotHandleCursors: boolean;
  119170. /**
  119171. * This is used to call preventDefault() on pointer down
  119172. * in order to block unwanted artifacts like system double clicks
  119173. */
  119174. preventDefaultOnPointerDown: boolean;
  119175. /**
  119176. * This is used to call preventDefault() on pointer up
  119177. * in order to block unwanted artifacts like system double clicks
  119178. */
  119179. preventDefaultOnPointerUp: boolean;
  119180. /**
  119181. * Gets or sets user defined metadata
  119182. */
  119183. metadata: any;
  119184. /**
  119185. * For internal use only. Please do not use.
  119186. */
  119187. reservedDataStore: any;
  119188. /**
  119189. * Gets the name of the plugin used to load this scene (null by default)
  119190. */
  119191. loadingPluginName: string;
  119192. /**
  119193. * Use this array to add regular expressions used to disable offline support for specific urls
  119194. */
  119195. disableOfflineSupportExceptionRules: RegExp[];
  119196. /**
  119197. * An event triggered when the scene is disposed.
  119198. */
  119199. onDisposeObservable: Observable<Scene>;
  119200. private _onDisposeObserver;
  119201. /** Sets a function to be executed when this scene is disposed. */
  119202. set onDispose(callback: () => void);
  119203. /**
  119204. * An event triggered before rendering the scene (right after animations and physics)
  119205. */
  119206. onBeforeRenderObservable: Observable<Scene>;
  119207. private _onBeforeRenderObserver;
  119208. /** Sets a function to be executed before rendering this scene */
  119209. set beforeRender(callback: Nullable<() => void>);
  119210. /**
  119211. * An event triggered after rendering the scene
  119212. */
  119213. onAfterRenderObservable: Observable<Scene>;
  119214. /**
  119215. * An event triggered after rendering the scene for an active camera (When scene.render is called this will be called after each camera)
  119216. */
  119217. onAfterRenderCameraObservable: Observable<Camera>;
  119218. private _onAfterRenderObserver;
  119219. /** Sets a function to be executed after rendering this scene */
  119220. set afterRender(callback: Nullable<() => void>);
  119221. /**
  119222. * An event triggered before animating the scene
  119223. */
  119224. onBeforeAnimationsObservable: Observable<Scene>;
  119225. /**
  119226. * An event triggered after animations processing
  119227. */
  119228. onAfterAnimationsObservable: Observable<Scene>;
  119229. /**
  119230. * An event triggered before draw calls are ready to be sent
  119231. */
  119232. onBeforeDrawPhaseObservable: Observable<Scene>;
  119233. /**
  119234. * An event triggered after draw calls have been sent
  119235. */
  119236. onAfterDrawPhaseObservable: Observable<Scene>;
  119237. /**
  119238. * An event triggered when the scene is ready
  119239. */
  119240. onReadyObservable: Observable<Scene>;
  119241. /**
  119242. * An event triggered before rendering a camera
  119243. */
  119244. onBeforeCameraRenderObservable: Observable<Camera>;
  119245. private _onBeforeCameraRenderObserver;
  119246. /** Sets a function to be executed before rendering a camera*/
  119247. set beforeCameraRender(callback: () => void);
  119248. /**
  119249. * An event triggered after rendering a camera
  119250. */
  119251. onAfterCameraRenderObservable: Observable<Camera>;
  119252. private _onAfterCameraRenderObserver;
  119253. /** Sets a function to be executed after rendering a camera*/
  119254. set afterCameraRender(callback: () => void);
  119255. /**
  119256. * An event triggered when active meshes evaluation is about to start
  119257. */
  119258. onBeforeActiveMeshesEvaluationObservable: Observable<Scene>;
  119259. /**
  119260. * An event triggered when active meshes evaluation is done
  119261. */
  119262. onAfterActiveMeshesEvaluationObservable: Observable<Scene>;
  119263. /**
  119264. * An event triggered when particles rendering is about to start
  119265. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  119266. */
  119267. onBeforeParticlesRenderingObservable: Observable<Scene>;
  119268. /**
  119269. * An event triggered when particles rendering is done
  119270. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  119271. */
  119272. onAfterParticlesRenderingObservable: Observable<Scene>;
  119273. /**
  119274. * An event triggered when SceneLoader.Append or SceneLoader.Load or SceneLoader.ImportMesh were successfully executed
  119275. */
  119276. onDataLoadedObservable: Observable<Scene>;
  119277. /**
  119278. * An event triggered when a camera is created
  119279. */
  119280. onNewCameraAddedObservable: Observable<Camera>;
  119281. /**
  119282. * An event triggered when a camera is removed
  119283. */
  119284. onCameraRemovedObservable: Observable<Camera>;
  119285. /**
  119286. * An event triggered when a light is created
  119287. */
  119288. onNewLightAddedObservable: Observable<Light>;
  119289. /**
  119290. * An event triggered when a light is removed
  119291. */
  119292. onLightRemovedObservable: Observable<Light>;
  119293. /**
  119294. * An event triggered when a geometry is created
  119295. */
  119296. onNewGeometryAddedObservable: Observable<Geometry>;
  119297. /**
  119298. * An event triggered when a geometry is removed
  119299. */
  119300. onGeometryRemovedObservable: Observable<Geometry>;
  119301. /**
  119302. * An event triggered when a transform node is created
  119303. */
  119304. onNewTransformNodeAddedObservable: Observable<TransformNode>;
  119305. /**
  119306. * An event triggered when a transform node is removed
  119307. */
  119308. onTransformNodeRemovedObservable: Observable<TransformNode>;
  119309. /**
  119310. * An event triggered when a mesh is created
  119311. */
  119312. onNewMeshAddedObservable: Observable<AbstractMesh>;
  119313. /**
  119314. * An event triggered when a mesh is removed
  119315. */
  119316. onMeshRemovedObservable: Observable<AbstractMesh>;
  119317. /**
  119318. * An event triggered when a skeleton is created
  119319. */
  119320. onNewSkeletonAddedObservable: Observable<Skeleton>;
  119321. /**
  119322. * An event triggered when a skeleton is removed
  119323. */
  119324. onSkeletonRemovedObservable: Observable<Skeleton>;
  119325. /**
  119326. * An event triggered when a material is created
  119327. */
  119328. onNewMaterialAddedObservable: Observable<Material>;
  119329. /**
  119330. * An event triggered when a material is removed
  119331. */
  119332. onMaterialRemovedObservable: Observable<Material>;
  119333. /**
  119334. * An event triggered when a texture is created
  119335. */
  119336. onNewTextureAddedObservable: Observable<BaseTexture>;
  119337. /**
  119338. * An event triggered when a texture is removed
  119339. */
  119340. onTextureRemovedObservable: Observable<BaseTexture>;
  119341. /**
  119342. * An event triggered when render targets are about to be rendered
  119343. * Can happen multiple times per frame.
  119344. */
  119345. onBeforeRenderTargetsRenderObservable: Observable<Scene>;
  119346. /**
  119347. * An event triggered when render targets were rendered.
  119348. * Can happen multiple times per frame.
  119349. */
  119350. onAfterRenderTargetsRenderObservable: Observable<Scene>;
  119351. /**
  119352. * An event triggered before calculating deterministic simulation step
  119353. */
  119354. onBeforeStepObservable: Observable<Scene>;
  119355. /**
  119356. * An event triggered after calculating deterministic simulation step
  119357. */
  119358. onAfterStepObservable: Observable<Scene>;
  119359. /**
  119360. * An event triggered when the activeCamera property is updated
  119361. */
  119362. onActiveCameraChanged: Observable<Scene>;
  119363. /**
  119364. * This Observable will be triggered before rendering each renderingGroup of each rendered camera.
  119365. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  119366. * 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)
  119367. */
  119368. onBeforeRenderingGroupObservable: Observable<RenderingGroupInfo>;
  119369. /**
  119370. * This Observable will be triggered after rendering each renderingGroup of each rendered camera.
  119371. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  119372. * 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)
  119373. */
  119374. onAfterRenderingGroupObservable: Observable<RenderingGroupInfo>;
  119375. /**
  119376. * This Observable will when a mesh has been imported into the scene.
  119377. */
  119378. onMeshImportedObservable: Observable<AbstractMesh>;
  119379. /**
  119380. * This Observable will when an animation file has been imported into the scene.
  119381. */
  119382. onAnimationFileImportedObservable: Observable<Scene>;
  119383. /**
  119384. * Gets or sets a user defined funtion to select LOD from a mesh and a camera.
  119385. * By default this function is undefined and Babylon.js will select LOD based on distance to camera
  119386. */
  119387. customLODSelector: (mesh: AbstractMesh, camera: Camera) => Nullable<AbstractMesh>;
  119388. /** @hidden */
  119389. _registeredForLateAnimationBindings: SmartArrayNoDuplicate<any>;
  119390. /**
  119391. * Gets or sets a predicate used to select candidate meshes for a pointer down event
  119392. */
  119393. pointerDownPredicate: (Mesh: AbstractMesh) => boolean;
  119394. /**
  119395. * Gets or sets a predicate used to select candidate meshes for a pointer up event
  119396. */
  119397. pointerUpPredicate: (Mesh: AbstractMesh) => boolean;
  119398. /**
  119399. * Gets or sets a predicate used to select candidate meshes for a pointer move event
  119400. */
  119401. pointerMovePredicate: (Mesh: AbstractMesh) => boolean;
  119402. /** Callback called when a pointer move is detected */
  119403. onPointerMove: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  119404. /** Callback called when a pointer down is detected */
  119405. onPointerDown: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  119406. /** Callback called when a pointer up is detected */
  119407. onPointerUp: (evt: PointerEvent, pickInfo: Nullable<PickingInfo>, type: PointerEventTypes) => void;
  119408. /** Callback called when a pointer pick is detected */
  119409. onPointerPick: (evt: PointerEvent, pickInfo: PickingInfo) => void;
  119410. /**
  119411. * 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).
  119412. * You have the possibility to skip the process and the call to onPointerObservable by setting PointerInfoPre.skipOnPointerObservable to true
  119413. */
  119414. onPrePointerObservable: Observable<PointerInfoPre>;
  119415. /**
  119416. * Observable event triggered each time an input event is received from the rendering canvas
  119417. */
  119418. onPointerObservable: Observable<PointerInfo>;
  119419. /**
  119420. * Gets the pointer coordinates without any translation (ie. straight out of the pointer event)
  119421. */
  119422. get unTranslatedPointer(): Vector2;
  119423. /**
  119424. * Gets or sets the distance in pixel that you have to move to prevent some events. Default is 10 pixels
  119425. */
  119426. static get DragMovementThreshold(): number;
  119427. static set DragMovementThreshold(value: number);
  119428. /**
  119429. * Time in milliseconds to wait to raise long press events if button is still pressed. Default is 500 ms
  119430. */
  119431. static get LongPressDelay(): number;
  119432. static set LongPressDelay(value: number);
  119433. /**
  119434. * Time in milliseconds to wait to raise long press events if button is still pressed. Default is 300 ms
  119435. */
  119436. static get DoubleClickDelay(): number;
  119437. static set DoubleClickDelay(value: number);
  119438. /** If you need to check double click without raising a single click at first click, enable this flag */
  119439. static get ExclusiveDoubleClickMode(): boolean;
  119440. static set ExclusiveDoubleClickMode(value: boolean);
  119441. /** @hidden */
  119442. _mirroredCameraPosition: Nullable<Vector3>;
  119443. /**
  119444. * This observable event is triggered when any keyboard event si raised and registered during Scene.attachControl()
  119445. * You have the possibility to skip the process and the call to onKeyboardObservable by setting KeyboardInfoPre.skipOnPointerObservable to true
  119446. */
  119447. onPreKeyboardObservable: Observable<KeyboardInfoPre>;
  119448. /**
  119449. * Observable event triggered each time an keyboard event is received from the hosting window
  119450. */
  119451. onKeyboardObservable: Observable<KeyboardInfo>;
  119452. private _useRightHandedSystem;
  119453. /**
  119454. * Gets or sets a boolean indicating if the scene must use right-handed coordinates system
  119455. */
  119456. set useRightHandedSystem(value: boolean);
  119457. get useRightHandedSystem(): boolean;
  119458. private _timeAccumulator;
  119459. private _currentStepId;
  119460. private _currentInternalStep;
  119461. /**
  119462. * Sets the step Id used by deterministic lock step
  119463. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  119464. * @param newStepId defines the step Id
  119465. */
  119466. setStepId(newStepId: number): void;
  119467. /**
  119468. * Gets the step Id used by deterministic lock step
  119469. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  119470. * @returns the step Id
  119471. */
  119472. getStepId(): number;
  119473. /**
  119474. * Gets the internal step used by deterministic lock step
  119475. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  119476. * @returns the internal step
  119477. */
  119478. getInternalStep(): number;
  119479. private _fogEnabled;
  119480. /**
  119481. * Gets or sets a boolean indicating if fog is enabled on this scene
  119482. * @see https://doc.babylonjs.com/babylon101/environment#fog
  119483. * (Default is true)
  119484. */
  119485. set fogEnabled(value: boolean);
  119486. get fogEnabled(): boolean;
  119487. private _fogMode;
  119488. /**
  119489. * Gets or sets the fog mode to use
  119490. * @see https://doc.babylonjs.com/babylon101/environment#fog
  119491. * | mode | value |
  119492. * | --- | --- |
  119493. * | FOGMODE_NONE | 0 |
  119494. * | FOGMODE_EXP | 1 |
  119495. * | FOGMODE_EXP2 | 2 |
  119496. * | FOGMODE_LINEAR | 3 |
  119497. */
  119498. set fogMode(value: number);
  119499. get fogMode(): number;
  119500. /**
  119501. * Gets or sets the fog color to use
  119502. * @see https://doc.babylonjs.com/babylon101/environment#fog
  119503. * (Default is Color3(0.2, 0.2, 0.3))
  119504. */
  119505. fogColor: Color3;
  119506. /**
  119507. * Gets or sets the fog density to use
  119508. * @see https://doc.babylonjs.com/babylon101/environment#fog
  119509. * (Default is 0.1)
  119510. */
  119511. fogDensity: number;
  119512. /**
  119513. * Gets or sets the fog start distance to use
  119514. * @see https://doc.babylonjs.com/babylon101/environment#fog
  119515. * (Default is 0)
  119516. */
  119517. fogStart: number;
  119518. /**
  119519. * Gets or sets the fog end distance to use
  119520. * @see https://doc.babylonjs.com/babylon101/environment#fog
  119521. * (Default is 1000)
  119522. */
  119523. fogEnd: number;
  119524. /**
  119525. * Flag indicating that the frame buffer binding is handled by another component
  119526. */
  119527. prePass: boolean;
  119528. private _shadowsEnabled;
  119529. /**
  119530. * Gets or sets a boolean indicating if shadows are enabled on this scene
  119531. */
  119532. set shadowsEnabled(value: boolean);
  119533. get shadowsEnabled(): boolean;
  119534. private _lightsEnabled;
  119535. /**
  119536. * Gets or sets a boolean indicating if lights are enabled on this scene
  119537. */
  119538. set lightsEnabled(value: boolean);
  119539. get lightsEnabled(): boolean;
  119540. /** All of the active cameras added to this scene. */
  119541. activeCameras: Camera[];
  119542. /** @hidden */
  119543. _activeCamera: Nullable<Camera>;
  119544. /** Gets or sets the current active camera */
  119545. get activeCamera(): Nullable<Camera>;
  119546. set activeCamera(value: Nullable<Camera>);
  119547. private _defaultMaterial;
  119548. /** The default material used on meshes when no material is affected */
  119549. get defaultMaterial(): Material;
  119550. /** The default material used on meshes when no material is affected */
  119551. set defaultMaterial(value: Material);
  119552. private _texturesEnabled;
  119553. /**
  119554. * Gets or sets a boolean indicating if textures are enabled on this scene
  119555. */
  119556. set texturesEnabled(value: boolean);
  119557. get texturesEnabled(): boolean;
  119558. /**
  119559. * Gets or sets a boolean indicating if physic engines are enabled on this scene
  119560. */
  119561. physicsEnabled: boolean;
  119562. /**
  119563. * Gets or sets a boolean indicating if particles are enabled on this scene
  119564. */
  119565. particlesEnabled: boolean;
  119566. /**
  119567. * Gets or sets a boolean indicating if sprites are enabled on this scene
  119568. */
  119569. spritesEnabled: boolean;
  119570. private _skeletonsEnabled;
  119571. /**
  119572. * Gets or sets a boolean indicating if skeletons are enabled on this scene
  119573. */
  119574. set skeletonsEnabled(value: boolean);
  119575. get skeletonsEnabled(): boolean;
  119576. /**
  119577. * Gets or sets a boolean indicating if lens flares are enabled on this scene
  119578. */
  119579. lensFlaresEnabled: boolean;
  119580. /**
  119581. * Gets or sets a boolean indicating if collisions are enabled on this scene
  119582. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  119583. */
  119584. collisionsEnabled: boolean;
  119585. private _collisionCoordinator;
  119586. /** @hidden */
  119587. get collisionCoordinator(): ICollisionCoordinator;
  119588. /**
  119589. * Defines the gravity applied to this scene (used only for collisions)
  119590. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  119591. */
  119592. gravity: Vector3;
  119593. /**
  119594. * Gets or sets a boolean indicating if postprocesses are enabled on this scene
  119595. */
  119596. postProcessesEnabled: boolean;
  119597. /**
  119598. * Gets the current postprocess manager
  119599. */
  119600. postProcessManager: PostProcessManager;
  119601. /**
  119602. * Gets or sets a boolean indicating if render targets are enabled on this scene
  119603. */
  119604. renderTargetsEnabled: boolean;
  119605. /**
  119606. * Gets or sets a boolean indicating if next render targets must be dumped as image for debugging purposes
  119607. * We recommend not using it and instead rely on Spector.js: http://spector.babylonjs.com
  119608. */
  119609. dumpNextRenderTargets: boolean;
  119610. /**
  119611. * The list of user defined render targets added to the scene
  119612. */
  119613. customRenderTargets: RenderTargetTexture[];
  119614. /**
  119615. * Defines if texture loading must be delayed
  119616. * If true, textures will only be loaded when they need to be rendered
  119617. */
  119618. useDelayedTextureLoading: boolean;
  119619. /**
  119620. * Gets the list of meshes imported to the scene through SceneLoader
  119621. */
  119622. importedMeshesFiles: String[];
  119623. /**
  119624. * Gets or sets a boolean indicating if probes are enabled on this scene
  119625. */
  119626. probesEnabled: boolean;
  119627. /**
  119628. * Gets or sets the current offline provider to use to store scene data
  119629. * @see https://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  119630. */
  119631. offlineProvider: IOfflineProvider;
  119632. /**
  119633. * Gets or sets the action manager associated with the scene
  119634. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  119635. */
  119636. actionManager: AbstractActionManager;
  119637. private _meshesForIntersections;
  119638. /**
  119639. * Gets or sets a boolean indicating if procedural textures are enabled on this scene
  119640. */
  119641. proceduralTexturesEnabled: boolean;
  119642. private _engine;
  119643. private _totalVertices;
  119644. /** @hidden */
  119645. _activeIndices: PerfCounter;
  119646. /** @hidden */
  119647. _activeParticles: PerfCounter;
  119648. /** @hidden */
  119649. _activeBones: PerfCounter;
  119650. private _animationRatio;
  119651. /** @hidden */
  119652. _animationTimeLast: number;
  119653. /** @hidden */
  119654. _animationTime: number;
  119655. /**
  119656. * Gets or sets a general scale for animation speed
  119657. * @see https://www.babylonjs-playground.com/#IBU2W7#3
  119658. */
  119659. animationTimeScale: number;
  119660. /** @hidden */
  119661. _cachedMaterial: Nullable<Material>;
  119662. /** @hidden */
  119663. _cachedEffect: Nullable<Effect>;
  119664. /** @hidden */
  119665. _cachedVisibility: Nullable<number>;
  119666. private _renderId;
  119667. private _frameId;
  119668. private _executeWhenReadyTimeoutId;
  119669. private _intermediateRendering;
  119670. private _viewUpdateFlag;
  119671. private _projectionUpdateFlag;
  119672. /** @hidden */
  119673. _toBeDisposed: Nullable<IDisposable>[];
  119674. private _activeRequests;
  119675. /** @hidden */
  119676. _pendingData: any[];
  119677. private _isDisposed;
  119678. /**
  119679. * Gets or sets a boolean indicating that all submeshes of active meshes must be rendered
  119680. * Use this boolean to avoid computing frustum clipping on submeshes (This could help when you are CPU bound)
  119681. */
  119682. dispatchAllSubMeshesOfActiveMeshes: boolean;
  119683. private _activeMeshes;
  119684. private _processedMaterials;
  119685. private _renderTargets;
  119686. /** @hidden */
  119687. _activeParticleSystems: SmartArray<IParticleSystem>;
  119688. private _activeSkeletons;
  119689. private _softwareSkinnedMeshes;
  119690. private _renderingManager;
  119691. /** @hidden */
  119692. _activeAnimatables: Animatable[];
  119693. private _transformMatrix;
  119694. private _sceneUbo;
  119695. /** @hidden */
  119696. _viewMatrix: Matrix;
  119697. private _projectionMatrix;
  119698. /** @hidden */
  119699. _forcedViewPosition: Nullable<Vector3>;
  119700. /** @hidden */
  119701. _frustumPlanes: Plane[];
  119702. /**
  119703. * Gets the list of frustum planes (built from the active camera)
  119704. */
  119705. get frustumPlanes(): Plane[];
  119706. /**
  119707. * Gets or sets a boolean indicating if lights must be sorted by priority (off by default)
  119708. * This is useful if there are more lights that the maximum simulteanous authorized
  119709. */
  119710. requireLightSorting: boolean;
  119711. /** @hidden */
  119712. readonly useMaterialMeshMap: boolean;
  119713. /** @hidden */
  119714. readonly useClonedMeshMap: boolean;
  119715. private _externalData;
  119716. private _uid;
  119717. /**
  119718. * @hidden
  119719. * Backing store of defined scene components.
  119720. */
  119721. _components: ISceneComponent[];
  119722. /**
  119723. * @hidden
  119724. * Backing store of defined scene components.
  119725. */
  119726. _serializableComponents: ISceneSerializableComponent[];
  119727. /**
  119728. * List of components to register on the next registration step.
  119729. */
  119730. private _transientComponents;
  119731. /**
  119732. * Registers the transient components if needed.
  119733. */
  119734. private _registerTransientComponents;
  119735. /**
  119736. * @hidden
  119737. * Add a component to the scene.
  119738. * Note that the ccomponent could be registered on th next frame if this is called after
  119739. * the register component stage.
  119740. * @param component Defines the component to add to the scene
  119741. */
  119742. _addComponent(component: ISceneComponent): void;
  119743. /**
  119744. * @hidden
  119745. * Gets a component from the scene.
  119746. * @param name defines the name of the component to retrieve
  119747. * @returns the component or null if not present
  119748. */
  119749. _getComponent(name: string): Nullable<ISceneComponent>;
  119750. /**
  119751. * @hidden
  119752. * Defines the actions happening before camera updates.
  119753. */
  119754. _beforeCameraUpdateStage: Stage<SimpleStageAction>;
  119755. /**
  119756. * @hidden
  119757. * Defines the actions happening before clear the canvas.
  119758. */
  119759. _beforeClearStage: Stage<SimpleStageAction>;
  119760. /**
  119761. * @hidden
  119762. * Defines the actions when collecting render targets for the frame.
  119763. */
  119764. _gatherRenderTargetsStage: Stage<RenderTargetsStageAction>;
  119765. /**
  119766. * @hidden
  119767. * Defines the actions happening for one camera in the frame.
  119768. */
  119769. _gatherActiveCameraRenderTargetsStage: Stage<RenderTargetsStageAction>;
  119770. /**
  119771. * @hidden
  119772. * Defines the actions happening during the per mesh ready checks.
  119773. */
  119774. _isReadyForMeshStage: Stage<MeshStageAction>;
  119775. /**
  119776. * @hidden
  119777. * Defines the actions happening before evaluate active mesh checks.
  119778. */
  119779. _beforeEvaluateActiveMeshStage: Stage<SimpleStageAction>;
  119780. /**
  119781. * @hidden
  119782. * Defines the actions happening during the evaluate sub mesh checks.
  119783. */
  119784. _evaluateSubMeshStage: Stage<EvaluateSubMeshStageAction>;
  119785. /**
  119786. * @hidden
  119787. * Defines the actions happening during the active mesh stage.
  119788. */
  119789. _activeMeshStage: Stage<ActiveMeshStageAction>;
  119790. /**
  119791. * @hidden
  119792. * Defines the actions happening during the per camera render target step.
  119793. */
  119794. _cameraDrawRenderTargetStage: Stage<CameraStageFrameBufferAction>;
  119795. /**
  119796. * @hidden
  119797. * Defines the actions happening just before the active camera is drawing.
  119798. */
  119799. _beforeCameraDrawStage: Stage<CameraStageAction>;
  119800. /**
  119801. * @hidden
  119802. * Defines the actions happening just before a render target is drawing.
  119803. */
  119804. _beforeRenderTargetDrawStage: Stage<RenderTargetStageAction>;
  119805. /**
  119806. * @hidden
  119807. * Defines the actions happening just before a rendering group is drawing.
  119808. */
  119809. _beforeRenderingGroupDrawStage: Stage<RenderingGroupStageAction>;
  119810. /**
  119811. * @hidden
  119812. * Defines the actions happening just before a mesh is drawing.
  119813. */
  119814. _beforeRenderingMeshStage: Stage<RenderingMeshStageAction>;
  119815. /**
  119816. * @hidden
  119817. * Defines the actions happening just after a mesh has been drawn.
  119818. */
  119819. _afterRenderingMeshStage: Stage<RenderingMeshStageAction>;
  119820. /**
  119821. * @hidden
  119822. * Defines the actions happening just after a rendering group has been drawn.
  119823. */
  119824. _afterRenderingGroupDrawStage: Stage<RenderingGroupStageAction>;
  119825. /**
  119826. * @hidden
  119827. * Defines the actions happening just after the active camera has been drawn.
  119828. */
  119829. _afterCameraDrawStage: Stage<CameraStageAction>;
  119830. /**
  119831. * @hidden
  119832. * Defines the actions happening just after a render target has been drawn.
  119833. */
  119834. _afterRenderTargetDrawStage: Stage<RenderTargetStageAction>;
  119835. /**
  119836. * @hidden
  119837. * Defines the actions happening just after rendering all cameras and computing intersections.
  119838. */
  119839. _afterRenderStage: Stage<SimpleStageAction>;
  119840. /**
  119841. * @hidden
  119842. * Defines the actions happening when a pointer move event happens.
  119843. */
  119844. _pointerMoveStage: Stage<PointerMoveStageAction>;
  119845. /**
  119846. * @hidden
  119847. * Defines the actions happening when a pointer down event happens.
  119848. */
  119849. _pointerDownStage: Stage<PointerUpDownStageAction>;
  119850. /**
  119851. * @hidden
  119852. * Defines the actions happening when a pointer up event happens.
  119853. */
  119854. _pointerUpStage: Stage<PointerUpDownStageAction>;
  119855. /**
  119856. * an optional map from Geometry Id to Geometry index in the 'geometries' array
  119857. */
  119858. private geometriesByUniqueId;
  119859. /**
  119860. * Creates a new Scene
  119861. * @param engine defines the engine to use to render this scene
  119862. * @param options defines the scene options
  119863. */
  119864. constructor(engine: Engine, options?: SceneOptions);
  119865. /**
  119866. * Gets a string identifying the name of the class
  119867. * @returns "Scene" string
  119868. */
  119869. getClassName(): string;
  119870. private _defaultMeshCandidates;
  119871. /**
  119872. * @hidden
  119873. */
  119874. _getDefaultMeshCandidates(): ISmartArrayLike<AbstractMesh>;
  119875. private _defaultSubMeshCandidates;
  119876. /**
  119877. * @hidden
  119878. */
  119879. _getDefaultSubMeshCandidates(mesh: AbstractMesh): ISmartArrayLike<SubMesh>;
  119880. /**
  119881. * Sets the default candidate providers for the scene.
  119882. * This sets the getActiveMeshCandidates, getActiveSubMeshCandidates, getIntersectingSubMeshCandidates
  119883. * and getCollidingSubMeshCandidates to their default function
  119884. */
  119885. setDefaultCandidateProviders(): void;
  119886. /**
  119887. * Gets the mesh that is currently under the pointer
  119888. */
  119889. get meshUnderPointer(): Nullable<AbstractMesh>;
  119890. /**
  119891. * Gets or sets the current on-screen X position of the pointer
  119892. */
  119893. get pointerX(): number;
  119894. set pointerX(value: number);
  119895. /**
  119896. * Gets or sets the current on-screen Y position of the pointer
  119897. */
  119898. get pointerY(): number;
  119899. set pointerY(value: number);
  119900. /**
  119901. * Gets the cached material (ie. the latest rendered one)
  119902. * @returns the cached material
  119903. */
  119904. getCachedMaterial(): Nullable<Material>;
  119905. /**
  119906. * Gets the cached effect (ie. the latest rendered one)
  119907. * @returns the cached effect
  119908. */
  119909. getCachedEffect(): Nullable<Effect>;
  119910. /**
  119911. * Gets the cached visibility state (ie. the latest rendered one)
  119912. * @returns the cached visibility state
  119913. */
  119914. getCachedVisibility(): Nullable<number>;
  119915. /**
  119916. * Gets a boolean indicating if the current material / effect / visibility must be bind again
  119917. * @param material defines the current material
  119918. * @param effect defines the current effect
  119919. * @param visibility defines the current visibility state
  119920. * @returns true if one parameter is not cached
  119921. */
  119922. isCachedMaterialInvalid(material: Material, effect: Effect, visibility?: number): boolean;
  119923. /**
  119924. * Gets the engine associated with the scene
  119925. * @returns an Engine
  119926. */
  119927. getEngine(): Engine;
  119928. /**
  119929. * Gets the total number of vertices rendered per frame
  119930. * @returns the total number of vertices rendered per frame
  119931. */
  119932. getTotalVertices(): number;
  119933. /**
  119934. * Gets the performance counter for total vertices
  119935. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  119936. */
  119937. get totalVerticesPerfCounter(): PerfCounter;
  119938. /**
  119939. * Gets the total number of active indices rendered per frame (You can deduce the number of rendered triangles by dividing this number by 3)
  119940. * @returns the total number of active indices rendered per frame
  119941. */
  119942. getActiveIndices(): number;
  119943. /**
  119944. * Gets the performance counter for active indices
  119945. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  119946. */
  119947. get totalActiveIndicesPerfCounter(): PerfCounter;
  119948. /**
  119949. * Gets the total number of active particles rendered per frame
  119950. * @returns the total number of active particles rendered per frame
  119951. */
  119952. getActiveParticles(): number;
  119953. /**
  119954. * Gets the performance counter for active particles
  119955. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  119956. */
  119957. get activeParticlesPerfCounter(): PerfCounter;
  119958. /**
  119959. * Gets the total number of active bones rendered per frame
  119960. * @returns the total number of active bones rendered per frame
  119961. */
  119962. getActiveBones(): number;
  119963. /**
  119964. * Gets the performance counter for active bones
  119965. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  119966. */
  119967. get activeBonesPerfCounter(): PerfCounter;
  119968. /**
  119969. * Gets the array of active meshes
  119970. * @returns an array of AbstractMesh
  119971. */
  119972. getActiveMeshes(): SmartArray<AbstractMesh>;
  119973. /**
  119974. * Gets the animation ratio (which is 1.0 is the scene renders at 60fps and 2 if the scene renders at 30fps, etc.)
  119975. * @returns a number
  119976. */
  119977. getAnimationRatio(): number;
  119978. /**
  119979. * Gets an unique Id for the current render phase
  119980. * @returns a number
  119981. */
  119982. getRenderId(): number;
  119983. /**
  119984. * Gets an unique Id for the current frame
  119985. * @returns a number
  119986. */
  119987. getFrameId(): number;
  119988. /** Call this function if you want to manually increment the render Id*/
  119989. incrementRenderId(): void;
  119990. private _createUbo;
  119991. /**
  119992. * Use this method to simulate a pointer move on a mesh
  119993. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  119994. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  119995. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  119996. * @returns the current scene
  119997. */
  119998. simulatePointerMove(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  119999. /**
  120000. * Use this method to simulate a pointer down on a mesh
  120001. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  120002. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  120003. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  120004. * @returns the current scene
  120005. */
  120006. simulatePointerDown(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  120007. /**
  120008. * Use this method to simulate a pointer up on a mesh
  120009. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  120010. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  120011. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  120012. * @param doubleTap indicates that the pointer up event should be considered as part of a double click (false by default)
  120013. * @returns the current scene
  120014. */
  120015. simulatePointerUp(pickResult: PickingInfo, pointerEventInit?: PointerEventInit, doubleTap?: boolean): Scene;
  120016. /**
  120017. * Gets a boolean indicating if the current pointer event is captured (meaning that the scene has already handled the pointer down)
  120018. * @param pointerId defines the pointer id to use in a multi-touch scenario (0 by default)
  120019. * @returns true if the pointer was captured
  120020. */
  120021. isPointerCaptured(pointerId?: number): boolean;
  120022. /**
  120023. * Attach events to the canvas (To handle actionManagers triggers and raise onPointerMove, onPointerDown and onPointerUp
  120024. * @param attachUp defines if you want to attach events to pointerup
  120025. * @param attachDown defines if you want to attach events to pointerdown
  120026. * @param attachMove defines if you want to attach events to pointermove
  120027. */
  120028. attachControl(attachUp?: boolean, attachDown?: boolean, attachMove?: boolean): void;
  120029. /** Detaches all event handlers*/
  120030. detachControl(): void;
  120031. /**
  120032. * This function will check if the scene can be rendered (textures are loaded, shaders are compiled)
  120033. * Delay loaded resources are not taking in account
  120034. * @return true if all required resources are ready
  120035. */
  120036. isReady(): boolean;
  120037. /** Resets all cached information relative to material (including effect and visibility) */
  120038. resetCachedMaterial(): void;
  120039. /**
  120040. * Registers a function to be called before every frame render
  120041. * @param func defines the function to register
  120042. */
  120043. registerBeforeRender(func: () => void): void;
  120044. /**
  120045. * Unregisters a function called before every frame render
  120046. * @param func defines the function to unregister
  120047. */
  120048. unregisterBeforeRender(func: () => void): void;
  120049. /**
  120050. * Registers a function to be called after every frame render
  120051. * @param func defines the function to register
  120052. */
  120053. registerAfterRender(func: () => void): void;
  120054. /**
  120055. * Unregisters a function called after every frame render
  120056. * @param func defines the function to unregister
  120057. */
  120058. unregisterAfterRender(func: () => void): void;
  120059. private _executeOnceBeforeRender;
  120060. /**
  120061. * The provided function will run before render once and will be disposed afterwards.
  120062. * A timeout delay can be provided so that the function will be executed in N ms.
  120063. * The timeout is using the browser's native setTimeout so time percision cannot be guaranteed.
  120064. * @param func The function to be executed.
  120065. * @param timeout optional delay in ms
  120066. */
  120067. executeOnceBeforeRender(func: () => void, timeout?: number): void;
  120068. /** @hidden */
  120069. _addPendingData(data: any): void;
  120070. /** @hidden */
  120071. _removePendingData(data: any): void;
  120072. /**
  120073. * Returns the number of items waiting to be loaded
  120074. * @returns the number of items waiting to be loaded
  120075. */
  120076. getWaitingItemsCount(): number;
  120077. /**
  120078. * Returns a boolean indicating if the scene is still loading data
  120079. */
  120080. get isLoading(): boolean;
  120081. /**
  120082. * Registers a function to be executed when the scene is ready
  120083. * @param {Function} func - the function to be executed
  120084. */
  120085. executeWhenReady(func: () => void): void;
  120086. /**
  120087. * Returns a promise that resolves when the scene is ready
  120088. * @returns A promise that resolves when the scene is ready
  120089. */
  120090. whenReadyAsync(): Promise<void>;
  120091. /** @hidden */
  120092. _checkIsReady(): void;
  120093. /**
  120094. * Gets all animatable attached to the scene
  120095. */
  120096. get animatables(): Animatable[];
  120097. /**
  120098. * Resets the last animation time frame.
  120099. * Useful to override when animations start running when loading a scene for the first time.
  120100. */
  120101. resetLastAnimationTimeFrame(): void;
  120102. /**
  120103. * Gets the current view matrix
  120104. * @returns a Matrix
  120105. */
  120106. getViewMatrix(): Matrix;
  120107. /**
  120108. * Gets the current projection matrix
  120109. * @returns a Matrix
  120110. */
  120111. getProjectionMatrix(): Matrix;
  120112. /**
  120113. * Gets the current transform matrix
  120114. * @returns a Matrix made of View * Projection
  120115. */
  120116. getTransformMatrix(): Matrix;
  120117. /**
  120118. * Sets the current transform matrix
  120119. * @param viewL defines the View matrix to use
  120120. * @param projectionL defines the Projection matrix to use
  120121. * @param viewR defines the right View matrix to use (if provided)
  120122. * @param projectionR defines the right Projection matrix to use (if provided)
  120123. */
  120124. setTransformMatrix(viewL: Matrix, projectionL: Matrix, viewR?: Matrix, projectionR?: Matrix): void;
  120125. /**
  120126. * Gets the uniform buffer used to store scene data
  120127. * @returns a UniformBuffer
  120128. */
  120129. getSceneUniformBuffer(): UniformBuffer;
  120130. /**
  120131. * Gets an unique (relatively to the current scene) Id
  120132. * @returns an unique number for the scene
  120133. */
  120134. getUniqueId(): number;
  120135. /**
  120136. * Add a mesh to the list of scene's meshes
  120137. * @param newMesh defines the mesh to add
  120138. * @param recursive if all child meshes should also be added to the scene
  120139. */
  120140. addMesh(newMesh: AbstractMesh, recursive?: boolean): void;
  120141. /**
  120142. * Remove a mesh for the list of scene's meshes
  120143. * @param toRemove defines the mesh to remove
  120144. * @param recursive if all child meshes should also be removed from the scene
  120145. * @returns the index where the mesh was in the mesh list
  120146. */
  120147. removeMesh(toRemove: AbstractMesh, recursive?: boolean): number;
  120148. /**
  120149. * Add a transform node to the list of scene's transform nodes
  120150. * @param newTransformNode defines the transform node to add
  120151. */
  120152. addTransformNode(newTransformNode: TransformNode): void;
  120153. /**
  120154. * Remove a transform node for the list of scene's transform nodes
  120155. * @param toRemove defines the transform node to remove
  120156. * @returns the index where the transform node was in the transform node list
  120157. */
  120158. removeTransformNode(toRemove: TransformNode): number;
  120159. /**
  120160. * Remove a skeleton for the list of scene's skeletons
  120161. * @param toRemove defines the skeleton to remove
  120162. * @returns the index where the skeleton was in the skeleton list
  120163. */
  120164. removeSkeleton(toRemove: Skeleton): number;
  120165. /**
  120166. * Remove a morph target for the list of scene's morph targets
  120167. * @param toRemove defines the morph target to remove
  120168. * @returns the index where the morph target was in the morph target list
  120169. */
  120170. removeMorphTargetManager(toRemove: MorphTargetManager): number;
  120171. /**
  120172. * Remove a light for the list of scene's lights
  120173. * @param toRemove defines the light to remove
  120174. * @returns the index where the light was in the light list
  120175. */
  120176. removeLight(toRemove: Light): number;
  120177. /**
  120178. * Remove a camera for the list of scene's cameras
  120179. * @param toRemove defines the camera to remove
  120180. * @returns the index where the camera was in the camera list
  120181. */
  120182. removeCamera(toRemove: Camera): number;
  120183. /**
  120184. * Remove a particle system for the list of scene's particle systems
  120185. * @param toRemove defines the particle system to remove
  120186. * @returns the index where the particle system was in the particle system list
  120187. */
  120188. removeParticleSystem(toRemove: IParticleSystem): number;
  120189. /**
  120190. * Remove a animation for the list of scene's animations
  120191. * @param toRemove defines the animation to remove
  120192. * @returns the index where the animation was in the animation list
  120193. */
  120194. removeAnimation(toRemove: Animation): number;
  120195. /**
  120196. * Will stop the animation of the given target
  120197. * @param target - the target
  120198. * @param animationName - the name of the animation to stop (all animations will be stopped if both this and targetMask are empty)
  120199. * @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)
  120200. */
  120201. stopAnimation(target: any, animationName?: string, targetMask?: (target: any) => boolean): void;
  120202. /**
  120203. * Removes the given animation group from this scene.
  120204. * @param toRemove The animation group to remove
  120205. * @returns The index of the removed animation group
  120206. */
  120207. removeAnimationGroup(toRemove: AnimationGroup): number;
  120208. /**
  120209. * Removes the given multi-material from this scene.
  120210. * @param toRemove The multi-material to remove
  120211. * @returns The index of the removed multi-material
  120212. */
  120213. removeMultiMaterial(toRemove: MultiMaterial): number;
  120214. /**
  120215. * Removes the given material from this scene.
  120216. * @param toRemove The material to remove
  120217. * @returns The index of the removed material
  120218. */
  120219. removeMaterial(toRemove: Material): number;
  120220. /**
  120221. * Removes the given action manager from this scene.
  120222. * @param toRemove The action manager to remove
  120223. * @returns The index of the removed action manager
  120224. */
  120225. removeActionManager(toRemove: AbstractActionManager): number;
  120226. /**
  120227. * Removes the given texture from this scene.
  120228. * @param toRemove The texture to remove
  120229. * @returns The index of the removed texture
  120230. */
  120231. removeTexture(toRemove: BaseTexture): number;
  120232. /**
  120233. * Adds the given light to this scene
  120234. * @param newLight The light to add
  120235. */
  120236. addLight(newLight: Light): void;
  120237. /**
  120238. * Sorts the list list based on light priorities
  120239. */
  120240. sortLightsByPriority(): void;
  120241. /**
  120242. * Adds the given camera to this scene
  120243. * @param newCamera The camera to add
  120244. */
  120245. addCamera(newCamera: Camera): void;
  120246. /**
  120247. * Adds the given skeleton to this scene
  120248. * @param newSkeleton The skeleton to add
  120249. */
  120250. addSkeleton(newSkeleton: Skeleton): void;
  120251. /**
  120252. * Adds the given particle system to this scene
  120253. * @param newParticleSystem The particle system to add
  120254. */
  120255. addParticleSystem(newParticleSystem: IParticleSystem): void;
  120256. /**
  120257. * Adds the given animation to this scene
  120258. * @param newAnimation The animation to add
  120259. */
  120260. addAnimation(newAnimation: Animation): void;
  120261. /**
  120262. * Adds the given animation group to this scene.
  120263. * @param newAnimationGroup The animation group to add
  120264. */
  120265. addAnimationGroup(newAnimationGroup: AnimationGroup): void;
  120266. /**
  120267. * Adds the given multi-material to this scene
  120268. * @param newMultiMaterial The multi-material to add
  120269. */
  120270. addMultiMaterial(newMultiMaterial: MultiMaterial): void;
  120271. /**
  120272. * Adds the given material to this scene
  120273. * @param newMaterial The material to add
  120274. */
  120275. addMaterial(newMaterial: Material): void;
  120276. /**
  120277. * Adds the given morph target to this scene
  120278. * @param newMorphTargetManager The morph target to add
  120279. */
  120280. addMorphTargetManager(newMorphTargetManager: MorphTargetManager): void;
  120281. /**
  120282. * Adds the given geometry to this scene
  120283. * @param newGeometry The geometry to add
  120284. */
  120285. addGeometry(newGeometry: Geometry): void;
  120286. /**
  120287. * Adds the given action manager to this scene
  120288. * @param newActionManager The action manager to add
  120289. */
  120290. addActionManager(newActionManager: AbstractActionManager): void;
  120291. /**
  120292. * Adds the given texture to this scene.
  120293. * @param newTexture The texture to add
  120294. */
  120295. addTexture(newTexture: BaseTexture): void;
  120296. /**
  120297. * Switch active camera
  120298. * @param newCamera defines the new active camera
  120299. * @param attachControl defines if attachControl must be called for the new active camera (default: true)
  120300. */
  120301. switchActiveCamera(newCamera: Camera, attachControl?: boolean): void;
  120302. /**
  120303. * sets the active camera of the scene using its ID
  120304. * @param id defines the camera's ID
  120305. * @return the new active camera or null if none found.
  120306. */
  120307. setActiveCameraByID(id: string): Nullable<Camera>;
  120308. /**
  120309. * sets the active camera of the scene using its name
  120310. * @param name defines the camera's name
  120311. * @returns the new active camera or null if none found.
  120312. */
  120313. setActiveCameraByName(name: string): Nullable<Camera>;
  120314. /**
  120315. * get an animation group using its name
  120316. * @param name defines the material's name
  120317. * @return the animation group or null if none found.
  120318. */
  120319. getAnimationGroupByName(name: string): Nullable<AnimationGroup>;
  120320. /**
  120321. * Get a material using its unique id
  120322. * @param uniqueId defines the material's unique id
  120323. * @return the material or null if none found.
  120324. */
  120325. getMaterialByUniqueID(uniqueId: number): Nullable<Material>;
  120326. /**
  120327. * get a material using its id
  120328. * @param id defines the material's ID
  120329. * @return the material or null if none found.
  120330. */
  120331. getMaterialByID(id: string): Nullable<Material>;
  120332. /**
  120333. * Gets a the last added material using a given id
  120334. * @param id defines the material's ID
  120335. * @return the last material with the given id or null if none found.
  120336. */
  120337. getLastMaterialByID(id: string): Nullable<Material>;
  120338. /**
  120339. * Gets a material using its name
  120340. * @param name defines the material's name
  120341. * @return the material or null if none found.
  120342. */
  120343. getMaterialByName(name: string): Nullable<Material>;
  120344. /**
  120345. * Get a texture using its unique id
  120346. * @param uniqueId defines the texture's unique id
  120347. * @return the texture or null if none found.
  120348. */
  120349. getTextureByUniqueID(uniqueId: number): Nullable<BaseTexture>;
  120350. /**
  120351. * Gets a camera using its id
  120352. * @param id defines the id to look for
  120353. * @returns the camera or null if not found
  120354. */
  120355. getCameraByID(id: string): Nullable<Camera>;
  120356. /**
  120357. * Gets a camera using its unique id
  120358. * @param uniqueId defines the unique id to look for
  120359. * @returns the camera or null if not found
  120360. */
  120361. getCameraByUniqueID(uniqueId: number): Nullable<Camera>;
  120362. /**
  120363. * Gets a camera using its name
  120364. * @param name defines the camera's name
  120365. * @return the camera or null if none found.
  120366. */
  120367. getCameraByName(name: string): Nullable<Camera>;
  120368. /**
  120369. * Gets a bone using its id
  120370. * @param id defines the bone's id
  120371. * @return the bone or null if not found
  120372. */
  120373. getBoneByID(id: string): Nullable<Bone>;
  120374. /**
  120375. * Gets a bone using its id
  120376. * @param name defines the bone's name
  120377. * @return the bone or null if not found
  120378. */
  120379. getBoneByName(name: string): Nullable<Bone>;
  120380. /**
  120381. * Gets a light node using its name
  120382. * @param name defines the the light's name
  120383. * @return the light or null if none found.
  120384. */
  120385. getLightByName(name: string): Nullable<Light>;
  120386. /**
  120387. * Gets a light node using its id
  120388. * @param id defines the light's id
  120389. * @return the light or null if none found.
  120390. */
  120391. getLightByID(id: string): Nullable<Light>;
  120392. /**
  120393. * Gets a light node using its scene-generated unique ID
  120394. * @param uniqueId defines the light's unique id
  120395. * @return the light or null if none found.
  120396. */
  120397. getLightByUniqueID(uniqueId: number): Nullable<Light>;
  120398. /**
  120399. * Gets a particle system by id
  120400. * @param id defines the particle system id
  120401. * @return the corresponding system or null if none found
  120402. */
  120403. getParticleSystemByID(id: string): Nullable<IParticleSystem>;
  120404. /**
  120405. * Gets a geometry using its ID
  120406. * @param id defines the geometry's id
  120407. * @return the geometry or null if none found.
  120408. */
  120409. getGeometryByID(id: string): Nullable<Geometry>;
  120410. private _getGeometryByUniqueID;
  120411. /**
  120412. * Add a new geometry to this scene
  120413. * @param geometry defines the geometry to be added to the scene.
  120414. * @param force defines if the geometry must be pushed even if a geometry with this id already exists
  120415. * @return a boolean defining if the geometry was added or not
  120416. */
  120417. pushGeometry(geometry: Geometry, force?: boolean): boolean;
  120418. /**
  120419. * Removes an existing geometry
  120420. * @param geometry defines the geometry to be removed from the scene
  120421. * @return a boolean defining if the geometry was removed or not
  120422. */
  120423. removeGeometry(geometry: Geometry): boolean;
  120424. /**
  120425. * Gets the list of geometries attached to the scene
  120426. * @returns an array of Geometry
  120427. */
  120428. getGeometries(): Geometry[];
  120429. /**
  120430. * Gets the first added mesh found of a given ID
  120431. * @param id defines the id to search for
  120432. * @return the mesh found or null if not found at all
  120433. */
  120434. getMeshByID(id: string): Nullable<AbstractMesh>;
  120435. /**
  120436. * Gets a list of meshes using their id
  120437. * @param id defines the id to search for
  120438. * @returns a list of meshes
  120439. */
  120440. getMeshesByID(id: string): Array<AbstractMesh>;
  120441. /**
  120442. * Gets the first added transform node found of a given ID
  120443. * @param id defines the id to search for
  120444. * @return the found transform node or null if not found at all.
  120445. */
  120446. getTransformNodeByID(id: string): Nullable<TransformNode>;
  120447. /**
  120448. * Gets a transform node with its auto-generated unique id
  120449. * @param uniqueId efines the unique id to search for
  120450. * @return the found transform node or null if not found at all.
  120451. */
  120452. getTransformNodeByUniqueID(uniqueId: number): Nullable<TransformNode>;
  120453. /**
  120454. * Gets a list of transform nodes using their id
  120455. * @param id defines the id to search for
  120456. * @returns a list of transform nodes
  120457. */
  120458. getTransformNodesByID(id: string): Array<TransformNode>;
  120459. /**
  120460. * Gets a mesh with its auto-generated unique id
  120461. * @param uniqueId defines the unique id to search for
  120462. * @return the found mesh or null if not found at all.
  120463. */
  120464. getMeshByUniqueID(uniqueId: number): Nullable<AbstractMesh>;
  120465. /**
  120466. * Gets a the last added mesh using a given id
  120467. * @param id defines the id to search for
  120468. * @return the found mesh or null if not found at all.
  120469. */
  120470. getLastMeshByID(id: string): Nullable<AbstractMesh>;
  120471. /**
  120472. * Gets a the last added node (Mesh, Camera, Light) using a given id
  120473. * @param id defines the id to search for
  120474. * @return the found node or null if not found at all
  120475. */
  120476. getLastEntryByID(id: string): Nullable<Node>;
  120477. /**
  120478. * Gets a node (Mesh, Camera, Light) using a given id
  120479. * @param id defines the id to search for
  120480. * @return the found node or null if not found at all
  120481. */
  120482. getNodeByID(id: string): Nullable<Node>;
  120483. /**
  120484. * Gets a node (Mesh, Camera, Light) using a given name
  120485. * @param name defines the name to search for
  120486. * @return the found node or null if not found at all.
  120487. */
  120488. getNodeByName(name: string): Nullable<Node>;
  120489. /**
  120490. * Gets a mesh using a given name
  120491. * @param name defines the name to search for
  120492. * @return the found mesh or null if not found at all.
  120493. */
  120494. getMeshByName(name: string): Nullable<AbstractMesh>;
  120495. /**
  120496. * Gets a transform node using a given name
  120497. * @param name defines the name to search for
  120498. * @return the found transform node or null if not found at all.
  120499. */
  120500. getTransformNodeByName(name: string): Nullable<TransformNode>;
  120501. /**
  120502. * Gets a skeleton using a given id (if many are found, this function will pick the last one)
  120503. * @param id defines the id to search for
  120504. * @return the found skeleton or null if not found at all.
  120505. */
  120506. getLastSkeletonByID(id: string): Nullable<Skeleton>;
  120507. /**
  120508. * Gets a skeleton using a given auto generated unique id
  120509. * @param uniqueId defines the unique id to search for
  120510. * @return the found skeleton or null if not found at all.
  120511. */
  120512. getSkeletonByUniqueId(uniqueId: number): Nullable<Skeleton>;
  120513. /**
  120514. * Gets a skeleton using a given id (if many are found, this function will pick the first one)
  120515. * @param id defines the id to search for
  120516. * @return the found skeleton or null if not found at all.
  120517. */
  120518. getSkeletonById(id: string): Nullable<Skeleton>;
  120519. /**
  120520. * Gets a skeleton using a given name
  120521. * @param name defines the name to search for
  120522. * @return the found skeleton or null if not found at all.
  120523. */
  120524. getSkeletonByName(name: string): Nullable<Skeleton>;
  120525. /**
  120526. * Gets a morph target manager using a given id (if many are found, this function will pick the last one)
  120527. * @param id defines the id to search for
  120528. * @return the found morph target manager or null if not found at all.
  120529. */
  120530. getMorphTargetManagerById(id: number): Nullable<MorphTargetManager>;
  120531. /**
  120532. * Gets a morph target using a given id (if many are found, this function will pick the first one)
  120533. * @param id defines the id to search for
  120534. * @return the found morph target or null if not found at all.
  120535. */
  120536. getMorphTargetById(id: string): Nullable<MorphTarget>;
  120537. /**
  120538. * Gets a morph target using a given name (if many are found, this function will pick the first one)
  120539. * @param name defines the name to search for
  120540. * @return the found morph target or null if not found at all.
  120541. */
  120542. getMorphTargetByName(name: string): Nullable<MorphTarget>;
  120543. /**
  120544. * Gets a post process using a given name (if many are found, this function will pick the first one)
  120545. * @param name defines the name to search for
  120546. * @return the found post process or null if not found at all.
  120547. */
  120548. getPostProcessByName(name: string): Nullable<PostProcess>;
  120549. /**
  120550. * Gets a boolean indicating if the given mesh is active
  120551. * @param mesh defines the mesh to look for
  120552. * @returns true if the mesh is in the active list
  120553. */
  120554. isActiveMesh(mesh: AbstractMesh): boolean;
  120555. /**
  120556. * Return a unique id as a string which can serve as an identifier for the scene
  120557. */
  120558. get uid(): string;
  120559. /**
  120560. * Add an externaly attached data from its key.
  120561. * This method call will fail and return false, if such key already exists.
  120562. * If you don't care and just want to get the data no matter what, use the more convenient getOrAddExternalDataWithFactory() method.
  120563. * @param key the unique key that identifies the data
  120564. * @param data the data object to associate to the key for this Engine instance
  120565. * @return true if no such key were already present and the data was added successfully, false otherwise
  120566. */
  120567. addExternalData<T>(key: string, data: T): boolean;
  120568. /**
  120569. * Get an externaly attached data from its key
  120570. * @param key the unique key that identifies the data
  120571. * @return the associated data, if present (can be null), or undefined if not present
  120572. */
  120573. getExternalData<T>(key: string): Nullable<T>;
  120574. /**
  120575. * Get an externaly attached data from its key, create it using a factory if it's not already present
  120576. * @param key the unique key that identifies the data
  120577. * @param factory the factory that will be called to create the instance if and only if it doesn't exists
  120578. * @return the associated data, can be null if the factory returned null.
  120579. */
  120580. getOrAddExternalDataWithFactory<T>(key: string, factory: (k: string) => T): T;
  120581. /**
  120582. * Remove an externaly attached data from the Engine instance
  120583. * @param key the unique key that identifies the data
  120584. * @return true if the data was successfully removed, false if it doesn't exist
  120585. */
  120586. removeExternalData(key: string): boolean;
  120587. private _evaluateSubMesh;
  120588. /**
  120589. * Clear the processed materials smart array preventing retention point in material dispose.
  120590. */
  120591. freeProcessedMaterials(): void;
  120592. private _preventFreeActiveMeshesAndRenderingGroups;
  120593. /** Gets or sets a boolean blocking all the calls to freeActiveMeshes and freeRenderingGroups
  120594. * It can be used in order to prevent going through methods freeRenderingGroups and freeActiveMeshes several times to improve performance
  120595. * when disposing several meshes in a row or a hierarchy of meshes.
  120596. * When used, it is the responsability of the user to blockfreeActiveMeshesAndRenderingGroups back to false.
  120597. */
  120598. get blockfreeActiveMeshesAndRenderingGroups(): boolean;
  120599. set blockfreeActiveMeshesAndRenderingGroups(value: boolean);
  120600. /**
  120601. * Clear the active meshes smart array preventing retention point in mesh dispose.
  120602. */
  120603. freeActiveMeshes(): void;
  120604. /**
  120605. * Clear the info related to rendering groups preventing retention points during dispose.
  120606. */
  120607. freeRenderingGroups(): void;
  120608. /** @hidden */
  120609. _isInIntermediateRendering(): boolean;
  120610. /**
  120611. * Lambda returning the list of potentially active meshes.
  120612. */
  120613. getActiveMeshCandidates: () => ISmartArrayLike<AbstractMesh>;
  120614. /**
  120615. * Lambda returning the list of potentially active sub meshes.
  120616. */
  120617. getActiveSubMeshCandidates: (mesh: AbstractMesh) => ISmartArrayLike<SubMesh>;
  120618. /**
  120619. * Lambda returning the list of potentially intersecting sub meshes.
  120620. */
  120621. getIntersectingSubMeshCandidates: (mesh: AbstractMesh, localRay: Ray) => ISmartArrayLike<SubMesh>;
  120622. /**
  120623. * Lambda returning the list of potentially colliding sub meshes.
  120624. */
  120625. getCollidingSubMeshCandidates: (mesh: AbstractMesh, collider: Collider) => ISmartArrayLike<SubMesh>;
  120626. private _activeMeshesFrozen;
  120627. private _skipEvaluateActiveMeshesCompletely;
  120628. /**
  120629. * Use this function to stop evaluating active meshes. The current list will be keep alive between frames
  120630. * @param skipEvaluateActiveMeshes defines an optional boolean indicating that the evaluate active meshes step must be completely skipped
  120631. * @returns the current scene
  120632. */
  120633. freezeActiveMeshes(skipEvaluateActiveMeshes?: boolean): Scene;
  120634. /**
  120635. * Use this function to restart evaluating active meshes on every frame
  120636. * @returns the current scene
  120637. */
  120638. unfreezeActiveMeshes(): Scene;
  120639. private _evaluateActiveMeshes;
  120640. private _activeMesh;
  120641. /**
  120642. * Update the transform matrix to update from the current active camera
  120643. * @param force defines a boolean used to force the update even if cache is up to date
  120644. */
  120645. updateTransformMatrix(force?: boolean): void;
  120646. private _bindFrameBuffer;
  120647. /** @hidden */
  120648. _allowPostProcessClearColor: boolean;
  120649. /** @hidden */
  120650. _renderForCamera(camera: Camera, rigParent?: Camera): void;
  120651. private _processSubCameras;
  120652. private _checkIntersections;
  120653. /** @hidden */
  120654. _advancePhysicsEngineStep(step: number): void;
  120655. /**
  120656. * User updatable function that will return a deterministic frame time when engine is in deterministic lock step mode
  120657. */
  120658. getDeterministicFrameTime: () => number;
  120659. /** @hidden */
  120660. _animate(): void;
  120661. /** Execute all animations (for a frame) */
  120662. animate(): void;
  120663. /**
  120664. * Render the scene
  120665. * @param updateCameras defines a boolean indicating if cameras must update according to their inputs (true by default)
  120666. * @param ignoreAnimations defines a boolean indicating if animations should not be executed (false by default)
  120667. */
  120668. render(updateCameras?: boolean, ignoreAnimations?: boolean): void;
  120669. /**
  120670. * Freeze all materials
  120671. * A frozen material will not be updatable but should be faster to render
  120672. */
  120673. freezeMaterials(): void;
  120674. /**
  120675. * Unfreeze all materials
  120676. * A frozen material will not be updatable but should be faster to render
  120677. */
  120678. unfreezeMaterials(): void;
  120679. /**
  120680. * Releases all held ressources
  120681. */
  120682. dispose(): void;
  120683. /**
  120684. * Gets if the scene is already disposed
  120685. */
  120686. get isDisposed(): boolean;
  120687. /**
  120688. * Call this function to reduce memory footprint of the scene.
  120689. * Vertex buffers will not store CPU data anymore (this will prevent picking, collisions or physics to work correctly)
  120690. */
  120691. clearCachedVertexData(): void;
  120692. /**
  120693. * This function will remove the local cached buffer data from texture.
  120694. * It will save memory but will prevent the texture from being rebuilt
  120695. */
  120696. cleanCachedTextureBuffer(): void;
  120697. /**
  120698. * Get the world extend vectors with an optional filter
  120699. *
  120700. * @param filterPredicate the predicate - which meshes should be included when calculating the world size
  120701. * @returns {{ min: Vector3; max: Vector3 }} min and max vectors
  120702. */
  120703. getWorldExtends(filterPredicate?: (mesh: AbstractMesh) => boolean): {
  120704. min: Vector3;
  120705. max: Vector3;
  120706. };
  120707. /**
  120708. * Creates a ray that can be used to pick in the scene
  120709. * @param x defines the x coordinate of the origin (on-screen)
  120710. * @param y defines the y coordinate of the origin (on-screen)
  120711. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  120712. * @param camera defines the camera to use for the picking
  120713. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  120714. * @returns a Ray
  120715. */
  120716. createPickingRay(x: number, y: number, world: Matrix, camera: Nullable<Camera>, cameraViewSpace?: boolean): Ray;
  120717. /**
  120718. * Creates a ray that can be used to pick in the scene
  120719. * @param x defines the x coordinate of the origin (on-screen)
  120720. * @param y defines the y coordinate of the origin (on-screen)
  120721. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  120722. * @param result defines the ray where to store the picking ray
  120723. * @param camera defines the camera to use for the picking
  120724. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  120725. * @returns the current scene
  120726. */
  120727. createPickingRayToRef(x: number, y: number, world: Matrix, result: Ray, camera: Nullable<Camera>, cameraViewSpace?: boolean): Scene;
  120728. /**
  120729. * Creates a ray that can be used to pick in the scene
  120730. * @param x defines the x coordinate of the origin (on-screen)
  120731. * @param y defines the y coordinate of the origin (on-screen)
  120732. * @param camera defines the camera to use for the picking
  120733. * @returns a Ray
  120734. */
  120735. createPickingRayInCameraSpace(x: number, y: number, camera?: Camera): Ray;
  120736. /**
  120737. * Creates a ray that can be used to pick in the scene
  120738. * @param x defines the x coordinate of the origin (on-screen)
  120739. * @param y defines the y coordinate of the origin (on-screen)
  120740. * @param result defines the ray where to store the picking ray
  120741. * @param camera defines the camera to use for the picking
  120742. * @returns the current scene
  120743. */
  120744. createPickingRayInCameraSpaceToRef(x: number, y: number, result: Ray, camera?: Camera): Scene;
  120745. /** Launch a ray to try to pick a mesh in the scene
  120746. * @param x position on screen
  120747. * @param y position on screen
  120748. * @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
  120749. * @param fastCheck defines if the first intersection will be used (and not the closest)
  120750. * @param camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  120751. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  120752. * @returns a PickingInfo
  120753. */
  120754. pick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, camera?: Nullable<Camera>, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  120755. /** Launch a ray to try to pick a mesh in the scene using only bounding information of the main mesh (not using submeshes)
  120756. * @param x position on screen
  120757. * @param y position on screen
  120758. * @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
  120759. * @param fastCheck defines if the first intersection will be used (and not the closest)
  120760. * @param camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  120761. * @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)
  120762. */
  120763. pickWithBoundingInfo(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, camera?: Nullable<Camera>): Nullable<PickingInfo>;
  120764. /** Use the given ray to pick a mesh in the scene
  120765. * @param ray The ray to use to pick meshes
  120766. * @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
  120767. * @param fastCheck defines if the first intersection will be used (and not the closest)
  120768. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  120769. * @returns a PickingInfo
  120770. */
  120771. pickWithRay(ray: Ray, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  120772. /**
  120773. * Launch a ray to try to pick a mesh in the scene
  120774. * @param x X position on screen
  120775. * @param y Y position on screen
  120776. * @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
  120777. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  120778. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  120779. * @returns an array of PickingInfo
  120780. */
  120781. multiPick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, camera?: Camera, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  120782. /**
  120783. * Launch a ray to try to pick a mesh in the scene
  120784. * @param ray Ray to use
  120785. * @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
  120786. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  120787. * @returns an array of PickingInfo
  120788. */
  120789. multiPickWithRay(ray: Ray, predicate: (mesh: AbstractMesh) => boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  120790. /**
  120791. * Force the value of meshUnderPointer
  120792. * @param mesh defines the mesh to use
  120793. * @param pointerId optional pointer id when using more than one pointer
  120794. */
  120795. setPointerOverMesh(mesh: Nullable<AbstractMesh>, pointerId?: number): void;
  120796. /**
  120797. * Gets the mesh under the pointer
  120798. * @returns a Mesh or null if no mesh is under the pointer
  120799. */
  120800. getPointerOverMesh(): Nullable<AbstractMesh>;
  120801. /** @hidden */
  120802. _rebuildGeometries(): void;
  120803. /** @hidden */
  120804. _rebuildTextures(): void;
  120805. private _getByTags;
  120806. /**
  120807. * Get a list of meshes by tags
  120808. * @param tagsQuery defines the tags query to use
  120809. * @param forEach defines a predicate used to filter results
  120810. * @returns an array of Mesh
  120811. */
  120812. getMeshesByTags(tagsQuery: string, forEach?: (mesh: AbstractMesh) => void): Mesh[];
  120813. /**
  120814. * Get a list of cameras by tags
  120815. * @param tagsQuery defines the tags query to use
  120816. * @param forEach defines a predicate used to filter results
  120817. * @returns an array of Camera
  120818. */
  120819. getCamerasByTags(tagsQuery: string, forEach?: (camera: Camera) => void): Camera[];
  120820. /**
  120821. * Get a list of lights by tags
  120822. * @param tagsQuery defines the tags query to use
  120823. * @param forEach defines a predicate used to filter results
  120824. * @returns an array of Light
  120825. */
  120826. getLightsByTags(tagsQuery: string, forEach?: (light: Light) => void): Light[];
  120827. /**
  120828. * Get a list of materials by tags
  120829. * @param tagsQuery defines the tags query to use
  120830. * @param forEach defines a predicate used to filter results
  120831. * @returns an array of Material
  120832. */
  120833. getMaterialByTags(tagsQuery: string, forEach?: (material: Material) => void): Material[];
  120834. /**
  120835. * Get a list of transform nodes by tags
  120836. * @param tagsQuery defines the tags query to use
  120837. * @param forEach defines a predicate used to filter results
  120838. * @returns an array of TransformNode
  120839. */
  120840. getTransformNodesByTags(tagsQuery: string, forEach?: (transform: TransformNode) => void): TransformNode[];
  120841. /**
  120842. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  120843. * This allowed control for front to back rendering or reversly depending of the special needs.
  120844. *
  120845. * @param renderingGroupId The rendering group id corresponding to its index
  120846. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  120847. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  120848. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  120849. */
  120850. 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;
  120851. /**
  120852. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  120853. *
  120854. * @param renderingGroupId The rendering group id corresponding to its index
  120855. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  120856. * @param depth Automatically clears depth between groups if true and autoClear is true.
  120857. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  120858. */
  120859. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  120860. /**
  120861. * Gets the current auto clear configuration for one rendering group of the rendering
  120862. * manager.
  120863. * @param index the rendering group index to get the information for
  120864. * @returns The auto clear setup for the requested rendering group
  120865. */
  120866. getAutoClearDepthStencilSetup(index: number): IRenderingManagerAutoClearSetup;
  120867. private _blockMaterialDirtyMechanism;
  120868. /** Gets or sets a boolean blocking all the calls to markAllMaterialsAsDirty (ie. the materials won't be updated if they are out of sync) */
  120869. get blockMaterialDirtyMechanism(): boolean;
  120870. set blockMaterialDirtyMechanism(value: boolean);
  120871. /**
  120872. * Will flag all materials as dirty to trigger new shader compilation
  120873. * @param flag defines the flag used to specify which material part must be marked as dirty
  120874. * @param predicate If not null, it will be used to specifiy if a material has to be marked as dirty
  120875. */
  120876. markAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  120877. /** @hidden */
  120878. _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;
  120879. /** @hidden */
  120880. _loadFileAsync(url: string, onProgress?: (data: any) => void, useOfflineSupport?: boolean, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  120881. /** @hidden */
  120882. _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;
  120883. /** @hidden */
  120884. _requestFileAsync(url: string, onProgress?: (ev: ProgressEvent) => void, useOfflineSupport?: boolean, useArrayBuffer?: boolean, onOpened?: (request: WebRequest) => void): Promise<string | ArrayBuffer>;
  120885. /** @hidden */
  120886. _readFile(file: File, onSuccess: (data: string | ArrayBuffer) => void, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: ReadFileError) => void): IFileRequest;
  120887. /** @hidden */
  120888. _readFileAsync(file: File, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  120889. }
  120890. }
  120891. declare module BABYLON {
  120892. /**
  120893. * Set of assets to keep when moving a scene into an asset container.
  120894. */
  120895. export class KeepAssets extends AbstractScene {
  120896. }
  120897. /**
  120898. * Class used to store the output of the AssetContainer.instantiateAllMeshesToScene function
  120899. */
  120900. export class InstantiatedEntries {
  120901. /**
  120902. * List of new root nodes (eg. nodes with no parent)
  120903. */
  120904. rootNodes: TransformNode[];
  120905. /**
  120906. * List of new skeletons
  120907. */
  120908. skeletons: Skeleton[];
  120909. /**
  120910. * List of new animation groups
  120911. */
  120912. animationGroups: AnimationGroup[];
  120913. }
  120914. /**
  120915. * Container with a set of assets that can be added or removed from a scene.
  120916. */
  120917. export class AssetContainer extends AbstractScene {
  120918. private _wasAddedToScene;
  120919. /**
  120920. * The scene the AssetContainer belongs to.
  120921. */
  120922. scene: Scene;
  120923. /**
  120924. * Instantiates an AssetContainer.
  120925. * @param scene The scene the AssetContainer belongs to.
  120926. */
  120927. constructor(scene: Scene);
  120928. /**
  120929. * Instantiate or clone all meshes and add the new ones to the scene.
  120930. * Skeletons and animation groups will all be cloned
  120931. * @param nameFunction defines an optional function used to get new names for clones
  120932. * @param cloneMaterials defines an optional boolean that defines if materials must be cloned as well (false by default)
  120933. * @returns a list of rootNodes, skeletons and aniamtion groups that were duplicated
  120934. */
  120935. instantiateModelsToScene(nameFunction?: (sourceName: string) => string, cloneMaterials?: boolean): InstantiatedEntries;
  120936. /**
  120937. * Adds all the assets from the container to the scene.
  120938. */
  120939. addAllToScene(): void;
  120940. /**
  120941. * Removes all the assets in the container from the scene
  120942. */
  120943. removeAllFromScene(): void;
  120944. /**
  120945. * Disposes all the assets in the container
  120946. */
  120947. dispose(): void;
  120948. private _moveAssets;
  120949. /**
  120950. * Removes all the assets contained in the scene and adds them to the container.
  120951. * @param keepAssets Set of assets to keep in the scene. (default: empty)
  120952. */
  120953. moveAllFromScene(keepAssets?: KeepAssets): void;
  120954. /**
  120955. * 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.
  120956. * @returns the root mesh
  120957. */
  120958. createRootMesh(): Mesh;
  120959. /**
  120960. * Merge animations (direct and animation groups) from this asset container into a scene
  120961. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  120962. * @param animatables set of animatables to retarget to a node from the scene
  120963. * @param targetConverter defines a function used to convert animation targets from the asset container to the scene (default: search node by name)
  120964. * @returns an array of the new AnimationGroup added to the scene (empty array if none)
  120965. */
  120966. mergeAnimationsTo(scene: Scene | null | undefined, animatables: Animatable[], targetConverter?: Nullable<(target: any) => Nullable<Node>>): AnimationGroup[];
  120967. }
  120968. }
  120969. declare module BABYLON {
  120970. /**
  120971. * Defines how the parser contract is defined.
  120972. * These parsers are used to parse a list of specific assets (like particle systems, etc..)
  120973. */
  120974. export type BabylonFileParser = (parsedData: any, scene: Scene, container: AssetContainer, rootUrl: string) => void;
  120975. /**
  120976. * Defines how the individual parser contract is defined.
  120977. * These parser can parse an individual asset
  120978. */
  120979. export type IndividualBabylonFileParser = (parsedData: any, scene: Scene, rootUrl: string) => any;
  120980. /**
  120981. * Base class of the scene acting as a container for the different elements composing a scene.
  120982. * This class is dynamically extended by the different components of the scene increasing
  120983. * flexibility and reducing coupling
  120984. */
  120985. export abstract class AbstractScene {
  120986. /**
  120987. * Stores the list of available parsers in the application.
  120988. */
  120989. private static _BabylonFileParsers;
  120990. /**
  120991. * Stores the list of available individual parsers in the application.
  120992. */
  120993. private static _IndividualBabylonFileParsers;
  120994. /**
  120995. * Adds a parser in the list of available ones
  120996. * @param name Defines the name of the parser
  120997. * @param parser Defines the parser to add
  120998. */
  120999. static AddParser(name: string, parser: BabylonFileParser): void;
  121000. /**
  121001. * Gets a general parser from the list of avaialble ones
  121002. * @param name Defines the name of the parser
  121003. * @returns the requested parser or null
  121004. */
  121005. static GetParser(name: string): Nullable<BabylonFileParser>;
  121006. /**
  121007. * Adds n individual parser in the list of available ones
  121008. * @param name Defines the name of the parser
  121009. * @param parser Defines the parser to add
  121010. */
  121011. static AddIndividualParser(name: string, parser: IndividualBabylonFileParser): void;
  121012. /**
  121013. * Gets an individual parser from the list of avaialble ones
  121014. * @param name Defines the name of the parser
  121015. * @returns the requested parser or null
  121016. */
  121017. static GetIndividualParser(name: string): Nullable<IndividualBabylonFileParser>;
  121018. /**
  121019. * Parser json data and populate both a scene and its associated container object
  121020. * @param jsonData Defines the data to parse
  121021. * @param scene Defines the scene to parse the data for
  121022. * @param container Defines the container attached to the parsing sequence
  121023. * @param rootUrl Defines the root url of the data
  121024. */
  121025. static Parse(jsonData: any, scene: Scene, container: AssetContainer, rootUrl: string): void;
  121026. /**
  121027. * Gets the list of root nodes (ie. nodes with no parent)
  121028. */
  121029. rootNodes: Node[];
  121030. /** All of the cameras added to this scene
  121031. * @see https://doc.babylonjs.com/babylon101/cameras
  121032. */
  121033. cameras: Camera[];
  121034. /**
  121035. * All of the lights added to this scene
  121036. * @see https://doc.babylonjs.com/babylon101/lights
  121037. */
  121038. lights: Light[];
  121039. /**
  121040. * All of the (abstract) meshes added to this scene
  121041. */
  121042. meshes: AbstractMesh[];
  121043. /**
  121044. * The list of skeletons added to the scene
  121045. * @see https://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  121046. */
  121047. skeletons: Skeleton[];
  121048. /**
  121049. * All of the particle systems added to this scene
  121050. * @see https://doc.babylonjs.com/babylon101/particles
  121051. */
  121052. particleSystems: IParticleSystem[];
  121053. /**
  121054. * Gets a list of Animations associated with the scene
  121055. */
  121056. animations: Animation[];
  121057. /**
  121058. * All of the animation groups added to this scene
  121059. * @see https://doc.babylonjs.com/how_to/group
  121060. */
  121061. animationGroups: AnimationGroup[];
  121062. /**
  121063. * All of the multi-materials added to this scene
  121064. * @see https://doc.babylonjs.com/how_to/multi_materials
  121065. */
  121066. multiMaterials: MultiMaterial[];
  121067. /**
  121068. * All of the materials added to this scene
  121069. * In the context of a Scene, it is not supposed to be modified manually.
  121070. * Any addition or removal should be done using the addMaterial and removeMaterial Scene methods.
  121071. * Note also that the order of the Material within the array is not significant and might change.
  121072. * @see https://doc.babylonjs.com/babylon101/materials
  121073. */
  121074. materials: Material[];
  121075. /**
  121076. * The list of morph target managers added to the scene
  121077. * @see https://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh
  121078. */
  121079. morphTargetManagers: MorphTargetManager[];
  121080. /**
  121081. * The list of geometries used in the scene.
  121082. */
  121083. geometries: Geometry[];
  121084. /**
  121085. * All of the tranform nodes added to this scene
  121086. * In the context of a Scene, it is not supposed to be modified manually.
  121087. * Any addition or removal should be done using the addTransformNode and removeTransformNode Scene methods.
  121088. * Note also that the order of the TransformNode wihin the array is not significant and might change.
  121089. * @see https://doc.babylonjs.com/how_to/transformnode
  121090. */
  121091. transformNodes: TransformNode[];
  121092. /**
  121093. * ActionManagers available on the scene.
  121094. */
  121095. actionManagers: AbstractActionManager[];
  121096. /**
  121097. * Textures to keep.
  121098. */
  121099. textures: BaseTexture[];
  121100. /** @hidden */
  121101. protected _environmentTexture: Nullable<BaseTexture>;
  121102. /**
  121103. * Texture used in all pbr material as the reflection texture.
  121104. * As in the majority of the scene they are the same (exception for multi room and so on),
  121105. * this is easier to reference from here than from all the materials.
  121106. */
  121107. get environmentTexture(): Nullable<BaseTexture>;
  121108. set environmentTexture(value: Nullable<BaseTexture>);
  121109. /**
  121110. * The list of postprocesses added to the scene
  121111. */
  121112. postProcesses: PostProcess[];
  121113. /**
  121114. * @returns all meshes, lights, cameras, transformNodes and bones
  121115. */
  121116. getNodes(): Array<Node>;
  121117. }
  121118. }
  121119. declare module BABYLON {
  121120. /**
  121121. * Interface used to define options for Sound class
  121122. */
  121123. export interface ISoundOptions {
  121124. /**
  121125. * Does the sound autoplay once loaded.
  121126. */
  121127. autoplay?: boolean;
  121128. /**
  121129. * Does the sound loop after it finishes playing once.
  121130. */
  121131. loop?: boolean;
  121132. /**
  121133. * Sound's volume
  121134. */
  121135. volume?: number;
  121136. /**
  121137. * Is it a spatial sound?
  121138. */
  121139. spatialSound?: boolean;
  121140. /**
  121141. * Maximum distance to hear that sound
  121142. */
  121143. maxDistance?: number;
  121144. /**
  121145. * Uses user defined attenuation function
  121146. */
  121147. useCustomAttenuation?: boolean;
  121148. /**
  121149. * Define the roll off factor of spatial sounds.
  121150. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  121151. */
  121152. rolloffFactor?: number;
  121153. /**
  121154. * Define the reference distance the sound should be heard perfectly.
  121155. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  121156. */
  121157. refDistance?: number;
  121158. /**
  121159. * Define the distance attenuation model the sound will follow.
  121160. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  121161. */
  121162. distanceModel?: string;
  121163. /**
  121164. * Defines the playback speed (1 by default)
  121165. */
  121166. playbackRate?: number;
  121167. /**
  121168. * Defines if the sound is from a streaming source
  121169. */
  121170. streaming?: boolean;
  121171. /**
  121172. * Defines an optional length (in seconds) inside the sound file
  121173. */
  121174. length?: number;
  121175. /**
  121176. * Defines an optional offset (in seconds) inside the sound file
  121177. */
  121178. offset?: number;
  121179. /**
  121180. * If true, URLs will not be required to state the audio file codec to use.
  121181. */
  121182. skipCodecCheck?: boolean;
  121183. }
  121184. /**
  121185. * Defines a sound that can be played in the application.
  121186. * The sound can either be an ambient track or a simple sound played in reaction to a user action.
  121187. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  121188. */
  121189. export class Sound {
  121190. /**
  121191. * The name of the sound in the scene.
  121192. */
  121193. name: string;
  121194. /**
  121195. * Does the sound autoplay once loaded.
  121196. */
  121197. autoplay: boolean;
  121198. /**
  121199. * Does the sound loop after it finishes playing once.
  121200. */
  121201. loop: boolean;
  121202. /**
  121203. * Does the sound use a custom attenuation curve to simulate the falloff
  121204. * happening when the source gets further away from the camera.
  121205. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function
  121206. */
  121207. useCustomAttenuation: boolean;
  121208. /**
  121209. * The sound track id this sound belongs to.
  121210. */
  121211. soundTrackId: number;
  121212. /**
  121213. * Is this sound currently played.
  121214. */
  121215. isPlaying: boolean;
  121216. /**
  121217. * Is this sound currently paused.
  121218. */
  121219. isPaused: boolean;
  121220. /**
  121221. * Does this sound enables spatial sound.
  121222. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  121223. */
  121224. spatialSound: boolean;
  121225. /**
  121226. * Define the reference distance the sound should be heard perfectly.
  121227. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  121228. */
  121229. refDistance: number;
  121230. /**
  121231. * Define the roll off factor of spatial sounds.
  121232. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  121233. */
  121234. rolloffFactor: number;
  121235. /**
  121236. * Define the max distance the sound should be heard (intensity just became 0 at this point).
  121237. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  121238. */
  121239. maxDistance: number;
  121240. /**
  121241. * Define the distance attenuation model the sound will follow.
  121242. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  121243. */
  121244. distanceModel: string;
  121245. /**
  121246. * @hidden
  121247. * Back Compat
  121248. **/
  121249. onended: () => any;
  121250. /**
  121251. * Gets or sets an object used to store user defined information for the sound.
  121252. */
  121253. metadata: any;
  121254. /**
  121255. * Observable event when the current playing sound finishes.
  121256. */
  121257. onEndedObservable: Observable<Sound>;
  121258. private _panningModel;
  121259. private _playbackRate;
  121260. private _streaming;
  121261. private _startTime;
  121262. private _startOffset;
  121263. private _position;
  121264. /** @hidden */
  121265. _positionInEmitterSpace: boolean;
  121266. private _localDirection;
  121267. private _volume;
  121268. private _isReadyToPlay;
  121269. private _isDirectional;
  121270. private _readyToPlayCallback;
  121271. private _audioBuffer;
  121272. private _soundSource;
  121273. private _streamingSource;
  121274. private _soundPanner;
  121275. private _soundGain;
  121276. private _inputAudioNode;
  121277. private _outputAudioNode;
  121278. private _coneInnerAngle;
  121279. private _coneOuterAngle;
  121280. private _coneOuterGain;
  121281. private _scene;
  121282. private _connectedTransformNode;
  121283. private _customAttenuationFunction;
  121284. private _registerFunc;
  121285. private _isOutputConnected;
  121286. private _htmlAudioElement;
  121287. private _urlType;
  121288. private _length?;
  121289. private _offset?;
  121290. /** @hidden */
  121291. static _SceneComponentInitialization: (scene: Scene) => void;
  121292. /**
  121293. * Create a sound and attach it to a scene
  121294. * @param name Name of your sound
  121295. * @param urlOrArrayBuffer Url to the sound to load async or ArrayBuffer, it also works with MediaStreams
  121296. * @param scene defines the scene the sound belongs to
  121297. * @param readyToPlayCallback Provide a callback function if you'd like to load your code once the sound is ready to be played
  121298. * @param options Objects to provide with the current available options: autoplay, loop, volume, spatialSound, maxDistance, rolloffFactor, refDistance, distanceModel, panningModel, streaming
  121299. */
  121300. constructor(name: string, urlOrArrayBuffer: any, scene: Scene, readyToPlayCallback?: Nullable<() => void>, options?: ISoundOptions);
  121301. /**
  121302. * Release the sound and its associated resources
  121303. */
  121304. dispose(): void;
  121305. /**
  121306. * Gets if the sounds is ready to be played or not.
  121307. * @returns true if ready, otherwise false
  121308. */
  121309. isReady(): boolean;
  121310. private _soundLoaded;
  121311. /**
  121312. * Sets the data of the sound from an audiobuffer
  121313. * @param audioBuffer The audioBuffer containing the data
  121314. */
  121315. setAudioBuffer(audioBuffer: AudioBuffer): void;
  121316. /**
  121317. * Updates the current sounds options such as maxdistance, loop...
  121318. * @param options A JSON object containing values named as the object properties
  121319. */
  121320. updateOptions(options: ISoundOptions): void;
  121321. private _createSpatialParameters;
  121322. private _updateSpatialParameters;
  121323. /**
  121324. * Switch the panning model to HRTF:
  121325. * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
  121326. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  121327. */
  121328. switchPanningModelToHRTF(): void;
  121329. /**
  121330. * Switch the panning model to Equal Power:
  121331. * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
  121332. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  121333. */
  121334. switchPanningModelToEqualPower(): void;
  121335. private _switchPanningModel;
  121336. /**
  121337. * Connect this sound to a sound track audio node like gain...
  121338. * @param soundTrackAudioNode the sound track audio node to connect to
  121339. */
  121340. connectToSoundTrackAudioNode(soundTrackAudioNode: AudioNode): void;
  121341. /**
  121342. * Transform this sound into a directional source
  121343. * @param coneInnerAngle Size of the inner cone in degree
  121344. * @param coneOuterAngle Size of the outer cone in degree
  121345. * @param coneOuterGain Volume of the sound outside the outer cone (between 0.0 and 1.0)
  121346. */
  121347. setDirectionalCone(coneInnerAngle: number, coneOuterAngle: number, coneOuterGain: number): void;
  121348. /**
  121349. * Gets or sets the inner angle for the directional cone.
  121350. */
  121351. get directionalConeInnerAngle(): number;
  121352. /**
  121353. * Gets or sets the inner angle for the directional cone.
  121354. */
  121355. set directionalConeInnerAngle(value: number);
  121356. /**
  121357. * Gets or sets the outer angle for the directional cone.
  121358. */
  121359. get directionalConeOuterAngle(): number;
  121360. /**
  121361. * Gets or sets the outer angle for the directional cone.
  121362. */
  121363. set directionalConeOuterAngle(value: number);
  121364. /**
  121365. * Sets the position of the emitter if spatial sound is enabled
  121366. * @param newPosition Defines the new posisiton
  121367. */
  121368. setPosition(newPosition: Vector3): void;
  121369. /**
  121370. * Sets the local direction of the emitter if spatial sound is enabled
  121371. * @param newLocalDirection Defines the new local direction
  121372. */
  121373. setLocalDirectionToMesh(newLocalDirection: Vector3): void;
  121374. private _updateDirection;
  121375. /** @hidden */
  121376. updateDistanceFromListener(): void;
  121377. /**
  121378. * Sets a new custom attenuation function for the sound.
  121379. * @param callback Defines the function used for the attenuation
  121380. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function
  121381. */
  121382. setAttenuationFunction(callback: (currentVolume: number, currentDistance: number, maxDistance: number, refDistance: number, rolloffFactor: number) => number): void;
  121383. /**
  121384. * Play the sound
  121385. * @param time (optional) Start the sound after X seconds. Start immediately (0) by default.
  121386. * @param offset (optional) Start the sound at a specific time in seconds
  121387. * @param length (optional) Sound duration (in seconds)
  121388. */
  121389. play(time?: number, offset?: number, length?: number): void;
  121390. private _onended;
  121391. /**
  121392. * Stop the sound
  121393. * @param time (optional) Stop the sound after X seconds. Stop immediately (0) by default.
  121394. */
  121395. stop(time?: number): void;
  121396. /**
  121397. * Put the sound in pause
  121398. */
  121399. pause(): void;
  121400. /**
  121401. * Sets a dedicated volume for this sounds
  121402. * @param newVolume Define the new volume of the sound
  121403. * @param time Define time for gradual change to new volume
  121404. */
  121405. setVolume(newVolume: number, time?: number): void;
  121406. /**
  121407. * Set the sound play back rate
  121408. * @param newPlaybackRate Define the playback rate the sound should be played at
  121409. */
  121410. setPlaybackRate(newPlaybackRate: number): void;
  121411. /**
  121412. * Gets the volume of the sound.
  121413. * @returns the volume of the sound
  121414. */
  121415. getVolume(): number;
  121416. /**
  121417. * Attach the sound to a dedicated mesh
  121418. * @param transformNode The transform node to connect the sound with
  121419. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh
  121420. */
  121421. attachToMesh(transformNode: TransformNode): void;
  121422. /**
  121423. * Detach the sound from the previously attached mesh
  121424. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh
  121425. */
  121426. detachFromMesh(): void;
  121427. private _onRegisterAfterWorldMatrixUpdate;
  121428. /**
  121429. * Clone the current sound in the scene.
  121430. * @returns the new sound clone
  121431. */
  121432. clone(): Nullable<Sound>;
  121433. /**
  121434. * Gets the current underlying audio buffer containing the data
  121435. * @returns the audio buffer
  121436. */
  121437. getAudioBuffer(): Nullable<AudioBuffer>;
  121438. /**
  121439. * Gets the WebAudio AudioBufferSourceNode, lets you keep track of and stop instances of this Sound.
  121440. * @returns the source node
  121441. */
  121442. getSoundSource(): Nullable<AudioBufferSourceNode>;
  121443. /**
  121444. * Gets the WebAudio GainNode, gives you precise control over the gain of instances of this Sound.
  121445. * @returns the gain node
  121446. */
  121447. getSoundGain(): Nullable<GainNode>;
  121448. /**
  121449. * Serializes the Sound in a JSON representation
  121450. * @returns the JSON representation of the sound
  121451. */
  121452. serialize(): any;
  121453. /**
  121454. * Parse a JSON representation of a sound to innstantiate in a given scene
  121455. * @param parsedSound Define the JSON representation of the sound (usually coming from the serialize method)
  121456. * @param scene Define the scene the new parsed sound should be created in
  121457. * @param rootUrl Define the rooturl of the load in case we need to fetch relative dependencies
  121458. * @param sourceSound Define a cound place holder if do not need to instantiate a new one
  121459. * @returns the newly parsed sound
  121460. */
  121461. static Parse(parsedSound: any, scene: Scene, rootUrl: string, sourceSound?: Sound): Sound;
  121462. }
  121463. }
  121464. declare module BABYLON {
  121465. /**
  121466. * This defines an action helpful to play a defined sound on a triggered action.
  121467. */
  121468. export class PlaySoundAction extends Action {
  121469. private _sound;
  121470. /**
  121471. * Instantiate the action
  121472. * @param triggerOptions defines the trigger options
  121473. * @param sound defines the sound to play
  121474. * @param condition defines the trigger related conditions
  121475. */
  121476. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  121477. /** @hidden */
  121478. _prepare(): void;
  121479. /**
  121480. * Execute the action and play the sound.
  121481. */
  121482. execute(): void;
  121483. /**
  121484. * Serializes the actions and its related information.
  121485. * @param parent defines the object to serialize in
  121486. * @returns the serialized object
  121487. */
  121488. serialize(parent: any): any;
  121489. }
  121490. /**
  121491. * This defines an action helpful to stop a defined sound on a triggered action.
  121492. */
  121493. export class StopSoundAction extends Action {
  121494. private _sound;
  121495. /**
  121496. * Instantiate the action
  121497. * @param triggerOptions defines the trigger options
  121498. * @param sound defines the sound to stop
  121499. * @param condition defines the trigger related conditions
  121500. */
  121501. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  121502. /** @hidden */
  121503. _prepare(): void;
  121504. /**
  121505. * Execute the action and stop the sound.
  121506. */
  121507. execute(): void;
  121508. /**
  121509. * Serializes the actions and its related information.
  121510. * @param parent defines the object to serialize in
  121511. * @returns the serialized object
  121512. */
  121513. serialize(parent: any): any;
  121514. }
  121515. }
  121516. declare module BABYLON {
  121517. /**
  121518. * This defines an action responsible to change the value of a property
  121519. * by interpolating between its current value and the newly set one once triggered.
  121520. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  121521. */
  121522. export class InterpolateValueAction extends Action {
  121523. /**
  121524. * Defines the path of the property where the value should be interpolated
  121525. */
  121526. propertyPath: string;
  121527. /**
  121528. * Defines the target value at the end of the interpolation.
  121529. */
  121530. value: any;
  121531. /**
  121532. * Defines the time it will take for the property to interpolate to the value.
  121533. */
  121534. duration: number;
  121535. /**
  121536. * Defines if the other scene animations should be stopped when the action has been triggered
  121537. */
  121538. stopOtherAnimations?: boolean;
  121539. /**
  121540. * Defines a callback raised once the interpolation animation has been done.
  121541. */
  121542. onInterpolationDone?: () => void;
  121543. /**
  121544. * Observable triggered once the interpolation animation has been done.
  121545. */
  121546. onInterpolationDoneObservable: Observable<InterpolateValueAction>;
  121547. private _target;
  121548. private _effectiveTarget;
  121549. private _property;
  121550. /**
  121551. * Instantiate the action
  121552. * @param triggerOptions defines the trigger options
  121553. * @param target defines the object containing the value to interpolate
  121554. * @param propertyPath defines the path to the property in the target object
  121555. * @param value defines the target value at the end of the interpolation
  121556. * @param duration deines the time it will take for the property to interpolate to the value.
  121557. * @param condition defines the trigger related conditions
  121558. * @param stopOtherAnimations defines if the other scene animations should be stopped when the action has been triggered
  121559. * @param onInterpolationDone defines a callback raised once the interpolation animation has been done
  121560. */
  121561. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, duration?: number, condition?: Condition, stopOtherAnimations?: boolean, onInterpolationDone?: () => void);
  121562. /** @hidden */
  121563. _prepare(): void;
  121564. /**
  121565. * Execute the action starts the value interpolation.
  121566. */
  121567. execute(): void;
  121568. /**
  121569. * Serializes the actions and its related information.
  121570. * @param parent defines the object to serialize in
  121571. * @returns the serialized object
  121572. */
  121573. serialize(parent: any): any;
  121574. }
  121575. }
  121576. declare module BABYLON {
  121577. /**
  121578. * Options allowed during the creation of a sound track.
  121579. */
  121580. export interface ISoundTrackOptions {
  121581. /**
  121582. * The volume the sound track should take during creation
  121583. */
  121584. volume?: number;
  121585. /**
  121586. * Define if the sound track is the main sound track of the scene
  121587. */
  121588. mainTrack?: boolean;
  121589. }
  121590. /**
  121591. * It could be useful to isolate your music & sounds on several tracks to better manage volume on a grouped instance of sounds.
  121592. * It will be also used in a future release to apply effects on a specific track.
  121593. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks
  121594. */
  121595. export class SoundTrack {
  121596. /**
  121597. * The unique identifier of the sound track in the scene.
  121598. */
  121599. id: number;
  121600. /**
  121601. * The list of sounds included in the sound track.
  121602. */
  121603. soundCollection: Array<Sound>;
  121604. private _outputAudioNode;
  121605. private _scene;
  121606. private _connectedAnalyser;
  121607. private _options;
  121608. private _isInitialized;
  121609. /**
  121610. * Creates a new sound track.
  121611. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks
  121612. * @param scene Define the scene the sound track belongs to
  121613. * @param options
  121614. */
  121615. constructor(scene: Scene, options?: ISoundTrackOptions);
  121616. private _initializeSoundTrackAudioGraph;
  121617. /**
  121618. * Release the sound track and its associated resources
  121619. */
  121620. dispose(): void;
  121621. /**
  121622. * Adds a sound to this sound track
  121623. * @param sound define the cound to add
  121624. * @ignoreNaming
  121625. */
  121626. AddSound(sound: Sound): void;
  121627. /**
  121628. * Removes a sound to this sound track
  121629. * @param sound define the cound to remove
  121630. * @ignoreNaming
  121631. */
  121632. RemoveSound(sound: Sound): void;
  121633. /**
  121634. * Set a global volume for the full sound track.
  121635. * @param newVolume Define the new volume of the sound track
  121636. */
  121637. setVolume(newVolume: number): void;
  121638. /**
  121639. * Switch the panning model to HRTF:
  121640. * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
  121641. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  121642. */
  121643. switchPanningModelToHRTF(): void;
  121644. /**
  121645. * Switch the panning model to Equal Power:
  121646. * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
  121647. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  121648. */
  121649. switchPanningModelToEqualPower(): void;
  121650. /**
  121651. * Connect the sound track to an audio analyser allowing some amazing
  121652. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  121653. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  121654. * @param analyser The analyser to connect to the engine
  121655. */
  121656. connectToAnalyser(analyser: Analyser): void;
  121657. }
  121658. }
  121659. declare module BABYLON {
  121660. interface AbstractScene {
  121661. /**
  121662. * The list of sounds used in the scene.
  121663. */
  121664. sounds: Nullable<Array<Sound>>;
  121665. }
  121666. interface Scene {
  121667. /**
  121668. * @hidden
  121669. * Backing field
  121670. */
  121671. _mainSoundTrack: SoundTrack;
  121672. /**
  121673. * The main sound track played by the scene.
  121674. * It cotains your primary collection of sounds.
  121675. */
  121676. mainSoundTrack: SoundTrack;
  121677. /**
  121678. * The list of sound tracks added to the scene
  121679. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  121680. */
  121681. soundTracks: Nullable<Array<SoundTrack>>;
  121682. /**
  121683. * Gets a sound using a given name
  121684. * @param name defines the name to search for
  121685. * @return the found sound or null if not found at all.
  121686. */
  121687. getSoundByName(name: string): Nullable<Sound>;
  121688. /**
  121689. * Gets or sets if audio support is enabled
  121690. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  121691. */
  121692. audioEnabled: boolean;
  121693. /**
  121694. * Gets or sets if audio will be output to headphones
  121695. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  121696. */
  121697. headphone: boolean;
  121698. /**
  121699. * Gets or sets custom audio listener position provider
  121700. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  121701. */
  121702. audioListenerPositionProvider: Nullable<() => Vector3>;
  121703. /**
  121704. * Gets or sets a refresh rate when using 3D audio positioning
  121705. */
  121706. audioPositioningRefreshRate: number;
  121707. }
  121708. /**
  121709. * Defines the sound scene component responsible to manage any sounds
  121710. * in a given scene.
  121711. */
  121712. export class AudioSceneComponent implements ISceneSerializableComponent {
  121713. private static _CameraDirectionLH;
  121714. private static _CameraDirectionRH;
  121715. /**
  121716. * The component name helpfull to identify the component in the list of scene components.
  121717. */
  121718. readonly name: string;
  121719. /**
  121720. * The scene the component belongs to.
  121721. */
  121722. scene: Scene;
  121723. private _audioEnabled;
  121724. /**
  121725. * Gets whether audio is enabled or not.
  121726. * Please use related enable/disable method to switch state.
  121727. */
  121728. get audioEnabled(): boolean;
  121729. private _headphone;
  121730. /**
  121731. * Gets whether audio is outputing to headphone or not.
  121732. * Please use the according Switch methods to change output.
  121733. */
  121734. get headphone(): boolean;
  121735. /**
  121736. * Gets or sets a refresh rate when using 3D audio positioning
  121737. */
  121738. audioPositioningRefreshRate: number;
  121739. private _audioListenerPositionProvider;
  121740. /**
  121741. * Gets the current audio listener position provider
  121742. */
  121743. get audioListenerPositionProvider(): Nullable<() => Vector3>;
  121744. /**
  121745. * Sets a custom listener position for all sounds in the scene
  121746. * By default, this is the position of the first active camera
  121747. */
  121748. set audioListenerPositionProvider(value: Nullable<() => Vector3>);
  121749. /**
  121750. * Creates a new instance of the component for the given scene
  121751. * @param scene Defines the scene to register the component in
  121752. */
  121753. constructor(scene: Scene);
  121754. /**
  121755. * Registers the component in a given scene
  121756. */
  121757. register(): void;
  121758. /**
  121759. * Rebuilds the elements related to this component in case of
  121760. * context lost for instance.
  121761. */
  121762. rebuild(): void;
  121763. /**
  121764. * Serializes the component data to the specified json object
  121765. * @param serializationObject The object to serialize to
  121766. */
  121767. serialize(serializationObject: any): void;
  121768. /**
  121769. * Adds all the elements from the container to the scene
  121770. * @param container the container holding the elements
  121771. */
  121772. addFromContainer(container: AbstractScene): void;
  121773. /**
  121774. * Removes all the elements in the container from the scene
  121775. * @param container contains the elements to remove
  121776. * @param dispose if the removed element should be disposed (default: false)
  121777. */
  121778. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  121779. /**
  121780. * Disposes the component and the associated ressources.
  121781. */
  121782. dispose(): void;
  121783. /**
  121784. * Disables audio in the associated scene.
  121785. */
  121786. disableAudio(): void;
  121787. /**
  121788. * Enables audio in the associated scene.
  121789. */
  121790. enableAudio(): void;
  121791. /**
  121792. * Switch audio to headphone output.
  121793. */
  121794. switchAudioModeForHeadphones(): void;
  121795. /**
  121796. * Switch audio to normal speakers.
  121797. */
  121798. switchAudioModeForNormalSpeakers(): void;
  121799. private _cachedCameraDirection;
  121800. private _cachedCameraPosition;
  121801. private _lastCheck;
  121802. private _afterRender;
  121803. }
  121804. }
  121805. declare module BABYLON {
  121806. /**
  121807. * Wraps one or more Sound objects and selects one with random weight for playback.
  121808. */
  121809. export class WeightedSound {
  121810. /** When true a Sound will be selected and played when the current playing Sound completes. */
  121811. loop: boolean;
  121812. private _coneInnerAngle;
  121813. private _coneOuterAngle;
  121814. private _volume;
  121815. /** A Sound is currently playing. */
  121816. isPlaying: boolean;
  121817. /** A Sound is currently paused. */
  121818. isPaused: boolean;
  121819. private _sounds;
  121820. private _weights;
  121821. private _currentIndex?;
  121822. /**
  121823. * Creates a new WeightedSound from the list of sounds given.
  121824. * @param loop When true a Sound will be selected and played when the current playing Sound completes.
  121825. * @param sounds Array of Sounds that will be selected from.
  121826. * @param weights Array of number values for selection weights; length must equal sounds, values will be normalized to 1
  121827. */
  121828. constructor(loop: boolean, sounds: Sound[], weights: number[]);
  121829. /**
  121830. * The size of cone in degrees for a directional sound in which there will be no attenuation.
  121831. */
  121832. get directionalConeInnerAngle(): number;
  121833. /**
  121834. * The size of cone in degress for a directional sound in which there will be no attenuation.
  121835. */
  121836. set directionalConeInnerAngle(value: number);
  121837. /**
  121838. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  121839. * Listener angles between innerAngle and outerAngle will falloff linearly.
  121840. */
  121841. get directionalConeOuterAngle(): number;
  121842. /**
  121843. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  121844. * Listener angles between innerAngle and outerAngle will falloff linearly.
  121845. */
  121846. set directionalConeOuterAngle(value: number);
  121847. /**
  121848. * Playback volume.
  121849. */
  121850. get volume(): number;
  121851. /**
  121852. * Playback volume.
  121853. */
  121854. set volume(value: number);
  121855. private _onended;
  121856. /**
  121857. * Suspend playback
  121858. */
  121859. pause(): void;
  121860. /**
  121861. * Stop playback
  121862. */
  121863. stop(): void;
  121864. /**
  121865. * Start playback.
  121866. * @param startOffset Position the clip head at a specific time in seconds.
  121867. */
  121868. play(startOffset?: number): void;
  121869. }
  121870. }
  121871. declare module BABYLON {
  121872. /**
  121873. * Add a bouncing effect to an ArcRotateCamera when reaching a specified minimum and maximum radius
  121874. * @see https://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  121875. */
  121876. export class BouncingBehavior implements Behavior<ArcRotateCamera> {
  121877. /**
  121878. * Gets the name of the behavior.
  121879. */
  121880. get name(): string;
  121881. /**
  121882. * The easing function used by animations
  121883. */
  121884. static EasingFunction: BackEase;
  121885. /**
  121886. * The easing mode used by animations
  121887. */
  121888. static EasingMode: number;
  121889. /**
  121890. * The duration of the animation, in milliseconds
  121891. */
  121892. transitionDuration: number;
  121893. /**
  121894. * Length of the distance animated by the transition when lower radius is reached
  121895. */
  121896. lowerRadiusTransitionRange: number;
  121897. /**
  121898. * Length of the distance animated by the transition when upper radius is reached
  121899. */
  121900. upperRadiusTransitionRange: number;
  121901. private _autoTransitionRange;
  121902. /**
  121903. * Gets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  121904. */
  121905. get autoTransitionRange(): boolean;
  121906. /**
  121907. * Sets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  121908. * Transition ranges will be set to 5% of the bounding box diagonal in world space
  121909. */
  121910. set autoTransitionRange(value: boolean);
  121911. private _attachedCamera;
  121912. private _onAfterCheckInputsObserver;
  121913. private _onMeshTargetChangedObserver;
  121914. /**
  121915. * Initializes the behavior.
  121916. */
  121917. init(): void;
  121918. /**
  121919. * Attaches the behavior to its arc rotate camera.
  121920. * @param camera Defines the camera to attach the behavior to
  121921. */
  121922. attach(camera: ArcRotateCamera): void;
  121923. /**
  121924. * Detaches the behavior from its current arc rotate camera.
  121925. */
  121926. detach(): void;
  121927. private _radiusIsAnimating;
  121928. private _radiusBounceTransition;
  121929. private _animatables;
  121930. private _cachedWheelPrecision;
  121931. /**
  121932. * Checks if the camera radius is at the specified limit. Takes into account animation locks.
  121933. * @param radiusLimit The limit to check against.
  121934. * @return Bool to indicate if at limit.
  121935. */
  121936. private _isRadiusAtLimit;
  121937. /**
  121938. * Applies an animation to the radius of the camera, extending by the radiusDelta.
  121939. * @param radiusDelta The delta by which to animate to. Can be negative.
  121940. */
  121941. private _applyBoundRadiusAnimation;
  121942. /**
  121943. * Removes all animation locks. Allows new animations to be added to any of the camera properties.
  121944. */
  121945. protected _clearAnimationLocks(): void;
  121946. /**
  121947. * Stops and removes all animations that have been applied to the camera
  121948. */
  121949. stopAllAnimations(): void;
  121950. }
  121951. }
  121952. declare module BABYLON {
  121953. /**
  121954. * 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.
  121955. * @see https://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  121956. */
  121957. export class FramingBehavior implements Behavior<ArcRotateCamera> {
  121958. /**
  121959. * Gets the name of the behavior.
  121960. */
  121961. get name(): string;
  121962. private _mode;
  121963. private _radiusScale;
  121964. private _positionScale;
  121965. private _defaultElevation;
  121966. private _elevationReturnTime;
  121967. private _elevationReturnWaitTime;
  121968. private _zoomStopsAnimation;
  121969. private _framingTime;
  121970. /**
  121971. * The easing function used by animations
  121972. */
  121973. static EasingFunction: ExponentialEase;
  121974. /**
  121975. * The easing mode used by animations
  121976. */
  121977. static EasingMode: number;
  121978. /**
  121979. * Sets the current mode used by the behavior
  121980. */
  121981. set mode(mode: number);
  121982. /**
  121983. * Gets current mode used by the behavior.
  121984. */
  121985. get mode(): number;
  121986. /**
  121987. * Sets the scale applied to the radius (1 by default)
  121988. */
  121989. set radiusScale(radius: number);
  121990. /**
  121991. * Gets the scale applied to the radius
  121992. */
  121993. get radiusScale(): number;
  121994. /**
  121995. * Sets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  121996. */
  121997. set positionScale(scale: number);
  121998. /**
  121999. * Gets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  122000. */
  122001. get positionScale(): number;
  122002. /**
  122003. * Sets the angle above/below the horizontal plane to return to when the return to default elevation idle
  122004. * behaviour is triggered, in radians.
  122005. */
  122006. set defaultElevation(elevation: number);
  122007. /**
  122008. * Gets the angle above/below the horizontal plane to return to when the return to default elevation idle
  122009. * behaviour is triggered, in radians.
  122010. */
  122011. get defaultElevation(): number;
  122012. /**
  122013. * Sets the time (in milliseconds) taken to return to the default beta position.
  122014. * Negative value indicates camera should not return to default.
  122015. */
  122016. set elevationReturnTime(speed: number);
  122017. /**
  122018. * Gets the time (in milliseconds) taken to return to the default beta position.
  122019. * Negative value indicates camera should not return to default.
  122020. */
  122021. get elevationReturnTime(): number;
  122022. /**
  122023. * Sets the delay (in milliseconds) taken before the camera returns to the default beta position.
  122024. */
  122025. set elevationReturnWaitTime(time: number);
  122026. /**
  122027. * Gets the delay (in milliseconds) taken before the camera returns to the default beta position.
  122028. */
  122029. get elevationReturnWaitTime(): number;
  122030. /**
  122031. * Sets the flag that indicates if user zooming should stop animation.
  122032. */
  122033. set zoomStopsAnimation(flag: boolean);
  122034. /**
  122035. * Gets the flag that indicates if user zooming should stop animation.
  122036. */
  122037. get zoomStopsAnimation(): boolean;
  122038. /**
  122039. * Sets the transition time when framing the mesh, in milliseconds
  122040. */
  122041. set framingTime(time: number);
  122042. /**
  122043. * Gets the transition time when framing the mesh, in milliseconds
  122044. */
  122045. get framingTime(): number;
  122046. /**
  122047. * Define if the behavior should automatically change the configured
  122048. * camera limits and sensibilities.
  122049. */
  122050. autoCorrectCameraLimitsAndSensibility: boolean;
  122051. private _onPrePointerObservableObserver;
  122052. private _onAfterCheckInputsObserver;
  122053. private _onMeshTargetChangedObserver;
  122054. private _attachedCamera;
  122055. private _isPointerDown;
  122056. private _lastInteractionTime;
  122057. /**
  122058. * Initializes the behavior.
  122059. */
  122060. init(): void;
  122061. /**
  122062. * Attaches the behavior to its arc rotate camera.
  122063. * @param camera Defines the camera to attach the behavior to
  122064. */
  122065. attach(camera: ArcRotateCamera): void;
  122066. /**
  122067. * Detaches the behavior from its current arc rotate camera.
  122068. */
  122069. detach(): void;
  122070. private _animatables;
  122071. private _betaIsAnimating;
  122072. private _betaTransition;
  122073. private _radiusTransition;
  122074. private _vectorTransition;
  122075. /**
  122076. * Targets the given mesh and updates zoom level accordingly.
  122077. * @param mesh The mesh to target.
  122078. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  122079. * @param onAnimationEnd Callback triggered at the end of the framing animation
  122080. */
  122081. zoomOnMesh(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  122082. /**
  122083. * Targets the given mesh with its children and updates zoom level accordingly.
  122084. * @param mesh The mesh to target.
  122085. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  122086. * @param onAnimationEnd Callback triggered at the end of the framing animation
  122087. */
  122088. zoomOnMeshHierarchy(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  122089. /**
  122090. * Targets the given meshes with their children and updates zoom level accordingly.
  122091. * @param meshes The mesh to target.
  122092. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  122093. * @param onAnimationEnd Callback triggered at the end of the framing animation
  122094. */
  122095. zoomOnMeshesHierarchy(meshes: AbstractMesh[], focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  122096. /**
  122097. * Targets the bounding box info defined by its extends and updates zoom level accordingly.
  122098. * @param minimumWorld Determines the smaller position of the bounding box extend
  122099. * @param maximumWorld Determines the bigger position of the bounding box extend
  122100. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  122101. * @param onAnimationEnd Callback triggered at the end of the framing animation
  122102. */
  122103. zoomOnBoundingInfo(minimumWorld: Vector3, maximumWorld: Vector3, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  122104. /**
  122105. * Calculates the lowest radius for the camera based on the bounding box of the mesh.
  122106. * @param mesh The mesh on which to base the calculation. mesh boundingInfo used to estimate necessary
  122107. * frustum width.
  122108. * @return The minimum distance from the primary mesh's center point at which the camera must be kept in order
  122109. * to fully enclose the mesh in the viewing frustum.
  122110. */
  122111. protected _calculateLowerRadiusFromModelBoundingSphere(minimumWorld: Vector3, maximumWorld: Vector3): number;
  122112. /**
  122113. * Keeps the camera above the ground plane. If the user pulls the camera below the ground plane, the camera
  122114. * is automatically returned to its default position (expected to be above ground plane).
  122115. */
  122116. private _maintainCameraAboveGround;
  122117. /**
  122118. * Returns the frustum slope based on the canvas ratio and camera FOV
  122119. * @returns The frustum slope represented as a Vector2 with X and Y slopes
  122120. */
  122121. private _getFrustumSlope;
  122122. /**
  122123. * Removes all animation locks. Allows new animations to be added to any of the arcCamera properties.
  122124. */
  122125. private _clearAnimationLocks;
  122126. /**
  122127. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  122128. */
  122129. private _applyUserInteraction;
  122130. /**
  122131. * Stops and removes all animations that have been applied to the camera
  122132. */
  122133. stopAllAnimations(): void;
  122134. /**
  122135. * Gets a value indicating if the user is moving the camera
  122136. */
  122137. get isUserIsMoving(): boolean;
  122138. /**
  122139. * The camera can move all the way towards the mesh.
  122140. */
  122141. static IgnoreBoundsSizeMode: number;
  122142. /**
  122143. * The camera is not allowed to zoom closer to the mesh than the point at which the adjusted bounding sphere touches the frustum sides
  122144. */
  122145. static FitFrustumSidesMode: number;
  122146. }
  122147. }
  122148. declare module BABYLON {
  122149. /**
  122150. * Base class for Camera Pointer Inputs.
  122151. * See FollowCameraPointersInput in src/Cameras/Inputs/followCameraPointersInput.ts
  122152. * for example usage.
  122153. */
  122154. export abstract class BaseCameraPointersInput implements ICameraInput<Camera> {
  122155. /**
  122156. * Defines the camera the input is attached to.
  122157. */
  122158. abstract camera: Camera;
  122159. /**
  122160. * Whether keyboard modifier keys are pressed at time of last mouse event.
  122161. */
  122162. protected _altKey: boolean;
  122163. protected _ctrlKey: boolean;
  122164. protected _metaKey: boolean;
  122165. protected _shiftKey: boolean;
  122166. /**
  122167. * Which mouse buttons were pressed at time of last mouse event.
  122168. * https://developer.mozilla.org/en-US/docs/Web/API/MouseEvent/buttons
  122169. */
  122170. protected _buttonsPressed: number;
  122171. /**
  122172. * Defines the buttons associated with the input to handle camera move.
  122173. */
  122174. buttons: number[];
  122175. /**
  122176. * Attach the input controls to a specific dom element to get the input from.
  122177. * @param element Defines the element the controls should be listened from
  122178. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  122179. */
  122180. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  122181. /**
  122182. * Detach the current controls from the specified dom element.
  122183. * @param element Defines the element to stop listening the inputs from
  122184. */
  122185. detachControl(element: Nullable<HTMLElement>): void;
  122186. /**
  122187. * Gets the class name of the current input.
  122188. * @returns the class name
  122189. */
  122190. getClassName(): string;
  122191. /**
  122192. * Get the friendly name associated with the input class.
  122193. * @returns the input friendly name
  122194. */
  122195. getSimpleName(): string;
  122196. /**
  122197. * Called on pointer POINTERDOUBLETAP event.
  122198. * Override this method to provide functionality on POINTERDOUBLETAP event.
  122199. */
  122200. protected onDoubleTap(type: string): void;
  122201. /**
  122202. * Called on pointer POINTERMOVE event if only a single touch is active.
  122203. * Override this method to provide functionality.
  122204. */
  122205. protected onTouch(point: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  122206. /**
  122207. * Called on pointer POINTERMOVE event if multiple touches are active.
  122208. * Override this method to provide functionality.
  122209. */
  122210. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  122211. /**
  122212. * Called on JS contextmenu event.
  122213. * Override this method to provide functionality.
  122214. */
  122215. protected onContextMenu(evt: PointerEvent): void;
  122216. /**
  122217. * Called each time a new POINTERDOWN event occurs. Ie, for each button
  122218. * press.
  122219. * Override this method to provide functionality.
  122220. */
  122221. protected onButtonDown(evt: PointerEvent): void;
  122222. /**
  122223. * Called each time a new POINTERUP event occurs. Ie, for each button
  122224. * release.
  122225. * Override this method to provide functionality.
  122226. */
  122227. protected onButtonUp(evt: PointerEvent): void;
  122228. /**
  122229. * Called when window becomes inactive.
  122230. * Override this method to provide functionality.
  122231. */
  122232. protected onLostFocus(): void;
  122233. private _pointerInput;
  122234. private _observer;
  122235. private _onLostFocus;
  122236. private pointA;
  122237. private pointB;
  122238. }
  122239. }
  122240. declare module BABYLON {
  122241. /**
  122242. * Manage the pointers inputs to control an arc rotate camera.
  122243. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  122244. */
  122245. export class ArcRotateCameraPointersInput extends BaseCameraPointersInput {
  122246. /**
  122247. * Defines the camera the input is attached to.
  122248. */
  122249. camera: ArcRotateCamera;
  122250. /**
  122251. * Gets the class name of the current input.
  122252. * @returns the class name
  122253. */
  122254. getClassName(): string;
  122255. /**
  122256. * Defines the buttons associated with the input to handle camera move.
  122257. */
  122258. buttons: number[];
  122259. /**
  122260. * Defines the pointer angular sensibility along the X axis or how fast is
  122261. * the camera rotating.
  122262. */
  122263. angularSensibilityX: number;
  122264. /**
  122265. * Defines the pointer angular sensibility along the Y axis or how fast is
  122266. * the camera rotating.
  122267. */
  122268. angularSensibilityY: number;
  122269. /**
  122270. * Defines the pointer pinch precision or how fast is the camera zooming.
  122271. */
  122272. pinchPrecision: number;
  122273. /**
  122274. * pinchDeltaPercentage will be used instead of pinchPrecision if different
  122275. * from 0.
  122276. * It defines the percentage of current camera.radius to use as delta when
  122277. * pinch zoom is used.
  122278. */
  122279. pinchDeltaPercentage: number;
  122280. /**
  122281. * When useNaturalPinchZoom is true, multi touch zoom will zoom in such
  122282. * that any object in the plane at the camera's target point will scale
  122283. * perfectly with finger motion.
  122284. * Overrides pinchDeltaPercentage and pinchPrecision.
  122285. */
  122286. useNaturalPinchZoom: boolean;
  122287. /**
  122288. * Defines the pointer panning sensibility or how fast is the camera moving.
  122289. */
  122290. panningSensibility: number;
  122291. /**
  122292. * Defines whether panning (2 fingers swipe) is enabled through multitouch.
  122293. */
  122294. multiTouchPanning: boolean;
  122295. /**
  122296. * Defines whether panning is enabled for both pan (2 fingers swipe) and
  122297. * zoom (pinch) through multitouch.
  122298. */
  122299. multiTouchPanAndZoom: boolean;
  122300. /**
  122301. * Revers pinch action direction.
  122302. */
  122303. pinchInwards: boolean;
  122304. private _isPanClick;
  122305. private _twoFingerActivityCount;
  122306. private _isPinching;
  122307. /**
  122308. * Called on pointer POINTERMOVE event if only a single touch is active.
  122309. */
  122310. protected onTouch(point: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  122311. /**
  122312. * Called on pointer POINTERDOUBLETAP event.
  122313. */
  122314. protected onDoubleTap(type: string): void;
  122315. /**
  122316. * Called on pointer POINTERMOVE event if multiple touches are active.
  122317. */
  122318. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  122319. /**
  122320. * Called each time a new POINTERDOWN event occurs. Ie, for each button
  122321. * press.
  122322. */
  122323. protected onButtonDown(evt: PointerEvent): void;
  122324. /**
  122325. * Called each time a new POINTERUP event occurs. Ie, for each button
  122326. * release.
  122327. */
  122328. protected onButtonUp(evt: PointerEvent): void;
  122329. /**
  122330. * Called when window becomes inactive.
  122331. */
  122332. protected onLostFocus(): void;
  122333. }
  122334. }
  122335. declare module BABYLON {
  122336. /**
  122337. * Manage the keyboard inputs to control the movement of an arc rotate camera.
  122338. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  122339. */
  122340. export class ArcRotateCameraKeyboardMoveInput implements ICameraInput<ArcRotateCamera> {
  122341. /**
  122342. * Defines the camera the input is attached to.
  122343. */
  122344. camera: ArcRotateCamera;
  122345. /**
  122346. * Defines the list of key codes associated with the up action (increase alpha)
  122347. */
  122348. keysUp: number[];
  122349. /**
  122350. * Defines the list of key codes associated with the down action (decrease alpha)
  122351. */
  122352. keysDown: number[];
  122353. /**
  122354. * Defines the list of key codes associated with the left action (increase beta)
  122355. */
  122356. keysLeft: number[];
  122357. /**
  122358. * Defines the list of key codes associated with the right action (decrease beta)
  122359. */
  122360. keysRight: number[];
  122361. /**
  122362. * Defines the list of key codes associated with the reset action.
  122363. * Those keys reset the camera to its last stored state (with the method camera.storeState())
  122364. */
  122365. keysReset: number[];
  122366. /**
  122367. * Defines the panning sensibility of the inputs.
  122368. * (How fast is the camera panning)
  122369. */
  122370. panningSensibility: number;
  122371. /**
  122372. * Defines the zooming sensibility of the inputs.
  122373. * (How fast is the camera zooming)
  122374. */
  122375. zoomingSensibility: number;
  122376. /**
  122377. * Defines whether maintaining the alt key down switch the movement mode from
  122378. * orientation to zoom.
  122379. */
  122380. useAltToZoom: boolean;
  122381. /**
  122382. * Rotation speed of the camera
  122383. */
  122384. angularSpeed: number;
  122385. private _keys;
  122386. private _ctrlPressed;
  122387. private _altPressed;
  122388. private _onCanvasBlurObserver;
  122389. private _onKeyboardObserver;
  122390. private _engine;
  122391. private _scene;
  122392. /**
  122393. * Attach the input controls to a specific dom element to get the input from.
  122394. * @param element Defines the element the controls should be listened from
  122395. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  122396. */
  122397. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  122398. /**
  122399. * Detach the current controls from the specified dom element.
  122400. * @param element Defines the element to stop listening the inputs from
  122401. */
  122402. detachControl(element: Nullable<HTMLElement>): void;
  122403. /**
  122404. * Update the current camera state depending on the inputs that have been used this frame.
  122405. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  122406. */
  122407. checkInputs(): void;
  122408. /**
  122409. * Gets the class name of the current intput.
  122410. * @returns the class name
  122411. */
  122412. getClassName(): string;
  122413. /**
  122414. * Get the friendly name associated with the input class.
  122415. * @returns the input friendly name
  122416. */
  122417. getSimpleName(): string;
  122418. }
  122419. }
  122420. declare module BABYLON {
  122421. /**
  122422. * Manage the mouse wheel inputs to control an arc rotate camera.
  122423. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  122424. */
  122425. export class ArcRotateCameraMouseWheelInput implements ICameraInput<ArcRotateCamera> {
  122426. /**
  122427. * Defines the camera the input is attached to.
  122428. */
  122429. camera: ArcRotateCamera;
  122430. /**
  122431. * Gets or Set the mouse wheel precision or how fast is the camera zooming.
  122432. */
  122433. wheelPrecision: number;
  122434. /**
  122435. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  122436. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  122437. */
  122438. wheelDeltaPercentage: number;
  122439. private _wheel;
  122440. private _observer;
  122441. private computeDeltaFromMouseWheelLegacyEvent;
  122442. /**
  122443. * Attach the input controls to a specific dom element to get the input from.
  122444. * @param element Defines the element the controls should be listened from
  122445. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  122446. */
  122447. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  122448. /**
  122449. * Detach the current controls from the specified dom element.
  122450. * @param element Defines the element to stop listening the inputs from
  122451. */
  122452. detachControl(element: Nullable<HTMLElement>): void;
  122453. /**
  122454. * Gets the class name of the current intput.
  122455. * @returns the class name
  122456. */
  122457. getClassName(): string;
  122458. /**
  122459. * Get the friendly name associated with the input class.
  122460. * @returns the input friendly name
  122461. */
  122462. getSimpleName(): string;
  122463. }
  122464. }
  122465. declare module BABYLON {
  122466. /**
  122467. * Default Inputs manager for the ArcRotateCamera.
  122468. * It groups all the default supported inputs for ease of use.
  122469. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  122470. */
  122471. export class ArcRotateCameraInputsManager extends CameraInputsManager<ArcRotateCamera> {
  122472. /**
  122473. * Instantiates a new ArcRotateCameraInputsManager.
  122474. * @param camera Defines the camera the inputs belong to
  122475. */
  122476. constructor(camera: ArcRotateCamera);
  122477. /**
  122478. * Add mouse wheel input support to the input manager.
  122479. * @returns the current input manager
  122480. */
  122481. addMouseWheel(): ArcRotateCameraInputsManager;
  122482. /**
  122483. * Add pointers input support to the input manager.
  122484. * @returns the current input manager
  122485. */
  122486. addPointers(): ArcRotateCameraInputsManager;
  122487. /**
  122488. * Add keyboard input support to the input manager.
  122489. * @returns the current input manager
  122490. */
  122491. addKeyboard(): ArcRotateCameraInputsManager;
  122492. }
  122493. }
  122494. declare module BABYLON {
  122495. /**
  122496. * This represents an orbital type of camera.
  122497. *
  122498. * 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.
  122499. * 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.
  122500. * @see https://doc.babylonjs.com/babylon101/cameras#arc-rotate-camera
  122501. */
  122502. export class ArcRotateCamera extends TargetCamera {
  122503. /**
  122504. * Defines the rotation angle of the camera along the longitudinal axis.
  122505. */
  122506. alpha: number;
  122507. /**
  122508. * Defines the rotation angle of the camera along the latitudinal axis.
  122509. */
  122510. beta: number;
  122511. /**
  122512. * Defines the radius of the camera from it s target point.
  122513. */
  122514. radius: number;
  122515. protected _target: Vector3;
  122516. protected _targetHost: Nullable<AbstractMesh>;
  122517. /**
  122518. * Defines the target point of the camera.
  122519. * The camera looks towards it form the radius distance.
  122520. * Please note that you can set the target to a mesh and thus the target will be copied from mesh.position
  122521. */
  122522. get target(): Vector3;
  122523. set target(value: Vector3);
  122524. /**
  122525. * Define the current local position of the camera in the scene
  122526. */
  122527. get position(): Vector3;
  122528. set position(newPosition: Vector3);
  122529. protected _upToYMatrix: Matrix;
  122530. protected _YToUpMatrix: Matrix;
  122531. /**
  122532. * The vector the camera should consider as up. (default is Vector3(0, 1, 0) as returned by Vector3.Up())
  122533. * Setting this will copy the given vector to the camera's upVector, and set rotation matrices to and from Y up.
  122534. * DO NOT set the up vector using copyFrom or copyFromFloats, as this bypasses setting the above matrices.
  122535. */
  122536. set upVector(vec: Vector3);
  122537. get upVector(): Vector3;
  122538. /**
  122539. * Sets the Y-up to camera up-vector rotation matrix, and the up-vector to Y-up rotation matrix.
  122540. */
  122541. setMatUp(): void;
  122542. /**
  122543. * Current inertia value on the longitudinal axis.
  122544. * The bigger this number the longer it will take for the camera to stop.
  122545. */
  122546. inertialAlphaOffset: number;
  122547. /**
  122548. * Current inertia value on the latitudinal axis.
  122549. * The bigger this number the longer it will take for the camera to stop.
  122550. */
  122551. inertialBetaOffset: number;
  122552. /**
  122553. * Current inertia value on the radius axis.
  122554. * The bigger this number the longer it will take for the camera to stop.
  122555. */
  122556. inertialRadiusOffset: number;
  122557. /**
  122558. * Minimum allowed angle on the longitudinal axis.
  122559. * This can help limiting how the Camera is able to move in the scene.
  122560. */
  122561. lowerAlphaLimit: Nullable<number>;
  122562. /**
  122563. * Maximum allowed angle on the longitudinal axis.
  122564. * This can help limiting how the Camera is able to move in the scene.
  122565. */
  122566. upperAlphaLimit: Nullable<number>;
  122567. /**
  122568. * Minimum allowed angle on the latitudinal axis.
  122569. * This can help limiting how the Camera is able to move in the scene.
  122570. */
  122571. lowerBetaLimit: number;
  122572. /**
  122573. * Maximum allowed angle on the latitudinal axis.
  122574. * This can help limiting how the Camera is able to move in the scene.
  122575. */
  122576. upperBetaLimit: number;
  122577. /**
  122578. * Minimum allowed distance of the camera to the target (The camera can not get closer).
  122579. * This can help limiting how the Camera is able to move in the scene.
  122580. */
  122581. lowerRadiusLimit: Nullable<number>;
  122582. /**
  122583. * Maximum allowed distance of the camera to the target (The camera can not get further).
  122584. * This can help limiting how the Camera is able to move in the scene.
  122585. */
  122586. upperRadiusLimit: Nullable<number>;
  122587. /**
  122588. * Defines the current inertia value used during panning of the camera along the X axis.
  122589. */
  122590. inertialPanningX: number;
  122591. /**
  122592. * Defines the current inertia value used during panning of the camera along the Y axis.
  122593. */
  122594. inertialPanningY: number;
  122595. /**
  122596. * Defines the distance used to consider the camera in pan mode vs pinch/zoom.
  122597. * Basically if your fingers moves away from more than this distance you will be considered
  122598. * in pinch mode.
  122599. */
  122600. pinchToPanMaxDistance: number;
  122601. /**
  122602. * Defines the maximum distance the camera can pan.
  122603. * This could help keeping the cammera always in your scene.
  122604. */
  122605. panningDistanceLimit: Nullable<number>;
  122606. /**
  122607. * Defines the target of the camera before paning.
  122608. */
  122609. panningOriginTarget: Vector3;
  122610. /**
  122611. * Defines the value of the inertia used during panning.
  122612. * 0 would mean stop inertia and one would mean no decelleration at all.
  122613. */
  122614. panningInertia: number;
  122615. /**
  122616. * Gets or Set the pointer angular sensibility along the X axis or how fast is the camera rotating.
  122617. */
  122618. get angularSensibilityX(): number;
  122619. set angularSensibilityX(value: number);
  122620. /**
  122621. * Gets or Set the pointer angular sensibility along the Y axis or how fast is the camera rotating.
  122622. */
  122623. get angularSensibilityY(): number;
  122624. set angularSensibilityY(value: number);
  122625. /**
  122626. * Gets or Set the pointer pinch precision or how fast is the camera zooming.
  122627. */
  122628. get pinchPrecision(): number;
  122629. set pinchPrecision(value: number);
  122630. /**
  122631. * Gets or Set the pointer pinch delta percentage or how fast is the camera zooming.
  122632. * It will be used instead of pinchDeltaPrecision if different from 0.
  122633. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  122634. */
  122635. get pinchDeltaPercentage(): number;
  122636. set pinchDeltaPercentage(value: number);
  122637. /**
  122638. * Gets or Set the pointer use natural pinch zoom to override the pinch precision
  122639. * and pinch delta percentage.
  122640. * When useNaturalPinchZoom is true, multi touch zoom will zoom in such
  122641. * that any object in the plane at the camera's target point will scale
  122642. * perfectly with finger motion.
  122643. */
  122644. get useNaturalPinchZoom(): boolean;
  122645. set useNaturalPinchZoom(value: boolean);
  122646. /**
  122647. * Gets or Set the pointer panning sensibility or how fast is the camera moving.
  122648. */
  122649. get panningSensibility(): number;
  122650. set panningSensibility(value: number);
  122651. /**
  122652. * Gets or Set the list of keyboard keys used to control beta angle in a positive direction.
  122653. */
  122654. get keysUp(): number[];
  122655. set keysUp(value: number[]);
  122656. /**
  122657. * Gets or Set the list of keyboard keys used to control beta angle in a negative direction.
  122658. */
  122659. get keysDown(): number[];
  122660. set keysDown(value: number[]);
  122661. /**
  122662. * Gets or Set the list of keyboard keys used to control alpha angle in a negative direction.
  122663. */
  122664. get keysLeft(): number[];
  122665. set keysLeft(value: number[]);
  122666. /**
  122667. * Gets or Set the list of keyboard keys used to control alpha angle in a positive direction.
  122668. */
  122669. get keysRight(): number[];
  122670. set keysRight(value: number[]);
  122671. /**
  122672. * Gets or Set the mouse wheel precision or how fast is the camera zooming.
  122673. */
  122674. get wheelPrecision(): number;
  122675. set wheelPrecision(value: number);
  122676. /**
  122677. * Gets or Set the mouse wheel delta percentage or how fast is the camera zooming.
  122678. * It will be used instead of pinchDeltaPrecision if different from 0.
  122679. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  122680. */
  122681. get wheelDeltaPercentage(): number;
  122682. set wheelDeltaPercentage(value: number);
  122683. /**
  122684. * Defines how much the radius should be scaled while zomming on a particular mesh (through the zoomOn function)
  122685. */
  122686. zoomOnFactor: number;
  122687. /**
  122688. * Defines a screen offset for the camera position.
  122689. */
  122690. targetScreenOffset: Vector2;
  122691. /**
  122692. * Allows the camera to be completely reversed.
  122693. * If false the camera can not arrive upside down.
  122694. */
  122695. allowUpsideDown: boolean;
  122696. /**
  122697. * Define if double tap/click is used to restore the previously saved state of the camera.
  122698. */
  122699. useInputToRestoreState: boolean;
  122700. /** @hidden */
  122701. _viewMatrix: Matrix;
  122702. /** @hidden */
  122703. _useCtrlForPanning: boolean;
  122704. /** @hidden */
  122705. _panningMouseButton: number;
  122706. /**
  122707. * Defines the input associated to the camera.
  122708. */
  122709. inputs: ArcRotateCameraInputsManager;
  122710. /** @hidden */
  122711. _reset: () => void;
  122712. /**
  122713. * Defines the allowed panning axis.
  122714. */
  122715. panningAxis: Vector3;
  122716. protected _localDirection: Vector3;
  122717. protected _transformedDirection: Vector3;
  122718. private _bouncingBehavior;
  122719. /**
  122720. * Gets the bouncing behavior of the camera if it has been enabled.
  122721. * @see https://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  122722. */
  122723. get bouncingBehavior(): Nullable<BouncingBehavior>;
  122724. /**
  122725. * Defines if the bouncing behavior of the camera is enabled on the camera.
  122726. * @see https://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  122727. */
  122728. get useBouncingBehavior(): boolean;
  122729. set useBouncingBehavior(value: boolean);
  122730. private _framingBehavior;
  122731. /**
  122732. * Gets the framing behavior of the camera if it has been enabled.
  122733. * @see https://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  122734. */
  122735. get framingBehavior(): Nullable<FramingBehavior>;
  122736. /**
  122737. * Defines if the framing behavior of the camera is enabled on the camera.
  122738. * @see https://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  122739. */
  122740. get useFramingBehavior(): boolean;
  122741. set useFramingBehavior(value: boolean);
  122742. private _autoRotationBehavior;
  122743. /**
  122744. * Gets the auto rotation behavior of the camera if it has been enabled.
  122745. * @see https://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  122746. */
  122747. get autoRotationBehavior(): Nullable<AutoRotationBehavior>;
  122748. /**
  122749. * Defines if the auto rotation behavior of the camera is enabled on the camera.
  122750. * @see https://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  122751. */
  122752. get useAutoRotationBehavior(): boolean;
  122753. set useAutoRotationBehavior(value: boolean);
  122754. /**
  122755. * Observable triggered when the mesh target has been changed on the camera.
  122756. */
  122757. onMeshTargetChangedObservable: Observable<Nullable<AbstractMesh>>;
  122758. /**
  122759. * Event raised when the camera is colliding with a mesh.
  122760. */
  122761. onCollide: (collidedMesh: AbstractMesh) => void;
  122762. /**
  122763. * Defines whether the camera should check collision with the objects oh the scene.
  122764. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#how-can-i-do-this
  122765. */
  122766. checkCollisions: boolean;
  122767. /**
  122768. * Defines the collision radius of the camera.
  122769. * This simulates a sphere around the camera.
  122770. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  122771. */
  122772. collisionRadius: Vector3;
  122773. protected _collider: Collider;
  122774. protected _previousPosition: Vector3;
  122775. protected _collisionVelocity: Vector3;
  122776. protected _newPosition: Vector3;
  122777. protected _previousAlpha: number;
  122778. protected _previousBeta: number;
  122779. protected _previousRadius: number;
  122780. protected _collisionTriggered: boolean;
  122781. protected _targetBoundingCenter: Nullable<Vector3>;
  122782. private _computationVector;
  122783. /**
  122784. * Instantiates a new ArcRotateCamera in a given scene
  122785. * @param name Defines the name of the camera
  122786. * @param alpha Defines the camera rotation along the logitudinal axis
  122787. * @param beta Defines the camera rotation along the latitudinal axis
  122788. * @param radius Defines the camera distance from its target
  122789. * @param target Defines the camera target
  122790. * @param scene Defines the scene the camera belongs to
  122791. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  122792. */
  122793. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  122794. /** @hidden */
  122795. _initCache(): void;
  122796. /** @hidden */
  122797. _updateCache(ignoreParentClass?: boolean): void;
  122798. protected _getTargetPosition(): Vector3;
  122799. private _storedAlpha;
  122800. private _storedBeta;
  122801. private _storedRadius;
  122802. private _storedTarget;
  122803. private _storedTargetScreenOffset;
  122804. /**
  122805. * Stores the current state of the camera (alpha, beta, radius and target)
  122806. * @returns the camera itself
  122807. */
  122808. storeState(): Camera;
  122809. /**
  122810. * @hidden
  122811. * Restored camera state. You must call storeState() first
  122812. */
  122813. _restoreStateValues(): boolean;
  122814. /** @hidden */
  122815. _isSynchronizedViewMatrix(): boolean;
  122816. /**
  122817. * Attached controls to the current camera.
  122818. * @param element Defines the element the controls should be listened from
  122819. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  122820. * @param useCtrlForPanning Defines whether ctrl is used for paning within the controls
  122821. * @param panningMouseButton Defines whether panning is allowed through mouse click button
  122822. */
  122823. attachControl(element: HTMLElement, noPreventDefault?: boolean, useCtrlForPanning?: boolean, panningMouseButton?: number): void;
  122824. /**
  122825. * Detach the current controls from the camera.
  122826. * The camera will stop reacting to inputs.
  122827. * @param element Defines the element to stop listening the inputs from
  122828. */
  122829. detachControl(element: HTMLElement): void;
  122830. /** @hidden */
  122831. _checkInputs(): void;
  122832. protected _checkLimits(): void;
  122833. /**
  122834. * Rebuilds angles (alpha, beta) and radius from the give position and target
  122835. */
  122836. rebuildAnglesAndRadius(): void;
  122837. /**
  122838. * Use a position to define the current camera related information like alpha, beta and radius
  122839. * @param position Defines the position to set the camera at
  122840. */
  122841. setPosition(position: Vector3): void;
  122842. /**
  122843. * Defines the target the camera should look at.
  122844. * This will automatically adapt alpha beta and radius to fit within the new target.
  122845. * @param target Defines the new target as a Vector or a mesh
  122846. * @param toBoundingCenter In case of a mesh target, defines whether to target the mesh position or its bounding information center
  122847. * @param allowSamePosition If false, prevents reapplying the new computed position if it is identical to the current one (optim)
  122848. */
  122849. setTarget(target: AbstractMesh | Vector3, toBoundingCenter?: boolean, allowSamePosition?: boolean): void;
  122850. /** @hidden */
  122851. _getViewMatrix(): Matrix;
  122852. protected _onCollisionPositionChange: (collisionId: number, newPosition: Vector3, collidedMesh?: Nullable<AbstractMesh>) => void;
  122853. /**
  122854. * Zooms on a mesh to be at the min distance where we could see it fully in the current viewport.
  122855. * @param meshes Defines the mesh to zoom on
  122856. * @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)
  122857. */
  122858. zoomOn(meshes?: AbstractMesh[], doNotUpdateMaxZ?: boolean): void;
  122859. /**
  122860. * Focus on a mesh or a bounding box. This adapts the target and maxRadius if necessary but does not update the current radius.
  122861. * The target will be changed but the radius
  122862. * @param meshesOrMinMaxVectorAndDistance Defines the mesh or bounding info to focus on
  122863. * @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)
  122864. */
  122865. focusOn(meshesOrMinMaxVectorAndDistance: AbstractMesh[] | {
  122866. min: Vector3;
  122867. max: Vector3;
  122868. distance: number;
  122869. }, doNotUpdateMaxZ?: boolean): void;
  122870. /**
  122871. * @override
  122872. * Override Camera.createRigCamera
  122873. */
  122874. createRigCamera(name: string, cameraIndex: number): Camera;
  122875. /**
  122876. * @hidden
  122877. * @override
  122878. * Override Camera._updateRigCameras
  122879. */
  122880. _updateRigCameras(): void;
  122881. /**
  122882. * Destroy the camera and release the current resources hold by it.
  122883. */
  122884. dispose(): void;
  122885. /**
  122886. * Gets the current object class name.
  122887. * @return the class name
  122888. */
  122889. getClassName(): string;
  122890. }
  122891. }
  122892. declare module BABYLON {
  122893. /**
  122894. * The autoRotation behavior (AutoRotationBehavior) is designed to create a smooth rotation of an ArcRotateCamera when there is no user interaction.
  122895. * @see https://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  122896. */
  122897. export class AutoRotationBehavior implements Behavior<ArcRotateCamera> {
  122898. /**
  122899. * Gets the name of the behavior.
  122900. */
  122901. get name(): string;
  122902. private _zoomStopsAnimation;
  122903. private _idleRotationSpeed;
  122904. private _idleRotationWaitTime;
  122905. private _idleRotationSpinupTime;
  122906. /**
  122907. * Sets the flag that indicates if user zooming should stop animation.
  122908. */
  122909. set zoomStopsAnimation(flag: boolean);
  122910. /**
  122911. * Gets the flag that indicates if user zooming should stop animation.
  122912. */
  122913. get zoomStopsAnimation(): boolean;
  122914. /**
  122915. * Sets the default speed at which the camera rotates around the model.
  122916. */
  122917. set idleRotationSpeed(speed: number);
  122918. /**
  122919. * Gets the default speed at which the camera rotates around the model.
  122920. */
  122921. get idleRotationSpeed(): number;
  122922. /**
  122923. * Sets the time (in milliseconds) to wait after user interaction before the camera starts rotating.
  122924. */
  122925. set idleRotationWaitTime(time: number);
  122926. /**
  122927. * Gets the time (milliseconds) to wait after user interaction before the camera starts rotating.
  122928. */
  122929. get idleRotationWaitTime(): number;
  122930. /**
  122931. * Sets the time (milliseconds) to take to spin up to the full idle rotation speed.
  122932. */
  122933. set idleRotationSpinupTime(time: number);
  122934. /**
  122935. * Gets the time (milliseconds) to take to spin up to the full idle rotation speed.
  122936. */
  122937. get idleRotationSpinupTime(): number;
  122938. /**
  122939. * Gets a value indicating if the camera is currently rotating because of this behavior
  122940. */
  122941. get rotationInProgress(): boolean;
  122942. private _onPrePointerObservableObserver;
  122943. private _onAfterCheckInputsObserver;
  122944. private _attachedCamera;
  122945. private _isPointerDown;
  122946. private _lastFrameTime;
  122947. private _lastInteractionTime;
  122948. private _cameraRotationSpeed;
  122949. /**
  122950. * Initializes the behavior.
  122951. */
  122952. init(): void;
  122953. /**
  122954. * Attaches the behavior to its arc rotate camera.
  122955. * @param camera Defines the camera to attach the behavior to
  122956. */
  122957. attach(camera: ArcRotateCamera): void;
  122958. /**
  122959. * Detaches the behavior from its current arc rotate camera.
  122960. */
  122961. detach(): void;
  122962. /**
  122963. * Returns true if user is scrolling.
  122964. * @return true if user is scrolling.
  122965. */
  122966. private _userIsZooming;
  122967. private _lastFrameRadius;
  122968. private _shouldAnimationStopForInteraction;
  122969. /**
  122970. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  122971. */
  122972. private _applyUserInteraction;
  122973. private _userIsMoving;
  122974. }
  122975. }
  122976. declare module BABYLON {
  122977. /**
  122978. * A behavior that when attached to a mesh will will place a specified node on the meshes face pointing towards the camera
  122979. */
  122980. export class AttachToBoxBehavior implements Behavior<Mesh> {
  122981. private ui;
  122982. /**
  122983. * The name of the behavior
  122984. */
  122985. name: string;
  122986. /**
  122987. * The distance away from the face of the mesh that the UI should be attached to (default: 0.15)
  122988. */
  122989. distanceAwayFromFace: number;
  122990. /**
  122991. * The distance from the bottom of the face that the UI should be attached to (default: 0.15)
  122992. */
  122993. distanceAwayFromBottomOfFace: number;
  122994. private _faceVectors;
  122995. private _target;
  122996. private _scene;
  122997. private _onRenderObserver;
  122998. private _tmpMatrix;
  122999. private _tmpVector;
  123000. /**
  123001. * Creates the AttachToBoxBehavior, used to attach UI to the closest face of the box to a camera
  123002. * @param ui The transform node that should be attched to the mesh
  123003. */
  123004. constructor(ui: TransformNode);
  123005. /**
  123006. * Initializes the behavior
  123007. */
  123008. init(): void;
  123009. private _closestFace;
  123010. private _zeroVector;
  123011. private _lookAtTmpMatrix;
  123012. private _lookAtToRef;
  123013. /**
  123014. * Attaches the AttachToBoxBehavior to the passed in mesh
  123015. * @param target The mesh that the specified node will be attached to
  123016. */
  123017. attach(target: Mesh): void;
  123018. /**
  123019. * Detaches the behavior from the mesh
  123020. */
  123021. detach(): void;
  123022. }
  123023. }
  123024. declare module BABYLON {
  123025. /**
  123026. * A behavior that when attached to a mesh will allow the mesh to fade in and out
  123027. */
  123028. export class FadeInOutBehavior implements Behavior<Mesh> {
  123029. /**
  123030. * Time in milliseconds to delay before fading in (Default: 0)
  123031. */
  123032. delay: number;
  123033. /**
  123034. * Time in milliseconds for the mesh to fade in (Default: 300)
  123035. */
  123036. fadeInTime: number;
  123037. private _millisecondsPerFrame;
  123038. private _hovered;
  123039. private _hoverValue;
  123040. private _ownerNode;
  123041. /**
  123042. * Instatiates the FadeInOutBehavior
  123043. */
  123044. constructor();
  123045. /**
  123046. * The name of the behavior
  123047. */
  123048. get name(): string;
  123049. /**
  123050. * Initializes the behavior
  123051. */
  123052. init(): void;
  123053. /**
  123054. * Attaches the fade behavior on the passed in mesh
  123055. * @param ownerNode The mesh that will be faded in/out once attached
  123056. */
  123057. attach(ownerNode: Mesh): void;
  123058. /**
  123059. * Detaches the behavior from the mesh
  123060. */
  123061. detach(): void;
  123062. /**
  123063. * Triggers the mesh to begin fading in or out
  123064. * @param value if the object should fade in or out (true to fade in)
  123065. */
  123066. fadeIn(value: boolean): void;
  123067. private _update;
  123068. private _setAllVisibility;
  123069. }
  123070. }
  123071. declare module BABYLON {
  123072. /**
  123073. * Class containing a set of static utilities functions for managing Pivots
  123074. * @hidden
  123075. */
  123076. export class PivotTools {
  123077. private static _PivotCached;
  123078. private static _OldPivotPoint;
  123079. private static _PivotTranslation;
  123080. private static _PivotTmpVector;
  123081. /** @hidden */
  123082. static _RemoveAndStorePivotPoint(mesh: AbstractMesh): void;
  123083. /** @hidden */
  123084. static _RestorePivotPoint(mesh: AbstractMesh): void;
  123085. }
  123086. }
  123087. declare module BABYLON {
  123088. /**
  123089. * Class containing static functions to help procedurally build meshes
  123090. */
  123091. export class PlaneBuilder {
  123092. /**
  123093. * Creates a plane mesh
  123094. * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
  123095. * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value of `size`)
  123096. * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane
  123097. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  123098. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  123099. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  123100. * @param name defines the name of the mesh
  123101. * @param options defines the options used to create the mesh
  123102. * @param scene defines the hosting scene
  123103. * @returns the plane mesh
  123104. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  123105. */
  123106. static CreatePlane(name: string, options: {
  123107. size?: number;
  123108. width?: number;
  123109. height?: number;
  123110. sideOrientation?: number;
  123111. frontUVs?: Vector4;
  123112. backUVs?: Vector4;
  123113. updatable?: boolean;
  123114. sourcePlane?: Plane;
  123115. }, scene?: Nullable<Scene>): Mesh;
  123116. }
  123117. }
  123118. declare module BABYLON {
  123119. /**
  123120. * A behavior that when attached to a mesh will allow the mesh to be dragged around the screen based on pointer events
  123121. */
  123122. export class PointerDragBehavior implements Behavior<AbstractMesh> {
  123123. private static _AnyMouseID;
  123124. /**
  123125. * Abstract mesh the behavior is set on
  123126. */
  123127. attachedNode: AbstractMesh;
  123128. private _dragPlane;
  123129. private _scene;
  123130. private _pointerObserver;
  123131. private _beforeRenderObserver;
  123132. private static _planeScene;
  123133. private _useAlternatePickedPointAboveMaxDragAngleDragSpeed;
  123134. /**
  123135. * 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)
  123136. */
  123137. maxDragAngle: number;
  123138. /**
  123139. * @hidden
  123140. */
  123141. _useAlternatePickedPointAboveMaxDragAngle: boolean;
  123142. /**
  123143. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  123144. */
  123145. currentDraggingPointerID: number;
  123146. /**
  123147. * The last position where the pointer hit the drag plane in world space
  123148. */
  123149. lastDragPosition: Vector3;
  123150. /**
  123151. * If the behavior is currently in a dragging state
  123152. */
  123153. dragging: boolean;
  123154. /**
  123155. * 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)
  123156. */
  123157. dragDeltaRatio: number;
  123158. /**
  123159. * If the drag plane orientation should be updated during the dragging (Default: true)
  123160. */
  123161. updateDragPlane: boolean;
  123162. private _debugMode;
  123163. private _moving;
  123164. /**
  123165. * Fires each time the attached mesh is dragged with the pointer
  123166. * * delta between last drag position and current drag position in world space
  123167. * * dragDistance along the drag axis
  123168. * * dragPlaneNormal normal of the current drag plane used during the drag
  123169. * * dragPlanePoint in world space where the drag intersects the drag plane
  123170. */
  123171. onDragObservable: Observable<{
  123172. delta: Vector3;
  123173. dragPlanePoint: Vector3;
  123174. dragPlaneNormal: Vector3;
  123175. dragDistance: number;
  123176. pointerId: number;
  123177. }>;
  123178. /**
  123179. * Fires each time a drag begins (eg. mouse down on mesh)
  123180. */
  123181. onDragStartObservable: Observable<{
  123182. dragPlanePoint: Vector3;
  123183. pointerId: number;
  123184. }>;
  123185. /**
  123186. * Fires each time a drag ends (eg. mouse release after drag)
  123187. */
  123188. onDragEndObservable: Observable<{
  123189. dragPlanePoint: Vector3;
  123190. pointerId: number;
  123191. }>;
  123192. /**
  123193. * If the attached mesh should be moved when dragged
  123194. */
  123195. moveAttached: boolean;
  123196. /**
  123197. * If the drag behavior will react to drag events (Default: true)
  123198. */
  123199. enabled: boolean;
  123200. /**
  123201. * If pointer events should start and release the drag (Default: true)
  123202. */
  123203. startAndReleaseDragOnPointerEvents: boolean;
  123204. /**
  123205. * If camera controls should be detached during the drag
  123206. */
  123207. detachCameraControls: boolean;
  123208. /**
  123209. * If set, the drag plane/axis will be rotated based on the attached mesh's world rotation (Default: true)
  123210. */
  123211. useObjectOrientationForDragging: boolean;
  123212. private _options;
  123213. /**
  123214. * Gets the options used by the behavior
  123215. */
  123216. get options(): {
  123217. dragAxis?: Vector3;
  123218. dragPlaneNormal?: Vector3;
  123219. };
  123220. /**
  123221. * Sets the options used by the behavior
  123222. */
  123223. set options(options: {
  123224. dragAxis?: Vector3;
  123225. dragPlaneNormal?: Vector3;
  123226. });
  123227. /**
  123228. * Creates a pointer drag behavior that can be attached to a mesh
  123229. * @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)
  123230. */
  123231. constructor(options?: {
  123232. dragAxis?: Vector3;
  123233. dragPlaneNormal?: Vector3;
  123234. });
  123235. /**
  123236. * Predicate to determine if it is valid to move the object to a new position when it is moved
  123237. */
  123238. validateDrag: (targetPosition: Vector3) => boolean;
  123239. /**
  123240. * The name of the behavior
  123241. */
  123242. get name(): string;
  123243. /**
  123244. * Initializes the behavior
  123245. */
  123246. init(): void;
  123247. private _tmpVector;
  123248. private _alternatePickedPoint;
  123249. private _worldDragAxis;
  123250. private _targetPosition;
  123251. private _attachedElement;
  123252. /**
  123253. * Attaches the drag behavior the passed in mesh
  123254. * @param ownerNode The mesh that will be dragged around once attached
  123255. * @param predicate Predicate to use for pick filtering
  123256. */
  123257. attach(ownerNode: AbstractMesh, predicate?: (m: AbstractMesh) => boolean): void;
  123258. /**
  123259. * Force relase the drag action by code.
  123260. */
  123261. releaseDrag(): void;
  123262. private _startDragRay;
  123263. private _lastPointerRay;
  123264. /**
  123265. * Simulates the start of a pointer drag event on the behavior
  123266. * @param pointerId pointerID of the pointer that should be simulated (Default: Any mouse pointer ID)
  123267. * @param fromRay initial ray of the pointer to be simulated (Default: Ray from camera to attached mesh)
  123268. * @param startPickedPoint picked point of the pointer to be simulated (Default: attached mesh position)
  123269. */
  123270. startDrag(pointerId?: number, fromRay?: Ray, startPickedPoint?: Vector3): void;
  123271. private _startDrag;
  123272. private _dragDelta;
  123273. private _moveDrag;
  123274. private _pickWithRayOnDragPlane;
  123275. private _pointA;
  123276. private _pointC;
  123277. private _localAxis;
  123278. private _lookAt;
  123279. private _updateDragPlanePosition;
  123280. /**
  123281. * Detaches the behavior from the mesh
  123282. */
  123283. detach(): void;
  123284. }
  123285. }
  123286. declare module BABYLON {
  123287. /**
  123288. * A behavior that when attached to a mesh will allow the mesh to be scaled
  123289. */
  123290. export class MultiPointerScaleBehavior implements Behavior<Mesh> {
  123291. private _dragBehaviorA;
  123292. private _dragBehaviorB;
  123293. private _startDistance;
  123294. private _initialScale;
  123295. private _targetScale;
  123296. private _ownerNode;
  123297. private _sceneRenderObserver;
  123298. /**
  123299. * Instantiate a new behavior that when attached to a mesh will allow the mesh to be scaled
  123300. */
  123301. constructor();
  123302. /**
  123303. * The name of the behavior
  123304. */
  123305. get name(): string;
  123306. /**
  123307. * Initializes the behavior
  123308. */
  123309. init(): void;
  123310. private _getCurrentDistance;
  123311. /**
  123312. * Attaches the scale behavior the passed in mesh
  123313. * @param ownerNode The mesh that will be scaled around once attached
  123314. */
  123315. attach(ownerNode: Mesh): void;
  123316. /**
  123317. * Detaches the behavior from the mesh
  123318. */
  123319. detach(): void;
  123320. }
  123321. }
  123322. declare module BABYLON {
  123323. /**
  123324. * 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
  123325. */
  123326. export class SixDofDragBehavior implements Behavior<Mesh> {
  123327. private static _virtualScene;
  123328. private _ownerNode;
  123329. private _sceneRenderObserver;
  123330. private _scene;
  123331. private _targetPosition;
  123332. private _virtualOriginMesh;
  123333. private _virtualDragMesh;
  123334. private _pointerObserver;
  123335. private _moving;
  123336. private _startingOrientation;
  123337. private _attachedElement;
  123338. /**
  123339. * 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)
  123340. */
  123341. private zDragFactor;
  123342. /**
  123343. * If the object should rotate to face the drag origin
  123344. */
  123345. rotateDraggedObject: boolean;
  123346. /**
  123347. * If the behavior is currently in a dragging state
  123348. */
  123349. dragging: boolean;
  123350. /**
  123351. * 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)
  123352. */
  123353. dragDeltaRatio: number;
  123354. /**
  123355. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  123356. */
  123357. currentDraggingPointerID: number;
  123358. /**
  123359. * If camera controls should be detached during the drag
  123360. */
  123361. detachCameraControls: boolean;
  123362. /**
  123363. * Fires each time a drag starts
  123364. */
  123365. onDragStartObservable: Observable<{}>;
  123366. /**
  123367. * Fires each time a drag ends (eg. mouse release after drag)
  123368. */
  123369. onDragEndObservable: Observable<{}>;
  123370. /**
  123371. * 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
  123372. */
  123373. constructor();
  123374. /**
  123375. * The name of the behavior
  123376. */
  123377. get name(): string;
  123378. /**
  123379. * Initializes the behavior
  123380. */
  123381. init(): void;
  123382. /**
  123383. * In the case of multiplea active cameras, the cameraToUseForPointers should be used if set instead of active camera
  123384. */
  123385. private get _pointerCamera();
  123386. /**
  123387. * Attaches the scale behavior the passed in mesh
  123388. * @param ownerNode The mesh that will be scaled around once attached
  123389. */
  123390. attach(ownerNode: Mesh): void;
  123391. /**
  123392. * Detaches the behavior from the mesh
  123393. */
  123394. detach(): void;
  123395. }
  123396. }
  123397. declare module BABYLON {
  123398. /**
  123399. * Class used to apply inverse kinematics to bones
  123400. * @see https://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#boneikcontroller
  123401. */
  123402. export class BoneIKController {
  123403. private static _tmpVecs;
  123404. private static _tmpQuat;
  123405. private static _tmpMats;
  123406. /**
  123407. * Gets or sets the target mesh
  123408. */
  123409. targetMesh: AbstractMesh;
  123410. /** Gets or sets the mesh used as pole */
  123411. poleTargetMesh: AbstractMesh;
  123412. /**
  123413. * Gets or sets the bone used as pole
  123414. */
  123415. poleTargetBone: Nullable<Bone>;
  123416. /**
  123417. * Gets or sets the target position
  123418. */
  123419. targetPosition: Vector3;
  123420. /**
  123421. * Gets or sets the pole target position
  123422. */
  123423. poleTargetPosition: Vector3;
  123424. /**
  123425. * Gets or sets the pole target local offset
  123426. */
  123427. poleTargetLocalOffset: Vector3;
  123428. /**
  123429. * Gets or sets the pole angle
  123430. */
  123431. poleAngle: number;
  123432. /**
  123433. * Gets or sets the mesh associated with the controller
  123434. */
  123435. mesh: AbstractMesh;
  123436. /**
  123437. * 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)
  123438. */
  123439. slerpAmount: number;
  123440. private _bone1Quat;
  123441. private _bone1Mat;
  123442. private _bone2Ang;
  123443. private _bone1;
  123444. private _bone2;
  123445. private _bone1Length;
  123446. private _bone2Length;
  123447. private _maxAngle;
  123448. private _maxReach;
  123449. private _rightHandedSystem;
  123450. private _bendAxis;
  123451. private _slerping;
  123452. private _adjustRoll;
  123453. /**
  123454. * Gets or sets maximum allowed angle
  123455. */
  123456. get maxAngle(): number;
  123457. set maxAngle(value: number);
  123458. /**
  123459. * Creates a new BoneIKController
  123460. * @param mesh defines the mesh to control
  123461. * @param bone defines the bone to control
  123462. * @param options defines options to set up the controller
  123463. */
  123464. constructor(mesh: AbstractMesh, bone: Bone, options?: {
  123465. targetMesh?: AbstractMesh;
  123466. poleTargetMesh?: AbstractMesh;
  123467. poleTargetBone?: Bone;
  123468. poleTargetLocalOffset?: Vector3;
  123469. poleAngle?: number;
  123470. bendAxis?: Vector3;
  123471. maxAngle?: number;
  123472. slerpAmount?: number;
  123473. });
  123474. private _setMaxAngle;
  123475. /**
  123476. * Force the controller to update the bones
  123477. */
  123478. update(): void;
  123479. }
  123480. }
  123481. declare module BABYLON {
  123482. /**
  123483. * Class used to make a bone look toward a point in space
  123484. * @see https://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#bonelookcontroller
  123485. */
  123486. export class BoneLookController {
  123487. private static _tmpVecs;
  123488. private static _tmpQuat;
  123489. private static _tmpMats;
  123490. /**
  123491. * The target Vector3 that the bone will look at
  123492. */
  123493. target: Vector3;
  123494. /**
  123495. * The mesh that the bone is attached to
  123496. */
  123497. mesh: AbstractMesh;
  123498. /**
  123499. * The bone that will be looking to the target
  123500. */
  123501. bone: Bone;
  123502. /**
  123503. * The up axis of the coordinate system that is used when the bone is rotated
  123504. */
  123505. upAxis: Vector3;
  123506. /**
  123507. * The space that the up axis is in - Space.BONE, Space.LOCAL (default), or Space.WORLD
  123508. */
  123509. upAxisSpace: Space;
  123510. /**
  123511. * Used to make an adjustment to the yaw of the bone
  123512. */
  123513. adjustYaw: number;
  123514. /**
  123515. * Used to make an adjustment to the pitch of the bone
  123516. */
  123517. adjustPitch: number;
  123518. /**
  123519. * Used to make an adjustment to the roll of the bone
  123520. */
  123521. adjustRoll: number;
  123522. /**
  123523. * 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)
  123524. */
  123525. slerpAmount: number;
  123526. private _minYaw;
  123527. private _maxYaw;
  123528. private _minPitch;
  123529. private _maxPitch;
  123530. private _minYawSin;
  123531. private _minYawCos;
  123532. private _maxYawSin;
  123533. private _maxYawCos;
  123534. private _midYawConstraint;
  123535. private _minPitchTan;
  123536. private _maxPitchTan;
  123537. private _boneQuat;
  123538. private _slerping;
  123539. private _transformYawPitch;
  123540. private _transformYawPitchInv;
  123541. private _firstFrameSkipped;
  123542. private _yawRange;
  123543. private _fowardAxis;
  123544. /**
  123545. * Gets or sets the minimum yaw angle that the bone can look to
  123546. */
  123547. get minYaw(): number;
  123548. set minYaw(value: number);
  123549. /**
  123550. * Gets or sets the maximum yaw angle that the bone can look to
  123551. */
  123552. get maxYaw(): number;
  123553. set maxYaw(value: number);
  123554. /**
  123555. * Gets or sets the minimum pitch angle that the bone can look to
  123556. */
  123557. get minPitch(): number;
  123558. set minPitch(value: number);
  123559. /**
  123560. * Gets or sets the maximum pitch angle that the bone can look to
  123561. */
  123562. get maxPitch(): number;
  123563. set maxPitch(value: number);
  123564. /**
  123565. * Create a BoneLookController
  123566. * @param mesh the mesh that the bone belongs to
  123567. * @param bone the bone that will be looking to the target
  123568. * @param target the target Vector3 to look at
  123569. * @param options optional settings:
  123570. * * maxYaw: the maximum angle the bone will yaw to
  123571. * * minYaw: the minimum angle the bone will yaw to
  123572. * * maxPitch: the maximum angle the bone will pitch to
  123573. * * minPitch: the minimum angle the bone will yaw to
  123574. * * slerpAmount: set the between 0 and 1 to make the bone slerp to the target.
  123575. * * upAxis: the up axis of the coordinate system
  123576. * * upAxisSpace: the space that the up axis is in - Space.BONE, Space.LOCAL (default), or Space.WORLD.
  123577. * * yawAxis: set yawAxis if the bone does not yaw on the y axis
  123578. * * pitchAxis: set pitchAxis if the bone does not pitch on the x axis
  123579. * * adjustYaw: used to make an adjustment to the yaw of the bone
  123580. * * adjustPitch: used to make an adjustment to the pitch of the bone
  123581. * * adjustRoll: used to make an adjustment to the roll of the bone
  123582. **/
  123583. constructor(mesh: AbstractMesh, bone: Bone, target: Vector3, options?: {
  123584. maxYaw?: number;
  123585. minYaw?: number;
  123586. maxPitch?: number;
  123587. minPitch?: number;
  123588. slerpAmount?: number;
  123589. upAxis?: Vector3;
  123590. upAxisSpace?: Space;
  123591. yawAxis?: Vector3;
  123592. pitchAxis?: Vector3;
  123593. adjustYaw?: number;
  123594. adjustPitch?: number;
  123595. adjustRoll?: number;
  123596. });
  123597. /**
  123598. * Update the bone to look at the target. This should be called before the scene is rendered (use scene.registerBeforeRender())
  123599. */
  123600. update(): void;
  123601. private _getAngleDiff;
  123602. private _getAngleBetween;
  123603. private _isAngleBetween;
  123604. }
  123605. }
  123606. declare module BABYLON {
  123607. /**
  123608. * Manage the gamepad inputs to control an arc rotate camera.
  123609. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  123610. */
  123611. export class ArcRotateCameraGamepadInput implements ICameraInput<ArcRotateCamera> {
  123612. /**
  123613. * Defines the camera the input is attached to.
  123614. */
  123615. camera: ArcRotateCamera;
  123616. /**
  123617. * Defines the gamepad the input is gathering event from.
  123618. */
  123619. gamepad: Nullable<Gamepad>;
  123620. /**
  123621. * Defines the gamepad rotation sensiblity.
  123622. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  123623. */
  123624. gamepadRotationSensibility: number;
  123625. /**
  123626. * Defines the gamepad move sensiblity.
  123627. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  123628. */
  123629. gamepadMoveSensibility: number;
  123630. private _yAxisScale;
  123631. /**
  123632. * Gets or sets a boolean indicating that Yaxis (for right stick) should be inverted
  123633. */
  123634. get invertYAxis(): boolean;
  123635. set invertYAxis(value: boolean);
  123636. private _onGamepadConnectedObserver;
  123637. private _onGamepadDisconnectedObserver;
  123638. /**
  123639. * Attach the input controls to a specific dom element to get the input from.
  123640. * @param element Defines the element the controls should be listened from
  123641. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  123642. */
  123643. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  123644. /**
  123645. * Detach the current controls from the specified dom element.
  123646. * @param element Defines the element to stop listening the inputs from
  123647. */
  123648. detachControl(element: Nullable<HTMLElement>): void;
  123649. /**
  123650. * Update the current camera state depending on the inputs that have been used this frame.
  123651. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  123652. */
  123653. checkInputs(): void;
  123654. /**
  123655. * Gets the class name of the current intput.
  123656. * @returns the class name
  123657. */
  123658. getClassName(): string;
  123659. /**
  123660. * Get the friendly name associated with the input class.
  123661. * @returns the input friendly name
  123662. */
  123663. getSimpleName(): string;
  123664. }
  123665. }
  123666. declare module BABYLON {
  123667. interface ArcRotateCameraInputsManager {
  123668. /**
  123669. * Add orientation input support to the input manager.
  123670. * @returns the current input manager
  123671. */
  123672. addVRDeviceOrientation(): ArcRotateCameraInputsManager;
  123673. }
  123674. /**
  123675. * Manage the device orientation inputs (gyroscope) to control an arc rotate camera.
  123676. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  123677. */
  123678. export class ArcRotateCameraVRDeviceOrientationInput implements ICameraInput<ArcRotateCamera> {
  123679. /**
  123680. * Defines the camera the input is attached to.
  123681. */
  123682. camera: ArcRotateCamera;
  123683. /**
  123684. * Defines a correction factor applied on the alpha value retrieved from the orientation events.
  123685. */
  123686. alphaCorrection: number;
  123687. /**
  123688. * Defines a correction factor applied on the gamma value retrieved from the orientation events.
  123689. */
  123690. gammaCorrection: number;
  123691. private _alpha;
  123692. private _gamma;
  123693. private _dirty;
  123694. private _deviceOrientationHandler;
  123695. /**
  123696. * Instantiate a new ArcRotateCameraVRDeviceOrientationInput.
  123697. */
  123698. constructor();
  123699. /**
  123700. * Attach the input controls to a specific dom element to get the input from.
  123701. * @param element Defines the element the controls should be listened from
  123702. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  123703. */
  123704. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  123705. /** @hidden */
  123706. _onOrientationEvent(evt: DeviceOrientationEvent): void;
  123707. /**
  123708. * Update the current camera state depending on the inputs that have been used this frame.
  123709. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  123710. */
  123711. checkInputs(): void;
  123712. /**
  123713. * Detach the current controls from the specified dom element.
  123714. * @param element Defines the element to stop listening the inputs from
  123715. */
  123716. detachControl(element: Nullable<HTMLElement>): void;
  123717. /**
  123718. * Gets the class name of the current intput.
  123719. * @returns the class name
  123720. */
  123721. getClassName(): string;
  123722. /**
  123723. * Get the friendly name associated with the input class.
  123724. * @returns the input friendly name
  123725. */
  123726. getSimpleName(): string;
  123727. }
  123728. }
  123729. declare module BABYLON {
  123730. /**
  123731. * Listen to mouse events to control the camera.
  123732. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  123733. */
  123734. export class FlyCameraMouseInput implements ICameraInput<FlyCamera> {
  123735. /**
  123736. * Defines the camera the input is attached to.
  123737. */
  123738. camera: FlyCamera;
  123739. /**
  123740. * Defines if touch is enabled. (Default is true.)
  123741. */
  123742. touchEnabled: boolean;
  123743. /**
  123744. * Defines the buttons associated with the input to handle camera rotation.
  123745. */
  123746. buttons: number[];
  123747. /**
  123748. * Assign buttons for Yaw control.
  123749. */
  123750. buttonsYaw: number[];
  123751. /**
  123752. * Assign buttons for Pitch control.
  123753. */
  123754. buttonsPitch: number[];
  123755. /**
  123756. * Assign buttons for Roll control.
  123757. */
  123758. buttonsRoll: number[];
  123759. /**
  123760. * Detect if any button is being pressed while mouse is moved.
  123761. * -1 = Mouse locked.
  123762. * 0 = Left button.
  123763. * 1 = Middle Button.
  123764. * 2 = Right Button.
  123765. */
  123766. activeButton: number;
  123767. /**
  123768. * Defines the pointer's angular sensibility, to control the camera rotation speed.
  123769. * Higher values reduce its sensitivity.
  123770. */
  123771. angularSensibility: number;
  123772. private _mousemoveCallback;
  123773. private _observer;
  123774. private _rollObserver;
  123775. private previousPosition;
  123776. private noPreventDefault;
  123777. private element;
  123778. /**
  123779. * Listen to mouse events to control the camera.
  123780. * @param touchEnabled Define if touch is enabled. (Default is true.)
  123781. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  123782. */
  123783. constructor(touchEnabled?: boolean);
  123784. /**
  123785. * Attach the mouse control to the HTML DOM element.
  123786. * @param element Defines the element that listens to the input events.
  123787. * @param noPreventDefault Defines whether events caught by the controls should call preventdefault().
  123788. */
  123789. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  123790. /**
  123791. * Detach the current controls from the specified dom element.
  123792. * @param element Defines the element to stop listening the inputs from
  123793. */
  123794. detachControl(element: Nullable<HTMLElement>): void;
  123795. /**
  123796. * Gets the class name of the current input.
  123797. * @returns the class name.
  123798. */
  123799. getClassName(): string;
  123800. /**
  123801. * Get the friendly name associated with the input class.
  123802. * @returns the input's friendly name.
  123803. */
  123804. getSimpleName(): string;
  123805. private _pointerInput;
  123806. private _onMouseMove;
  123807. /**
  123808. * Rotate camera by mouse offset.
  123809. */
  123810. private rotateCamera;
  123811. }
  123812. }
  123813. declare module BABYLON {
  123814. /**
  123815. * Default Inputs manager for the FlyCamera.
  123816. * It groups all the default supported inputs for ease of use.
  123817. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  123818. */
  123819. export class FlyCameraInputsManager extends CameraInputsManager<FlyCamera> {
  123820. /**
  123821. * Instantiates a new FlyCameraInputsManager.
  123822. * @param camera Defines the camera the inputs belong to.
  123823. */
  123824. constructor(camera: FlyCamera);
  123825. /**
  123826. * Add keyboard input support to the input manager.
  123827. * @returns the new FlyCameraKeyboardMoveInput().
  123828. */
  123829. addKeyboard(): FlyCameraInputsManager;
  123830. /**
  123831. * Add mouse input support to the input manager.
  123832. * @param touchEnabled Enable touch screen support.
  123833. * @returns the new FlyCameraMouseInput().
  123834. */
  123835. addMouse(touchEnabled?: boolean): FlyCameraInputsManager;
  123836. }
  123837. }
  123838. declare module BABYLON {
  123839. /**
  123840. * This is a flying camera, designed for 3D movement and rotation in all directions,
  123841. * such as in a 3D Space Shooter or a Flight Simulator.
  123842. */
  123843. export class FlyCamera extends TargetCamera {
  123844. /**
  123845. * Define the collision ellipsoid of the camera.
  123846. * This is helpful for simulating a camera body, like a player's body.
  123847. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  123848. */
  123849. ellipsoid: Vector3;
  123850. /**
  123851. * Define an offset for the position of the ellipsoid around the camera.
  123852. * This can be helpful if the camera is attached away from the player's body center,
  123853. * such as at its head.
  123854. */
  123855. ellipsoidOffset: Vector3;
  123856. /**
  123857. * Enable or disable collisions of the camera with the rest of the scene objects.
  123858. */
  123859. checkCollisions: boolean;
  123860. /**
  123861. * Enable or disable gravity on the camera.
  123862. */
  123863. applyGravity: boolean;
  123864. /**
  123865. * Define the current direction the camera is moving to.
  123866. */
  123867. cameraDirection: Vector3;
  123868. /**
  123869. * Define the current local rotation of the camera as a quaternion to prevent Gimbal lock.
  123870. * This overrides and empties cameraRotation.
  123871. */
  123872. rotationQuaternion: Quaternion;
  123873. /**
  123874. * Track Roll to maintain the wanted Rolling when looking around.
  123875. */
  123876. _trackRoll: number;
  123877. /**
  123878. * Slowly correct the Roll to its original value after a Pitch+Yaw rotation.
  123879. */
  123880. rollCorrect: number;
  123881. /**
  123882. * Mimic a banked turn, Rolling the camera when Yawing.
  123883. * It's recommended to use rollCorrect = 10 for faster banking correction.
  123884. */
  123885. bankedTurn: boolean;
  123886. /**
  123887. * Limit in radians for how much Roll banking will add. (Default: 90°)
  123888. */
  123889. bankedTurnLimit: number;
  123890. /**
  123891. * Value of 0 disables the banked Roll.
  123892. * Value of 1 is equal to the Yaw angle in radians.
  123893. */
  123894. bankedTurnMultiplier: number;
  123895. /**
  123896. * The inputs manager loads all the input sources, such as keyboard and mouse.
  123897. */
  123898. inputs: FlyCameraInputsManager;
  123899. /**
  123900. * Gets the input sensibility for mouse input.
  123901. * Higher values reduce sensitivity.
  123902. */
  123903. get angularSensibility(): number;
  123904. /**
  123905. * Sets the input sensibility for a mouse input.
  123906. * Higher values reduce sensitivity.
  123907. */
  123908. set angularSensibility(value: number);
  123909. /**
  123910. * Get the keys for camera movement forward.
  123911. */
  123912. get keysForward(): number[];
  123913. /**
  123914. * Set the keys for camera movement forward.
  123915. */
  123916. set keysForward(value: number[]);
  123917. /**
  123918. * Get the keys for camera movement backward.
  123919. */
  123920. get keysBackward(): number[];
  123921. set keysBackward(value: number[]);
  123922. /**
  123923. * Get the keys for camera movement up.
  123924. */
  123925. get keysUp(): number[];
  123926. /**
  123927. * Set the keys for camera movement up.
  123928. */
  123929. set keysUp(value: number[]);
  123930. /**
  123931. * Get the keys for camera movement down.
  123932. */
  123933. get keysDown(): number[];
  123934. /**
  123935. * Set the keys for camera movement down.
  123936. */
  123937. set keysDown(value: number[]);
  123938. /**
  123939. * Get the keys for camera movement left.
  123940. */
  123941. get keysLeft(): number[];
  123942. /**
  123943. * Set the keys for camera movement left.
  123944. */
  123945. set keysLeft(value: number[]);
  123946. /**
  123947. * Set the keys for camera movement right.
  123948. */
  123949. get keysRight(): number[];
  123950. /**
  123951. * Set the keys for camera movement right.
  123952. */
  123953. set keysRight(value: number[]);
  123954. /**
  123955. * Event raised when the camera collides with a mesh in the scene.
  123956. */
  123957. onCollide: (collidedMesh: AbstractMesh) => void;
  123958. private _collider;
  123959. private _needMoveForGravity;
  123960. private _oldPosition;
  123961. private _diffPosition;
  123962. private _newPosition;
  123963. /** @hidden */
  123964. _localDirection: Vector3;
  123965. /** @hidden */
  123966. _transformedDirection: Vector3;
  123967. /**
  123968. * Instantiates a FlyCamera.
  123969. * This is a flying camera, designed for 3D movement and rotation in all directions,
  123970. * such as in a 3D Space Shooter or a Flight Simulator.
  123971. * @param name Define the name of the camera in the scene.
  123972. * @param position Define the starting position of the camera in the scene.
  123973. * @param scene Define the scene the camera belongs to.
  123974. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active, if no other camera has been defined as active.
  123975. */
  123976. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  123977. /**
  123978. * Attach a control to the HTML DOM element.
  123979. * @param element Defines the element that listens to the input events.
  123980. * @param noPreventDefault Defines whether events caught by the controls should call preventdefault(). https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault
  123981. */
  123982. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  123983. /**
  123984. * Detach a control from the HTML DOM element.
  123985. * The camera will stop reacting to that input.
  123986. * @param element Defines the element that listens to the input events.
  123987. */
  123988. detachControl(element: HTMLElement): void;
  123989. private _collisionMask;
  123990. /**
  123991. * Get the mask that the camera ignores in collision events.
  123992. */
  123993. get collisionMask(): number;
  123994. /**
  123995. * Set the mask that the camera ignores in collision events.
  123996. */
  123997. set collisionMask(mask: number);
  123998. /** @hidden */
  123999. _collideWithWorld(displacement: Vector3): void;
  124000. /** @hidden */
  124001. private _onCollisionPositionChange;
  124002. /** @hidden */
  124003. _checkInputs(): void;
  124004. /** @hidden */
  124005. _decideIfNeedsToMove(): boolean;
  124006. /** @hidden */
  124007. _updatePosition(): void;
  124008. /**
  124009. * Restore the Roll to its target value at the rate specified.
  124010. * @param rate - Higher means slower restoring.
  124011. * @hidden
  124012. */
  124013. restoreRoll(rate: number): void;
  124014. /**
  124015. * Destroy the camera and release the current resources held by it.
  124016. */
  124017. dispose(): void;
  124018. /**
  124019. * Get the current object class name.
  124020. * @returns the class name.
  124021. */
  124022. getClassName(): string;
  124023. }
  124024. }
  124025. declare module BABYLON {
  124026. /**
  124027. * Listen to keyboard events to control the camera.
  124028. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  124029. */
  124030. export class FlyCameraKeyboardInput implements ICameraInput<FlyCamera> {
  124031. /**
  124032. * Defines the camera the input is attached to.
  124033. */
  124034. camera: FlyCamera;
  124035. /**
  124036. * The list of keyboard keys used to control the forward move of the camera.
  124037. */
  124038. keysForward: number[];
  124039. /**
  124040. * The list of keyboard keys used to control the backward move of the camera.
  124041. */
  124042. keysBackward: number[];
  124043. /**
  124044. * The list of keyboard keys used to control the forward move of the camera.
  124045. */
  124046. keysUp: number[];
  124047. /**
  124048. * The list of keyboard keys used to control the backward move of the camera.
  124049. */
  124050. keysDown: number[];
  124051. /**
  124052. * The list of keyboard keys used to control the right strafe move of the camera.
  124053. */
  124054. keysRight: number[];
  124055. /**
  124056. * The list of keyboard keys used to control the left strafe move of the camera.
  124057. */
  124058. keysLeft: number[];
  124059. private _keys;
  124060. private _onCanvasBlurObserver;
  124061. private _onKeyboardObserver;
  124062. private _engine;
  124063. private _scene;
  124064. /**
  124065. * Attach the input controls to a specific dom element to get the input from.
  124066. * @param element Defines the element the controls should be listened from
  124067. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  124068. */
  124069. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  124070. /**
  124071. * Detach the current controls from the specified dom element.
  124072. * @param element Defines the element to stop listening the inputs from
  124073. */
  124074. detachControl(element: Nullable<HTMLElement>): void;
  124075. /**
  124076. * Gets the class name of the current intput.
  124077. * @returns the class name
  124078. */
  124079. getClassName(): string;
  124080. /** @hidden */
  124081. _onLostFocus(e: FocusEvent): void;
  124082. /**
  124083. * Get the friendly name associated with the input class.
  124084. * @returns the input friendly name
  124085. */
  124086. getSimpleName(): string;
  124087. /**
  124088. * Update the current camera state depending on the inputs that have been used this frame.
  124089. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  124090. */
  124091. checkInputs(): void;
  124092. }
  124093. }
  124094. declare module BABYLON {
  124095. /**
  124096. * Manage the mouse wheel inputs to control a follow camera.
  124097. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  124098. */
  124099. export class FollowCameraMouseWheelInput implements ICameraInput<FollowCamera> {
  124100. /**
  124101. * Defines the camera the input is attached to.
  124102. */
  124103. camera: FollowCamera;
  124104. /**
  124105. * Moue wheel controls zoom. (Mouse wheel modifies camera.radius value.)
  124106. */
  124107. axisControlRadius: boolean;
  124108. /**
  124109. * Moue wheel controls height. (Mouse wheel modifies camera.heightOffset value.)
  124110. */
  124111. axisControlHeight: boolean;
  124112. /**
  124113. * Moue wheel controls angle. (Mouse wheel modifies camera.rotationOffset value.)
  124114. */
  124115. axisControlRotation: boolean;
  124116. /**
  124117. * Gets or Set the mouse wheel precision or how fast is the camera moves in
  124118. * relation to mouseWheel events.
  124119. */
  124120. wheelPrecision: number;
  124121. /**
  124122. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  124123. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  124124. */
  124125. wheelDeltaPercentage: number;
  124126. private _wheel;
  124127. private _observer;
  124128. /**
  124129. * Attach the input controls to a specific dom element to get the input from.
  124130. * @param element Defines the element the controls should be listened from
  124131. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  124132. */
  124133. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  124134. /**
  124135. * Detach the current controls from the specified dom element.
  124136. * @param element Defines the element to stop listening the inputs from
  124137. */
  124138. detachControl(element: Nullable<HTMLElement>): void;
  124139. /**
  124140. * Gets the class name of the current intput.
  124141. * @returns the class name
  124142. */
  124143. getClassName(): string;
  124144. /**
  124145. * Get the friendly name associated with the input class.
  124146. * @returns the input friendly name
  124147. */
  124148. getSimpleName(): string;
  124149. }
  124150. }
  124151. declare module BABYLON {
  124152. /**
  124153. * Manage the pointers inputs to control an follow camera.
  124154. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  124155. */
  124156. export class FollowCameraPointersInput extends BaseCameraPointersInput {
  124157. /**
  124158. * Defines the camera the input is attached to.
  124159. */
  124160. camera: FollowCamera;
  124161. /**
  124162. * Gets the class name of the current input.
  124163. * @returns the class name
  124164. */
  124165. getClassName(): string;
  124166. /**
  124167. * Defines the pointer angular sensibility along the X axis or how fast is
  124168. * the camera rotating.
  124169. * A negative number will reverse the axis direction.
  124170. */
  124171. angularSensibilityX: number;
  124172. /**
  124173. * Defines the pointer angular sensibility along the Y axis or how fast is
  124174. * the camera rotating.
  124175. * A negative number will reverse the axis direction.
  124176. */
  124177. angularSensibilityY: number;
  124178. /**
  124179. * Defines the pointer pinch precision or how fast is the camera zooming.
  124180. * A negative number will reverse the axis direction.
  124181. */
  124182. pinchPrecision: number;
  124183. /**
  124184. * pinchDeltaPercentage will be used instead of pinchPrecision if different
  124185. * from 0.
  124186. * It defines the percentage of current camera.radius to use as delta when
  124187. * pinch zoom is used.
  124188. */
  124189. pinchDeltaPercentage: number;
  124190. /**
  124191. * Pointer X axis controls zoom. (X axis modifies camera.radius value.)
  124192. */
  124193. axisXControlRadius: boolean;
  124194. /**
  124195. * Pointer X axis controls height. (X axis modifies camera.heightOffset value.)
  124196. */
  124197. axisXControlHeight: boolean;
  124198. /**
  124199. * Pointer X axis controls angle. (X axis modifies camera.rotationOffset value.)
  124200. */
  124201. axisXControlRotation: boolean;
  124202. /**
  124203. * Pointer Y axis controls zoom. (Y axis modifies camera.radius value.)
  124204. */
  124205. axisYControlRadius: boolean;
  124206. /**
  124207. * Pointer Y axis controls height. (Y axis modifies camera.heightOffset value.)
  124208. */
  124209. axisYControlHeight: boolean;
  124210. /**
  124211. * Pointer Y axis controls angle. (Y axis modifies camera.rotationOffset value.)
  124212. */
  124213. axisYControlRotation: boolean;
  124214. /**
  124215. * Pinch controls zoom. (Pinch modifies camera.radius value.)
  124216. */
  124217. axisPinchControlRadius: boolean;
  124218. /**
  124219. * Pinch controls height. (Pinch modifies camera.heightOffset value.)
  124220. */
  124221. axisPinchControlHeight: boolean;
  124222. /**
  124223. * Pinch controls angle. (Pinch modifies camera.rotationOffset value.)
  124224. */
  124225. axisPinchControlRotation: boolean;
  124226. /**
  124227. * Log error messages if basic misconfiguration has occurred.
  124228. */
  124229. warningEnable: boolean;
  124230. protected onTouch(pointA: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  124231. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  124232. private _warningCounter;
  124233. private _warning;
  124234. }
  124235. }
  124236. declare module BABYLON {
  124237. /**
  124238. * Default Inputs manager for the FollowCamera.
  124239. * It groups all the default supported inputs for ease of use.
  124240. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  124241. */
  124242. export class FollowCameraInputsManager extends CameraInputsManager<FollowCamera> {
  124243. /**
  124244. * Instantiates a new FollowCameraInputsManager.
  124245. * @param camera Defines the camera the inputs belong to
  124246. */
  124247. constructor(camera: FollowCamera);
  124248. /**
  124249. * Add keyboard input support to the input manager.
  124250. * @returns the current input manager
  124251. */
  124252. addKeyboard(): FollowCameraInputsManager;
  124253. /**
  124254. * Add mouse wheel input support to the input manager.
  124255. * @returns the current input manager
  124256. */
  124257. addMouseWheel(): FollowCameraInputsManager;
  124258. /**
  124259. * Add pointers input support to the input manager.
  124260. * @returns the current input manager
  124261. */
  124262. addPointers(): FollowCameraInputsManager;
  124263. /**
  124264. * Add orientation input support to the input manager.
  124265. * @returns the current input manager
  124266. */
  124267. addVRDeviceOrientation(): FollowCameraInputsManager;
  124268. }
  124269. }
  124270. declare module BABYLON {
  124271. /**
  124272. * A follow camera takes a mesh as a target and follows it as it moves. Both a free camera version followCamera and
  124273. * an arc rotate version arcFollowCamera are available.
  124274. * @see https://doc.babylonjs.com/features/cameras#follow-camera
  124275. */
  124276. export class FollowCamera extends TargetCamera {
  124277. /**
  124278. * Distance the follow camera should follow an object at
  124279. */
  124280. radius: number;
  124281. /**
  124282. * Minimum allowed distance of the camera to the axis of rotation
  124283. * (The camera can not get closer).
  124284. * This can help limiting how the Camera is able to move in the scene.
  124285. */
  124286. lowerRadiusLimit: Nullable<number>;
  124287. /**
  124288. * Maximum allowed distance of the camera to the axis of rotation
  124289. * (The camera can not get further).
  124290. * This can help limiting how the Camera is able to move in the scene.
  124291. */
  124292. upperRadiusLimit: Nullable<number>;
  124293. /**
  124294. * Define a rotation offset between the camera and the object it follows
  124295. */
  124296. rotationOffset: number;
  124297. /**
  124298. * Minimum allowed angle to camera position relative to target object.
  124299. * This can help limiting how the Camera is able to move in the scene.
  124300. */
  124301. lowerRotationOffsetLimit: Nullable<number>;
  124302. /**
  124303. * Maximum allowed angle to camera position relative to target object.
  124304. * This can help limiting how the Camera is able to move in the scene.
  124305. */
  124306. upperRotationOffsetLimit: Nullable<number>;
  124307. /**
  124308. * Define a height offset between the camera and the object it follows.
  124309. * It can help following an object from the top (like a car chaing a plane)
  124310. */
  124311. heightOffset: number;
  124312. /**
  124313. * Minimum allowed height of camera position relative to target object.
  124314. * This can help limiting how the Camera is able to move in the scene.
  124315. */
  124316. lowerHeightOffsetLimit: Nullable<number>;
  124317. /**
  124318. * Maximum allowed height of camera position relative to target object.
  124319. * This can help limiting how the Camera is able to move in the scene.
  124320. */
  124321. upperHeightOffsetLimit: Nullable<number>;
  124322. /**
  124323. * Define how fast the camera can accelerate to follow it s target.
  124324. */
  124325. cameraAcceleration: number;
  124326. /**
  124327. * Define the speed limit of the camera following an object.
  124328. */
  124329. maxCameraSpeed: number;
  124330. /**
  124331. * Define the target of the camera.
  124332. */
  124333. lockedTarget: Nullable<AbstractMesh>;
  124334. /**
  124335. * Defines the input associated with the camera.
  124336. */
  124337. inputs: FollowCameraInputsManager;
  124338. /**
  124339. * Instantiates the follow camera.
  124340. * @see https://doc.babylonjs.com/features/cameras#follow-camera
  124341. * @param name Define the name of the camera in the scene
  124342. * @param position Define the position of the camera
  124343. * @param scene Define the scene the camera belong to
  124344. * @param lockedTarget Define the target of the camera
  124345. */
  124346. constructor(name: string, position: Vector3, scene: Scene, lockedTarget?: Nullable<AbstractMesh>);
  124347. private _follow;
  124348. /**
  124349. * Attached controls to the current camera.
  124350. * @param element Defines the element the controls should be listened from
  124351. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  124352. */
  124353. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  124354. /**
  124355. * Detach the current controls from the camera.
  124356. * The camera will stop reacting to inputs.
  124357. * @param element Defines the element to stop listening the inputs from
  124358. */
  124359. detachControl(element: HTMLElement): void;
  124360. /** @hidden */
  124361. _checkInputs(): void;
  124362. private _checkLimits;
  124363. /**
  124364. * Gets the camera class name.
  124365. * @returns the class name
  124366. */
  124367. getClassName(): string;
  124368. }
  124369. /**
  124370. * Arc Rotate version of the follow camera.
  124371. * It still follows a Defined mesh but in an Arc Rotate Camera fashion.
  124372. * @see https://doc.babylonjs.com/features/cameras#follow-camera
  124373. */
  124374. export class ArcFollowCamera extends TargetCamera {
  124375. /** The longitudinal angle of the camera */
  124376. alpha: number;
  124377. /** The latitudinal angle of the camera */
  124378. beta: number;
  124379. /** The radius of the camera from its target */
  124380. radius: number;
  124381. private _cartesianCoordinates;
  124382. /** Define the camera target (the mesh it should follow) */
  124383. private _meshTarget;
  124384. /**
  124385. * Instantiates a new ArcFollowCamera
  124386. * @see https://doc.babylonjs.com/features/cameras#follow-camera
  124387. * @param name Define the name of the camera
  124388. * @param alpha Define the rotation angle of the camera around the logitudinal axis
  124389. * @param beta Define the rotation angle of the camera around the elevation axis
  124390. * @param radius Define the radius of the camera from its target point
  124391. * @param target Define the target of the camera
  124392. * @param scene Define the scene the camera belongs to
  124393. */
  124394. constructor(name: string,
  124395. /** The longitudinal angle of the camera */
  124396. alpha: number,
  124397. /** The latitudinal angle of the camera */
  124398. beta: number,
  124399. /** The radius of the camera from its target */
  124400. radius: number,
  124401. /** Define the camera target (the mesh it should follow) */
  124402. target: Nullable<AbstractMesh>, scene: Scene);
  124403. private _follow;
  124404. /** @hidden */
  124405. _checkInputs(): void;
  124406. /**
  124407. * Returns the class name of the object.
  124408. * It is mostly used internally for serialization purposes.
  124409. */
  124410. getClassName(): string;
  124411. }
  124412. }
  124413. declare module BABYLON {
  124414. /**
  124415. * Manage the keyboard inputs to control the movement of a follow camera.
  124416. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  124417. */
  124418. export class FollowCameraKeyboardMoveInput implements ICameraInput<FollowCamera> {
  124419. /**
  124420. * Defines the camera the input is attached to.
  124421. */
  124422. camera: FollowCamera;
  124423. /**
  124424. * Defines the list of key codes associated with the up action (increase heightOffset)
  124425. */
  124426. keysHeightOffsetIncr: number[];
  124427. /**
  124428. * Defines the list of key codes associated with the down action (decrease heightOffset)
  124429. */
  124430. keysHeightOffsetDecr: number[];
  124431. /**
  124432. * Defines whether the Alt modifier key is required to move up/down (alter heightOffset)
  124433. */
  124434. keysHeightOffsetModifierAlt: boolean;
  124435. /**
  124436. * Defines whether the Ctrl modifier key is required to move up/down (alter heightOffset)
  124437. */
  124438. keysHeightOffsetModifierCtrl: boolean;
  124439. /**
  124440. * Defines whether the Shift modifier key is required to move up/down (alter heightOffset)
  124441. */
  124442. keysHeightOffsetModifierShift: boolean;
  124443. /**
  124444. * Defines the list of key codes associated with the left action (increase rotationOffset)
  124445. */
  124446. keysRotationOffsetIncr: number[];
  124447. /**
  124448. * Defines the list of key codes associated with the right action (decrease rotationOffset)
  124449. */
  124450. keysRotationOffsetDecr: number[];
  124451. /**
  124452. * Defines whether the Alt modifier key is required to move left/right (alter rotationOffset)
  124453. */
  124454. keysRotationOffsetModifierAlt: boolean;
  124455. /**
  124456. * Defines whether the Ctrl modifier key is required to move left/right (alter rotationOffset)
  124457. */
  124458. keysRotationOffsetModifierCtrl: boolean;
  124459. /**
  124460. * Defines whether the Shift modifier key is required to move left/right (alter rotationOffset)
  124461. */
  124462. keysRotationOffsetModifierShift: boolean;
  124463. /**
  124464. * Defines the list of key codes associated with the zoom-in action (decrease radius)
  124465. */
  124466. keysRadiusIncr: number[];
  124467. /**
  124468. * Defines the list of key codes associated with the zoom-out action (increase radius)
  124469. */
  124470. keysRadiusDecr: number[];
  124471. /**
  124472. * Defines whether the Alt modifier key is required to zoom in/out (alter radius value)
  124473. */
  124474. keysRadiusModifierAlt: boolean;
  124475. /**
  124476. * Defines whether the Ctrl modifier key is required to zoom in/out (alter radius value)
  124477. */
  124478. keysRadiusModifierCtrl: boolean;
  124479. /**
  124480. * Defines whether the Shift modifier key is required to zoom in/out (alter radius value)
  124481. */
  124482. keysRadiusModifierShift: boolean;
  124483. /**
  124484. * Defines the rate of change of heightOffset.
  124485. */
  124486. heightSensibility: number;
  124487. /**
  124488. * Defines the rate of change of rotationOffset.
  124489. */
  124490. rotationSensibility: number;
  124491. /**
  124492. * Defines the rate of change of radius.
  124493. */
  124494. radiusSensibility: number;
  124495. private _keys;
  124496. private _ctrlPressed;
  124497. private _altPressed;
  124498. private _shiftPressed;
  124499. private _onCanvasBlurObserver;
  124500. private _onKeyboardObserver;
  124501. private _engine;
  124502. private _scene;
  124503. /**
  124504. * Attach the input controls to a specific dom element to get the input from.
  124505. * @param element Defines the element the controls should be listened from
  124506. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  124507. */
  124508. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  124509. /**
  124510. * Detach the current controls from the specified dom element.
  124511. * @param element Defines the element to stop listening the inputs from
  124512. */
  124513. detachControl(element: Nullable<HTMLElement>): void;
  124514. /**
  124515. * Update the current camera state depending on the inputs that have been used this frame.
  124516. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  124517. */
  124518. checkInputs(): void;
  124519. /**
  124520. * Gets the class name of the current input.
  124521. * @returns the class name
  124522. */
  124523. getClassName(): string;
  124524. /**
  124525. * Get the friendly name associated with the input class.
  124526. * @returns the input friendly name
  124527. */
  124528. getSimpleName(): string;
  124529. /**
  124530. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  124531. * allow modification of the heightOffset value.
  124532. */
  124533. private _modifierHeightOffset;
  124534. /**
  124535. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  124536. * allow modification of the rotationOffset value.
  124537. */
  124538. private _modifierRotationOffset;
  124539. /**
  124540. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  124541. * allow modification of the radius value.
  124542. */
  124543. private _modifierRadius;
  124544. }
  124545. }
  124546. declare module BABYLON {
  124547. interface FreeCameraInputsManager {
  124548. /**
  124549. * @hidden
  124550. */
  124551. _deviceOrientationInput: Nullable<FreeCameraDeviceOrientationInput>;
  124552. /**
  124553. * Add orientation input support to the input manager.
  124554. * @returns the current input manager
  124555. */
  124556. addDeviceOrientation(): FreeCameraInputsManager;
  124557. }
  124558. /**
  124559. * Takes information about the orientation of the device as reported by the deviceorientation event to orient the camera.
  124560. * Screen rotation is taken into account.
  124561. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  124562. */
  124563. export class FreeCameraDeviceOrientationInput implements ICameraInput<FreeCamera> {
  124564. private _camera;
  124565. private _screenOrientationAngle;
  124566. private _constantTranform;
  124567. private _screenQuaternion;
  124568. private _alpha;
  124569. private _beta;
  124570. private _gamma;
  124571. /**
  124572. * Can be used to detect if a device orientation sensor is available on a device
  124573. * @param timeout amount of time in milliseconds to wait for a response from the sensor (default: infinite)
  124574. * @returns a promise that will resolve on orientation change
  124575. */
  124576. static WaitForOrientationChangeAsync(timeout?: number): Promise<unknown>;
  124577. /**
  124578. * @hidden
  124579. */
  124580. _onDeviceOrientationChangedObservable: Observable<void>;
  124581. /**
  124582. * Instantiates a new input
  124583. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  124584. */
  124585. constructor();
  124586. /**
  124587. * Define the camera controlled by the input.
  124588. */
  124589. get camera(): FreeCamera;
  124590. set camera(camera: FreeCamera);
  124591. /**
  124592. * Attach the input controls to a specific dom element to get the input from.
  124593. * @param element Defines the element the controls should be listened from
  124594. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  124595. */
  124596. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  124597. private _orientationChanged;
  124598. private _deviceOrientation;
  124599. /**
  124600. * Detach the current controls from the specified dom element.
  124601. * @param element Defines the element to stop listening the inputs from
  124602. */
  124603. detachControl(element: Nullable<HTMLElement>): void;
  124604. /**
  124605. * Update the current camera state depending on the inputs that have been used this frame.
  124606. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  124607. */
  124608. checkInputs(): void;
  124609. /**
  124610. * Gets the class name of the current intput.
  124611. * @returns the class name
  124612. */
  124613. getClassName(): string;
  124614. /**
  124615. * Get the friendly name associated with the input class.
  124616. * @returns the input friendly name
  124617. */
  124618. getSimpleName(): string;
  124619. }
  124620. }
  124621. declare module BABYLON {
  124622. /**
  124623. * Manage the gamepad inputs to control a free camera.
  124624. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  124625. */
  124626. export class FreeCameraGamepadInput implements ICameraInput<FreeCamera> {
  124627. /**
  124628. * Define the camera the input is attached to.
  124629. */
  124630. camera: FreeCamera;
  124631. /**
  124632. * Define the Gamepad controlling the input
  124633. */
  124634. gamepad: Nullable<Gamepad>;
  124635. /**
  124636. * Defines the gamepad rotation sensiblity.
  124637. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  124638. */
  124639. gamepadAngularSensibility: number;
  124640. /**
  124641. * Defines the gamepad move sensiblity.
  124642. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  124643. */
  124644. gamepadMoveSensibility: number;
  124645. private _yAxisScale;
  124646. /**
  124647. * Gets or sets a boolean indicating that Yaxis (for right stick) should be inverted
  124648. */
  124649. get invertYAxis(): boolean;
  124650. set invertYAxis(value: boolean);
  124651. private _onGamepadConnectedObserver;
  124652. private _onGamepadDisconnectedObserver;
  124653. private _cameraTransform;
  124654. private _deltaTransform;
  124655. private _vector3;
  124656. private _vector2;
  124657. /**
  124658. * Attach the input controls to a specific dom element to get the input from.
  124659. * @param element Defines the element the controls should be listened from
  124660. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  124661. */
  124662. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  124663. /**
  124664. * Detach the current controls from the specified dom element.
  124665. * @param element Defines the element to stop listening the inputs from
  124666. */
  124667. detachControl(element: Nullable<HTMLElement>): void;
  124668. /**
  124669. * Update the current camera state depending on the inputs that have been used this frame.
  124670. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  124671. */
  124672. checkInputs(): void;
  124673. /**
  124674. * Gets the class name of the current intput.
  124675. * @returns the class name
  124676. */
  124677. getClassName(): string;
  124678. /**
  124679. * Get the friendly name associated with the input class.
  124680. * @returns the input friendly name
  124681. */
  124682. getSimpleName(): string;
  124683. }
  124684. }
  124685. declare module BABYLON {
  124686. /**
  124687. * Defines the potential axis of a Joystick
  124688. */
  124689. export enum JoystickAxis {
  124690. /** X axis */
  124691. X = 0,
  124692. /** Y axis */
  124693. Y = 1,
  124694. /** Z axis */
  124695. Z = 2
  124696. }
  124697. /**
  124698. * Represents the different customization options available
  124699. * for VirtualJoystick
  124700. */
  124701. interface VirtualJoystickCustomizations {
  124702. /**
  124703. * Size of the joystick's puck
  124704. */
  124705. puckSize: number;
  124706. /**
  124707. * Size of the joystick's container
  124708. */
  124709. containerSize: number;
  124710. /**
  124711. * Color of the joystick && puck
  124712. */
  124713. color: string;
  124714. /**
  124715. * Image URL for the joystick's puck
  124716. */
  124717. puckImage?: string;
  124718. /**
  124719. * Image URL for the joystick's container
  124720. */
  124721. containerImage?: string;
  124722. /**
  124723. * Defines the unmoving position of the joystick container
  124724. */
  124725. position?: {
  124726. x: number;
  124727. y: number;
  124728. };
  124729. /**
  124730. * Defines whether or not the joystick container is always visible
  124731. */
  124732. alwaysVisible: boolean;
  124733. /**
  124734. * Defines whether or not to limit the movement of the puck to the joystick's container
  124735. */
  124736. limitToContainer: boolean;
  124737. }
  124738. /**
  124739. * Class used to define virtual joystick (used in touch mode)
  124740. */
  124741. export class VirtualJoystick {
  124742. /**
  124743. * Gets or sets a boolean indicating that left and right values must be inverted
  124744. */
  124745. reverseLeftRight: boolean;
  124746. /**
  124747. * Gets or sets a boolean indicating that up and down values must be inverted
  124748. */
  124749. reverseUpDown: boolean;
  124750. /**
  124751. * Gets the offset value for the position (ie. the change of the position value)
  124752. */
  124753. deltaPosition: Vector3;
  124754. /**
  124755. * Gets a boolean indicating if the virtual joystick was pressed
  124756. */
  124757. pressed: boolean;
  124758. /**
  124759. * Canvas the virtual joystick will render onto, default z-index of this is 5
  124760. */
  124761. static Canvas: Nullable<HTMLCanvasElement>;
  124762. /**
  124763. * boolean indicating whether or not the joystick's puck's movement should be limited to the joystick's container area
  124764. */
  124765. limitToContainer: boolean;
  124766. private static _globalJoystickIndex;
  124767. private static _alwaysVisibleSticks;
  124768. private static vjCanvasContext;
  124769. private static vjCanvasWidth;
  124770. private static vjCanvasHeight;
  124771. private static halfWidth;
  124772. private static _GetDefaultOptions;
  124773. private _action;
  124774. private _axisTargetedByLeftAndRight;
  124775. private _axisTargetedByUpAndDown;
  124776. private _joystickSensibility;
  124777. private _inversedSensibility;
  124778. private _joystickPointerID;
  124779. private _joystickColor;
  124780. private _joystickPointerPos;
  124781. private _joystickPreviousPointerPos;
  124782. private _joystickPointerStartPos;
  124783. private _deltaJoystickVector;
  124784. private _leftJoystick;
  124785. private _touches;
  124786. private _joystickPosition;
  124787. private _alwaysVisible;
  124788. private _puckImage;
  124789. private _containerImage;
  124790. private _joystickPuckSize;
  124791. private _joystickContainerSize;
  124792. private _clearPuckSize;
  124793. private _clearContainerSize;
  124794. private _clearPuckSizeOffset;
  124795. private _clearContainerSizeOffset;
  124796. private _onPointerDownHandlerRef;
  124797. private _onPointerMoveHandlerRef;
  124798. private _onPointerUpHandlerRef;
  124799. private _onResize;
  124800. /**
  124801. * Creates a new virtual joystick
  124802. * @param leftJoystick defines that the joystick is for left hand (false by default)
  124803. * @param customizations Defines the options we want to customize the VirtualJoystick
  124804. */
  124805. constructor(leftJoystick?: boolean, customizations?: Partial<VirtualJoystickCustomizations>);
  124806. /**
  124807. * Defines joystick sensibility (ie. the ratio beteen a physical move and virtual joystick position change)
  124808. * @param newJoystickSensibility defines the new sensibility
  124809. */
  124810. setJoystickSensibility(newJoystickSensibility: number): void;
  124811. private _onPointerDown;
  124812. private _onPointerMove;
  124813. private _onPointerUp;
  124814. /**
  124815. * Change the color of the virtual joystick
  124816. * @param newColor a string that must be a CSS color value (like "red") or the hexa value (like "#FF0000")
  124817. */
  124818. setJoystickColor(newColor: string): void;
  124819. /**
  124820. * Size of the joystick's container
  124821. */
  124822. set containerSize(newSize: number);
  124823. get containerSize(): number;
  124824. /**
  124825. * Size of the joystick's puck
  124826. */
  124827. set puckSize(newSize: number);
  124828. get puckSize(): number;
  124829. /**
  124830. * Clears the set position of the joystick
  124831. */
  124832. clearPosition(): void;
  124833. /**
  124834. * Defines whether or not the joystick container is always visible
  124835. */
  124836. set alwaysVisible(value: boolean);
  124837. get alwaysVisible(): boolean;
  124838. /**
  124839. * Sets the constant position of the Joystick container
  124840. * @param x X axis coordinate
  124841. * @param y Y axis coordinate
  124842. */
  124843. setPosition(x: number, y: number): void;
  124844. /**
  124845. * Defines a callback to call when the joystick is touched
  124846. * @param action defines the callback
  124847. */
  124848. setActionOnTouch(action: () => any): void;
  124849. /**
  124850. * Defines which axis you'd like to control for left & right
  124851. * @param axis defines the axis to use
  124852. */
  124853. setAxisForLeftRight(axis: JoystickAxis): void;
  124854. /**
  124855. * Defines which axis you'd like to control for up & down
  124856. * @param axis defines the axis to use
  124857. */
  124858. setAxisForUpDown(axis: JoystickAxis): void;
  124859. /**
  124860. * Clears the canvas from the previous puck / container draw
  124861. */
  124862. private _clearPreviousDraw;
  124863. /**
  124864. * Loads `urlPath` to be used for the container's image
  124865. * @param urlPath defines the urlPath of an image to use
  124866. */
  124867. setContainerImage(urlPath: string): void;
  124868. /**
  124869. * Loads `urlPath` to be used for the puck's image
  124870. * @param urlPath defines the urlPath of an image to use
  124871. */
  124872. setPuckImage(urlPath: string): void;
  124873. /**
  124874. * Draws the Virtual Joystick's container
  124875. */
  124876. private _drawContainer;
  124877. /**
  124878. * Draws the Virtual Joystick's puck
  124879. */
  124880. private _drawPuck;
  124881. private _drawVirtualJoystick;
  124882. /**
  124883. * Release internal HTML canvas
  124884. */
  124885. releaseCanvas(): void;
  124886. }
  124887. }
  124888. declare module BABYLON {
  124889. interface FreeCameraInputsManager {
  124890. /**
  124891. * Add virtual joystick input support to the input manager.
  124892. * @returns the current input manager
  124893. */
  124894. addVirtualJoystick(): FreeCameraInputsManager;
  124895. }
  124896. /**
  124897. * Manage the Virtual Joystick inputs to control the movement of a free camera.
  124898. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  124899. */
  124900. export class FreeCameraVirtualJoystickInput implements ICameraInput<FreeCamera> {
  124901. /**
  124902. * Defines the camera the input is attached to.
  124903. */
  124904. camera: FreeCamera;
  124905. private _leftjoystick;
  124906. private _rightjoystick;
  124907. /**
  124908. * Gets the left stick of the virtual joystick.
  124909. * @returns The virtual Joystick
  124910. */
  124911. getLeftJoystick(): VirtualJoystick;
  124912. /**
  124913. * Gets the right stick of the virtual joystick.
  124914. * @returns The virtual Joystick
  124915. */
  124916. getRightJoystick(): VirtualJoystick;
  124917. /**
  124918. * Update the current camera state depending on the inputs that have been used this frame.
  124919. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  124920. */
  124921. checkInputs(): void;
  124922. /**
  124923. * Attach the input controls to a specific dom element to get the input from.
  124924. * @param element Defines the element the controls should be listened from
  124925. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  124926. */
  124927. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  124928. /**
  124929. * Detach the current controls from the specified dom element.
  124930. * @param element Defines the element to stop listening the inputs from
  124931. */
  124932. detachControl(element: Nullable<HTMLElement>): void;
  124933. /**
  124934. * Gets the class name of the current intput.
  124935. * @returns the class name
  124936. */
  124937. getClassName(): string;
  124938. /**
  124939. * Get the friendly name associated with the input class.
  124940. * @returns the input friendly name
  124941. */
  124942. getSimpleName(): string;
  124943. }
  124944. }
  124945. declare module BABYLON {
  124946. /**
  124947. * This represents a FPS type of camera controlled by touch.
  124948. * This is like a universal camera minus the Gamepad controls.
  124949. * @see https://doc.babylonjs.com/features/cameras#universal-camera
  124950. */
  124951. export class TouchCamera extends FreeCamera {
  124952. /**
  124953. * Defines the touch sensibility for rotation.
  124954. * The higher the faster.
  124955. */
  124956. get touchAngularSensibility(): number;
  124957. set touchAngularSensibility(value: number);
  124958. /**
  124959. * Defines the touch sensibility for move.
  124960. * The higher the faster.
  124961. */
  124962. get touchMoveSensibility(): number;
  124963. set touchMoveSensibility(value: number);
  124964. /**
  124965. * Instantiates a new touch camera.
  124966. * This represents a FPS type of camera controlled by touch.
  124967. * This is like a universal camera minus the Gamepad controls.
  124968. * @see https://doc.babylonjs.com/features/cameras#universal-camera
  124969. * @param name Define the name of the camera in the scene
  124970. * @param position Define the start position of the camera in the scene
  124971. * @param scene Define the scene the camera belongs to
  124972. */
  124973. constructor(name: string, position: Vector3, scene: Scene);
  124974. /**
  124975. * Gets the current object class name.
  124976. * @return the class name
  124977. */
  124978. getClassName(): string;
  124979. /** @hidden */
  124980. _setupInputs(): void;
  124981. }
  124982. }
  124983. declare module BABYLON {
  124984. /**
  124985. * This is a camera specifically designed to react to device orientation events such as a modern mobile device
  124986. * being tilted forward or back and left or right.
  124987. */
  124988. export class DeviceOrientationCamera extends FreeCamera {
  124989. private _initialQuaternion;
  124990. private _quaternionCache;
  124991. private _tmpDragQuaternion;
  124992. private _disablePointerInputWhenUsingDeviceOrientation;
  124993. /**
  124994. * Creates a new device orientation camera
  124995. * @param name The name of the camera
  124996. * @param position The start position camera
  124997. * @param scene The scene the camera belongs to
  124998. */
  124999. constructor(name: string, position: Vector3, scene: Scene);
  125000. /**
  125001. * Gets or sets a boolean indicating that pointer input must be disabled on first orientation sensor update (Default: true)
  125002. */
  125003. get disablePointerInputWhenUsingDeviceOrientation(): boolean;
  125004. set disablePointerInputWhenUsingDeviceOrientation(value: boolean);
  125005. private _dragFactor;
  125006. /**
  125007. * Enabled turning on the y axis when the orientation sensor is active
  125008. * @param dragFactor the factor that controls the turn speed (default: 1/300)
  125009. */
  125010. enableHorizontalDragging(dragFactor?: number): void;
  125011. /**
  125012. * Gets the current instance class name ("DeviceOrientationCamera").
  125013. * This helps avoiding instanceof at run time.
  125014. * @returns the class name
  125015. */
  125016. getClassName(): string;
  125017. /**
  125018. * @hidden
  125019. * Checks and applies the current values of the inputs to the camera. (Internal use only)
  125020. */
  125021. _checkInputs(): void;
  125022. /**
  125023. * Reset the camera to its default orientation on the specified axis only.
  125024. * @param axis The axis to reset
  125025. */
  125026. resetToCurrentRotation(axis?: Axis): void;
  125027. }
  125028. }
  125029. declare module BABYLON {
  125030. /**
  125031. * Defines supported buttons for XBox360 compatible gamepads
  125032. */
  125033. export enum Xbox360Button {
  125034. /** A */
  125035. A = 0,
  125036. /** B */
  125037. B = 1,
  125038. /** X */
  125039. X = 2,
  125040. /** Y */
  125041. Y = 3,
  125042. /** Left button */
  125043. LB = 4,
  125044. /** Right button */
  125045. RB = 5,
  125046. /** Back */
  125047. Back = 8,
  125048. /** Start */
  125049. Start = 9,
  125050. /** Left stick */
  125051. LeftStick = 10,
  125052. /** Right stick */
  125053. RightStick = 11
  125054. }
  125055. /** Defines values for XBox360 DPad */
  125056. export enum Xbox360Dpad {
  125057. /** Up */
  125058. Up = 12,
  125059. /** Down */
  125060. Down = 13,
  125061. /** Left */
  125062. Left = 14,
  125063. /** Right */
  125064. Right = 15
  125065. }
  125066. /**
  125067. * Defines a XBox360 gamepad
  125068. */
  125069. export class Xbox360Pad extends Gamepad {
  125070. private _leftTrigger;
  125071. private _rightTrigger;
  125072. private _onlefttriggerchanged;
  125073. private _onrighttriggerchanged;
  125074. private _onbuttondown;
  125075. private _onbuttonup;
  125076. private _ondpaddown;
  125077. private _ondpadup;
  125078. /** Observable raised when a button is pressed */
  125079. onButtonDownObservable: Observable<Xbox360Button>;
  125080. /** Observable raised when a button is released */
  125081. onButtonUpObservable: Observable<Xbox360Button>;
  125082. /** Observable raised when a pad is pressed */
  125083. onPadDownObservable: Observable<Xbox360Dpad>;
  125084. /** Observable raised when a pad is released */
  125085. onPadUpObservable: Observable<Xbox360Dpad>;
  125086. private _buttonA;
  125087. private _buttonB;
  125088. private _buttonX;
  125089. private _buttonY;
  125090. private _buttonBack;
  125091. private _buttonStart;
  125092. private _buttonLB;
  125093. private _buttonRB;
  125094. private _buttonLeftStick;
  125095. private _buttonRightStick;
  125096. private _dPadUp;
  125097. private _dPadDown;
  125098. private _dPadLeft;
  125099. private _dPadRight;
  125100. private _isXboxOnePad;
  125101. /**
  125102. * Creates a new XBox360 gamepad object
  125103. * @param id defines the id of this gamepad
  125104. * @param index defines its index
  125105. * @param gamepad defines the internal HTML gamepad object
  125106. * @param xboxOne defines if it is a XBox One gamepad
  125107. */
  125108. constructor(id: string, index: number, gamepad: any, xboxOne?: boolean);
  125109. /**
  125110. * Defines the callback to call when left trigger is pressed
  125111. * @param callback defines the callback to use
  125112. */
  125113. onlefttriggerchanged(callback: (value: number) => void): void;
  125114. /**
  125115. * Defines the callback to call when right trigger is pressed
  125116. * @param callback defines the callback to use
  125117. */
  125118. onrighttriggerchanged(callback: (value: number) => void): void;
  125119. /**
  125120. * Gets the left trigger value
  125121. */
  125122. get leftTrigger(): number;
  125123. /**
  125124. * Sets the left trigger value
  125125. */
  125126. set leftTrigger(newValue: number);
  125127. /**
  125128. * Gets the right trigger value
  125129. */
  125130. get rightTrigger(): number;
  125131. /**
  125132. * Sets the right trigger value
  125133. */
  125134. set rightTrigger(newValue: number);
  125135. /**
  125136. * Defines the callback to call when a button is pressed
  125137. * @param callback defines the callback to use
  125138. */
  125139. onbuttondown(callback: (buttonPressed: Xbox360Button) => void): void;
  125140. /**
  125141. * Defines the callback to call when a button is released
  125142. * @param callback defines the callback to use
  125143. */
  125144. onbuttonup(callback: (buttonReleased: Xbox360Button) => void): void;
  125145. /**
  125146. * Defines the callback to call when a pad is pressed
  125147. * @param callback defines the callback to use
  125148. */
  125149. ondpaddown(callback: (dPadPressed: Xbox360Dpad) => void): void;
  125150. /**
  125151. * Defines the callback to call when a pad is released
  125152. * @param callback defines the callback to use
  125153. */
  125154. ondpadup(callback: (dPadReleased: Xbox360Dpad) => void): void;
  125155. private _setButtonValue;
  125156. private _setDPadValue;
  125157. /**
  125158. * Gets the value of the `A` button
  125159. */
  125160. get buttonA(): number;
  125161. /**
  125162. * Sets the value of the `A` button
  125163. */
  125164. set buttonA(value: number);
  125165. /**
  125166. * Gets the value of the `B` button
  125167. */
  125168. get buttonB(): number;
  125169. /**
  125170. * Sets the value of the `B` button
  125171. */
  125172. set buttonB(value: number);
  125173. /**
  125174. * Gets the value of the `X` button
  125175. */
  125176. get buttonX(): number;
  125177. /**
  125178. * Sets the value of the `X` button
  125179. */
  125180. set buttonX(value: number);
  125181. /**
  125182. * Gets the value of the `Y` button
  125183. */
  125184. get buttonY(): number;
  125185. /**
  125186. * Sets the value of the `Y` button
  125187. */
  125188. set buttonY(value: number);
  125189. /**
  125190. * Gets the value of the `Start` button
  125191. */
  125192. get buttonStart(): number;
  125193. /**
  125194. * Sets the value of the `Start` button
  125195. */
  125196. set buttonStart(value: number);
  125197. /**
  125198. * Gets the value of the `Back` button
  125199. */
  125200. get buttonBack(): number;
  125201. /**
  125202. * Sets the value of the `Back` button
  125203. */
  125204. set buttonBack(value: number);
  125205. /**
  125206. * Gets the value of the `Left` button
  125207. */
  125208. get buttonLB(): number;
  125209. /**
  125210. * Sets the value of the `Left` button
  125211. */
  125212. set buttonLB(value: number);
  125213. /**
  125214. * Gets the value of the `Right` button
  125215. */
  125216. get buttonRB(): number;
  125217. /**
  125218. * Sets the value of the `Right` button
  125219. */
  125220. set buttonRB(value: number);
  125221. /**
  125222. * Gets the value of the Left joystick
  125223. */
  125224. get buttonLeftStick(): number;
  125225. /**
  125226. * Sets the value of the Left joystick
  125227. */
  125228. set buttonLeftStick(value: number);
  125229. /**
  125230. * Gets the value of the Right joystick
  125231. */
  125232. get buttonRightStick(): number;
  125233. /**
  125234. * Sets the value of the Right joystick
  125235. */
  125236. set buttonRightStick(value: number);
  125237. /**
  125238. * Gets the value of D-pad up
  125239. */
  125240. get dPadUp(): number;
  125241. /**
  125242. * Sets the value of D-pad up
  125243. */
  125244. set dPadUp(value: number);
  125245. /**
  125246. * Gets the value of D-pad down
  125247. */
  125248. get dPadDown(): number;
  125249. /**
  125250. * Sets the value of D-pad down
  125251. */
  125252. set dPadDown(value: number);
  125253. /**
  125254. * Gets the value of D-pad left
  125255. */
  125256. get dPadLeft(): number;
  125257. /**
  125258. * Sets the value of D-pad left
  125259. */
  125260. set dPadLeft(value: number);
  125261. /**
  125262. * Gets the value of D-pad right
  125263. */
  125264. get dPadRight(): number;
  125265. /**
  125266. * Sets the value of D-pad right
  125267. */
  125268. set dPadRight(value: number);
  125269. /**
  125270. * Force the gamepad to synchronize with device values
  125271. */
  125272. update(): void;
  125273. /**
  125274. * Disposes the gamepad
  125275. */
  125276. dispose(): void;
  125277. }
  125278. }
  125279. declare module BABYLON {
  125280. /**
  125281. * Defines supported buttons for DualShock compatible gamepads
  125282. */
  125283. export enum DualShockButton {
  125284. /** Cross */
  125285. Cross = 0,
  125286. /** Circle */
  125287. Circle = 1,
  125288. /** Square */
  125289. Square = 2,
  125290. /** Triangle */
  125291. Triangle = 3,
  125292. /** L1 */
  125293. L1 = 4,
  125294. /** R1 */
  125295. R1 = 5,
  125296. /** Share */
  125297. Share = 8,
  125298. /** Options */
  125299. Options = 9,
  125300. /** Left stick */
  125301. LeftStick = 10,
  125302. /** Right stick */
  125303. RightStick = 11
  125304. }
  125305. /** Defines values for DualShock DPad */
  125306. export enum DualShockDpad {
  125307. /** Up */
  125308. Up = 12,
  125309. /** Down */
  125310. Down = 13,
  125311. /** Left */
  125312. Left = 14,
  125313. /** Right */
  125314. Right = 15
  125315. }
  125316. /**
  125317. * Defines a DualShock gamepad
  125318. */
  125319. export class DualShockPad extends Gamepad {
  125320. private _leftTrigger;
  125321. private _rightTrigger;
  125322. private _onlefttriggerchanged;
  125323. private _onrighttriggerchanged;
  125324. private _onbuttondown;
  125325. private _onbuttonup;
  125326. private _ondpaddown;
  125327. private _ondpadup;
  125328. /** Observable raised when a button is pressed */
  125329. onButtonDownObservable: Observable<DualShockButton>;
  125330. /** Observable raised when a button is released */
  125331. onButtonUpObservable: Observable<DualShockButton>;
  125332. /** Observable raised when a pad is pressed */
  125333. onPadDownObservable: Observable<DualShockDpad>;
  125334. /** Observable raised when a pad is released */
  125335. onPadUpObservable: Observable<DualShockDpad>;
  125336. private _buttonCross;
  125337. private _buttonCircle;
  125338. private _buttonSquare;
  125339. private _buttonTriangle;
  125340. private _buttonShare;
  125341. private _buttonOptions;
  125342. private _buttonL1;
  125343. private _buttonR1;
  125344. private _buttonLeftStick;
  125345. private _buttonRightStick;
  125346. private _dPadUp;
  125347. private _dPadDown;
  125348. private _dPadLeft;
  125349. private _dPadRight;
  125350. /**
  125351. * Creates a new DualShock gamepad object
  125352. * @param id defines the id of this gamepad
  125353. * @param index defines its index
  125354. * @param gamepad defines the internal HTML gamepad object
  125355. */
  125356. constructor(id: string, index: number, gamepad: any);
  125357. /**
  125358. * Defines the callback to call when left trigger is pressed
  125359. * @param callback defines the callback to use
  125360. */
  125361. onlefttriggerchanged(callback: (value: number) => void): void;
  125362. /**
  125363. * Defines the callback to call when right trigger is pressed
  125364. * @param callback defines the callback to use
  125365. */
  125366. onrighttriggerchanged(callback: (value: number) => void): void;
  125367. /**
  125368. * Gets the left trigger value
  125369. */
  125370. get leftTrigger(): number;
  125371. /**
  125372. * Sets the left trigger value
  125373. */
  125374. set leftTrigger(newValue: number);
  125375. /**
  125376. * Gets the right trigger value
  125377. */
  125378. get rightTrigger(): number;
  125379. /**
  125380. * Sets the right trigger value
  125381. */
  125382. set rightTrigger(newValue: number);
  125383. /**
  125384. * Defines the callback to call when a button is pressed
  125385. * @param callback defines the callback to use
  125386. */
  125387. onbuttondown(callback: (buttonPressed: DualShockButton) => void): void;
  125388. /**
  125389. * Defines the callback to call when a button is released
  125390. * @param callback defines the callback to use
  125391. */
  125392. onbuttonup(callback: (buttonReleased: DualShockButton) => void): void;
  125393. /**
  125394. * Defines the callback to call when a pad is pressed
  125395. * @param callback defines the callback to use
  125396. */
  125397. ondpaddown(callback: (dPadPressed: DualShockDpad) => void): void;
  125398. /**
  125399. * Defines the callback to call when a pad is released
  125400. * @param callback defines the callback to use
  125401. */
  125402. ondpadup(callback: (dPadReleased: DualShockDpad) => void): void;
  125403. private _setButtonValue;
  125404. private _setDPadValue;
  125405. /**
  125406. * Gets the value of the `Cross` button
  125407. */
  125408. get buttonCross(): number;
  125409. /**
  125410. * Sets the value of the `Cross` button
  125411. */
  125412. set buttonCross(value: number);
  125413. /**
  125414. * Gets the value of the `Circle` button
  125415. */
  125416. get buttonCircle(): number;
  125417. /**
  125418. * Sets the value of the `Circle` button
  125419. */
  125420. set buttonCircle(value: number);
  125421. /**
  125422. * Gets the value of the `Square` button
  125423. */
  125424. get buttonSquare(): number;
  125425. /**
  125426. * Sets the value of the `Square` button
  125427. */
  125428. set buttonSquare(value: number);
  125429. /**
  125430. * Gets the value of the `Triangle` button
  125431. */
  125432. get buttonTriangle(): number;
  125433. /**
  125434. * Sets the value of the `Triangle` button
  125435. */
  125436. set buttonTriangle(value: number);
  125437. /**
  125438. * Gets the value of the `Options` button
  125439. */
  125440. get buttonOptions(): number;
  125441. /**
  125442. * Sets the value of the `Options` button
  125443. */
  125444. set buttonOptions(value: number);
  125445. /**
  125446. * Gets the value of the `Share` button
  125447. */
  125448. get buttonShare(): number;
  125449. /**
  125450. * Sets the value of the `Share` button
  125451. */
  125452. set buttonShare(value: number);
  125453. /**
  125454. * Gets the value of the `L1` button
  125455. */
  125456. get buttonL1(): number;
  125457. /**
  125458. * Sets the value of the `L1` button
  125459. */
  125460. set buttonL1(value: number);
  125461. /**
  125462. * Gets the value of the `R1` button
  125463. */
  125464. get buttonR1(): number;
  125465. /**
  125466. * Sets the value of the `R1` button
  125467. */
  125468. set buttonR1(value: number);
  125469. /**
  125470. * Gets the value of the Left joystick
  125471. */
  125472. get buttonLeftStick(): number;
  125473. /**
  125474. * Sets the value of the Left joystick
  125475. */
  125476. set buttonLeftStick(value: number);
  125477. /**
  125478. * Gets the value of the Right joystick
  125479. */
  125480. get buttonRightStick(): number;
  125481. /**
  125482. * Sets the value of the Right joystick
  125483. */
  125484. set buttonRightStick(value: number);
  125485. /**
  125486. * Gets the value of D-pad up
  125487. */
  125488. get dPadUp(): number;
  125489. /**
  125490. * Sets the value of D-pad up
  125491. */
  125492. set dPadUp(value: number);
  125493. /**
  125494. * Gets the value of D-pad down
  125495. */
  125496. get dPadDown(): number;
  125497. /**
  125498. * Sets the value of D-pad down
  125499. */
  125500. set dPadDown(value: number);
  125501. /**
  125502. * Gets the value of D-pad left
  125503. */
  125504. get dPadLeft(): number;
  125505. /**
  125506. * Sets the value of D-pad left
  125507. */
  125508. set dPadLeft(value: number);
  125509. /**
  125510. * Gets the value of D-pad right
  125511. */
  125512. get dPadRight(): number;
  125513. /**
  125514. * Sets the value of D-pad right
  125515. */
  125516. set dPadRight(value: number);
  125517. /**
  125518. * Force the gamepad to synchronize with device values
  125519. */
  125520. update(): void;
  125521. /**
  125522. * Disposes the gamepad
  125523. */
  125524. dispose(): void;
  125525. }
  125526. }
  125527. declare module BABYLON {
  125528. /**
  125529. * Manager for handling gamepads
  125530. */
  125531. export class GamepadManager {
  125532. private _scene?;
  125533. private _babylonGamepads;
  125534. private _oneGamepadConnected;
  125535. /** @hidden */
  125536. _isMonitoring: boolean;
  125537. private _gamepadEventSupported;
  125538. private _gamepadSupport?;
  125539. /**
  125540. * observable to be triggered when the gamepad controller has been connected
  125541. */
  125542. onGamepadConnectedObservable: Observable<Gamepad>;
  125543. /**
  125544. * observable to be triggered when the gamepad controller has been disconnected
  125545. */
  125546. onGamepadDisconnectedObservable: Observable<Gamepad>;
  125547. private _onGamepadConnectedEvent;
  125548. private _onGamepadDisconnectedEvent;
  125549. /**
  125550. * Initializes the gamepad manager
  125551. * @param _scene BabylonJS scene
  125552. */
  125553. constructor(_scene?: Scene | undefined);
  125554. /**
  125555. * The gamepads in the game pad manager
  125556. */
  125557. get gamepads(): Gamepad[];
  125558. /**
  125559. * Get the gamepad controllers based on type
  125560. * @param type The type of gamepad controller
  125561. * @returns Nullable gamepad
  125562. */
  125563. getGamepadByType(type?: number): Nullable<Gamepad>;
  125564. /**
  125565. * Disposes the gamepad manager
  125566. */
  125567. dispose(): void;
  125568. private _addNewGamepad;
  125569. private _startMonitoringGamepads;
  125570. private _stopMonitoringGamepads;
  125571. /** @hidden */
  125572. _checkGamepadsStatus(): void;
  125573. private _updateGamepadObjects;
  125574. }
  125575. }
  125576. declare module BABYLON {
  125577. interface Scene {
  125578. /** @hidden */
  125579. _gamepadManager: Nullable<GamepadManager>;
  125580. /**
  125581. * Gets the gamepad manager associated with the scene
  125582. * @see https://doc.babylonjs.com/how_to/how_to_use_gamepads
  125583. */
  125584. gamepadManager: GamepadManager;
  125585. }
  125586. /**
  125587. * Interface representing a free camera inputs manager
  125588. */
  125589. interface FreeCameraInputsManager {
  125590. /**
  125591. * Adds gamepad input support to the FreeCameraInputsManager.
  125592. * @returns the FreeCameraInputsManager
  125593. */
  125594. addGamepad(): FreeCameraInputsManager;
  125595. }
  125596. /**
  125597. * Interface representing an arc rotate camera inputs manager
  125598. */
  125599. interface ArcRotateCameraInputsManager {
  125600. /**
  125601. * Adds gamepad input support to the ArcRotateCamera InputManager.
  125602. * @returns the camera inputs manager
  125603. */
  125604. addGamepad(): ArcRotateCameraInputsManager;
  125605. }
  125606. /**
  125607. * Defines the gamepad scene component responsible to manage gamepads in a given scene
  125608. */
  125609. export class GamepadSystemSceneComponent implements ISceneComponent {
  125610. /**
  125611. * The component name helpfull to identify the component in the list of scene components.
  125612. */
  125613. readonly name: string;
  125614. /**
  125615. * The scene the component belongs to.
  125616. */
  125617. scene: Scene;
  125618. /**
  125619. * Creates a new instance of the component for the given scene
  125620. * @param scene Defines the scene to register the component in
  125621. */
  125622. constructor(scene: Scene);
  125623. /**
  125624. * Registers the component in a given scene
  125625. */
  125626. register(): void;
  125627. /**
  125628. * Rebuilds the elements related to this component in case of
  125629. * context lost for instance.
  125630. */
  125631. rebuild(): void;
  125632. /**
  125633. * Disposes the component and the associated ressources
  125634. */
  125635. dispose(): void;
  125636. private _beforeCameraUpdate;
  125637. }
  125638. }
  125639. declare module BABYLON {
  125640. /**
  125641. * 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,
  125642. * which still works and will still be found in many Playgrounds.
  125643. * @see https://doc.babylonjs.com/features/cameras#universal-camera
  125644. */
  125645. export class UniversalCamera extends TouchCamera {
  125646. /**
  125647. * Defines the gamepad rotation sensiblity.
  125648. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  125649. */
  125650. get gamepadAngularSensibility(): number;
  125651. set gamepadAngularSensibility(value: number);
  125652. /**
  125653. * Defines the gamepad move sensiblity.
  125654. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  125655. */
  125656. get gamepadMoveSensibility(): number;
  125657. set gamepadMoveSensibility(value: number);
  125658. /**
  125659. * 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,
  125660. * which still works and will still be found in many Playgrounds.
  125661. * @see https://doc.babylonjs.com/features/cameras#universal-camera
  125662. * @param name Define the name of the camera in the scene
  125663. * @param position Define the start position of the camera in the scene
  125664. * @param scene Define the scene the camera belongs to
  125665. */
  125666. constructor(name: string, position: Vector3, scene: Scene);
  125667. /**
  125668. * Gets the current object class name.
  125669. * @return the class name
  125670. */
  125671. getClassName(): string;
  125672. }
  125673. }
  125674. declare module BABYLON {
  125675. /**
  125676. * This represents a FPS type of camera. This is only here for back compat purpose.
  125677. * Please use the UniversalCamera instead as both are identical.
  125678. * @see https://doc.babylonjs.com/features/cameras#universal-camera
  125679. */
  125680. export class GamepadCamera extends UniversalCamera {
  125681. /**
  125682. * Instantiates a new Gamepad Camera
  125683. * This represents a FPS type of camera. This is only here for back compat purpose.
  125684. * Please use the UniversalCamera instead as both are identical.
  125685. * @see https://doc.babylonjs.com/features/cameras#universal-camera
  125686. * @param name Define the name of the camera in the scene
  125687. * @param position Define the start position of the camera in the scene
  125688. * @param scene Define the scene the camera belongs to
  125689. */
  125690. constructor(name: string, position: Vector3, scene: Scene);
  125691. /**
  125692. * Gets the current object class name.
  125693. * @return the class name
  125694. */
  125695. getClassName(): string;
  125696. }
  125697. }
  125698. declare module BABYLON {
  125699. /** @hidden */
  125700. export var passPixelShader: {
  125701. name: string;
  125702. shader: string;
  125703. };
  125704. }
  125705. declare module BABYLON {
  125706. /** @hidden */
  125707. export var passCubePixelShader: {
  125708. name: string;
  125709. shader: string;
  125710. };
  125711. }
  125712. declare module BABYLON {
  125713. /**
  125714. * PassPostProcess which produces an output the same as it's input
  125715. */
  125716. export class PassPostProcess extends PostProcess {
  125717. /**
  125718. * Gets a string identifying the name of the class
  125719. * @returns "PassPostProcess" string
  125720. */
  125721. getClassName(): string;
  125722. /**
  125723. * Creates the PassPostProcess
  125724. * @param name The name of the effect.
  125725. * @param options The required width/height ratio to downsize to before computing the render pass.
  125726. * @param camera The camera to apply the render pass to.
  125727. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  125728. * @param engine The engine which the post process will be applied. (default: current engine)
  125729. * @param reusable If the post process can be reused on the same frame. (default: false)
  125730. * @param textureType The type of texture to be used when performing the post processing.
  125731. * @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)
  125732. */
  125733. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  125734. /** @hidden */
  125735. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): PassPostProcess;
  125736. }
  125737. /**
  125738. * PassCubePostProcess which produces an output the same as it's input (which must be a cube texture)
  125739. */
  125740. export class PassCubePostProcess extends PostProcess {
  125741. private _face;
  125742. /**
  125743. * Gets or sets the cube face to display.
  125744. * * 0 is +X
  125745. * * 1 is -X
  125746. * * 2 is +Y
  125747. * * 3 is -Y
  125748. * * 4 is +Z
  125749. * * 5 is -Z
  125750. */
  125751. get face(): number;
  125752. set face(value: number);
  125753. /**
  125754. * Gets a string identifying the name of the class
  125755. * @returns "PassCubePostProcess" string
  125756. */
  125757. getClassName(): string;
  125758. /**
  125759. * Creates the PassCubePostProcess
  125760. * @param name The name of the effect.
  125761. * @param options The required width/height ratio to downsize to before computing the render pass.
  125762. * @param camera The camera to apply the render pass to.
  125763. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  125764. * @param engine The engine which the post process will be applied. (default: current engine)
  125765. * @param reusable If the post process can be reused on the same frame. (default: false)
  125766. * @param textureType The type of texture to be used when performing the post processing.
  125767. * @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)
  125768. */
  125769. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  125770. /** @hidden */
  125771. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): PassCubePostProcess;
  125772. }
  125773. }
  125774. declare module BABYLON {
  125775. /** @hidden */
  125776. export var anaglyphPixelShader: {
  125777. name: string;
  125778. shader: string;
  125779. };
  125780. }
  125781. declare module BABYLON {
  125782. /**
  125783. * Postprocess used to generate anaglyphic rendering
  125784. */
  125785. export class AnaglyphPostProcess extends PostProcess {
  125786. private _passedProcess;
  125787. /**
  125788. * Gets a string identifying the name of the class
  125789. * @returns "AnaglyphPostProcess" string
  125790. */
  125791. getClassName(): string;
  125792. /**
  125793. * Creates a new AnaglyphPostProcess
  125794. * @param name defines postprocess name
  125795. * @param options defines creation options or target ratio scale
  125796. * @param rigCameras defines cameras using this postprocess
  125797. * @param samplingMode defines required sampling mode (BABYLON.Texture.NEAREST_SAMPLINGMODE by default)
  125798. * @param engine defines hosting engine
  125799. * @param reusable defines if the postprocess will be reused multiple times per frame
  125800. */
  125801. constructor(name: string, options: number | PostProcessOptions, rigCameras: Camera[], samplingMode?: number, engine?: Engine, reusable?: boolean);
  125802. }
  125803. }
  125804. declare module BABYLON {
  125805. /**
  125806. * Camera used to simulate anaglyphic rendering (based on ArcRotateCamera)
  125807. * @see https://doc.babylonjs.com/features/cameras#anaglyph-cameras
  125808. */
  125809. export class AnaglyphArcRotateCamera extends ArcRotateCamera {
  125810. /**
  125811. * Creates a new AnaglyphArcRotateCamera
  125812. * @param name defines camera name
  125813. * @param alpha defines alpha angle (in radians)
  125814. * @param beta defines beta angle (in radians)
  125815. * @param radius defines radius
  125816. * @param target defines camera target
  125817. * @param interaxialDistance defines distance between each color axis
  125818. * @param scene defines the hosting scene
  125819. */
  125820. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, scene: Scene);
  125821. /**
  125822. * Gets camera class name
  125823. * @returns AnaglyphArcRotateCamera
  125824. */
  125825. getClassName(): string;
  125826. }
  125827. }
  125828. declare module BABYLON {
  125829. /**
  125830. * Camera used to simulate anaglyphic rendering (based on FreeCamera)
  125831. * @see https://doc.babylonjs.com/features/cameras#anaglyph-cameras
  125832. */
  125833. export class AnaglyphFreeCamera extends FreeCamera {
  125834. /**
  125835. * Creates a new AnaglyphFreeCamera
  125836. * @param name defines camera name
  125837. * @param position defines initial position
  125838. * @param interaxialDistance defines distance between each color axis
  125839. * @param scene defines the hosting scene
  125840. */
  125841. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  125842. /**
  125843. * Gets camera class name
  125844. * @returns AnaglyphFreeCamera
  125845. */
  125846. getClassName(): string;
  125847. }
  125848. }
  125849. declare module BABYLON {
  125850. /**
  125851. * Camera used to simulate anaglyphic rendering (based on GamepadCamera)
  125852. * @see https://doc.babylonjs.com/features/cameras#anaglyph-cameras
  125853. */
  125854. export class AnaglyphGamepadCamera extends GamepadCamera {
  125855. /**
  125856. * Creates a new AnaglyphGamepadCamera
  125857. * @param name defines camera name
  125858. * @param position defines initial position
  125859. * @param interaxialDistance defines distance between each color axis
  125860. * @param scene defines the hosting scene
  125861. */
  125862. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  125863. /**
  125864. * Gets camera class name
  125865. * @returns AnaglyphGamepadCamera
  125866. */
  125867. getClassName(): string;
  125868. }
  125869. }
  125870. declare module BABYLON {
  125871. /**
  125872. * Camera used to simulate anaglyphic rendering (based on UniversalCamera)
  125873. * @see https://doc.babylonjs.com/features/cameras#anaglyph-cameras
  125874. */
  125875. export class AnaglyphUniversalCamera extends UniversalCamera {
  125876. /**
  125877. * Creates a new AnaglyphUniversalCamera
  125878. * @param name defines camera name
  125879. * @param position defines initial position
  125880. * @param interaxialDistance defines distance between each color axis
  125881. * @param scene defines the hosting scene
  125882. */
  125883. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  125884. /**
  125885. * Gets camera class name
  125886. * @returns AnaglyphUniversalCamera
  125887. */
  125888. getClassName(): string;
  125889. }
  125890. }
  125891. declare module BABYLON {
  125892. /**
  125893. * Camera used to simulate stereoscopic rendering (based on ArcRotateCamera)
  125894. * @see https://doc.babylonjs.com/features/cameras
  125895. */
  125896. export class StereoscopicArcRotateCamera extends ArcRotateCamera {
  125897. /**
  125898. * Creates a new StereoscopicArcRotateCamera
  125899. * @param name defines camera name
  125900. * @param alpha defines alpha angle (in radians)
  125901. * @param beta defines beta angle (in radians)
  125902. * @param radius defines radius
  125903. * @param target defines camera target
  125904. * @param interaxialDistance defines distance between each color axis
  125905. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  125906. * @param scene defines the hosting scene
  125907. */
  125908. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  125909. /**
  125910. * Gets camera class name
  125911. * @returns StereoscopicArcRotateCamera
  125912. */
  125913. getClassName(): string;
  125914. }
  125915. }
  125916. declare module BABYLON {
  125917. /**
  125918. * Camera used to simulate stereoscopic rendering (based on FreeCamera)
  125919. * @see https://doc.babylonjs.com/features/cameras
  125920. */
  125921. export class StereoscopicFreeCamera extends FreeCamera {
  125922. /**
  125923. * Creates a new StereoscopicFreeCamera
  125924. * @param name defines camera name
  125925. * @param position defines initial position
  125926. * @param interaxialDistance defines distance between each color axis
  125927. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  125928. * @param scene defines the hosting scene
  125929. */
  125930. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  125931. /**
  125932. * Gets camera class name
  125933. * @returns StereoscopicFreeCamera
  125934. */
  125935. getClassName(): string;
  125936. }
  125937. }
  125938. declare module BABYLON {
  125939. /**
  125940. * Camera used to simulate stereoscopic rendering (based on GamepadCamera)
  125941. * @see https://doc.babylonjs.com/features/cameras
  125942. */
  125943. export class StereoscopicGamepadCamera extends GamepadCamera {
  125944. /**
  125945. * Creates a new StereoscopicGamepadCamera
  125946. * @param name defines camera name
  125947. * @param position defines initial position
  125948. * @param interaxialDistance defines distance between each color axis
  125949. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  125950. * @param scene defines the hosting scene
  125951. */
  125952. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  125953. /**
  125954. * Gets camera class name
  125955. * @returns StereoscopicGamepadCamera
  125956. */
  125957. getClassName(): string;
  125958. }
  125959. }
  125960. declare module BABYLON {
  125961. /**
  125962. * Camera used to simulate stereoscopic rendering (based on UniversalCamera)
  125963. * @see https://doc.babylonjs.com/features/cameras
  125964. */
  125965. export class StereoscopicUniversalCamera extends UniversalCamera {
  125966. /**
  125967. * Creates a new StereoscopicUniversalCamera
  125968. * @param name defines camera name
  125969. * @param position defines initial position
  125970. * @param interaxialDistance defines distance between each color axis
  125971. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  125972. * @param scene defines the hosting scene
  125973. */
  125974. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  125975. /**
  125976. * Gets camera class name
  125977. * @returns StereoscopicUniversalCamera
  125978. */
  125979. getClassName(): string;
  125980. }
  125981. }
  125982. declare module BABYLON {
  125983. /**
  125984. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  125985. * It is identical to the Free Camera and simply adds by default a virtual joystick.
  125986. * Virtual Joysticks are on-screen 2D graphics that are used to control the camera or other scene items.
  125987. * @see https://doc.babylonjs.com/features/cameras#virtual-joysticks-camera
  125988. */
  125989. export class VirtualJoysticksCamera extends FreeCamera {
  125990. /**
  125991. * Intantiates a VirtualJoysticksCamera. It can be useful in First Person Shooter game for instance.
  125992. * It is identical to the Free Camera and simply adds by default a virtual joystick.
  125993. * Virtual Joysticks are on-screen 2D graphics that are used to control the camera or other scene items.
  125994. * @see https://doc.babylonjs.com/features/cameras#virtual-joysticks-camera
  125995. * @param name Define the name of the camera in the scene
  125996. * @param position Define the start position of the camera in the scene
  125997. * @param scene Define the scene the camera belongs to
  125998. */
  125999. constructor(name: string, position: Vector3, scene: Scene);
  126000. /**
  126001. * Gets the current object class name.
  126002. * @return the class name
  126003. */
  126004. getClassName(): string;
  126005. }
  126006. }
  126007. declare module BABYLON {
  126008. /**
  126009. * This represents all the required metrics to create a VR camera.
  126010. * @see https://doc.babylonjs.com/babylon101/cameras#device-orientation-camera
  126011. */
  126012. export class VRCameraMetrics {
  126013. /**
  126014. * Define the horizontal resolution off the screen.
  126015. */
  126016. hResolution: number;
  126017. /**
  126018. * Define the vertical resolution off the screen.
  126019. */
  126020. vResolution: number;
  126021. /**
  126022. * Define the horizontal screen size.
  126023. */
  126024. hScreenSize: number;
  126025. /**
  126026. * Define the vertical screen size.
  126027. */
  126028. vScreenSize: number;
  126029. /**
  126030. * Define the vertical screen center position.
  126031. */
  126032. vScreenCenter: number;
  126033. /**
  126034. * Define the distance of the eyes to the screen.
  126035. */
  126036. eyeToScreenDistance: number;
  126037. /**
  126038. * Define the distance between both lenses
  126039. */
  126040. lensSeparationDistance: number;
  126041. /**
  126042. * Define the distance between both viewer's eyes.
  126043. */
  126044. interpupillaryDistance: number;
  126045. /**
  126046. * Define the distortion factor of the VR postprocess.
  126047. * Please, touch with care.
  126048. */
  126049. distortionK: number[];
  126050. /**
  126051. * Define the chromatic aberration correction factors for the VR post process.
  126052. */
  126053. chromaAbCorrection: number[];
  126054. /**
  126055. * Define the scale factor of the post process.
  126056. * The smaller the better but the slower.
  126057. */
  126058. postProcessScaleFactor: number;
  126059. /**
  126060. * Define an offset for the lens center.
  126061. */
  126062. lensCenterOffset: number;
  126063. /**
  126064. * Define if the current vr camera should compensate the distortion of the lense or not.
  126065. */
  126066. compensateDistortion: boolean;
  126067. /**
  126068. * Defines if multiview should be enabled when rendering (Default: false)
  126069. */
  126070. multiviewEnabled: boolean;
  126071. /**
  126072. * Gets the rendering aspect ratio based on the provided resolutions.
  126073. */
  126074. get aspectRatio(): number;
  126075. /**
  126076. * Gets the aspect ratio based on the FOV, scale factors, and real screen sizes.
  126077. */
  126078. get aspectRatioFov(): number;
  126079. /**
  126080. * @hidden
  126081. */
  126082. get leftHMatrix(): Matrix;
  126083. /**
  126084. * @hidden
  126085. */
  126086. get rightHMatrix(): Matrix;
  126087. /**
  126088. * @hidden
  126089. */
  126090. get leftPreViewMatrix(): Matrix;
  126091. /**
  126092. * @hidden
  126093. */
  126094. get rightPreViewMatrix(): Matrix;
  126095. /**
  126096. * Get the default VRMetrics based on the most generic setup.
  126097. * @returns the default vr metrics
  126098. */
  126099. static GetDefault(): VRCameraMetrics;
  126100. }
  126101. }
  126102. declare module BABYLON {
  126103. /** @hidden */
  126104. export var vrDistortionCorrectionPixelShader: {
  126105. name: string;
  126106. shader: string;
  126107. };
  126108. }
  126109. declare module BABYLON {
  126110. /**
  126111. * VRDistortionCorrectionPostProcess used for mobile VR
  126112. */
  126113. export class VRDistortionCorrectionPostProcess extends PostProcess {
  126114. private _isRightEye;
  126115. private _distortionFactors;
  126116. private _postProcessScaleFactor;
  126117. private _lensCenterOffset;
  126118. private _scaleIn;
  126119. private _scaleFactor;
  126120. private _lensCenter;
  126121. /**
  126122. * Gets a string identifying the name of the class
  126123. * @returns "VRDistortionCorrectionPostProcess" string
  126124. */
  126125. getClassName(): string;
  126126. /**
  126127. * Initializes the VRDistortionCorrectionPostProcess
  126128. * @param name The name of the effect.
  126129. * @param camera The camera to apply the render pass to.
  126130. * @param isRightEye If this is for the right eye distortion
  126131. * @param vrMetrics All the required metrics for the VR camera
  126132. */
  126133. constructor(name: string, camera: Camera, isRightEye: boolean, vrMetrics: VRCameraMetrics);
  126134. }
  126135. }
  126136. declare module BABYLON {
  126137. /**
  126138. * Camera used to simulate VR rendering (based on ArcRotateCamera)
  126139. * @see https://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  126140. */
  126141. export class VRDeviceOrientationArcRotateCamera extends ArcRotateCamera {
  126142. /**
  126143. * Creates a new VRDeviceOrientationArcRotateCamera
  126144. * @param name defines camera name
  126145. * @param alpha defines the camera rotation along the logitudinal axis
  126146. * @param beta defines the camera rotation along the latitudinal axis
  126147. * @param radius defines the camera distance from its target
  126148. * @param target defines the camera target
  126149. * @param scene defines the scene the camera belongs to
  126150. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  126151. * @param vrCameraMetrics defines the vr metrics associated to the camera
  126152. */
  126153. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  126154. /**
  126155. * Gets camera class name
  126156. * @returns VRDeviceOrientationArcRotateCamera
  126157. */
  126158. getClassName(): string;
  126159. }
  126160. }
  126161. declare module BABYLON {
  126162. /**
  126163. * Camera used to simulate VR rendering (based on FreeCamera)
  126164. * @see https://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  126165. */
  126166. export class VRDeviceOrientationFreeCamera extends DeviceOrientationCamera {
  126167. /**
  126168. * Creates a new VRDeviceOrientationFreeCamera
  126169. * @param name defines camera name
  126170. * @param position defines the start position of the camera
  126171. * @param scene defines the scene the camera belongs to
  126172. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  126173. * @param vrCameraMetrics defines the vr metrics associated to the camera
  126174. */
  126175. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  126176. /**
  126177. * Gets camera class name
  126178. * @returns VRDeviceOrientationFreeCamera
  126179. */
  126180. getClassName(): string;
  126181. }
  126182. }
  126183. declare module BABYLON {
  126184. /**
  126185. * Camera used to simulate VR rendering (based on VRDeviceOrientationFreeCamera)
  126186. * @see https://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  126187. */
  126188. export class VRDeviceOrientationGamepadCamera extends VRDeviceOrientationFreeCamera {
  126189. /**
  126190. * Creates a new VRDeviceOrientationGamepadCamera
  126191. * @param name defines camera name
  126192. * @param position defines the start position of the camera
  126193. * @param scene defines the scene the camera belongs to
  126194. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  126195. * @param vrCameraMetrics defines the vr metrics associated to the camera
  126196. */
  126197. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  126198. /**
  126199. * Gets camera class name
  126200. * @returns VRDeviceOrientationGamepadCamera
  126201. */
  126202. getClassName(): string;
  126203. }
  126204. }
  126205. declare module BABYLON {
  126206. /**
  126207. * A class extending Texture allowing drawing on a texture
  126208. * @see https://doc.babylonjs.com/how_to/dynamictexture
  126209. */
  126210. export class DynamicTexture extends Texture {
  126211. private _generateMipMaps;
  126212. private _canvas;
  126213. private _context;
  126214. /**
  126215. * Creates a DynamicTexture
  126216. * @param name defines the name of the texture
  126217. * @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
  126218. * @param scene defines the scene where you want the texture
  126219. * @param generateMipMaps defines the use of MinMaps or not (default is false)
  126220. * @param samplingMode defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  126221. * @param format defines the texture format to use (default is Engine.TEXTUREFORMAT_RGBA)
  126222. */
  126223. constructor(name: string, options: any, scene: Scene | null | undefined, generateMipMaps: boolean, samplingMode?: number, format?: number);
  126224. /**
  126225. * Get the current class name of the texture useful for serialization or dynamic coding.
  126226. * @returns "DynamicTexture"
  126227. */
  126228. getClassName(): string;
  126229. /**
  126230. * Gets the current state of canRescale
  126231. */
  126232. get canRescale(): boolean;
  126233. private _recreate;
  126234. /**
  126235. * Scales the texture
  126236. * @param ratio the scale factor to apply to both width and height
  126237. */
  126238. scale(ratio: number): void;
  126239. /**
  126240. * Resizes the texture
  126241. * @param width the new width
  126242. * @param height the new height
  126243. */
  126244. scaleTo(width: number, height: number): void;
  126245. /**
  126246. * Gets the context of the canvas used by the texture
  126247. * @returns the canvas context of the dynamic texture
  126248. */
  126249. getContext(): CanvasRenderingContext2D;
  126250. /**
  126251. * Clears the texture
  126252. */
  126253. clear(): void;
  126254. /**
  126255. * Updates the texture
  126256. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  126257. * @param premulAlpha defines if alpha is stored as premultiplied (default is false)
  126258. */
  126259. update(invertY?: boolean, premulAlpha?: boolean): void;
  126260. /**
  126261. * Draws text onto the texture
  126262. * @param text defines the text to be drawn
  126263. * @param x defines the placement of the text from the left
  126264. * @param y defines the placement of the text from the top when invertY is true and from the bottom when false
  126265. * @param font defines the font to be used with font-style, font-size, font-name
  126266. * @param color defines the color used for the text
  126267. * @param clearColor defines the color for the canvas, use null to not overwrite canvas
  126268. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  126269. * @param update defines whether texture is immediately update (default is true)
  126270. */
  126271. drawText(text: string, x: number | null | undefined, y: number | null | undefined, font: string, color: string | null, clearColor: string, invertY?: boolean, update?: boolean): void;
  126272. /**
  126273. * Clones the texture
  126274. * @returns the clone of the texture.
  126275. */
  126276. clone(): DynamicTexture;
  126277. /**
  126278. * Serializes the dynamic texture. The scene should be ready before the dynamic texture is serialized
  126279. * @returns a serialized dynamic texture object
  126280. */
  126281. serialize(): any;
  126282. private _IsCanvasElement;
  126283. /** @hidden */
  126284. _rebuild(): void;
  126285. }
  126286. }
  126287. declare module BABYLON {
  126288. /**
  126289. * Class containing static functions to help procedurally build meshes
  126290. */
  126291. export class GroundBuilder {
  126292. /**
  126293. * Creates a ground mesh
  126294. * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
  126295. * * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side
  126296. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  126297. * @param name defines the name of the mesh
  126298. * @param options defines the options used to create the mesh
  126299. * @param scene defines the hosting scene
  126300. * @returns the ground mesh
  126301. * @see https://doc.babylonjs.com/how_to/set_shapes#ground
  126302. */
  126303. static CreateGround(name: string, options: {
  126304. width?: number;
  126305. height?: number;
  126306. subdivisions?: number;
  126307. subdivisionsX?: number;
  126308. subdivisionsY?: number;
  126309. updatable?: boolean;
  126310. }, scene: any): Mesh;
  126311. /**
  126312. * Creates a tiled ground mesh
  126313. * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
  126314. * * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates
  126315. * * 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
  126316. * * 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
  126317. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  126318. * @param name defines the name of the mesh
  126319. * @param options defines the options used to create the mesh
  126320. * @param scene defines the hosting scene
  126321. * @returns the tiled ground mesh
  126322. * @see https://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  126323. */
  126324. static CreateTiledGround(name: string, options: {
  126325. xmin: number;
  126326. zmin: number;
  126327. xmax: number;
  126328. zmax: number;
  126329. subdivisions?: {
  126330. w: number;
  126331. h: number;
  126332. };
  126333. precision?: {
  126334. w: number;
  126335. h: number;
  126336. };
  126337. updatable?: boolean;
  126338. }, scene?: Nullable<Scene>): Mesh;
  126339. /**
  126340. * Creates a ground mesh from a height map
  126341. * * The parameter `url` sets the URL of the height map image resource.
  126342. * * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  126343. * * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  126344. * * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  126345. * * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  126346. * * 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.
  126347. * * 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).
  126348. * * The parameter `alphaFilter` will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  126349. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  126350. * @param name defines the name of the mesh
  126351. * @param url defines the url to the height map
  126352. * @param options defines the options used to create the mesh
  126353. * @param scene defines the hosting scene
  126354. * @returns the ground mesh
  126355. * @see https://doc.babylonjs.com/babylon101/height_map
  126356. * @see https://doc.babylonjs.com/how_to/set_shapes#ground-from-a-height-map
  126357. */
  126358. static CreateGroundFromHeightMap(name: string, url: string, options: {
  126359. width?: number;
  126360. height?: number;
  126361. subdivisions?: number;
  126362. minHeight?: number;
  126363. maxHeight?: number;
  126364. colorFilter?: Color3;
  126365. alphaFilter?: number;
  126366. updatable?: boolean;
  126367. onReady?: (mesh: GroundMesh) => void;
  126368. }, scene?: Nullable<Scene>): GroundMesh;
  126369. }
  126370. }
  126371. declare module BABYLON {
  126372. /**
  126373. * Class containing static functions to help procedurally build meshes
  126374. */
  126375. export class TorusBuilder {
  126376. /**
  126377. * Creates a torus mesh
  126378. * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
  126379. * * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5)
  126380. * * The parameter `tessellation` sets the number of torus sides (postive integer, default 16)
  126381. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  126382. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  126383. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  126384. * @param name defines the name of the mesh
  126385. * @param options defines the options used to create the mesh
  126386. * @param scene defines the hosting scene
  126387. * @returns the torus mesh
  126388. * @see https://doc.babylonjs.com/how_to/set_shapes#torus
  126389. */
  126390. static CreateTorus(name: string, options: {
  126391. diameter?: number;
  126392. thickness?: number;
  126393. tessellation?: number;
  126394. updatable?: boolean;
  126395. sideOrientation?: number;
  126396. frontUVs?: Vector4;
  126397. backUVs?: Vector4;
  126398. }, scene: any): Mesh;
  126399. }
  126400. }
  126401. declare module BABYLON {
  126402. /**
  126403. * Class containing static functions to help procedurally build meshes
  126404. */
  126405. export class CylinderBuilder {
  126406. /**
  126407. * Creates a cylinder or a cone mesh
  126408. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  126409. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  126410. * * 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.
  126411. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  126412. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  126413. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  126414. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  126415. * * 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).
  126416. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  126417. * * 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).
  126418. * * 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
  126419. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  126420. * * 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
  126421. * * 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.
  126422. * * If `enclose` is false, a ring surface is one element.
  126423. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  126424. * * 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
  126425. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  126426. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  126427. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  126428. * @param name defines the name of the mesh
  126429. * @param options defines the options used to create the mesh
  126430. * @param scene defines the hosting scene
  126431. * @returns the cylinder mesh
  126432. * @see https://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  126433. */
  126434. static CreateCylinder(name: string, options: {
  126435. height?: number;
  126436. diameterTop?: number;
  126437. diameterBottom?: number;
  126438. diameter?: number;
  126439. tessellation?: number;
  126440. subdivisions?: number;
  126441. arc?: number;
  126442. faceColors?: Color4[];
  126443. faceUV?: Vector4[];
  126444. updatable?: boolean;
  126445. hasRings?: boolean;
  126446. enclose?: boolean;
  126447. cap?: number;
  126448. sideOrientation?: number;
  126449. frontUVs?: Vector4;
  126450. backUVs?: Vector4;
  126451. }, scene: any): Mesh;
  126452. }
  126453. }
  126454. declare module BABYLON {
  126455. /**
  126456. * States of the webXR experience
  126457. */
  126458. export enum WebXRState {
  126459. /**
  126460. * Transitioning to being in XR mode
  126461. */
  126462. ENTERING_XR = 0,
  126463. /**
  126464. * Transitioning to non XR mode
  126465. */
  126466. EXITING_XR = 1,
  126467. /**
  126468. * In XR mode and presenting
  126469. */
  126470. IN_XR = 2,
  126471. /**
  126472. * Not entered XR mode
  126473. */
  126474. NOT_IN_XR = 3
  126475. }
  126476. /**
  126477. * Abstraction of the XR render target
  126478. */
  126479. export interface WebXRRenderTarget extends IDisposable {
  126480. /**
  126481. * xrpresent context of the canvas which can be used to display/mirror xr content
  126482. */
  126483. canvasContext: WebGLRenderingContext;
  126484. /**
  126485. * xr layer for the canvas
  126486. */
  126487. xrLayer: Nullable<XRWebGLLayer>;
  126488. /**
  126489. * Initializes the xr layer for the session
  126490. * @param xrSession xr session
  126491. * @returns a promise that will resolve once the XR Layer has been created
  126492. */
  126493. initializeXRLayerAsync(xrSession: XRSession): Promise<XRWebGLLayer>;
  126494. }
  126495. }
  126496. declare module BABYLON {
  126497. /**
  126498. * COnfiguration object for WebXR output canvas
  126499. */
  126500. export class WebXRManagedOutputCanvasOptions {
  126501. /**
  126502. * An optional canvas in case you wish to create it yourself and provide it here.
  126503. * If not provided, a new canvas will be created
  126504. */
  126505. canvasElement?: HTMLCanvasElement;
  126506. /**
  126507. * Options for this XR Layer output
  126508. */
  126509. canvasOptions?: XRWebGLLayerOptions;
  126510. /**
  126511. * CSS styling for a newly created canvas (if not provided)
  126512. */
  126513. newCanvasCssStyle?: string;
  126514. /**
  126515. * Get the default values of the configuration object
  126516. * @param engine defines the engine to use (can be null)
  126517. * @returns default values of this configuration object
  126518. */
  126519. static GetDefaults(engine?: ThinEngine): WebXRManagedOutputCanvasOptions;
  126520. }
  126521. /**
  126522. * Creates a canvas that is added/removed from the webpage when entering/exiting XR
  126523. */
  126524. export class WebXRManagedOutputCanvas implements WebXRRenderTarget {
  126525. private _options;
  126526. private _canvas;
  126527. private _engine;
  126528. private _originalCanvasSize;
  126529. /**
  126530. * Rendering context of the canvas which can be used to display/mirror xr content
  126531. */
  126532. canvasContext: WebGLRenderingContext;
  126533. /**
  126534. * xr layer for the canvas
  126535. */
  126536. xrLayer: Nullable<XRWebGLLayer>;
  126537. /**
  126538. * Obseervers registered here will be triggered when the xr layer was initialized
  126539. */
  126540. onXRLayerInitObservable: Observable<XRWebGLLayer>;
  126541. /**
  126542. * Initializes the canvas to be added/removed upon entering/exiting xr
  126543. * @param _xrSessionManager The XR Session manager
  126544. * @param _options optional configuration for this canvas output. defaults will be used if not provided
  126545. */
  126546. constructor(_xrSessionManager: WebXRSessionManager, _options?: WebXRManagedOutputCanvasOptions);
  126547. /**
  126548. * Disposes of the object
  126549. */
  126550. dispose(): void;
  126551. /**
  126552. * Initializes the xr layer for the session
  126553. * @param xrSession xr session
  126554. * @returns a promise that will resolve once the XR Layer has been created
  126555. */
  126556. initializeXRLayerAsync(xrSession: XRSession): Promise<XRWebGLLayer>;
  126557. private _addCanvas;
  126558. private _removeCanvas;
  126559. private _setCanvasSize;
  126560. private _setManagedOutputCanvas;
  126561. }
  126562. }
  126563. declare module BABYLON {
  126564. /**
  126565. * Manages an XRSession to work with Babylon's engine
  126566. * @see https://doc.babylonjs.com/how_to/webxr_session_manager
  126567. */
  126568. export class WebXRSessionManager implements IDisposable {
  126569. /** The scene which the session should be created for */
  126570. scene: Scene;
  126571. private _referenceSpace;
  126572. private _rttProvider;
  126573. private _sessionEnded;
  126574. private _xrNavigator;
  126575. private baseLayer;
  126576. /**
  126577. * The base reference space from which the session started. good if you want to reset your
  126578. * reference space
  126579. */
  126580. baseReferenceSpace: XRReferenceSpace;
  126581. /**
  126582. * Current XR frame
  126583. */
  126584. currentFrame: Nullable<XRFrame>;
  126585. /** WebXR timestamp updated every frame */
  126586. currentTimestamp: number;
  126587. /**
  126588. * Used just in case of a failure to initialize an immersive session.
  126589. * The viewer reference space is compensated using this height, creating a kind of "viewer-floor" reference space
  126590. */
  126591. defaultHeightCompensation: number;
  126592. /**
  126593. * Fires every time a new xrFrame arrives which can be used to update the camera
  126594. */
  126595. onXRFrameObservable: Observable<XRFrame>;
  126596. /**
  126597. * Fires when the reference space changed
  126598. */
  126599. onXRReferenceSpaceChanged: Observable<XRReferenceSpace>;
  126600. /**
  126601. * Fires when the xr session is ended either by the device or manually done
  126602. */
  126603. onXRSessionEnded: Observable<any>;
  126604. /**
  126605. * Fires when the xr session is ended either by the device or manually done
  126606. */
  126607. onXRSessionInit: Observable<XRSession>;
  126608. /**
  126609. * Underlying xr session
  126610. */
  126611. session: XRSession;
  126612. /**
  126613. * The viewer (head position) reference space. This can be used to get the XR world coordinates
  126614. * or get the offset the player is currently at.
  126615. */
  126616. viewerReferenceSpace: XRReferenceSpace;
  126617. /**
  126618. * Constructs a WebXRSessionManager, this must be initialized within a user action before usage
  126619. * @param scene The scene which the session should be created for
  126620. */
  126621. constructor(
  126622. /** The scene which the session should be created for */
  126623. scene: Scene);
  126624. /**
  126625. * The current reference space used in this session. This reference space can constantly change!
  126626. * It is mainly used to offset the camera's position.
  126627. */
  126628. get referenceSpace(): XRReferenceSpace;
  126629. /**
  126630. * Set a new reference space and triggers the observable
  126631. */
  126632. set referenceSpace(newReferenceSpace: XRReferenceSpace);
  126633. /**
  126634. * Disposes of the session manager
  126635. */
  126636. dispose(): void;
  126637. /**
  126638. * Stops the xrSession and restores the render loop
  126639. * @returns Promise which resolves after it exits XR
  126640. */
  126641. exitXRAsync(): Promise<void>;
  126642. /**
  126643. * Gets the correct render target texture to be rendered this frame for this eye
  126644. * @param eye the eye for which to get the render target
  126645. * @returns the render target for the specified eye
  126646. */
  126647. getRenderTargetTextureForEye(eye: XREye): RenderTargetTexture;
  126648. /**
  126649. * Creates a WebXRRenderTarget object for the XR session
  126650. * @param onStateChangedObservable optional, mechanism for enabling/disabling XR rendering canvas, used only on Web
  126651. * @param options optional options to provide when creating a new render target
  126652. * @returns a WebXR render target to which the session can render
  126653. */
  126654. getWebXRRenderTarget(options?: WebXRManagedOutputCanvasOptions): WebXRRenderTarget;
  126655. /**
  126656. * Initializes the manager
  126657. * After initialization enterXR can be called to start an XR session
  126658. * @returns Promise which resolves after it is initialized
  126659. */
  126660. initializeAsync(): Promise<void>;
  126661. /**
  126662. * Initializes an xr session
  126663. * @param xrSessionMode mode to initialize
  126664. * @param xrSessionInit defines optional and required values to pass to the session builder
  126665. * @returns a promise which will resolve once the session has been initialized
  126666. */
  126667. initializeSessionAsync(xrSessionMode?: XRSessionMode, xrSessionInit?: XRSessionInit): Promise<XRSession>;
  126668. /**
  126669. * Checks if a session would be supported for the creation options specified
  126670. * @param sessionMode session mode to check if supported eg. immersive-vr
  126671. * @returns A Promise that resolves to true if supported and false if not
  126672. */
  126673. isSessionSupportedAsync(sessionMode: XRSessionMode): Promise<boolean>;
  126674. /**
  126675. * Resets the reference space to the one started the session
  126676. */
  126677. resetReferenceSpace(): void;
  126678. /**
  126679. * Starts rendering to the xr layer
  126680. */
  126681. runXRRenderLoop(): void;
  126682. /**
  126683. * Sets the reference space on the xr session
  126684. * @param referenceSpaceType space to set
  126685. * @returns a promise that will resolve once the reference space has been set
  126686. */
  126687. setReferenceSpaceTypeAsync(referenceSpaceType?: XRReferenceSpaceType): Promise<XRReferenceSpace>;
  126688. /**
  126689. * Updates the render state of the session
  126690. * @param state state to set
  126691. * @returns a promise that resolves once the render state has been updated
  126692. */
  126693. updateRenderStateAsync(state: XRRenderState): Promise<void>;
  126694. /**
  126695. * Returns a promise that resolves with a boolean indicating if the provided session mode is supported by this browser
  126696. * @param sessionMode defines the session to test
  126697. * @returns a promise with boolean as final value
  126698. */
  126699. static IsSessionSupportedAsync(sessionMode: XRSessionMode): Promise<boolean>;
  126700. private _createRenderTargetTexture;
  126701. }
  126702. }
  126703. declare module BABYLON {
  126704. /**
  126705. * WebXR Camera which holds the views for the xrSession
  126706. * @see https://doc.babylonjs.com/how_to/webxr_camera
  126707. */
  126708. export class WebXRCamera extends FreeCamera {
  126709. private _xrSessionManager;
  126710. private _firstFrame;
  126711. private _referenceQuaternion;
  126712. private _referencedPosition;
  126713. private _xrInvPositionCache;
  126714. private _xrInvQuaternionCache;
  126715. /**
  126716. * Observable raised before camera teleportation
  126717. */
  126718. onBeforeCameraTeleport: Observable<Vector3>;
  126719. /**
  126720. * Observable raised after camera teleportation
  126721. */
  126722. onAfterCameraTeleport: Observable<Vector3>;
  126723. /**
  126724. * Should position compensation execute on first frame.
  126725. * This is used when copying the position from a native (non XR) camera
  126726. */
  126727. compensateOnFirstFrame: boolean;
  126728. /**
  126729. * Creates a new webXRCamera, this should only be set at the camera after it has been updated by the xrSessionManager
  126730. * @param name the name of the camera
  126731. * @param scene the scene to add the camera to
  126732. * @param _xrSessionManager a constructed xr session manager
  126733. */
  126734. constructor(name: string, scene: Scene, _xrSessionManager: WebXRSessionManager);
  126735. /**
  126736. * Return the user's height, unrelated to the current ground.
  126737. * This will be the y position of this camera, when ground level is 0.
  126738. */
  126739. get realWorldHeight(): number;
  126740. /** @hidden */
  126741. _updateForDualEyeDebugging(): void;
  126742. /**
  126743. * Sets this camera's transformation based on a non-vr camera
  126744. * @param otherCamera the non-vr camera to copy the transformation from
  126745. * @param resetToBaseReferenceSpace should XR reset to the base reference space
  126746. */
  126747. setTransformationFromNonVRCamera(otherCamera?: Camera, resetToBaseReferenceSpace?: boolean): void;
  126748. /**
  126749. * Gets the current instance class name ("WebXRCamera").
  126750. * @returns the class name
  126751. */
  126752. getClassName(): string;
  126753. private _rotate180;
  126754. private _updateFromXRSession;
  126755. private _updateNumberOfRigCameras;
  126756. private _updateReferenceSpace;
  126757. private _updateReferenceSpaceOffset;
  126758. }
  126759. }
  126760. declare module BABYLON {
  126761. /**
  126762. * Defining the interface required for a (webxr) feature
  126763. */
  126764. export interface IWebXRFeature extends IDisposable {
  126765. /**
  126766. * Is this feature attached
  126767. */
  126768. attached: boolean;
  126769. /**
  126770. * Should auto-attach be disabled?
  126771. */
  126772. disableAutoAttach: boolean;
  126773. /**
  126774. * Attach the feature to the session
  126775. * Will usually be called by the features manager
  126776. *
  126777. * @param force should attachment be forced (even when already attached)
  126778. * @returns true if successful.
  126779. */
  126780. attach(force?: boolean): boolean;
  126781. /**
  126782. * Detach the feature from the session
  126783. * Will usually be called by the features manager
  126784. *
  126785. * @returns true if successful.
  126786. */
  126787. detach(): boolean;
  126788. /**
  126789. * This function will be executed during before enabling the feature and can be used to not-allow enabling it.
  126790. * Note that at this point the session has NOT started, so this is purely checking if the browser supports it
  126791. *
  126792. * @returns whether or not the feature is compatible in this environment
  126793. */
  126794. isCompatible(): boolean;
  126795. /**
  126796. * The name of the native xr feature name, if applicable (like anchor, hit-test, or hand-tracking)
  126797. */
  126798. xrNativeFeatureName?: string;
  126799. /**
  126800. * A list of (Babylon WebXR) features this feature depends on
  126801. */
  126802. dependsOn?: string[];
  126803. }
  126804. /**
  126805. * A list of the currently available features without referencing them
  126806. */
  126807. export class WebXRFeatureName {
  126808. /**
  126809. * The name of the anchor system feature
  126810. */
  126811. static readonly ANCHOR_SYSTEM: string;
  126812. /**
  126813. * The name of the background remover feature
  126814. */
  126815. static readonly BACKGROUND_REMOVER: string;
  126816. /**
  126817. * The name of the hit test feature
  126818. */
  126819. static readonly HIT_TEST: string;
  126820. /**
  126821. * physics impostors for xr controllers feature
  126822. */
  126823. static readonly PHYSICS_CONTROLLERS: string;
  126824. /**
  126825. * The name of the plane detection feature
  126826. */
  126827. static readonly PLANE_DETECTION: string;
  126828. /**
  126829. * The name of the pointer selection feature
  126830. */
  126831. static readonly POINTER_SELECTION: string;
  126832. /**
  126833. * The name of the teleportation feature
  126834. */
  126835. static readonly TELEPORTATION: string;
  126836. /**
  126837. * The name of the feature points feature.
  126838. */
  126839. static readonly FEATURE_POINTS: string;
  126840. /**
  126841. * The name of the hand tracking feature.
  126842. */
  126843. static readonly HAND_TRACKING: string;
  126844. }
  126845. /**
  126846. * Defining the constructor of a feature. Used to register the modules.
  126847. */
  126848. export type WebXRFeatureConstructor = (xrSessionManager: WebXRSessionManager, options?: any) => () => IWebXRFeature;
  126849. /**
  126850. * The WebXR features manager is responsible of enabling or disabling features required for the current XR session.
  126851. * It is mainly used in AR sessions.
  126852. *
  126853. * A feature can have a version that is defined by Babylon (and does not correspond with the webxr version).
  126854. */
  126855. export class WebXRFeaturesManager implements IDisposable {
  126856. private _xrSessionManager;
  126857. private static readonly _AvailableFeatures;
  126858. private _features;
  126859. /**
  126860. * constructs a new features manages.
  126861. *
  126862. * @param _xrSessionManager an instance of WebXRSessionManager
  126863. */
  126864. constructor(_xrSessionManager: WebXRSessionManager);
  126865. /**
  126866. * Used to register a module. After calling this function a developer can use this feature in the scene.
  126867. * Mainly used internally.
  126868. *
  126869. * @param featureName the name of the feature to register
  126870. * @param constructorFunction the function used to construct the module
  126871. * @param version the (babylon) version of the module
  126872. * @param stable is that a stable version of this module
  126873. */
  126874. static AddWebXRFeature(featureName: string, constructorFunction: WebXRFeatureConstructor, version?: number, stable?: boolean): void;
  126875. /**
  126876. * Returns a constructor of a specific feature.
  126877. *
  126878. * @param featureName the name of the feature to construct
  126879. * @param version the version of the feature to load
  126880. * @param xrSessionManager the xrSessionManager. Used to construct the module
  126881. * @param options optional options provided to the module.
  126882. * @returns a function that, when called, will return a new instance of this feature
  126883. */
  126884. static ConstructFeature(featureName: string, version: number | undefined, xrSessionManager: WebXRSessionManager, options?: any): () => IWebXRFeature;
  126885. /**
  126886. * Can be used to return the list of features currently registered
  126887. *
  126888. * @returns an Array of available features
  126889. */
  126890. static GetAvailableFeatures(): string[];
  126891. /**
  126892. * Gets the versions available for a specific feature
  126893. * @param featureName the name of the feature
  126894. * @returns an array with the available versions
  126895. */
  126896. static GetAvailableVersions(featureName: string): string[];
  126897. /**
  126898. * Return the latest unstable version of this feature
  126899. * @param featureName the name of the feature to search
  126900. * @returns the version number. if not found will return -1
  126901. */
  126902. static GetLatestVersionOfFeature(featureName: string): number;
  126903. /**
  126904. * Return the latest stable version of this feature
  126905. * @param featureName the name of the feature to search
  126906. * @returns the version number. if not found will return -1
  126907. */
  126908. static GetStableVersionOfFeature(featureName: string): number;
  126909. /**
  126910. * Attach a feature to the current session. Mainly used when session started to start the feature effect.
  126911. * Can be used during a session to start a feature
  126912. * @param featureName the name of feature to attach
  126913. */
  126914. attachFeature(featureName: string): void;
  126915. /**
  126916. * Can be used inside a session or when the session ends to detach a specific feature
  126917. * @param featureName the name of the feature to detach
  126918. */
  126919. detachFeature(featureName: string): void;
  126920. /**
  126921. * Used to disable an already-enabled feature
  126922. * The feature will be disposed and will be recreated once enabled.
  126923. * @param featureName the feature to disable
  126924. * @returns true if disable was successful
  126925. */
  126926. disableFeature(featureName: string | {
  126927. Name: string;
  126928. }): boolean;
  126929. /**
  126930. * dispose this features manager
  126931. */
  126932. dispose(): void;
  126933. /**
  126934. * 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.
  126935. * 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.
  126936. *
  126937. * @param featureName the name of the feature to load or the class of the feature
  126938. * @param version optional version to load. if not provided the latest version will be enabled
  126939. * @param moduleOptions options provided to the module. Ses the module documentation / constructor
  126940. * @param attachIfPossible if set to true (default) the feature will be automatically attached, if it is currently possible
  126941. * @param required is this feature required to the app. If set to true the session init will fail if the feature is not available.
  126942. * @returns a new constructed feature or throws an error if feature not found.
  126943. */
  126944. enableFeature(featureName: string | {
  126945. Name: string;
  126946. }, version?: number | string, moduleOptions?: any, attachIfPossible?: boolean, required?: boolean): IWebXRFeature;
  126947. /**
  126948. * get the implementation of an enabled feature.
  126949. * @param featureName the name of the feature to load
  126950. * @returns the feature class, if found
  126951. */
  126952. getEnabledFeature(featureName: string): IWebXRFeature;
  126953. /**
  126954. * Get the list of enabled features
  126955. * @returns an array of enabled features
  126956. */
  126957. getEnabledFeatures(): string[];
  126958. /**
  126959. * This function will exten the session creation configuration object with enabled features.
  126960. * If, for example, the anchors feature is enabled, it will be automatically added to the optional or required features list,
  126961. * according to the defined "required" variable, provided during enableFeature call
  126962. * @param xrSessionInit the xr Session init object to extend
  126963. *
  126964. * @returns an extended XRSessionInit object
  126965. */
  126966. extendXRSessionInitObject(xrSessionInit: XRSessionInit): XRSessionInit;
  126967. }
  126968. }
  126969. declare module BABYLON {
  126970. /**
  126971. * Base set of functionality needed to create an XR experience (WebXRSessionManager, Camera, StateManagement, etc.)
  126972. * @see https://doc.babylonjs.com/how_to/webxr_experience_helpers
  126973. */
  126974. export class WebXRExperienceHelper implements IDisposable {
  126975. private scene;
  126976. private _nonVRCamera;
  126977. private _originalSceneAutoClear;
  126978. private _supported;
  126979. /**
  126980. * Camera used to render xr content
  126981. */
  126982. camera: WebXRCamera;
  126983. /** A features manager for this xr session */
  126984. featuresManager: WebXRFeaturesManager;
  126985. /**
  126986. * Observers registered here will be triggered after the camera's initial transformation is set
  126987. * This can be used to set a different ground level or an extra rotation.
  126988. *
  126989. * Note that ground level is considered to be at 0. The height defined by the XR camera will be added
  126990. * to the position set after this observable is done executing.
  126991. */
  126992. onInitialXRPoseSetObservable: Observable<WebXRCamera>;
  126993. /**
  126994. * Fires when the state of the experience helper has changed
  126995. */
  126996. onStateChangedObservable: Observable<WebXRState>;
  126997. /** Session manager used to keep track of xr session */
  126998. sessionManager: WebXRSessionManager;
  126999. /**
  127000. * The current state of the XR experience (eg. transitioning, in XR or not in XR)
  127001. */
  127002. state: WebXRState;
  127003. /**
  127004. * Creates a WebXRExperienceHelper
  127005. * @param scene The scene the helper should be created in
  127006. */
  127007. private constructor();
  127008. /**
  127009. * Creates the experience helper
  127010. * @param scene the scene to attach the experience helper to
  127011. * @returns a promise for the experience helper
  127012. */
  127013. static CreateAsync(scene: Scene): Promise<WebXRExperienceHelper>;
  127014. /**
  127015. * Disposes of the experience helper
  127016. */
  127017. dispose(): void;
  127018. /**
  127019. * Enters XR mode (This must be done within a user interaction in most browsers eg. button click)
  127020. * @param sessionMode options for the XR session
  127021. * @param referenceSpaceType frame of reference of the XR session
  127022. * @param renderTarget the output canvas that will be used to enter XR mode
  127023. * @param sessionCreationOptions optional XRSessionInit object to init the session with
  127024. * @returns promise that resolves after xr mode has entered
  127025. */
  127026. enterXRAsync(sessionMode: XRSessionMode, referenceSpaceType: XRReferenceSpaceType, renderTarget?: WebXRRenderTarget, sessionCreationOptions?: XRSessionInit): Promise<WebXRSessionManager>;
  127027. /**
  127028. * Exits XR mode and returns the scene to its original state
  127029. * @returns promise that resolves after xr mode has exited
  127030. */
  127031. exitXRAsync(): Promise<void>;
  127032. private _nonXRToXRCamera;
  127033. private _setState;
  127034. }
  127035. }
  127036. declare module BABYLON {
  127037. /**
  127038. * X-Y values for axes in WebXR
  127039. */
  127040. export interface IWebXRMotionControllerAxesValue {
  127041. /**
  127042. * The value of the x axis
  127043. */
  127044. x: number;
  127045. /**
  127046. * The value of the y-axis
  127047. */
  127048. y: number;
  127049. }
  127050. /**
  127051. * changed / previous values for the values of this component
  127052. */
  127053. export interface IWebXRMotionControllerComponentChangesValues<T> {
  127054. /**
  127055. * current (this frame) value
  127056. */
  127057. current: T;
  127058. /**
  127059. * previous (last change) value
  127060. */
  127061. previous: T;
  127062. }
  127063. /**
  127064. * Represents changes in the component between current frame and last values recorded
  127065. */
  127066. export interface IWebXRMotionControllerComponentChanges {
  127067. /**
  127068. * will be populated with previous and current values if axes changed
  127069. */
  127070. axes?: IWebXRMotionControllerComponentChangesValues<IWebXRMotionControllerAxesValue>;
  127071. /**
  127072. * will be populated with previous and current values if pressed changed
  127073. */
  127074. pressed?: IWebXRMotionControllerComponentChangesValues<boolean>;
  127075. /**
  127076. * will be populated with previous and current values if touched changed
  127077. */
  127078. touched?: IWebXRMotionControllerComponentChangesValues<boolean>;
  127079. /**
  127080. * will be populated with previous and current values if value changed
  127081. */
  127082. value?: IWebXRMotionControllerComponentChangesValues<number>;
  127083. }
  127084. /**
  127085. * This class represents a single component (for example button or thumbstick) of a motion controller
  127086. */
  127087. export class WebXRControllerComponent implements IDisposable {
  127088. /**
  127089. * the id of this component
  127090. */
  127091. id: string;
  127092. /**
  127093. * the type of the component
  127094. */
  127095. type: MotionControllerComponentType;
  127096. private _buttonIndex;
  127097. private _axesIndices;
  127098. private _axes;
  127099. private _changes;
  127100. private _currentValue;
  127101. private _hasChanges;
  127102. private _pressed;
  127103. private _touched;
  127104. /**
  127105. * button component type
  127106. */
  127107. static BUTTON_TYPE: MotionControllerComponentType;
  127108. /**
  127109. * squeeze component type
  127110. */
  127111. static SQUEEZE_TYPE: MotionControllerComponentType;
  127112. /**
  127113. * Thumbstick component type
  127114. */
  127115. static THUMBSTICK_TYPE: MotionControllerComponentType;
  127116. /**
  127117. * Touchpad component type
  127118. */
  127119. static TOUCHPAD_TYPE: MotionControllerComponentType;
  127120. /**
  127121. * trigger component type
  127122. */
  127123. static TRIGGER_TYPE: MotionControllerComponentType;
  127124. /**
  127125. * If axes are available for this component (like a touchpad or thumbstick) the observers will be notified when
  127126. * the axes data changes
  127127. */
  127128. onAxisValueChangedObservable: Observable<{
  127129. x: number;
  127130. y: number;
  127131. }>;
  127132. /**
  127133. * Observers registered here will be triggered when the state of a button changes
  127134. * State change is either pressed / touched / value
  127135. */
  127136. onButtonStateChangedObservable: Observable<WebXRControllerComponent>;
  127137. /**
  127138. * Creates a new component for a motion controller.
  127139. * It is created by the motion controller itself
  127140. *
  127141. * @param id the id of this component
  127142. * @param type the type of the component
  127143. * @param _buttonIndex index in the buttons array of the gamepad
  127144. * @param _axesIndices indices of the values in the axes array of the gamepad
  127145. */
  127146. constructor(
  127147. /**
  127148. * the id of this component
  127149. */
  127150. id: string,
  127151. /**
  127152. * the type of the component
  127153. */
  127154. type: MotionControllerComponentType, _buttonIndex?: number, _axesIndices?: number[]);
  127155. /**
  127156. * The current axes data. If this component has no axes it will still return an object { x: 0, y: 0 }
  127157. */
  127158. get axes(): IWebXRMotionControllerAxesValue;
  127159. /**
  127160. * Get the changes. Elements will be populated only if they changed with their previous and current value
  127161. */
  127162. get changes(): IWebXRMotionControllerComponentChanges;
  127163. /**
  127164. * Return whether or not the component changed the last frame
  127165. */
  127166. get hasChanges(): boolean;
  127167. /**
  127168. * is the button currently pressed
  127169. */
  127170. get pressed(): boolean;
  127171. /**
  127172. * is the button currently touched
  127173. */
  127174. get touched(): boolean;
  127175. /**
  127176. * Get the current value of this component
  127177. */
  127178. get value(): number;
  127179. /**
  127180. * Dispose this component
  127181. */
  127182. dispose(): void;
  127183. /**
  127184. * Are there axes correlating to this component
  127185. * @return true is axes data is available
  127186. */
  127187. isAxes(): boolean;
  127188. /**
  127189. * Is this component a button (hence - pressable)
  127190. * @returns true if can be pressed
  127191. */
  127192. isButton(): boolean;
  127193. /**
  127194. * update this component using the gamepad object it is in. Called on every frame
  127195. * @param nativeController the native gamepad controller object
  127196. */
  127197. update(nativeController: IMinimalMotionControllerObject): void;
  127198. }
  127199. }
  127200. declare module BABYLON {
  127201. /**
  127202. * Interface used to represent data loading progression
  127203. */
  127204. export interface ISceneLoaderProgressEvent {
  127205. /**
  127206. * Defines if data length to load can be evaluated
  127207. */
  127208. readonly lengthComputable: boolean;
  127209. /**
  127210. * Defines the loaded data length
  127211. */
  127212. readonly loaded: number;
  127213. /**
  127214. * Defines the data length to load
  127215. */
  127216. readonly total: number;
  127217. }
  127218. /**
  127219. * Interface used by SceneLoader plugins to define supported file extensions
  127220. */
  127221. export interface ISceneLoaderPluginExtensions {
  127222. /**
  127223. * Defines the list of supported extensions
  127224. */
  127225. [extension: string]: {
  127226. isBinary: boolean;
  127227. };
  127228. }
  127229. /**
  127230. * Interface used by SceneLoader plugin factory
  127231. */
  127232. export interface ISceneLoaderPluginFactory {
  127233. /**
  127234. * Defines the name of the factory
  127235. */
  127236. name: string;
  127237. /**
  127238. * Function called to create a new plugin
  127239. * @return the new plugin
  127240. */
  127241. createPlugin(): ISceneLoaderPlugin | ISceneLoaderPluginAsync;
  127242. /**
  127243. * The callback that returns true if the data can be directly loaded.
  127244. * @param data string containing the file data
  127245. * @returns if the data can be loaded directly
  127246. */
  127247. canDirectLoad?(data: string): boolean;
  127248. }
  127249. /**
  127250. * Interface used to define the base of ISceneLoaderPlugin and ISceneLoaderPluginAsync
  127251. */
  127252. export interface ISceneLoaderPluginBase {
  127253. /**
  127254. * The friendly name of this plugin.
  127255. */
  127256. name: string;
  127257. /**
  127258. * The file extensions supported by this plugin.
  127259. */
  127260. extensions: string | ISceneLoaderPluginExtensions;
  127261. /**
  127262. * The callback called when loading from a url.
  127263. * @param scene scene loading this url
  127264. * @param url url to load
  127265. * @param onSuccess callback called when the file successfully loads
  127266. * @param onProgress callback called while file is loading (if the server supports this mode)
  127267. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  127268. * @param onError callback called when the file fails to load
  127269. * @returns a file request object
  127270. */
  127271. requestFile?(scene: Scene, url: string, onSuccess: (data: any, request?: WebRequest) => void, onProgress?: (ev: ISceneLoaderProgressEvent) => void, useArrayBuffer?: boolean, onError?: (error: any) => void): IFileRequest;
  127272. /**
  127273. * The callback called when loading from a file object.
  127274. * @param scene scene loading this file
  127275. * @param file defines the file to load
  127276. * @param onSuccess defines the callback to call when data is loaded
  127277. * @param onProgress defines the callback to call during loading process
  127278. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  127279. * @param onError defines the callback to call when an error occurs
  127280. * @returns a file request object
  127281. */
  127282. readFile?(scene: Scene, file: File, onSuccess: (data: any) => void, onProgress?: (ev: ISceneLoaderProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: any) => void): IFileRequest;
  127283. /**
  127284. * The callback that returns true if the data can be directly loaded.
  127285. * @param data string containing the file data
  127286. * @returns if the data can be loaded directly
  127287. */
  127288. canDirectLoad?(data: string): boolean;
  127289. /**
  127290. * The callback that returns the data to pass to the plugin if the data can be directly loaded.
  127291. * @param scene scene loading this data
  127292. * @param data string containing the data
  127293. * @returns data to pass to the plugin
  127294. */
  127295. directLoad?(scene: Scene, data: string): any;
  127296. /**
  127297. * The callback that allows custom handling of the root url based on the response url.
  127298. * @param rootUrl the original root url
  127299. * @param responseURL the response url if available
  127300. * @returns the new root url
  127301. */
  127302. rewriteRootURL?(rootUrl: string, responseURL?: string): string;
  127303. }
  127304. /**
  127305. * Interface used to define a SceneLoader plugin
  127306. */
  127307. export interface ISceneLoaderPlugin extends ISceneLoaderPluginBase {
  127308. /**
  127309. * Import meshes into a scene.
  127310. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  127311. * @param scene The scene to import into
  127312. * @param data The data to import
  127313. * @param rootUrl The root url for scene and resources
  127314. * @param meshes The meshes array to import into
  127315. * @param particleSystems The particle systems array to import into
  127316. * @param skeletons The skeletons array to import into
  127317. * @param onError The callback when import fails
  127318. * @returns True if successful or false otherwise
  127319. */
  127320. importMesh(meshesNames: any, scene: Scene, data: any, rootUrl: string, meshes: AbstractMesh[], particleSystems: IParticleSystem[], skeletons: Skeleton[], onError?: (message: string, exception?: any) => void): boolean;
  127321. /**
  127322. * Load into a scene.
  127323. * @param scene The scene to load into
  127324. * @param data The data to import
  127325. * @param rootUrl The root url for scene and resources
  127326. * @param onError The callback when import fails
  127327. * @returns True if successful or false otherwise
  127328. */
  127329. load(scene: Scene, data: any, rootUrl: string, onError?: (message: string, exception?: any) => void): boolean;
  127330. /**
  127331. * Load into an asset container.
  127332. * @param scene The scene to load into
  127333. * @param data The data to import
  127334. * @param rootUrl The root url for scene and resources
  127335. * @param onError The callback when import fails
  127336. * @returns The loaded asset container
  127337. */
  127338. loadAssetContainer(scene: Scene, data: any, rootUrl: string, onError?: (message: string, exception?: any) => void): AssetContainer;
  127339. }
  127340. /**
  127341. * Interface used to define an async SceneLoader plugin
  127342. */
  127343. export interface ISceneLoaderPluginAsync extends ISceneLoaderPluginBase {
  127344. /**
  127345. * Import meshes into a scene.
  127346. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  127347. * @param scene The scene to import into
  127348. * @param data The data to import
  127349. * @param rootUrl The root url for scene and resources
  127350. * @param onProgress The callback when the load progresses
  127351. * @param fileName Defines the name of the file to load
  127352. * @returns The loaded meshes, particle systems, skeletons, and animation groups
  127353. */
  127354. importMeshAsync(meshesNames: any, scene: Scene, data: any, rootUrl: string, onProgress?: (event: ISceneLoaderProgressEvent) => void, fileName?: string): Promise<{
  127355. meshes: AbstractMesh[];
  127356. particleSystems: IParticleSystem[];
  127357. skeletons: Skeleton[];
  127358. animationGroups: AnimationGroup[];
  127359. }>;
  127360. /**
  127361. * Load into a scene.
  127362. * @param scene The scene to load into
  127363. * @param data The data to import
  127364. * @param rootUrl The root url for scene and resources
  127365. * @param onProgress The callback when the load progresses
  127366. * @param fileName Defines the name of the file to load
  127367. * @returns Nothing
  127368. */
  127369. loadAsync(scene: Scene, data: any, rootUrl: string, onProgress?: (event: ISceneLoaderProgressEvent) => void, fileName?: string): Promise<void>;
  127370. /**
  127371. * Load into an asset container.
  127372. * @param scene The scene to load into
  127373. * @param data The data to import
  127374. * @param rootUrl The root url for scene and resources
  127375. * @param onProgress The callback when the load progresses
  127376. * @param fileName Defines the name of the file to load
  127377. * @returns The loaded asset container
  127378. */
  127379. loadAssetContainerAsync(scene: Scene, data: any, rootUrl: string, onProgress?: (event: ISceneLoaderProgressEvent) => void, fileName?: string): Promise<AssetContainer>;
  127380. }
  127381. /**
  127382. * Mode that determines how to handle old animation groups before loading new ones.
  127383. */
  127384. export enum SceneLoaderAnimationGroupLoadingMode {
  127385. /**
  127386. * Reset all old animations to initial state then dispose them.
  127387. */
  127388. Clean = 0,
  127389. /**
  127390. * Stop all old animations.
  127391. */
  127392. Stop = 1,
  127393. /**
  127394. * Restart old animations from first frame.
  127395. */
  127396. Sync = 2,
  127397. /**
  127398. * Old animations remains untouched.
  127399. */
  127400. NoSync = 3
  127401. }
  127402. /**
  127403. * Defines a plugin registered by the SceneLoader
  127404. */
  127405. interface IRegisteredPlugin {
  127406. /**
  127407. * Defines the plugin to use
  127408. */
  127409. plugin: ISceneLoaderPlugin | ISceneLoaderPluginAsync | ISceneLoaderPluginFactory;
  127410. /**
  127411. * Defines if the plugin supports binary data
  127412. */
  127413. isBinary: boolean;
  127414. }
  127415. /**
  127416. * Class used to load scene from various file formats using registered plugins
  127417. * @see https://doc.babylonjs.com/how_to/load_from_any_file_type
  127418. */
  127419. export class SceneLoader {
  127420. /**
  127421. * No logging while loading
  127422. */
  127423. static readonly NO_LOGGING: number;
  127424. /**
  127425. * Minimal logging while loading
  127426. */
  127427. static readonly MINIMAL_LOGGING: number;
  127428. /**
  127429. * Summary logging while loading
  127430. */
  127431. static readonly SUMMARY_LOGGING: number;
  127432. /**
  127433. * Detailled logging while loading
  127434. */
  127435. static readonly DETAILED_LOGGING: number;
  127436. /**
  127437. * Gets or sets a boolean indicating if entire scene must be loaded even if scene contains incremental data
  127438. */
  127439. static get ForceFullSceneLoadingForIncremental(): boolean;
  127440. static set ForceFullSceneLoadingForIncremental(value: boolean);
  127441. /**
  127442. * Gets or sets a boolean indicating if loading screen must be displayed while loading a scene
  127443. */
  127444. static get ShowLoadingScreen(): boolean;
  127445. static set ShowLoadingScreen(value: boolean);
  127446. /**
  127447. * Defines the current logging level (while loading the scene)
  127448. * @ignorenaming
  127449. */
  127450. static get loggingLevel(): number;
  127451. static set loggingLevel(value: number);
  127452. /**
  127453. * Gets or set a boolean indicating if matrix weights must be cleaned upon loading
  127454. */
  127455. static get CleanBoneMatrixWeights(): boolean;
  127456. static set CleanBoneMatrixWeights(value: boolean);
  127457. /**
  127458. * Event raised when a plugin is used to load a scene
  127459. */
  127460. static OnPluginActivatedObservable: Observable<ISceneLoaderPlugin | ISceneLoaderPluginAsync>;
  127461. private static _registeredPlugins;
  127462. private static _showingLoadingScreen;
  127463. /**
  127464. * Gets the default plugin (used to load Babylon files)
  127465. * @returns the .babylon plugin
  127466. */
  127467. static GetDefaultPlugin(): IRegisteredPlugin;
  127468. private static _GetPluginForExtension;
  127469. private static _GetPluginForDirectLoad;
  127470. private static _GetPluginForFilename;
  127471. private static _GetDirectLoad;
  127472. private static _LoadData;
  127473. private static _GetFileInfo;
  127474. /**
  127475. * Gets a plugin that can load the given extension
  127476. * @param extension defines the extension to load
  127477. * @returns a plugin or null if none works
  127478. */
  127479. static GetPluginForExtension(extension: string): ISceneLoaderPlugin | ISceneLoaderPluginAsync | ISceneLoaderPluginFactory;
  127480. /**
  127481. * Gets a boolean indicating that the given extension can be loaded
  127482. * @param extension defines the extension to load
  127483. * @returns true if the extension is supported
  127484. */
  127485. static IsPluginForExtensionAvailable(extension: string): boolean;
  127486. /**
  127487. * Adds a new plugin to the list of registered plugins
  127488. * @param plugin defines the plugin to add
  127489. */
  127490. static RegisterPlugin(plugin: ISceneLoaderPlugin | ISceneLoaderPluginAsync): void;
  127491. /**
  127492. * Import meshes into a scene
  127493. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  127494. * @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)
  127495. * @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)
  127496. * @param scene the instance of BABYLON.Scene to append to
  127497. * @param onSuccess a callback with a list of imported meshes, particleSystems, and skeletons when import succeeds
  127498. * @param onProgress a callback with a progress event for each file being loaded
  127499. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  127500. * @param pluginExtension the extension used to determine the plugin
  127501. * @returns The loaded plugin
  127502. */
  127503. 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>;
  127504. /**
  127505. * Import meshes into a scene
  127506. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  127507. * @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)
  127508. * @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)
  127509. * @param scene the instance of BABYLON.Scene to append to
  127510. * @param onProgress a callback with a progress event for each file being loaded
  127511. * @param pluginExtension the extension used to determine the plugin
  127512. * @returns The loaded list of imported meshes, particle systems, skeletons, and animation groups
  127513. */
  127514. static ImportMeshAsync(meshNames: any, rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onProgress?: Nullable<(event: ISceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<{
  127515. meshes: AbstractMesh[];
  127516. particleSystems: IParticleSystem[];
  127517. skeletons: Skeleton[];
  127518. animationGroups: AnimationGroup[];
  127519. }>;
  127520. /**
  127521. * Load a scene
  127522. * @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)
  127523. * @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)
  127524. * @param engine is the instance of BABYLON.Engine to use to create the scene
  127525. * @param onSuccess a callback with the scene when import succeeds
  127526. * @param onProgress a callback with a progress event for each file being loaded
  127527. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  127528. * @param pluginExtension the extension used to determine the plugin
  127529. * @returns The loaded plugin
  127530. */
  127531. 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>;
  127532. /**
  127533. * Load a scene
  127534. * @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)
  127535. * @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)
  127536. * @param engine is the instance of BABYLON.Engine to use to create the scene
  127537. * @param onProgress a callback with a progress event for each file being loaded
  127538. * @param pluginExtension the extension used to determine the plugin
  127539. * @returns The loaded scene
  127540. */
  127541. static LoadAsync(rootUrl: string, sceneFilename?: string | File, engine?: Nullable<Engine>, onProgress?: Nullable<(event: ISceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  127542. /**
  127543. * Append a scene
  127544. * @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)
  127545. * @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)
  127546. * @param scene is the instance of BABYLON.Scene to append to
  127547. * @param onSuccess a callback with the scene when import succeeds
  127548. * @param onProgress a callback with a progress event for each file being loaded
  127549. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  127550. * @param pluginExtension the extension used to determine the plugin
  127551. * @returns The loaded plugin
  127552. */
  127553. 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>;
  127554. /**
  127555. * Append a scene
  127556. * @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)
  127557. * @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)
  127558. * @param scene is the instance of BABYLON.Scene to append to
  127559. * @param onProgress a callback with a progress event for each file being loaded
  127560. * @param pluginExtension the extension used to determine the plugin
  127561. * @returns The given scene
  127562. */
  127563. static AppendAsync(rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onProgress?: Nullable<(event: ISceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  127564. /**
  127565. * Load a scene into an asset container
  127566. * @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)
  127567. * @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)
  127568. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  127569. * @param onSuccess a callback with the scene when import succeeds
  127570. * @param onProgress a callback with a progress event for each file being loaded
  127571. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  127572. * @param pluginExtension the extension used to determine the plugin
  127573. * @returns The loaded plugin
  127574. */
  127575. 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>;
  127576. /**
  127577. * Load a scene into an asset container
  127578. * @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)
  127579. * @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)
  127580. * @param scene is the instance of Scene to append to
  127581. * @param onProgress a callback with a progress event for each file being loaded
  127582. * @param pluginExtension the extension used to determine the plugin
  127583. * @returns The loaded asset container
  127584. */
  127585. static LoadAssetContainerAsync(rootUrl: string, sceneFilename?: string, scene?: Nullable<Scene>, onProgress?: Nullable<(event: ISceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<AssetContainer>;
  127586. /**
  127587. * Import animations from a file into a scene
  127588. * @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)
  127589. * @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)
  127590. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  127591. * @param overwriteAnimations when true, animations are cleaned before importing new ones. Animations are appended otherwise
  127592. * @param animationGroupLoadingMode defines how to handle old animations groups before importing new ones
  127593. * @param targetConverter defines a function used to convert animation targets from loaded scene to current scene (default: search node by name)
  127594. * @param onSuccess a callback with the scene when import succeeds
  127595. * @param onProgress a callback with a progress event for each file being loaded
  127596. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  127597. * @param pluginExtension the extension used to determine the plugin
  127598. */
  127599. 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;
  127600. /**
  127601. * Import animations from a file into a scene
  127602. * @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)
  127603. * @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)
  127604. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  127605. * @param overwriteAnimations when true, animations are cleaned before importing new ones. Animations are appended otherwise
  127606. * @param animationGroupLoadingMode defines how to handle old animations groups before importing new ones
  127607. * @param targetConverter defines a function used to convert animation targets from loaded scene to current scene (default: search node by name)
  127608. * @param onSuccess a callback with the scene when import succeeds
  127609. * @param onProgress a callback with a progress event for each file being loaded
  127610. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  127611. * @param pluginExtension the extension used to determine the plugin
  127612. * @returns the updated scene with imported animations
  127613. */
  127614. 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>;
  127615. }
  127616. }
  127617. declare module BABYLON {
  127618. /**
  127619. * Handedness type in xrInput profiles. These can be used to define layouts in the Layout Map.
  127620. */
  127621. export type MotionControllerHandedness = "none" | "left" | "right";
  127622. /**
  127623. * The type of components available in motion controllers.
  127624. * This is not the name of the component.
  127625. */
  127626. export type MotionControllerComponentType = "trigger" | "squeeze" | "touchpad" | "thumbstick" | "button";
  127627. /**
  127628. * The state of a controller component
  127629. */
  127630. export type MotionControllerComponentStateType = "default" | "touched" | "pressed";
  127631. /**
  127632. * The schema of motion controller layout.
  127633. * No object will be initialized using this interface
  127634. * This is used just to define the profile.
  127635. */
  127636. export interface IMotionControllerLayout {
  127637. /**
  127638. * Path to load the assets. Usually relative to the base path
  127639. */
  127640. assetPath: string;
  127641. /**
  127642. * Available components (unsorted)
  127643. */
  127644. components: {
  127645. /**
  127646. * A map of component Ids
  127647. */
  127648. [componentId: string]: {
  127649. /**
  127650. * The type of input the component outputs
  127651. */
  127652. type: MotionControllerComponentType;
  127653. /**
  127654. * The indices of this component in the gamepad object
  127655. */
  127656. gamepadIndices: {
  127657. /**
  127658. * Index of button
  127659. */
  127660. button?: number;
  127661. /**
  127662. * If available, index of x-axis
  127663. */
  127664. xAxis?: number;
  127665. /**
  127666. * If available, index of y-axis
  127667. */
  127668. yAxis?: number;
  127669. };
  127670. /**
  127671. * The mesh's root node name
  127672. */
  127673. rootNodeName: string;
  127674. /**
  127675. * Animation definitions for this model
  127676. */
  127677. visualResponses: {
  127678. [stateKey: string]: {
  127679. /**
  127680. * What property will be animated
  127681. */
  127682. componentProperty: "xAxis" | "yAxis" | "button" | "state";
  127683. /**
  127684. * What states influence this visual response
  127685. */
  127686. states: MotionControllerComponentStateType[];
  127687. /**
  127688. * Type of animation - movement or visibility
  127689. */
  127690. valueNodeProperty: "transform" | "visibility";
  127691. /**
  127692. * Base node name to move. Its position will be calculated according to the min and max nodes
  127693. */
  127694. valueNodeName?: string;
  127695. /**
  127696. * Minimum movement node
  127697. */
  127698. minNodeName?: string;
  127699. /**
  127700. * Max movement node
  127701. */
  127702. maxNodeName?: string;
  127703. };
  127704. };
  127705. /**
  127706. * If touch enabled, what is the name of node to display user feedback
  127707. */
  127708. touchPointNodeName?: string;
  127709. };
  127710. };
  127711. /**
  127712. * Is it xr standard mapping or not
  127713. */
  127714. gamepadMapping: "" | "xr-standard";
  127715. /**
  127716. * Base root node of this entire model
  127717. */
  127718. rootNodeName: string;
  127719. /**
  127720. * Defines the main button component id
  127721. */
  127722. selectComponentId: string;
  127723. }
  127724. /**
  127725. * A definition for the layout map in the input profile
  127726. */
  127727. export interface IMotionControllerLayoutMap {
  127728. /**
  127729. * Layouts with handedness type as a key
  127730. */
  127731. [handedness: string]: IMotionControllerLayout;
  127732. }
  127733. /**
  127734. * The XR Input profile schema
  127735. * Profiles can be found here:
  127736. * https://github.com/immersive-web/webxr-input-profiles/tree/master/packages/registry/profiles
  127737. */
  127738. export interface IMotionControllerProfile {
  127739. /**
  127740. * fallback profiles for this profileId
  127741. */
  127742. fallbackProfileIds: string[];
  127743. /**
  127744. * The layout map, with handedness as key
  127745. */
  127746. layouts: IMotionControllerLayoutMap;
  127747. /**
  127748. * The id of this profile
  127749. * correlates to the profile(s) in the xrInput.profiles array
  127750. */
  127751. profileId: string;
  127752. }
  127753. /**
  127754. * A helper-interface for the 3 meshes needed for controller button animation
  127755. * The meshes are provided to the _lerpButtonTransform function to calculate the current position of the value mesh
  127756. */
  127757. export interface IMotionControllerButtonMeshMap {
  127758. /**
  127759. * the mesh that defines the pressed value mesh position.
  127760. * This is used to find the max-position of this button
  127761. */
  127762. pressedMesh: AbstractMesh;
  127763. /**
  127764. * the mesh that defines the unpressed value mesh position.
  127765. * This is used to find the min (or initial) position of this button
  127766. */
  127767. unpressedMesh: AbstractMesh;
  127768. /**
  127769. * The mesh that will be changed when value changes
  127770. */
  127771. valueMesh: AbstractMesh;
  127772. }
  127773. /**
  127774. * A helper-interface for the 3 meshes needed for controller axis animation.
  127775. * This will be expanded when touchpad animations are fully supported
  127776. * The meshes are provided to the _lerpAxisTransform function to calculate the current position of the value mesh
  127777. */
  127778. export interface IMotionControllerMeshMap {
  127779. /**
  127780. * the mesh that defines the maximum value mesh position.
  127781. */
  127782. maxMesh?: AbstractMesh;
  127783. /**
  127784. * the mesh that defines the minimum value mesh position.
  127785. */
  127786. minMesh?: AbstractMesh;
  127787. /**
  127788. * The mesh that will be changed when axis value changes
  127789. */
  127790. valueMesh?: AbstractMesh;
  127791. }
  127792. /**
  127793. * The elements needed for change-detection of the gamepad objects in motion controllers
  127794. */
  127795. export interface IMinimalMotionControllerObject {
  127796. /**
  127797. * Available axes of this controller
  127798. */
  127799. axes: number[];
  127800. /**
  127801. * An array of available buttons
  127802. */
  127803. buttons: Array<{
  127804. /**
  127805. * Value of the button/trigger
  127806. */
  127807. value: number;
  127808. /**
  127809. * If the button/trigger is currently touched
  127810. */
  127811. touched: boolean;
  127812. /**
  127813. * If the button/trigger is currently pressed
  127814. */
  127815. pressed: boolean;
  127816. }>;
  127817. /**
  127818. * EXPERIMENTAL haptic support.
  127819. */
  127820. hapticActuators?: Array<{
  127821. pulse: (value: number, duration: number) => Promise<boolean>;
  127822. }>;
  127823. }
  127824. /**
  127825. * An Abstract Motion controller
  127826. * This class receives an xrInput and a profile layout and uses those to initialize the components
  127827. * Each component has an observable to check for changes in value and state
  127828. */
  127829. export abstract class WebXRAbstractMotionController implements IDisposable {
  127830. protected scene: Scene;
  127831. protected layout: IMotionControllerLayout;
  127832. /**
  127833. * The gamepad object correlating to this controller
  127834. */
  127835. gamepadObject: IMinimalMotionControllerObject;
  127836. /**
  127837. * handedness (left/right/none) of this controller
  127838. */
  127839. handedness: MotionControllerHandedness;
  127840. private _initComponent;
  127841. private _modelReady;
  127842. /**
  127843. * A map of components (WebXRControllerComponent) in this motion controller
  127844. * Components have a ComponentType and can also have both button and axis definitions
  127845. */
  127846. readonly components: {
  127847. [id: string]: WebXRControllerComponent;
  127848. };
  127849. /**
  127850. * Disable the model's animation. Can be set at any time.
  127851. */
  127852. disableAnimation: boolean;
  127853. /**
  127854. * Observers registered here will be triggered when the model of this controller is done loading
  127855. */
  127856. onModelLoadedObservable: Observable<WebXRAbstractMotionController>;
  127857. /**
  127858. * The profile id of this motion controller
  127859. */
  127860. abstract profileId: string;
  127861. /**
  127862. * The root mesh of the model. It is null if the model was not yet initialized
  127863. */
  127864. rootMesh: Nullable<AbstractMesh>;
  127865. /**
  127866. * constructs a new abstract motion controller
  127867. * @param scene the scene to which the model of the controller will be added
  127868. * @param layout The profile layout to load
  127869. * @param gamepadObject The gamepad object correlating to this controller
  127870. * @param handedness handedness (left/right/none) of this controller
  127871. * @param _doNotLoadControllerMesh set this flag to ignore the mesh loading
  127872. */
  127873. constructor(scene: Scene, layout: IMotionControllerLayout,
  127874. /**
  127875. * The gamepad object correlating to this controller
  127876. */
  127877. gamepadObject: IMinimalMotionControllerObject,
  127878. /**
  127879. * handedness (left/right/none) of this controller
  127880. */
  127881. handedness: MotionControllerHandedness, _doNotLoadControllerMesh?: boolean);
  127882. /**
  127883. * Dispose this controller, the model mesh and all its components
  127884. */
  127885. dispose(): void;
  127886. /**
  127887. * Returns all components of specific type
  127888. * @param type the type to search for
  127889. * @return an array of components with this type
  127890. */
  127891. getAllComponentsOfType(type: MotionControllerComponentType): WebXRControllerComponent[];
  127892. /**
  127893. * get a component based an its component id as defined in layout.components
  127894. * @param id the id of the component
  127895. * @returns the component correlates to the id or undefined if not found
  127896. */
  127897. getComponent(id: string): WebXRControllerComponent;
  127898. /**
  127899. * Get the list of components available in this motion controller
  127900. * @returns an array of strings correlating to available components
  127901. */
  127902. getComponentIds(): string[];
  127903. /**
  127904. * Get the first component of specific type
  127905. * @param type type of component to find
  127906. * @return a controller component or null if not found
  127907. */
  127908. getComponentOfType(type: MotionControllerComponentType): Nullable<WebXRControllerComponent>;
  127909. /**
  127910. * Get the main (Select) component of this controller as defined in the layout
  127911. * @returns the main component of this controller
  127912. */
  127913. getMainComponent(): WebXRControllerComponent;
  127914. /**
  127915. * Loads the model correlating to this controller
  127916. * When the mesh is loaded, the onModelLoadedObservable will be triggered
  127917. * @returns A promise fulfilled with the result of the model loading
  127918. */
  127919. loadModel(): Promise<boolean>;
  127920. /**
  127921. * Update this model using the current XRFrame
  127922. * @param xrFrame the current xr frame to use and update the model
  127923. */
  127924. updateFromXRFrame(xrFrame: XRFrame): void;
  127925. /**
  127926. * Backwards compatibility due to a deeply-integrated typo
  127927. */
  127928. get handness(): XREye;
  127929. /**
  127930. * Pulse (vibrate) this controller
  127931. * If the controller does not support pulses, this function will fail silently and return Promise<false> directly after called
  127932. * Consecutive calls to this function will cancel the last pulse call
  127933. *
  127934. * @param value the strength of the pulse in 0.0...1.0 range
  127935. * @param duration Duration of the pulse in milliseconds
  127936. * @param hapticActuatorIndex optional index of actuator (will usually be 0)
  127937. * @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
  127938. */
  127939. pulse(value: number, duration: number, hapticActuatorIndex?: number): Promise<boolean>;
  127940. protected _getChildByName(node: AbstractMesh, name: string): AbstractMesh | undefined;
  127941. protected _getImmediateChildByName(node: AbstractMesh, name: string): AbstractMesh | undefined;
  127942. /**
  127943. * Moves the axis on the controller mesh based on its current state
  127944. * @param axis the index of the axis
  127945. * @param axisValue the value of the axis which determines the meshes new position
  127946. * @hidden
  127947. */
  127948. protected _lerpTransform(axisMap: IMotionControllerMeshMap, axisValue: number, fixValueCoordinates?: boolean): void;
  127949. /**
  127950. * Update the model itself with the current frame data
  127951. * @param xrFrame the frame to use for updating the model mesh
  127952. */
  127953. protected updateModel(xrFrame: XRFrame): void;
  127954. /**
  127955. * Get the filename and path for this controller's model
  127956. * @returns a map of filename and path
  127957. */
  127958. protected abstract _getFilenameAndPath(): {
  127959. filename: string;
  127960. path: string;
  127961. };
  127962. /**
  127963. * This function is called before the mesh is loaded. It checks for loading constraints.
  127964. * For example, this function can check if the GLB loader is available
  127965. * If this function returns false, the generic controller will be loaded instead
  127966. * @returns Is the client ready to load the mesh
  127967. */
  127968. protected abstract _getModelLoadingConstraints(): boolean;
  127969. /**
  127970. * This function will be called after the model was successfully loaded and can be used
  127971. * for mesh transformations before it is available for the user
  127972. * @param meshes the loaded meshes
  127973. */
  127974. protected abstract _processLoadedModel(meshes: AbstractMesh[]): void;
  127975. /**
  127976. * Set the root mesh for this controller. Important for the WebXR controller class
  127977. * @param meshes the loaded meshes
  127978. */
  127979. protected abstract _setRootMesh(meshes: AbstractMesh[]): void;
  127980. /**
  127981. * A function executed each frame that updates the mesh (if needed)
  127982. * @param xrFrame the current xrFrame
  127983. */
  127984. protected abstract _updateModel(xrFrame: XRFrame): void;
  127985. private _getGenericFilenameAndPath;
  127986. private _getGenericParentMesh;
  127987. }
  127988. }
  127989. declare module BABYLON {
  127990. /**
  127991. * A generic trigger-only motion controller for WebXR
  127992. */
  127993. export class WebXRGenericTriggerMotionController extends WebXRAbstractMotionController {
  127994. /**
  127995. * Static version of the profile id of this controller
  127996. */
  127997. static ProfileId: string;
  127998. profileId: string;
  127999. constructor(scene: Scene, gamepadObject: IMinimalMotionControllerObject, handedness: MotionControllerHandedness);
  128000. protected _getFilenameAndPath(): {
  128001. filename: string;
  128002. path: string;
  128003. };
  128004. protected _getModelLoadingConstraints(): boolean;
  128005. protected _processLoadedModel(meshes: AbstractMesh[]): void;
  128006. protected _setRootMesh(meshes: AbstractMesh[]): void;
  128007. protected _updateModel(): void;
  128008. }
  128009. }
  128010. declare module BABYLON {
  128011. /**
  128012. * Class containing static functions to help procedurally build meshes
  128013. */
  128014. export class SphereBuilder {
  128015. /**
  128016. * Creates a sphere mesh
  128017. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  128018. * * 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`)
  128019. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  128020. * * 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
  128021. * * 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)
  128022. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  128023. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  128024. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  128025. * @param name defines the name of the mesh
  128026. * @param options defines the options used to create the mesh
  128027. * @param scene defines the hosting scene
  128028. * @returns the sphere mesh
  128029. * @see https://doc.babylonjs.com/how_to/set_shapes#sphere
  128030. */
  128031. static CreateSphere(name: string, options: {
  128032. segments?: number;
  128033. diameter?: number;
  128034. diameterX?: number;
  128035. diameterY?: number;
  128036. diameterZ?: number;
  128037. arc?: number;
  128038. slice?: number;
  128039. sideOrientation?: number;
  128040. frontUVs?: Vector4;
  128041. backUVs?: Vector4;
  128042. updatable?: boolean;
  128043. }, scene?: Nullable<Scene>): Mesh;
  128044. }
  128045. }
  128046. declare module BABYLON {
  128047. /**
  128048. * A profiled motion controller has its profile loaded from an online repository.
  128049. * The class is responsible of loading the model, mapping the keys and enabling model-animations
  128050. */
  128051. export class WebXRProfiledMotionController extends WebXRAbstractMotionController {
  128052. private _repositoryUrl;
  128053. private _buttonMeshMapping;
  128054. private _touchDots;
  128055. /**
  128056. * The profile ID of this controller. Will be populated when the controller initializes.
  128057. */
  128058. profileId: string;
  128059. constructor(scene: Scene, xrInput: XRInputSource, _profile: IMotionControllerProfile, _repositoryUrl: string);
  128060. dispose(): void;
  128061. protected _getFilenameAndPath(): {
  128062. filename: string;
  128063. path: string;
  128064. };
  128065. protected _getModelLoadingConstraints(): boolean;
  128066. protected _processLoadedModel(_meshes: AbstractMesh[]): void;
  128067. protected _setRootMesh(meshes: AbstractMesh[]): void;
  128068. protected _updateModel(_xrFrame: XRFrame): void;
  128069. }
  128070. }
  128071. declare module BABYLON {
  128072. /**
  128073. * A construction function type to create a new controller based on an xrInput object
  128074. */
  128075. export type MotionControllerConstructor = (xrInput: XRInputSource, scene: Scene) => WebXRAbstractMotionController;
  128076. /**
  128077. * The MotionController Manager manages all registered motion controllers and loads the right one when needed.
  128078. *
  128079. * When this repository is complete: https://github.com/immersive-web/webxr-input-profiles/tree/master/packages/assets
  128080. * it should be replaced with auto-loaded controllers.
  128081. *
  128082. * When using a model try to stay as generic as possible. Eventually there will be no need in any of the controller classes
  128083. */
  128084. export class WebXRMotionControllerManager {
  128085. private static _AvailableControllers;
  128086. private static _Fallbacks;
  128087. private static _ProfileLoadingPromises;
  128088. private static _ProfilesList;
  128089. /**
  128090. * The base URL of the online controller repository. Can be changed at any time.
  128091. */
  128092. static BaseRepositoryUrl: string;
  128093. /**
  128094. * Which repository gets priority - local or online
  128095. */
  128096. static PrioritizeOnlineRepository: boolean;
  128097. /**
  128098. * Use the online repository, or use only locally-defined controllers
  128099. */
  128100. static UseOnlineRepository: boolean;
  128101. /**
  128102. * Clear the cache used for profile loading and reload when requested again
  128103. */
  128104. static ClearProfilesCache(): void;
  128105. /**
  128106. * Register the default fallbacks.
  128107. * This function is called automatically when this file is imported.
  128108. */
  128109. static DefaultFallbacks(): void;
  128110. /**
  128111. * Find a fallback profile if the profile was not found. There are a few predefined generic profiles.
  128112. * @param profileId the profile to which a fallback needs to be found
  128113. * @return an array with corresponding fallback profiles
  128114. */
  128115. static FindFallbackWithProfileId(profileId: string): string[];
  128116. /**
  128117. * When acquiring a new xrInput object (usually by the WebXRInput class), match it with the correct profile.
  128118. * The order of search:
  128119. *
  128120. * 1) Iterate the profiles array of the xr input and try finding a corresponding motion controller
  128121. * 2) (If not found) search in the gamepad id and try using it (legacy versions only)
  128122. * 3) search for registered fallbacks (should be redundant, nonetheless it makes sense to check)
  128123. * 4) return the generic trigger controller if none were found
  128124. *
  128125. * @param xrInput the xrInput to which a new controller is initialized
  128126. * @param scene the scene to which the model will be added
  128127. * @param forceProfile force a certain profile for this controller
  128128. * @return A promise that fulfils with the motion controller class for this profile id or the generic standard class if none was found
  128129. */
  128130. static GetMotionControllerWithXRInput(xrInput: XRInputSource, scene: Scene, forceProfile?: string): Promise<WebXRAbstractMotionController>;
  128131. /**
  128132. * Register a new controller based on its profile. This function will be called by the controller classes themselves.
  128133. *
  128134. * If you are missing a profile, make sure it is imported in your source, otherwise it will not register.
  128135. *
  128136. * @param type the profile type to register
  128137. * @param constructFunction the function to be called when loading this profile
  128138. */
  128139. static RegisterController(type: string, constructFunction: MotionControllerConstructor): void;
  128140. /**
  128141. * Register a fallback to a specific profile.
  128142. * @param profileId the profileId that will receive the fallbacks
  128143. * @param fallbacks A list of fallback profiles
  128144. */
  128145. static RegisterFallbacksForProfileId(profileId: string, fallbacks: string[]): void;
  128146. /**
  128147. * Will update the list of profiles available in the repository
  128148. * @return a promise that resolves to a map of profiles available online
  128149. */
  128150. static UpdateProfilesList(): Promise<{
  128151. [profile: string]: string;
  128152. }>;
  128153. private static _LoadProfileFromRepository;
  128154. private static _LoadProfilesFromAvailableControllers;
  128155. }
  128156. }
  128157. declare module BABYLON {
  128158. /**
  128159. * Configuration options for the WebXR controller creation
  128160. */
  128161. export interface IWebXRControllerOptions {
  128162. /**
  128163. * Should the controller mesh be animated when a user interacts with it
  128164. * The pressed buttons / thumbstick and touchpad animations will be disabled
  128165. */
  128166. disableMotionControllerAnimation?: boolean;
  128167. /**
  128168. * Do not load the controller mesh, in case a different mesh needs to be loaded.
  128169. */
  128170. doNotLoadControllerMesh?: boolean;
  128171. /**
  128172. * Force a specific controller type for this controller.
  128173. * This can be used when creating your own profile or when testing different controllers
  128174. */
  128175. forceControllerProfile?: string;
  128176. /**
  128177. * Defines a rendering group ID for meshes that will be loaded.
  128178. * This is for the default controllers only.
  128179. */
  128180. renderingGroupId?: number;
  128181. }
  128182. /**
  128183. * Represents an XR controller
  128184. */
  128185. export class WebXRInputSource {
  128186. private _scene;
  128187. /** The underlying input source for the controller */
  128188. inputSource: XRInputSource;
  128189. private _options;
  128190. private _tmpVector;
  128191. private _uniqueId;
  128192. private _disposed;
  128193. /**
  128194. * 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
  128195. */
  128196. grip?: AbstractMesh;
  128197. /**
  128198. * If available, this is the gamepad object related to this controller.
  128199. * Using this object it is possible to get click events and trackpad changes of the
  128200. * webxr controller that is currently being used.
  128201. */
  128202. motionController?: WebXRAbstractMotionController;
  128203. /**
  128204. * Event that fires when the controller is removed/disposed.
  128205. * The object provided as event data is this controller, after associated assets were disposed.
  128206. * uniqueId is still available.
  128207. */
  128208. onDisposeObservable: Observable<WebXRInputSource>;
  128209. /**
  128210. * Will be triggered when the mesh associated with the motion controller is done loading.
  128211. * It is also possible that this will never trigger (!) if no mesh was loaded, or if the developer decides to load a different mesh
  128212. * A shortened version of controller -> motion controller -> on mesh loaded.
  128213. */
  128214. onMeshLoadedObservable: Observable<AbstractMesh>;
  128215. /**
  128216. * Observers registered here will trigger when a motion controller profile was assigned to this xr controller
  128217. */
  128218. onMotionControllerInitObservable: Observable<WebXRAbstractMotionController>;
  128219. /**
  128220. * Pointer which can be used to select objects or attach a visible laser to
  128221. */
  128222. pointer: AbstractMesh;
  128223. /**
  128224. * Creates the input source object
  128225. * @see https://doc.babylonjs.com/how_to/webxr_controllers_support
  128226. * @param _scene the scene which the controller should be associated to
  128227. * @param inputSource the underlying input source for the controller
  128228. * @param _options options for this controller creation
  128229. */
  128230. constructor(_scene: Scene,
  128231. /** The underlying input source for the controller */
  128232. inputSource: XRInputSource, _options?: IWebXRControllerOptions);
  128233. /**
  128234. * Get this controllers unique id
  128235. */
  128236. get uniqueId(): string;
  128237. /**
  128238. * Disposes of the object
  128239. */
  128240. dispose(): void;
  128241. /**
  128242. * Gets a world space ray coming from the pointer or grip
  128243. * @param result the resulting ray
  128244. * @param gripIfAvailable use the grip mesh instead of the pointer, if available
  128245. */
  128246. getWorldPointerRayToRef(result: Ray, gripIfAvailable?: boolean): void;
  128247. /**
  128248. * Updates the controller pose based on the given XRFrame
  128249. * @param xrFrame xr frame to update the pose with
  128250. * @param referenceSpace reference space to use
  128251. */
  128252. updateFromXRFrame(xrFrame: XRFrame, referenceSpace: XRReferenceSpace): void;
  128253. }
  128254. }
  128255. declare module BABYLON {
  128256. /**
  128257. * The schema for initialization options of the XR Input class
  128258. */
  128259. export interface IWebXRInputOptions {
  128260. /**
  128261. * If set to true no model will be automatically loaded
  128262. */
  128263. doNotLoadControllerMeshes?: boolean;
  128264. /**
  128265. * If set, this profile will be used for all controllers loaded (for example "microsoft-mixed-reality")
  128266. * If not found, the xr input profile data will be used.
  128267. * Profiles are defined here - https://github.com/immersive-web/webxr-input-profiles/
  128268. */
  128269. forceInputProfile?: string;
  128270. /**
  128271. * Do not send a request to the controller repository to load the profile.
  128272. *
  128273. * Instead, use the controllers available in babylon itself.
  128274. */
  128275. disableOnlineControllerRepository?: boolean;
  128276. /**
  128277. * A custom URL for the controllers repository
  128278. */
  128279. customControllersRepositoryURL?: string;
  128280. /**
  128281. * Should the controller model's components not move according to the user input
  128282. */
  128283. disableControllerAnimation?: boolean;
  128284. /**
  128285. * Optional options to pass to the controller. Will be overridden by the Input options where applicable
  128286. */
  128287. controllerOptions?: IWebXRControllerOptions;
  128288. }
  128289. /**
  128290. * XR input used to track XR inputs such as controllers/rays
  128291. */
  128292. export class WebXRInput implements IDisposable {
  128293. /**
  128294. * the xr session manager for this session
  128295. */
  128296. xrSessionManager: WebXRSessionManager;
  128297. /**
  128298. * the WebXR camera for this session. Mainly used for teleportation
  128299. */
  128300. xrCamera: WebXRCamera;
  128301. private readonly options;
  128302. /**
  128303. * XR controllers being tracked
  128304. */
  128305. controllers: Array<WebXRInputSource>;
  128306. private _frameObserver;
  128307. private _sessionEndedObserver;
  128308. private _sessionInitObserver;
  128309. /**
  128310. * Event when a controller has been connected/added
  128311. */
  128312. onControllerAddedObservable: Observable<WebXRInputSource>;
  128313. /**
  128314. * Event when a controller has been removed/disconnected
  128315. */
  128316. onControllerRemovedObservable: Observable<WebXRInputSource>;
  128317. /**
  128318. * Initializes the WebXRInput
  128319. * @param xrSessionManager the xr session manager for this session
  128320. * @param xrCamera the WebXR camera for this session. Mainly used for teleportation
  128321. * @param options = initialization options for this xr input
  128322. */
  128323. constructor(
  128324. /**
  128325. * the xr session manager for this session
  128326. */
  128327. xrSessionManager: WebXRSessionManager,
  128328. /**
  128329. * the WebXR camera for this session. Mainly used for teleportation
  128330. */
  128331. xrCamera: WebXRCamera, options?: IWebXRInputOptions);
  128332. private _onInputSourcesChange;
  128333. private _addAndRemoveControllers;
  128334. /**
  128335. * Disposes of the object
  128336. */
  128337. dispose(): void;
  128338. }
  128339. }
  128340. declare module BABYLON {
  128341. /**
  128342. * This is the base class for all WebXR features.
  128343. * Since most features require almost the same resources and callbacks, this class can be used to simplify the development
  128344. * Note that since the features manager is using the `IWebXRFeature` you are in no way obligated to use this class
  128345. */
  128346. export abstract class WebXRAbstractFeature implements IWebXRFeature {
  128347. protected _xrSessionManager: WebXRSessionManager;
  128348. private _attached;
  128349. private _removeOnDetach;
  128350. /**
  128351. * Should auto-attach be disabled?
  128352. */
  128353. disableAutoAttach: boolean;
  128354. /**
  128355. * The name of the native xr feature name (like anchor, hit-test, or hand-tracking)
  128356. */
  128357. xrNativeFeatureName: string;
  128358. /**
  128359. * Construct a new (abstract) WebXR feature
  128360. * @param _xrSessionManager the xr session manager for this feature
  128361. */
  128362. constructor(_xrSessionManager: WebXRSessionManager);
  128363. /**
  128364. * Is this feature attached
  128365. */
  128366. get attached(): boolean;
  128367. /**
  128368. * attach this feature
  128369. *
  128370. * @param force should attachment be forced (even when already attached)
  128371. * @returns true if successful, false is failed or already attached
  128372. */
  128373. attach(force?: boolean): boolean;
  128374. /**
  128375. * detach this feature.
  128376. *
  128377. * @returns true if successful, false if failed or already detached
  128378. */
  128379. detach(): boolean;
  128380. /**
  128381. * Dispose this feature and all of the resources attached
  128382. */
  128383. dispose(): void;
  128384. /**
  128385. * This function will be executed during before enabling the feature and can be used to not-allow enabling it.
  128386. * Note that at this point the session has NOT started, so this is purely checking if the browser supports it
  128387. *
  128388. * @returns whether or not the feature is compatible in this environment
  128389. */
  128390. isCompatible(): boolean;
  128391. /**
  128392. * This is used to register callbacks that will automatically be removed when detach is called.
  128393. * @param observable the observable to which the observer will be attached
  128394. * @param callback the callback to register
  128395. */
  128396. protected _addNewAttachObserver<T>(observable: Observable<T>, callback: (eventData: T, eventState: EventState) => void): void;
  128397. /**
  128398. * Code in this function will be executed on each xrFrame received from the browser.
  128399. * This function will not execute after the feature is detached.
  128400. * @param _xrFrame the current frame
  128401. */
  128402. protected abstract _onXRFrame(_xrFrame: XRFrame): void;
  128403. }
  128404. }
  128405. declare module BABYLON {
  128406. /**
  128407. * Renders a layer on top of an existing scene
  128408. */
  128409. export class UtilityLayerRenderer implements IDisposable {
  128410. /** the original scene that will be rendered on top of */
  128411. originalScene: Scene;
  128412. private _pointerCaptures;
  128413. private _lastPointerEvents;
  128414. private static _DefaultUtilityLayer;
  128415. private static _DefaultKeepDepthUtilityLayer;
  128416. private _sharedGizmoLight;
  128417. private _renderCamera;
  128418. /**
  128419. * Gets the camera that is used to render the utility layer (when not set, this will be the last active camera)
  128420. * @param getRigParentIfPossible if the current active camera is a rig camera, should its parent camera be returned
  128421. * @returns the camera that is used when rendering the utility layer
  128422. */
  128423. getRenderCamera(getRigParentIfPossible?: boolean): Camera;
  128424. /**
  128425. * Sets the camera that should be used when rendering the utility layer (If set to null the last active camera will be used)
  128426. * @param cam the camera that should be used when rendering the utility layer
  128427. */
  128428. setRenderCamera(cam: Nullable<Camera>): void;
  128429. /**
  128430. * @hidden
  128431. * Light which used by gizmos to get light shading
  128432. */
  128433. _getSharedGizmoLight(): HemisphericLight;
  128434. /**
  128435. * If the picking should be done on the utility layer prior to the actual scene (Default: true)
  128436. */
  128437. pickUtilitySceneFirst: boolean;
  128438. /**
  128439. * 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)
  128440. */
  128441. static get DefaultUtilityLayer(): UtilityLayerRenderer;
  128442. /**
  128443. * 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)
  128444. */
  128445. static get DefaultKeepDepthUtilityLayer(): UtilityLayerRenderer;
  128446. /**
  128447. * The scene that is rendered on top of the original scene
  128448. */
  128449. utilityLayerScene: Scene;
  128450. /**
  128451. * If the utility layer should automatically be rendered on top of existing scene
  128452. */
  128453. shouldRender: boolean;
  128454. /**
  128455. * If set to true, only pointer down onPointerObservable events will be blocked when picking is occluded by original scene
  128456. */
  128457. onlyCheckPointerDownEvents: boolean;
  128458. /**
  128459. * If set to false, only pointerUp, pointerDown and pointerMove will be sent to the utilityLayerScene (false by default)
  128460. */
  128461. processAllEvents: boolean;
  128462. /**
  128463. * Observable raised when the pointer move from the utility layer scene to the main scene
  128464. */
  128465. onPointerOutObservable: Observable<number>;
  128466. /** Gets or sets a predicate that will be used to indicate utility meshes present in the main scene */
  128467. mainSceneTrackerPredicate: (mesh: Nullable<AbstractMesh>) => boolean;
  128468. private _afterRenderObserver;
  128469. private _sceneDisposeObserver;
  128470. private _originalPointerObserver;
  128471. /**
  128472. * Instantiates a UtilityLayerRenderer
  128473. * @param originalScene the original scene that will be rendered on top of
  128474. * @param handleEvents boolean indicating if the utility layer should handle events
  128475. */
  128476. constructor(
  128477. /** the original scene that will be rendered on top of */
  128478. originalScene: Scene, handleEvents?: boolean);
  128479. private _notifyObservers;
  128480. /**
  128481. * Renders the utility layers scene on top of the original scene
  128482. */
  128483. render(): void;
  128484. /**
  128485. * Disposes of the renderer
  128486. */
  128487. dispose(): void;
  128488. private _updateCamera;
  128489. }
  128490. }
  128491. declare module BABYLON {
  128492. /**
  128493. * Options interface for the pointer selection module
  128494. */
  128495. export interface IWebXRControllerPointerSelectionOptions {
  128496. /**
  128497. * if provided, this scene will be used to render meshes.
  128498. */
  128499. customUtilityLayerScene?: Scene;
  128500. /**
  128501. * 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)
  128502. * If not disabled, the last picked point will be used to execute a pointer up event
  128503. * If disabled, pointer up event will be triggered right after the pointer down event.
  128504. * Used in screen and gaze target ray mode only
  128505. */
  128506. disablePointerUpOnTouchOut: boolean;
  128507. /**
  128508. * For gaze mode for tracked-pointer / controllers (time to select instead of button press)
  128509. */
  128510. forceGazeMode: boolean;
  128511. /**
  128512. * 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
  128513. * to start a new countdown to the pointer down event.
  128514. * Defaults to 1.
  128515. */
  128516. gazeModePointerMovedFactor?: number;
  128517. /**
  128518. * Different button type to use instead of the main component
  128519. */
  128520. overrideButtonId?: string;
  128521. /**
  128522. * use this rendering group id for the meshes (optional)
  128523. */
  128524. renderingGroupId?: number;
  128525. /**
  128526. * The amount of time in milliseconds it takes between pick found something to a pointer down event.
  128527. * Used in gaze modes. Tracked pointer uses the trigger, screen uses touch events
  128528. * 3000 means 3 seconds between pointing at something and selecting it
  128529. */
  128530. timeToSelect?: number;
  128531. /**
  128532. * Should meshes created here be added to a utility layer or the main scene
  128533. */
  128534. useUtilityLayer?: boolean;
  128535. /**
  128536. * Optional WebXR camera to be used for gaze selection
  128537. */
  128538. gazeCamera?: WebXRCamera;
  128539. /**
  128540. * the xr input to use with this pointer selection
  128541. */
  128542. xrInput: WebXRInput;
  128543. }
  128544. /**
  128545. * A module that will enable pointer selection for motion controllers of XR Input Sources
  128546. */
  128547. export class WebXRControllerPointerSelection extends WebXRAbstractFeature {
  128548. private readonly _options;
  128549. private static _idCounter;
  128550. private _attachController;
  128551. private _controllers;
  128552. private _scene;
  128553. private _tmpVectorForPickCompare;
  128554. /**
  128555. * The module's name
  128556. */
  128557. static readonly Name: string;
  128558. /**
  128559. * The (Babylon) version of this module.
  128560. * This is an integer representing the implementation version.
  128561. * This number does not correspond to the WebXR specs version
  128562. */
  128563. static readonly Version: number;
  128564. /**
  128565. * Disable lighting on the laser pointer (so it will always be visible)
  128566. */
  128567. disablePointerLighting: boolean;
  128568. /**
  128569. * Disable lighting on the selection mesh (so it will always be visible)
  128570. */
  128571. disableSelectionMeshLighting: boolean;
  128572. /**
  128573. * Should the laser pointer be displayed
  128574. */
  128575. displayLaserPointer: boolean;
  128576. /**
  128577. * Should the selection mesh be displayed (The ring at the end of the laser pointer)
  128578. */
  128579. displaySelectionMesh: boolean;
  128580. /**
  128581. * This color will be set to the laser pointer when selection is triggered
  128582. */
  128583. laserPointerPickedColor: Color3;
  128584. /**
  128585. * Default color of the laser pointer
  128586. */
  128587. laserPointerDefaultColor: Color3;
  128588. /**
  128589. * default color of the selection ring
  128590. */
  128591. selectionMeshDefaultColor: Color3;
  128592. /**
  128593. * This color will be applied to the selection ring when selection is triggered
  128594. */
  128595. selectionMeshPickedColor: Color3;
  128596. /**
  128597. * Optional filter to be used for ray selection. This predicate shares behavior with
  128598. * scene.pointerMovePredicate which takes priority if it is also assigned.
  128599. */
  128600. raySelectionPredicate: (mesh: AbstractMesh) => boolean;
  128601. /**
  128602. * constructs a new background remover module
  128603. * @param _xrSessionManager the session manager for this module
  128604. * @param _options read-only options to be used in this module
  128605. */
  128606. constructor(_xrSessionManager: WebXRSessionManager, _options: IWebXRControllerPointerSelectionOptions);
  128607. /**
  128608. * attach this feature
  128609. * Will usually be called by the features manager
  128610. *
  128611. * @returns true if successful.
  128612. */
  128613. attach(): boolean;
  128614. /**
  128615. * detach this feature.
  128616. * Will usually be called by the features manager
  128617. *
  128618. * @returns true if successful.
  128619. */
  128620. detach(): boolean;
  128621. /**
  128622. * Will get the mesh under a specific pointer.
  128623. * `scene.meshUnderPointer` will only return one mesh - either left or right.
  128624. * @param controllerId the controllerId to check
  128625. * @returns The mesh under pointer or null if no mesh is under the pointer
  128626. */
  128627. getMeshUnderPointer(controllerId: string): Nullable<AbstractMesh>;
  128628. /**
  128629. * Get the xr controller that correlates to the pointer id in the pointer event
  128630. *
  128631. * @param id the pointer id to search for
  128632. * @returns the controller that correlates to this id or null if not found
  128633. */
  128634. getXRControllerByPointerId(id: number): Nullable<WebXRInputSource>;
  128635. protected _onXRFrame(_xrFrame: XRFrame): void;
  128636. private _attachGazeMode;
  128637. private _attachScreenRayMode;
  128638. private _attachTrackedPointerRayMode;
  128639. private _convertNormalToDirectionOfRay;
  128640. private _detachController;
  128641. private _generateNewMeshPair;
  128642. private _pickingMoved;
  128643. private _updatePointerDistance;
  128644. /** @hidden */
  128645. get lasterPointerDefaultColor(): Color3;
  128646. }
  128647. }
  128648. declare module BABYLON {
  128649. /**
  128650. * Button which can be used to enter a different mode of XR
  128651. */
  128652. export class WebXREnterExitUIButton {
  128653. /** button element */
  128654. element: HTMLElement;
  128655. /** XR initialization options for the button */
  128656. sessionMode: XRSessionMode;
  128657. /** Reference space type */
  128658. referenceSpaceType: XRReferenceSpaceType;
  128659. /**
  128660. * Creates a WebXREnterExitUIButton
  128661. * @param element button element
  128662. * @param sessionMode XR initialization session mode
  128663. * @param referenceSpaceType the type of reference space to be used
  128664. */
  128665. constructor(
  128666. /** button element */
  128667. element: HTMLElement,
  128668. /** XR initialization options for the button */
  128669. sessionMode: XRSessionMode,
  128670. /** Reference space type */
  128671. referenceSpaceType: XRReferenceSpaceType);
  128672. /**
  128673. * Extendable function which can be used to update the button's visuals when the state changes
  128674. * @param activeButton the current active button in the UI
  128675. */
  128676. update(activeButton: Nullable<WebXREnterExitUIButton>): void;
  128677. }
  128678. /**
  128679. * Options to create the webXR UI
  128680. */
  128681. export class WebXREnterExitUIOptions {
  128682. /**
  128683. * User provided buttons to enable/disable WebXR. The system will provide default if not set
  128684. */
  128685. customButtons?: Array<WebXREnterExitUIButton>;
  128686. /**
  128687. * A reference space type to use when creating the default button.
  128688. * Default is local-floor
  128689. */
  128690. referenceSpaceType?: XRReferenceSpaceType;
  128691. /**
  128692. * Context to enter xr with
  128693. */
  128694. renderTarget?: Nullable<WebXRRenderTarget>;
  128695. /**
  128696. * A session mode to use when creating the default button.
  128697. * Default is immersive-vr
  128698. */
  128699. sessionMode?: XRSessionMode;
  128700. /**
  128701. * A list of optional features to init the session with
  128702. */
  128703. optionalFeatures?: string[];
  128704. /**
  128705. * A list of optional features to init the session with
  128706. */
  128707. requiredFeatures?: string[];
  128708. }
  128709. /**
  128710. * UI to allow the user to enter/exit XR mode
  128711. */
  128712. export class WebXREnterExitUI implements IDisposable {
  128713. private scene;
  128714. /** version of the options passed to this UI */
  128715. options: WebXREnterExitUIOptions;
  128716. private _activeButton;
  128717. private _buttons;
  128718. /**
  128719. * The HTML Div Element to which buttons are added.
  128720. */
  128721. readonly overlay: HTMLDivElement;
  128722. /**
  128723. * Fired every time the active button is changed.
  128724. *
  128725. * When xr is entered via a button that launches xr that button will be the callback parameter
  128726. *
  128727. * When exiting xr the callback parameter will be null)
  128728. */
  128729. activeButtonChangedObservable: Observable<Nullable<WebXREnterExitUIButton>>;
  128730. /**
  128731. *
  128732. * @param scene babylon scene object to use
  128733. * @param options (read-only) version of the options passed to this UI
  128734. */
  128735. private constructor();
  128736. /**
  128737. * Creates UI to allow the user to enter/exit XR mode
  128738. * @param scene the scene to add the ui to
  128739. * @param helper the xr experience helper to enter/exit xr with
  128740. * @param options options to configure the UI
  128741. * @returns the created ui
  128742. */
  128743. static CreateAsync(scene: Scene, helper: WebXRExperienceHelper, options: WebXREnterExitUIOptions): Promise<WebXREnterExitUI>;
  128744. /**
  128745. * Disposes of the XR UI component
  128746. */
  128747. dispose(): void;
  128748. private _updateButtons;
  128749. }
  128750. }
  128751. declare module BABYLON {
  128752. /**
  128753. * Class containing static functions to help procedurally build meshes
  128754. */
  128755. export class LinesBuilder {
  128756. /**
  128757. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  128758. * * 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
  128759. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  128760. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  128761. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  128762. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  128763. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  128764. * * 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
  128765. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  128766. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  128767. * @see https://doc.babylonjs.com/how_to/parametric_shapes#line-system
  128768. * @param name defines the name of the new line system
  128769. * @param options defines the options used to create the line system
  128770. * @param scene defines the hosting scene
  128771. * @returns a new line system mesh
  128772. */
  128773. static CreateLineSystem(name: string, options: {
  128774. lines: Vector3[][];
  128775. updatable?: boolean;
  128776. instance?: Nullable<LinesMesh>;
  128777. colors?: Nullable<Color4[][]>;
  128778. useVertexAlpha?: boolean;
  128779. }, scene: Nullable<Scene>): LinesMesh;
  128780. /**
  128781. * Creates a line mesh
  128782. * 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
  128783. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  128784. * * The parameter `points` is an array successive Vector3
  128785. * * 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
  128786. * * The optional parameter `colors` is an array of successive Color4, one per line point
  128787. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  128788. * * When updating an instance, remember that only point positions can change, not the number of points
  128789. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  128790. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lines
  128791. * @param name defines the name of the new line system
  128792. * @param options defines the options used to create the line system
  128793. * @param scene defines the hosting scene
  128794. * @returns a new line mesh
  128795. */
  128796. static CreateLines(name: string, options: {
  128797. points: Vector3[];
  128798. updatable?: boolean;
  128799. instance?: Nullable<LinesMesh>;
  128800. colors?: Color4[];
  128801. useVertexAlpha?: boolean;
  128802. }, scene?: Nullable<Scene>): LinesMesh;
  128803. /**
  128804. * Creates a dashed line mesh
  128805. * * 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
  128806. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  128807. * * The parameter `points` is an array successive Vector3
  128808. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  128809. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  128810. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  128811. * * 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
  128812. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  128813. * * When updating an instance, remember that only point positions can change, not the number of points
  128814. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  128815. * @param name defines the name of the mesh
  128816. * @param options defines the options used to create the mesh
  128817. * @param scene defines the hosting scene
  128818. * @returns the dashed line mesh
  128819. * @see https://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  128820. */
  128821. static CreateDashedLines(name: string, options: {
  128822. points: Vector3[];
  128823. dashSize?: number;
  128824. gapSize?: number;
  128825. dashNb?: number;
  128826. updatable?: boolean;
  128827. instance?: LinesMesh;
  128828. useVertexAlpha?: boolean;
  128829. }, scene?: Nullable<Scene>): LinesMesh;
  128830. }
  128831. }
  128832. declare module BABYLON {
  128833. /**
  128834. * Construction options for a timer
  128835. */
  128836. export interface ITimerOptions<T> {
  128837. /**
  128838. * Time-to-end
  128839. */
  128840. timeout: number;
  128841. /**
  128842. * The context observable is used to calculate time deltas and provides the context of the timer's callbacks. Will usually be OnBeforeRenderObservable.
  128843. * Countdown calculation is done ONLY when the observable is notifying its observers, meaning that if
  128844. * you choose an observable that doesn't trigger too often, the wait time might extend further than the requested max time
  128845. */
  128846. contextObservable: Observable<T>;
  128847. /**
  128848. * Optional parameters when adding an observer to the observable
  128849. */
  128850. observableParameters?: {
  128851. mask?: number;
  128852. insertFirst?: boolean;
  128853. scope?: any;
  128854. };
  128855. /**
  128856. * An optional break condition that will stop the times prematurely. In this case onEnded will not be triggered!
  128857. */
  128858. breakCondition?: (data?: ITimerData<T>) => boolean;
  128859. /**
  128860. * Will be triggered when the time condition has met
  128861. */
  128862. onEnded?: (data: ITimerData<any>) => void;
  128863. /**
  128864. * Will be triggered when the break condition has met (prematurely ended)
  128865. */
  128866. onAborted?: (data: ITimerData<any>) => void;
  128867. /**
  128868. * Optional function to execute on each tick (or count)
  128869. */
  128870. onTick?: (data: ITimerData<any>) => void;
  128871. }
  128872. /**
  128873. * An interface defining the data sent by the timer
  128874. */
  128875. export interface ITimerData<T> {
  128876. /**
  128877. * When did it start
  128878. */
  128879. startTime: number;
  128880. /**
  128881. * Time now
  128882. */
  128883. currentTime: number;
  128884. /**
  128885. * Time passed since started
  128886. */
  128887. deltaTime: number;
  128888. /**
  128889. * How much is completed, in [0.0...1.0].
  128890. * Note that this CAN be higher than 1 due to the fact that we don't actually measure time but delta between observable calls
  128891. */
  128892. completeRate: number;
  128893. /**
  128894. * What the registered observable sent in the last count
  128895. */
  128896. payload: T;
  128897. }
  128898. /**
  128899. * The current state of the timer
  128900. */
  128901. export enum TimerState {
  128902. /**
  128903. * Timer initialized, not yet started
  128904. */
  128905. INIT = 0,
  128906. /**
  128907. * Timer started and counting
  128908. */
  128909. STARTED = 1,
  128910. /**
  128911. * Timer ended (whether aborted or time reached)
  128912. */
  128913. ENDED = 2
  128914. }
  128915. /**
  128916. * A simple version of the timer. Will take options and start the timer immediately after calling it
  128917. *
  128918. * @param options options with which to initialize this timer
  128919. */
  128920. export function setAndStartTimer(options: ITimerOptions<any>): Nullable<Observer<any>>;
  128921. /**
  128922. * An advanced implementation of a timer class
  128923. */
  128924. export class AdvancedTimer<T = any> implements IDisposable {
  128925. /**
  128926. * Will notify each time the timer calculates the remaining time
  128927. */
  128928. onEachCountObservable: Observable<ITimerData<T>>;
  128929. /**
  128930. * Will trigger when the timer was aborted due to the break condition
  128931. */
  128932. onTimerAbortedObservable: Observable<ITimerData<T>>;
  128933. /**
  128934. * Will trigger when the timer ended successfully
  128935. */
  128936. onTimerEndedObservable: Observable<ITimerData<T>>;
  128937. /**
  128938. * Will trigger when the timer state has changed
  128939. */
  128940. onStateChangedObservable: Observable<TimerState>;
  128941. private _observer;
  128942. private _contextObservable;
  128943. private _observableParameters;
  128944. private _startTime;
  128945. private _timer;
  128946. private _state;
  128947. private _breakCondition;
  128948. private _timeToEnd;
  128949. private _breakOnNextTick;
  128950. /**
  128951. * Will construct a new advanced timer based on the options provided. Timer will not start until start() is called.
  128952. * @param options construction options for this advanced timer
  128953. */
  128954. constructor(options: ITimerOptions<T>);
  128955. /**
  128956. * set a breaking condition for this timer. Default is to never break during count
  128957. * @param predicate the new break condition. Returns true to break, false otherwise
  128958. */
  128959. set breakCondition(predicate: (data: ITimerData<T>) => boolean);
  128960. /**
  128961. * Reset ALL associated observables in this advanced timer
  128962. */
  128963. clearObservables(): void;
  128964. /**
  128965. * Will start a new iteration of this timer. Only one instance of this timer can run at a time.
  128966. *
  128967. * @param timeToEnd how much time to measure until timer ended
  128968. */
  128969. start(timeToEnd?: number): void;
  128970. /**
  128971. * Will force a stop on the next tick.
  128972. */
  128973. stop(): void;
  128974. /**
  128975. * Dispose this timer, clearing all resources
  128976. */
  128977. dispose(): void;
  128978. private _setState;
  128979. private _tick;
  128980. private _stop;
  128981. }
  128982. }
  128983. declare module BABYLON {
  128984. /**
  128985. * The options container for the teleportation module
  128986. */
  128987. export interface IWebXRTeleportationOptions {
  128988. /**
  128989. * if provided, this scene will be used to render meshes.
  128990. */
  128991. customUtilityLayerScene?: Scene;
  128992. /**
  128993. * Values to configure the default target mesh
  128994. */
  128995. defaultTargetMeshOptions?: {
  128996. /**
  128997. * Fill color of the teleportation area
  128998. */
  128999. teleportationFillColor?: string;
  129000. /**
  129001. * Border color for the teleportation area
  129002. */
  129003. teleportationBorderColor?: string;
  129004. /**
  129005. * Disable the mesh's animation sequence
  129006. */
  129007. disableAnimation?: boolean;
  129008. /**
  129009. * Disable lighting on the material or the ring and arrow
  129010. */
  129011. disableLighting?: boolean;
  129012. /**
  129013. * Override the default material of the torus and arrow
  129014. */
  129015. torusArrowMaterial?: Material;
  129016. };
  129017. /**
  129018. * A list of meshes to use as floor meshes.
  129019. * Meshes can be added and removed after initializing the feature using the
  129020. * addFloorMesh and removeFloorMesh functions
  129021. * If empty, rotation will still work
  129022. */
  129023. floorMeshes?: AbstractMesh[];
  129024. /**
  129025. * use this rendering group id for the meshes (optional)
  129026. */
  129027. renderingGroupId?: number;
  129028. /**
  129029. * Should teleportation move only to snap points
  129030. */
  129031. snapPointsOnly?: boolean;
  129032. /**
  129033. * An array of points to which the teleportation will snap to.
  129034. * If the teleportation ray is in the proximity of one of those points, it will be corrected to this point.
  129035. */
  129036. snapPositions?: Vector3[];
  129037. /**
  129038. * How close should the teleportation ray be in order to snap to position.
  129039. * Default to 0.8 units (meters)
  129040. */
  129041. snapToPositionRadius?: number;
  129042. /**
  129043. * Provide your own teleportation mesh instead of babylon's wonderful doughnut.
  129044. * If you want to support rotation, make sure your mesh has a direction indicator.
  129045. *
  129046. * When left untouched, the default mesh will be initialized.
  129047. */
  129048. teleportationTargetMesh?: AbstractMesh;
  129049. /**
  129050. * If main component is used (no thumbstick), how long should the "long press" take before teleport
  129051. */
  129052. timeToTeleport?: number;
  129053. /**
  129054. * Disable using the thumbstick and use the main component (usually trigger) on long press.
  129055. * This will be automatically true if the controller doesn't have a thumbstick or touchpad.
  129056. */
  129057. useMainComponentOnly?: boolean;
  129058. /**
  129059. * Should meshes created here be added to a utility layer or the main scene
  129060. */
  129061. useUtilityLayer?: boolean;
  129062. /**
  129063. * Babylon XR Input class for controller
  129064. */
  129065. xrInput: WebXRInput;
  129066. /**
  129067. * Meshes that the teleportation ray cannot go through
  129068. */
  129069. pickBlockerMeshes?: AbstractMesh[];
  129070. }
  129071. /**
  129072. * This is a teleportation feature to be used with WebXR-enabled motion controllers.
  129073. * When enabled and attached, the feature will allow a user to move around and rotate in the scene using
  129074. * the input of the attached controllers.
  129075. */
  129076. export class WebXRMotionControllerTeleportation extends WebXRAbstractFeature {
  129077. private _options;
  129078. private _controllers;
  129079. private _currentTeleportationControllerId;
  129080. private _floorMeshes;
  129081. private _quadraticBezierCurve;
  129082. private _selectionFeature;
  129083. private _snapToPositions;
  129084. private _snappedToPoint;
  129085. private _teleportationRingMaterial?;
  129086. private _tmpRay;
  129087. private _tmpVector;
  129088. private _tmpQuaternion;
  129089. /**
  129090. * The module's name
  129091. */
  129092. static readonly Name: string;
  129093. /**
  129094. * The (Babylon) version of this module.
  129095. * This is an integer representing the implementation version.
  129096. * This number does not correspond to the webxr specs version
  129097. */
  129098. static readonly Version: number;
  129099. /**
  129100. * Is movement backwards enabled
  129101. */
  129102. backwardsMovementEnabled: boolean;
  129103. /**
  129104. * Distance to travel when moving backwards
  129105. */
  129106. backwardsTeleportationDistance: number;
  129107. /**
  129108. * The distance from the user to the inspection point in the direction of the controller
  129109. * A higher number will allow the user to move further
  129110. * defaults to 5 (meters, in xr units)
  129111. */
  129112. parabolicCheckRadius: number;
  129113. /**
  129114. * Should the module support parabolic ray on top of direct ray
  129115. * If enabled, the user will be able to point "at the sky" and move according to predefined radius distance
  129116. * Very helpful when moving between floors / different heights
  129117. */
  129118. parabolicRayEnabled: boolean;
  129119. /**
  129120. * How much rotation should be applied when rotating right and left
  129121. */
  129122. rotationAngle: number;
  129123. /**
  129124. * Is rotation enabled when moving forward?
  129125. * Disabling this feature will prevent the user from deciding the direction when teleporting
  129126. */
  129127. rotationEnabled: boolean;
  129128. /**
  129129. * constructs a new anchor system
  129130. * @param _xrSessionManager an instance of WebXRSessionManager
  129131. * @param _options configuration object for this feature
  129132. */
  129133. constructor(_xrSessionManager: WebXRSessionManager, _options: IWebXRTeleportationOptions);
  129134. /**
  129135. * Get the snapPointsOnly flag
  129136. */
  129137. get snapPointsOnly(): boolean;
  129138. /**
  129139. * Sets the snapPointsOnly flag
  129140. * @param snapToPoints should teleportation be exclusively to snap points
  129141. */
  129142. set snapPointsOnly(snapToPoints: boolean);
  129143. /**
  129144. * Add a new mesh to the floor meshes array
  129145. * @param mesh the mesh to use as floor mesh
  129146. */
  129147. addFloorMesh(mesh: AbstractMesh): void;
  129148. /**
  129149. * Add a new snap-to point to fix teleportation to this position
  129150. * @param newSnapPoint The new Snap-To point
  129151. */
  129152. addSnapPoint(newSnapPoint: Vector3): void;
  129153. attach(): boolean;
  129154. detach(): boolean;
  129155. dispose(): void;
  129156. /**
  129157. * Remove a mesh from the floor meshes array
  129158. * @param mesh the mesh to remove
  129159. */
  129160. removeFloorMesh(mesh: AbstractMesh): void;
  129161. /**
  129162. * Remove a mesh from the floor meshes array using its name
  129163. * @param name the mesh name to remove
  129164. */
  129165. removeFloorMeshByName(name: string): void;
  129166. /**
  129167. * 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
  129168. * @param snapPointToRemove the point (or a clone of it) to be removed from the array
  129169. * @returns was the point found and removed or not
  129170. */
  129171. removeSnapPoint(snapPointToRemove: Vector3): boolean;
  129172. /**
  129173. * This function sets a selection feature that will be disabled when
  129174. * the forward ray is shown and will be reattached when hidden.
  129175. * This is used to remove the selection rays when moving.
  129176. * @param selectionFeature the feature to disable when forward movement is enabled
  129177. */
  129178. setSelectionFeature(selectionFeature: IWebXRFeature): void;
  129179. protected _onXRFrame(_xrFrame: XRFrame): void;
  129180. private _attachController;
  129181. private _createDefaultTargetMesh;
  129182. private _detachController;
  129183. private _findClosestSnapPointWithRadius;
  129184. private _setTargetMeshPosition;
  129185. private _setTargetMeshVisibility;
  129186. private _showParabolicPath;
  129187. private _teleportForward;
  129188. }
  129189. }
  129190. declare module BABYLON {
  129191. /**
  129192. * Options for the default xr helper
  129193. */
  129194. export class WebXRDefaultExperienceOptions {
  129195. /**
  129196. * Enable or disable default UI to enter XR
  129197. */
  129198. disableDefaultUI?: boolean;
  129199. /**
  129200. * Should teleportation not initialize. defaults to false.
  129201. */
  129202. disableTeleportation?: boolean;
  129203. /**
  129204. * Floor meshes that will be used for teleport
  129205. */
  129206. floorMeshes?: Array<AbstractMesh>;
  129207. /**
  129208. * If set to true, the first frame will not be used to reset position
  129209. * The first frame is mainly used when copying transformation from the old camera
  129210. * Mainly used in AR
  129211. */
  129212. ignoreNativeCameraTransformation?: boolean;
  129213. /**
  129214. * Disable the controller mesh-loading. Can be used if you want to load your own meshes
  129215. */
  129216. inputOptions?: IWebXRInputOptions;
  129217. /**
  129218. * optional configuration for the output canvas
  129219. */
  129220. outputCanvasOptions?: WebXRManagedOutputCanvasOptions;
  129221. /**
  129222. * optional UI options. This can be used among other to change session mode and reference space type
  129223. */
  129224. uiOptions?: WebXREnterExitUIOptions;
  129225. /**
  129226. * When loading teleportation and pointer select, use stable versions instead of latest.
  129227. */
  129228. useStablePlugins?: boolean;
  129229. /**
  129230. * An optional rendering group id that will be set globally for teleportation, pointer selection and default controller meshes
  129231. */
  129232. renderingGroupId?: number;
  129233. /**
  129234. * A list of optional features to init the session with
  129235. * If set to true, all features we support will be added
  129236. */
  129237. optionalFeatures?: boolean | string[];
  129238. }
  129239. /**
  129240. * Default experience which provides a similar setup to the previous webVRExperience
  129241. */
  129242. export class WebXRDefaultExperience {
  129243. /**
  129244. * Base experience
  129245. */
  129246. baseExperience: WebXRExperienceHelper;
  129247. /**
  129248. * Enables ui for entering/exiting xr
  129249. */
  129250. enterExitUI: WebXREnterExitUI;
  129251. /**
  129252. * Input experience extension
  129253. */
  129254. input: WebXRInput;
  129255. /**
  129256. * Enables laser pointer and selection
  129257. */
  129258. pointerSelection: WebXRControllerPointerSelection;
  129259. /**
  129260. * Default target xr should render to
  129261. */
  129262. renderTarget: WebXRRenderTarget;
  129263. /**
  129264. * Enables teleportation
  129265. */
  129266. teleportation: WebXRMotionControllerTeleportation;
  129267. private constructor();
  129268. /**
  129269. * Creates the default xr experience
  129270. * @param scene scene
  129271. * @param options options for basic configuration
  129272. * @returns resulting WebXRDefaultExperience
  129273. */
  129274. static CreateAsync(scene: Scene, options?: WebXRDefaultExperienceOptions): Promise<WebXRDefaultExperience>;
  129275. /**
  129276. * DIsposes of the experience helper
  129277. */
  129278. dispose(): void;
  129279. }
  129280. }
  129281. declare module BABYLON {
  129282. /**
  129283. * Options to modify the vr teleportation behavior.
  129284. */
  129285. export interface VRTeleportationOptions {
  129286. /**
  129287. * The name of the mesh which should be used as the teleportation floor. (default: null)
  129288. */
  129289. floorMeshName?: string;
  129290. /**
  129291. * A list of meshes to be used as the teleportation floor. (default: empty)
  129292. */
  129293. floorMeshes?: Mesh[];
  129294. /**
  129295. * The teleportation mode. (default: TELEPORTATIONMODE_CONSTANTTIME)
  129296. */
  129297. teleportationMode?: number;
  129298. /**
  129299. * The duration of the animation in ms, apply when animationMode is TELEPORTATIONMODE_CONSTANTTIME. (default 122ms)
  129300. */
  129301. teleportationTime?: number;
  129302. /**
  129303. * The speed of the animation in distance/sec, apply when animationMode is TELEPORTATIONMODE_CONSTANTSPEED. (default 20 units / sec)
  129304. */
  129305. teleportationSpeed?: number;
  129306. /**
  129307. * The easing function used in the animation or null for Linear. (default CircleEase)
  129308. */
  129309. easingFunction?: EasingFunction;
  129310. }
  129311. /**
  129312. * Options to modify the vr experience helper's behavior.
  129313. */
  129314. export interface VRExperienceHelperOptions extends WebVROptions {
  129315. /**
  129316. * Create a DeviceOrientationCamera to be used as your out of vr camera. (default: true)
  129317. */
  129318. createDeviceOrientationCamera?: boolean;
  129319. /**
  129320. * Create a VRDeviceOrientationFreeCamera to be used for VR when no external HMD is found. (default: true)
  129321. */
  129322. createFallbackVRDeviceOrientationFreeCamera?: boolean;
  129323. /**
  129324. * Uses the main button on the controller to toggle the laser casted. (default: true)
  129325. */
  129326. laserToggle?: boolean;
  129327. /**
  129328. * A list of meshes to be used as the teleportation floor. If specified, teleportation will be enabled (default: undefined)
  129329. */
  129330. floorMeshes?: Mesh[];
  129331. /**
  129332. * Distortion metrics for the fallback vrDeviceOrientationCamera (default: VRCameraMetrics.Default)
  129333. */
  129334. vrDeviceOrientationCameraMetrics?: VRCameraMetrics;
  129335. /**
  129336. * Defines if WebXR should be used instead of WebVR (if available)
  129337. */
  129338. useXR?: boolean;
  129339. }
  129340. /**
  129341. * Event containing information after VR has been entered
  129342. */
  129343. export class OnAfterEnteringVRObservableEvent {
  129344. /**
  129345. * If entering vr was successful
  129346. */
  129347. success: boolean;
  129348. }
  129349. /**
  129350. * Helps to quickly add VR support to an existing scene.
  129351. * See https://doc.babylonjs.com/how_to/webvr_helper
  129352. */
  129353. export class VRExperienceHelper {
  129354. /** Options to modify the vr experience helper's behavior. */
  129355. webVROptions: VRExperienceHelperOptions;
  129356. private _scene;
  129357. private _position;
  129358. private _btnVR;
  129359. private _btnVRDisplayed;
  129360. private _webVRsupported;
  129361. private _webVRready;
  129362. private _webVRrequesting;
  129363. private _webVRpresenting;
  129364. private _hasEnteredVR;
  129365. private _fullscreenVRpresenting;
  129366. private _inputElement;
  129367. private _webVRCamera;
  129368. private _vrDeviceOrientationCamera;
  129369. private _deviceOrientationCamera;
  129370. private _existingCamera;
  129371. private _onKeyDown;
  129372. private _onVrDisplayPresentChange;
  129373. private _onVRDisplayChanged;
  129374. private _onVRRequestPresentStart;
  129375. private _onVRRequestPresentComplete;
  129376. /**
  129377. * 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)
  129378. */
  129379. enableGazeEvenWhenNoPointerLock: boolean;
  129380. /**
  129381. * Gets or sets a boolean indicating that the VREXperienceHelper will exit VR if double tap is detected
  129382. */
  129383. exitVROnDoubleTap: boolean;
  129384. /**
  129385. * Observable raised right before entering VR.
  129386. */
  129387. onEnteringVRObservable: Observable<VRExperienceHelper>;
  129388. /**
  129389. * Observable raised when entering VR has completed.
  129390. */
  129391. onAfterEnteringVRObservable: Observable<OnAfterEnteringVRObservableEvent>;
  129392. /**
  129393. * Observable raised when exiting VR.
  129394. */
  129395. onExitingVRObservable: Observable<VRExperienceHelper>;
  129396. /**
  129397. * Observable raised when controller mesh is loaded.
  129398. */
  129399. onControllerMeshLoadedObservable: Observable<WebVRController>;
  129400. /** Return this.onEnteringVRObservable
  129401. * Note: This one is for backward compatibility. Please use onEnteringVRObservable directly
  129402. */
  129403. get onEnteringVR(): Observable<VRExperienceHelper>;
  129404. /** Return this.onExitingVRObservable
  129405. * Note: This one is for backward compatibility. Please use onExitingVRObservable directly
  129406. */
  129407. get onExitingVR(): Observable<VRExperienceHelper>;
  129408. /** Return this.onControllerMeshLoadedObservable
  129409. * Note: This one is for backward compatibility. Please use onControllerMeshLoadedObservable directly
  129410. */
  129411. get onControllerMeshLoaded(): Observable<WebVRController>;
  129412. private _rayLength;
  129413. private _useCustomVRButton;
  129414. private _teleportationRequested;
  129415. private _teleportActive;
  129416. private _floorMeshName;
  129417. private _floorMeshesCollection;
  129418. private _teleportationMode;
  129419. private _teleportationTime;
  129420. private _teleportationSpeed;
  129421. private _teleportationEasing;
  129422. private _rotationAllowed;
  129423. private _teleportBackwardsVector;
  129424. private _teleportationTarget;
  129425. private _isDefaultTeleportationTarget;
  129426. private _postProcessMove;
  129427. private _teleportationFillColor;
  129428. private _teleportationBorderColor;
  129429. private _rotationAngle;
  129430. private _haloCenter;
  129431. private _cameraGazer;
  129432. private _padSensibilityUp;
  129433. private _padSensibilityDown;
  129434. private _leftController;
  129435. private _rightController;
  129436. private _gazeColor;
  129437. private _laserColor;
  129438. private _pickedLaserColor;
  129439. private _pickedGazeColor;
  129440. /**
  129441. * Observable raised when a new mesh is selected based on meshSelectionPredicate
  129442. */
  129443. onNewMeshSelected: Observable<AbstractMesh>;
  129444. /**
  129445. * Observable raised when a new mesh is selected based on meshSelectionPredicate.
  129446. * This observable will provide the mesh and the controller used to select the mesh
  129447. */
  129448. onMeshSelectedWithController: Observable<{
  129449. mesh: AbstractMesh;
  129450. controller: WebVRController;
  129451. }>;
  129452. /**
  129453. * Observable raised when a new mesh is picked based on meshSelectionPredicate
  129454. */
  129455. onNewMeshPicked: Observable<PickingInfo>;
  129456. private _circleEase;
  129457. /**
  129458. * Observable raised before camera teleportation
  129459. */
  129460. onBeforeCameraTeleport: Observable<Vector3>;
  129461. /**
  129462. * Observable raised after camera teleportation
  129463. */
  129464. onAfterCameraTeleport: Observable<Vector3>;
  129465. /**
  129466. * Observable raised when current selected mesh gets unselected
  129467. */
  129468. onSelectedMeshUnselected: Observable<AbstractMesh>;
  129469. private _raySelectionPredicate;
  129470. /**
  129471. * To be optionaly changed by user to define custom ray selection
  129472. */
  129473. raySelectionPredicate: (mesh: AbstractMesh) => boolean;
  129474. /**
  129475. * To be optionaly changed by user to define custom selection logic (after ray selection)
  129476. */
  129477. meshSelectionPredicate: (mesh: AbstractMesh) => boolean;
  129478. /**
  129479. * Set teleportation enabled. If set to false camera teleportation will be disabled but camera rotation will be kept.
  129480. */
  129481. teleportationEnabled: boolean;
  129482. private _defaultHeight;
  129483. private _teleportationInitialized;
  129484. private _interactionsEnabled;
  129485. private _interactionsRequested;
  129486. private _displayGaze;
  129487. private _displayLaserPointer;
  129488. /**
  129489. * The mesh used to display where the user is going to teleport.
  129490. */
  129491. get teleportationTarget(): Mesh;
  129492. /**
  129493. * Sets the mesh to be used to display where the user is going to teleport.
  129494. */
  129495. set teleportationTarget(value: Mesh);
  129496. /**
  129497. * 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
  129498. * when set bakeCurrentTransformIntoVertices will be called on the mesh.
  129499. * See https://doc.babylonjs.com/resources/baking_transformations
  129500. */
  129501. get gazeTrackerMesh(): Mesh;
  129502. set gazeTrackerMesh(value: Mesh);
  129503. /**
  129504. * If the gaze trackers scale should be updated to be constant size when pointing at near/far meshes
  129505. */
  129506. updateGazeTrackerScale: boolean;
  129507. /**
  129508. * If the gaze trackers color should be updated when selecting meshes
  129509. */
  129510. updateGazeTrackerColor: boolean;
  129511. /**
  129512. * If the controller laser color should be updated when selecting meshes
  129513. */
  129514. updateControllerLaserColor: boolean;
  129515. /**
  129516. * The gaze tracking mesh corresponding to the left controller
  129517. */
  129518. get leftControllerGazeTrackerMesh(): Nullable<Mesh>;
  129519. /**
  129520. * The gaze tracking mesh corresponding to the right controller
  129521. */
  129522. get rightControllerGazeTrackerMesh(): Nullable<Mesh>;
  129523. /**
  129524. * If the ray of the gaze should be displayed.
  129525. */
  129526. get displayGaze(): boolean;
  129527. /**
  129528. * Sets if the ray of the gaze should be displayed.
  129529. */
  129530. set displayGaze(value: boolean);
  129531. /**
  129532. * If the ray of the LaserPointer should be displayed.
  129533. */
  129534. get displayLaserPointer(): boolean;
  129535. /**
  129536. * Sets if the ray of the LaserPointer should be displayed.
  129537. */
  129538. set displayLaserPointer(value: boolean);
  129539. /**
  129540. * The deviceOrientationCamera used as the camera when not in VR.
  129541. */
  129542. get deviceOrientationCamera(): Nullable<DeviceOrientationCamera>;
  129543. /**
  129544. * Based on the current WebVR support, returns the current VR camera used.
  129545. */
  129546. get currentVRCamera(): Nullable<Camera>;
  129547. /**
  129548. * The webVRCamera which is used when in VR.
  129549. */
  129550. get webVRCamera(): WebVRFreeCamera;
  129551. /**
  129552. * The deviceOrientationCamera that is used as a fallback when vr device is not connected.
  129553. */
  129554. get vrDeviceOrientationCamera(): Nullable<VRDeviceOrientationFreeCamera>;
  129555. /**
  129556. * The html button that is used to trigger entering into VR.
  129557. */
  129558. get vrButton(): Nullable<HTMLButtonElement>;
  129559. private get _teleportationRequestInitiated();
  129560. /**
  129561. * Defines whether or not Pointer lock should be requested when switching to
  129562. * full screen.
  129563. */
  129564. requestPointerLockOnFullScreen: boolean;
  129565. /**
  129566. * If asking to force XR, this will be populated with the default xr experience
  129567. */
  129568. xr: WebXRDefaultExperience;
  129569. /**
  129570. * Was the XR test done already. If this is true AND this.xr exists, xr is initialized.
  129571. * If this is true and no this.xr, xr exists but is not supported, using WebVR.
  129572. */
  129573. xrTestDone: boolean;
  129574. /**
  129575. * Instantiates a VRExperienceHelper.
  129576. * Helps to quickly add VR support to an existing scene.
  129577. * @param scene The scene the VRExperienceHelper belongs to.
  129578. * @param webVROptions Options to modify the vr experience helper's behavior.
  129579. */
  129580. constructor(scene: Scene,
  129581. /** Options to modify the vr experience helper's behavior. */
  129582. webVROptions?: VRExperienceHelperOptions);
  129583. private completeVRInit;
  129584. private _onDefaultMeshLoaded;
  129585. private _onResize;
  129586. private _onFullscreenChange;
  129587. /**
  129588. * Gets a value indicating if we are currently in VR mode.
  129589. */
  129590. get isInVRMode(): boolean;
  129591. private onVrDisplayPresentChange;
  129592. private onVRDisplayChanged;
  129593. private moveButtonToBottomRight;
  129594. private displayVRButton;
  129595. private updateButtonVisibility;
  129596. private _cachedAngularSensibility;
  129597. /**
  129598. * Attempt to enter VR. If a headset is connected and ready, will request present on that.
  129599. * Otherwise, will use the fullscreen API.
  129600. */
  129601. enterVR(): void;
  129602. /**
  129603. * Attempt to exit VR, or fullscreen.
  129604. */
  129605. exitVR(): void;
  129606. /**
  129607. * The position of the vr experience helper.
  129608. */
  129609. get position(): Vector3;
  129610. /**
  129611. * Sets the position of the vr experience helper.
  129612. */
  129613. set position(value: Vector3);
  129614. /**
  129615. * Enables controllers and user interactions such as selecting and object or clicking on an object.
  129616. */
  129617. enableInteractions(): void;
  129618. private get _noControllerIsActive();
  129619. private beforeRender;
  129620. private _isTeleportationFloor;
  129621. /**
  129622. * Adds a floor mesh to be used for teleportation.
  129623. * @param floorMesh the mesh to be used for teleportation.
  129624. */
  129625. addFloorMesh(floorMesh: Mesh): void;
  129626. /**
  129627. * Removes a floor mesh from being used for teleportation.
  129628. * @param floorMesh the mesh to be removed.
  129629. */
  129630. removeFloorMesh(floorMesh: Mesh): void;
  129631. /**
  129632. * Enables interactions and teleportation using the VR controllers and gaze.
  129633. * @param vrTeleportationOptions options to modify teleportation behavior.
  129634. */
  129635. enableTeleportation(vrTeleportationOptions?: VRTeleportationOptions): void;
  129636. private _onNewGamepadConnected;
  129637. private _tryEnableInteractionOnController;
  129638. private _onNewGamepadDisconnected;
  129639. private _enableInteractionOnController;
  129640. private _checkTeleportWithRay;
  129641. private _checkRotate;
  129642. private _checkTeleportBackwards;
  129643. private _enableTeleportationOnController;
  129644. private _createTeleportationCircles;
  129645. private _displayTeleportationTarget;
  129646. private _hideTeleportationTarget;
  129647. private _rotateCamera;
  129648. private _moveTeleportationSelectorTo;
  129649. private _workingVector;
  129650. private _workingQuaternion;
  129651. private _workingMatrix;
  129652. /**
  129653. * Time Constant Teleportation Mode
  129654. */
  129655. static readonly TELEPORTATIONMODE_CONSTANTTIME: number;
  129656. /**
  129657. * Speed Constant Teleportation Mode
  129658. */
  129659. static readonly TELEPORTATIONMODE_CONSTANTSPEED: number;
  129660. /**
  129661. * Teleports the users feet to the desired location
  129662. * @param location The location where the user's feet should be placed
  129663. */
  129664. teleportCamera(location: Vector3): void;
  129665. private _convertNormalToDirectionOfRay;
  129666. private _castRayAndSelectObject;
  129667. private _notifySelectedMeshUnselected;
  129668. /**
  129669. * Permanently set new colors for the laser pointer
  129670. * @param color the new laser color
  129671. * @param pickedColor the new laser color when picked mesh detected
  129672. */
  129673. setLaserColor(color: Color3, pickedColor?: Color3): void;
  129674. /**
  129675. * Set lighting enabled / disabled on the laser pointer of both controllers
  129676. * @param enabled should the lighting be enabled on the laser pointer
  129677. */
  129678. setLaserLightingState(enabled?: boolean): void;
  129679. /**
  129680. * Permanently set new colors for the gaze pointer
  129681. * @param color the new gaze color
  129682. * @param pickedColor the new gaze color when picked mesh detected
  129683. */
  129684. setGazeColor(color: Color3, pickedColor?: Color3): void;
  129685. /**
  129686. * Sets the color of the laser ray from the vr controllers.
  129687. * @param color new color for the ray.
  129688. */
  129689. changeLaserColor(color: Color3): void;
  129690. /**
  129691. * Sets the color of the ray from the vr headsets gaze.
  129692. * @param color new color for the ray.
  129693. */
  129694. changeGazeColor(color: Color3): void;
  129695. /**
  129696. * Exits VR and disposes of the vr experience helper
  129697. */
  129698. dispose(): void;
  129699. /**
  129700. * Gets the name of the VRExperienceHelper class
  129701. * @returns "VRExperienceHelper"
  129702. */
  129703. getClassName(): string;
  129704. }
  129705. }
  129706. declare module BABYLON {
  129707. /**
  129708. * Contains an array of blocks representing the octree
  129709. */
  129710. export interface IOctreeContainer<T> {
  129711. /**
  129712. * Blocks within the octree
  129713. */
  129714. blocks: Array<OctreeBlock<T>>;
  129715. }
  129716. /**
  129717. * Class used to store a cell in an octree
  129718. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  129719. */
  129720. export class OctreeBlock<T> {
  129721. /**
  129722. * Gets the content of the current block
  129723. */
  129724. entries: T[];
  129725. /**
  129726. * Gets the list of block children
  129727. */
  129728. blocks: Array<OctreeBlock<T>>;
  129729. private _depth;
  129730. private _maxDepth;
  129731. private _capacity;
  129732. private _minPoint;
  129733. private _maxPoint;
  129734. private _boundingVectors;
  129735. private _creationFunc;
  129736. /**
  129737. * Creates a new block
  129738. * @param minPoint defines the minimum vector (in world space) of the block's bounding box
  129739. * @param maxPoint defines the maximum vector (in world space) of the block's bounding box
  129740. * @param capacity defines the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  129741. * @param depth defines the current depth of this block in the octree
  129742. * @param maxDepth defines the maximal depth allowed (beyond this value, the capacity is ignored)
  129743. * @param creationFunc defines a callback to call when an element is added to the block
  129744. */
  129745. constructor(minPoint: Vector3, maxPoint: Vector3, capacity: number, depth: number, maxDepth: number, creationFunc: (entry: T, block: OctreeBlock<T>) => void);
  129746. /**
  129747. * Gets the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  129748. */
  129749. get capacity(): number;
  129750. /**
  129751. * Gets the minimum vector (in world space) of the block's bounding box
  129752. */
  129753. get minPoint(): Vector3;
  129754. /**
  129755. * Gets the maximum vector (in world space) of the block's bounding box
  129756. */
  129757. get maxPoint(): Vector3;
  129758. /**
  129759. * Add a new element to this block
  129760. * @param entry defines the element to add
  129761. */
  129762. addEntry(entry: T): void;
  129763. /**
  129764. * Remove an element from this block
  129765. * @param entry defines the element to remove
  129766. */
  129767. removeEntry(entry: T): void;
  129768. /**
  129769. * Add an array of elements to this block
  129770. * @param entries defines the array of elements to add
  129771. */
  129772. addEntries(entries: T[]): void;
  129773. /**
  129774. * Test if the current block intersects the furstum planes and if yes, then add its content to the selection array
  129775. * @param frustumPlanes defines the frustum planes to test
  129776. * @param selection defines the array to store current content if selection is positive
  129777. * @param allowDuplicate defines if the selection array can contains duplicated entries
  129778. */
  129779. select(frustumPlanes: Plane[], selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  129780. /**
  129781. * Test if the current block intersect with the given bounding sphere and if yes, then add its content to the selection array
  129782. * @param sphereCenter defines the bounding sphere center
  129783. * @param sphereRadius defines the bounding sphere radius
  129784. * @param selection defines the array to store current content if selection is positive
  129785. * @param allowDuplicate defines if the selection array can contains duplicated entries
  129786. */
  129787. intersects(sphereCenter: Vector3, sphereRadius: number, selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  129788. /**
  129789. * Test if the current block intersect with the given ray and if yes, then add its content to the selection array
  129790. * @param ray defines the ray to test with
  129791. * @param selection defines the array to store current content if selection is positive
  129792. */
  129793. intersectsRay(ray: Ray, selection: SmartArrayNoDuplicate<T>): void;
  129794. /**
  129795. * Subdivide the content into child blocks (this block will then be empty)
  129796. */
  129797. createInnerBlocks(): void;
  129798. /**
  129799. * @hidden
  129800. */
  129801. 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;
  129802. }
  129803. }
  129804. declare module BABYLON {
  129805. /**
  129806. * Octrees are a really powerful data structure that can quickly select entities based on space coordinates.
  129807. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  129808. */
  129809. export class Octree<T> {
  129810. /** 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.) */
  129811. maxDepth: number;
  129812. /**
  129813. * Blocks within the octree containing objects
  129814. */
  129815. blocks: Array<OctreeBlock<T>>;
  129816. /**
  129817. * Content stored in the octree
  129818. */
  129819. dynamicContent: T[];
  129820. private _maxBlockCapacity;
  129821. private _selectionContent;
  129822. private _creationFunc;
  129823. /**
  129824. * Creates a octree
  129825. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  129826. * @param creationFunc function to be used to instatiate the octree
  129827. * @param maxBlockCapacity defines the maximum number of meshes you want on your octree's leaves (default: 64)
  129828. * @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.)
  129829. */
  129830. constructor(creationFunc: (entry: T, block: OctreeBlock<T>) => void, maxBlockCapacity?: number,
  129831. /** 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.) */
  129832. maxDepth?: number);
  129833. /**
  129834. * Updates the octree by adding blocks for the passed in meshes within the min and max world parameters
  129835. * @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);
  129836. * @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);
  129837. * @param entries meshes to be added to the octree blocks
  129838. */
  129839. update(worldMin: Vector3, worldMax: Vector3, entries: T[]): void;
  129840. /**
  129841. * Adds a mesh to the octree
  129842. * @param entry Mesh to add to the octree
  129843. */
  129844. addMesh(entry: T): void;
  129845. /**
  129846. * Remove an element from the octree
  129847. * @param entry defines the element to remove
  129848. */
  129849. removeMesh(entry: T): void;
  129850. /**
  129851. * Selects an array of meshes within the frustum
  129852. * @param frustumPlanes The frustum planes to use which will select all meshes within it
  129853. * @param allowDuplicate If duplicate objects are allowed in the resulting object array
  129854. * @returns array of meshes within the frustum
  129855. */
  129856. select(frustumPlanes: Plane[], allowDuplicate?: boolean): SmartArray<T>;
  129857. /**
  129858. * Test if the octree intersect with the given bounding sphere and if yes, then add its content to the selection array
  129859. * @param sphereCenter defines the bounding sphere center
  129860. * @param sphereRadius defines the bounding sphere radius
  129861. * @param allowDuplicate defines if the selection array can contains duplicated entries
  129862. * @returns an array of objects that intersect the sphere
  129863. */
  129864. intersects(sphereCenter: Vector3, sphereRadius: number, allowDuplicate?: boolean): SmartArray<T>;
  129865. /**
  129866. * Test if the octree intersect with the given ray and if yes, then add its content to resulting array
  129867. * @param ray defines the ray to test with
  129868. * @returns array of intersected objects
  129869. */
  129870. intersectsRay(ray: Ray): SmartArray<T>;
  129871. /**
  129872. * Adds a mesh into the octree block if it intersects the block
  129873. */
  129874. static CreationFuncForMeshes: (entry: AbstractMesh, block: OctreeBlock<AbstractMesh>) => void;
  129875. /**
  129876. * Adds a submesh into the octree block if it intersects the block
  129877. */
  129878. static CreationFuncForSubMeshes: (entry: SubMesh, block: OctreeBlock<SubMesh>) => void;
  129879. }
  129880. }
  129881. declare module BABYLON {
  129882. interface Scene {
  129883. /**
  129884. * @hidden
  129885. * Backing Filed
  129886. */
  129887. _selectionOctree: Octree<AbstractMesh>;
  129888. /**
  129889. * Gets the octree used to boost mesh selection (picking)
  129890. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  129891. */
  129892. selectionOctree: Octree<AbstractMesh>;
  129893. /**
  129894. * Creates or updates the octree used to boost selection (picking)
  129895. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  129896. * @param maxCapacity defines the maximum capacity per leaf
  129897. * @param maxDepth defines the maximum depth of the octree
  129898. * @returns an octree of AbstractMesh
  129899. */
  129900. createOrUpdateSelectionOctree(maxCapacity?: number, maxDepth?: number): Octree<AbstractMesh>;
  129901. }
  129902. interface AbstractMesh {
  129903. /**
  129904. * @hidden
  129905. * Backing Field
  129906. */
  129907. _submeshesOctree: Octree<SubMesh>;
  129908. /**
  129909. * This function will create an octree to help to select the right submeshes for rendering, picking and collision computations.
  129910. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  129911. * @param maxCapacity defines the maximum size of each block (64 by default)
  129912. * @param maxDepth defines the maximum depth to use (no more than 2 levels by default)
  129913. * @returns the new octree
  129914. * @see https://www.babylonjs-playground.com/#NA4OQ#12
  129915. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  129916. */
  129917. createOrUpdateSubmeshesOctree(maxCapacity?: number, maxDepth?: number): Octree<SubMesh>;
  129918. }
  129919. /**
  129920. * Defines the octree scene component responsible to manage any octrees
  129921. * in a given scene.
  129922. */
  129923. export class OctreeSceneComponent {
  129924. /**
  129925. * The component name help to identify the component in the list of scene components.
  129926. */
  129927. readonly name: string;
  129928. /**
  129929. * The scene the component belongs to.
  129930. */
  129931. scene: Scene;
  129932. /**
  129933. * Indicates if the meshes have been checked to make sure they are isEnabled()
  129934. */
  129935. readonly checksIsEnabled: boolean;
  129936. /**
  129937. * Creates a new instance of the component for the given scene
  129938. * @param scene Defines the scene to register the component in
  129939. */
  129940. constructor(scene: Scene);
  129941. /**
  129942. * Registers the component in a given scene
  129943. */
  129944. register(): void;
  129945. /**
  129946. * Return the list of active meshes
  129947. * @returns the list of active meshes
  129948. */
  129949. getActiveMeshCandidates(): ISmartArrayLike<AbstractMesh>;
  129950. /**
  129951. * Return the list of active sub meshes
  129952. * @param mesh The mesh to get the candidates sub meshes from
  129953. * @returns the list of active sub meshes
  129954. */
  129955. getActiveSubMeshCandidates(mesh: AbstractMesh): ISmartArrayLike<SubMesh>;
  129956. private _tempRay;
  129957. /**
  129958. * Return the list of sub meshes intersecting with a given local ray
  129959. * @param mesh defines the mesh to find the submesh for
  129960. * @param localRay defines the ray in local space
  129961. * @returns the list of intersecting sub meshes
  129962. */
  129963. getIntersectingSubMeshCandidates(mesh: AbstractMesh, localRay: Ray): ISmartArrayLike<SubMesh>;
  129964. /**
  129965. * Return the list of sub meshes colliding with a collider
  129966. * @param mesh defines the mesh to find the submesh for
  129967. * @param collider defines the collider to evaluate the collision against
  129968. * @returns the list of colliding sub meshes
  129969. */
  129970. getCollidingSubMeshCandidates(mesh: AbstractMesh, collider: Collider): ISmartArrayLike<SubMesh>;
  129971. /**
  129972. * Rebuilds the elements related to this component in case of
  129973. * context lost for instance.
  129974. */
  129975. rebuild(): void;
  129976. /**
  129977. * Disposes the component and the associated ressources.
  129978. */
  129979. dispose(): void;
  129980. }
  129981. }
  129982. declare module BABYLON {
  129983. /**
  129984. * Renders gizmos on top of an existing scene which provide controls for position, rotation, etc.
  129985. */
  129986. export class Gizmo implements IDisposable {
  129987. /** The utility layer the gizmo will be added to */
  129988. gizmoLayer: UtilityLayerRenderer;
  129989. /**
  129990. * The root mesh of the gizmo
  129991. */
  129992. _rootMesh: Mesh;
  129993. private _attachedMesh;
  129994. private _attachedNode;
  129995. /**
  129996. * Ratio for the scale of the gizmo (Default: 1)
  129997. */
  129998. protected _scaleRatio: number;
  129999. /**
  130000. * Ratio for the scale of the gizmo (Default: 1)
  130001. */
  130002. set scaleRatio(value: number);
  130003. get scaleRatio(): number;
  130004. /**
  130005. * If a custom mesh has been set (Default: false)
  130006. */
  130007. protected _customMeshSet: boolean;
  130008. /**
  130009. * Mesh that the gizmo will be attached to. (eg. on a drag gizmo the mesh that will be dragged)
  130010. * * When set, interactions will be enabled
  130011. */
  130012. get attachedMesh(): Nullable<AbstractMesh>;
  130013. set attachedMesh(value: Nullable<AbstractMesh>);
  130014. /**
  130015. * Node that the gizmo will be attached to. (eg. on a drag gizmo the mesh, bone or NodeTransform that will be dragged)
  130016. * * When set, interactions will be enabled
  130017. */
  130018. get attachedNode(): Nullable<Node>;
  130019. set attachedNode(value: Nullable<Node>);
  130020. /**
  130021. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  130022. * @param mesh The mesh to replace the default mesh of the gizmo
  130023. */
  130024. setCustomMesh(mesh: Mesh): void;
  130025. protected _updateGizmoRotationToMatchAttachedMesh: boolean;
  130026. /**
  130027. * If set the gizmo's rotation will be updated to match the attached mesh each frame (Default: true)
  130028. */
  130029. set updateGizmoRotationToMatchAttachedMesh(value: boolean);
  130030. get updateGizmoRotationToMatchAttachedMesh(): boolean;
  130031. /**
  130032. * If set the gizmo's position will be updated to match the attached mesh each frame (Default: true)
  130033. */
  130034. updateGizmoPositionToMatchAttachedMesh: boolean;
  130035. /**
  130036. * When set, the gizmo will always appear the same size no matter where the camera is (default: true)
  130037. */
  130038. updateScale: boolean;
  130039. protected _interactionsEnabled: boolean;
  130040. protected _attachedNodeChanged(value: Nullable<Node>): void;
  130041. private _beforeRenderObserver;
  130042. private _tempQuaternion;
  130043. private _tempVector;
  130044. private _tempVector2;
  130045. private _tempMatrix1;
  130046. private _tempMatrix2;
  130047. private _rightHandtoLeftHandMatrix;
  130048. /**
  130049. * Creates a gizmo
  130050. * @param gizmoLayer The utility layer the gizmo will be added to
  130051. */
  130052. constructor(
  130053. /** The utility layer the gizmo will be added to */
  130054. gizmoLayer?: UtilityLayerRenderer);
  130055. /**
  130056. * Updates the gizmo to match the attached mesh's position/rotation
  130057. */
  130058. protected _update(): void;
  130059. /**
  130060. * computes the rotation/scaling/position of the transform once the Node world matrix has changed.
  130061. * @param value Node, TransformNode or mesh
  130062. */
  130063. protected _matrixChanged(): void;
  130064. /**
  130065. * Disposes of the gizmo
  130066. */
  130067. dispose(): void;
  130068. }
  130069. }
  130070. declare module BABYLON {
  130071. /**
  130072. * Single plane drag gizmo
  130073. */
  130074. export class PlaneDragGizmo extends Gizmo {
  130075. /**
  130076. * Drag behavior responsible for the gizmos dragging interactions
  130077. */
  130078. dragBehavior: PointerDragBehavior;
  130079. private _pointerObserver;
  130080. /**
  130081. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  130082. */
  130083. snapDistance: number;
  130084. /**
  130085. * Event that fires each time the gizmo snaps to a new location.
  130086. * * snapDistance is the the change in distance
  130087. */
  130088. onSnapObservable: Observable<{
  130089. snapDistance: number;
  130090. }>;
  130091. private _plane;
  130092. private _coloredMaterial;
  130093. private _hoverMaterial;
  130094. private _isEnabled;
  130095. private _parent;
  130096. /** @hidden */
  130097. static _CreatePlane(scene: Scene, material: StandardMaterial): TransformNode;
  130098. /** @hidden */
  130099. static _CreateArrowInstance(scene: Scene, arrow: TransformNode): TransformNode;
  130100. /**
  130101. * Creates a PlaneDragGizmo
  130102. * @param gizmoLayer The utility layer the gizmo will be added to
  130103. * @param dragPlaneNormal The axis normal to which the gizmo will be able to drag on
  130104. * @param color The color of the gizmo
  130105. */
  130106. constructor(dragPlaneNormal: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<PositionGizmo>);
  130107. protected _attachedNodeChanged(value: Nullable<Node>): void;
  130108. /**
  130109. * If the gizmo is enabled
  130110. */
  130111. set isEnabled(value: boolean);
  130112. get isEnabled(): boolean;
  130113. /**
  130114. * Disposes of the gizmo
  130115. */
  130116. dispose(): void;
  130117. }
  130118. }
  130119. declare module BABYLON {
  130120. /**
  130121. * Gizmo that enables dragging a mesh along 3 axis
  130122. */
  130123. export class PositionGizmo extends Gizmo {
  130124. /**
  130125. * Internal gizmo used for interactions on the x axis
  130126. */
  130127. xGizmo: AxisDragGizmo;
  130128. /**
  130129. * Internal gizmo used for interactions on the y axis
  130130. */
  130131. yGizmo: AxisDragGizmo;
  130132. /**
  130133. * Internal gizmo used for interactions on the z axis
  130134. */
  130135. zGizmo: AxisDragGizmo;
  130136. /**
  130137. * Internal gizmo used for interactions on the yz plane
  130138. */
  130139. xPlaneGizmo: PlaneDragGizmo;
  130140. /**
  130141. * Internal gizmo used for interactions on the xz plane
  130142. */
  130143. yPlaneGizmo: PlaneDragGizmo;
  130144. /**
  130145. * Internal gizmo used for interactions on the xy plane
  130146. */
  130147. zPlaneGizmo: PlaneDragGizmo;
  130148. /**
  130149. * private variables
  130150. */
  130151. private _meshAttached;
  130152. private _nodeAttached;
  130153. private _snapDistance;
  130154. /** Fires an event when any of it's sub gizmos are dragged */
  130155. onDragStartObservable: Observable<unknown>;
  130156. /** Fires an event when any of it's sub gizmos are released from dragging */
  130157. onDragEndObservable: Observable<unknown>;
  130158. /**
  130159. * If set to true, planar drag is enabled
  130160. */
  130161. private _planarGizmoEnabled;
  130162. get attachedMesh(): Nullable<AbstractMesh>;
  130163. set attachedMesh(mesh: Nullable<AbstractMesh>);
  130164. get attachedNode(): Nullable<Node>;
  130165. set attachedNode(node: Nullable<Node>);
  130166. /**
  130167. * Creates a PositionGizmo
  130168. * @param gizmoLayer The utility layer the gizmo will be added to
  130169. @param thickness display gizmo axis thickness
  130170. */
  130171. constructor(gizmoLayer?: UtilityLayerRenderer, thickness?: number);
  130172. /**
  130173. * If the planar drag gizmo is enabled
  130174. * setting this will enable/disable XY, XZ and YZ planes regardless of individual gizmo settings.
  130175. */
  130176. set planarGizmoEnabled(value: boolean);
  130177. get planarGizmoEnabled(): boolean;
  130178. set updateGizmoRotationToMatchAttachedMesh(value: boolean);
  130179. get updateGizmoRotationToMatchAttachedMesh(): boolean;
  130180. /**
  130181. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  130182. */
  130183. set snapDistance(value: number);
  130184. get snapDistance(): number;
  130185. /**
  130186. * Ratio for the scale of the gizmo (Default: 1)
  130187. */
  130188. set scaleRatio(value: number);
  130189. get scaleRatio(): number;
  130190. /**
  130191. * Disposes of the gizmo
  130192. */
  130193. dispose(): void;
  130194. /**
  130195. * CustomMeshes are not supported by this gizmo
  130196. * @param mesh The mesh to replace the default mesh of the gizmo
  130197. */
  130198. setCustomMesh(mesh: Mesh): void;
  130199. }
  130200. }
  130201. declare module BABYLON {
  130202. /**
  130203. * Single axis drag gizmo
  130204. */
  130205. export class AxisDragGizmo extends Gizmo {
  130206. /**
  130207. * Drag behavior responsible for the gizmos dragging interactions
  130208. */
  130209. dragBehavior: PointerDragBehavior;
  130210. private _pointerObserver;
  130211. /**
  130212. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  130213. */
  130214. snapDistance: number;
  130215. /**
  130216. * Event that fires each time the gizmo snaps to a new location.
  130217. * * snapDistance is the the change in distance
  130218. */
  130219. onSnapObservable: Observable<{
  130220. snapDistance: number;
  130221. }>;
  130222. private _isEnabled;
  130223. private _parent;
  130224. private _arrow;
  130225. private _coloredMaterial;
  130226. private _hoverMaterial;
  130227. /** @hidden */
  130228. static _CreateArrow(scene: Scene, material: StandardMaterial, thickness?: number): TransformNode;
  130229. /** @hidden */
  130230. static _CreateArrowInstance(scene: Scene, arrow: TransformNode): TransformNode;
  130231. /**
  130232. * Creates an AxisDragGizmo
  130233. * @param gizmoLayer The utility layer the gizmo will be added to
  130234. * @param dragAxis The axis which the gizmo will be able to drag on
  130235. * @param color The color of the gizmo
  130236. * @param thickness display gizmo axis thickness
  130237. */
  130238. constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<PositionGizmo>, thickness?: number);
  130239. protected _attachedNodeChanged(value: Nullable<Node>): void;
  130240. /**
  130241. * If the gizmo is enabled
  130242. */
  130243. set isEnabled(value: boolean);
  130244. get isEnabled(): boolean;
  130245. /**
  130246. * Disposes of the gizmo
  130247. */
  130248. dispose(): void;
  130249. }
  130250. }
  130251. declare module BABYLON.Debug {
  130252. /**
  130253. * The Axes viewer will show 3 axes in a specific point in space
  130254. */
  130255. export class AxesViewer {
  130256. private _xAxis;
  130257. private _yAxis;
  130258. private _zAxis;
  130259. private _scaleLinesFactor;
  130260. private _instanced;
  130261. /**
  130262. * Gets the hosting scene
  130263. */
  130264. scene: Nullable<Scene>;
  130265. /**
  130266. * Gets or sets a number used to scale line length
  130267. */
  130268. scaleLines: number;
  130269. /** Gets the node hierarchy used to render x-axis */
  130270. get xAxis(): TransformNode;
  130271. /** Gets the node hierarchy used to render y-axis */
  130272. get yAxis(): TransformNode;
  130273. /** Gets the node hierarchy used to render z-axis */
  130274. get zAxis(): TransformNode;
  130275. /**
  130276. * Creates a new AxesViewer
  130277. * @param scene defines the hosting scene
  130278. * @param scaleLines defines a number used to scale line length (1 by default)
  130279. * @param renderingGroupId defines a number used to set the renderingGroupId of the meshes (2 by default)
  130280. * @param xAxis defines the node hierarchy used to render the x-axis
  130281. * @param yAxis defines the node hierarchy used to render the y-axis
  130282. * @param zAxis defines the node hierarchy used to render the z-axis
  130283. */
  130284. constructor(scene: Scene, scaleLines?: number, renderingGroupId?: Nullable<number>, xAxis?: TransformNode, yAxis?: TransformNode, zAxis?: TransformNode);
  130285. /**
  130286. * Force the viewer to update
  130287. * @param position defines the position of the viewer
  130288. * @param xaxis defines the x axis of the viewer
  130289. * @param yaxis defines the y axis of the viewer
  130290. * @param zaxis defines the z axis of the viewer
  130291. */
  130292. update(position: Vector3, xaxis: Vector3, yaxis: Vector3, zaxis: Vector3): void;
  130293. /**
  130294. * Creates an instance of this axes viewer.
  130295. * @returns a new axes viewer with instanced meshes
  130296. */
  130297. createInstance(): AxesViewer;
  130298. /** Releases resources */
  130299. dispose(): void;
  130300. private static _SetRenderingGroupId;
  130301. }
  130302. }
  130303. declare module BABYLON.Debug {
  130304. /**
  130305. * The BoneAxesViewer will attach 3 axes to a specific bone of a specific mesh
  130306. * @see demo here: https://www.babylonjs-playground.com/#0DE8F4#8
  130307. */
  130308. export class BoneAxesViewer extends AxesViewer {
  130309. /**
  130310. * Gets or sets the target mesh where to display the axes viewer
  130311. */
  130312. mesh: Nullable<Mesh>;
  130313. /**
  130314. * Gets or sets the target bone where to display the axes viewer
  130315. */
  130316. bone: Nullable<Bone>;
  130317. /** Gets current position */
  130318. pos: Vector3;
  130319. /** Gets direction of X axis */
  130320. xaxis: Vector3;
  130321. /** Gets direction of Y axis */
  130322. yaxis: Vector3;
  130323. /** Gets direction of Z axis */
  130324. zaxis: Vector3;
  130325. /**
  130326. * Creates a new BoneAxesViewer
  130327. * @param scene defines the hosting scene
  130328. * @param bone defines the target bone
  130329. * @param mesh defines the target mesh
  130330. * @param scaleLines defines a scaling factor for line length (1 by default)
  130331. */
  130332. constructor(scene: Scene, bone: Bone, mesh: Mesh, scaleLines?: number);
  130333. /**
  130334. * Force the viewer to update
  130335. */
  130336. update(): void;
  130337. /** Releases resources */
  130338. dispose(): void;
  130339. }
  130340. }
  130341. declare module BABYLON {
  130342. /**
  130343. * Interface used to define scene explorer extensibility option
  130344. */
  130345. export interface IExplorerExtensibilityOption {
  130346. /**
  130347. * Define the option label
  130348. */
  130349. label: string;
  130350. /**
  130351. * Defines the action to execute on click
  130352. */
  130353. action: (entity: any) => void;
  130354. }
  130355. /**
  130356. * Defines a group of actions associated with a predicate to use when extending the Inspector scene explorer
  130357. */
  130358. export interface IExplorerExtensibilityGroup {
  130359. /**
  130360. * Defines a predicate to test if a given type mut be extended
  130361. */
  130362. predicate: (entity: any) => boolean;
  130363. /**
  130364. * Gets the list of options added to a type
  130365. */
  130366. entries: IExplorerExtensibilityOption[];
  130367. }
  130368. /**
  130369. * Interface used to define the options to use to create the Inspector
  130370. */
  130371. export interface IInspectorOptions {
  130372. /**
  130373. * Display in overlay mode (default: false)
  130374. */
  130375. overlay?: boolean;
  130376. /**
  130377. * HTML element to use as root (the parent of the rendering canvas will be used as default value)
  130378. */
  130379. globalRoot?: HTMLElement;
  130380. /**
  130381. * Display the Scene explorer
  130382. */
  130383. showExplorer?: boolean;
  130384. /**
  130385. * Display the property inspector
  130386. */
  130387. showInspector?: boolean;
  130388. /**
  130389. * Display in embed mode (both panes on the right)
  130390. */
  130391. embedMode?: boolean;
  130392. /**
  130393. * let the Inspector handles resize of the canvas when panes are resized (default to true)
  130394. */
  130395. handleResize?: boolean;
  130396. /**
  130397. * Allow the panes to popup (default: true)
  130398. */
  130399. enablePopup?: boolean;
  130400. /**
  130401. * Allow the panes to be closed by users (default: true)
  130402. */
  130403. enableClose?: boolean;
  130404. /**
  130405. * Optional list of extensibility entries
  130406. */
  130407. explorerExtensibility?: IExplorerExtensibilityGroup[];
  130408. /**
  130409. * Optional URL to get the inspector script from (by default it uses the babylonjs CDN).
  130410. */
  130411. inspectorURL?: string;
  130412. /**
  130413. * Optional initial tab (default to DebugLayerTab.Properties)
  130414. */
  130415. initialTab?: DebugLayerTab;
  130416. }
  130417. interface Scene {
  130418. /**
  130419. * @hidden
  130420. * Backing field
  130421. */
  130422. _debugLayer: DebugLayer;
  130423. /**
  130424. * Gets the debug layer (aka Inspector) associated with the scene
  130425. * @see https://doc.babylonjs.com/features/playground_debuglayer
  130426. */
  130427. debugLayer: DebugLayer;
  130428. }
  130429. /**
  130430. * Enum of inspector action tab
  130431. */
  130432. export enum DebugLayerTab {
  130433. /**
  130434. * Properties tag (default)
  130435. */
  130436. Properties = 0,
  130437. /**
  130438. * Debug tab
  130439. */
  130440. Debug = 1,
  130441. /**
  130442. * Statistics tab
  130443. */
  130444. Statistics = 2,
  130445. /**
  130446. * Tools tab
  130447. */
  130448. Tools = 3,
  130449. /**
  130450. * Settings tab
  130451. */
  130452. Settings = 4
  130453. }
  130454. /**
  130455. * The debug layer (aka Inspector) is the go to tool in order to better understand
  130456. * what is happening in your scene
  130457. * @see https://doc.babylonjs.com/features/playground_debuglayer
  130458. */
  130459. export class DebugLayer {
  130460. /**
  130461. * Define the url to get the inspector script from.
  130462. * By default it uses the babylonjs CDN.
  130463. * @ignoreNaming
  130464. */
  130465. static InspectorURL: string;
  130466. private _scene;
  130467. private BJSINSPECTOR;
  130468. private _onPropertyChangedObservable?;
  130469. /**
  130470. * Observable triggered when a property is changed through the inspector.
  130471. */
  130472. get onPropertyChangedObservable(): any;
  130473. /**
  130474. * Instantiates a new debug layer.
  130475. * The debug layer (aka Inspector) is the go to tool in order to better understand
  130476. * what is happening in your scene
  130477. * @see https://doc.babylonjs.com/features/playground_debuglayer
  130478. * @param scene Defines the scene to inspect
  130479. */
  130480. constructor(scene: Scene);
  130481. /** Creates the inspector window. */
  130482. private _createInspector;
  130483. /**
  130484. * Select a specific entity in the scene explorer and highlight a specific block in that entity property grid
  130485. * @param entity defines the entity to select
  130486. * @param lineContainerTitles defines the specific blocks to highlight (could be a string or an array of strings)
  130487. */
  130488. select(entity: any, lineContainerTitles?: string | string[]): void;
  130489. /** Get the inspector from bundle or global */
  130490. private _getGlobalInspector;
  130491. /**
  130492. * Get if the inspector is visible or not.
  130493. * @returns true if visible otherwise, false
  130494. */
  130495. isVisible(): boolean;
  130496. /**
  130497. * Hide the inspector and close its window.
  130498. */
  130499. hide(): void;
  130500. /**
  130501. * Update the scene in the inspector
  130502. */
  130503. setAsActiveScene(): void;
  130504. /**
  130505. * Launch the debugLayer.
  130506. * @param config Define the configuration of the inspector
  130507. * @return a promise fulfilled when the debug layer is visible
  130508. */
  130509. show(config?: IInspectorOptions): Promise<DebugLayer>;
  130510. }
  130511. }
  130512. declare module BABYLON {
  130513. /**
  130514. * Class containing static functions to help procedurally build meshes
  130515. */
  130516. export class BoxBuilder {
  130517. /**
  130518. * Creates a box mesh
  130519. * * The parameter `size` sets the size (float) of each box side (default 1)
  130520. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value of `size`)
  130521. * * 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)
  130522. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  130523. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  130524. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  130525. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  130526. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  130527. * @param name defines the name of the mesh
  130528. * @param options defines the options used to create the mesh
  130529. * @param scene defines the hosting scene
  130530. * @returns the box mesh
  130531. */
  130532. static CreateBox(name: string, options: {
  130533. size?: number;
  130534. width?: number;
  130535. height?: number;
  130536. depth?: number;
  130537. faceUV?: Vector4[];
  130538. faceColors?: Color4[];
  130539. sideOrientation?: number;
  130540. frontUVs?: Vector4;
  130541. backUVs?: Vector4;
  130542. wrap?: boolean;
  130543. topBaseAt?: number;
  130544. bottomBaseAt?: number;
  130545. updatable?: boolean;
  130546. }, scene?: Nullable<Scene>): Mesh;
  130547. }
  130548. }
  130549. declare module BABYLON.Debug {
  130550. /**
  130551. * Used to show the physics impostor around the specific mesh
  130552. */
  130553. export class PhysicsViewer {
  130554. /** @hidden */
  130555. protected _impostors: Array<Nullable<PhysicsImpostor>>;
  130556. /** @hidden */
  130557. protected _meshes: Array<Nullable<AbstractMesh>>;
  130558. /** @hidden */
  130559. protected _scene: Nullable<Scene>;
  130560. /** @hidden */
  130561. protected _numMeshes: number;
  130562. /** @hidden */
  130563. protected _physicsEnginePlugin: Nullable<IPhysicsEnginePlugin>;
  130564. private _renderFunction;
  130565. private _utilityLayer;
  130566. private _debugBoxMesh;
  130567. private _debugSphereMesh;
  130568. private _debugCylinderMesh;
  130569. private _debugMaterial;
  130570. private _debugMeshMeshes;
  130571. /**
  130572. * Creates a new PhysicsViewer
  130573. * @param scene defines the hosting scene
  130574. */
  130575. constructor(scene: Scene);
  130576. /** @hidden */
  130577. protected _updateDebugMeshes(): void;
  130578. /**
  130579. * Renders a specified physic impostor
  130580. * @param impostor defines the impostor to render
  130581. * @param targetMesh defines the mesh represented by the impostor
  130582. * @returns the new debug mesh used to render the impostor
  130583. */
  130584. showImpostor(impostor: PhysicsImpostor, targetMesh?: Mesh): Nullable<AbstractMesh>;
  130585. /**
  130586. * Hides a specified physic impostor
  130587. * @param impostor defines the impostor to hide
  130588. */
  130589. hideImpostor(impostor: Nullable<PhysicsImpostor>): void;
  130590. private _getDebugMaterial;
  130591. private _getDebugBoxMesh;
  130592. private _getDebugSphereMesh;
  130593. private _getDebugCylinderMesh;
  130594. private _getDebugMeshMesh;
  130595. private _getDebugMesh;
  130596. /** Releases all resources */
  130597. dispose(): void;
  130598. }
  130599. }
  130600. declare module BABYLON {
  130601. /**
  130602. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  130603. * in order to better appreciate the issue one might have.
  130604. * @see https://doc.babylonjs.com/babylon101/raycasts#debugging
  130605. */
  130606. export class RayHelper {
  130607. /**
  130608. * Defines the ray we are currently tryin to visualize.
  130609. */
  130610. ray: Nullable<Ray>;
  130611. private _renderPoints;
  130612. private _renderLine;
  130613. private _renderFunction;
  130614. private _scene;
  130615. private _onAfterRenderObserver;
  130616. private _onAfterStepObserver;
  130617. private _attachedToMesh;
  130618. private _meshSpaceDirection;
  130619. private _meshSpaceOrigin;
  130620. /**
  130621. * Helper function to create a colored helper in a scene in one line.
  130622. * @param ray Defines the ray we are currently tryin to visualize
  130623. * @param scene Defines the scene the ray is used in
  130624. * @param color Defines the color we want to see the ray in
  130625. * @returns The newly created ray helper.
  130626. */
  130627. static CreateAndShow(ray: Ray, scene: Scene, color: Color3): RayHelper;
  130628. /**
  130629. * Instantiate a new ray helper.
  130630. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  130631. * in order to better appreciate the issue one might have.
  130632. * @see https://doc.babylonjs.com/babylon101/raycasts#debugging
  130633. * @param ray Defines the ray we are currently tryin to visualize
  130634. */
  130635. constructor(ray: Ray);
  130636. /**
  130637. * Shows the ray we are willing to debug.
  130638. * @param scene Defines the scene the ray needs to be rendered in
  130639. * @param color Defines the color the ray needs to be rendered in
  130640. */
  130641. show(scene: Scene, color?: Color3): void;
  130642. /**
  130643. * Hides the ray we are debugging.
  130644. */
  130645. hide(): void;
  130646. private _render;
  130647. /**
  130648. * Attach a ray helper to a mesh so that we can easily see its orientation for instance or information like its normals.
  130649. * @param mesh Defines the mesh we want the helper attached to
  130650. * @param meshSpaceDirection Defines the direction of the Ray in mesh space (local space of the mesh node)
  130651. * @param meshSpaceOrigin Defines the origin of the Ray in mesh space (local space of the mesh node)
  130652. * @param length Defines the length of the ray
  130653. */
  130654. attachToMesh(mesh: AbstractMesh, meshSpaceDirection?: Vector3, meshSpaceOrigin?: Vector3, length?: number): void;
  130655. /**
  130656. * Detach the ray helper from the mesh it has previously been attached to.
  130657. */
  130658. detachFromMesh(): void;
  130659. private _updateToMesh;
  130660. /**
  130661. * Dispose the helper and release its associated resources.
  130662. */
  130663. dispose(): void;
  130664. }
  130665. }
  130666. declare module BABYLON {
  130667. /**
  130668. * Defines the options associated with the creation of a SkeletonViewer.
  130669. */
  130670. export interface ISkeletonViewerOptions {
  130671. /** Should the system pause animations before building the Viewer? */
  130672. pauseAnimations: boolean;
  130673. /** Should the system return the skeleton to rest before building? */
  130674. returnToRest: boolean;
  130675. /** public Display Mode of the Viewer */
  130676. displayMode: number;
  130677. /** Flag to toggle if the Viewer should use the CPU for animations or not? */
  130678. displayOptions: ISkeletonViewerDisplayOptions;
  130679. /** Flag to toggle if the Viewer should use the CPU for animations or not? */
  130680. computeBonesUsingShaders: boolean;
  130681. }
  130682. /**
  130683. * Defines how to display the various bone meshes for the viewer.
  130684. */
  130685. export interface ISkeletonViewerDisplayOptions {
  130686. /** How far down to start tapering the bone spurs */
  130687. midStep?: number;
  130688. /** How big is the midStep? */
  130689. midStepFactor?: number;
  130690. /** Base for the Sphere Size */
  130691. sphereBaseSize?: number;
  130692. /** The ratio of the sphere to the longest bone in units */
  130693. sphereScaleUnit?: number;
  130694. /** Ratio for the Sphere Size */
  130695. sphereFactor?: number;
  130696. }
  130697. }
  130698. declare module BABYLON {
  130699. /**
  130700. * Class containing static functions to help procedurally build meshes
  130701. */
  130702. export class RibbonBuilder {
  130703. /**
  130704. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  130705. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  130706. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  130707. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  130708. * * 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
  130709. * * 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
  130710. * * 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
  130711. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  130712. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  130713. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  130714. * * 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
  130715. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  130716. * * 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
  130717. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  130718. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  130719. * @param name defines the name of the mesh
  130720. * @param options defines the options used to create the mesh
  130721. * @param scene defines the hosting scene
  130722. * @returns the ribbon mesh
  130723. * @see https://doc.babylonjs.com/how_to/ribbon_tutorial
  130724. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  130725. */
  130726. static CreateRibbon(name: string, options: {
  130727. pathArray: Vector3[][];
  130728. closeArray?: boolean;
  130729. closePath?: boolean;
  130730. offset?: number;
  130731. updatable?: boolean;
  130732. sideOrientation?: number;
  130733. frontUVs?: Vector4;
  130734. backUVs?: Vector4;
  130735. instance?: Mesh;
  130736. invertUV?: boolean;
  130737. uvs?: Vector2[];
  130738. colors?: Color4[];
  130739. }, scene?: Nullable<Scene>): Mesh;
  130740. }
  130741. }
  130742. declare module BABYLON {
  130743. /**
  130744. * Class containing static functions to help procedurally build meshes
  130745. */
  130746. export class ShapeBuilder {
  130747. /**
  130748. * 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.
  130749. * * 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.
  130750. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  130751. * * 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.
  130752. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  130753. * * 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
  130754. * * 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
  130755. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  130756. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  130757. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  130758. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  130759. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  130760. * @param name defines the name of the mesh
  130761. * @param options defines the options used to create the mesh
  130762. * @param scene defines the hosting scene
  130763. * @returns the extruded shape mesh
  130764. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  130765. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  130766. */
  130767. static ExtrudeShape(name: string, options: {
  130768. shape: Vector3[];
  130769. path: Vector3[];
  130770. scale?: number;
  130771. rotation?: number;
  130772. cap?: number;
  130773. updatable?: boolean;
  130774. sideOrientation?: number;
  130775. frontUVs?: Vector4;
  130776. backUVs?: Vector4;
  130777. instance?: Mesh;
  130778. invertUV?: boolean;
  130779. }, scene?: Nullable<Scene>): Mesh;
  130780. /**
  130781. * Creates an custom extruded shape mesh.
  130782. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  130783. * * 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.
  130784. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  130785. * * 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
  130786. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  130787. * * 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
  130788. * * It must returns a float value that will be the scale value applied to the shape on each path point
  130789. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  130790. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  130791. * * 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
  130792. * * 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
  130793. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  130794. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  130795. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  130796. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  130797. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  130798. * @param name defines the name of the mesh
  130799. * @param options defines the options used to create the mesh
  130800. * @param scene defines the hosting scene
  130801. * @returns the custom extruded shape mesh
  130802. * @see https://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  130803. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  130804. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  130805. */
  130806. static ExtrudeShapeCustom(name: string, options: {
  130807. shape: Vector3[];
  130808. path: Vector3[];
  130809. scaleFunction?: any;
  130810. rotationFunction?: any;
  130811. ribbonCloseArray?: boolean;
  130812. ribbonClosePath?: boolean;
  130813. cap?: number;
  130814. updatable?: boolean;
  130815. sideOrientation?: number;
  130816. frontUVs?: Vector4;
  130817. backUVs?: Vector4;
  130818. instance?: Mesh;
  130819. invertUV?: boolean;
  130820. }, scene?: Nullable<Scene>): Mesh;
  130821. private static _ExtrudeShapeGeneric;
  130822. }
  130823. }
  130824. declare module BABYLON.Debug {
  130825. /**
  130826. * Class used to render a debug view of a given skeleton
  130827. * @see http://www.babylonjs-playground.com/#1BZJVJ#8
  130828. */
  130829. export class SkeletonViewer {
  130830. /** defines the skeleton to render */
  130831. skeleton: Skeleton;
  130832. /** defines the mesh attached to the skeleton */
  130833. mesh: AbstractMesh;
  130834. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  130835. autoUpdateBonesMatrices: boolean;
  130836. /** defines the rendering group id to use with the viewer */
  130837. renderingGroupId: number;
  130838. /** is the options for the viewer */
  130839. options: Partial<ISkeletonViewerOptions>;
  130840. /** public Display constants BABYLON.SkeletonViewer.DISPLAY_LINES */
  130841. static readonly DISPLAY_LINES: number;
  130842. /** public Display constants BABYLON.SkeletonViewer.DISPLAY_SPHERES */
  130843. static readonly DISPLAY_SPHERES: number;
  130844. /** public Display constants BABYLON.SkeletonViewer.DISPLAY_SPHERE_AND_SPURS */
  130845. static readonly DISPLAY_SPHERE_AND_SPURS: number;
  130846. /** If SkeletonViewer scene scope. */
  130847. private _scene;
  130848. /** Gets or sets the color used to render the skeleton */
  130849. color: Color3;
  130850. /** Array of the points of the skeleton fo the line view. */
  130851. private _debugLines;
  130852. /** The SkeletonViewers Mesh. */
  130853. private _debugMesh;
  130854. /** If SkeletonViewer is enabled. */
  130855. private _isEnabled;
  130856. /** If SkeletonViewer is ready. */
  130857. private _ready;
  130858. /** SkeletonViewer render observable. */
  130859. private _obs;
  130860. /** The Utility Layer to render the gizmos in. */
  130861. private _utilityLayer;
  130862. private _boneIndices;
  130863. /** Gets the Scene. */
  130864. get scene(): Scene;
  130865. /** Gets the utilityLayer. */
  130866. get utilityLayer(): Nullable<UtilityLayerRenderer>;
  130867. /** Checks Ready Status. */
  130868. get isReady(): Boolean;
  130869. /** Sets Ready Status. */
  130870. set ready(value: boolean);
  130871. /** Gets the debugMesh */
  130872. get debugMesh(): Nullable<AbstractMesh> | Nullable<LinesMesh>;
  130873. /** Sets the debugMesh */
  130874. set debugMesh(value: Nullable<AbstractMesh> | Nullable<LinesMesh>);
  130875. /** Gets the material */
  130876. get material(): StandardMaterial;
  130877. /** Sets the material */
  130878. set material(value: StandardMaterial);
  130879. /** Gets the material */
  130880. get displayMode(): number;
  130881. /** Sets the material */
  130882. set displayMode(value: number);
  130883. /**
  130884. * Creates a new SkeletonViewer
  130885. * @param skeleton defines the skeleton to render
  130886. * @param mesh defines the mesh attached to the skeleton
  130887. * @param scene defines the hosting scene
  130888. * @param autoUpdateBonesMatrices defines a boolean indicating if bones matrices must be forced to update before rendering (true by default)
  130889. * @param renderingGroupId defines the rendering group id to use with the viewer
  130890. * @param options All of the extra constructor options for the SkeletonViewer
  130891. */
  130892. constructor(
  130893. /** defines the skeleton to render */
  130894. skeleton: Skeleton,
  130895. /** defines the mesh attached to the skeleton */
  130896. mesh: AbstractMesh,
  130897. /** The Scene scope*/
  130898. scene: Scene,
  130899. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  130900. autoUpdateBonesMatrices?: boolean,
  130901. /** defines the rendering group id to use with the viewer */
  130902. renderingGroupId?: number,
  130903. /** is the options for the viewer */
  130904. options?: Partial<ISkeletonViewerOptions>);
  130905. /** The Dynamic bindings for the update functions */
  130906. private _bindObs;
  130907. /** Update the viewer to sync with current skeleton state, only used to manually update. */
  130908. update(): void;
  130909. /** Gets or sets a boolean indicating if the viewer is enabled */
  130910. set isEnabled(value: boolean);
  130911. get isEnabled(): boolean;
  130912. private _getBonePosition;
  130913. private _getLinesForBonesWithLength;
  130914. private _getLinesForBonesNoLength;
  130915. /** function to revert the mesh and scene back to the initial state. */
  130916. private _revert;
  130917. /** function to build and bind sphere joint points and spur bone representations. */
  130918. private _buildSpheresAndSpurs;
  130919. /** Update the viewer to sync with current skeleton state, only used for the line display. */
  130920. private _displayLinesUpdate;
  130921. /** Changes the displayMode of the skeleton viewer
  130922. * @param mode The displayMode numerical value
  130923. */
  130924. changeDisplayMode(mode: number): void;
  130925. /** Changes the displayMode of the skeleton viewer
  130926. * @param option String of the option name
  130927. * @param value The numerical option value
  130928. */
  130929. changeDisplayOptions(option: string, value: number): void;
  130930. /** Release associated resources */
  130931. dispose(): void;
  130932. }
  130933. }
  130934. declare module BABYLON {
  130935. /**
  130936. * Enum for Device Types
  130937. */
  130938. export enum DeviceType {
  130939. /** Generic */
  130940. Generic = 0,
  130941. /** Keyboard */
  130942. Keyboard = 1,
  130943. /** Mouse */
  130944. Mouse = 2,
  130945. /** Touch Pointers */
  130946. Touch = 3,
  130947. /** PS4 Dual Shock */
  130948. DualShock = 4,
  130949. /** Xbox */
  130950. Xbox = 5,
  130951. /** Switch Controller */
  130952. Switch = 6
  130953. }
  130954. /**
  130955. * Enum for All Pointers (Touch/Mouse)
  130956. */
  130957. export enum PointerInput {
  130958. /** Horizontal Axis */
  130959. Horizontal = 0,
  130960. /** Vertical Axis */
  130961. Vertical = 1,
  130962. /** Left Click or Touch */
  130963. LeftClick = 2,
  130964. /** Middle Click */
  130965. MiddleClick = 3,
  130966. /** Right Click */
  130967. RightClick = 4,
  130968. /** Browser Back */
  130969. BrowserBack = 5,
  130970. /** Browser Forward */
  130971. BrowserForward = 6
  130972. }
  130973. /**
  130974. * Enum for Dual Shock Gamepad
  130975. */
  130976. export enum DualShockInput {
  130977. /** Cross */
  130978. Cross = 0,
  130979. /** Circle */
  130980. Circle = 1,
  130981. /** Square */
  130982. Square = 2,
  130983. /** Triangle */
  130984. Triangle = 3,
  130985. /** L1 */
  130986. L1 = 4,
  130987. /** R1 */
  130988. R1 = 5,
  130989. /** L2 */
  130990. L2 = 6,
  130991. /** R2 */
  130992. R2 = 7,
  130993. /** Share */
  130994. Share = 8,
  130995. /** Options */
  130996. Options = 9,
  130997. /** L3 */
  130998. L3 = 10,
  130999. /** R3 */
  131000. R3 = 11,
  131001. /** DPadUp */
  131002. DPadUp = 12,
  131003. /** DPadDown */
  131004. DPadDown = 13,
  131005. /** DPadLeft */
  131006. DPadLeft = 14,
  131007. /** DRight */
  131008. DPadRight = 15,
  131009. /** Home */
  131010. Home = 16,
  131011. /** TouchPad */
  131012. TouchPad = 17,
  131013. /** LStickXAxis */
  131014. LStickXAxis = 18,
  131015. /** LStickYAxis */
  131016. LStickYAxis = 19,
  131017. /** RStickXAxis */
  131018. RStickXAxis = 20,
  131019. /** RStickYAxis */
  131020. RStickYAxis = 21
  131021. }
  131022. /**
  131023. * Enum for Xbox Gamepad
  131024. */
  131025. export enum XboxInput {
  131026. /** A */
  131027. A = 0,
  131028. /** B */
  131029. B = 1,
  131030. /** X */
  131031. X = 2,
  131032. /** Y */
  131033. Y = 3,
  131034. /** LB */
  131035. LB = 4,
  131036. /** RB */
  131037. RB = 5,
  131038. /** LT */
  131039. LT = 6,
  131040. /** RT */
  131041. RT = 7,
  131042. /** Back */
  131043. Back = 8,
  131044. /** Start */
  131045. Start = 9,
  131046. /** LS */
  131047. LS = 10,
  131048. /** RS */
  131049. RS = 11,
  131050. /** DPadUp */
  131051. DPadUp = 12,
  131052. /** DPadDown */
  131053. DPadDown = 13,
  131054. /** DPadLeft */
  131055. DPadLeft = 14,
  131056. /** DRight */
  131057. DPadRight = 15,
  131058. /** Home */
  131059. Home = 16,
  131060. /** LStickXAxis */
  131061. LStickXAxis = 17,
  131062. /** LStickYAxis */
  131063. LStickYAxis = 18,
  131064. /** RStickXAxis */
  131065. RStickXAxis = 19,
  131066. /** RStickYAxis */
  131067. RStickYAxis = 20
  131068. }
  131069. /**
  131070. * Enum for Switch (Pro/JoyCon L+R) Gamepad
  131071. */
  131072. export enum SwitchInput {
  131073. /** B */
  131074. B = 0,
  131075. /** A */
  131076. A = 1,
  131077. /** Y */
  131078. Y = 2,
  131079. /** X */
  131080. X = 3,
  131081. /** L */
  131082. L = 4,
  131083. /** R */
  131084. R = 5,
  131085. /** ZL */
  131086. ZL = 6,
  131087. /** ZR */
  131088. ZR = 7,
  131089. /** Minus */
  131090. Minus = 8,
  131091. /** Plus */
  131092. Plus = 9,
  131093. /** LS */
  131094. LS = 10,
  131095. /** RS */
  131096. RS = 11,
  131097. /** DPadUp */
  131098. DPadUp = 12,
  131099. /** DPadDown */
  131100. DPadDown = 13,
  131101. /** DPadLeft */
  131102. DPadLeft = 14,
  131103. /** DRight */
  131104. DPadRight = 15,
  131105. /** Home */
  131106. Home = 16,
  131107. /** Capture */
  131108. Capture = 17,
  131109. /** LStickXAxis */
  131110. LStickXAxis = 18,
  131111. /** LStickYAxis */
  131112. LStickYAxis = 19,
  131113. /** RStickXAxis */
  131114. RStickXAxis = 20,
  131115. /** RStickYAxis */
  131116. RStickYAxis = 21
  131117. }
  131118. }
  131119. declare module BABYLON {
  131120. /**
  131121. * This class will take all inputs from Keyboard, Pointer, and
  131122. * any Gamepads and provide a polling system that all devices
  131123. * will use. This class assumes that there will only be one
  131124. * pointer device and one keyboard.
  131125. */
  131126. export class DeviceInputSystem implements IDisposable {
  131127. /**
  131128. * Callback to be triggered when a device is connected
  131129. */
  131130. onDeviceConnected: (deviceType: DeviceType, deviceSlot: number) => void;
  131131. /**
  131132. * Callback to be triggered when a device is disconnected
  131133. */
  131134. onDeviceDisconnected: (deviceType: DeviceType, deviceSlot: number) => void;
  131135. /**
  131136. * Callback to be triggered when event driven input is updated
  131137. */
  131138. onInputChanged: (deviceType: DeviceType, deviceSlot: number, inputIndex: number, previousState: Nullable<number>, currentState: Nullable<number>) => void;
  131139. private _inputs;
  131140. private _gamepads;
  131141. private _keyboardActive;
  131142. private _pointerActive;
  131143. private _elementToAttachTo;
  131144. private _keyboardDownEvent;
  131145. private _keyboardUpEvent;
  131146. private _pointerMoveEvent;
  131147. private _pointerDownEvent;
  131148. private _pointerUpEvent;
  131149. private _gamepadConnectedEvent;
  131150. private _gamepadDisconnectedEvent;
  131151. private static _MAX_KEYCODES;
  131152. private static _MAX_POINTER_INPUTS;
  131153. private constructor();
  131154. /**
  131155. * Creates a new DeviceInputSystem instance
  131156. * @param engine Engine to pull input element from
  131157. * @returns The new instance
  131158. */
  131159. static Create(engine: Engine): DeviceInputSystem;
  131160. /**
  131161. * Checks for current device input value, given an id and input index
  131162. * @param deviceName Id of connected device
  131163. * @param inputIndex Index of device input
  131164. * @returns Current value of input
  131165. */
  131166. /**
  131167. * Checks for current device input value, given an id and input index. Throws exception if requested device not initialized.
  131168. * @param deviceType Enum specifiying device type
  131169. * @param deviceSlot "Slot" or index that device is referenced in
  131170. * @param inputIndex Id of input to be checked
  131171. * @returns Current value of input
  131172. */
  131173. pollInput(deviceType: DeviceType, deviceSlot: number, inputIndex: number): number;
  131174. /**
  131175. * Dispose of all the eventlisteners
  131176. */
  131177. dispose(): void;
  131178. /**
  131179. * Add device and inputs to device array
  131180. * @param deviceType Enum specifiying device type
  131181. * @param deviceSlot "Slot" or index that device is referenced in
  131182. * @param numberOfInputs Number of input entries to create for given device
  131183. */
  131184. private _registerDevice;
  131185. /**
  131186. * Given a specific device name, remove that device from the device map
  131187. * @param deviceType Enum specifiying device type
  131188. * @param deviceSlot "Slot" or index that device is referenced in
  131189. */
  131190. private _unregisterDevice;
  131191. /**
  131192. * Handle all actions that come from keyboard interaction
  131193. */
  131194. private _handleKeyActions;
  131195. /**
  131196. * Handle all actions that come from pointer interaction
  131197. */
  131198. private _handlePointerActions;
  131199. /**
  131200. * Handle all actions that come from gamepad interaction
  131201. */
  131202. private _handleGamepadActions;
  131203. /**
  131204. * Update all non-event based devices with each frame
  131205. * @param deviceType Enum specifiying device type
  131206. * @param deviceSlot "Slot" or index that device is referenced in
  131207. * @param inputIndex Id of input to be checked
  131208. */
  131209. private _updateDevice;
  131210. /**
  131211. * Gets DeviceType from the device name
  131212. * @param deviceName Name of Device from DeviceInputSystem
  131213. * @returns DeviceType enum value
  131214. */
  131215. private _getGamepadDeviceType;
  131216. }
  131217. }
  131218. declare module BABYLON {
  131219. /**
  131220. * Type to handle enforcement of inputs
  131221. */
  131222. 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;
  131223. }
  131224. declare module BABYLON {
  131225. /**
  131226. * Class that handles all input for a specific device
  131227. */
  131228. export class DeviceSource<T extends DeviceType> {
  131229. /** Type of device */
  131230. readonly deviceType: DeviceType;
  131231. /** "Slot" or index that device is referenced in */
  131232. readonly deviceSlot: number;
  131233. /**
  131234. * Observable to handle device input changes per device
  131235. */
  131236. readonly onInputChangedObservable: Observable<{
  131237. inputIndex: DeviceInput<T>;
  131238. previousState: Nullable<number>;
  131239. currentState: Nullable<number>;
  131240. }>;
  131241. private readonly _deviceInputSystem;
  131242. /**
  131243. * Default Constructor
  131244. * @param deviceInputSystem Reference to DeviceInputSystem
  131245. * @param deviceType Type of device
  131246. * @param deviceSlot "Slot" or index that device is referenced in
  131247. */
  131248. constructor(deviceInputSystem: DeviceInputSystem,
  131249. /** Type of device */
  131250. deviceType: DeviceType,
  131251. /** "Slot" or index that device is referenced in */
  131252. deviceSlot?: number);
  131253. /**
  131254. * Get input for specific input
  131255. * @param inputIndex index of specific input on device
  131256. * @returns Input value from DeviceInputSystem
  131257. */
  131258. getInput(inputIndex: DeviceInput<T>): number;
  131259. }
  131260. /**
  131261. * Class to keep track of devices
  131262. */
  131263. export class DeviceSourceManager implements IDisposable {
  131264. /**
  131265. * Observable to be triggered when before a device is connected
  131266. */
  131267. readonly onBeforeDeviceConnectedObservable: Observable<{
  131268. deviceType: DeviceType;
  131269. deviceSlot: number;
  131270. }>;
  131271. /**
  131272. * Observable to be triggered when before a device is disconnected
  131273. */
  131274. readonly onBeforeDeviceDisconnectedObservable: Observable<{
  131275. deviceType: DeviceType;
  131276. deviceSlot: number;
  131277. }>;
  131278. /**
  131279. * Observable to be triggered when after a device is connected
  131280. */
  131281. readonly onAfterDeviceConnectedObservable: Observable<{
  131282. deviceType: DeviceType;
  131283. deviceSlot: number;
  131284. }>;
  131285. /**
  131286. * Observable to be triggered when after a device is disconnected
  131287. */
  131288. readonly onAfterDeviceDisconnectedObservable: Observable<{
  131289. deviceType: DeviceType;
  131290. deviceSlot: number;
  131291. }>;
  131292. private readonly _devices;
  131293. private readonly _firstDevice;
  131294. private readonly _deviceInputSystem;
  131295. /**
  131296. * Default Constructor
  131297. * @param engine engine to pull input element from
  131298. */
  131299. constructor(engine: Engine);
  131300. /**
  131301. * Gets a DeviceSource, given a type and slot
  131302. * @param deviceType Enum specifying device type
  131303. * @param deviceSlot "Slot" or index that device is referenced in
  131304. * @returns DeviceSource object
  131305. */
  131306. getDeviceSource<T extends DeviceType>(deviceType: T, deviceSlot?: number): Nullable<DeviceSource<T>>;
  131307. /**
  131308. * Gets an array of DeviceSource objects for a given device type
  131309. * @param deviceType Enum specifying device type
  131310. * @returns Array of DeviceSource objects
  131311. */
  131312. getDeviceSources<T extends DeviceType>(deviceType: T): ReadonlyArray<DeviceSource<T>>;
  131313. /**
  131314. * Dispose of DeviceInputSystem and other parts
  131315. */
  131316. dispose(): void;
  131317. /**
  131318. * Function to add device name to device list
  131319. * @param deviceType Enum specifying device type
  131320. * @param deviceSlot "Slot" or index that device is referenced in
  131321. */
  131322. private _addDevice;
  131323. /**
  131324. * Function to remove device name to device list
  131325. * @param deviceType Enum specifying device type
  131326. * @param deviceSlot "Slot" or index that device is referenced in
  131327. */
  131328. private _removeDevice;
  131329. /**
  131330. * Updates array storing first connected device of each type
  131331. * @param type Type of Device
  131332. */
  131333. private _updateFirstDevices;
  131334. }
  131335. }
  131336. declare module BABYLON {
  131337. /**
  131338. * Options to create the null engine
  131339. */
  131340. export class NullEngineOptions {
  131341. /**
  131342. * Render width (Default: 512)
  131343. */
  131344. renderWidth: number;
  131345. /**
  131346. * Render height (Default: 256)
  131347. */
  131348. renderHeight: number;
  131349. /**
  131350. * Texture size (Default: 512)
  131351. */
  131352. textureSize: number;
  131353. /**
  131354. * If delta time between frames should be constant
  131355. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  131356. */
  131357. deterministicLockstep: boolean;
  131358. /**
  131359. * Maximum about of steps between frames (Default: 4)
  131360. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  131361. */
  131362. lockstepMaxSteps: number;
  131363. /**
  131364. * Make the matrix computations to be performed in 64 bits instead of 32 bits. False by default
  131365. */
  131366. useHighPrecisionMatrix?: boolean;
  131367. }
  131368. /**
  131369. * The null engine class provides support for headless version of babylon.js.
  131370. * This can be used in server side scenario or for testing purposes
  131371. */
  131372. export class NullEngine extends Engine {
  131373. private _options;
  131374. /**
  131375. * Gets a boolean indicating that the engine is running in deterministic lock step mode
  131376. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  131377. * @returns true if engine is in deterministic lock step mode
  131378. */
  131379. isDeterministicLockStep(): boolean;
  131380. /**
  131381. * Gets the max steps when engine is running in deterministic lock step
  131382. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  131383. * @returns the max steps
  131384. */
  131385. getLockstepMaxSteps(): number;
  131386. /**
  131387. * Gets the current hardware scaling level.
  131388. * By default the hardware scaling level is computed from the window device ratio.
  131389. * 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.
  131390. * @returns a number indicating the current hardware scaling level
  131391. */
  131392. getHardwareScalingLevel(): number;
  131393. constructor(options?: NullEngineOptions);
  131394. /**
  131395. * Creates a vertex buffer
  131396. * @param vertices the data for the vertex buffer
  131397. * @returns the new WebGL static buffer
  131398. */
  131399. createVertexBuffer(vertices: FloatArray): DataBuffer;
  131400. /**
  131401. * Creates a new index buffer
  131402. * @param indices defines the content of the index buffer
  131403. * @param updatable defines if the index buffer must be updatable
  131404. * @returns a new webGL buffer
  131405. */
  131406. createIndexBuffer(indices: IndicesArray): DataBuffer;
  131407. /**
  131408. * Clear the current render buffer or the current render target (if any is set up)
  131409. * @param color defines the color to use
  131410. * @param backBuffer defines if the back buffer must be cleared
  131411. * @param depth defines if the depth buffer must be cleared
  131412. * @param stencil defines if the stencil buffer must be cleared
  131413. */
  131414. clear(color: IColor4Like, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  131415. /**
  131416. * Gets the current render width
  131417. * @param useScreen defines if screen size must be used (or the current render target if any)
  131418. * @returns a number defining the current render width
  131419. */
  131420. getRenderWidth(useScreen?: boolean): number;
  131421. /**
  131422. * Gets the current render height
  131423. * @param useScreen defines if screen size must be used (or the current render target if any)
  131424. * @returns a number defining the current render height
  131425. */
  131426. getRenderHeight(useScreen?: boolean): number;
  131427. /**
  131428. * Set the WebGL's viewport
  131429. * @param viewport defines the viewport element to be used
  131430. * @param requiredWidth defines the width required for rendering. If not provided the rendering canvas' width is used
  131431. * @param requiredHeight defines the height required for rendering. If not provided the rendering canvas' height is used
  131432. */
  131433. setViewport(viewport: IViewportLike, requiredWidth?: number, requiredHeight?: number): void;
  131434. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: string, context?: WebGLRenderingContext): WebGLProgram;
  131435. /**
  131436. * Gets the list of webGL uniform locations associated with a specific program based on a list of uniform names
  131437. * @param pipelineContext defines the pipeline context to use
  131438. * @param uniformsNames defines the list of uniform names
  131439. * @returns an array of webGL uniform locations
  131440. */
  131441. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): Nullable<WebGLUniformLocation>[];
  131442. /**
  131443. * Gets the lsit of active attributes for a given webGL program
  131444. * @param pipelineContext defines the pipeline context to use
  131445. * @param attributesNames defines the list of attribute names to get
  131446. * @returns an array of indices indicating the offset of each attribute
  131447. */
  131448. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  131449. /**
  131450. * Binds an effect to the webGL context
  131451. * @param effect defines the effect to bind
  131452. */
  131453. bindSamplers(effect: Effect): void;
  131454. /**
  131455. * Activates an effect, mkaing it the current one (ie. the one used for rendering)
  131456. * @param effect defines the effect to activate
  131457. */
  131458. enableEffect(effect: Effect): void;
  131459. /**
  131460. * Set various states to the webGL context
  131461. * @param culling defines backface culling state
  131462. * @param zOffset defines the value to apply to zOffset (0 by default)
  131463. * @param force defines if states must be applied even if cache is up to date
  131464. * @param reverseSide defines if culling must be reversed (CCW instead of CW and CW instead of CCW)
  131465. */
  131466. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  131467. /**
  131468. * Set the value of an uniform to an array of int32
  131469. * @param uniform defines the webGL uniform location where to store the value
  131470. * @param array defines the array of int32 to store
  131471. */
  131472. setIntArray(uniform: WebGLUniformLocation, array: Int32Array): void;
  131473. /**
  131474. * Set the value of an uniform to an array of int32 (stored as vec2)
  131475. * @param uniform defines the webGL uniform location where to store the value
  131476. * @param array defines the array of int32 to store
  131477. */
  131478. setIntArray2(uniform: WebGLUniformLocation, array: Int32Array): void;
  131479. /**
  131480. * Set the value of an uniform to an array of int32 (stored as vec3)
  131481. * @param uniform defines the webGL uniform location where to store the value
  131482. * @param array defines the array of int32 to store
  131483. */
  131484. setIntArray3(uniform: WebGLUniformLocation, array: Int32Array): void;
  131485. /**
  131486. * Set the value of an uniform to an array of int32 (stored as vec4)
  131487. * @param uniform defines the webGL uniform location where to store the value
  131488. * @param array defines the array of int32 to store
  131489. */
  131490. setIntArray4(uniform: WebGLUniformLocation, array: Int32Array): void;
  131491. /**
  131492. * Set the value of an uniform to an array of float32
  131493. * @param uniform defines the webGL uniform location where to store the value
  131494. * @param array defines the array of float32 to store
  131495. */
  131496. setFloatArray(uniform: WebGLUniformLocation, array: Float32Array): void;
  131497. /**
  131498. * Set the value of an uniform to an array of float32 (stored as vec2)
  131499. * @param uniform defines the webGL uniform location where to store the value
  131500. * @param array defines the array of float32 to store
  131501. */
  131502. setFloatArray2(uniform: WebGLUniformLocation, array: Float32Array): void;
  131503. /**
  131504. * Set the value of an uniform to an array of float32 (stored as vec3)
  131505. * @param uniform defines the webGL uniform location where to store the value
  131506. * @param array defines the array of float32 to store
  131507. */
  131508. setFloatArray3(uniform: WebGLUniformLocation, array: Float32Array): void;
  131509. /**
  131510. * Set the value of an uniform to an array of float32 (stored as vec4)
  131511. * @param uniform defines the webGL uniform location where to store the value
  131512. * @param array defines the array of float32 to store
  131513. */
  131514. setFloatArray4(uniform: WebGLUniformLocation, array: Float32Array): void;
  131515. /**
  131516. * Set the value of an uniform to an array of number
  131517. * @param uniform defines the webGL uniform location where to store the value
  131518. * @param array defines the array of number to store
  131519. */
  131520. setArray(uniform: WebGLUniformLocation, array: number[]): void;
  131521. /**
  131522. * Set the value of an uniform to an array of number (stored as vec2)
  131523. * @param uniform defines the webGL uniform location where to store the value
  131524. * @param array defines the array of number to store
  131525. */
  131526. setArray2(uniform: WebGLUniformLocation, array: number[]): void;
  131527. /**
  131528. * Set the value of an uniform to an array of number (stored as vec3)
  131529. * @param uniform defines the webGL uniform location where to store the value
  131530. * @param array defines the array of number to store
  131531. */
  131532. setArray3(uniform: WebGLUniformLocation, array: number[]): void;
  131533. /**
  131534. * Set the value of an uniform to an array of number (stored as vec4)
  131535. * @param uniform defines the webGL uniform location where to store the value
  131536. * @param array defines the array of number to store
  131537. */
  131538. setArray4(uniform: WebGLUniformLocation, array: number[]): void;
  131539. /**
  131540. * Set the value of an uniform to an array of float32 (stored as matrices)
  131541. * @param uniform defines the webGL uniform location where to store the value
  131542. * @param matrices defines the array of float32 to store
  131543. */
  131544. setMatrices(uniform: WebGLUniformLocation, matrices: Float32Array): void;
  131545. /**
  131546. * Set the value of an uniform to a matrix (3x3)
  131547. * @param uniform defines the webGL uniform location where to store the value
  131548. * @param matrix defines the Float32Array representing the 3x3 matrix to store
  131549. */
  131550. setMatrix3x3(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  131551. /**
  131552. * Set the value of an uniform to a matrix (2x2)
  131553. * @param uniform defines the webGL uniform location where to store the value
  131554. * @param matrix defines the Float32Array representing the 2x2 matrix to store
  131555. */
  131556. setMatrix2x2(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  131557. /**
  131558. * Set the value of an uniform to a number (float)
  131559. * @param uniform defines the webGL uniform location where to store the value
  131560. * @param value defines the float number to store
  131561. */
  131562. setFloat(uniform: WebGLUniformLocation, value: number): void;
  131563. /**
  131564. * Set the value of an uniform to a vec2
  131565. * @param uniform defines the webGL uniform location where to store the value
  131566. * @param x defines the 1st component of the value
  131567. * @param y defines the 2nd component of the value
  131568. */
  131569. setFloat2(uniform: WebGLUniformLocation, x: number, y: number): void;
  131570. /**
  131571. * Set the value of an uniform to a vec3
  131572. * @param uniform defines the webGL uniform location where to store the value
  131573. * @param x defines the 1st component of the value
  131574. * @param y defines the 2nd component of the value
  131575. * @param z defines the 3rd component of the value
  131576. */
  131577. setFloat3(uniform: WebGLUniformLocation, x: number, y: number, z: number): void;
  131578. /**
  131579. * Set the value of an uniform to a boolean
  131580. * @param uniform defines the webGL uniform location where to store the value
  131581. * @param bool defines the boolean to store
  131582. */
  131583. setBool(uniform: WebGLUniformLocation, bool: number): void;
  131584. /**
  131585. * Set the value of an uniform to a vec4
  131586. * @param uniform defines the webGL uniform location where to store the value
  131587. * @param x defines the 1st component of the value
  131588. * @param y defines the 2nd component of the value
  131589. * @param z defines the 3rd component of the value
  131590. * @param w defines the 4th component of the value
  131591. */
  131592. setFloat4(uniform: WebGLUniformLocation, x: number, y: number, z: number, w: number): void;
  131593. /**
  131594. * Sets the current alpha mode
  131595. * @param mode defines the mode to use (one of the Engine.ALPHA_XXX)
  131596. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  131597. * @see https://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  131598. */
  131599. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  131600. /**
  131601. * Bind webGl buffers directly to the webGL context
  131602. * @param vertexBuffers defines the vertex buffer to bind
  131603. * @param indexBuffer defines the index buffer to bind
  131604. * @param vertexDeclaration defines the vertex declaration to use with the vertex buffer
  131605. * @param vertexStrideSize defines the vertex stride of the vertex buffer
  131606. * @param effect defines the effect associated with the vertex buffer
  131607. */
  131608. bindBuffers(vertexBuffers: {
  131609. [key: string]: VertexBuffer;
  131610. }, indexBuffer: DataBuffer, effect: Effect): void;
  131611. /**
  131612. * Force the entire cache to be cleared
  131613. * You should not have to use this function unless your engine needs to share the webGL context with another engine
  131614. * @param bruteForce defines a boolean to force clearing ALL caches (including stencil, detoh and alpha states)
  131615. */
  131616. wipeCaches(bruteForce?: boolean): void;
  131617. /**
  131618. * Send a draw order
  131619. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  131620. * @param indexStart defines the starting index
  131621. * @param indexCount defines the number of index to draw
  131622. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  131623. */
  131624. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  131625. /**
  131626. * Draw a list of indexed primitives
  131627. * @param fillMode defines the primitive to use
  131628. * @param indexStart defines the starting index
  131629. * @param indexCount defines the number of index to draw
  131630. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  131631. */
  131632. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  131633. /**
  131634. * Draw a list of unindexed primitives
  131635. * @param fillMode defines the primitive to use
  131636. * @param verticesStart defines the index of first vertex to draw
  131637. * @param verticesCount defines the count of vertices to draw
  131638. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  131639. */
  131640. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  131641. /** @hidden */
  131642. _createTexture(): WebGLTexture;
  131643. /** @hidden */
  131644. _releaseTexture(texture: InternalTexture): void;
  131645. /**
  131646. * Usually called from Texture.ts.
  131647. * Passed information to create a WebGLTexture
  131648. * @param urlArg defines a value which contains one of the following:
  131649. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  131650. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  131651. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  131652. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  131653. * @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)
  131654. * @param scene needed for loading to the correct scene
  131655. * @param samplingMode mode with should be used sample / access the texture (Default: Texture.TRILINEAR_SAMPLINGMODE)
  131656. * @param onLoad optional callback to be called upon successful completion
  131657. * @param onError optional callback to be called upon failure
  131658. * @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
  131659. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  131660. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  131661. * @param forcedExtension defines the extension to use to pick the right loader
  131662. * @param mimeType defines an optional mime type
  131663. * @returns a InternalTexture for assignment back into BABYLON.Texture
  131664. */
  131665. 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;
  131666. /**
  131667. * Creates a new render target texture
  131668. * @param size defines the size of the texture
  131669. * @param options defines the options used to create the texture
  131670. * @returns a new render target texture stored in an InternalTexture
  131671. */
  131672. createRenderTargetTexture(size: any, options: boolean | RenderTargetCreationOptions): InternalTexture;
  131673. /**
  131674. * Update the sampling mode of a given texture
  131675. * @param samplingMode defines the required sampling mode
  131676. * @param texture defines the texture to update
  131677. */
  131678. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  131679. /**
  131680. * Binds the frame buffer to the specified texture.
  131681. * @param texture The texture to render to or null for the default canvas
  131682. * @param faceIndex The face of the texture to render to in case of cube texture
  131683. * @param requiredWidth The width of the target to render to
  131684. * @param requiredHeight The height of the target to render to
  131685. * @param forceFullscreenViewport Forces the viewport to be the entire texture/screen if true
  131686. * @param lodLevel defines le lod level to bind to the frame buffer
  131687. */
  131688. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean): void;
  131689. /**
  131690. * Unbind the current render target texture from the webGL context
  131691. * @param texture defines the render target texture to unbind
  131692. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  131693. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  131694. */
  131695. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  131696. /**
  131697. * Creates a dynamic vertex buffer
  131698. * @param vertices the data for the dynamic vertex buffer
  131699. * @returns the new WebGL dynamic buffer
  131700. */
  131701. createDynamicVertexBuffer(vertices: FloatArray): DataBuffer;
  131702. /**
  131703. * Update the content of a dynamic texture
  131704. * @param texture defines the texture to update
  131705. * @param canvas defines the canvas containing the source
  131706. * @param invertY defines if data must be stored with Y axis inverted
  131707. * @param premulAlpha defines if alpha is stored as premultiplied
  131708. * @param format defines the format of the data
  131709. * @param forceBindTexture if the texture should be forced to be bound eg. after a graphics context loss (Default: false)
  131710. */
  131711. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement, invertY: boolean, premulAlpha?: boolean, format?: number): void;
  131712. /**
  131713. * Gets a boolean indicating if all created effects are ready
  131714. * @returns true if all effects are ready
  131715. */
  131716. areAllEffectsReady(): boolean;
  131717. /**
  131718. * @hidden
  131719. * Get the current error code of the webGL context
  131720. * @returns the error code
  131721. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  131722. */
  131723. getError(): number;
  131724. /** @hidden */
  131725. _getUnpackAlignement(): number;
  131726. /** @hidden */
  131727. _unpackFlipY(value: boolean): void;
  131728. /**
  131729. * Update a dynamic index buffer
  131730. * @param indexBuffer defines the target index buffer
  131731. * @param indices defines the data to update
  131732. * @param offset defines the offset in the target index buffer where update should start
  131733. */
  131734. updateDynamicIndexBuffer(indexBuffer: WebGLBuffer, indices: IndicesArray, offset?: number): void;
  131735. /**
  131736. * Updates a dynamic vertex buffer.
  131737. * @param vertexBuffer the vertex buffer to update
  131738. * @param vertices the data used to update the vertex buffer
  131739. * @param byteOffset the byte offset of the data (optional)
  131740. * @param byteLength the byte length of the data (optional)
  131741. */
  131742. updateDynamicVertexBuffer(vertexBuffer: WebGLBuffer, vertices: FloatArray, byteOffset?: number, byteLength?: number): void;
  131743. /** @hidden */
  131744. _bindTextureDirectly(target: number, texture: InternalTexture): boolean;
  131745. /** @hidden */
  131746. _bindTexture(channel: number, texture: InternalTexture): void;
  131747. protected _deleteBuffer(buffer: WebGLBuffer): void;
  131748. /**
  131749. * 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
  131750. */
  131751. releaseEffects(): void;
  131752. displayLoadingUI(): void;
  131753. hideLoadingUI(): void;
  131754. /** @hidden */
  131755. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  131756. /** @hidden */
  131757. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  131758. /** @hidden */
  131759. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  131760. /** @hidden */
  131761. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  131762. }
  131763. }
  131764. declare module BABYLON {
  131765. /**
  131766. * @hidden
  131767. **/
  131768. export class _TimeToken {
  131769. _startTimeQuery: Nullable<WebGLQuery>;
  131770. _endTimeQuery: Nullable<WebGLQuery>;
  131771. _timeElapsedQuery: Nullable<WebGLQuery>;
  131772. _timeElapsedQueryEnded: boolean;
  131773. }
  131774. }
  131775. declare module BABYLON {
  131776. /** @hidden */
  131777. export class _OcclusionDataStorage {
  131778. /** @hidden */
  131779. occlusionInternalRetryCounter: number;
  131780. /** @hidden */
  131781. isOcclusionQueryInProgress: boolean;
  131782. /** @hidden */
  131783. isOccluded: boolean;
  131784. /** @hidden */
  131785. occlusionRetryCount: number;
  131786. /** @hidden */
  131787. occlusionType: number;
  131788. /** @hidden */
  131789. occlusionQueryAlgorithmType: number;
  131790. }
  131791. interface Engine {
  131792. /**
  131793. * Create a new webGL query (you must be sure that queries are supported by checking getCaps() function)
  131794. * @return the new query
  131795. */
  131796. createQuery(): WebGLQuery;
  131797. /**
  131798. * Delete and release a webGL query
  131799. * @param query defines the query to delete
  131800. * @return the current engine
  131801. */
  131802. deleteQuery(query: WebGLQuery): Engine;
  131803. /**
  131804. * Check if a given query has resolved and got its value
  131805. * @param query defines the query to check
  131806. * @returns true if the query got its value
  131807. */
  131808. isQueryResultAvailable(query: WebGLQuery): boolean;
  131809. /**
  131810. * Gets the value of a given query
  131811. * @param query defines the query to check
  131812. * @returns the value of the query
  131813. */
  131814. getQueryResult(query: WebGLQuery): number;
  131815. /**
  131816. * Initiates an occlusion query
  131817. * @param algorithmType defines the algorithm to use
  131818. * @param query defines the query to use
  131819. * @returns the current engine
  131820. * @see https://doc.babylonjs.com/features/occlusionquery
  131821. */
  131822. beginOcclusionQuery(algorithmType: number, query: WebGLQuery): Engine;
  131823. /**
  131824. * Ends an occlusion query
  131825. * @see https://doc.babylonjs.com/features/occlusionquery
  131826. * @param algorithmType defines the algorithm to use
  131827. * @returns the current engine
  131828. */
  131829. endOcclusionQuery(algorithmType: number): Engine;
  131830. /**
  131831. * Starts a time query (used to measure time spent by the GPU on a specific frame)
  131832. * Please note that only one query can be issued at a time
  131833. * @returns a time token used to track the time span
  131834. */
  131835. startTimeQuery(): Nullable<_TimeToken>;
  131836. /**
  131837. * Ends a time query
  131838. * @param token defines the token used to measure the time span
  131839. * @returns the time spent (in ns)
  131840. */
  131841. endTimeQuery(token: _TimeToken): int;
  131842. /** @hidden */
  131843. _currentNonTimestampToken: Nullable<_TimeToken>;
  131844. /** @hidden */
  131845. _createTimeQuery(): WebGLQuery;
  131846. /** @hidden */
  131847. _deleteTimeQuery(query: WebGLQuery): void;
  131848. /** @hidden */
  131849. _getGlAlgorithmType(algorithmType: number): number;
  131850. /** @hidden */
  131851. _getTimeQueryResult(query: WebGLQuery): any;
  131852. /** @hidden */
  131853. _getTimeQueryAvailability(query: WebGLQuery): any;
  131854. }
  131855. interface AbstractMesh {
  131856. /**
  131857. * Backing filed
  131858. * @hidden
  131859. */
  131860. __occlusionDataStorage: _OcclusionDataStorage;
  131861. /**
  131862. * Access property
  131863. * @hidden
  131864. */
  131865. _occlusionDataStorage: _OcclusionDataStorage;
  131866. /**
  131867. * 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.
  131868. * The default value is -1 which means don't break the query and wait till the result
  131869. * @see https://doc.babylonjs.com/features/occlusionquery
  131870. */
  131871. occlusionRetryCount: number;
  131872. /**
  131873. * 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:
  131874. * * OCCLUSION_TYPE_NONE (Default Value): this option means no occlusion query whith the Mesh.
  131875. * * OCCLUSION_TYPE_OPTIMISTIC: this option is means use occlusion query and if occlusionRetryCount is reached and the query is broken show the mesh.
  131876. * * 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.
  131877. * @see https://doc.babylonjs.com/features/occlusionquery
  131878. */
  131879. occlusionType: number;
  131880. /**
  131881. * This property determines the type of occlusion query algorithm to run in WebGl, you can use:
  131882. * * AbstractMesh.OCCLUSION_ALGORITHM_TYPE_ACCURATE which is mapped to GL_ANY_SAMPLES_PASSED.
  131883. * * 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.
  131884. * @see https://doc.babylonjs.com/features/occlusionquery
  131885. */
  131886. occlusionQueryAlgorithmType: number;
  131887. /**
  131888. * 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
  131889. * @see https://doc.babylonjs.com/features/occlusionquery
  131890. */
  131891. isOccluded: boolean;
  131892. /**
  131893. * Flag to check the progress status of the query
  131894. * @see https://doc.babylonjs.com/features/occlusionquery
  131895. */
  131896. isOcclusionQueryInProgress: boolean;
  131897. }
  131898. }
  131899. declare module BABYLON {
  131900. /** @hidden */
  131901. export var _forceTransformFeedbackToBundle: boolean;
  131902. interface Engine {
  131903. /**
  131904. * Creates a webGL transform feedback object
  131905. * Please makes sure to check webGLVersion property to check if you are running webGL 2+
  131906. * @returns the webGL transform feedback object
  131907. */
  131908. createTransformFeedback(): WebGLTransformFeedback;
  131909. /**
  131910. * Delete a webGL transform feedback object
  131911. * @param value defines the webGL transform feedback object to delete
  131912. */
  131913. deleteTransformFeedback(value: WebGLTransformFeedback): void;
  131914. /**
  131915. * Bind a webGL transform feedback object to the webgl context
  131916. * @param value defines the webGL transform feedback object to bind
  131917. */
  131918. bindTransformFeedback(value: Nullable<WebGLTransformFeedback>): void;
  131919. /**
  131920. * Begins a transform feedback operation
  131921. * @param usePoints defines if points or triangles must be used
  131922. */
  131923. beginTransformFeedback(usePoints: boolean): void;
  131924. /**
  131925. * Ends a transform feedback operation
  131926. */
  131927. endTransformFeedback(): void;
  131928. /**
  131929. * Specify the varyings to use with transform feedback
  131930. * @param program defines the associated webGL program
  131931. * @param value defines the list of strings representing the varying names
  131932. */
  131933. setTranformFeedbackVaryings(program: WebGLProgram, value: string[]): void;
  131934. /**
  131935. * Bind a webGL buffer for a transform feedback operation
  131936. * @param value defines the webGL buffer to bind
  131937. */
  131938. bindTransformFeedbackBuffer(value: Nullable<DataBuffer>): void;
  131939. }
  131940. }
  131941. declare module BABYLON {
  131942. /**
  131943. * Class used to define an additional view for the engine
  131944. * @see https://doc.babylonjs.com/how_to/multi_canvases
  131945. */
  131946. export class EngineView {
  131947. /** Defines the canvas where to render the view */
  131948. target: HTMLCanvasElement;
  131949. /** Defines an optional camera used to render the view (will use active camera else) */
  131950. camera?: Camera;
  131951. }
  131952. interface Engine {
  131953. /**
  131954. * Gets or sets the HTML element to use for attaching events
  131955. */
  131956. inputElement: Nullable<HTMLElement>;
  131957. /**
  131958. * Gets the current engine view
  131959. * @see https://doc.babylonjs.com/how_to/multi_canvases
  131960. */
  131961. activeView: Nullable<EngineView>;
  131962. /** Gets or sets the list of views */
  131963. views: EngineView[];
  131964. /**
  131965. * Register a new child canvas
  131966. * @param canvas defines the canvas to register
  131967. * @param camera defines an optional camera to use with this canvas (it will overwrite the scene.camera for this view)
  131968. * @returns the associated view
  131969. */
  131970. registerView(canvas: HTMLCanvasElement, camera?: Camera): EngineView;
  131971. /**
  131972. * Remove a registered child canvas
  131973. * @param canvas defines the canvas to remove
  131974. * @returns the current engine
  131975. */
  131976. unRegisterView(canvas: HTMLCanvasElement): Engine;
  131977. }
  131978. }
  131979. declare module BABYLON {
  131980. interface Engine {
  131981. /** @hidden */
  131982. _excludedCompressedTextures: string[];
  131983. /** @hidden */
  131984. _textureFormatInUse: string;
  131985. /**
  131986. * Gets the list of texture formats supported
  131987. */
  131988. readonly texturesSupported: Array<string>;
  131989. /**
  131990. * Gets the texture format in use
  131991. */
  131992. readonly textureFormatInUse: Nullable<string>;
  131993. /**
  131994. * Set the compressed texture extensions or file names to skip.
  131995. *
  131996. * @param skippedFiles defines the list of those texture files you want to skip
  131997. * Example: [".dds", ".env", "myfile.png"]
  131998. */
  131999. setCompressedTextureExclusions(skippedFiles: Array<string>): void;
  132000. /**
  132001. * Set the compressed texture format to use, based on the formats you have, and the formats
  132002. * supported by the hardware / browser.
  132003. *
  132004. * Khronos Texture Container (.ktx) files are used to support this. This format has the
  132005. * advantage of being specifically designed for OpenGL. Header elements directly correspond
  132006. * to API arguments needed to compressed textures. This puts the burden on the container
  132007. * generator to house the arcane code for determining these for current & future formats.
  132008. *
  132009. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  132010. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  132011. *
  132012. * Note: The result of this call is not taken into account when a texture is base64.
  132013. *
  132014. * @param formatsAvailable defines the list of those format families you have created
  132015. * on your server. Syntax: '-' + format family + '.ktx'. (Case and order do not matter.)
  132016. *
  132017. * Current families are astc, dxt, pvrtc, etc2, & etc1.
  132018. * @returns The extension selected.
  132019. */
  132020. setTextureFormatToUse(formatsAvailable: Array<string>): Nullable<string>;
  132021. }
  132022. }
  132023. declare module BABYLON {
  132024. /**
  132025. * CubeMap information grouping all the data for each faces as well as the cubemap size.
  132026. */
  132027. export interface CubeMapInfo {
  132028. /**
  132029. * The pixel array for the front face.
  132030. * This is stored in format, left to right, up to down format.
  132031. */
  132032. front: Nullable<ArrayBufferView>;
  132033. /**
  132034. * The pixel array for the back face.
  132035. * This is stored in format, left to right, up to down format.
  132036. */
  132037. back: Nullable<ArrayBufferView>;
  132038. /**
  132039. * The pixel array for the left face.
  132040. * This is stored in format, left to right, up to down format.
  132041. */
  132042. left: Nullable<ArrayBufferView>;
  132043. /**
  132044. * The pixel array for the right face.
  132045. * This is stored in format, left to right, up to down format.
  132046. */
  132047. right: Nullable<ArrayBufferView>;
  132048. /**
  132049. * The pixel array for the up face.
  132050. * This is stored in format, left to right, up to down format.
  132051. */
  132052. up: Nullable<ArrayBufferView>;
  132053. /**
  132054. * The pixel array for the down face.
  132055. * This is stored in format, left to right, up to down format.
  132056. */
  132057. down: Nullable<ArrayBufferView>;
  132058. /**
  132059. * The size of the cubemap stored.
  132060. *
  132061. * Each faces will be size * size pixels.
  132062. */
  132063. size: number;
  132064. /**
  132065. * The format of the texture.
  132066. *
  132067. * RGBA, RGB.
  132068. */
  132069. format: number;
  132070. /**
  132071. * The type of the texture data.
  132072. *
  132073. * UNSIGNED_INT, FLOAT.
  132074. */
  132075. type: number;
  132076. /**
  132077. * Specifies whether the texture is in gamma space.
  132078. */
  132079. gammaSpace: boolean;
  132080. }
  132081. /**
  132082. * Helper class useful to convert panorama picture to their cubemap representation in 6 faces.
  132083. */
  132084. export class PanoramaToCubeMapTools {
  132085. private static FACE_LEFT;
  132086. private static FACE_RIGHT;
  132087. private static FACE_FRONT;
  132088. private static FACE_BACK;
  132089. private static FACE_DOWN;
  132090. private static FACE_UP;
  132091. /**
  132092. * Converts a panorma stored in RGB right to left up to down format into a cubemap (6 faces).
  132093. *
  132094. * @param float32Array The source data.
  132095. * @param inputWidth The width of the input panorama.
  132096. * @param inputHeight The height of the input panorama.
  132097. * @param size The willing size of the generated cubemap (each faces will be size * size pixels)
  132098. * @return The cubemap data
  132099. */
  132100. static ConvertPanoramaToCubemap(float32Array: Float32Array, inputWidth: number, inputHeight: number, size: number): CubeMapInfo;
  132101. private static CreateCubemapTexture;
  132102. private static CalcProjectionSpherical;
  132103. }
  132104. }
  132105. declare module BABYLON {
  132106. /**
  132107. * Helper class dealing with the extraction of spherical polynomial dataArray
  132108. * from a cube map.
  132109. */
  132110. export class CubeMapToSphericalPolynomialTools {
  132111. private static FileFaces;
  132112. /**
  132113. * Converts a texture to the according Spherical Polynomial data.
  132114. * This extracts the first 3 orders only as they are the only one used in the lighting.
  132115. *
  132116. * @param texture The texture to extract the information from.
  132117. * @return The Spherical Polynomial data.
  132118. */
  132119. static ConvertCubeMapTextureToSphericalPolynomial(texture: BaseTexture): Nullable<SphericalPolynomial>;
  132120. /**
  132121. * Converts a cubemap to the according Spherical Polynomial data.
  132122. * This extracts the first 3 orders only as they are the only one used in the lighting.
  132123. *
  132124. * @param cubeInfo The Cube map to extract the information from.
  132125. * @return The Spherical Polynomial data.
  132126. */
  132127. static ConvertCubeMapToSphericalPolynomial(cubeInfo: CubeMapInfo): SphericalPolynomial;
  132128. }
  132129. }
  132130. declare module BABYLON {
  132131. interface BaseTexture {
  132132. /**
  132133. * Get the polynomial representation of the texture data.
  132134. * This is mainly use as a fast way to recover IBL Diffuse irradiance data.
  132135. * @see https://learnopengl.com/PBR/IBL/Diffuse-irradiance
  132136. */
  132137. sphericalPolynomial: Nullable<SphericalPolynomial>;
  132138. }
  132139. }
  132140. declare module BABYLON {
  132141. /** @hidden */
  132142. export var rgbdEncodePixelShader: {
  132143. name: string;
  132144. shader: string;
  132145. };
  132146. }
  132147. declare module BABYLON {
  132148. /** @hidden */
  132149. export var rgbdDecodePixelShader: {
  132150. name: string;
  132151. shader: string;
  132152. };
  132153. }
  132154. declare module BABYLON {
  132155. /**
  132156. * Raw texture data and descriptor sufficient for WebGL texture upload
  132157. */
  132158. export interface EnvironmentTextureInfo {
  132159. /**
  132160. * Version of the environment map
  132161. */
  132162. version: number;
  132163. /**
  132164. * Width of image
  132165. */
  132166. width: number;
  132167. /**
  132168. * Irradiance information stored in the file.
  132169. */
  132170. irradiance: any;
  132171. /**
  132172. * Specular information stored in the file.
  132173. */
  132174. specular: any;
  132175. }
  132176. /**
  132177. * Defines One Image in the file. It requires only the position in the file
  132178. * as well as the length.
  132179. */
  132180. interface BufferImageData {
  132181. /**
  132182. * Length of the image data.
  132183. */
  132184. length: number;
  132185. /**
  132186. * Position of the data from the null terminator delimiting the end of the JSON.
  132187. */
  132188. position: number;
  132189. }
  132190. /**
  132191. * Defines the specular data enclosed in the file.
  132192. * This corresponds to the version 1 of the data.
  132193. */
  132194. export interface EnvironmentTextureSpecularInfoV1 {
  132195. /**
  132196. * Defines where the specular Payload is located. It is a runtime value only not stored in the file.
  132197. */
  132198. specularDataPosition?: number;
  132199. /**
  132200. * This contains all the images data needed to reconstruct the cubemap.
  132201. */
  132202. mipmaps: Array<BufferImageData>;
  132203. /**
  132204. * Defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness.
  132205. */
  132206. lodGenerationScale: number;
  132207. }
  132208. /**
  132209. * Sets of helpers addressing the serialization and deserialization of environment texture
  132210. * stored in a BabylonJS env file.
  132211. * Those files are usually stored as .env files.
  132212. */
  132213. export class EnvironmentTextureTools {
  132214. /**
  132215. * Magic number identifying the env file.
  132216. */
  132217. private static _MagicBytes;
  132218. /**
  132219. * Gets the environment info from an env file.
  132220. * @param data The array buffer containing the .env bytes.
  132221. * @returns the environment file info (the json header) if successfully parsed.
  132222. */
  132223. static GetEnvInfo(data: ArrayBufferView): Nullable<EnvironmentTextureInfo>;
  132224. /**
  132225. * Creates an environment texture from a loaded cube texture.
  132226. * @param texture defines the cube texture to convert in env file
  132227. * @return a promise containing the environment data if succesfull.
  132228. */
  132229. static CreateEnvTextureAsync(texture: BaseTexture): Promise<ArrayBuffer>;
  132230. /**
  132231. * Creates a JSON representation of the spherical data.
  132232. * @param texture defines the texture containing the polynomials
  132233. * @return the JSON representation of the spherical info
  132234. */
  132235. private static _CreateEnvTextureIrradiance;
  132236. /**
  132237. * Creates the ArrayBufferViews used for initializing environment texture image data.
  132238. * @param data the image data
  132239. * @param info parameters that determine what views will be created for accessing the underlying buffer
  132240. * @return the views described by info providing access to the underlying buffer
  132241. */
  132242. static CreateImageDataArrayBufferViews(data: ArrayBufferView, info: EnvironmentTextureInfo): Array<Array<ArrayBufferView>>;
  132243. /**
  132244. * Uploads the texture info contained in the env file to the GPU.
  132245. * @param texture defines the internal texture to upload to
  132246. * @param data defines the data to load
  132247. * @param info defines the texture info retrieved through the GetEnvInfo method
  132248. * @returns a promise
  132249. */
  132250. static UploadEnvLevelsAsync(texture: InternalTexture, data: ArrayBufferView, info: EnvironmentTextureInfo): Promise<void>;
  132251. private static _OnImageReadyAsync;
  132252. /**
  132253. * Uploads the levels of image data to the GPU.
  132254. * @param texture defines the internal texture to upload to
  132255. * @param imageData defines the array buffer views of image data [mipmap][face]
  132256. * @returns a promise
  132257. */
  132258. static UploadLevelsAsync(texture: InternalTexture, imageData: ArrayBufferView[][]): Promise<void>;
  132259. /**
  132260. * Uploads spherical polynomials information to the texture.
  132261. * @param texture defines the texture we are trying to upload the information to
  132262. * @param info defines the environment texture info retrieved through the GetEnvInfo method
  132263. */
  132264. static UploadEnvSpherical(texture: InternalTexture, info: EnvironmentTextureInfo): void;
  132265. /** @hidden */
  132266. static _UpdateRGBDAsync(internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number): Promise<void>;
  132267. }
  132268. }
  132269. declare module BABYLON {
  132270. /**
  132271. * Class used to inline functions in shader code
  132272. */
  132273. export class ShaderCodeInliner {
  132274. private static readonly _RegexpFindFunctionNameAndType;
  132275. private _sourceCode;
  132276. private _functionDescr;
  132277. private _numMaxIterations;
  132278. /** Gets or sets the token used to mark the functions to inline */
  132279. inlineToken: string;
  132280. /** Gets or sets the debug mode */
  132281. debug: boolean;
  132282. /** Gets the code after the inlining process */
  132283. get code(): string;
  132284. /**
  132285. * Initializes the inliner
  132286. * @param sourceCode shader code source to inline
  132287. * @param numMaxIterations maximum number of iterations (used to detect recursive calls)
  132288. */
  132289. constructor(sourceCode: string, numMaxIterations?: number);
  132290. /**
  132291. * Start the processing of the shader code
  132292. */
  132293. processCode(): void;
  132294. private _collectFunctions;
  132295. private _processInlining;
  132296. private _extractBetweenMarkers;
  132297. private _skipWhitespaces;
  132298. private _removeComments;
  132299. private _replaceFunctionCallsByCode;
  132300. private _findBackward;
  132301. private _escapeRegExp;
  132302. private _replaceNames;
  132303. }
  132304. }
  132305. declare module BABYLON {
  132306. /**
  132307. * Container for accessors for natively-stored mesh data buffers.
  132308. */
  132309. class NativeDataBuffer extends DataBuffer {
  132310. /**
  132311. * Accessor value used to identify/retrieve a natively-stored index buffer.
  132312. */
  132313. nativeIndexBuffer?: any;
  132314. /**
  132315. * Accessor value used to identify/retrieve a natively-stored vertex buffer.
  132316. */
  132317. nativeVertexBuffer?: any;
  132318. }
  132319. /** @hidden */
  132320. class NativeTexture extends InternalTexture {
  132321. getInternalTexture(): InternalTexture;
  132322. getViewCount(): number;
  132323. }
  132324. /** @hidden */
  132325. export class NativeEngine extends Engine {
  132326. private readonly _native;
  132327. /** Defines the invalid handle returned by bgfx when resource creation goes wrong */
  132328. private readonly INVALID_HANDLE;
  132329. private _boundBuffersVertexArray;
  132330. getHardwareScalingLevel(): number;
  132331. constructor();
  132332. dispose(): void;
  132333. /**
  132334. * Can be used to override the current requestAnimationFrame requester.
  132335. * @hidden
  132336. */
  132337. protected _queueNewFrame(bindedRenderFunction: any, requester?: any): number;
  132338. /**
  132339. * Override default engine behavior.
  132340. * @param color
  132341. * @param backBuffer
  132342. * @param depth
  132343. * @param stencil
  132344. */
  132345. _bindUnboundFramebuffer(framebuffer: Nullable<WebGLFramebuffer>): void;
  132346. /**
  132347. * Gets host document
  132348. * @returns the host document object
  132349. */
  132350. getHostDocument(): Nullable<Document>;
  132351. clear(color: Nullable<IColor4Like>, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  132352. createIndexBuffer(indices: IndicesArray, updateable?: boolean): NativeDataBuffer;
  132353. createVertexBuffer(data: DataArray, updateable?: boolean): NativeDataBuffer;
  132354. protected _recordVertexArrayObject(vertexArray: any, vertexBuffers: {
  132355. [key: string]: VertexBuffer;
  132356. }, indexBuffer: Nullable<NativeDataBuffer>, effect: Effect): void;
  132357. bindBuffers(vertexBuffers: {
  132358. [key: string]: VertexBuffer;
  132359. }, indexBuffer: Nullable<NativeDataBuffer>, effect: Effect): void;
  132360. recordVertexArrayObject(vertexBuffers: {
  132361. [key: string]: VertexBuffer;
  132362. }, indexBuffer: Nullable<NativeDataBuffer>, effect: Effect): WebGLVertexArrayObject;
  132363. bindVertexArrayObject(vertexArray: WebGLVertexArrayObject): void;
  132364. releaseVertexArrayObject(vertexArray: WebGLVertexArrayObject): void;
  132365. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  132366. /**
  132367. * Draw a list of indexed primitives
  132368. * @param fillMode defines the primitive to use
  132369. * @param indexStart defines the starting index
  132370. * @param indexCount defines the number of index to draw
  132371. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  132372. */
  132373. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  132374. /**
  132375. * Draw a list of unindexed primitives
  132376. * @param fillMode defines the primitive to use
  132377. * @param verticesStart defines the index of first vertex to draw
  132378. * @param verticesCount defines the count of vertices to draw
  132379. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  132380. */
  132381. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  132382. createPipelineContext(): IPipelineContext;
  132383. _preparePipelineContext(pipelineContext: IPipelineContext, vertexSourceCode: string, fragmentSourceCode: string, createAsRaw: boolean, rebuildRebind: any, defines: Nullable<string>, transformFeedbackVaryings: Nullable<string[]>): void;
  132384. /** @hidden */
  132385. _isRenderingStateCompiled(pipelineContext: IPipelineContext): boolean;
  132386. /** @hidden */
  132387. _executeWhenRenderingStateIsCompiled(pipelineContext: IPipelineContext, action: () => void): void;
  132388. createRawShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): any;
  132389. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): any;
  132390. protected _setProgram(program: WebGLProgram): void;
  132391. _releaseEffect(effect: Effect): void;
  132392. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  132393. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): WebGLUniformLocation[];
  132394. bindUniformBlock(pipelineContext: IPipelineContext, blockName: string, index: number): void;
  132395. bindSamplers(effect: Effect): void;
  132396. setMatrix(uniform: WebGLUniformLocation, matrix: Matrix): void;
  132397. getRenderWidth(useScreen?: boolean): number;
  132398. getRenderHeight(useScreen?: boolean): number;
  132399. setViewport(viewport: Viewport, requiredWidth?: number, requiredHeight?: number): void;
  132400. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  132401. /**
  132402. * Set the z offset to apply to current rendering
  132403. * @param value defines the offset to apply
  132404. */
  132405. setZOffset(value: number): void;
  132406. /**
  132407. * Gets the current value of the zOffset
  132408. * @returns the current zOffset state
  132409. */
  132410. getZOffset(): number;
  132411. /**
  132412. * Enable or disable depth buffering
  132413. * @param enable defines the state to set
  132414. */
  132415. setDepthBuffer(enable: boolean): void;
  132416. /**
  132417. * Gets a boolean indicating if depth writing is enabled
  132418. * @returns the current depth writing state
  132419. */
  132420. getDepthWrite(): boolean;
  132421. /**
  132422. * Enable or disable depth writing
  132423. * @param enable defines the state to set
  132424. */
  132425. setDepthWrite(enable: boolean): void;
  132426. /**
  132427. * Enable or disable color writing
  132428. * @param enable defines the state to set
  132429. */
  132430. setColorWrite(enable: boolean): void;
  132431. /**
  132432. * Gets a boolean indicating if color writing is enabled
  132433. * @returns the current color writing state
  132434. */
  132435. getColorWrite(): boolean;
  132436. /**
  132437. * Sets alpha constants used by some alpha blending modes
  132438. * @param r defines the red component
  132439. * @param g defines the green component
  132440. * @param b defines the blue component
  132441. * @param a defines the alpha component
  132442. */
  132443. setAlphaConstants(r: number, g: number, b: number, a: number): void;
  132444. /**
  132445. * Sets the current alpha mode
  132446. * @param mode defines the mode to use (one of the BABYLON.Constants.ALPHA_XXX)
  132447. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  132448. * @see https://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  132449. */
  132450. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  132451. /**
  132452. * Gets the current alpha mode
  132453. * @see https://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  132454. * @returns the current alpha mode
  132455. */
  132456. getAlphaMode(): number;
  132457. setInt(uniform: WebGLUniformLocation, int: number): void;
  132458. setIntArray(uniform: WebGLUniformLocation, array: Int32Array): void;
  132459. setIntArray2(uniform: WebGLUniformLocation, array: Int32Array): void;
  132460. setIntArray3(uniform: WebGLUniformLocation, array: Int32Array): void;
  132461. setIntArray4(uniform: WebGLUniformLocation, array: Int32Array): void;
  132462. setFloatArray(uniform: WebGLUniformLocation, array: Float32Array): void;
  132463. setFloatArray2(uniform: WebGLUniformLocation, array: Float32Array): void;
  132464. setFloatArray3(uniform: WebGLUniformLocation, array: Float32Array): void;
  132465. setFloatArray4(uniform: WebGLUniformLocation, array: Float32Array): void;
  132466. setArray(uniform: WebGLUniformLocation, array: number[]): void;
  132467. setArray2(uniform: WebGLUniformLocation, array: number[]): void;
  132468. setArray3(uniform: WebGLUniformLocation, array: number[]): void;
  132469. setArray4(uniform: WebGLUniformLocation, array: number[]): void;
  132470. setMatrices(uniform: WebGLUniformLocation, matrices: Float32Array): void;
  132471. setMatrix3x3(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  132472. setMatrix2x2(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  132473. setFloat(uniform: WebGLUniformLocation, value: number): void;
  132474. setFloat2(uniform: WebGLUniformLocation, x: number, y: number): void;
  132475. setFloat3(uniform: WebGLUniformLocation, x: number, y: number, z: number): void;
  132476. setFloat4(uniform: WebGLUniformLocation, x: number, y: number, z: number, w: number): void;
  132477. setColor3(uniform: WebGLUniformLocation, color3: Color3): void;
  132478. setColor4(uniform: WebGLUniformLocation, color3: Color3, alpha: number): void;
  132479. wipeCaches(bruteForce?: boolean): void;
  132480. _createTexture(): WebGLTexture;
  132481. protected _deleteTexture(texture: Nullable<WebGLTexture>): void;
  132482. /**
  132483. * Usually called from Texture.ts.
  132484. * Passed information to create a WebGLTexture
  132485. * @param url defines a value which contains one of the following:
  132486. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  132487. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  132488. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  132489. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  132490. * @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)
  132491. * @param scene needed for loading to the correct scene
  132492. * @param samplingMode mode with should be used sample / access the texture (Default: Texture.TRILINEAR_SAMPLINGMODE)
  132493. * @param onLoad optional callback to be called upon successful completion
  132494. * @param onError optional callback to be called upon failure
  132495. * @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
  132496. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  132497. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  132498. * @param forcedExtension defines the extension to use to pick the right loader
  132499. * @param mimeType defines an optional mime type
  132500. * @returns a InternalTexture for assignment back into BABYLON.Texture
  132501. */
  132502. 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;
  132503. /**
  132504. * Creates a cube texture
  132505. * @param rootUrl defines the url where the files to load is located
  132506. * @param scene defines the current scene
  132507. * @param files defines the list of files to load (1 per face)
  132508. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  132509. * @param onLoad defines an optional callback raised when the texture is loaded
  132510. * @param onError defines an optional callback raised if there is an issue to load the texture
  132511. * @param format defines the format of the data
  132512. * @param forcedExtension defines the extension to use to pick the right loader
  132513. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  132514. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  132515. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  132516. * @param fallback defines texture to use while falling back when (compressed) texture file not found.
  132517. * @returns the cube texture as an InternalTexture
  132518. */
  132519. 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;
  132520. private _getSamplingFilter;
  132521. private static _GetNativeTextureFormat;
  132522. createRenderTargetTexture(size: number | {
  132523. width: number;
  132524. height: number;
  132525. }, options: boolean | RenderTargetCreationOptions): NativeTexture;
  132526. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  132527. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean): void;
  132528. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  132529. createDynamicVertexBuffer(data: DataArray): DataBuffer;
  132530. updateDynamicIndexBuffer(indexBuffer: DataBuffer, indices: IndicesArray, offset?: number): void;
  132531. /**
  132532. * Updates a dynamic vertex buffer.
  132533. * @param vertexBuffer the vertex buffer to update
  132534. * @param data the data used to update the vertex buffer
  132535. * @param byteOffset the byte offset of the data (optional)
  132536. * @param byteLength the byte length of the data (optional)
  132537. */
  132538. updateDynamicVertexBuffer(vertexBuffer: DataBuffer, data: DataArray, byteOffset?: number, byteLength?: number): void;
  132539. protected _setTexture(channel: number, texture: Nullable<BaseTexture>, isPartOfTextureArray?: boolean, depthStencilTexture?: boolean): boolean;
  132540. private _updateAnisotropicLevel;
  132541. private _getAddressMode;
  132542. /** @hidden */
  132543. _bindTexture(channel: number, texture: InternalTexture): void;
  132544. protected _deleteBuffer(buffer: NativeDataBuffer): void;
  132545. releaseEffects(): void;
  132546. /** @hidden */
  132547. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  132548. /** @hidden */
  132549. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  132550. /** @hidden */
  132551. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  132552. /** @hidden */
  132553. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  132554. }
  132555. }
  132556. declare module BABYLON {
  132557. /**
  132558. * Gather the list of clipboard event types as constants.
  132559. */
  132560. export class ClipboardEventTypes {
  132561. /**
  132562. * The clipboard event is fired when a copy command is active (pressed).
  132563. */
  132564. static readonly COPY: number;
  132565. /**
  132566. * The clipboard event is fired when a cut command is active (pressed).
  132567. */
  132568. static readonly CUT: number;
  132569. /**
  132570. * The clipboard event is fired when a paste command is active (pressed).
  132571. */
  132572. static readonly PASTE: number;
  132573. }
  132574. /**
  132575. * This class is used to store clipboard related info for the onClipboardObservable event.
  132576. */
  132577. export class ClipboardInfo {
  132578. /**
  132579. * Defines the type of event (BABYLON.ClipboardEventTypes)
  132580. */
  132581. type: number;
  132582. /**
  132583. * Defines the related dom event
  132584. */
  132585. event: ClipboardEvent;
  132586. /**
  132587. *Creates an instance of ClipboardInfo.
  132588. * @param type Defines the type of event (BABYLON.ClipboardEventTypes)
  132589. * @param event Defines the related dom event
  132590. */
  132591. constructor(
  132592. /**
  132593. * Defines the type of event (BABYLON.ClipboardEventTypes)
  132594. */
  132595. type: number,
  132596. /**
  132597. * Defines the related dom event
  132598. */
  132599. event: ClipboardEvent);
  132600. /**
  132601. * Get the clipboard event's type from the keycode.
  132602. * @param keyCode Defines the keyCode for the current keyboard event.
  132603. * @return {number}
  132604. */
  132605. static GetTypeFromCharacter(keyCode: number): number;
  132606. }
  132607. }
  132608. declare module BABYLON {
  132609. /**
  132610. * Google Daydream controller
  132611. */
  132612. export class DaydreamController extends WebVRController {
  132613. /**
  132614. * Base Url for the controller model.
  132615. */
  132616. static MODEL_BASE_URL: string;
  132617. /**
  132618. * File name for the controller model.
  132619. */
  132620. static MODEL_FILENAME: string;
  132621. /**
  132622. * Gamepad Id prefix used to identify Daydream Controller.
  132623. */
  132624. static readonly GAMEPAD_ID_PREFIX: string;
  132625. /**
  132626. * Creates a new DaydreamController from a gamepad
  132627. * @param vrGamepad the gamepad that the controller should be created from
  132628. */
  132629. constructor(vrGamepad: any);
  132630. /**
  132631. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  132632. * @param scene scene in which to add meshes
  132633. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  132634. */
  132635. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  132636. /**
  132637. * Called once for each button that changed state since the last frame
  132638. * @param buttonIdx Which button index changed
  132639. * @param state New state of the button
  132640. * @param changes Which properties on the state changed since last frame
  132641. */
  132642. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  132643. }
  132644. }
  132645. declare module BABYLON {
  132646. /**
  132647. * Gear VR Controller
  132648. */
  132649. export class GearVRController extends WebVRController {
  132650. /**
  132651. * Base Url for the controller model.
  132652. */
  132653. static MODEL_BASE_URL: string;
  132654. /**
  132655. * File name for the controller model.
  132656. */
  132657. static MODEL_FILENAME: string;
  132658. /**
  132659. * Gamepad Id prefix used to identify this controller.
  132660. */
  132661. static readonly GAMEPAD_ID_PREFIX: string;
  132662. private readonly _buttonIndexToObservableNameMap;
  132663. /**
  132664. * Creates a new GearVRController from a gamepad
  132665. * @param vrGamepad the gamepad that the controller should be created from
  132666. */
  132667. constructor(vrGamepad: any);
  132668. /**
  132669. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  132670. * @param scene scene in which to add meshes
  132671. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  132672. */
  132673. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  132674. /**
  132675. * Called once for each button that changed state since the last frame
  132676. * @param buttonIdx Which button index changed
  132677. * @param state New state of the button
  132678. * @param changes Which properties on the state changed since last frame
  132679. */
  132680. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  132681. }
  132682. }
  132683. declare module BABYLON {
  132684. /**
  132685. * Generic Controller
  132686. */
  132687. export class GenericController extends WebVRController {
  132688. /**
  132689. * Base Url for the controller model.
  132690. */
  132691. static readonly MODEL_BASE_URL: string;
  132692. /**
  132693. * File name for the controller model.
  132694. */
  132695. static readonly MODEL_FILENAME: string;
  132696. /**
  132697. * Creates a new GenericController from a gamepad
  132698. * @param vrGamepad the gamepad that the controller should be created from
  132699. */
  132700. constructor(vrGamepad: any);
  132701. /**
  132702. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  132703. * @param scene scene in which to add meshes
  132704. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  132705. */
  132706. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  132707. /**
  132708. * Called once for each button that changed state since the last frame
  132709. * @param buttonIdx Which button index changed
  132710. * @param state New state of the button
  132711. * @param changes Which properties on the state changed since last frame
  132712. */
  132713. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  132714. }
  132715. }
  132716. declare module BABYLON {
  132717. /**
  132718. * Oculus Touch Controller
  132719. */
  132720. export class OculusTouchController extends WebVRController {
  132721. /**
  132722. * Base Url for the controller model.
  132723. */
  132724. static MODEL_BASE_URL: string;
  132725. /**
  132726. * File name for the left controller model.
  132727. */
  132728. static MODEL_LEFT_FILENAME: string;
  132729. /**
  132730. * File name for the right controller model.
  132731. */
  132732. static MODEL_RIGHT_FILENAME: string;
  132733. /**
  132734. * Base Url for the Quest controller model.
  132735. */
  132736. static QUEST_MODEL_BASE_URL: string;
  132737. /**
  132738. * @hidden
  132739. * If the controllers are running on a device that needs the updated Quest controller models
  132740. */
  132741. static _IsQuest: boolean;
  132742. /**
  132743. * Fired when the secondary trigger on this controller is modified
  132744. */
  132745. onSecondaryTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  132746. /**
  132747. * Fired when the thumb rest on this controller is modified
  132748. */
  132749. onThumbRestChangedObservable: Observable<ExtendedGamepadButton>;
  132750. /**
  132751. * Creates a new OculusTouchController from a gamepad
  132752. * @param vrGamepad the gamepad that the controller should be created from
  132753. */
  132754. constructor(vrGamepad: any);
  132755. /**
  132756. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  132757. * @param scene scene in which to add meshes
  132758. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  132759. */
  132760. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  132761. /**
  132762. * Fired when the A button on this controller is modified
  132763. */
  132764. get onAButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  132765. /**
  132766. * Fired when the B button on this controller is modified
  132767. */
  132768. get onBButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  132769. /**
  132770. * Fired when the X button on this controller is modified
  132771. */
  132772. get onXButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  132773. /**
  132774. * Fired when the Y button on this controller is modified
  132775. */
  132776. get onYButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  132777. /**
  132778. * Called once for each button that changed state since the last frame
  132779. * 0) thumb stick (touch, press, value = pressed (0,1)). value is in this.leftStick
  132780. * 1) index trigger (touch (?), press (only when value > 0.1), value 0 to 1)
  132781. * 2) secondary trigger (same)
  132782. * 3) A (right) X (left), touch, pressed = value
  132783. * 4) B / Y
  132784. * 5) thumb rest
  132785. * @param buttonIdx Which button index changed
  132786. * @param state New state of the button
  132787. * @param changes Which properties on the state changed since last frame
  132788. */
  132789. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  132790. }
  132791. }
  132792. declare module BABYLON {
  132793. /**
  132794. * Vive Controller
  132795. */
  132796. export class ViveController extends WebVRController {
  132797. /**
  132798. * Base Url for the controller model.
  132799. */
  132800. static MODEL_BASE_URL: string;
  132801. /**
  132802. * File name for the controller model.
  132803. */
  132804. static MODEL_FILENAME: string;
  132805. /**
  132806. * Creates a new ViveController from a gamepad
  132807. * @param vrGamepad the gamepad that the controller should be created from
  132808. */
  132809. constructor(vrGamepad: any);
  132810. /**
  132811. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  132812. * @param scene scene in which to add meshes
  132813. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  132814. */
  132815. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  132816. /**
  132817. * Fired when the left button on this controller is modified
  132818. */
  132819. get onLeftButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  132820. /**
  132821. * Fired when the right button on this controller is modified
  132822. */
  132823. get onRightButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  132824. /**
  132825. * Fired when the menu button on this controller is modified
  132826. */
  132827. get onMenuButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  132828. /**
  132829. * Called once for each button that changed state since the last frame
  132830. * Vive mapping:
  132831. * 0: touchpad
  132832. * 1: trigger
  132833. * 2: left AND right buttons
  132834. * 3: menu button
  132835. * @param buttonIdx Which button index changed
  132836. * @param state New state of the button
  132837. * @param changes Which properties on the state changed since last frame
  132838. */
  132839. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  132840. }
  132841. }
  132842. declare module BABYLON {
  132843. /**
  132844. * Defines the WindowsMotionController object that the state of the windows motion controller
  132845. */
  132846. export class WindowsMotionController extends WebVRController {
  132847. /**
  132848. * The base url used to load the left and right controller models
  132849. */
  132850. static MODEL_BASE_URL: string;
  132851. /**
  132852. * The name of the left controller model file
  132853. */
  132854. static MODEL_LEFT_FILENAME: string;
  132855. /**
  132856. * The name of the right controller model file
  132857. */
  132858. static MODEL_RIGHT_FILENAME: string;
  132859. /**
  132860. * The controller name prefix for this controller type
  132861. */
  132862. static readonly GAMEPAD_ID_PREFIX: string;
  132863. /**
  132864. * The controller id pattern for this controller type
  132865. */
  132866. private static readonly GAMEPAD_ID_PATTERN;
  132867. private _loadedMeshInfo;
  132868. protected readonly _mapping: {
  132869. buttons: string[];
  132870. buttonMeshNames: {
  132871. trigger: string;
  132872. menu: string;
  132873. grip: string;
  132874. thumbstick: string;
  132875. trackpad: string;
  132876. };
  132877. buttonObservableNames: {
  132878. trigger: string;
  132879. menu: string;
  132880. grip: string;
  132881. thumbstick: string;
  132882. trackpad: string;
  132883. };
  132884. axisMeshNames: string[];
  132885. pointingPoseMeshName: string;
  132886. };
  132887. /**
  132888. * Fired when the trackpad on this controller is clicked
  132889. */
  132890. onTrackpadChangedObservable: Observable<ExtendedGamepadButton>;
  132891. /**
  132892. * Fired when the trackpad on this controller is modified
  132893. */
  132894. onTrackpadValuesChangedObservable: Observable<StickValues>;
  132895. /**
  132896. * The current x and y values of this controller's trackpad
  132897. */
  132898. trackpad: StickValues;
  132899. /**
  132900. * Creates a new WindowsMotionController from a gamepad
  132901. * @param vrGamepad the gamepad that the controller should be created from
  132902. */
  132903. constructor(vrGamepad: any);
  132904. /**
  132905. * Fired when the trigger on this controller is modified
  132906. */
  132907. get onTriggerButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  132908. /**
  132909. * Fired when the menu button on this controller is modified
  132910. */
  132911. get onMenuButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  132912. /**
  132913. * Fired when the grip button on this controller is modified
  132914. */
  132915. get onGripButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  132916. /**
  132917. * Fired when the thumbstick button on this controller is modified
  132918. */
  132919. get onThumbstickButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  132920. /**
  132921. * Fired when the touchpad button on this controller is modified
  132922. */
  132923. get onTouchpadButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  132924. /**
  132925. * Fired when the touchpad values on this controller are modified
  132926. */
  132927. get onTouchpadValuesChangedObservable(): Observable<StickValues>;
  132928. protected _updateTrackpad(): void;
  132929. /**
  132930. * Called once per frame by the engine.
  132931. */
  132932. update(): void;
  132933. /**
  132934. * Called once for each button that changed state since the last frame
  132935. * @param buttonIdx Which button index changed
  132936. * @param state New state of the button
  132937. * @param changes Which properties on the state changed since last frame
  132938. */
  132939. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  132940. /**
  132941. * Moves the buttons on the controller mesh based on their current state
  132942. * @param buttonName the name of the button to move
  132943. * @param buttonValue the value of the button which determines the buttons new position
  132944. */
  132945. protected _lerpButtonTransform(buttonName: string, buttonValue: number): void;
  132946. /**
  132947. * Moves the axis on the controller mesh based on its current state
  132948. * @param axis the index of the axis
  132949. * @param axisValue the value of the axis which determines the meshes new position
  132950. * @hidden
  132951. */
  132952. protected _lerpAxisTransform(axis: number, axisValue: number): void;
  132953. /**
  132954. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  132955. * @param scene scene in which to add meshes
  132956. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  132957. */
  132958. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void, forceDefault?: boolean): void;
  132959. /**
  132960. * Takes a list of meshes (as loaded from the glTF file) and finds the root node, as well as nodes that
  132961. * can be transformed by button presses and axes values, based on this._mapping.
  132962. *
  132963. * @param scene scene in which the meshes exist
  132964. * @param meshes list of meshes that make up the controller model to process
  132965. * @return structured view of the given meshes, with mapping of buttons and axes to meshes that can be transformed.
  132966. */
  132967. private processModel;
  132968. private createMeshInfo;
  132969. /**
  132970. * Gets the ray of the controller in the direction the controller is pointing
  132971. * @param length the length the resulting ray should be
  132972. * @returns a ray in the direction the controller is pointing
  132973. */
  132974. getForwardRay(length?: number): Ray;
  132975. /**
  132976. * Disposes of the controller
  132977. */
  132978. dispose(): void;
  132979. }
  132980. /**
  132981. * This class represents a new windows motion controller in XR.
  132982. */
  132983. export class XRWindowsMotionController extends WindowsMotionController {
  132984. /**
  132985. * Changing the original WIndowsMotionController mapping to fir the new mapping
  132986. */
  132987. protected readonly _mapping: {
  132988. buttons: string[];
  132989. buttonMeshNames: {
  132990. trigger: string;
  132991. menu: string;
  132992. grip: string;
  132993. thumbstick: string;
  132994. trackpad: string;
  132995. };
  132996. buttonObservableNames: {
  132997. trigger: string;
  132998. menu: string;
  132999. grip: string;
  133000. thumbstick: string;
  133001. trackpad: string;
  133002. };
  133003. axisMeshNames: string[];
  133004. pointingPoseMeshName: string;
  133005. };
  133006. /**
  133007. * Construct a new XR-Based windows motion controller
  133008. *
  133009. * @param gamepadInfo the gamepad object from the browser
  133010. */
  133011. constructor(gamepadInfo: any);
  133012. /**
  133013. * holds the thumbstick values (X,Y)
  133014. */
  133015. thumbstickValues: StickValues;
  133016. /**
  133017. * Fired when the thumbstick on this controller is clicked
  133018. */
  133019. onThumbstickStateChangedObservable: Observable<ExtendedGamepadButton>;
  133020. /**
  133021. * Fired when the thumbstick on this controller is modified
  133022. */
  133023. onThumbstickValuesChangedObservable: Observable<StickValues>;
  133024. /**
  133025. * Fired when the touchpad button on this controller is modified
  133026. */
  133027. onTrackpadChangedObservable: Observable<ExtendedGamepadButton>;
  133028. /**
  133029. * Fired when the touchpad values on this controller are modified
  133030. */
  133031. onTrackpadValuesChangedObservable: Observable<StickValues>;
  133032. /**
  133033. * Fired when the thumbstick button on this controller is modified
  133034. * here to prevent breaking changes
  133035. */
  133036. get onThumbstickButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  133037. /**
  133038. * updating the thumbstick(!) and not the trackpad.
  133039. * This is named this way due to the difference between WebVR and XR and to avoid
  133040. * changing the parent class.
  133041. */
  133042. protected _updateTrackpad(): void;
  133043. /**
  133044. * Disposes the class with joy
  133045. */
  133046. dispose(): void;
  133047. }
  133048. }
  133049. declare module BABYLON {
  133050. /**
  133051. * Class containing static functions to help procedurally build meshes
  133052. */
  133053. export class PolyhedronBuilder {
  133054. /**
  133055. * Creates a polyhedron mesh
  133056. * * 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
  133057. * * The parameter `size` (positive float, default 1) sets the polygon size
  133058. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  133059. * * 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`
  133060. * * 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
  133061. * * 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)`)
  133062. * * 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
  133063. * * 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
  133064. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  133065. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  133066. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  133067. * @param name defines the name of the mesh
  133068. * @param options defines the options used to create the mesh
  133069. * @param scene defines the hosting scene
  133070. * @returns the polyhedron mesh
  133071. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes
  133072. */
  133073. static CreatePolyhedron(name: string, options: {
  133074. type?: number;
  133075. size?: number;
  133076. sizeX?: number;
  133077. sizeY?: number;
  133078. sizeZ?: number;
  133079. custom?: any;
  133080. faceUV?: Vector4[];
  133081. faceColors?: Color4[];
  133082. flat?: boolean;
  133083. updatable?: boolean;
  133084. sideOrientation?: number;
  133085. frontUVs?: Vector4;
  133086. backUVs?: Vector4;
  133087. }, scene?: Nullable<Scene>): Mesh;
  133088. }
  133089. }
  133090. declare module BABYLON {
  133091. /**
  133092. * Gizmo that enables scaling a mesh along 3 axis
  133093. */
  133094. export class ScaleGizmo extends Gizmo {
  133095. /**
  133096. * Internal gizmo used for interactions on the x axis
  133097. */
  133098. xGizmo: AxisScaleGizmo;
  133099. /**
  133100. * Internal gizmo used for interactions on the y axis
  133101. */
  133102. yGizmo: AxisScaleGizmo;
  133103. /**
  133104. * Internal gizmo used for interactions on the z axis
  133105. */
  133106. zGizmo: AxisScaleGizmo;
  133107. /**
  133108. * Internal gizmo used to scale all axis equally
  133109. */
  133110. uniformScaleGizmo: AxisScaleGizmo;
  133111. private _meshAttached;
  133112. private _nodeAttached;
  133113. private _snapDistance;
  133114. private _uniformScalingMesh;
  133115. private _octahedron;
  133116. private _sensitivity;
  133117. /** Fires an event when any of it's sub gizmos are dragged */
  133118. onDragStartObservable: Observable<unknown>;
  133119. /** Fires an event when any of it's sub gizmos are released from dragging */
  133120. onDragEndObservable: Observable<unknown>;
  133121. get attachedMesh(): Nullable<AbstractMesh>;
  133122. set attachedMesh(mesh: Nullable<AbstractMesh>);
  133123. get attachedNode(): Nullable<Node>;
  133124. set attachedNode(node: Nullable<Node>);
  133125. /**
  133126. * Creates a ScaleGizmo
  133127. * @param gizmoLayer The utility layer the gizmo will be added to
  133128. * @param thickness display gizmo axis thickness
  133129. */
  133130. constructor(gizmoLayer?: UtilityLayerRenderer, thickness?: number);
  133131. set updateGizmoRotationToMatchAttachedMesh(value: boolean);
  133132. get updateGizmoRotationToMatchAttachedMesh(): boolean;
  133133. /**
  133134. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  133135. */
  133136. set snapDistance(value: number);
  133137. get snapDistance(): number;
  133138. /**
  133139. * Ratio for the scale of the gizmo (Default: 1)
  133140. */
  133141. set scaleRatio(value: number);
  133142. get scaleRatio(): number;
  133143. /**
  133144. * Sensitivity factor for dragging (Default: 1)
  133145. */
  133146. set sensitivity(value: number);
  133147. get sensitivity(): number;
  133148. /**
  133149. * Disposes of the gizmo
  133150. */
  133151. dispose(): void;
  133152. }
  133153. }
  133154. declare module BABYLON {
  133155. /**
  133156. * Single axis scale gizmo
  133157. */
  133158. export class AxisScaleGizmo extends Gizmo {
  133159. /**
  133160. * Drag behavior responsible for the gizmos dragging interactions
  133161. */
  133162. dragBehavior: PointerDragBehavior;
  133163. private _pointerObserver;
  133164. /**
  133165. * Scale distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  133166. */
  133167. snapDistance: number;
  133168. /**
  133169. * Event that fires each time the gizmo snaps to a new location.
  133170. * * snapDistance is the the change in distance
  133171. */
  133172. onSnapObservable: Observable<{
  133173. snapDistance: number;
  133174. }>;
  133175. /**
  133176. * If the scaling operation should be done on all axis (default: false)
  133177. */
  133178. uniformScaling: boolean;
  133179. /**
  133180. * Custom sensitivity value for the drag strength
  133181. */
  133182. sensitivity: number;
  133183. private _isEnabled;
  133184. private _parent;
  133185. private _arrow;
  133186. private _coloredMaterial;
  133187. private _hoverMaterial;
  133188. /**
  133189. * Creates an AxisScaleGizmo
  133190. * @param gizmoLayer The utility layer the gizmo will be added to
  133191. * @param dragAxis The axis which the gizmo will be able to scale on
  133192. * @param color The color of the gizmo
  133193. * @param thickness display gizmo axis thickness
  133194. */
  133195. constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<ScaleGizmo>, thickness?: number);
  133196. protected _attachedNodeChanged(value: Nullable<Node>): void;
  133197. /**
  133198. * If the gizmo is enabled
  133199. */
  133200. set isEnabled(value: boolean);
  133201. get isEnabled(): boolean;
  133202. /**
  133203. * Disposes of the gizmo
  133204. */
  133205. dispose(): void;
  133206. /**
  133207. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  133208. * @param mesh The mesh to replace the default mesh of the gizmo
  133209. * @param useGizmoMaterial If the gizmo's default material should be used (default: false)
  133210. */
  133211. setCustomMesh(mesh: Mesh, useGizmoMaterial?: boolean): void;
  133212. }
  133213. }
  133214. declare module BABYLON {
  133215. /**
  133216. * Bounding box gizmo
  133217. */
  133218. export class BoundingBoxGizmo extends Gizmo {
  133219. private _lineBoundingBox;
  133220. private _rotateSpheresParent;
  133221. private _scaleBoxesParent;
  133222. private _boundingDimensions;
  133223. private _renderObserver;
  133224. private _pointerObserver;
  133225. private _scaleDragSpeed;
  133226. private _tmpQuaternion;
  133227. private _tmpVector;
  133228. private _tmpRotationMatrix;
  133229. /**
  133230. * 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)
  133231. */
  133232. ignoreChildren: boolean;
  133233. /**
  133234. * 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)
  133235. */
  133236. includeChildPredicate: Nullable<(abstractMesh: AbstractMesh) => boolean>;
  133237. /**
  133238. * The size of the rotation spheres attached to the bounding box (Default: 0.1)
  133239. */
  133240. rotationSphereSize: number;
  133241. /**
  133242. * The size of the scale boxes attached to the bounding box (Default: 0.1)
  133243. */
  133244. scaleBoxSize: number;
  133245. /**
  133246. * 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)
  133247. */
  133248. fixedDragMeshScreenSize: boolean;
  133249. /**
  133250. * The distance away from the object which the draggable meshes should appear world sized when fixedDragMeshScreenSize is set to true (default: 10)
  133251. */
  133252. fixedDragMeshScreenSizeDistanceFactor: number;
  133253. /**
  133254. * Fired when a rotation sphere or scale box is dragged
  133255. */
  133256. onDragStartObservable: Observable<{}>;
  133257. /**
  133258. * Fired when a scale box is dragged
  133259. */
  133260. onScaleBoxDragObservable: Observable<{}>;
  133261. /**
  133262. * Fired when a scale box drag is ended
  133263. */
  133264. onScaleBoxDragEndObservable: Observable<{}>;
  133265. /**
  133266. * Fired when a rotation sphere is dragged
  133267. */
  133268. onRotationSphereDragObservable: Observable<{}>;
  133269. /**
  133270. * Fired when a rotation sphere drag is ended
  133271. */
  133272. onRotationSphereDragEndObservable: Observable<{}>;
  133273. /**
  133274. * 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)
  133275. */
  133276. scalePivot: Nullable<Vector3>;
  133277. /**
  133278. * Mesh used as a pivot to rotate the attached node
  133279. */
  133280. private _anchorMesh;
  133281. private _existingMeshScale;
  133282. private _dragMesh;
  133283. private pointerDragBehavior;
  133284. private coloredMaterial;
  133285. private hoverColoredMaterial;
  133286. /**
  133287. * Sets the color of the bounding box gizmo
  133288. * @param color the color to set
  133289. */
  133290. setColor(color: Color3): void;
  133291. /**
  133292. * Creates an BoundingBoxGizmo
  133293. * @param gizmoLayer The utility layer the gizmo will be added to
  133294. * @param color The color of the gizmo
  133295. */
  133296. constructor(color?: Color3, gizmoLayer?: UtilityLayerRenderer);
  133297. protected _attachedNodeChanged(value: Nullable<AbstractMesh>): void;
  133298. private _selectNode;
  133299. /**
  133300. * Updates the bounding box information for the Gizmo
  133301. */
  133302. updateBoundingBox(): void;
  133303. private _updateRotationSpheres;
  133304. private _updateScaleBoxes;
  133305. /**
  133306. * Enables rotation on the specified axis and disables rotation on the others
  133307. * @param axis The list of axis that should be enabled (eg. "xy" or "xyz")
  133308. */
  133309. setEnabledRotationAxis(axis: string): void;
  133310. /**
  133311. * Enables/disables scaling
  133312. * @param enable if scaling should be enabled
  133313. * @param homogeneousScaling defines if scaling should only be homogeneous
  133314. */
  133315. setEnabledScaling(enable: boolean, homogeneousScaling?: boolean): void;
  133316. private _updateDummy;
  133317. /**
  133318. * Enables a pointer drag behavior on the bounding box of the gizmo
  133319. */
  133320. enableDragBehavior(): void;
  133321. /**
  133322. * Disposes of the gizmo
  133323. */
  133324. dispose(): void;
  133325. /**
  133326. * 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)
  133327. * @param mesh the mesh to wrap in the bounding box mesh and make not pickable
  133328. * @returns the bounding box mesh with the passed in mesh as a child
  133329. */
  133330. static MakeNotPickableAndWrapInBoundingBox(mesh: Mesh): Mesh;
  133331. /**
  133332. * CustomMeshes are not supported by this gizmo
  133333. * @param mesh The mesh to replace the default mesh of the gizmo
  133334. */
  133335. setCustomMesh(mesh: Mesh): void;
  133336. }
  133337. }
  133338. declare module BABYLON {
  133339. /**
  133340. * Single plane rotation gizmo
  133341. */
  133342. export class PlaneRotationGizmo extends Gizmo {
  133343. /**
  133344. * Drag behavior responsible for the gizmos dragging interactions
  133345. */
  133346. dragBehavior: PointerDragBehavior;
  133347. private _pointerObserver;
  133348. /**
  133349. * Rotation distance in radians that the gizmo will snap to (Default: 0)
  133350. */
  133351. snapDistance: number;
  133352. /**
  133353. * Event that fires each time the gizmo snaps to a new location.
  133354. * * snapDistance is the the change in distance
  133355. */
  133356. onSnapObservable: Observable<{
  133357. snapDistance: number;
  133358. }>;
  133359. private _isEnabled;
  133360. private _parent;
  133361. /**
  133362. * Creates a PlaneRotationGizmo
  133363. * @param gizmoLayer The utility layer the gizmo will be added to
  133364. * @param planeNormal The normal of the plane which the gizmo will be able to rotate on
  133365. * @param color The color of the gizmo
  133366. * @param tessellation Amount of tessellation to be used when creating rotation circles
  133367. * @param useEulerRotation Use and update Euler angle instead of quaternion
  133368. * @param thickness display gizmo axis thickness
  133369. */
  133370. constructor(planeNormal: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, tessellation?: number, parent?: Nullable<RotationGizmo>, useEulerRotation?: boolean, 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. }
  133383. declare module BABYLON {
  133384. /**
  133385. * Gizmo that enables rotating a mesh along 3 axis
  133386. */
  133387. export class RotationGizmo extends Gizmo {
  133388. /**
  133389. * Internal gizmo used for interactions on the x axis
  133390. */
  133391. xGizmo: PlaneRotationGizmo;
  133392. /**
  133393. * Internal gizmo used for interactions on the y axis
  133394. */
  133395. yGizmo: PlaneRotationGizmo;
  133396. /**
  133397. * Internal gizmo used for interactions on the z axis
  133398. */
  133399. zGizmo: PlaneRotationGizmo;
  133400. /** Fires an event when any of it's sub gizmos are dragged */
  133401. onDragStartObservable: Observable<unknown>;
  133402. /** Fires an event when any of it's sub gizmos are released from dragging */
  133403. onDragEndObservable: Observable<unknown>;
  133404. private _meshAttached;
  133405. private _nodeAttached;
  133406. get attachedMesh(): Nullable<AbstractMesh>;
  133407. set attachedMesh(mesh: Nullable<AbstractMesh>);
  133408. get attachedNode(): Nullable<Node>;
  133409. set attachedNode(node: Nullable<Node>);
  133410. /**
  133411. * Creates a RotationGizmo
  133412. * @param gizmoLayer The utility layer the gizmo will be added to
  133413. * @param tessellation Amount of tessellation to be used when creating rotation circles
  133414. * @param useEulerRotation Use and update Euler angle instead of quaternion
  133415. * @param thickness display gizmo axis thickness
  133416. */
  133417. constructor(gizmoLayer?: UtilityLayerRenderer, tessellation?: number, useEulerRotation?: boolean, thickness?: number);
  133418. set updateGizmoRotationToMatchAttachedMesh(value: boolean);
  133419. get updateGizmoRotationToMatchAttachedMesh(): boolean;
  133420. /**
  133421. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  133422. */
  133423. set snapDistance(value: number);
  133424. get snapDistance(): number;
  133425. /**
  133426. * Ratio for the scale of the gizmo (Default: 1)
  133427. */
  133428. set scaleRatio(value: number);
  133429. get scaleRatio(): number;
  133430. /**
  133431. * Disposes of the gizmo
  133432. */
  133433. dispose(): void;
  133434. /**
  133435. * CustomMeshes are not supported by this gizmo
  133436. * @param mesh The mesh to replace the default mesh of the gizmo
  133437. */
  133438. setCustomMesh(mesh: Mesh): void;
  133439. }
  133440. }
  133441. declare module BABYLON {
  133442. /**
  133443. * Helps setup gizmo's in the scene to rotate/scale/position nodes
  133444. */
  133445. export class GizmoManager implements IDisposable {
  133446. private scene;
  133447. /**
  133448. * Gizmo's created by the gizmo manager, gizmo will be null until gizmo has been enabled for the first time
  133449. */
  133450. gizmos: {
  133451. positionGizmo: Nullable<PositionGizmo>;
  133452. rotationGizmo: Nullable<RotationGizmo>;
  133453. scaleGizmo: Nullable<ScaleGizmo>;
  133454. boundingBoxGizmo: Nullable<BoundingBoxGizmo>;
  133455. };
  133456. /** When true, the gizmo will be detached from the current object when a pointer down occurs with an empty picked mesh */
  133457. clearGizmoOnEmptyPointerEvent: boolean;
  133458. /** Fires an event when the manager is attached to a mesh */
  133459. onAttachedToMeshObservable: Observable<Nullable<AbstractMesh>>;
  133460. /** Fires an event when the manager is attached to a node */
  133461. onAttachedToNodeObservable: Observable<Nullable<Node>>;
  133462. private _gizmosEnabled;
  133463. private _pointerObserver;
  133464. private _attachedMesh;
  133465. private _attachedNode;
  133466. private _boundingBoxColor;
  133467. private _defaultUtilityLayer;
  133468. private _defaultKeepDepthUtilityLayer;
  133469. private _thickness;
  133470. /**
  133471. * When bounding box gizmo is enabled, this can be used to track drag/end events
  133472. */
  133473. boundingBoxDragBehavior: SixDofDragBehavior;
  133474. /**
  133475. * Array of meshes which will have the gizmo attached when a pointer selected them. If null, all meshes are attachable. (Default: null)
  133476. */
  133477. attachableMeshes: Nullable<Array<AbstractMesh>>;
  133478. /**
  133479. * Array of nodes which will have the gizmo attached when a pointer selected them. If null, all nodes are attachable. (Default: null)
  133480. */
  133481. attachableNodes: Nullable<Array<Node>>;
  133482. /**
  133483. * If pointer events should perform attaching/detaching a gizmo, if false this can be done manually via attachToMesh/attachToNode. (Default: true)
  133484. */
  133485. usePointerToAttachGizmos: boolean;
  133486. /**
  133487. * Utility layer that the bounding box gizmo belongs to
  133488. */
  133489. get keepDepthUtilityLayer(): UtilityLayerRenderer;
  133490. /**
  133491. * Utility layer that all gizmos besides bounding box belong to
  133492. */
  133493. get utilityLayer(): UtilityLayerRenderer;
  133494. /**
  133495. * Instatiates a gizmo manager
  133496. * @param scene the scene to overlay the gizmos on top of
  133497. * @param thickness display gizmo axis thickness
  133498. */
  133499. constructor(scene: Scene, thickness?: number);
  133500. /**
  133501. * Attaches a set of gizmos to the specified mesh
  133502. * @param mesh The mesh the gizmo's should be attached to
  133503. */
  133504. attachToMesh(mesh: Nullable<AbstractMesh>): void;
  133505. /**
  133506. * Attaches a set of gizmos to the specified node
  133507. * @param node The node the gizmo's should be attached to
  133508. */
  133509. attachToNode(node: Nullable<Node>): void;
  133510. /**
  133511. * If the position gizmo is enabled
  133512. */
  133513. set positionGizmoEnabled(value: boolean);
  133514. get positionGizmoEnabled(): boolean;
  133515. /**
  133516. * If the rotation gizmo is enabled
  133517. */
  133518. set rotationGizmoEnabled(value: boolean);
  133519. get rotationGizmoEnabled(): boolean;
  133520. /**
  133521. * If the scale gizmo is enabled
  133522. */
  133523. set scaleGizmoEnabled(value: boolean);
  133524. get scaleGizmoEnabled(): boolean;
  133525. /**
  133526. * If the boundingBox gizmo is enabled
  133527. */
  133528. set boundingBoxGizmoEnabled(value: boolean);
  133529. get boundingBoxGizmoEnabled(): boolean;
  133530. /**
  133531. * Disposes of the gizmo manager
  133532. */
  133533. dispose(): void;
  133534. }
  133535. }
  133536. declare module BABYLON {
  133537. /**
  133538. * A directional light is defined by a direction (what a surprise!).
  133539. * The light is emitted from everywhere in the specified direction, and has an infinite range.
  133540. * 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.
  133541. * Documentation: https://doc.babylonjs.com/babylon101/lights
  133542. */
  133543. export class DirectionalLight extends ShadowLight {
  133544. private _shadowFrustumSize;
  133545. /**
  133546. * Fix frustum size for the shadow generation. This is disabled if the value is 0.
  133547. */
  133548. get shadowFrustumSize(): number;
  133549. /**
  133550. * Specifies a fix frustum size for the shadow generation.
  133551. */
  133552. set shadowFrustumSize(value: number);
  133553. private _shadowOrthoScale;
  133554. /**
  133555. * Gets the shadow projection scale against the optimal computed one.
  133556. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  133557. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  133558. */
  133559. get shadowOrthoScale(): number;
  133560. /**
  133561. * Sets the shadow projection scale against the optimal computed one.
  133562. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  133563. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  133564. */
  133565. set shadowOrthoScale(value: number);
  133566. /**
  133567. * Automatically compute the projection matrix to best fit (including all the casters)
  133568. * on each frame.
  133569. */
  133570. autoUpdateExtends: boolean;
  133571. /**
  133572. * Automatically compute the shadowMinZ and shadowMaxZ for the projection matrix to best fit (including all the casters)
  133573. * on each frame. autoUpdateExtends must be set to true for this to work
  133574. */
  133575. autoCalcShadowZBounds: boolean;
  133576. private _orthoLeft;
  133577. private _orthoRight;
  133578. private _orthoTop;
  133579. private _orthoBottom;
  133580. /**
  133581. * Creates a DirectionalLight object in the scene, oriented towards the passed direction (Vector3).
  133582. * The directional light is emitted from everywhere in the given direction.
  133583. * It can cast shadows.
  133584. * Documentation : https://doc.babylonjs.com/babylon101/lights
  133585. * @param name The friendly name of the light
  133586. * @param direction The direction of the light
  133587. * @param scene The scene the light belongs to
  133588. */
  133589. constructor(name: string, direction: Vector3, scene: Scene);
  133590. /**
  133591. * Returns the string "DirectionalLight".
  133592. * @return The class name
  133593. */
  133594. getClassName(): string;
  133595. /**
  133596. * Returns the integer 1.
  133597. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  133598. */
  133599. getTypeID(): number;
  133600. /**
  133601. * Sets the passed matrix "matrix" as projection matrix for the shadows cast by the light according to the passed view matrix.
  133602. * Returns the DirectionalLight Shadow projection matrix.
  133603. */
  133604. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  133605. /**
  133606. * Sets the passed matrix "matrix" as fixed frustum projection matrix for the shadows cast by the light according to the passed view matrix.
  133607. * Returns the DirectionalLight Shadow projection matrix.
  133608. */
  133609. protected _setDefaultFixedFrustumShadowProjectionMatrix(matrix: Matrix): void;
  133610. /**
  133611. * Sets the passed matrix "matrix" as auto extend projection matrix for the shadows cast by the light according to the passed view matrix.
  133612. * Returns the DirectionalLight Shadow projection matrix.
  133613. */
  133614. protected _setDefaultAutoExtendShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  133615. protected _buildUniformLayout(): void;
  133616. /**
  133617. * Sets the passed Effect object with the DirectionalLight transformed position (or position if not parented) and the passed name.
  133618. * @param effect The effect to update
  133619. * @param lightIndex The index of the light in the effect to update
  133620. * @returns The directional light
  133621. */
  133622. transferToEffect(effect: Effect, lightIndex: string): DirectionalLight;
  133623. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): Light;
  133624. /**
  133625. * Gets the minZ used for shadow according to both the scene and the light.
  133626. *
  133627. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  133628. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  133629. * @param activeCamera The camera we are returning the min for
  133630. * @returns the depth min z
  133631. */
  133632. getDepthMinZ(activeCamera: Camera): number;
  133633. /**
  133634. * Gets the maxZ used for shadow according to both the scene and the light.
  133635. *
  133636. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  133637. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  133638. * @param activeCamera The camera we are returning the max for
  133639. * @returns the depth max z
  133640. */
  133641. getDepthMaxZ(activeCamera: Camera): number;
  133642. /**
  133643. * Prepares the list of defines specific to the light type.
  133644. * @param defines the list of defines
  133645. * @param lightIndex defines the index of the light for the effect
  133646. */
  133647. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  133648. }
  133649. }
  133650. declare module BABYLON {
  133651. /**
  133652. * Class containing static functions to help procedurally build meshes
  133653. */
  133654. export class HemisphereBuilder {
  133655. /**
  133656. * Creates a hemisphere mesh
  133657. * @param name defines the name of the mesh
  133658. * @param options defines the options used to create the mesh
  133659. * @param scene defines the hosting scene
  133660. * @returns the hemisphere mesh
  133661. */
  133662. static CreateHemisphere(name: string, options: {
  133663. segments?: number;
  133664. diameter?: number;
  133665. sideOrientation?: number;
  133666. }, scene: any): Mesh;
  133667. }
  133668. }
  133669. declare module BABYLON {
  133670. /**
  133671. * A spot light is defined by a position, a direction, an angle, and an exponent.
  133672. * These values define a cone of light starting from the position, emitting toward the direction.
  133673. * The angle, in radians, defines the size (field of illumination) of the spotlight's conical beam,
  133674. * and the exponent defines the speed of the decay of the light with distance (reach).
  133675. * Documentation: https://doc.babylonjs.com/babylon101/lights
  133676. */
  133677. export class SpotLight extends ShadowLight {
  133678. private _angle;
  133679. private _innerAngle;
  133680. private _cosHalfAngle;
  133681. private _lightAngleScale;
  133682. private _lightAngleOffset;
  133683. /**
  133684. * Gets the cone angle of the spot light in Radians.
  133685. */
  133686. get angle(): number;
  133687. /**
  133688. * Sets the cone angle of the spot light in Radians.
  133689. */
  133690. set angle(value: number);
  133691. /**
  133692. * Only used in gltf falloff mode, this defines the angle where
  133693. * the directional falloff will start before cutting at angle which could be seen
  133694. * as outer angle.
  133695. */
  133696. get innerAngle(): number;
  133697. /**
  133698. * Only used in gltf falloff mode, this defines the angle where
  133699. * the directional falloff will start before cutting at angle which could be seen
  133700. * as outer angle.
  133701. */
  133702. set innerAngle(value: number);
  133703. private _shadowAngleScale;
  133704. /**
  133705. * Allows scaling the angle of the light for shadow generation only.
  133706. */
  133707. get shadowAngleScale(): number;
  133708. /**
  133709. * Allows scaling the angle of the light for shadow generation only.
  133710. */
  133711. set shadowAngleScale(value: number);
  133712. /**
  133713. * The light decay speed with the distance from the emission spot.
  133714. */
  133715. exponent: number;
  133716. private _projectionTextureMatrix;
  133717. /**
  133718. * Allows reading the projecton texture
  133719. */
  133720. get projectionTextureMatrix(): Matrix;
  133721. protected _projectionTextureLightNear: number;
  133722. /**
  133723. * Gets the near clip of the Spotlight for texture projection.
  133724. */
  133725. get projectionTextureLightNear(): number;
  133726. /**
  133727. * Sets the near clip of the Spotlight for texture projection.
  133728. */
  133729. set projectionTextureLightNear(value: number);
  133730. protected _projectionTextureLightFar: number;
  133731. /**
  133732. * Gets the far clip of the Spotlight for texture projection.
  133733. */
  133734. get projectionTextureLightFar(): number;
  133735. /**
  133736. * Sets the far clip of the Spotlight for texture projection.
  133737. */
  133738. set projectionTextureLightFar(value: number);
  133739. protected _projectionTextureUpDirection: Vector3;
  133740. /**
  133741. * Gets the Up vector of the Spotlight for texture projection.
  133742. */
  133743. get projectionTextureUpDirection(): Vector3;
  133744. /**
  133745. * Sets the Up vector of the Spotlight for texture projection.
  133746. */
  133747. set projectionTextureUpDirection(value: Vector3);
  133748. private _projectionTexture;
  133749. /**
  133750. * Gets the projection texture of the light.
  133751. */
  133752. get projectionTexture(): Nullable<BaseTexture>;
  133753. /**
  133754. * Sets the projection texture of the light.
  133755. */
  133756. set projectionTexture(value: Nullable<BaseTexture>);
  133757. private _projectionTextureViewLightDirty;
  133758. private _projectionTextureProjectionLightDirty;
  133759. private _projectionTextureDirty;
  133760. private _projectionTextureViewTargetVector;
  133761. private _projectionTextureViewLightMatrix;
  133762. private _projectionTextureProjectionLightMatrix;
  133763. private _projectionTextureScalingMatrix;
  133764. /**
  133765. * Creates a SpotLight object in the scene. A spot light is a simply light oriented cone.
  133766. * It can cast shadows.
  133767. * Documentation : https://doc.babylonjs.com/babylon101/lights
  133768. * @param name The light friendly name
  133769. * @param position The position of the spot light in the scene
  133770. * @param direction The direction of the light in the scene
  133771. * @param angle The cone angle of the light in Radians
  133772. * @param exponent The light decay speed with the distance from the emission spot
  133773. * @param scene The scene the lights belongs to
  133774. */
  133775. constructor(name: string, position: Vector3, direction: Vector3, angle: number, exponent: number, scene: Scene);
  133776. /**
  133777. * Returns the string "SpotLight".
  133778. * @returns the class name
  133779. */
  133780. getClassName(): string;
  133781. /**
  133782. * Returns the integer 2.
  133783. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  133784. */
  133785. getTypeID(): number;
  133786. /**
  133787. * Overrides the direction setter to recompute the projection texture view light Matrix.
  133788. */
  133789. protected _setDirection(value: Vector3): void;
  133790. /**
  133791. * Overrides the position setter to recompute the projection texture view light Matrix.
  133792. */
  133793. protected _setPosition(value: Vector3): void;
  133794. /**
  133795. * 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.
  133796. * Returns the SpotLight.
  133797. */
  133798. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  133799. protected _computeProjectionTextureViewLightMatrix(): void;
  133800. protected _computeProjectionTextureProjectionLightMatrix(): void;
  133801. /**
  133802. * Main function for light texture projection matrix computing.
  133803. */
  133804. protected _computeProjectionTextureMatrix(): void;
  133805. protected _buildUniformLayout(): void;
  133806. private _computeAngleValues;
  133807. /**
  133808. * Sets the passed Effect "effect" with the Light textures.
  133809. * @param effect The effect to update
  133810. * @param lightIndex The index of the light in the effect to update
  133811. * @returns The light
  133812. */
  133813. transferTexturesToEffect(effect: Effect, lightIndex: string): Light;
  133814. /**
  133815. * Sets the passed Effect object with the SpotLight transfomed position (or position if not parented) and normalized direction.
  133816. * @param effect The effect to update
  133817. * @param lightIndex The index of the light in the effect to update
  133818. * @returns The spot light
  133819. */
  133820. transferToEffect(effect: Effect, lightIndex: string): SpotLight;
  133821. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): this;
  133822. /**
  133823. * Disposes the light and the associated resources.
  133824. */
  133825. dispose(): void;
  133826. /**
  133827. * Prepares the list of defines specific to the light type.
  133828. * @param defines the list of defines
  133829. * @param lightIndex defines the index of the light for the effect
  133830. */
  133831. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  133832. }
  133833. }
  133834. declare module BABYLON {
  133835. /**
  133836. * Gizmo that enables viewing a light
  133837. */
  133838. export class LightGizmo extends Gizmo {
  133839. private _lightMesh;
  133840. private _material;
  133841. private _cachedPosition;
  133842. private _cachedForward;
  133843. private _attachedMeshParent;
  133844. private _pointerObserver;
  133845. /**
  133846. * Event that fires each time the gizmo is clicked
  133847. */
  133848. onClickedObservable: Observable<Light>;
  133849. /**
  133850. * Creates a LightGizmo
  133851. * @param gizmoLayer The utility layer the gizmo will be added to
  133852. */
  133853. constructor(gizmoLayer?: UtilityLayerRenderer);
  133854. private _light;
  133855. /**
  133856. * The light that the gizmo is attached to
  133857. */
  133858. set light(light: Nullable<Light>);
  133859. get light(): Nullable<Light>;
  133860. /**
  133861. * Gets the material used to render the light gizmo
  133862. */
  133863. get material(): StandardMaterial;
  133864. /**
  133865. * @hidden
  133866. * Updates the gizmo to match the attached mesh's position/rotation
  133867. */
  133868. protected _update(): void;
  133869. private static _Scale;
  133870. /**
  133871. * Creates the lines for a light mesh
  133872. */
  133873. private static _CreateLightLines;
  133874. /**
  133875. * Disposes of the light gizmo
  133876. */
  133877. dispose(): void;
  133878. private static _CreateHemisphericLightMesh;
  133879. private static _CreatePointLightMesh;
  133880. private static _CreateSpotLightMesh;
  133881. private static _CreateDirectionalLightMesh;
  133882. }
  133883. }
  133884. declare module BABYLON {
  133885. /**
  133886. * Gizmo that enables viewing a camera
  133887. */
  133888. export class CameraGizmo extends Gizmo {
  133889. private _cameraMesh;
  133890. private _cameraLinesMesh;
  133891. private _material;
  133892. private _pointerObserver;
  133893. /**
  133894. * Event that fires each time the gizmo is clicked
  133895. */
  133896. onClickedObservable: Observable<Camera>;
  133897. /**
  133898. * Creates a CameraGizmo
  133899. * @param gizmoLayer The utility layer the gizmo will be added to
  133900. */
  133901. constructor(gizmoLayer?: UtilityLayerRenderer);
  133902. private _camera;
  133903. /** Gets or sets a boolean indicating if frustum lines must be rendered (true by default)) */
  133904. get displayFrustum(): boolean;
  133905. set displayFrustum(value: boolean);
  133906. /**
  133907. * The camera that the gizmo is attached to
  133908. */
  133909. set camera(camera: Nullable<Camera>);
  133910. get camera(): Nullable<Camera>;
  133911. /**
  133912. * Gets the material used to render the camera gizmo
  133913. */
  133914. get material(): StandardMaterial;
  133915. /**
  133916. * @hidden
  133917. * Updates the gizmo to match the attached mesh's position/rotation
  133918. */
  133919. protected _update(): void;
  133920. private static _Scale;
  133921. private _invProjection;
  133922. /**
  133923. * Disposes of the camera gizmo
  133924. */
  133925. dispose(): void;
  133926. private static _CreateCameraMesh;
  133927. private static _CreateCameraFrustum;
  133928. }
  133929. }
  133930. declare module BABYLON {
  133931. /** @hidden */
  133932. export var backgroundFragmentDeclaration: {
  133933. name: string;
  133934. shader: string;
  133935. };
  133936. }
  133937. declare module BABYLON {
  133938. /** @hidden */
  133939. export var backgroundUboDeclaration: {
  133940. name: string;
  133941. shader: string;
  133942. };
  133943. }
  133944. declare module BABYLON {
  133945. /** @hidden */
  133946. export var backgroundPixelShader: {
  133947. name: string;
  133948. shader: string;
  133949. };
  133950. }
  133951. declare module BABYLON {
  133952. /** @hidden */
  133953. export var backgroundVertexDeclaration: {
  133954. name: string;
  133955. shader: string;
  133956. };
  133957. }
  133958. declare module BABYLON {
  133959. /** @hidden */
  133960. export var backgroundVertexShader: {
  133961. name: string;
  133962. shader: string;
  133963. };
  133964. }
  133965. declare module BABYLON {
  133966. /**
  133967. * Background material used to create an efficient environement around your scene.
  133968. */
  133969. export class BackgroundMaterial extends PushMaterial {
  133970. /**
  133971. * Standard reflectance value at parallel view angle.
  133972. */
  133973. static StandardReflectance0: number;
  133974. /**
  133975. * Standard reflectance value at grazing angle.
  133976. */
  133977. static StandardReflectance90: number;
  133978. protected _primaryColor: Color3;
  133979. /**
  133980. * Key light Color (multiply against the environement texture)
  133981. */
  133982. primaryColor: Color3;
  133983. protected __perceptualColor: Nullable<Color3>;
  133984. /**
  133985. * Experimental Internal Use Only.
  133986. *
  133987. * Key light Color in "perceptual value" meaning the color you would like to see on screen.
  133988. * This acts as a helper to set the primary color to a more "human friendly" value.
  133989. * Conversion to linear space as well as exposure and tone mapping correction will be applied to keep the
  133990. * output color as close as possible from the chosen value.
  133991. * (This does not account for contrast color grading and color curves as they are considered post effect and not directly
  133992. * part of lighting setup.)
  133993. */
  133994. get _perceptualColor(): Nullable<Color3>;
  133995. set _perceptualColor(value: Nullable<Color3>);
  133996. protected _primaryColorShadowLevel: float;
  133997. /**
  133998. * Defines the level of the shadows (dark area of the reflection map) in order to help scaling the colors.
  133999. * The color opposite to the primary color is used at the level chosen to define what the black area would look.
  134000. */
  134001. get primaryColorShadowLevel(): float;
  134002. set primaryColorShadowLevel(value: float);
  134003. protected _primaryColorHighlightLevel: float;
  134004. /**
  134005. * Defines the level of the highliights (highlight area of the reflection map) in order to help scaling the colors.
  134006. * The primary color is used at the level chosen to define what the white area would look.
  134007. */
  134008. get primaryColorHighlightLevel(): float;
  134009. set primaryColorHighlightLevel(value: float);
  134010. protected _reflectionTexture: Nullable<BaseTexture>;
  134011. /**
  134012. * Reflection Texture used in the material.
  134013. * Should be author in a specific way for the best result (refer to the documentation).
  134014. */
  134015. reflectionTexture: Nullable<BaseTexture>;
  134016. protected _reflectionBlur: float;
  134017. /**
  134018. * Reflection Texture level of blur.
  134019. *
  134020. * Can be use to reuse an existing HDR Texture and target a specific LOD to prevent authoring the
  134021. * texture twice.
  134022. */
  134023. reflectionBlur: float;
  134024. protected _diffuseTexture: Nullable<BaseTexture>;
  134025. /**
  134026. * Diffuse Texture used in the material.
  134027. * Should be author in a specific way for the best result (refer to the documentation).
  134028. */
  134029. diffuseTexture: Nullable<BaseTexture>;
  134030. protected _shadowLights: Nullable<IShadowLight[]>;
  134031. /**
  134032. * Specify the list of lights casting shadow on the material.
  134033. * All scene shadow lights will be included if null.
  134034. */
  134035. shadowLights: Nullable<IShadowLight[]>;
  134036. protected _shadowLevel: float;
  134037. /**
  134038. * Helps adjusting the shadow to a softer level if required.
  134039. * 0 means black shadows and 1 means no shadows.
  134040. */
  134041. shadowLevel: float;
  134042. protected _sceneCenter: Vector3;
  134043. /**
  134044. * In case of opacity Fresnel or reflection falloff, this is use as a scene center.
  134045. * It is usually zero but might be interesting to modify according to your setup.
  134046. */
  134047. sceneCenter: Vector3;
  134048. protected _opacityFresnel: boolean;
  134049. /**
  134050. * This helps specifying that the material is falling off to the sky box at grazing angle.
  134051. * This helps ensuring a nice transition when the camera goes under the ground.
  134052. */
  134053. opacityFresnel: boolean;
  134054. protected _reflectionFresnel: boolean;
  134055. /**
  134056. * This helps specifying that the material is falling off from diffuse to the reflection texture at grazing angle.
  134057. * This helps adding a mirror texture on the ground.
  134058. */
  134059. reflectionFresnel: boolean;
  134060. protected _reflectionFalloffDistance: number;
  134061. /**
  134062. * This helps specifying the falloff radius off the reflection texture from the sceneCenter.
  134063. * This helps adding a nice falloff effect to the reflection if used as a mirror for instance.
  134064. */
  134065. reflectionFalloffDistance: number;
  134066. protected _reflectionAmount: number;
  134067. /**
  134068. * This specifies the weight of the reflection against the background in case of reflection Fresnel.
  134069. */
  134070. reflectionAmount: number;
  134071. protected _reflectionReflectance0: number;
  134072. /**
  134073. * This specifies the weight of the reflection at grazing angle.
  134074. */
  134075. reflectionReflectance0: number;
  134076. protected _reflectionReflectance90: number;
  134077. /**
  134078. * This specifies the weight of the reflection at a perpendicular point of view.
  134079. */
  134080. reflectionReflectance90: number;
  134081. /**
  134082. * Sets the reflection reflectance fresnel values according to the default standard
  134083. * empirically know to work well :-)
  134084. */
  134085. set reflectionStandardFresnelWeight(value: number);
  134086. protected _useRGBColor: boolean;
  134087. /**
  134088. * Helps to directly use the maps channels instead of their level.
  134089. */
  134090. useRGBColor: boolean;
  134091. protected _enableNoise: boolean;
  134092. /**
  134093. * This helps reducing the banding effect that could occur on the background.
  134094. */
  134095. enableNoise: boolean;
  134096. /**
  134097. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  134098. * Best used when trying to implement visual zoom effects like fish-eye or binoculars while not adjusting camera fov.
  134099. * Recommended to be keep at 1.0 except for special cases.
  134100. */
  134101. get fovMultiplier(): number;
  134102. set fovMultiplier(value: number);
  134103. private _fovMultiplier;
  134104. /**
  134105. * Enable the FOV adjustment feature controlled by fovMultiplier.
  134106. */
  134107. useEquirectangularFOV: boolean;
  134108. private _maxSimultaneousLights;
  134109. /**
  134110. * Number of Simultaneous lights allowed on the material.
  134111. */
  134112. maxSimultaneousLights: int;
  134113. private _shadowOnly;
  134114. /**
  134115. * Make the material only render shadows
  134116. */
  134117. shadowOnly: boolean;
  134118. /**
  134119. * Default configuration related to image processing available in the Background Material.
  134120. */
  134121. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  134122. /**
  134123. * Keep track of the image processing observer to allow dispose and replace.
  134124. */
  134125. private _imageProcessingObserver;
  134126. /**
  134127. * Attaches a new image processing configuration to the PBR Material.
  134128. * @param configuration (if null the scene configuration will be use)
  134129. */
  134130. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  134131. /**
  134132. * Gets the image processing configuration used either in this material.
  134133. */
  134134. get imageProcessingConfiguration(): Nullable<ImageProcessingConfiguration>;
  134135. /**
  134136. * Sets the Default image processing configuration used either in the this material.
  134137. *
  134138. * If sets to null, the scene one is in use.
  134139. */
  134140. set imageProcessingConfiguration(value: Nullable<ImageProcessingConfiguration>);
  134141. /**
  134142. * Gets wether the color curves effect is enabled.
  134143. */
  134144. get cameraColorCurvesEnabled(): boolean;
  134145. /**
  134146. * Sets wether the color curves effect is enabled.
  134147. */
  134148. set cameraColorCurvesEnabled(value: boolean);
  134149. /**
  134150. * Gets wether the color grading effect is enabled.
  134151. */
  134152. get cameraColorGradingEnabled(): boolean;
  134153. /**
  134154. * Gets wether the color grading effect is enabled.
  134155. */
  134156. set cameraColorGradingEnabled(value: boolean);
  134157. /**
  134158. * Gets wether tonemapping is enabled or not.
  134159. */
  134160. get cameraToneMappingEnabled(): boolean;
  134161. /**
  134162. * Sets wether tonemapping is enabled or not
  134163. */
  134164. set cameraToneMappingEnabled(value: boolean);
  134165. /**
  134166. * The camera exposure used on this material.
  134167. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  134168. * This corresponds to a photographic exposure.
  134169. */
  134170. get cameraExposure(): float;
  134171. /**
  134172. * The camera exposure used on this material.
  134173. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  134174. * This corresponds to a photographic exposure.
  134175. */
  134176. set cameraExposure(value: float);
  134177. /**
  134178. * Gets The camera contrast used on this material.
  134179. */
  134180. get cameraContrast(): float;
  134181. /**
  134182. * Sets The camera contrast used on this material.
  134183. */
  134184. set cameraContrast(value: float);
  134185. /**
  134186. * Gets the Color Grading 2D Lookup Texture.
  134187. */
  134188. get cameraColorGradingTexture(): Nullable<BaseTexture>;
  134189. /**
  134190. * Sets the Color Grading 2D Lookup Texture.
  134191. */
  134192. set cameraColorGradingTexture(value: Nullable<BaseTexture>);
  134193. /**
  134194. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  134195. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  134196. * 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;
  134197. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  134198. */
  134199. get cameraColorCurves(): Nullable<ColorCurves>;
  134200. /**
  134201. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  134202. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  134203. * 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;
  134204. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  134205. */
  134206. set cameraColorCurves(value: Nullable<ColorCurves>);
  134207. /**
  134208. * Due to a bug in iOS10, video tags (which are using the background material) are in BGR and not RGB.
  134209. * Setting this flag to true (not done automatically!) will convert it back to RGB.
  134210. */
  134211. switchToBGR: boolean;
  134212. private _renderTargets;
  134213. private _reflectionControls;
  134214. private _white;
  134215. private _primaryShadowColor;
  134216. private _primaryHighlightColor;
  134217. /**
  134218. * Instantiates a Background Material in the given scene
  134219. * @param name The friendly name of the material
  134220. * @param scene The scene to add the material to
  134221. */
  134222. constructor(name: string, scene: Scene);
  134223. /**
  134224. * Gets a boolean indicating that current material needs to register RTT
  134225. */
  134226. get hasRenderTargetTextures(): boolean;
  134227. /**
  134228. * The entire material has been created in order to prevent overdraw.
  134229. * @returns false
  134230. */
  134231. needAlphaTesting(): boolean;
  134232. /**
  134233. * The entire material has been created in order to prevent overdraw.
  134234. * @returns true if blending is enable
  134235. */
  134236. needAlphaBlending(): boolean;
  134237. /**
  134238. * Checks wether the material is ready to be rendered for a given mesh.
  134239. * @param mesh The mesh to render
  134240. * @param subMesh The submesh to check against
  134241. * @param useInstances Specify wether or not the material is used with instances
  134242. * @returns true if all the dependencies are ready (Textures, Effects...)
  134243. */
  134244. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  134245. /**
  134246. * Compute the primary color according to the chosen perceptual color.
  134247. */
  134248. private _computePrimaryColorFromPerceptualColor;
  134249. /**
  134250. * Compute the highlights and shadow colors according to their chosen levels.
  134251. */
  134252. private _computePrimaryColors;
  134253. /**
  134254. * Build the uniform buffer used in the material.
  134255. */
  134256. buildUniformLayout(): void;
  134257. /**
  134258. * Unbind the material.
  134259. */
  134260. unbind(): void;
  134261. /**
  134262. * Bind only the world matrix to the material.
  134263. * @param world The world matrix to bind.
  134264. */
  134265. bindOnlyWorldMatrix(world: Matrix): void;
  134266. /**
  134267. * Bind the material for a dedicated submeh (every used meshes will be considered opaque).
  134268. * @param world The world matrix to bind.
  134269. * @param subMesh The submesh to bind for.
  134270. */
  134271. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  134272. /**
  134273. * Checks to see if a texture is used in the material.
  134274. * @param texture - Base texture to use.
  134275. * @returns - Boolean specifying if a texture is used in the material.
  134276. */
  134277. hasTexture(texture: BaseTexture): boolean;
  134278. /**
  134279. * Dispose the material.
  134280. * @param forceDisposeEffect Force disposal of the associated effect.
  134281. * @param forceDisposeTextures Force disposal of the associated textures.
  134282. */
  134283. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  134284. /**
  134285. * Clones the material.
  134286. * @param name The cloned name.
  134287. * @returns The cloned material.
  134288. */
  134289. clone(name: string): BackgroundMaterial;
  134290. /**
  134291. * Serializes the current material to its JSON representation.
  134292. * @returns The JSON representation.
  134293. */
  134294. serialize(): any;
  134295. /**
  134296. * Gets the class name of the material
  134297. * @returns "BackgroundMaterial"
  134298. */
  134299. getClassName(): string;
  134300. /**
  134301. * Parse a JSON input to create back a background material.
  134302. * @param source The JSON data to parse
  134303. * @param scene The scene to create the parsed material in
  134304. * @param rootUrl The root url of the assets the material depends upon
  134305. * @returns the instantiated BackgroundMaterial.
  134306. */
  134307. static Parse(source: any, scene: Scene, rootUrl: string): BackgroundMaterial;
  134308. }
  134309. }
  134310. declare module BABYLON {
  134311. /**
  134312. * Represents the different options available during the creation of
  134313. * a Environment helper.
  134314. *
  134315. * This can control the default ground, skybox and image processing setup of your scene.
  134316. */
  134317. export interface IEnvironmentHelperOptions {
  134318. /**
  134319. * Specifies whether or not to create a ground.
  134320. * True by default.
  134321. */
  134322. createGround: boolean;
  134323. /**
  134324. * Specifies the ground size.
  134325. * 15 by default.
  134326. */
  134327. groundSize: number;
  134328. /**
  134329. * The texture used on the ground for the main color.
  134330. * Comes from the BabylonJS CDN by default.
  134331. *
  134332. * Remarks: Can be either a texture or a url.
  134333. */
  134334. groundTexture: string | BaseTexture;
  134335. /**
  134336. * The color mixed in the ground texture by default.
  134337. * BabylonJS clearColor by default.
  134338. */
  134339. groundColor: Color3;
  134340. /**
  134341. * Specifies the ground opacity.
  134342. * 1 by default.
  134343. */
  134344. groundOpacity: number;
  134345. /**
  134346. * Enables the ground to receive shadows.
  134347. * True by default.
  134348. */
  134349. enableGroundShadow: boolean;
  134350. /**
  134351. * Helps preventing the shadow to be fully black on the ground.
  134352. * 0.5 by default.
  134353. */
  134354. groundShadowLevel: number;
  134355. /**
  134356. * Creates a mirror texture attach to the ground.
  134357. * false by default.
  134358. */
  134359. enableGroundMirror: boolean;
  134360. /**
  134361. * Specifies the ground mirror size ratio.
  134362. * 0.3 by default as the default kernel is 64.
  134363. */
  134364. groundMirrorSizeRatio: number;
  134365. /**
  134366. * Specifies the ground mirror blur kernel size.
  134367. * 64 by default.
  134368. */
  134369. groundMirrorBlurKernel: number;
  134370. /**
  134371. * Specifies the ground mirror visibility amount.
  134372. * 1 by default
  134373. */
  134374. groundMirrorAmount: number;
  134375. /**
  134376. * Specifies the ground mirror reflectance weight.
  134377. * This uses the standard weight of the background material to setup the fresnel effect
  134378. * of the mirror.
  134379. * 1 by default.
  134380. */
  134381. groundMirrorFresnelWeight: number;
  134382. /**
  134383. * Specifies the ground mirror Falloff distance.
  134384. * This can helps reducing the size of the reflection.
  134385. * 0 by Default.
  134386. */
  134387. groundMirrorFallOffDistance: number;
  134388. /**
  134389. * Specifies the ground mirror texture type.
  134390. * Unsigned Int by Default.
  134391. */
  134392. groundMirrorTextureType: number;
  134393. /**
  134394. * Specifies a bias applied to the ground vertical position to prevent z-fighting with
  134395. * the shown objects.
  134396. */
  134397. groundYBias: number;
  134398. /**
  134399. * Specifies whether or not to create a skybox.
  134400. * True by default.
  134401. */
  134402. createSkybox: boolean;
  134403. /**
  134404. * Specifies the skybox size.
  134405. * 20 by default.
  134406. */
  134407. skyboxSize: number;
  134408. /**
  134409. * The texture used on the skybox for the main color.
  134410. * Comes from the BabylonJS CDN by default.
  134411. *
  134412. * Remarks: Can be either a texture or a url.
  134413. */
  134414. skyboxTexture: string | BaseTexture;
  134415. /**
  134416. * The color mixed in the skybox texture by default.
  134417. * BabylonJS clearColor by default.
  134418. */
  134419. skyboxColor: Color3;
  134420. /**
  134421. * The background rotation around the Y axis of the scene.
  134422. * This helps aligning the key lights of your scene with the background.
  134423. * 0 by default.
  134424. */
  134425. backgroundYRotation: number;
  134426. /**
  134427. * Compute automatically the size of the elements to best fit with the scene.
  134428. */
  134429. sizeAuto: boolean;
  134430. /**
  134431. * Default position of the rootMesh if autoSize is not true.
  134432. */
  134433. rootPosition: Vector3;
  134434. /**
  134435. * Sets up the image processing in the scene.
  134436. * true by default.
  134437. */
  134438. setupImageProcessing: boolean;
  134439. /**
  134440. * The texture used as your environment texture in the scene.
  134441. * Comes from the BabylonJS CDN by default and in use if setupImageProcessing is true.
  134442. *
  134443. * Remarks: Can be either a texture or a url.
  134444. */
  134445. environmentTexture: string | BaseTexture;
  134446. /**
  134447. * The value of the exposure to apply to the scene.
  134448. * 0.6 by default if setupImageProcessing is true.
  134449. */
  134450. cameraExposure: number;
  134451. /**
  134452. * The value of the contrast to apply to the scene.
  134453. * 1.6 by default if setupImageProcessing is true.
  134454. */
  134455. cameraContrast: number;
  134456. /**
  134457. * Specifies whether or not tonemapping should be enabled in the scene.
  134458. * true by default if setupImageProcessing is true.
  134459. */
  134460. toneMappingEnabled: boolean;
  134461. }
  134462. /**
  134463. * The Environment helper class can be used to add a fully featuread none expensive background to your scene.
  134464. * It includes by default a skybox and a ground relying on the BackgroundMaterial.
  134465. * It also helps with the default setup of your imageProcessing configuration.
  134466. */
  134467. export class EnvironmentHelper {
  134468. /**
  134469. * Default ground texture URL.
  134470. */
  134471. private static _groundTextureCDNUrl;
  134472. /**
  134473. * Default skybox texture URL.
  134474. */
  134475. private static _skyboxTextureCDNUrl;
  134476. /**
  134477. * Default environment texture URL.
  134478. */
  134479. private static _environmentTextureCDNUrl;
  134480. /**
  134481. * Creates the default options for the helper.
  134482. */
  134483. private static _getDefaultOptions;
  134484. private _rootMesh;
  134485. /**
  134486. * Gets the root mesh created by the helper.
  134487. */
  134488. get rootMesh(): Mesh;
  134489. private _skybox;
  134490. /**
  134491. * Gets the skybox created by the helper.
  134492. */
  134493. get skybox(): Nullable<Mesh>;
  134494. private _skyboxTexture;
  134495. /**
  134496. * Gets the skybox texture created by the helper.
  134497. */
  134498. get skyboxTexture(): Nullable<BaseTexture>;
  134499. private _skyboxMaterial;
  134500. /**
  134501. * Gets the skybox material created by the helper.
  134502. */
  134503. get skyboxMaterial(): Nullable<BackgroundMaterial>;
  134504. private _ground;
  134505. /**
  134506. * Gets the ground mesh created by the helper.
  134507. */
  134508. get ground(): Nullable<Mesh>;
  134509. private _groundTexture;
  134510. /**
  134511. * Gets the ground texture created by the helper.
  134512. */
  134513. get groundTexture(): Nullable<BaseTexture>;
  134514. private _groundMirror;
  134515. /**
  134516. * Gets the ground mirror created by the helper.
  134517. */
  134518. get groundMirror(): Nullable<MirrorTexture>;
  134519. /**
  134520. * Gets the ground mirror render list to helps pushing the meshes
  134521. * you wish in the ground reflection.
  134522. */
  134523. get groundMirrorRenderList(): Nullable<AbstractMesh[]>;
  134524. private _groundMaterial;
  134525. /**
  134526. * Gets the ground material created by the helper.
  134527. */
  134528. get groundMaterial(): Nullable<BackgroundMaterial>;
  134529. /**
  134530. * Stores the creation options.
  134531. */
  134532. private readonly _scene;
  134533. private _options;
  134534. /**
  134535. * This observable will be notified with any error during the creation of the environment,
  134536. * mainly texture creation errors.
  134537. */
  134538. onErrorObservable: Observable<{
  134539. message?: string;
  134540. exception?: any;
  134541. }>;
  134542. /**
  134543. * constructor
  134544. * @param options Defines the options we want to customize the helper
  134545. * @param scene The scene to add the material to
  134546. */
  134547. constructor(options: Partial<IEnvironmentHelperOptions>, scene: Scene);
  134548. /**
  134549. * Updates the background according to the new options
  134550. * @param options
  134551. */
  134552. updateOptions(options: Partial<IEnvironmentHelperOptions>): void;
  134553. /**
  134554. * Sets the primary color of all the available elements.
  134555. * @param color the main color to affect to the ground and the background
  134556. */
  134557. setMainColor(color: Color3): void;
  134558. /**
  134559. * Setup the image processing according to the specified options.
  134560. */
  134561. private _setupImageProcessing;
  134562. /**
  134563. * Setup the environment texture according to the specified options.
  134564. */
  134565. private _setupEnvironmentTexture;
  134566. /**
  134567. * Setup the background according to the specified options.
  134568. */
  134569. private _setupBackground;
  134570. /**
  134571. * Get the scene sizes according to the setup.
  134572. */
  134573. private _getSceneSize;
  134574. /**
  134575. * Setup the ground according to the specified options.
  134576. */
  134577. private _setupGround;
  134578. /**
  134579. * Setup the ground material according to the specified options.
  134580. */
  134581. private _setupGroundMaterial;
  134582. /**
  134583. * Setup the ground diffuse texture according to the specified options.
  134584. */
  134585. private _setupGroundDiffuseTexture;
  134586. /**
  134587. * Setup the ground mirror texture according to the specified options.
  134588. */
  134589. private _setupGroundMirrorTexture;
  134590. /**
  134591. * Setup the ground to receive the mirror texture.
  134592. */
  134593. private _setupMirrorInGroundMaterial;
  134594. /**
  134595. * Setup the skybox according to the specified options.
  134596. */
  134597. private _setupSkybox;
  134598. /**
  134599. * Setup the skybox material according to the specified options.
  134600. */
  134601. private _setupSkyboxMaterial;
  134602. /**
  134603. * Setup the skybox reflection texture according to the specified options.
  134604. */
  134605. private _setupSkyboxReflectionTexture;
  134606. private _errorHandler;
  134607. /**
  134608. * Dispose all the elements created by the Helper.
  134609. */
  134610. dispose(): void;
  134611. }
  134612. }
  134613. declare module BABYLON {
  134614. /**
  134615. * Display a 360/180 degree texture on an approximately spherical surface, useful for VR applications or skyboxes.
  134616. * As a subclass of TransformNode, this allow parenting to the camera or multiple textures with different locations in the scene.
  134617. * This class achieves its effect with a Texture and a correctly configured BackgroundMaterial on an inverted sphere.
  134618. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  134619. */
  134620. export abstract class TextureDome<T extends Texture> extends TransformNode {
  134621. protected onError: Nullable<(message?: string, exception?: any) => void>;
  134622. /**
  134623. * Define the source as a Monoscopic panoramic 360/180.
  134624. */
  134625. static readonly MODE_MONOSCOPIC: number;
  134626. /**
  134627. * Define the source as a Stereoscopic TopBottom/OverUnder panoramic 360/180.
  134628. */
  134629. static readonly MODE_TOPBOTTOM: number;
  134630. /**
  134631. * Define the source as a Stereoscopic Side by Side panoramic 360/180.
  134632. */
  134633. static readonly MODE_SIDEBYSIDE: number;
  134634. private _halfDome;
  134635. protected _useDirectMapping: boolean;
  134636. /**
  134637. * The texture being displayed on the sphere
  134638. */
  134639. protected _texture: T;
  134640. /**
  134641. * Gets the texture being displayed on the sphere
  134642. */
  134643. get texture(): T;
  134644. /**
  134645. * Sets the texture being displayed on the sphere
  134646. */
  134647. set texture(newTexture: T);
  134648. /**
  134649. * The skybox material
  134650. */
  134651. protected _material: BackgroundMaterial;
  134652. /**
  134653. * The surface used for the dome
  134654. */
  134655. protected _mesh: Mesh;
  134656. /**
  134657. * Gets the mesh used for the dome.
  134658. */
  134659. get mesh(): Mesh;
  134660. /**
  134661. * A mesh that will be used to mask the back of the dome in case it is a 180 degree movie.
  134662. */
  134663. private _halfDomeMask;
  134664. /**
  134665. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  134666. * Also see the options.resolution property.
  134667. */
  134668. get fovMultiplier(): number;
  134669. set fovMultiplier(value: number);
  134670. protected _textureMode: number;
  134671. /**
  134672. * Gets or set the current texture mode for the texture. It can be:
  134673. * * TextureDome.MODE_MONOSCOPIC : Define the texture source as a Monoscopic panoramic 360.
  134674. * * TextureDome.MODE_TOPBOTTOM : Define the texture source as a Stereoscopic TopBottom/OverUnder panoramic 360.
  134675. * * TextureDome.MODE_SIDEBYSIDE : Define the texture source as a Stereoscopic Side by Side panoramic 360.
  134676. */
  134677. get textureMode(): number;
  134678. /**
  134679. * Sets the current texture mode for the texture. It can be:
  134680. * * TextureDome.MODE_MONOSCOPIC : Define the texture source as a Monoscopic panoramic 360.
  134681. * * TextureDome.MODE_TOPBOTTOM : Define the texture source as a Stereoscopic TopBottom/OverUnder panoramic 360.
  134682. * * TextureDome.MODE_SIDEBYSIDE : Define the texture source as a Stereoscopic Side by Side panoramic 360.
  134683. */
  134684. set textureMode(value: number);
  134685. /**
  134686. * Is it a 180 degrees dome (half dome) or 360 texture (full dome)
  134687. */
  134688. get halfDome(): boolean;
  134689. /**
  134690. * Set the halfDome mode. If set, only the front (180 degrees) will be displayed and the back will be blacked out.
  134691. */
  134692. set halfDome(enabled: boolean);
  134693. /**
  134694. * Oberserver used in Stereoscopic VR Mode.
  134695. */
  134696. private _onBeforeCameraRenderObserver;
  134697. /**
  134698. * Observable raised when an error occured while loading the 360 image
  134699. */
  134700. onLoadErrorObservable: Observable<string>;
  134701. /**
  134702. * Create an instance of this class and pass through the parameters to the relevant classes- Texture, StandardMaterial, and Mesh.
  134703. * @param name Element's name, child elements will append suffixes for their own names.
  134704. * @param textureUrlOrElement defines the url(s) or the (video) HTML element to use
  134705. * @param options An object containing optional or exposed sub element properties
  134706. */
  134707. constructor(name: string, textureUrlOrElement: string | string[] | HTMLVideoElement, options: {
  134708. resolution?: number;
  134709. clickToPlay?: boolean;
  134710. autoPlay?: boolean;
  134711. loop?: boolean;
  134712. size?: number;
  134713. poster?: string;
  134714. faceForward?: boolean;
  134715. useDirectMapping?: boolean;
  134716. halfDomeMode?: boolean;
  134717. }, scene: Scene, onError?: Nullable<(message?: string, exception?: any) => void>);
  134718. protected abstract _initTexture(urlsOrElement: string | string[] | HTMLElement, scene: Scene, options: any): T;
  134719. protected _changeTextureMode(value: number): void;
  134720. /**
  134721. * Releases resources associated with this node.
  134722. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  134723. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  134724. */
  134725. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  134726. }
  134727. }
  134728. declare module BABYLON {
  134729. /**
  134730. * Display a 360 degree photo on an approximately spherical surface, useful for VR applications or skyboxes.
  134731. * As a subclass of TransformNode, this allow parenting to the camera with different locations in the scene.
  134732. * This class achieves its effect with a Texture and a correctly configured BackgroundMaterial on an inverted sphere.
  134733. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  134734. */
  134735. export class PhotoDome extends TextureDome<Texture> {
  134736. /**
  134737. * Define the image as a Monoscopic panoramic 360 image.
  134738. */
  134739. static readonly MODE_MONOSCOPIC: number;
  134740. /**
  134741. * Define the image as a Stereoscopic TopBottom/OverUnder panoramic 360 image.
  134742. */
  134743. static readonly MODE_TOPBOTTOM: number;
  134744. /**
  134745. * Define the image as a Stereoscopic Side by Side panoramic 360 image.
  134746. */
  134747. static readonly MODE_SIDEBYSIDE: number;
  134748. /**
  134749. * Gets or sets the texture being displayed on the sphere
  134750. */
  134751. get photoTexture(): Texture;
  134752. /**
  134753. * sets the texture being displayed on the sphere
  134754. */
  134755. set photoTexture(value: Texture);
  134756. /**
  134757. * Gets the current video mode for the video. It can be:
  134758. * * TextureDome.MODE_MONOSCOPIC : Define the texture source as a Monoscopic panoramic 360.
  134759. * * TextureDome.MODE_TOPBOTTOM : Define the texture source as a Stereoscopic TopBottom/OverUnder panoramic 360.
  134760. * * TextureDome.MODE_SIDEBYSIDE : Define the texture source as a Stereoscopic Side by Side panoramic 360.
  134761. */
  134762. get imageMode(): number;
  134763. /**
  134764. * Sets the current video mode for the video. It can be:
  134765. * * TextureDome.MODE_MONOSCOPIC : Define the texture source as a Monoscopic panoramic 360.
  134766. * * TextureDome.MODE_TOPBOTTOM : Define the texture source as a Stereoscopic TopBottom/OverUnder panoramic 360.
  134767. * * TextureDome.MODE_SIDEBYSIDE : Define the texture source as a Stereoscopic Side by Side panoramic 360.
  134768. */
  134769. set imageMode(value: number);
  134770. protected _initTexture(urlsOrElement: string, scene: Scene, options: any): Texture;
  134771. }
  134772. }
  134773. declare module BABYLON {
  134774. /**
  134775. * Class used to host RGBD texture specific utilities
  134776. */
  134777. export class RGBDTextureTools {
  134778. /**
  134779. * Expand the RGBD Texture from RGBD to Half Float if possible.
  134780. * @param texture the texture to expand.
  134781. */
  134782. static ExpandRGBDTexture(texture: Texture): void;
  134783. }
  134784. }
  134785. declare module BABYLON {
  134786. /**
  134787. * Class used to host texture specific utilities
  134788. */
  134789. export class BRDFTextureTools {
  134790. /**
  134791. * Prevents texture cache collision
  134792. */
  134793. private static _instanceNumber;
  134794. /**
  134795. * Gets a default environment BRDF for MS-BRDF Height Correlated BRDF
  134796. * @param scene defines the hosting scene
  134797. * @returns the environment BRDF texture
  134798. */
  134799. static GetEnvironmentBRDFTexture(scene: Scene): BaseTexture;
  134800. private static _environmentBRDFBase64Texture;
  134801. }
  134802. }
  134803. declare module BABYLON {
  134804. /**
  134805. * @hidden
  134806. */
  134807. export interface IMaterialClearCoatDefines {
  134808. CLEARCOAT: boolean;
  134809. CLEARCOAT_DEFAULTIOR: boolean;
  134810. CLEARCOAT_TEXTURE: boolean;
  134811. CLEARCOAT_TEXTUREDIRECTUV: number;
  134812. CLEARCOAT_BUMP: boolean;
  134813. CLEARCOAT_BUMPDIRECTUV: number;
  134814. CLEARCOAT_TINT: boolean;
  134815. CLEARCOAT_TINT_TEXTURE: boolean;
  134816. CLEARCOAT_TINT_TEXTUREDIRECTUV: number;
  134817. /** @hidden */
  134818. _areTexturesDirty: boolean;
  134819. }
  134820. /**
  134821. * Define the code related to the clear coat parameters of the pbr material.
  134822. */
  134823. export class PBRClearCoatConfiguration {
  134824. /**
  134825. * This defaults to 1.5 corresponding to a 0.04 f0 or a 4% reflectance at normal incidence
  134826. * The default fits with a polyurethane material.
  134827. */
  134828. private static readonly _DefaultIndexOfRefraction;
  134829. private _isEnabled;
  134830. /**
  134831. * Defines if the clear coat is enabled in the material.
  134832. */
  134833. isEnabled: boolean;
  134834. /**
  134835. * Defines the clear coat layer strength (between 0 and 1) it defaults to 1.
  134836. */
  134837. intensity: number;
  134838. /**
  134839. * Defines the clear coat layer roughness.
  134840. */
  134841. roughness: number;
  134842. private _indexOfRefraction;
  134843. /**
  134844. * Defines the index of refraction of the clear coat.
  134845. * This defaults to 1.5 corresponding to a 0.04 f0 or a 4% reflectance at normal incidence
  134846. * The default fits with a polyurethane material.
  134847. * Changing the default value is more performance intensive.
  134848. */
  134849. indexOfRefraction: number;
  134850. private _texture;
  134851. /**
  134852. * Stores the clear coat values in a texture.
  134853. */
  134854. texture: Nullable<BaseTexture>;
  134855. private _bumpTexture;
  134856. /**
  134857. * Define the clear coat specific bump texture.
  134858. */
  134859. bumpTexture: Nullable<BaseTexture>;
  134860. private _isTintEnabled;
  134861. /**
  134862. * Defines if the clear coat tint is enabled in the material.
  134863. */
  134864. isTintEnabled: boolean;
  134865. /**
  134866. * Defines the clear coat tint of the material.
  134867. * This is only use if tint is enabled
  134868. */
  134869. tintColor: Color3;
  134870. /**
  134871. * Defines the distance at which the tint color should be found in the
  134872. * clear coat media.
  134873. * This is only use if tint is enabled
  134874. */
  134875. tintColorAtDistance: number;
  134876. /**
  134877. * Defines the clear coat layer thickness.
  134878. * This is only use if tint is enabled
  134879. */
  134880. tintThickness: number;
  134881. private _tintTexture;
  134882. /**
  134883. * Stores the clear tint values in a texture.
  134884. * rgb is tint
  134885. * a is a thickness factor
  134886. */
  134887. tintTexture: Nullable<BaseTexture>;
  134888. /** @hidden */
  134889. private _internalMarkAllSubMeshesAsTexturesDirty;
  134890. /** @hidden */
  134891. _markAllSubMeshesAsTexturesDirty(): void;
  134892. /**
  134893. * Instantiate a new istance of clear coat configuration.
  134894. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  134895. */
  134896. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  134897. /**
  134898. * Gets wehter the submesh is ready to be used or not.
  134899. * @param defines the list of "defines" to update.
  134900. * @param scene defines the scene the material belongs to.
  134901. * @param engine defines the engine the material belongs to.
  134902. * @param disableBumpMap defines wether the material disables bump or not.
  134903. * @returns - boolean indicating that the submesh is ready or not.
  134904. */
  134905. isReadyForSubMesh(defines: IMaterialClearCoatDefines, scene: Scene, engine: Engine, disableBumpMap: boolean): boolean;
  134906. /**
  134907. * Checks to see if a texture is used in the material.
  134908. * @param defines the list of "defines" to update.
  134909. * @param scene defines the scene to the material belongs to.
  134910. */
  134911. prepareDefines(defines: IMaterialClearCoatDefines, scene: Scene): void;
  134912. /**
  134913. * Binds the material data.
  134914. * @param uniformBuffer defines the Uniform buffer to fill in.
  134915. * @param scene defines the scene the material belongs to.
  134916. * @param engine defines the engine the material belongs to.
  134917. * @param disableBumpMap defines wether the material disables bump or not.
  134918. * @param isFrozen defines wether the material is frozen or not.
  134919. * @param invertNormalMapX If sets to true, x component of normal map value will be inverted (x = 1.0 - x).
  134920. * @param invertNormalMapY If sets to true, y component of normal map value will be inverted (y = 1.0 - y).
  134921. */
  134922. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, engine: Engine, disableBumpMap: boolean, isFrozen: boolean, invertNormalMapX: boolean, invertNormalMapY: boolean): void;
  134923. /**
  134924. * Checks to see if a texture is used in the material.
  134925. * @param texture - Base texture to use.
  134926. * @returns - Boolean specifying if a texture is used in the material.
  134927. */
  134928. hasTexture(texture: BaseTexture): boolean;
  134929. /**
  134930. * Returns an array of the actively used textures.
  134931. * @param activeTextures Array of BaseTextures
  134932. */
  134933. getActiveTextures(activeTextures: BaseTexture[]): void;
  134934. /**
  134935. * Returns the animatable textures.
  134936. * @param animatables Array of animatable textures.
  134937. */
  134938. getAnimatables(animatables: IAnimatable[]): void;
  134939. /**
  134940. * Disposes the resources of the material.
  134941. * @param forceDisposeTextures - Forces the disposal of all textures.
  134942. */
  134943. dispose(forceDisposeTextures?: boolean): void;
  134944. /**
  134945. * Get the current class name of the texture useful for serialization or dynamic coding.
  134946. * @returns "PBRClearCoatConfiguration"
  134947. */
  134948. getClassName(): string;
  134949. /**
  134950. * Add fallbacks to the effect fallbacks list.
  134951. * @param defines defines the Base texture to use.
  134952. * @param fallbacks defines the current fallback list.
  134953. * @param currentRank defines the current fallback rank.
  134954. * @returns the new fallback rank.
  134955. */
  134956. static AddFallbacks(defines: IMaterialClearCoatDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  134957. /**
  134958. * Add the required uniforms to the current list.
  134959. * @param uniforms defines the current uniform list.
  134960. */
  134961. static AddUniforms(uniforms: string[]): void;
  134962. /**
  134963. * Add the required samplers to the current list.
  134964. * @param samplers defines the current sampler list.
  134965. */
  134966. static AddSamplers(samplers: string[]): void;
  134967. /**
  134968. * Add the required uniforms to the current buffer.
  134969. * @param uniformBuffer defines the current uniform buffer.
  134970. */
  134971. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  134972. /**
  134973. * Makes a duplicate of the current configuration into another one.
  134974. * @param clearCoatConfiguration define the config where to copy the info
  134975. */
  134976. copyTo(clearCoatConfiguration: PBRClearCoatConfiguration): void;
  134977. /**
  134978. * Serializes this clear coat configuration.
  134979. * @returns - An object with the serialized config.
  134980. */
  134981. serialize(): any;
  134982. /**
  134983. * Parses a anisotropy Configuration from a serialized object.
  134984. * @param source - Serialized object.
  134985. * @param scene Defines the scene we are parsing for
  134986. * @param rootUrl Defines the rootUrl to load from
  134987. */
  134988. parse(source: any, scene: Scene, rootUrl: string): void;
  134989. }
  134990. }
  134991. declare module BABYLON {
  134992. /**
  134993. * @hidden
  134994. */
  134995. export interface IMaterialAnisotropicDefines {
  134996. ANISOTROPIC: boolean;
  134997. ANISOTROPIC_TEXTURE: boolean;
  134998. ANISOTROPIC_TEXTUREDIRECTUV: number;
  134999. MAINUV1: boolean;
  135000. _areTexturesDirty: boolean;
  135001. _needUVs: boolean;
  135002. }
  135003. /**
  135004. * Define the code related to the anisotropic parameters of the pbr material.
  135005. */
  135006. export class PBRAnisotropicConfiguration {
  135007. private _isEnabled;
  135008. /**
  135009. * Defines if the anisotropy is enabled in the material.
  135010. */
  135011. isEnabled: boolean;
  135012. /**
  135013. * Defines the anisotropy strength (between 0 and 1) it defaults to 1.
  135014. */
  135015. intensity: number;
  135016. /**
  135017. * Defines if the effect is along the tangents, bitangents or in between.
  135018. * By default, the effect is "strectching" the highlights along the tangents.
  135019. */
  135020. direction: Vector2;
  135021. private _texture;
  135022. /**
  135023. * Stores the anisotropy values in a texture.
  135024. * rg is direction (like normal from -1 to 1)
  135025. * b is a intensity
  135026. */
  135027. texture: Nullable<BaseTexture>;
  135028. /** @hidden */
  135029. private _internalMarkAllSubMeshesAsTexturesDirty;
  135030. /** @hidden */
  135031. _markAllSubMeshesAsTexturesDirty(): void;
  135032. /**
  135033. * Instantiate a new istance of anisotropy configuration.
  135034. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  135035. */
  135036. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  135037. /**
  135038. * Specifies that the submesh is ready to be used.
  135039. * @param defines the list of "defines" to update.
  135040. * @param scene defines the scene the material belongs to.
  135041. * @returns - boolean indicating that the submesh is ready or not.
  135042. */
  135043. isReadyForSubMesh(defines: IMaterialAnisotropicDefines, scene: Scene): boolean;
  135044. /**
  135045. * Checks to see if a texture is used in the material.
  135046. * @param defines the list of "defines" to update.
  135047. * @param mesh the mesh we are preparing the defines for.
  135048. * @param scene defines the scene the material belongs to.
  135049. */
  135050. prepareDefines(defines: IMaterialAnisotropicDefines, mesh: AbstractMesh, scene: Scene): void;
  135051. /**
  135052. * Binds the material data.
  135053. * @param uniformBuffer defines the Uniform buffer to fill in.
  135054. * @param scene defines the scene the material belongs to.
  135055. * @param isFrozen defines wether the material is frozen or not.
  135056. */
  135057. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean): void;
  135058. /**
  135059. * Checks to see if a texture is used in the material.
  135060. * @param texture - Base texture to use.
  135061. * @returns - Boolean specifying if a texture is used in the material.
  135062. */
  135063. hasTexture(texture: BaseTexture): boolean;
  135064. /**
  135065. * Returns an array of the actively used textures.
  135066. * @param activeTextures Array of BaseTextures
  135067. */
  135068. getActiveTextures(activeTextures: BaseTexture[]): void;
  135069. /**
  135070. * Returns the animatable textures.
  135071. * @param animatables Array of animatable textures.
  135072. */
  135073. getAnimatables(animatables: IAnimatable[]): void;
  135074. /**
  135075. * Disposes the resources of the material.
  135076. * @param forceDisposeTextures - Forces the disposal of all textures.
  135077. */
  135078. dispose(forceDisposeTextures?: boolean): void;
  135079. /**
  135080. * Get the current class name of the texture useful for serialization or dynamic coding.
  135081. * @returns "PBRAnisotropicConfiguration"
  135082. */
  135083. getClassName(): string;
  135084. /**
  135085. * Add fallbacks to the effect fallbacks list.
  135086. * @param defines defines the Base texture to use.
  135087. * @param fallbacks defines the current fallback list.
  135088. * @param currentRank defines the current fallback rank.
  135089. * @returns the new fallback rank.
  135090. */
  135091. static AddFallbacks(defines: IMaterialAnisotropicDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  135092. /**
  135093. * Add the required uniforms to the current list.
  135094. * @param uniforms defines the current uniform list.
  135095. */
  135096. static AddUniforms(uniforms: string[]): void;
  135097. /**
  135098. * Add the required uniforms to the current buffer.
  135099. * @param uniformBuffer defines the current uniform buffer.
  135100. */
  135101. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  135102. /**
  135103. * Add the required samplers to the current list.
  135104. * @param samplers defines the current sampler list.
  135105. */
  135106. static AddSamplers(samplers: string[]): void;
  135107. /**
  135108. * Makes a duplicate of the current configuration into another one.
  135109. * @param anisotropicConfiguration define the config where to copy the info
  135110. */
  135111. copyTo(anisotropicConfiguration: PBRAnisotropicConfiguration): void;
  135112. /**
  135113. * Serializes this anisotropy configuration.
  135114. * @returns - An object with the serialized config.
  135115. */
  135116. serialize(): any;
  135117. /**
  135118. * Parses a anisotropy Configuration from a serialized object.
  135119. * @param source - Serialized object.
  135120. * @param scene Defines the scene we are parsing for
  135121. * @param rootUrl Defines the rootUrl to load from
  135122. */
  135123. parse(source: any, scene: Scene, rootUrl: string): void;
  135124. }
  135125. }
  135126. declare module BABYLON {
  135127. /**
  135128. * @hidden
  135129. */
  135130. export interface IMaterialBRDFDefines {
  135131. BRDF_V_HEIGHT_CORRELATED: boolean;
  135132. MS_BRDF_ENERGY_CONSERVATION: boolean;
  135133. SPHERICAL_HARMONICS: boolean;
  135134. SPECULAR_GLOSSINESS_ENERGY_CONSERVATION: boolean;
  135135. /** @hidden */
  135136. _areMiscDirty: boolean;
  135137. }
  135138. /**
  135139. * Define the code related to the BRDF parameters of the pbr material.
  135140. */
  135141. export class PBRBRDFConfiguration {
  135142. /**
  135143. * Default value used for the energy conservation.
  135144. * This should only be changed to adapt to the type of texture in scene.environmentBRDFTexture.
  135145. */
  135146. static DEFAULT_USE_ENERGY_CONSERVATION: boolean;
  135147. /**
  135148. * Default value used for the Smith Visibility Height Correlated mode.
  135149. * This should only be changed to adapt to the type of texture in scene.environmentBRDFTexture.
  135150. */
  135151. static DEFAULT_USE_SMITH_VISIBILITY_HEIGHT_CORRELATED: boolean;
  135152. /**
  135153. * Default value used for the IBL diffuse part.
  135154. * This can help switching back to the polynomials mode globally which is a tiny bit
  135155. * less GPU intensive at the drawback of a lower quality.
  135156. */
  135157. static DEFAULT_USE_SPHERICAL_HARMONICS: boolean;
  135158. /**
  135159. * Default value used for activating energy conservation for the specular workflow.
  135160. * If activated, the albedo color is multiplied with (1. - maxChannel(specular color)).
  135161. * If deactivated, a material is only physically plausible, when (albedo color + specular color) < 1.
  135162. */
  135163. static DEFAULT_USE_SPECULAR_GLOSSINESS_INPUT_ENERGY_CONSERVATION: boolean;
  135164. private _useEnergyConservation;
  135165. /**
  135166. * Defines if the material uses energy conservation.
  135167. */
  135168. useEnergyConservation: boolean;
  135169. private _useSmithVisibilityHeightCorrelated;
  135170. /**
  135171. * LEGACY Mode set to false
  135172. * Defines if the material uses height smith correlated visibility term.
  135173. * If you intent to not use our default BRDF, you need to load a separate BRDF Texture for the PBR
  135174. * You can either load https://assets.babylonjs.com/environments/uncorrelatedBRDF.png
  135175. * or https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds to have more precision
  135176. * Not relying on height correlated will also disable energy conservation.
  135177. */
  135178. useSmithVisibilityHeightCorrelated: boolean;
  135179. private _useSphericalHarmonics;
  135180. /**
  135181. * LEGACY Mode set to false
  135182. * Defines if the material uses spherical harmonics vs spherical polynomials for the
  135183. * diffuse part of the IBL.
  135184. * The harmonics despite a tiny bigger cost has been proven to provide closer results
  135185. * to the ground truth.
  135186. */
  135187. useSphericalHarmonics: boolean;
  135188. private _useSpecularGlossinessInputEnergyConservation;
  135189. /**
  135190. * Defines if the material uses energy conservation, when the specular workflow is active.
  135191. * If activated, the albedo color is multiplied with (1. - maxChannel(specular color)).
  135192. * If deactivated, a material is only physically plausible, when (albedo color + specular color) < 1.
  135193. * In the deactivated case, the material author has to ensure energy conservation, for a physically plausible rendering.
  135194. */
  135195. useSpecularGlossinessInputEnergyConservation: boolean;
  135196. /** @hidden */
  135197. private _internalMarkAllSubMeshesAsMiscDirty;
  135198. /** @hidden */
  135199. _markAllSubMeshesAsMiscDirty(): void;
  135200. /**
  135201. * Instantiate a new istance of clear coat configuration.
  135202. * @param markAllSubMeshesAsMiscDirty Callback to flag the material to dirty
  135203. */
  135204. constructor(markAllSubMeshesAsMiscDirty: () => void);
  135205. /**
  135206. * Checks to see if a texture is used in the material.
  135207. * @param defines the list of "defines" to update.
  135208. */
  135209. prepareDefines(defines: IMaterialBRDFDefines): void;
  135210. /**
  135211. * Get the current class name of the texture useful for serialization or dynamic coding.
  135212. * @returns "PBRClearCoatConfiguration"
  135213. */
  135214. getClassName(): string;
  135215. /**
  135216. * Makes a duplicate of the current configuration into another one.
  135217. * @param brdfConfiguration define the config where to copy the info
  135218. */
  135219. copyTo(brdfConfiguration: PBRBRDFConfiguration): void;
  135220. /**
  135221. * Serializes this BRDF configuration.
  135222. * @returns - An object with the serialized config.
  135223. */
  135224. serialize(): any;
  135225. /**
  135226. * Parses a anisotropy Configuration from a serialized object.
  135227. * @param source - Serialized object.
  135228. * @param scene Defines the scene we are parsing for
  135229. * @param rootUrl Defines the rootUrl to load from
  135230. */
  135231. parse(source: any, scene: Scene, rootUrl: string): void;
  135232. }
  135233. }
  135234. declare module BABYLON {
  135235. /**
  135236. * @hidden
  135237. */
  135238. export interface IMaterialSheenDefines {
  135239. SHEEN: boolean;
  135240. SHEEN_TEXTURE: boolean;
  135241. SHEEN_TEXTUREDIRECTUV: number;
  135242. SHEEN_LINKWITHALBEDO: boolean;
  135243. SHEEN_ROUGHNESS: boolean;
  135244. SHEEN_ALBEDOSCALING: boolean;
  135245. /** @hidden */
  135246. _areTexturesDirty: boolean;
  135247. }
  135248. /**
  135249. * Define the code related to the Sheen parameters of the pbr material.
  135250. */
  135251. export class PBRSheenConfiguration {
  135252. private _isEnabled;
  135253. /**
  135254. * Defines if the material uses sheen.
  135255. */
  135256. isEnabled: boolean;
  135257. private _linkSheenWithAlbedo;
  135258. /**
  135259. * Defines if the sheen is linked to the sheen color.
  135260. */
  135261. linkSheenWithAlbedo: boolean;
  135262. /**
  135263. * Defines the sheen intensity.
  135264. */
  135265. intensity: number;
  135266. /**
  135267. * Defines the sheen color.
  135268. */
  135269. color: Color3;
  135270. private _texture;
  135271. /**
  135272. * Stores the sheen tint values in a texture.
  135273. * rgb is tint
  135274. * a is a intensity or roughness if roughness has been defined
  135275. */
  135276. texture: Nullable<BaseTexture>;
  135277. private _roughness;
  135278. /**
  135279. * Defines the sheen roughness.
  135280. * It is not taken into account if linkSheenWithAlbedo is true.
  135281. * To stay backward compatible, material roughness is used instead if sheen roughness = null
  135282. */
  135283. roughness: Nullable<number>;
  135284. private _albedoScaling;
  135285. /**
  135286. * If true, the sheen effect is layered above the base BRDF with the albedo-scaling technique.
  135287. * It allows the strength of the sheen effect to not depend on the base color of the material,
  135288. * making it easier to setup and tweak the effect
  135289. */
  135290. albedoScaling: boolean;
  135291. /** @hidden */
  135292. private _internalMarkAllSubMeshesAsTexturesDirty;
  135293. /** @hidden */
  135294. _markAllSubMeshesAsTexturesDirty(): void;
  135295. /**
  135296. * Instantiate a new istance of clear coat configuration.
  135297. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  135298. */
  135299. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  135300. /**
  135301. * Specifies that the submesh is ready to be used.
  135302. * @param defines the list of "defines" to update.
  135303. * @param scene defines the scene the material belongs to.
  135304. * @returns - boolean indicating that the submesh is ready or not.
  135305. */
  135306. isReadyForSubMesh(defines: IMaterialSheenDefines, scene: Scene): boolean;
  135307. /**
  135308. * Checks to see if a texture is used in the material.
  135309. * @param defines the list of "defines" to update.
  135310. * @param scene defines the scene the material belongs to.
  135311. */
  135312. prepareDefines(defines: IMaterialSheenDefines, scene: Scene): void;
  135313. /**
  135314. * Binds the material data.
  135315. * @param uniformBuffer defines the Uniform buffer to fill in.
  135316. * @param scene defines the scene the material belongs to.
  135317. * @param isFrozen defines wether the material is frozen or not.
  135318. */
  135319. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean): void;
  135320. /**
  135321. * Checks to see if a texture is used in the material.
  135322. * @param texture - Base texture to use.
  135323. * @returns - Boolean specifying if a texture is used in the material.
  135324. */
  135325. hasTexture(texture: BaseTexture): boolean;
  135326. /**
  135327. * Returns an array of the actively used textures.
  135328. * @param activeTextures Array of BaseTextures
  135329. */
  135330. getActiveTextures(activeTextures: BaseTexture[]): void;
  135331. /**
  135332. * Returns the animatable textures.
  135333. * @param animatables Array of animatable textures.
  135334. */
  135335. getAnimatables(animatables: IAnimatable[]): void;
  135336. /**
  135337. * Disposes the resources of the material.
  135338. * @param forceDisposeTextures - Forces the disposal of all textures.
  135339. */
  135340. dispose(forceDisposeTextures?: boolean): void;
  135341. /**
  135342. * Get the current class name of the texture useful for serialization or dynamic coding.
  135343. * @returns "PBRSheenConfiguration"
  135344. */
  135345. getClassName(): string;
  135346. /**
  135347. * Add fallbacks to the effect fallbacks list.
  135348. * @param defines defines the Base texture to use.
  135349. * @param fallbacks defines the current fallback list.
  135350. * @param currentRank defines the current fallback rank.
  135351. * @returns the new fallback rank.
  135352. */
  135353. static AddFallbacks(defines: IMaterialSheenDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  135354. /**
  135355. * Add the required uniforms to the current list.
  135356. * @param uniforms defines the current uniform list.
  135357. */
  135358. static AddUniforms(uniforms: string[]): void;
  135359. /**
  135360. * Add the required uniforms to the current buffer.
  135361. * @param uniformBuffer defines the current uniform buffer.
  135362. */
  135363. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  135364. /**
  135365. * Add the required samplers to the current list.
  135366. * @param samplers defines the current sampler list.
  135367. */
  135368. static AddSamplers(samplers: string[]): void;
  135369. /**
  135370. * Makes a duplicate of the current configuration into another one.
  135371. * @param sheenConfiguration define the config where to copy the info
  135372. */
  135373. copyTo(sheenConfiguration: PBRSheenConfiguration): void;
  135374. /**
  135375. * Serializes this BRDF configuration.
  135376. * @returns - An object with the serialized config.
  135377. */
  135378. serialize(): any;
  135379. /**
  135380. * Parses a anisotropy Configuration from a serialized object.
  135381. * @param source - Serialized object.
  135382. * @param scene Defines the scene we are parsing for
  135383. * @param rootUrl Defines the rootUrl to load from
  135384. */
  135385. parse(source: any, scene: Scene, rootUrl: string): void;
  135386. }
  135387. }
  135388. declare module BABYLON {
  135389. /**
  135390. * @hidden
  135391. */
  135392. export interface IMaterialSubSurfaceDefines {
  135393. SUBSURFACE: boolean;
  135394. SS_REFRACTION: boolean;
  135395. SS_TRANSLUCENCY: boolean;
  135396. SS_SCATTERING: boolean;
  135397. SS_THICKNESSANDMASK_TEXTURE: boolean;
  135398. SS_THICKNESSANDMASK_TEXTUREDIRECTUV: number;
  135399. SS_REFRACTIONMAP_3D: boolean;
  135400. SS_REFRACTIONMAP_OPPOSITEZ: boolean;
  135401. SS_LODINREFRACTIONALPHA: boolean;
  135402. SS_GAMMAREFRACTION: boolean;
  135403. SS_RGBDREFRACTION: boolean;
  135404. SS_LINEARSPECULARREFRACTION: boolean;
  135405. SS_LINKREFRACTIONTOTRANSPARENCY: boolean;
  135406. SS_ALBEDOFORREFRACTIONTINT: boolean;
  135407. SS_MASK_FROM_THICKNESS_TEXTURE: boolean;
  135408. /** @hidden */
  135409. _areTexturesDirty: boolean;
  135410. }
  135411. /**
  135412. * Define the code related to the sub surface parameters of the pbr material.
  135413. */
  135414. export class PBRSubSurfaceConfiguration {
  135415. private _isRefractionEnabled;
  135416. /**
  135417. * Defines if the refraction is enabled in the material.
  135418. */
  135419. isRefractionEnabled: boolean;
  135420. private _isTranslucencyEnabled;
  135421. /**
  135422. * Defines if the translucency is enabled in the material.
  135423. */
  135424. isTranslucencyEnabled: boolean;
  135425. private _isScatteringEnabled;
  135426. /**
  135427. * Defines if the sub surface scattering is enabled in the material.
  135428. */
  135429. isScatteringEnabled: boolean;
  135430. private _scatteringDiffusionProfileIndex;
  135431. /**
  135432. * Diffusion profile for subsurface scattering.
  135433. * Useful for better scattering in the skins or foliages.
  135434. */
  135435. get scatteringDiffusionProfile(): Nullable<Color3>;
  135436. set scatteringDiffusionProfile(c: Nullable<Color3>);
  135437. /**
  135438. * Defines the refraction intensity of the material.
  135439. * The refraction when enabled replaces the Diffuse part of the material.
  135440. * The intensity helps transitionning between diffuse and refraction.
  135441. */
  135442. refractionIntensity: number;
  135443. /**
  135444. * Defines the translucency intensity of the material.
  135445. * When translucency has been enabled, this defines how much of the "translucency"
  135446. * is addded to the diffuse part of the material.
  135447. */
  135448. translucencyIntensity: number;
  135449. /**
  135450. * When enabled, transparent surfaces will be tinted with the albedo colour (independent of thickness)
  135451. */
  135452. useAlbedoToTintRefraction: boolean;
  135453. private _thicknessTexture;
  135454. /**
  135455. * Stores the average thickness of a mesh in a texture (The texture is holding the values linearly).
  135456. * The red channel of the texture should contain the thickness remapped between 0 and 1.
  135457. * 0 would mean minimumThickness
  135458. * 1 would mean maximumThickness
  135459. * The other channels might be use as a mask to vary the different effects intensity.
  135460. */
  135461. thicknessTexture: Nullable<BaseTexture>;
  135462. private _refractionTexture;
  135463. /**
  135464. * Defines the texture to use for refraction.
  135465. */
  135466. refractionTexture: Nullable<BaseTexture>;
  135467. private _indexOfRefraction;
  135468. /**
  135469. * Index of refraction of the material base layer.
  135470. * https://en.wikipedia.org/wiki/List_of_refractive_indices
  135471. *
  135472. * This does not only impact refraction but also the Base F0 of Dielectric Materials.
  135473. *
  135474. * From dielectric fresnel rules: F0 = square((iorT - iorI) / (iorT + iorI))
  135475. */
  135476. indexOfRefraction: number;
  135477. private _volumeIndexOfRefraction;
  135478. /**
  135479. * Index of refraction of the material's volume.
  135480. * https://en.wikipedia.org/wiki/List_of_refractive_indices
  135481. *
  135482. * This ONLY impacts refraction. If not provided or given a non-valid value,
  135483. * the volume will use the same IOR as the surface.
  135484. */
  135485. get volumeIndexOfRefraction(): number;
  135486. set volumeIndexOfRefraction(value: number);
  135487. private _invertRefractionY;
  135488. /**
  135489. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  135490. */
  135491. invertRefractionY: boolean;
  135492. private _linkRefractionWithTransparency;
  135493. /**
  135494. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  135495. * Materials half opaque for instance using refraction could benefit from this control.
  135496. */
  135497. linkRefractionWithTransparency: boolean;
  135498. /**
  135499. * Defines the minimum thickness stored in the thickness map.
  135500. * If no thickness map is defined, this value will be used to simulate thickness.
  135501. */
  135502. minimumThickness: number;
  135503. /**
  135504. * Defines the maximum thickness stored in the thickness map.
  135505. */
  135506. maximumThickness: number;
  135507. /**
  135508. * Defines the volume tint of the material.
  135509. * This is used for both translucency and scattering.
  135510. */
  135511. tintColor: Color3;
  135512. /**
  135513. * Defines the distance at which the tint color should be found in the media.
  135514. * This is used for refraction only.
  135515. */
  135516. tintColorAtDistance: number;
  135517. /**
  135518. * Defines how far each channel transmit through the media.
  135519. * It is defined as a color to simplify it selection.
  135520. */
  135521. diffusionDistance: Color3;
  135522. private _useMaskFromThicknessTexture;
  135523. /**
  135524. * Stores the intensity of the different subsurface effects in the thickness texture.
  135525. * * the green channel is the translucency intensity.
  135526. * * the blue channel is the scattering intensity.
  135527. * * the alpha channel is the refraction intensity.
  135528. */
  135529. useMaskFromThicknessTexture: boolean;
  135530. private _scene;
  135531. /** @hidden */
  135532. private _internalMarkAllSubMeshesAsTexturesDirty;
  135533. private _internalMarkScenePrePassDirty;
  135534. /** @hidden */
  135535. _markAllSubMeshesAsTexturesDirty(): void;
  135536. /** @hidden */
  135537. _markScenePrePassDirty(): void;
  135538. /**
  135539. * Instantiate a new istance of sub surface configuration.
  135540. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  135541. * @param markScenePrePassDirty Callback to flag the scene as prepass dirty
  135542. * @param scene The scene
  135543. */
  135544. constructor(markAllSubMeshesAsTexturesDirty: () => void, markScenePrePassDirty: () => void, scene: Scene);
  135545. /**
  135546. * Gets wehter the submesh is ready to be used or not.
  135547. * @param defines the list of "defines" to update.
  135548. * @param scene defines the scene the material belongs to.
  135549. * @returns - boolean indicating that the submesh is ready or not.
  135550. */
  135551. isReadyForSubMesh(defines: IMaterialSubSurfaceDefines, scene: Scene): boolean;
  135552. /**
  135553. * Checks to see if a texture is used in the material.
  135554. * @param defines the list of "defines" to update.
  135555. * @param scene defines the scene to the material belongs to.
  135556. */
  135557. prepareDefines(defines: IMaterialSubSurfaceDefines, scene: Scene): void;
  135558. /**
  135559. * Binds the material data.
  135560. * @param uniformBuffer defines the Uniform buffer to fill in.
  135561. * @param scene defines the scene the material belongs to.
  135562. * @param engine defines the engine the material belongs to.
  135563. * @param isFrozen defines whether the material is frozen or not.
  135564. * @param lodBasedMicrosurface defines whether the material relies on lod based microsurface or not.
  135565. * @param realTimeFiltering defines whether the textures should be filtered on the fly.
  135566. */
  135567. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, engine: Engine, isFrozen: boolean, lodBasedMicrosurface: boolean, realTimeFiltering: boolean): void;
  135568. /**
  135569. * Unbinds the material from the mesh.
  135570. * @param activeEffect defines the effect that should be unbound from.
  135571. * @returns true if unbound, otherwise false
  135572. */
  135573. unbind(activeEffect: Effect): boolean;
  135574. /**
  135575. * Returns the texture used for refraction or null if none is used.
  135576. * @param scene defines the scene the material belongs to.
  135577. * @returns - Refraction texture if present. If no refraction texture and refraction
  135578. * is linked with transparency, returns environment texture. Otherwise, returns null.
  135579. */
  135580. private _getRefractionTexture;
  135581. /**
  135582. * Returns true if alpha blending should be disabled.
  135583. */
  135584. get disableAlphaBlending(): boolean;
  135585. /**
  135586. * Fills the list of render target textures.
  135587. * @param renderTargets the list of render targets to update
  135588. */
  135589. fillRenderTargetTextures(renderTargets: SmartArray<RenderTargetTexture>): void;
  135590. /**
  135591. * Checks to see if a texture is used in the material.
  135592. * @param texture - Base texture to use.
  135593. * @returns - Boolean specifying if a texture is used in the material.
  135594. */
  135595. hasTexture(texture: BaseTexture): boolean;
  135596. /**
  135597. * Gets a boolean indicating that current material needs to register RTT
  135598. * @returns true if this uses a render target otherwise false.
  135599. */
  135600. hasRenderTargetTextures(): boolean;
  135601. /**
  135602. * Returns an array of the actively used textures.
  135603. * @param activeTextures Array of BaseTextures
  135604. */
  135605. getActiveTextures(activeTextures: BaseTexture[]): void;
  135606. /**
  135607. * Returns the animatable textures.
  135608. * @param animatables Array of animatable textures.
  135609. */
  135610. getAnimatables(animatables: IAnimatable[]): void;
  135611. /**
  135612. * Disposes the resources of the material.
  135613. * @param forceDisposeTextures - Forces the disposal of all textures.
  135614. */
  135615. dispose(forceDisposeTextures?: boolean): void;
  135616. /**
  135617. * Get the current class name of the texture useful for serialization or dynamic coding.
  135618. * @returns "PBRSubSurfaceConfiguration"
  135619. */
  135620. getClassName(): string;
  135621. /**
  135622. * Add fallbacks to the effect fallbacks list.
  135623. * @param defines defines the Base texture to use.
  135624. * @param fallbacks defines the current fallback list.
  135625. * @param currentRank defines the current fallback rank.
  135626. * @returns the new fallback rank.
  135627. */
  135628. static AddFallbacks(defines: IMaterialSubSurfaceDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  135629. /**
  135630. * Add the required uniforms to the current list.
  135631. * @param uniforms defines the current uniform list.
  135632. */
  135633. static AddUniforms(uniforms: string[]): void;
  135634. /**
  135635. * Add the required samplers to the current list.
  135636. * @param samplers defines the current sampler list.
  135637. */
  135638. static AddSamplers(samplers: string[]): void;
  135639. /**
  135640. * Add the required uniforms to the current buffer.
  135641. * @param uniformBuffer defines the current uniform buffer.
  135642. */
  135643. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  135644. /**
  135645. * Makes a duplicate of the current configuration into another one.
  135646. * @param configuration define the config where to copy the info
  135647. */
  135648. copyTo(configuration: PBRSubSurfaceConfiguration): void;
  135649. /**
  135650. * Serializes this Sub Surface configuration.
  135651. * @returns - An object with the serialized config.
  135652. */
  135653. serialize(): any;
  135654. /**
  135655. * Parses a anisotropy Configuration from a serialized object.
  135656. * @param source - Serialized object.
  135657. * @param scene Defines the scene we are parsing for
  135658. * @param rootUrl Defines the rootUrl to load from
  135659. */
  135660. parse(source: any, scene: Scene, rootUrl: string): void;
  135661. }
  135662. }
  135663. declare module BABYLON {
  135664. /** @hidden */
  135665. export var pbrFragmentDeclaration: {
  135666. name: string;
  135667. shader: string;
  135668. };
  135669. }
  135670. declare module BABYLON {
  135671. /** @hidden */
  135672. export var pbrUboDeclaration: {
  135673. name: string;
  135674. shader: string;
  135675. };
  135676. }
  135677. declare module BABYLON {
  135678. /** @hidden */
  135679. export var pbrFragmentExtraDeclaration: {
  135680. name: string;
  135681. shader: string;
  135682. };
  135683. }
  135684. declare module BABYLON {
  135685. /** @hidden */
  135686. export var pbrFragmentSamplersDeclaration: {
  135687. name: string;
  135688. shader: string;
  135689. };
  135690. }
  135691. declare module BABYLON {
  135692. /** @hidden */
  135693. export var importanceSampling: {
  135694. name: string;
  135695. shader: string;
  135696. };
  135697. }
  135698. declare module BABYLON {
  135699. /** @hidden */
  135700. export var pbrHelperFunctions: {
  135701. name: string;
  135702. shader: string;
  135703. };
  135704. }
  135705. declare module BABYLON {
  135706. /** @hidden */
  135707. export var harmonicsFunctions: {
  135708. name: string;
  135709. shader: string;
  135710. };
  135711. }
  135712. declare module BABYLON {
  135713. /** @hidden */
  135714. export var pbrDirectLightingSetupFunctions: {
  135715. name: string;
  135716. shader: string;
  135717. };
  135718. }
  135719. declare module BABYLON {
  135720. /** @hidden */
  135721. export var pbrDirectLightingFalloffFunctions: {
  135722. name: string;
  135723. shader: string;
  135724. };
  135725. }
  135726. declare module BABYLON {
  135727. /** @hidden */
  135728. export var pbrBRDFFunctions: {
  135729. name: string;
  135730. shader: string;
  135731. };
  135732. }
  135733. declare module BABYLON {
  135734. /** @hidden */
  135735. export var hdrFilteringFunctions: {
  135736. name: string;
  135737. shader: string;
  135738. };
  135739. }
  135740. declare module BABYLON {
  135741. /** @hidden */
  135742. export var pbrDirectLightingFunctions: {
  135743. name: string;
  135744. shader: string;
  135745. };
  135746. }
  135747. declare module BABYLON {
  135748. /** @hidden */
  135749. export var pbrIBLFunctions: {
  135750. name: string;
  135751. shader: string;
  135752. };
  135753. }
  135754. declare module BABYLON {
  135755. /** @hidden */
  135756. export var pbrBlockAlbedoOpacity: {
  135757. name: string;
  135758. shader: string;
  135759. };
  135760. }
  135761. declare module BABYLON {
  135762. /** @hidden */
  135763. export var pbrBlockReflectivity: {
  135764. name: string;
  135765. shader: string;
  135766. };
  135767. }
  135768. declare module BABYLON {
  135769. /** @hidden */
  135770. export var pbrBlockAmbientOcclusion: {
  135771. name: string;
  135772. shader: string;
  135773. };
  135774. }
  135775. declare module BABYLON {
  135776. /** @hidden */
  135777. export var pbrBlockAlphaFresnel: {
  135778. name: string;
  135779. shader: string;
  135780. };
  135781. }
  135782. declare module BABYLON {
  135783. /** @hidden */
  135784. export var pbrBlockAnisotropic: {
  135785. name: string;
  135786. shader: string;
  135787. };
  135788. }
  135789. declare module BABYLON {
  135790. /** @hidden */
  135791. export var pbrBlockReflection: {
  135792. name: string;
  135793. shader: string;
  135794. };
  135795. }
  135796. declare module BABYLON {
  135797. /** @hidden */
  135798. export var pbrBlockSheen: {
  135799. name: string;
  135800. shader: string;
  135801. };
  135802. }
  135803. declare module BABYLON {
  135804. /** @hidden */
  135805. export var pbrBlockClearcoat: {
  135806. name: string;
  135807. shader: string;
  135808. };
  135809. }
  135810. declare module BABYLON {
  135811. /** @hidden */
  135812. export var pbrBlockSubSurface: {
  135813. name: string;
  135814. shader: string;
  135815. };
  135816. }
  135817. declare module BABYLON {
  135818. /** @hidden */
  135819. export var pbrBlockNormalGeometric: {
  135820. name: string;
  135821. shader: string;
  135822. };
  135823. }
  135824. declare module BABYLON {
  135825. /** @hidden */
  135826. export var pbrBlockNormalFinal: {
  135827. name: string;
  135828. shader: string;
  135829. };
  135830. }
  135831. declare module BABYLON {
  135832. /** @hidden */
  135833. export var pbrBlockLightmapInit: {
  135834. name: string;
  135835. shader: string;
  135836. };
  135837. }
  135838. declare module BABYLON {
  135839. /** @hidden */
  135840. export var pbrBlockGeometryInfo: {
  135841. name: string;
  135842. shader: string;
  135843. };
  135844. }
  135845. declare module BABYLON {
  135846. /** @hidden */
  135847. export var pbrBlockReflectance0: {
  135848. name: string;
  135849. shader: string;
  135850. };
  135851. }
  135852. declare module BABYLON {
  135853. /** @hidden */
  135854. export var pbrBlockReflectance: {
  135855. name: string;
  135856. shader: string;
  135857. };
  135858. }
  135859. declare module BABYLON {
  135860. /** @hidden */
  135861. export var pbrBlockDirectLighting: {
  135862. name: string;
  135863. shader: string;
  135864. };
  135865. }
  135866. declare module BABYLON {
  135867. /** @hidden */
  135868. export var pbrBlockFinalLitComponents: {
  135869. name: string;
  135870. shader: string;
  135871. };
  135872. }
  135873. declare module BABYLON {
  135874. /** @hidden */
  135875. export var pbrBlockFinalUnlitComponents: {
  135876. name: string;
  135877. shader: string;
  135878. };
  135879. }
  135880. declare module BABYLON {
  135881. /** @hidden */
  135882. export var pbrBlockFinalColorComposition: {
  135883. name: string;
  135884. shader: string;
  135885. };
  135886. }
  135887. declare module BABYLON {
  135888. /** @hidden */
  135889. export var pbrBlockImageProcessing: {
  135890. name: string;
  135891. shader: string;
  135892. };
  135893. }
  135894. declare module BABYLON {
  135895. /** @hidden */
  135896. export var pbrDebug: {
  135897. name: string;
  135898. shader: string;
  135899. };
  135900. }
  135901. declare module BABYLON {
  135902. /** @hidden */
  135903. export var pbrPixelShader: {
  135904. name: string;
  135905. shader: string;
  135906. };
  135907. }
  135908. declare module BABYLON {
  135909. /** @hidden */
  135910. export var pbrVertexDeclaration: {
  135911. name: string;
  135912. shader: string;
  135913. };
  135914. }
  135915. declare module BABYLON {
  135916. /** @hidden */
  135917. export var pbrVertexShader: {
  135918. name: string;
  135919. shader: string;
  135920. };
  135921. }
  135922. declare module BABYLON {
  135923. /**
  135924. * Manages the defines for the PBR Material.
  135925. * @hidden
  135926. */
  135927. export class PBRMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines, IMaterialClearCoatDefines, IMaterialAnisotropicDefines, IMaterialBRDFDefines, IMaterialSheenDefines, IMaterialSubSurfaceDefines, IMaterialDetailMapDefines {
  135928. PBR: boolean;
  135929. NUM_SAMPLES: string;
  135930. REALTIME_FILTERING: boolean;
  135931. MAINUV1: boolean;
  135932. MAINUV2: boolean;
  135933. UV1: boolean;
  135934. UV2: boolean;
  135935. ALBEDO: boolean;
  135936. GAMMAALBEDO: boolean;
  135937. ALBEDODIRECTUV: number;
  135938. VERTEXCOLOR: boolean;
  135939. DETAIL: boolean;
  135940. DETAILDIRECTUV: number;
  135941. DETAIL_NORMALBLENDMETHOD: number;
  135942. AMBIENT: boolean;
  135943. AMBIENTDIRECTUV: number;
  135944. AMBIENTINGRAYSCALE: boolean;
  135945. OPACITY: boolean;
  135946. VERTEXALPHA: boolean;
  135947. OPACITYDIRECTUV: number;
  135948. OPACITYRGB: boolean;
  135949. ALPHATEST: boolean;
  135950. DEPTHPREPASS: boolean;
  135951. ALPHABLEND: boolean;
  135952. ALPHAFROMALBEDO: boolean;
  135953. ALPHATESTVALUE: string;
  135954. SPECULAROVERALPHA: boolean;
  135955. RADIANCEOVERALPHA: boolean;
  135956. ALPHAFRESNEL: boolean;
  135957. LINEARALPHAFRESNEL: boolean;
  135958. PREMULTIPLYALPHA: boolean;
  135959. EMISSIVE: boolean;
  135960. EMISSIVEDIRECTUV: number;
  135961. REFLECTIVITY: boolean;
  135962. REFLECTIVITYDIRECTUV: number;
  135963. SPECULARTERM: boolean;
  135964. MICROSURFACEFROMREFLECTIVITYMAP: boolean;
  135965. MICROSURFACEAUTOMATIC: boolean;
  135966. LODBASEDMICROSFURACE: boolean;
  135967. MICROSURFACEMAP: boolean;
  135968. MICROSURFACEMAPDIRECTUV: number;
  135969. METALLICWORKFLOW: boolean;
  135970. ROUGHNESSSTOREINMETALMAPALPHA: boolean;
  135971. ROUGHNESSSTOREINMETALMAPGREEN: boolean;
  135972. METALLNESSSTOREINMETALMAPBLUE: boolean;
  135973. AOSTOREINMETALMAPRED: boolean;
  135974. METALLIC_REFLECTANCE: boolean;
  135975. METALLIC_REFLECTANCEDIRECTUV: number;
  135976. ENVIRONMENTBRDF: boolean;
  135977. ENVIRONMENTBRDF_RGBD: boolean;
  135978. NORMAL: boolean;
  135979. TANGENT: boolean;
  135980. BUMP: boolean;
  135981. BUMPDIRECTUV: number;
  135982. OBJECTSPACE_NORMALMAP: boolean;
  135983. PARALLAX: boolean;
  135984. PARALLAXOCCLUSION: boolean;
  135985. NORMALXYSCALE: boolean;
  135986. LIGHTMAP: boolean;
  135987. LIGHTMAPDIRECTUV: number;
  135988. USELIGHTMAPASSHADOWMAP: boolean;
  135989. GAMMALIGHTMAP: boolean;
  135990. RGBDLIGHTMAP: boolean;
  135991. REFLECTION: boolean;
  135992. REFLECTIONMAP_3D: boolean;
  135993. REFLECTIONMAP_SPHERICAL: boolean;
  135994. REFLECTIONMAP_PLANAR: boolean;
  135995. REFLECTIONMAP_CUBIC: boolean;
  135996. USE_LOCAL_REFLECTIONMAP_CUBIC: boolean;
  135997. REFLECTIONMAP_PROJECTION: boolean;
  135998. REFLECTIONMAP_SKYBOX: boolean;
  135999. REFLECTIONMAP_EXPLICIT: boolean;
  136000. REFLECTIONMAP_EQUIRECTANGULAR: boolean;
  136001. REFLECTIONMAP_EQUIRECTANGULAR_FIXED: boolean;
  136002. REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED: boolean;
  136003. INVERTCUBICMAP: boolean;
  136004. USESPHERICALFROMREFLECTIONMAP: boolean;
  136005. USEIRRADIANCEMAP: boolean;
  136006. SPHERICAL_HARMONICS: boolean;
  136007. USESPHERICALINVERTEX: boolean;
  136008. REFLECTIONMAP_OPPOSITEZ: boolean;
  136009. LODINREFLECTIONALPHA: boolean;
  136010. GAMMAREFLECTION: boolean;
  136011. RGBDREFLECTION: boolean;
  136012. LINEARSPECULARREFLECTION: boolean;
  136013. RADIANCEOCCLUSION: boolean;
  136014. HORIZONOCCLUSION: boolean;
  136015. INSTANCES: boolean;
  136016. THIN_INSTANCES: boolean;
  136017. PREPASS: boolean;
  136018. SCENE_MRT_COUNT: number;
  136019. NUM_BONE_INFLUENCERS: number;
  136020. BonesPerMesh: number;
  136021. BONETEXTURE: boolean;
  136022. NONUNIFORMSCALING: boolean;
  136023. MORPHTARGETS: boolean;
  136024. MORPHTARGETS_NORMAL: boolean;
  136025. MORPHTARGETS_TANGENT: boolean;
  136026. MORPHTARGETS_UV: boolean;
  136027. NUM_MORPH_INFLUENCERS: number;
  136028. IMAGEPROCESSING: boolean;
  136029. VIGNETTE: boolean;
  136030. VIGNETTEBLENDMODEMULTIPLY: boolean;
  136031. VIGNETTEBLENDMODEOPAQUE: boolean;
  136032. TONEMAPPING: boolean;
  136033. TONEMAPPING_ACES: boolean;
  136034. CONTRAST: boolean;
  136035. COLORCURVES: boolean;
  136036. COLORGRADING: boolean;
  136037. COLORGRADING3D: boolean;
  136038. SAMPLER3DGREENDEPTH: boolean;
  136039. SAMPLER3DBGRMAP: boolean;
  136040. IMAGEPROCESSINGPOSTPROCESS: boolean;
  136041. EXPOSURE: boolean;
  136042. MULTIVIEW: boolean;
  136043. USEPHYSICALLIGHTFALLOFF: boolean;
  136044. USEGLTFLIGHTFALLOFF: boolean;
  136045. TWOSIDEDLIGHTING: boolean;
  136046. SHADOWFLOAT: boolean;
  136047. CLIPPLANE: boolean;
  136048. CLIPPLANE2: boolean;
  136049. CLIPPLANE3: boolean;
  136050. CLIPPLANE4: boolean;
  136051. CLIPPLANE5: boolean;
  136052. CLIPPLANE6: boolean;
  136053. POINTSIZE: boolean;
  136054. FOG: boolean;
  136055. LOGARITHMICDEPTH: boolean;
  136056. FORCENORMALFORWARD: boolean;
  136057. SPECULARAA: boolean;
  136058. CLEARCOAT: boolean;
  136059. CLEARCOAT_DEFAULTIOR: boolean;
  136060. CLEARCOAT_TEXTURE: boolean;
  136061. CLEARCOAT_TEXTUREDIRECTUV: number;
  136062. CLEARCOAT_BUMP: boolean;
  136063. CLEARCOAT_BUMPDIRECTUV: number;
  136064. CLEARCOAT_TINT: boolean;
  136065. CLEARCOAT_TINT_TEXTURE: boolean;
  136066. CLEARCOAT_TINT_TEXTUREDIRECTUV: number;
  136067. ANISOTROPIC: boolean;
  136068. ANISOTROPIC_TEXTURE: boolean;
  136069. ANISOTROPIC_TEXTUREDIRECTUV: number;
  136070. BRDF_V_HEIGHT_CORRELATED: boolean;
  136071. MS_BRDF_ENERGY_CONSERVATION: boolean;
  136072. SPECULAR_GLOSSINESS_ENERGY_CONSERVATION: boolean;
  136073. SHEEN: boolean;
  136074. SHEEN_TEXTURE: boolean;
  136075. SHEEN_TEXTUREDIRECTUV: number;
  136076. SHEEN_LINKWITHALBEDO: boolean;
  136077. SHEEN_ROUGHNESS: boolean;
  136078. SHEEN_ALBEDOSCALING: boolean;
  136079. SUBSURFACE: boolean;
  136080. SS_REFRACTION: boolean;
  136081. SS_TRANSLUCENCY: boolean;
  136082. SS_SCATTERING: boolean;
  136083. SS_THICKNESSANDMASK_TEXTURE: boolean;
  136084. SS_THICKNESSANDMASK_TEXTUREDIRECTUV: number;
  136085. SS_REFRACTIONMAP_3D: boolean;
  136086. SS_REFRACTIONMAP_OPPOSITEZ: boolean;
  136087. SS_LODINREFRACTIONALPHA: boolean;
  136088. SS_GAMMAREFRACTION: boolean;
  136089. SS_RGBDREFRACTION: boolean;
  136090. SS_LINEARSPECULARREFRACTION: boolean;
  136091. SS_LINKREFRACTIONTOTRANSPARENCY: boolean;
  136092. SS_ALBEDOFORREFRACTIONTINT: boolean;
  136093. SS_MASK_FROM_THICKNESS_TEXTURE: boolean;
  136094. UNLIT: boolean;
  136095. DEBUGMODE: number;
  136096. /**
  136097. * Initializes the PBR Material defines.
  136098. */
  136099. constructor();
  136100. /**
  136101. * Resets the PBR Material defines.
  136102. */
  136103. reset(): void;
  136104. }
  136105. /**
  136106. * The Physically based material base class of BJS.
  136107. *
  136108. * This offers the main features of a standard PBR material.
  136109. * For more information, please refer to the documentation :
  136110. * https://doc.babylonjs.com/how_to/physically_based_rendering
  136111. */
  136112. export abstract class PBRBaseMaterial extends PushMaterial {
  136113. /**
  136114. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  136115. */
  136116. static readonly PBRMATERIAL_OPAQUE: number;
  136117. /**
  136118. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  136119. */
  136120. static readonly PBRMATERIAL_ALPHATEST: number;
  136121. /**
  136122. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  136123. */
  136124. static readonly PBRMATERIAL_ALPHABLEND: number;
  136125. /**
  136126. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  136127. * They are also discarded below the alpha cutoff threshold to improve performances.
  136128. */
  136129. static readonly PBRMATERIAL_ALPHATESTANDBLEND: number;
  136130. /**
  136131. * Defines the default value of how much AO map is occluding the analytical lights
  136132. * (point spot...).
  136133. */
  136134. static DEFAULT_AO_ON_ANALYTICAL_LIGHTS: number;
  136135. /**
  136136. * PBRMaterialLightFalloff Physical: light is falling off following the inverse squared distance law.
  136137. */
  136138. static readonly LIGHTFALLOFF_PHYSICAL: number;
  136139. /**
  136140. * PBRMaterialLightFalloff gltf: light is falling off as described in the gltf moving to PBR document
  136141. * to enhance interoperability with other engines.
  136142. */
  136143. static readonly LIGHTFALLOFF_GLTF: number;
  136144. /**
  136145. * PBRMaterialLightFalloff Standard: light is falling off like in the standard material
  136146. * to enhance interoperability with other materials.
  136147. */
  136148. static readonly LIGHTFALLOFF_STANDARD: number;
  136149. /**
  136150. * Intensity of the direct lights e.g. the four lights available in your scene.
  136151. * This impacts both the direct diffuse and specular highlights.
  136152. */
  136153. protected _directIntensity: number;
  136154. /**
  136155. * Intensity of the emissive part of the material.
  136156. * This helps controlling the emissive effect without modifying the emissive color.
  136157. */
  136158. protected _emissiveIntensity: number;
  136159. /**
  136160. * Intensity of the environment e.g. how much the environment will light the object
  136161. * either through harmonics for rough material or through the refelction for shiny ones.
  136162. */
  136163. protected _environmentIntensity: number;
  136164. /**
  136165. * This is a special control allowing the reduction of the specular highlights coming from the
  136166. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  136167. */
  136168. protected _specularIntensity: number;
  136169. /**
  136170. * This stores the direct, emissive, environment, and specular light intensities into a Vector4.
  136171. */
  136172. private _lightingInfos;
  136173. /**
  136174. * Debug Control allowing disabling the bump map on this material.
  136175. */
  136176. protected _disableBumpMap: boolean;
  136177. /**
  136178. * AKA Diffuse Texture in standard nomenclature.
  136179. */
  136180. protected _albedoTexture: Nullable<BaseTexture>;
  136181. /**
  136182. * AKA Occlusion Texture in other nomenclature.
  136183. */
  136184. protected _ambientTexture: Nullable<BaseTexture>;
  136185. /**
  136186. * AKA Occlusion Texture Intensity in other nomenclature.
  136187. */
  136188. protected _ambientTextureStrength: number;
  136189. /**
  136190. * Defines how much the AO map is occluding the analytical lights (point spot...).
  136191. * 1 means it completely occludes it
  136192. * 0 mean it has no impact
  136193. */
  136194. protected _ambientTextureImpactOnAnalyticalLights: number;
  136195. /**
  136196. * Stores the alpha values in a texture.
  136197. */
  136198. protected _opacityTexture: Nullable<BaseTexture>;
  136199. /**
  136200. * Stores the reflection values in a texture.
  136201. */
  136202. protected _reflectionTexture: Nullable<BaseTexture>;
  136203. /**
  136204. * Stores the emissive values in a texture.
  136205. */
  136206. protected _emissiveTexture: Nullable<BaseTexture>;
  136207. /**
  136208. * AKA Specular texture in other nomenclature.
  136209. */
  136210. protected _reflectivityTexture: Nullable<BaseTexture>;
  136211. /**
  136212. * Used to switch from specular/glossiness to metallic/roughness workflow.
  136213. */
  136214. protected _metallicTexture: Nullable<BaseTexture>;
  136215. /**
  136216. * Specifies the metallic scalar of the metallic/roughness workflow.
  136217. * Can also be used to scale the metalness values of the metallic texture.
  136218. */
  136219. protected _metallic: Nullable<number>;
  136220. /**
  136221. * Specifies the roughness scalar of the metallic/roughness workflow.
  136222. * Can also be used to scale the roughness values of the metallic texture.
  136223. */
  136224. protected _roughness: Nullable<number>;
  136225. /**
  136226. * In metallic workflow, specifies an F0 factor to help configuring the material F0.
  136227. * By default the indexOfrefraction is used to compute F0;
  136228. *
  136229. * This is used as a factor against the default reflectance at normal incidence to tweak it.
  136230. *
  136231. * F0 = defaultF0 * metallicF0Factor * metallicReflectanceColor;
  136232. * F90 = metallicReflectanceColor;
  136233. */
  136234. protected _metallicF0Factor: number;
  136235. /**
  136236. * In metallic workflow, specifies an F90 color to help configuring the material F90.
  136237. * By default the F90 is always 1;
  136238. *
  136239. * Please note that this factor is also used as a factor against the default reflectance at normal incidence.
  136240. *
  136241. * F0 = defaultF0 * metallicF0Factor * metallicReflectanceColor
  136242. * F90 = metallicReflectanceColor;
  136243. */
  136244. protected _metallicReflectanceColor: Color3;
  136245. /**
  136246. * Defines to store metallicReflectanceColor in RGB and metallicF0Factor in A
  136247. * This is multiply against the scalar values defined in the material.
  136248. */
  136249. protected _metallicReflectanceTexture: Nullable<BaseTexture>;
  136250. /**
  136251. * Used to enable roughness/glossiness fetch from a separate channel depending on the current mode.
  136252. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  136253. */
  136254. protected _microSurfaceTexture: Nullable<BaseTexture>;
  136255. /**
  136256. * Stores surface normal data used to displace a mesh in a texture.
  136257. */
  136258. protected _bumpTexture: Nullable<BaseTexture>;
  136259. /**
  136260. * Stores the pre-calculated light information of a mesh in a texture.
  136261. */
  136262. protected _lightmapTexture: Nullable<BaseTexture>;
  136263. /**
  136264. * The color of a material in ambient lighting.
  136265. */
  136266. protected _ambientColor: Color3;
  136267. /**
  136268. * AKA Diffuse Color in other nomenclature.
  136269. */
  136270. protected _albedoColor: Color3;
  136271. /**
  136272. * AKA Specular Color in other nomenclature.
  136273. */
  136274. protected _reflectivityColor: Color3;
  136275. /**
  136276. * The color applied when light is reflected from a material.
  136277. */
  136278. protected _reflectionColor: Color3;
  136279. /**
  136280. * The color applied when light is emitted from a material.
  136281. */
  136282. protected _emissiveColor: Color3;
  136283. /**
  136284. * AKA Glossiness in other nomenclature.
  136285. */
  136286. protected _microSurface: number;
  136287. /**
  136288. * Specifies that the material will use the light map as a show map.
  136289. */
  136290. protected _useLightmapAsShadowmap: boolean;
  136291. /**
  136292. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  136293. * makes the reflect vector face the model (under horizon).
  136294. */
  136295. protected _useHorizonOcclusion: boolean;
  136296. /**
  136297. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  136298. * too much the area relying on ambient texture to define their ambient occlusion.
  136299. */
  136300. protected _useRadianceOcclusion: boolean;
  136301. /**
  136302. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  136303. */
  136304. protected _useAlphaFromAlbedoTexture: boolean;
  136305. /**
  136306. * Specifies that the material will keeps the specular highlights over a transparent surface (only the most limunous ones).
  136307. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  136308. */
  136309. protected _useSpecularOverAlpha: boolean;
  136310. /**
  136311. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  136312. */
  136313. protected _useMicroSurfaceFromReflectivityMapAlpha: boolean;
  136314. /**
  136315. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  136316. */
  136317. protected _useRoughnessFromMetallicTextureAlpha: boolean;
  136318. /**
  136319. * Specifies if the metallic texture contains the roughness information in its green channel.
  136320. */
  136321. protected _useRoughnessFromMetallicTextureGreen: boolean;
  136322. /**
  136323. * Specifies if the metallic texture contains the metallness information in its blue channel.
  136324. */
  136325. protected _useMetallnessFromMetallicTextureBlue: boolean;
  136326. /**
  136327. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  136328. */
  136329. protected _useAmbientOcclusionFromMetallicTextureRed: boolean;
  136330. /**
  136331. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  136332. */
  136333. protected _useAmbientInGrayScale: boolean;
  136334. /**
  136335. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  136336. * The material will try to infer what glossiness each pixel should be.
  136337. */
  136338. protected _useAutoMicroSurfaceFromReflectivityMap: boolean;
  136339. /**
  136340. * Defines the falloff type used in this material.
  136341. * It by default is Physical.
  136342. */
  136343. protected _lightFalloff: number;
  136344. /**
  136345. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  136346. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  136347. */
  136348. protected _useRadianceOverAlpha: boolean;
  136349. /**
  136350. * Allows using an object space normal map (instead of tangent space).
  136351. */
  136352. protected _useObjectSpaceNormalMap: boolean;
  136353. /**
  136354. * Allows using the bump map in parallax mode.
  136355. */
  136356. protected _useParallax: boolean;
  136357. /**
  136358. * Allows using the bump map in parallax occlusion mode.
  136359. */
  136360. protected _useParallaxOcclusion: boolean;
  136361. /**
  136362. * Controls the scale bias of the parallax mode.
  136363. */
  136364. protected _parallaxScaleBias: number;
  136365. /**
  136366. * If sets to true, disables all the lights affecting the material.
  136367. */
  136368. protected _disableLighting: boolean;
  136369. /**
  136370. * Number of Simultaneous lights allowed on the material.
  136371. */
  136372. protected _maxSimultaneousLights: number;
  136373. /**
  136374. * If sets to true, x component of normal map value will be inverted (x = 1.0 - x).
  136375. */
  136376. protected _invertNormalMapX: boolean;
  136377. /**
  136378. * If sets to true, y component of normal map value will be inverted (y = 1.0 - y).
  136379. */
  136380. protected _invertNormalMapY: boolean;
  136381. /**
  136382. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  136383. */
  136384. protected _twoSidedLighting: boolean;
  136385. /**
  136386. * Defines the alpha limits in alpha test mode.
  136387. */
  136388. protected _alphaCutOff: number;
  136389. /**
  136390. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  136391. */
  136392. protected _forceAlphaTest: boolean;
  136393. /**
  136394. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  136395. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  136396. */
  136397. protected _useAlphaFresnel: boolean;
  136398. /**
  136399. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  136400. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  136401. */
  136402. protected _useLinearAlphaFresnel: boolean;
  136403. /**
  136404. * Specifies the environment BRDF texture used to comput the scale and offset roughness values
  136405. * from cos thetav and roughness:
  136406. * http://blog.selfshadow.com/publications/s2013-shading-course/karis/s2013_pbs_epic_notes_v2.pdf
  136407. */
  136408. protected _environmentBRDFTexture: Nullable<BaseTexture>;
  136409. /**
  136410. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  136411. */
  136412. protected _forceIrradianceInFragment: boolean;
  136413. private _realTimeFiltering;
  136414. /**
  136415. * Enables realtime filtering on the texture.
  136416. */
  136417. get realTimeFiltering(): boolean;
  136418. set realTimeFiltering(b: boolean);
  136419. private _realTimeFilteringQuality;
  136420. /**
  136421. * Quality switch for realtime filtering
  136422. */
  136423. get realTimeFilteringQuality(): number;
  136424. set realTimeFilteringQuality(n: number);
  136425. /**
  136426. * Can this material render to several textures at once
  136427. */
  136428. get canRenderToMRT(): boolean;
  136429. /**
  136430. * Force normal to face away from face.
  136431. */
  136432. protected _forceNormalForward: boolean;
  136433. /**
  136434. * Enables specular anti aliasing in the PBR shader.
  136435. * It will both interacts on the Geometry for analytical and IBL lighting.
  136436. * It also prefilter the roughness map based on the bump values.
  136437. */
  136438. protected _enableSpecularAntiAliasing: boolean;
  136439. /**
  136440. * Default configuration related to image processing available in the PBR Material.
  136441. */
  136442. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  136443. /**
  136444. * Keep track of the image processing observer to allow dispose and replace.
  136445. */
  136446. private _imageProcessingObserver;
  136447. /**
  136448. * Attaches a new image processing configuration to the PBR Material.
  136449. * @param configuration
  136450. */
  136451. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  136452. /**
  136453. * Stores the available render targets.
  136454. */
  136455. private _renderTargets;
  136456. /**
  136457. * Sets the global ambient color for the material used in lighting calculations.
  136458. */
  136459. private _globalAmbientColor;
  136460. /**
  136461. * Enables the use of logarithmic depth buffers, which is good for wide depth buffers.
  136462. */
  136463. private _useLogarithmicDepth;
  136464. /**
  136465. * If set to true, no lighting calculations will be applied.
  136466. */
  136467. private _unlit;
  136468. private _debugMode;
  136469. /**
  136470. * @hidden
  136471. * This is reserved for the inspector.
  136472. * Defines the material debug mode.
  136473. * It helps seeing only some components of the material while troubleshooting.
  136474. */
  136475. debugMode: number;
  136476. /**
  136477. * @hidden
  136478. * This is reserved for the inspector.
  136479. * Specify from where on screen the debug mode should start.
  136480. * The value goes from -1 (full screen) to 1 (not visible)
  136481. * It helps with side by side comparison against the final render
  136482. * This defaults to -1
  136483. */
  136484. private debugLimit;
  136485. /**
  136486. * @hidden
  136487. * This is reserved for the inspector.
  136488. * As the default viewing range might not be enough (if the ambient is really small for instance)
  136489. * You can use the factor to better multiply the final value.
  136490. */
  136491. private debugFactor;
  136492. /**
  136493. * Defines the clear coat layer parameters for the material.
  136494. */
  136495. readonly clearCoat: PBRClearCoatConfiguration;
  136496. /**
  136497. * Defines the anisotropic parameters for the material.
  136498. */
  136499. readonly anisotropy: PBRAnisotropicConfiguration;
  136500. /**
  136501. * Defines the BRDF parameters for the material.
  136502. */
  136503. readonly brdf: PBRBRDFConfiguration;
  136504. /**
  136505. * Defines the Sheen parameters for the material.
  136506. */
  136507. readonly sheen: PBRSheenConfiguration;
  136508. /**
  136509. * Defines the SubSurface parameters for the material.
  136510. */
  136511. readonly subSurface: PBRSubSurfaceConfiguration;
  136512. /**
  136513. * Defines the detail map parameters for the material.
  136514. */
  136515. readonly detailMap: DetailMapConfiguration;
  136516. protected _rebuildInParallel: boolean;
  136517. /**
  136518. * Instantiates a new PBRMaterial instance.
  136519. *
  136520. * @param name The material name
  136521. * @param scene The scene the material will be use in.
  136522. */
  136523. constructor(name: string, scene: Scene);
  136524. /**
  136525. * Gets a boolean indicating that current material needs to register RTT
  136526. */
  136527. get hasRenderTargetTextures(): boolean;
  136528. /**
  136529. * Gets the name of the material class.
  136530. */
  136531. getClassName(): string;
  136532. /**
  136533. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  136534. */
  136535. get useLogarithmicDepth(): boolean;
  136536. /**
  136537. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  136538. */
  136539. set useLogarithmicDepth(value: boolean);
  136540. /**
  136541. * Returns true if alpha blending should be disabled.
  136542. */
  136543. protected get _disableAlphaBlending(): boolean;
  136544. /**
  136545. * Specifies whether or not this material should be rendered in alpha blend mode.
  136546. */
  136547. needAlphaBlending(): boolean;
  136548. /**
  136549. * Specifies whether or not this material should be rendered in alpha test mode.
  136550. */
  136551. needAlphaTesting(): boolean;
  136552. /**
  136553. * Specifies whether or not the alpha value of the albedo texture should be used for alpha blending.
  136554. */
  136555. protected _shouldUseAlphaFromAlbedoTexture(): boolean;
  136556. /**
  136557. * Gets the texture used for the alpha test.
  136558. */
  136559. getAlphaTestTexture(): Nullable<BaseTexture>;
  136560. /**
  136561. * Specifies that the submesh is ready to be used.
  136562. * @param mesh - BJS mesh.
  136563. * @param subMesh - A submesh of the BJS mesh. Used to check if it is ready.
  136564. * @param useInstances - Specifies that instances should be used.
  136565. * @returns - boolean indicating that the submesh is ready or not.
  136566. */
  136567. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  136568. /**
  136569. * Specifies if the material uses metallic roughness workflow.
  136570. * @returns boolean specifiying if the material uses metallic roughness workflow.
  136571. */
  136572. isMetallicWorkflow(): boolean;
  136573. private _prepareEffect;
  136574. private _prepareDefines;
  136575. /**
  136576. * Force shader compilation
  136577. */
  136578. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<IMaterialCompilationOptions>): void;
  136579. /**
  136580. * Initializes the uniform buffer layout for the shader.
  136581. */
  136582. buildUniformLayout(): void;
  136583. /**
  136584. * Unbinds the material from the mesh
  136585. */
  136586. unbind(): void;
  136587. /**
  136588. * Binds the submesh data.
  136589. * @param world - The world matrix.
  136590. * @param mesh - The BJS mesh.
  136591. * @param subMesh - A submesh of the BJS mesh.
  136592. */
  136593. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  136594. /**
  136595. * Returns the animatable textures.
  136596. * @returns - Array of animatable textures.
  136597. */
  136598. getAnimatables(): IAnimatable[];
  136599. /**
  136600. * Returns the texture used for reflections.
  136601. * @returns - Reflection texture if present. Otherwise, returns the environment texture.
  136602. */
  136603. private _getReflectionTexture;
  136604. /**
  136605. * Returns an array of the actively used textures.
  136606. * @returns - Array of BaseTextures
  136607. */
  136608. getActiveTextures(): BaseTexture[];
  136609. /**
  136610. * Checks to see if a texture is used in the material.
  136611. * @param texture - Base texture to use.
  136612. * @returns - Boolean specifying if a texture is used in the material.
  136613. */
  136614. hasTexture(texture: BaseTexture): boolean;
  136615. /**
  136616. * Sets the required values to the prepass renderer.
  136617. * @param prePassRenderer defines the prepass renderer to setup
  136618. */
  136619. setPrePassRenderer(prePassRenderer: PrePassRenderer): boolean;
  136620. /**
  136621. * Disposes the resources of the material.
  136622. * @param forceDisposeEffect - Forces the disposal of effects.
  136623. * @param forceDisposeTextures - Forces the disposal of all textures.
  136624. */
  136625. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  136626. }
  136627. }
  136628. declare module BABYLON {
  136629. /**
  136630. * The Physically based material of BJS.
  136631. *
  136632. * This offers the main features of a standard PBR material.
  136633. * For more information, please refer to the documentation :
  136634. * https://doc.babylonjs.com/how_to/physically_based_rendering
  136635. */
  136636. export class PBRMaterial extends PBRBaseMaterial {
  136637. /**
  136638. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  136639. */
  136640. static readonly PBRMATERIAL_OPAQUE: number;
  136641. /**
  136642. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  136643. */
  136644. static readonly PBRMATERIAL_ALPHATEST: number;
  136645. /**
  136646. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  136647. */
  136648. static readonly PBRMATERIAL_ALPHABLEND: number;
  136649. /**
  136650. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  136651. * They are also discarded below the alpha cutoff threshold to improve performances.
  136652. */
  136653. static readonly PBRMATERIAL_ALPHATESTANDBLEND: number;
  136654. /**
  136655. * Defines the default value of how much AO map is occluding the analytical lights
  136656. * (point spot...).
  136657. */
  136658. static DEFAULT_AO_ON_ANALYTICAL_LIGHTS: number;
  136659. /**
  136660. * Intensity of the direct lights e.g. the four lights available in your scene.
  136661. * This impacts both the direct diffuse and specular highlights.
  136662. */
  136663. directIntensity: number;
  136664. /**
  136665. * Intensity of the emissive part of the material.
  136666. * This helps controlling the emissive effect without modifying the emissive color.
  136667. */
  136668. emissiveIntensity: number;
  136669. /**
  136670. * Intensity of the environment e.g. how much the environment will light the object
  136671. * either through harmonics for rough material or through the refelction for shiny ones.
  136672. */
  136673. environmentIntensity: number;
  136674. /**
  136675. * This is a special control allowing the reduction of the specular highlights coming from the
  136676. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  136677. */
  136678. specularIntensity: number;
  136679. /**
  136680. * Debug Control allowing disabling the bump map on this material.
  136681. */
  136682. disableBumpMap: boolean;
  136683. /**
  136684. * AKA Diffuse Texture in standard nomenclature.
  136685. */
  136686. albedoTexture: BaseTexture;
  136687. /**
  136688. * AKA Occlusion Texture in other nomenclature.
  136689. */
  136690. ambientTexture: BaseTexture;
  136691. /**
  136692. * AKA Occlusion Texture Intensity in other nomenclature.
  136693. */
  136694. ambientTextureStrength: number;
  136695. /**
  136696. * Defines how much the AO map is occluding the analytical lights (point spot...).
  136697. * 1 means it completely occludes it
  136698. * 0 mean it has no impact
  136699. */
  136700. ambientTextureImpactOnAnalyticalLights: number;
  136701. /**
  136702. * Stores the alpha values in a texture. Use luminance if texture.getAlphaFromRGB is true.
  136703. */
  136704. opacityTexture: BaseTexture;
  136705. /**
  136706. * Stores the reflection values in a texture.
  136707. */
  136708. reflectionTexture: Nullable<BaseTexture>;
  136709. /**
  136710. * Stores the emissive values in a texture.
  136711. */
  136712. emissiveTexture: BaseTexture;
  136713. /**
  136714. * AKA Specular texture in other nomenclature.
  136715. */
  136716. reflectivityTexture: BaseTexture;
  136717. /**
  136718. * Used to switch from specular/glossiness to metallic/roughness workflow.
  136719. */
  136720. metallicTexture: BaseTexture;
  136721. /**
  136722. * Specifies the metallic scalar of the metallic/roughness workflow.
  136723. * Can also be used to scale the metalness values of the metallic texture.
  136724. */
  136725. metallic: Nullable<number>;
  136726. /**
  136727. * Specifies the roughness scalar of the metallic/roughness workflow.
  136728. * Can also be used to scale the roughness values of the metallic texture.
  136729. */
  136730. roughness: Nullable<number>;
  136731. /**
  136732. * In metallic workflow, specifies an F0 factor to help configuring the material F0.
  136733. * By default the indexOfrefraction is used to compute F0;
  136734. *
  136735. * This is used as a factor against the default reflectance at normal incidence to tweak it.
  136736. *
  136737. * F0 = defaultF0 * metallicF0Factor * metallicReflectanceColor;
  136738. * F90 = metallicReflectanceColor;
  136739. */
  136740. metallicF0Factor: number;
  136741. /**
  136742. * In metallic workflow, specifies an F90 color to help configuring the material F90.
  136743. * By default the F90 is always 1;
  136744. *
  136745. * Please note that this factor is also used as a factor against the default reflectance at normal incidence.
  136746. *
  136747. * F0 = defaultF0 * metallicF0Factor * metallicReflectanceColor
  136748. * F90 = metallicReflectanceColor;
  136749. */
  136750. metallicReflectanceColor: Color3;
  136751. /**
  136752. * Defines to store metallicReflectanceColor in RGB and metallicF0Factor in A
  136753. * This is multiply against the scalar values defined in the material.
  136754. */
  136755. metallicReflectanceTexture: Nullable<BaseTexture>;
  136756. /**
  136757. * Used to enable roughness/glossiness fetch from a separate channel depending on the current mode.
  136758. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  136759. */
  136760. microSurfaceTexture: BaseTexture;
  136761. /**
  136762. * Stores surface normal data used to displace a mesh in a texture.
  136763. */
  136764. bumpTexture: BaseTexture;
  136765. /**
  136766. * Stores the pre-calculated light information of a mesh in a texture.
  136767. */
  136768. lightmapTexture: BaseTexture;
  136769. /**
  136770. * Stores the refracted light information in a texture.
  136771. */
  136772. get refractionTexture(): Nullable<BaseTexture>;
  136773. set refractionTexture(value: Nullable<BaseTexture>);
  136774. /**
  136775. * The color of a material in ambient lighting.
  136776. */
  136777. ambientColor: Color3;
  136778. /**
  136779. * AKA Diffuse Color in other nomenclature.
  136780. */
  136781. albedoColor: Color3;
  136782. /**
  136783. * AKA Specular Color in other nomenclature.
  136784. */
  136785. reflectivityColor: Color3;
  136786. /**
  136787. * The color reflected from the material.
  136788. */
  136789. reflectionColor: Color3;
  136790. /**
  136791. * The color emitted from the material.
  136792. */
  136793. emissiveColor: Color3;
  136794. /**
  136795. * AKA Glossiness in other nomenclature.
  136796. */
  136797. microSurface: number;
  136798. /**
  136799. * Index of refraction of the material base layer.
  136800. * https://en.wikipedia.org/wiki/List_of_refractive_indices
  136801. *
  136802. * This does not only impact refraction but also the Base F0 of Dielectric Materials.
  136803. *
  136804. * From dielectric fresnel rules: F0 = square((iorT - iorI) / (iorT + iorI))
  136805. */
  136806. get indexOfRefraction(): number;
  136807. set indexOfRefraction(value: number);
  136808. /**
  136809. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  136810. */
  136811. get invertRefractionY(): boolean;
  136812. set invertRefractionY(value: boolean);
  136813. /**
  136814. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  136815. * Materials half opaque for instance using refraction could benefit from this control.
  136816. */
  136817. get linkRefractionWithTransparency(): boolean;
  136818. set linkRefractionWithTransparency(value: boolean);
  136819. /**
  136820. * If true, the light map contains occlusion information instead of lighting info.
  136821. */
  136822. useLightmapAsShadowmap: boolean;
  136823. /**
  136824. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  136825. */
  136826. useAlphaFromAlbedoTexture: boolean;
  136827. /**
  136828. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  136829. */
  136830. forceAlphaTest: boolean;
  136831. /**
  136832. * Defines the alpha limits in alpha test mode.
  136833. */
  136834. alphaCutOff: number;
  136835. /**
  136836. * Specifies that the material will keep the specular highlights over a transparent surface (only the most limunous ones).
  136837. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  136838. */
  136839. useSpecularOverAlpha: boolean;
  136840. /**
  136841. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  136842. */
  136843. useMicroSurfaceFromReflectivityMapAlpha: boolean;
  136844. /**
  136845. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  136846. */
  136847. useRoughnessFromMetallicTextureAlpha: boolean;
  136848. /**
  136849. * Specifies if the metallic texture contains the roughness information in its green channel.
  136850. */
  136851. useRoughnessFromMetallicTextureGreen: boolean;
  136852. /**
  136853. * Specifies if the metallic texture contains the metallness information in its blue channel.
  136854. */
  136855. useMetallnessFromMetallicTextureBlue: boolean;
  136856. /**
  136857. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  136858. */
  136859. useAmbientOcclusionFromMetallicTextureRed: boolean;
  136860. /**
  136861. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  136862. */
  136863. useAmbientInGrayScale: boolean;
  136864. /**
  136865. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  136866. * The material will try to infer what glossiness each pixel should be.
  136867. */
  136868. useAutoMicroSurfaceFromReflectivityMap: boolean;
  136869. /**
  136870. * BJS is using an harcoded light falloff based on a manually sets up range.
  136871. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  136872. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  136873. */
  136874. get usePhysicalLightFalloff(): boolean;
  136875. /**
  136876. * BJS is using an harcoded light falloff based on a manually sets up range.
  136877. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  136878. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  136879. */
  136880. set usePhysicalLightFalloff(value: boolean);
  136881. /**
  136882. * In order to support the falloff compatibility with gltf, a special mode has been added
  136883. * to reproduce the gltf light falloff.
  136884. */
  136885. get useGLTFLightFalloff(): boolean;
  136886. /**
  136887. * In order to support the falloff compatibility with gltf, a special mode has been added
  136888. * to reproduce the gltf light falloff.
  136889. */
  136890. set useGLTFLightFalloff(value: boolean);
  136891. /**
  136892. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  136893. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  136894. */
  136895. useRadianceOverAlpha: boolean;
  136896. /**
  136897. * Allows using an object space normal map (instead of tangent space).
  136898. */
  136899. useObjectSpaceNormalMap: boolean;
  136900. /**
  136901. * Allows using the bump map in parallax mode.
  136902. */
  136903. useParallax: boolean;
  136904. /**
  136905. * Allows using the bump map in parallax occlusion mode.
  136906. */
  136907. useParallaxOcclusion: boolean;
  136908. /**
  136909. * Controls the scale bias of the parallax mode.
  136910. */
  136911. parallaxScaleBias: number;
  136912. /**
  136913. * If sets to true, disables all the lights affecting the material.
  136914. */
  136915. disableLighting: boolean;
  136916. /**
  136917. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  136918. */
  136919. forceIrradianceInFragment: boolean;
  136920. /**
  136921. * Number of Simultaneous lights allowed on the material.
  136922. */
  136923. maxSimultaneousLights: number;
  136924. /**
  136925. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  136926. */
  136927. invertNormalMapX: boolean;
  136928. /**
  136929. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  136930. */
  136931. invertNormalMapY: boolean;
  136932. /**
  136933. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  136934. */
  136935. twoSidedLighting: boolean;
  136936. /**
  136937. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  136938. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  136939. */
  136940. useAlphaFresnel: boolean;
  136941. /**
  136942. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  136943. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  136944. */
  136945. useLinearAlphaFresnel: boolean;
  136946. /**
  136947. * Let user defines the brdf lookup texture used for IBL.
  136948. * A default 8bit version is embedded but you could point at :
  136949. * * Default texture: https://assets.babylonjs.com/environments/correlatedMSBRDF_RGBD.png
  136950. * * Default 16bit pixel depth texture: https://assets.babylonjs.com/environments/correlatedMSBRDF.dds
  136951. * * LEGACY Default None correlated https://assets.babylonjs.com/environments/uncorrelatedBRDF_RGBD.png
  136952. * * LEGACY Default None correlated 16bit pixel depth https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds
  136953. */
  136954. environmentBRDFTexture: Nullable<BaseTexture>;
  136955. /**
  136956. * Force normal to face away from face.
  136957. */
  136958. forceNormalForward: boolean;
  136959. /**
  136960. * Enables specular anti aliasing in the PBR shader.
  136961. * It will both interacts on the Geometry for analytical and IBL lighting.
  136962. * It also prefilter the roughness map based on the bump values.
  136963. */
  136964. enableSpecularAntiAliasing: boolean;
  136965. /**
  136966. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  136967. * makes the reflect vector face the model (under horizon).
  136968. */
  136969. useHorizonOcclusion: boolean;
  136970. /**
  136971. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  136972. * too much the area relying on ambient texture to define their ambient occlusion.
  136973. */
  136974. useRadianceOcclusion: boolean;
  136975. /**
  136976. * If set to true, no lighting calculations will be applied.
  136977. */
  136978. unlit: boolean;
  136979. /**
  136980. * Gets the image processing configuration used either in this material.
  136981. */
  136982. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  136983. /**
  136984. * Sets the Default image processing configuration used either in the this material.
  136985. *
  136986. * If sets to null, the scene one is in use.
  136987. */
  136988. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  136989. /**
  136990. * Gets wether the color curves effect is enabled.
  136991. */
  136992. get cameraColorCurvesEnabled(): boolean;
  136993. /**
  136994. * Sets wether the color curves effect is enabled.
  136995. */
  136996. set cameraColorCurvesEnabled(value: boolean);
  136997. /**
  136998. * Gets wether the color grading effect is enabled.
  136999. */
  137000. get cameraColorGradingEnabled(): boolean;
  137001. /**
  137002. * Gets wether the color grading effect is enabled.
  137003. */
  137004. set cameraColorGradingEnabled(value: boolean);
  137005. /**
  137006. * Gets wether tonemapping is enabled or not.
  137007. */
  137008. get cameraToneMappingEnabled(): boolean;
  137009. /**
  137010. * Sets wether tonemapping is enabled or not
  137011. */
  137012. set cameraToneMappingEnabled(value: boolean);
  137013. /**
  137014. * The camera exposure used on this material.
  137015. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  137016. * This corresponds to a photographic exposure.
  137017. */
  137018. get cameraExposure(): number;
  137019. /**
  137020. * The camera exposure used on this material.
  137021. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  137022. * This corresponds to a photographic exposure.
  137023. */
  137024. set cameraExposure(value: number);
  137025. /**
  137026. * Gets The camera contrast used on this material.
  137027. */
  137028. get cameraContrast(): number;
  137029. /**
  137030. * Sets The camera contrast used on this material.
  137031. */
  137032. set cameraContrast(value: number);
  137033. /**
  137034. * Gets the Color Grading 2D Lookup Texture.
  137035. */
  137036. get cameraColorGradingTexture(): Nullable<BaseTexture>;
  137037. /**
  137038. * Sets the Color Grading 2D Lookup Texture.
  137039. */
  137040. set cameraColorGradingTexture(value: Nullable<BaseTexture>);
  137041. /**
  137042. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  137043. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  137044. * 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;
  137045. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  137046. */
  137047. get cameraColorCurves(): Nullable<ColorCurves>;
  137048. /**
  137049. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  137050. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  137051. * 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;
  137052. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  137053. */
  137054. set cameraColorCurves(value: Nullable<ColorCurves>);
  137055. /**
  137056. * Instantiates a new PBRMaterial instance.
  137057. *
  137058. * @param name The material name
  137059. * @param scene The scene the material will be use in.
  137060. */
  137061. constructor(name: string, scene: Scene);
  137062. /**
  137063. * Returns the name of this material class.
  137064. */
  137065. getClassName(): string;
  137066. /**
  137067. * Makes a duplicate of the current material.
  137068. * @param name - name to use for the new material.
  137069. */
  137070. clone(name: string): PBRMaterial;
  137071. /**
  137072. * Serializes this PBR Material.
  137073. * @returns - An object with the serialized material.
  137074. */
  137075. serialize(): any;
  137076. /**
  137077. * Parses a PBR Material from a serialized object.
  137078. * @param source - Serialized object.
  137079. * @param scene - BJS scene instance.
  137080. * @param rootUrl - url for the scene object
  137081. * @returns - PBRMaterial
  137082. */
  137083. static Parse(source: any, scene: Scene, rootUrl: string): PBRMaterial;
  137084. }
  137085. }
  137086. declare module BABYLON {
  137087. /**
  137088. * Direct draw surface info
  137089. * @see https://docs.microsoft.com/en-us/windows/desktop/direct3ddds/dx-graphics-dds-pguide
  137090. */
  137091. export interface DDSInfo {
  137092. /**
  137093. * Width of the texture
  137094. */
  137095. width: number;
  137096. /**
  137097. * Width of the texture
  137098. */
  137099. height: number;
  137100. /**
  137101. * Number of Mipmaps for the texture
  137102. * @see https://en.wikipedia.org/wiki/Mipmap
  137103. */
  137104. mipmapCount: number;
  137105. /**
  137106. * If the textures format is a known fourCC format
  137107. * @see https://www.fourcc.org/
  137108. */
  137109. isFourCC: boolean;
  137110. /**
  137111. * If the texture is an RGB format eg. DXGI_FORMAT_B8G8R8X8_UNORM format
  137112. */
  137113. isRGB: boolean;
  137114. /**
  137115. * If the texture is a lumincance format
  137116. */
  137117. isLuminance: boolean;
  137118. /**
  137119. * If this is a cube texture
  137120. * @see https://docs.microsoft.com/en-us/windows/desktop/direct3ddds/dds-file-layout-for-cubic-environment-maps
  137121. */
  137122. isCube: boolean;
  137123. /**
  137124. * If the texture is a compressed format eg. FOURCC_DXT1
  137125. */
  137126. isCompressed: boolean;
  137127. /**
  137128. * The dxgiFormat of the texture
  137129. * @see https://docs.microsoft.com/en-us/windows/desktop/api/dxgiformat/ne-dxgiformat-dxgi_format
  137130. */
  137131. dxgiFormat: number;
  137132. /**
  137133. * Texture type eg. Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT
  137134. */
  137135. textureType: number;
  137136. /**
  137137. * Sphericle polynomial created for the dds texture
  137138. */
  137139. sphericalPolynomial?: SphericalPolynomial;
  137140. }
  137141. /**
  137142. * Class used to provide DDS decompression tools
  137143. */
  137144. export class DDSTools {
  137145. /**
  137146. * Gets or sets a boolean indicating that LOD info is stored in alpha channel (false by default)
  137147. */
  137148. static StoreLODInAlphaChannel: boolean;
  137149. /**
  137150. * Gets DDS information from an array buffer
  137151. * @param data defines the array buffer view to read data from
  137152. * @returns the DDS information
  137153. */
  137154. static GetDDSInfo(data: ArrayBufferView): DDSInfo;
  137155. private static _FloatView;
  137156. private static _Int32View;
  137157. private static _ToHalfFloat;
  137158. private static _FromHalfFloat;
  137159. private static _GetHalfFloatAsFloatRGBAArrayBuffer;
  137160. private static _GetHalfFloatRGBAArrayBuffer;
  137161. private static _GetFloatRGBAArrayBuffer;
  137162. private static _GetFloatAsUIntRGBAArrayBuffer;
  137163. private static _GetHalfFloatAsUIntRGBAArrayBuffer;
  137164. private static _GetRGBAArrayBuffer;
  137165. private static _ExtractLongWordOrder;
  137166. private static _GetRGBArrayBuffer;
  137167. private static _GetLuminanceArrayBuffer;
  137168. /**
  137169. * Uploads DDS Levels to a Babylon Texture
  137170. * @hidden
  137171. */
  137172. static UploadDDSLevels(engine: ThinEngine, texture: InternalTexture, data: ArrayBufferView, info: DDSInfo, loadMipmaps: boolean, faces: number, lodIndex?: number, currentFace?: number): void;
  137173. }
  137174. interface ThinEngine {
  137175. /**
  137176. * Create a cube texture from prefiltered data (ie. the mipmaps contain ready to use data for PBR reflection)
  137177. * @param rootUrl defines the url where the file to load is located
  137178. * @param scene defines the current scene
  137179. * @param lodScale defines scale to apply to the mip map selection
  137180. * @param lodOffset defines offset to apply to the mip map selection
  137181. * @param onLoad defines an optional callback raised when the texture is loaded
  137182. * @param onError defines an optional callback raised if there is an issue to load the texture
  137183. * @param format defines the format of the data
  137184. * @param forcedExtension defines the extension to use to pick the right loader
  137185. * @param createPolynomials defines wheter or not to create polynomails harmonics for the texture
  137186. * @returns the cube texture as an InternalTexture
  137187. */
  137188. 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;
  137189. }
  137190. }
  137191. declare module BABYLON {
  137192. /**
  137193. * Implementation of the DDS Texture Loader.
  137194. * @hidden
  137195. */
  137196. export class _DDSTextureLoader implements IInternalTextureLoader {
  137197. /**
  137198. * Defines wether the loader supports cascade loading the different faces.
  137199. */
  137200. readonly supportCascades: boolean;
  137201. /**
  137202. * This returns if the loader support the current file information.
  137203. * @param extension defines the file extension of the file being loaded
  137204. * @returns true if the loader can load the specified file
  137205. */
  137206. canLoad(extension: string): boolean;
  137207. /**
  137208. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  137209. * @param data contains the texture data
  137210. * @param texture defines the BabylonJS internal texture
  137211. * @param createPolynomials will be true if polynomials have been requested
  137212. * @param onLoad defines the callback to trigger once the texture is ready
  137213. * @param onError defines the callback to trigger in case of error
  137214. */
  137215. loadCubeData(imgs: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  137216. /**
  137217. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  137218. * @param data contains the texture data
  137219. * @param texture defines the BabylonJS internal texture
  137220. * @param callback defines the method to call once ready to upload
  137221. */
  137222. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  137223. }
  137224. }
  137225. declare module BABYLON {
  137226. /**
  137227. * Implementation of the ENV Texture Loader.
  137228. * @hidden
  137229. */
  137230. export class _ENVTextureLoader implements IInternalTextureLoader {
  137231. /**
  137232. * Defines wether the loader supports cascade loading the different faces.
  137233. */
  137234. readonly supportCascades: boolean;
  137235. /**
  137236. * This returns if the loader support the current file information.
  137237. * @param extension defines the file extension of the file being loaded
  137238. * @returns true if the loader can load the specified file
  137239. */
  137240. canLoad(extension: string): boolean;
  137241. /**
  137242. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  137243. * @param data contains the texture data
  137244. * @param texture defines the BabylonJS internal texture
  137245. * @param createPolynomials will be true if polynomials have been requested
  137246. * @param onLoad defines the callback to trigger once the texture is ready
  137247. * @param onError defines the callback to trigger in case of error
  137248. */
  137249. loadCubeData(data: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  137250. /**
  137251. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  137252. * @param data contains the texture data
  137253. * @param texture defines the BabylonJS internal texture
  137254. * @param callback defines the method to call once ready to upload
  137255. */
  137256. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  137257. }
  137258. }
  137259. declare module BABYLON {
  137260. /**
  137261. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  137262. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  137263. */
  137264. export class KhronosTextureContainer {
  137265. /** contents of the KTX container file */
  137266. data: ArrayBufferView;
  137267. private static HEADER_LEN;
  137268. private static COMPRESSED_2D;
  137269. private static COMPRESSED_3D;
  137270. private static TEX_2D;
  137271. private static TEX_3D;
  137272. /**
  137273. * Gets the openGL type
  137274. */
  137275. glType: number;
  137276. /**
  137277. * Gets the openGL type size
  137278. */
  137279. glTypeSize: number;
  137280. /**
  137281. * Gets the openGL format
  137282. */
  137283. glFormat: number;
  137284. /**
  137285. * Gets the openGL internal format
  137286. */
  137287. glInternalFormat: number;
  137288. /**
  137289. * Gets the base internal format
  137290. */
  137291. glBaseInternalFormat: number;
  137292. /**
  137293. * Gets image width in pixel
  137294. */
  137295. pixelWidth: number;
  137296. /**
  137297. * Gets image height in pixel
  137298. */
  137299. pixelHeight: number;
  137300. /**
  137301. * Gets image depth in pixels
  137302. */
  137303. pixelDepth: number;
  137304. /**
  137305. * Gets the number of array elements
  137306. */
  137307. numberOfArrayElements: number;
  137308. /**
  137309. * Gets the number of faces
  137310. */
  137311. numberOfFaces: number;
  137312. /**
  137313. * Gets the number of mipmap levels
  137314. */
  137315. numberOfMipmapLevels: number;
  137316. /**
  137317. * Gets the bytes of key value data
  137318. */
  137319. bytesOfKeyValueData: number;
  137320. /**
  137321. * Gets the load type
  137322. */
  137323. loadType: number;
  137324. /**
  137325. * If the container has been made invalid (eg. constructor failed to correctly load array buffer)
  137326. */
  137327. isInvalid: boolean;
  137328. /**
  137329. * Creates a new KhronosTextureContainer
  137330. * @param data contents of the KTX container file
  137331. * @param facesExpected should be either 1 or 6, based whether a cube texture or or
  137332. * @param threeDExpected provision for indicating that data should be a 3D texture, not implemented
  137333. * @param textureArrayExpected provision for indicating that data should be a texture array, not implemented
  137334. */
  137335. constructor(
  137336. /** contents of the KTX container file */
  137337. data: ArrayBufferView, facesExpected: number, threeDExpected?: boolean, textureArrayExpected?: boolean);
  137338. /**
  137339. * Uploads KTX content to a Babylon Texture.
  137340. * It is assumed that the texture has already been created & is currently bound
  137341. * @hidden
  137342. */
  137343. uploadLevels(texture: InternalTexture, loadMipmaps: boolean): void;
  137344. private _upload2DCompressedLevels;
  137345. /**
  137346. * Checks if the given data starts with a KTX file identifier.
  137347. * @param data the data to check
  137348. * @returns true if the data is a KTX file or false otherwise
  137349. */
  137350. static IsValid(data: ArrayBufferView): boolean;
  137351. }
  137352. }
  137353. declare module BABYLON {
  137354. /**
  137355. * Class for loading KTX2 files
  137356. * !!! Experimental Extension Subject to Changes !!!
  137357. * @hidden
  137358. */
  137359. export class KhronosTextureContainer2 {
  137360. private static _ModulePromise;
  137361. private static _TranscodeFormat;
  137362. constructor(engine: ThinEngine);
  137363. uploadAsync(data: ArrayBufferView, internalTexture: InternalTexture): Promise<void>;
  137364. private _determineTranscodeFormat;
  137365. /**
  137366. * Checks if the given data starts with a KTX2 file identifier.
  137367. * @param data the data to check
  137368. * @returns true if the data is a KTX2 file or false otherwise
  137369. */
  137370. static IsValid(data: ArrayBufferView): boolean;
  137371. }
  137372. }
  137373. declare module BABYLON {
  137374. /**
  137375. * Implementation of the KTX Texture Loader.
  137376. * @hidden
  137377. */
  137378. export class _KTXTextureLoader implements IInternalTextureLoader {
  137379. /**
  137380. * Defines wether the loader supports cascade loading the different faces.
  137381. */
  137382. readonly supportCascades: boolean;
  137383. /**
  137384. * This returns if the loader support the current file information.
  137385. * @param extension defines the file extension of the file being loaded
  137386. * @param mimeType defines the optional mime type of the file being loaded
  137387. * @returns true if the loader can load the specified file
  137388. */
  137389. canLoad(extension: string, mimeType?: string): boolean;
  137390. /**
  137391. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  137392. * @param data contains the texture data
  137393. * @param texture defines the BabylonJS internal texture
  137394. * @param createPolynomials will be true if polynomials have been requested
  137395. * @param onLoad defines the callback to trigger once the texture is ready
  137396. * @param onError defines the callback to trigger in case of error
  137397. */
  137398. loadCubeData(data: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  137399. /**
  137400. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  137401. * @param data contains the texture data
  137402. * @param texture defines the BabylonJS internal texture
  137403. * @param callback defines the method to call once ready to upload
  137404. */
  137405. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void, loadFailed: boolean) => void): void;
  137406. }
  137407. }
  137408. declare module BABYLON {
  137409. /** @hidden */
  137410. export var _forceSceneHelpersToBundle: boolean;
  137411. interface Scene {
  137412. /**
  137413. * Creates a default light for the scene.
  137414. * @see https://doc.babylonjs.com/How_To/Fast_Build#create-default-light
  137415. * @param replace has the default false, when true replaces the existing lights in the scene with a hemispheric light
  137416. */
  137417. createDefaultLight(replace?: boolean): void;
  137418. /**
  137419. * Creates a default camera for the scene.
  137420. * @see https://doc.babylonjs.com/How_To/Fast_Build#create-default-camera
  137421. * @param createArcRotateCamera has the default false which creates a free camera, when true creates an arc rotate camera
  137422. * @param replace has default false, when true replaces the active camera in the scene
  137423. * @param attachCameraControls has default false, when true attaches camera controls to the canvas.
  137424. */
  137425. createDefaultCamera(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  137426. /**
  137427. * Creates a default camera and a default light.
  137428. * @see https://doc.babylonjs.com/how_to/Fast_Build#create-default-camera-or-light
  137429. * @param createArcRotateCamera has the default false which creates a free camera, when true creates an arc rotate camera
  137430. * @param replace has the default false, when true replaces the active camera/light in the scene
  137431. * @param attachCameraControls has the default false, when true attaches camera controls to the canvas.
  137432. */
  137433. createDefaultCameraOrLight(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  137434. /**
  137435. * Creates a new sky box
  137436. * @see https://doc.babylonjs.com/how_to/Fast_Build#create-default-skybox
  137437. * @param environmentTexture defines the texture to use as environment texture
  137438. * @param pbr has default false which requires the StandardMaterial to be used, when true PBRMaterial must be used
  137439. * @param scale defines the overall scale of the skybox
  137440. * @param blur is only available when pbr is true, default is 0, no blur, maximum value is 1
  137441. * @param setGlobalEnvTexture has default true indicating that scene.environmentTexture must match the current skybox texture
  137442. * @returns a new mesh holding the sky box
  137443. */
  137444. createDefaultSkybox(environmentTexture?: BaseTexture, pbr?: boolean, scale?: number, blur?: number, setGlobalEnvTexture?: boolean): Nullable<Mesh>;
  137445. /**
  137446. * Creates a new environment
  137447. * @see https://doc.babylonjs.com/How_To/Fast_Build#create-default-environment
  137448. * @param options defines the options you can use to configure the environment
  137449. * @returns the new EnvironmentHelper
  137450. */
  137451. createDefaultEnvironment(options?: Partial<IEnvironmentHelperOptions>): Nullable<EnvironmentHelper>;
  137452. /**
  137453. * Creates a new VREXperienceHelper
  137454. * @see https://doc.babylonjs.com/how_to/webvr_helper
  137455. * @param webVROptions defines the options used to create the new VREXperienceHelper
  137456. * @returns a new VREXperienceHelper
  137457. */
  137458. createDefaultVRExperience(webVROptions?: VRExperienceHelperOptions): VRExperienceHelper;
  137459. /**
  137460. * Creates a new WebXRDefaultExperience
  137461. * @see https://doc.babylonjs.com/how_to/introduction_to_webxr
  137462. * @param options experience options
  137463. * @returns a promise for a new WebXRDefaultExperience
  137464. */
  137465. createDefaultXRExperienceAsync(options: WebXRDefaultExperienceOptions): Promise<WebXRDefaultExperience>;
  137466. }
  137467. }
  137468. declare module BABYLON {
  137469. /**
  137470. * Display a 360/180 degree video on an approximately spherical surface, useful for VR applications or skyboxes.
  137471. * As a subclass of TransformNode, this allow parenting to the camera or multiple videos with different locations in the scene.
  137472. * This class achieves its effect with a VideoTexture and a correctly configured BackgroundMaterial on an inverted sphere.
  137473. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  137474. */
  137475. export class VideoDome extends TextureDome<VideoTexture> {
  137476. /**
  137477. * Define the video source as a Monoscopic panoramic 360 video.
  137478. */
  137479. static readonly MODE_MONOSCOPIC: number;
  137480. /**
  137481. * Define the video source as a Stereoscopic TopBottom/OverUnder panoramic 360 video.
  137482. */
  137483. static readonly MODE_TOPBOTTOM: number;
  137484. /**
  137485. * Define the video source as a Stereoscopic Side by Side panoramic 360 video.
  137486. */
  137487. static readonly MODE_SIDEBYSIDE: number;
  137488. /**
  137489. * Get the video texture associated with this video dome
  137490. */
  137491. get videoTexture(): VideoTexture;
  137492. /**
  137493. * Get the video mode of this dome
  137494. */
  137495. get videoMode(): number;
  137496. /**
  137497. * Set the video mode of this dome.
  137498. * @see textureMode
  137499. */
  137500. set videoMode(value: number);
  137501. protected _initTexture(urlsOrElement: string | string[] | HTMLVideoElement, scene: Scene, options: any): VideoTexture;
  137502. }
  137503. }
  137504. declare module BABYLON {
  137505. /**
  137506. * This class can be used to get instrumentation data from a Babylon engine
  137507. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  137508. */
  137509. export class EngineInstrumentation implements IDisposable {
  137510. /**
  137511. * Define the instrumented engine.
  137512. */
  137513. engine: Engine;
  137514. private _captureGPUFrameTime;
  137515. private _gpuFrameTimeToken;
  137516. private _gpuFrameTime;
  137517. private _captureShaderCompilationTime;
  137518. private _shaderCompilationTime;
  137519. private _onBeginFrameObserver;
  137520. private _onEndFrameObserver;
  137521. private _onBeforeShaderCompilationObserver;
  137522. private _onAfterShaderCompilationObserver;
  137523. /**
  137524. * Gets the perf counter used for GPU frame time
  137525. */
  137526. get gpuFrameTimeCounter(): PerfCounter;
  137527. /**
  137528. * Gets the GPU frame time capture status
  137529. */
  137530. get captureGPUFrameTime(): boolean;
  137531. /**
  137532. * Enable or disable the GPU frame time capture
  137533. */
  137534. set captureGPUFrameTime(value: boolean);
  137535. /**
  137536. * Gets the perf counter used for shader compilation time
  137537. */
  137538. get shaderCompilationTimeCounter(): PerfCounter;
  137539. /**
  137540. * Gets the shader compilation time capture status
  137541. */
  137542. get captureShaderCompilationTime(): boolean;
  137543. /**
  137544. * Enable or disable the shader compilation time capture
  137545. */
  137546. set captureShaderCompilationTime(value: boolean);
  137547. /**
  137548. * Instantiates a new engine instrumentation.
  137549. * This class can be used to get instrumentation data from a Babylon engine
  137550. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  137551. * @param engine Defines the engine to instrument
  137552. */
  137553. constructor(
  137554. /**
  137555. * Define the instrumented engine.
  137556. */
  137557. engine: Engine);
  137558. /**
  137559. * Dispose and release associated resources.
  137560. */
  137561. dispose(): void;
  137562. }
  137563. }
  137564. declare module BABYLON {
  137565. /**
  137566. * This class can be used to get instrumentation data from a Babylon engine
  137567. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  137568. */
  137569. export class SceneInstrumentation implements IDisposable {
  137570. /**
  137571. * Defines the scene to instrument
  137572. */
  137573. scene: Scene;
  137574. private _captureActiveMeshesEvaluationTime;
  137575. private _activeMeshesEvaluationTime;
  137576. private _captureRenderTargetsRenderTime;
  137577. private _renderTargetsRenderTime;
  137578. private _captureFrameTime;
  137579. private _frameTime;
  137580. private _captureRenderTime;
  137581. private _renderTime;
  137582. private _captureInterFrameTime;
  137583. private _interFrameTime;
  137584. private _captureParticlesRenderTime;
  137585. private _particlesRenderTime;
  137586. private _captureSpritesRenderTime;
  137587. private _spritesRenderTime;
  137588. private _capturePhysicsTime;
  137589. private _physicsTime;
  137590. private _captureAnimationsTime;
  137591. private _animationsTime;
  137592. private _captureCameraRenderTime;
  137593. private _cameraRenderTime;
  137594. private _onBeforeActiveMeshesEvaluationObserver;
  137595. private _onAfterActiveMeshesEvaluationObserver;
  137596. private _onBeforeRenderTargetsRenderObserver;
  137597. private _onAfterRenderTargetsRenderObserver;
  137598. private _onAfterRenderObserver;
  137599. private _onBeforeDrawPhaseObserver;
  137600. private _onAfterDrawPhaseObserver;
  137601. private _onBeforeAnimationsObserver;
  137602. private _onBeforeParticlesRenderingObserver;
  137603. private _onAfterParticlesRenderingObserver;
  137604. private _onBeforeSpritesRenderingObserver;
  137605. private _onAfterSpritesRenderingObserver;
  137606. private _onBeforePhysicsObserver;
  137607. private _onAfterPhysicsObserver;
  137608. private _onAfterAnimationsObserver;
  137609. private _onBeforeCameraRenderObserver;
  137610. private _onAfterCameraRenderObserver;
  137611. /**
  137612. * Gets the perf counter used for active meshes evaluation time
  137613. */
  137614. get activeMeshesEvaluationTimeCounter(): PerfCounter;
  137615. /**
  137616. * Gets the active meshes evaluation time capture status
  137617. */
  137618. get captureActiveMeshesEvaluationTime(): boolean;
  137619. /**
  137620. * Enable or disable the active meshes evaluation time capture
  137621. */
  137622. set captureActiveMeshesEvaluationTime(value: boolean);
  137623. /**
  137624. * Gets the perf counter used for render targets render time
  137625. */
  137626. get renderTargetsRenderTimeCounter(): PerfCounter;
  137627. /**
  137628. * Gets the render targets render time capture status
  137629. */
  137630. get captureRenderTargetsRenderTime(): boolean;
  137631. /**
  137632. * Enable or disable the render targets render time capture
  137633. */
  137634. set captureRenderTargetsRenderTime(value: boolean);
  137635. /**
  137636. * Gets the perf counter used for particles render time
  137637. */
  137638. get particlesRenderTimeCounter(): PerfCounter;
  137639. /**
  137640. * Gets the particles render time capture status
  137641. */
  137642. get captureParticlesRenderTime(): boolean;
  137643. /**
  137644. * Enable or disable the particles render time capture
  137645. */
  137646. set captureParticlesRenderTime(value: boolean);
  137647. /**
  137648. * Gets the perf counter used for sprites render time
  137649. */
  137650. get spritesRenderTimeCounter(): PerfCounter;
  137651. /**
  137652. * Gets the sprites render time capture status
  137653. */
  137654. get captureSpritesRenderTime(): boolean;
  137655. /**
  137656. * Enable or disable the sprites render time capture
  137657. */
  137658. set captureSpritesRenderTime(value: boolean);
  137659. /**
  137660. * Gets the perf counter used for physics time
  137661. */
  137662. get physicsTimeCounter(): PerfCounter;
  137663. /**
  137664. * Gets the physics time capture status
  137665. */
  137666. get capturePhysicsTime(): boolean;
  137667. /**
  137668. * Enable or disable the physics time capture
  137669. */
  137670. set capturePhysicsTime(value: boolean);
  137671. /**
  137672. * Gets the perf counter used for animations time
  137673. */
  137674. get animationsTimeCounter(): PerfCounter;
  137675. /**
  137676. * Gets the animations time capture status
  137677. */
  137678. get captureAnimationsTime(): boolean;
  137679. /**
  137680. * Enable or disable the animations time capture
  137681. */
  137682. set captureAnimationsTime(value: boolean);
  137683. /**
  137684. * Gets the perf counter used for frame time capture
  137685. */
  137686. get frameTimeCounter(): PerfCounter;
  137687. /**
  137688. * Gets the frame time capture status
  137689. */
  137690. get captureFrameTime(): boolean;
  137691. /**
  137692. * Enable or disable the frame time capture
  137693. */
  137694. set captureFrameTime(value: boolean);
  137695. /**
  137696. * Gets the perf counter used for inter-frames time capture
  137697. */
  137698. get interFrameTimeCounter(): PerfCounter;
  137699. /**
  137700. * Gets the inter-frames time capture status
  137701. */
  137702. get captureInterFrameTime(): boolean;
  137703. /**
  137704. * Enable or disable the inter-frames time capture
  137705. */
  137706. set captureInterFrameTime(value: boolean);
  137707. /**
  137708. * Gets the perf counter used for render time capture
  137709. */
  137710. get renderTimeCounter(): PerfCounter;
  137711. /**
  137712. * Gets the render time capture status
  137713. */
  137714. get captureRenderTime(): boolean;
  137715. /**
  137716. * Enable or disable the render time capture
  137717. */
  137718. set captureRenderTime(value: boolean);
  137719. /**
  137720. * Gets the perf counter used for camera render time capture
  137721. */
  137722. get cameraRenderTimeCounter(): PerfCounter;
  137723. /**
  137724. * Gets the camera render time capture status
  137725. */
  137726. get captureCameraRenderTime(): boolean;
  137727. /**
  137728. * Enable or disable the camera render time capture
  137729. */
  137730. set captureCameraRenderTime(value: boolean);
  137731. /**
  137732. * Gets the perf counter used for draw calls
  137733. */
  137734. get drawCallsCounter(): PerfCounter;
  137735. /**
  137736. * Instantiates a new scene instrumentation.
  137737. * This class can be used to get instrumentation data from a Babylon engine
  137738. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  137739. * @param scene Defines the scene to instrument
  137740. */
  137741. constructor(
  137742. /**
  137743. * Defines the scene to instrument
  137744. */
  137745. scene: Scene);
  137746. /**
  137747. * Dispose and release associated resources.
  137748. */
  137749. dispose(): void;
  137750. }
  137751. }
  137752. declare module BABYLON {
  137753. /** @hidden */
  137754. export var glowMapGenerationPixelShader: {
  137755. name: string;
  137756. shader: string;
  137757. };
  137758. }
  137759. declare module BABYLON {
  137760. /** @hidden */
  137761. export var glowMapGenerationVertexShader: {
  137762. name: string;
  137763. shader: string;
  137764. };
  137765. }
  137766. declare module BABYLON {
  137767. /**
  137768. * Effect layer options. This helps customizing the behaviour
  137769. * of the effect layer.
  137770. */
  137771. export interface IEffectLayerOptions {
  137772. /**
  137773. * Multiplication factor apply to the canvas size to compute the render target size
  137774. * used to generated the objects (the smaller the faster).
  137775. */
  137776. mainTextureRatio: number;
  137777. /**
  137778. * Enforces a fixed size texture to ensure effect stability across devices.
  137779. */
  137780. mainTextureFixedSize?: number;
  137781. /**
  137782. * Alpha blending mode used to apply the blur. Default depends of the implementation.
  137783. */
  137784. alphaBlendingMode: number;
  137785. /**
  137786. * The camera attached to the layer.
  137787. */
  137788. camera: Nullable<Camera>;
  137789. /**
  137790. * The rendering group to draw the layer in.
  137791. */
  137792. renderingGroupId: number;
  137793. }
  137794. /**
  137795. * The effect layer Helps adding post process effect blended with the main pass.
  137796. *
  137797. * This can be for instance use to generate glow or higlight effects on the scene.
  137798. *
  137799. * The effect layer class can not be used directly and is intented to inherited from to be
  137800. * customized per effects.
  137801. */
  137802. export abstract class EffectLayer {
  137803. private _vertexBuffers;
  137804. private _indexBuffer;
  137805. private _cachedDefines;
  137806. private _effectLayerMapGenerationEffect;
  137807. private _effectLayerOptions;
  137808. private _mergeEffect;
  137809. protected _scene: Scene;
  137810. protected _engine: Engine;
  137811. protected _maxSize: number;
  137812. protected _mainTextureDesiredSize: ISize;
  137813. protected _mainTexture: RenderTargetTexture;
  137814. protected _shouldRender: boolean;
  137815. protected _postProcesses: PostProcess[];
  137816. protected _textures: BaseTexture[];
  137817. protected _emissiveTextureAndColor: {
  137818. texture: Nullable<BaseTexture>;
  137819. color: Color4;
  137820. };
  137821. /**
  137822. * The name of the layer
  137823. */
  137824. name: string;
  137825. /**
  137826. * The clear color of the texture used to generate the glow map.
  137827. */
  137828. neutralColor: Color4;
  137829. /**
  137830. * Specifies whether the highlight layer is enabled or not.
  137831. */
  137832. isEnabled: boolean;
  137833. /**
  137834. * Gets the camera attached to the layer.
  137835. */
  137836. get camera(): Nullable<Camera>;
  137837. /**
  137838. * Gets the rendering group id the layer should render in.
  137839. */
  137840. get renderingGroupId(): number;
  137841. set renderingGroupId(renderingGroupId: number);
  137842. /**
  137843. * An event triggered when the effect layer has been disposed.
  137844. */
  137845. onDisposeObservable: Observable<EffectLayer>;
  137846. /**
  137847. * An event triggered when the effect layer is about rendering the main texture with the glowy parts.
  137848. */
  137849. onBeforeRenderMainTextureObservable: Observable<EffectLayer>;
  137850. /**
  137851. * An event triggered when the generated texture is being merged in the scene.
  137852. */
  137853. onBeforeComposeObservable: Observable<EffectLayer>;
  137854. /**
  137855. * An event triggered when the mesh is rendered into the effect render target.
  137856. */
  137857. onBeforeRenderMeshToEffect: Observable<AbstractMesh>;
  137858. /**
  137859. * An event triggered after the mesh has been rendered into the effect render target.
  137860. */
  137861. onAfterRenderMeshToEffect: Observable<AbstractMesh>;
  137862. /**
  137863. * An event triggered when the generated texture has been merged in the scene.
  137864. */
  137865. onAfterComposeObservable: Observable<EffectLayer>;
  137866. /**
  137867. * An event triggered when the efffect layer changes its size.
  137868. */
  137869. onSizeChangedObservable: Observable<EffectLayer>;
  137870. /** @hidden */
  137871. static _SceneComponentInitialization: (scene: Scene) => void;
  137872. /**
  137873. * Instantiates a new effect Layer and references it in the scene.
  137874. * @param name The name of the layer
  137875. * @param scene The scene to use the layer in
  137876. */
  137877. constructor(
  137878. /** The Friendly of the effect in the scene */
  137879. name: string, scene: Scene);
  137880. /**
  137881. * Get the effect name of the layer.
  137882. * @return The effect name
  137883. */
  137884. abstract getEffectName(): string;
  137885. /**
  137886. * Checks for the readiness of the element composing the layer.
  137887. * @param subMesh the mesh to check for
  137888. * @param useInstances specify whether or not to use instances to render the mesh
  137889. * @return true if ready otherwise, false
  137890. */
  137891. abstract isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  137892. /**
  137893. * Returns whether or nood the layer needs stencil enabled during the mesh rendering.
  137894. * @returns true if the effect requires stencil during the main canvas render pass.
  137895. */
  137896. abstract needStencil(): boolean;
  137897. /**
  137898. * Create the merge effect. This is the shader use to blit the information back
  137899. * to the main canvas at the end of the scene rendering.
  137900. * @returns The effect containing the shader used to merge the effect on the main canvas
  137901. */
  137902. protected abstract _createMergeEffect(): Effect;
  137903. /**
  137904. * Creates the render target textures and post processes used in the effect layer.
  137905. */
  137906. protected abstract _createTextureAndPostProcesses(): void;
  137907. /**
  137908. * Implementation specific of rendering the generating effect on the main canvas.
  137909. * @param effect The effect used to render through
  137910. */
  137911. protected abstract _internalRender(effect: Effect): void;
  137912. /**
  137913. * Sets the required values for both the emissive texture and and the main color.
  137914. */
  137915. protected abstract _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  137916. /**
  137917. * Free any resources and references associated to a mesh.
  137918. * Internal use
  137919. * @param mesh The mesh to free.
  137920. */
  137921. abstract _disposeMesh(mesh: Mesh): void;
  137922. /**
  137923. * Serializes this layer (Glow or Highlight for example)
  137924. * @returns a serialized layer object
  137925. */
  137926. abstract serialize?(): any;
  137927. /**
  137928. * Initializes the effect layer with the required options.
  137929. * @param options Sets of none mandatory options to use with the layer (see IEffectLayerOptions for more information)
  137930. */
  137931. protected _init(options: Partial<IEffectLayerOptions>): void;
  137932. /**
  137933. * Generates the index buffer of the full screen quad blending to the main canvas.
  137934. */
  137935. private _generateIndexBuffer;
  137936. /**
  137937. * Generates the vertex buffer of the full screen quad blending to the main canvas.
  137938. */
  137939. private _generateVertexBuffer;
  137940. /**
  137941. * Sets the main texture desired size which is the closest power of two
  137942. * of the engine canvas size.
  137943. */
  137944. private _setMainTextureSize;
  137945. /**
  137946. * Creates the main texture for the effect layer.
  137947. */
  137948. protected _createMainTexture(): void;
  137949. /**
  137950. * Adds specific effects defines.
  137951. * @param defines The defines to add specifics to.
  137952. */
  137953. protected _addCustomEffectDefines(defines: string[]): void;
  137954. /**
  137955. * Checks for the readiness of the element composing the layer.
  137956. * @param subMesh the mesh to check for
  137957. * @param useInstances specify whether or not to use instances to render the mesh
  137958. * @param emissiveTexture the associated emissive texture used to generate the glow
  137959. * @return true if ready otherwise, false
  137960. */
  137961. protected _isReady(subMesh: SubMesh, useInstances: boolean, emissiveTexture: Nullable<BaseTexture>): boolean;
  137962. /**
  137963. * Renders the glowing part of the scene by blending the blurred glowing meshes on top of the rendered scene.
  137964. */
  137965. render(): void;
  137966. /**
  137967. * Determine if a given mesh will be used in the current effect.
  137968. * @param mesh mesh to test
  137969. * @returns true if the mesh will be used
  137970. */
  137971. hasMesh(mesh: AbstractMesh): boolean;
  137972. /**
  137973. * Returns true if the layer contains information to display, otherwise false.
  137974. * @returns true if the glow layer should be rendered
  137975. */
  137976. shouldRender(): boolean;
  137977. /**
  137978. * Returns true if the mesh should render, otherwise false.
  137979. * @param mesh The mesh to render
  137980. * @returns true if it should render otherwise false
  137981. */
  137982. protected _shouldRenderMesh(mesh: AbstractMesh): boolean;
  137983. /**
  137984. * Returns true if the mesh can be rendered, otherwise false.
  137985. * @param mesh The mesh to render
  137986. * @param material The material used on the mesh
  137987. * @returns true if it can be rendered otherwise false
  137988. */
  137989. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  137990. /**
  137991. * Returns true if the mesh should render, otherwise false.
  137992. * @param mesh The mesh to render
  137993. * @returns true if it should render otherwise false
  137994. */
  137995. protected _shouldRenderEmissiveTextureForMesh(): boolean;
  137996. /**
  137997. * Renders the submesh passed in parameter to the generation map.
  137998. */
  137999. protected _renderSubMesh(subMesh: SubMesh, enableAlphaMode?: boolean): void;
  138000. /**
  138001. * Defines whether the current material of the mesh should be use to render the effect.
  138002. * @param mesh defines the current mesh to render
  138003. */
  138004. protected _useMeshMaterial(mesh: AbstractMesh): boolean;
  138005. /**
  138006. * Rebuild the required buffers.
  138007. * @hidden Internal use only.
  138008. */
  138009. _rebuild(): void;
  138010. /**
  138011. * Dispose only the render target textures and post process.
  138012. */
  138013. private _disposeTextureAndPostProcesses;
  138014. /**
  138015. * Dispose the highlight layer and free resources.
  138016. */
  138017. dispose(): void;
  138018. /**
  138019. * Gets the class name of the effect layer
  138020. * @returns the string with the class name of the effect layer
  138021. */
  138022. getClassName(): string;
  138023. /**
  138024. * Creates an effect layer from parsed effect layer data
  138025. * @param parsedEffectLayer defines effect layer data
  138026. * @param scene defines the current scene
  138027. * @param rootUrl defines the root URL containing the effect layer information
  138028. * @returns a parsed effect Layer
  138029. */
  138030. static Parse(parsedEffectLayer: any, scene: Scene, rootUrl: string): EffectLayer;
  138031. }
  138032. }
  138033. declare module BABYLON {
  138034. interface AbstractScene {
  138035. /**
  138036. * The list of effect layers (highlights/glow) added to the scene
  138037. * @see https://doc.babylonjs.com/how_to/highlight_layer
  138038. * @see https://doc.babylonjs.com/how_to/glow_layer
  138039. */
  138040. effectLayers: Array<EffectLayer>;
  138041. /**
  138042. * Removes the given effect layer from this scene.
  138043. * @param toRemove defines the effect layer to remove
  138044. * @returns the index of the removed effect layer
  138045. */
  138046. removeEffectLayer(toRemove: EffectLayer): number;
  138047. /**
  138048. * Adds the given effect layer to this scene
  138049. * @param newEffectLayer defines the effect layer to add
  138050. */
  138051. addEffectLayer(newEffectLayer: EffectLayer): void;
  138052. }
  138053. /**
  138054. * Defines the layer scene component responsible to manage any effect layers
  138055. * in a given scene.
  138056. */
  138057. export class EffectLayerSceneComponent implements ISceneSerializableComponent {
  138058. /**
  138059. * The component name helpfull to identify the component in the list of scene components.
  138060. */
  138061. readonly name: string;
  138062. /**
  138063. * The scene the component belongs to.
  138064. */
  138065. scene: Scene;
  138066. private _engine;
  138067. private _renderEffects;
  138068. private _needStencil;
  138069. private _previousStencilState;
  138070. /**
  138071. * Creates a new instance of the component for the given scene
  138072. * @param scene Defines the scene to register the component in
  138073. */
  138074. constructor(scene: Scene);
  138075. /**
  138076. * Registers the component in a given scene
  138077. */
  138078. register(): void;
  138079. /**
  138080. * Rebuilds the elements related to this component in case of
  138081. * context lost for instance.
  138082. */
  138083. rebuild(): void;
  138084. /**
  138085. * Serializes the component data to the specified json object
  138086. * @param serializationObject The object to serialize to
  138087. */
  138088. serialize(serializationObject: any): void;
  138089. /**
  138090. * Adds all the elements from the container to the scene
  138091. * @param container the container holding the elements
  138092. */
  138093. addFromContainer(container: AbstractScene): void;
  138094. /**
  138095. * Removes all the elements in the container from the scene
  138096. * @param container contains the elements to remove
  138097. * @param dispose if the removed element should be disposed (default: false)
  138098. */
  138099. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  138100. /**
  138101. * Disposes the component and the associated ressources.
  138102. */
  138103. dispose(): void;
  138104. private _isReadyForMesh;
  138105. private _renderMainTexture;
  138106. private _setStencil;
  138107. private _setStencilBack;
  138108. private _draw;
  138109. private _drawCamera;
  138110. private _drawRenderingGroup;
  138111. }
  138112. }
  138113. declare module BABYLON {
  138114. /** @hidden */
  138115. export var glowMapMergePixelShader: {
  138116. name: string;
  138117. shader: string;
  138118. };
  138119. }
  138120. declare module BABYLON {
  138121. /** @hidden */
  138122. export var glowMapMergeVertexShader: {
  138123. name: string;
  138124. shader: string;
  138125. };
  138126. }
  138127. declare module BABYLON {
  138128. interface AbstractScene {
  138129. /**
  138130. * Return a the first highlight layer of the scene with a given name.
  138131. * @param name The name of the highlight layer to look for.
  138132. * @return The highlight layer if found otherwise null.
  138133. */
  138134. getGlowLayerByName(name: string): Nullable<GlowLayer>;
  138135. }
  138136. /**
  138137. * Glow layer options. This helps customizing the behaviour
  138138. * of the glow layer.
  138139. */
  138140. export interface IGlowLayerOptions {
  138141. /**
  138142. * Multiplication factor apply to the canvas size to compute the render target size
  138143. * used to generated the glowing objects (the smaller the faster).
  138144. */
  138145. mainTextureRatio: number;
  138146. /**
  138147. * Enforces a fixed size texture to ensure resize independant blur.
  138148. */
  138149. mainTextureFixedSize?: number;
  138150. /**
  138151. * How big is the kernel of the blur texture.
  138152. */
  138153. blurKernelSize: number;
  138154. /**
  138155. * The camera attached to the layer.
  138156. */
  138157. camera: Nullable<Camera>;
  138158. /**
  138159. * Enable MSAA by chosing the number of samples.
  138160. */
  138161. mainTextureSamples?: number;
  138162. /**
  138163. * The rendering group to draw the layer in.
  138164. */
  138165. renderingGroupId: number;
  138166. }
  138167. /**
  138168. * The glow layer Helps adding a glow effect around the emissive parts of a mesh.
  138169. *
  138170. * Once instantiated in a scene, by default, all the emissive meshes will glow.
  138171. *
  138172. * Documentation: https://doc.babylonjs.com/how_to/glow_layer
  138173. */
  138174. export class GlowLayer extends EffectLayer {
  138175. /**
  138176. * Effect Name of the layer.
  138177. */
  138178. static readonly EffectName: string;
  138179. /**
  138180. * The default blur kernel size used for the glow.
  138181. */
  138182. static DefaultBlurKernelSize: number;
  138183. /**
  138184. * The default texture size ratio used for the glow.
  138185. */
  138186. static DefaultTextureRatio: number;
  138187. /**
  138188. * Sets the kernel size of the blur.
  138189. */
  138190. set blurKernelSize(value: number);
  138191. /**
  138192. * Gets the kernel size of the blur.
  138193. */
  138194. get blurKernelSize(): number;
  138195. /**
  138196. * Sets the glow intensity.
  138197. */
  138198. set intensity(value: number);
  138199. /**
  138200. * Gets the glow intensity.
  138201. */
  138202. get intensity(): number;
  138203. private _options;
  138204. private _intensity;
  138205. private _horizontalBlurPostprocess1;
  138206. private _verticalBlurPostprocess1;
  138207. private _horizontalBlurPostprocess2;
  138208. private _verticalBlurPostprocess2;
  138209. private _blurTexture1;
  138210. private _blurTexture2;
  138211. private _postProcesses1;
  138212. private _postProcesses2;
  138213. private _includedOnlyMeshes;
  138214. private _excludedMeshes;
  138215. private _meshesUsingTheirOwnMaterials;
  138216. /**
  138217. * Callback used to let the user override the color selection on a per mesh basis
  138218. */
  138219. customEmissiveColorSelector: (mesh: Mesh, subMesh: SubMesh, material: Material, result: Color4) => void;
  138220. /**
  138221. * Callback used to let the user override the texture selection on a per mesh basis
  138222. */
  138223. customEmissiveTextureSelector: (mesh: Mesh, subMesh: SubMesh, material: Material) => Texture;
  138224. /**
  138225. * Instantiates a new glow Layer and references it to the scene.
  138226. * @param name The name of the layer
  138227. * @param scene The scene to use the layer in
  138228. * @param options Sets of none mandatory options to use with the layer (see IGlowLayerOptions for more information)
  138229. */
  138230. constructor(name: string, scene: Scene, options?: Partial<IGlowLayerOptions>);
  138231. /**
  138232. * Get the effect name of the layer.
  138233. * @return The effect name
  138234. */
  138235. getEffectName(): string;
  138236. /**
  138237. * Create the merge effect. This is the shader use to blit the information back
  138238. * to the main canvas at the end of the scene rendering.
  138239. */
  138240. protected _createMergeEffect(): Effect;
  138241. /**
  138242. * Creates the render target textures and post processes used in the glow layer.
  138243. */
  138244. protected _createTextureAndPostProcesses(): void;
  138245. /**
  138246. * Checks for the readiness of the element composing the layer.
  138247. * @param subMesh the mesh to check for
  138248. * @param useInstances specify wether or not to use instances to render the mesh
  138249. * @param emissiveTexture the associated emissive texture used to generate the glow
  138250. * @return true if ready otherwise, false
  138251. */
  138252. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  138253. /**
  138254. * Returns whether or nood the layer needs stencil enabled during the mesh rendering.
  138255. */
  138256. needStencil(): boolean;
  138257. /**
  138258. * Returns true if the mesh can be rendered, otherwise false.
  138259. * @param mesh The mesh to render
  138260. * @param material The material used on the mesh
  138261. * @returns true if it can be rendered otherwise false
  138262. */
  138263. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  138264. /**
  138265. * Implementation specific of rendering the generating effect on the main canvas.
  138266. * @param effect The effect used to render through
  138267. */
  138268. protected _internalRender(effect: Effect): void;
  138269. /**
  138270. * Sets the required values for both the emissive texture and and the main color.
  138271. */
  138272. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  138273. /**
  138274. * Returns true if the mesh should render, otherwise false.
  138275. * @param mesh The mesh to render
  138276. * @returns true if it should render otherwise false
  138277. */
  138278. protected _shouldRenderMesh(mesh: Mesh): boolean;
  138279. /**
  138280. * Adds specific effects defines.
  138281. * @param defines The defines to add specifics to.
  138282. */
  138283. protected _addCustomEffectDefines(defines: string[]): void;
  138284. /**
  138285. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the glow layer.
  138286. * @param mesh The mesh to exclude from the glow layer
  138287. */
  138288. addExcludedMesh(mesh: Mesh): void;
  138289. /**
  138290. * Remove a mesh from the exclusion list to let it impact or being impacted by the glow layer.
  138291. * @param mesh The mesh to remove
  138292. */
  138293. removeExcludedMesh(mesh: Mesh): void;
  138294. /**
  138295. * Add a mesh in the inclusion list to impact or being impacted by the glow layer.
  138296. * @param mesh The mesh to include in the glow layer
  138297. */
  138298. addIncludedOnlyMesh(mesh: Mesh): void;
  138299. /**
  138300. * Remove a mesh from the Inclusion list to prevent it to impact or being impacted by the glow layer.
  138301. * @param mesh The mesh to remove
  138302. */
  138303. removeIncludedOnlyMesh(mesh: Mesh): void;
  138304. /**
  138305. * Determine if a given mesh will be used in the glow layer
  138306. * @param mesh The mesh to test
  138307. * @returns true if the mesh will be highlighted by the current glow layer
  138308. */
  138309. hasMesh(mesh: AbstractMesh): boolean;
  138310. /**
  138311. * Defines whether the current material of the mesh should be use to render the effect.
  138312. * @param mesh defines the current mesh to render
  138313. */
  138314. protected _useMeshMaterial(mesh: AbstractMesh): boolean;
  138315. /**
  138316. * Add a mesh to be rendered through its own material and not with emissive only.
  138317. * @param mesh The mesh for which we need to use its material
  138318. */
  138319. referenceMeshToUseItsOwnMaterial(mesh: AbstractMesh): void;
  138320. /**
  138321. * Remove a mesh from being rendered through its own material and not with emissive only.
  138322. * @param mesh The mesh for which we need to not use its material
  138323. */
  138324. unReferenceMeshFromUsingItsOwnMaterial(mesh: AbstractMesh): void;
  138325. /**
  138326. * Free any resources and references associated to a mesh.
  138327. * Internal use
  138328. * @param mesh The mesh to free.
  138329. * @hidden
  138330. */
  138331. _disposeMesh(mesh: Mesh): void;
  138332. /**
  138333. * Gets the class name of the effect layer
  138334. * @returns the string with the class name of the effect layer
  138335. */
  138336. getClassName(): string;
  138337. /**
  138338. * Serializes this glow layer
  138339. * @returns a serialized glow layer object
  138340. */
  138341. serialize(): any;
  138342. /**
  138343. * Creates a Glow Layer from parsed glow layer data
  138344. * @param parsedGlowLayer defines glow layer data
  138345. * @param scene defines the current scene
  138346. * @param rootUrl defines the root URL containing the glow layer information
  138347. * @returns a parsed Glow Layer
  138348. */
  138349. static Parse(parsedGlowLayer: any, scene: Scene, rootUrl: string): GlowLayer;
  138350. }
  138351. }
  138352. declare module BABYLON {
  138353. /** @hidden */
  138354. export var glowBlurPostProcessPixelShader: {
  138355. name: string;
  138356. shader: string;
  138357. };
  138358. }
  138359. declare module BABYLON {
  138360. interface AbstractScene {
  138361. /**
  138362. * Return a the first highlight layer of the scene with a given name.
  138363. * @param name The name of the highlight layer to look for.
  138364. * @return The highlight layer if found otherwise null.
  138365. */
  138366. getHighlightLayerByName(name: string): Nullable<HighlightLayer>;
  138367. }
  138368. /**
  138369. * Highlight layer options. This helps customizing the behaviour
  138370. * of the highlight layer.
  138371. */
  138372. export interface IHighlightLayerOptions {
  138373. /**
  138374. * Multiplication factor apply to the canvas size to compute the render target size
  138375. * used to generated the glowing objects (the smaller the faster).
  138376. */
  138377. mainTextureRatio: number;
  138378. /**
  138379. * Enforces a fixed size texture to ensure resize independant blur.
  138380. */
  138381. mainTextureFixedSize?: number;
  138382. /**
  138383. * Multiplication factor apply to the main texture size in the first step of the blur to reduce the size
  138384. * of the picture to blur (the smaller the faster).
  138385. */
  138386. blurTextureSizeRatio: number;
  138387. /**
  138388. * How big in texel of the blur texture is the vertical blur.
  138389. */
  138390. blurVerticalSize: number;
  138391. /**
  138392. * How big in texel of the blur texture is the horizontal blur.
  138393. */
  138394. blurHorizontalSize: number;
  138395. /**
  138396. * Alpha blending mode used to apply the blur. Default is combine.
  138397. */
  138398. alphaBlendingMode: number;
  138399. /**
  138400. * The camera attached to the layer.
  138401. */
  138402. camera: Nullable<Camera>;
  138403. /**
  138404. * Should we display highlight as a solid stroke?
  138405. */
  138406. isStroke?: boolean;
  138407. /**
  138408. * The rendering group to draw the layer in.
  138409. */
  138410. renderingGroupId: number;
  138411. }
  138412. /**
  138413. * The highlight layer Helps adding a glow effect around a mesh.
  138414. *
  138415. * Once instantiated in a scene, simply use the addMesh or removeMesh method to add or remove
  138416. * glowy meshes to your scene.
  138417. *
  138418. * !!! THIS REQUIRES AN ACTIVE STENCIL BUFFER ON THE CANVAS !!!
  138419. */
  138420. export class HighlightLayer extends EffectLayer {
  138421. name: string;
  138422. /**
  138423. * Effect Name of the highlight layer.
  138424. */
  138425. static readonly EffectName: string;
  138426. /**
  138427. * The neutral color used during the preparation of the glow effect.
  138428. * This is black by default as the blend operation is a blend operation.
  138429. */
  138430. static NeutralColor: Color4;
  138431. /**
  138432. * Stencil value used for glowing meshes.
  138433. */
  138434. static GlowingMeshStencilReference: number;
  138435. /**
  138436. * Stencil value used for the other meshes in the scene.
  138437. */
  138438. static NormalMeshStencilReference: number;
  138439. /**
  138440. * Specifies whether or not the inner glow is ACTIVE in the layer.
  138441. */
  138442. innerGlow: boolean;
  138443. /**
  138444. * Specifies whether or not the outer glow is ACTIVE in the layer.
  138445. */
  138446. outerGlow: boolean;
  138447. /**
  138448. * Specifies the horizontal size of the blur.
  138449. */
  138450. set blurHorizontalSize(value: number);
  138451. /**
  138452. * Specifies the vertical size of the blur.
  138453. */
  138454. set blurVerticalSize(value: number);
  138455. /**
  138456. * Gets the horizontal size of the blur.
  138457. */
  138458. get blurHorizontalSize(): number;
  138459. /**
  138460. * Gets the vertical size of the blur.
  138461. */
  138462. get blurVerticalSize(): number;
  138463. /**
  138464. * An event triggered when the highlight layer is being blurred.
  138465. */
  138466. onBeforeBlurObservable: Observable<HighlightLayer>;
  138467. /**
  138468. * An event triggered when the highlight layer has been blurred.
  138469. */
  138470. onAfterBlurObservable: Observable<HighlightLayer>;
  138471. private _instanceGlowingMeshStencilReference;
  138472. private _options;
  138473. private _downSamplePostprocess;
  138474. private _horizontalBlurPostprocess;
  138475. private _verticalBlurPostprocess;
  138476. private _blurTexture;
  138477. private _meshes;
  138478. private _excludedMeshes;
  138479. /**
  138480. * Instantiates a new highlight Layer and references it to the scene..
  138481. * @param name The name of the layer
  138482. * @param scene The scene to use the layer in
  138483. * @param options Sets of none mandatory options to use with the layer (see IHighlightLayerOptions for more information)
  138484. */
  138485. constructor(name: string, scene: Scene, options?: Partial<IHighlightLayerOptions>);
  138486. /**
  138487. * Get the effect name of the layer.
  138488. * @return The effect name
  138489. */
  138490. getEffectName(): string;
  138491. /**
  138492. * Create the merge effect. This is the shader use to blit the information back
  138493. * to the main canvas at the end of the scene rendering.
  138494. */
  138495. protected _createMergeEffect(): Effect;
  138496. /**
  138497. * Creates the render target textures and post processes used in the highlight layer.
  138498. */
  138499. protected _createTextureAndPostProcesses(): void;
  138500. /**
  138501. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  138502. */
  138503. needStencil(): boolean;
  138504. /**
  138505. * Checks for the readiness of the element composing the layer.
  138506. * @param subMesh the mesh to check for
  138507. * @param useInstances specify wether or not to use instances to render the mesh
  138508. * @param emissiveTexture the associated emissive texture used to generate the glow
  138509. * @return true if ready otherwise, false
  138510. */
  138511. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  138512. /**
  138513. * Implementation specific of rendering the generating effect on the main canvas.
  138514. * @param effect The effect used to render through
  138515. */
  138516. protected _internalRender(effect: Effect): void;
  138517. /**
  138518. * Returns true if the layer contains information to display, otherwise false.
  138519. */
  138520. shouldRender(): boolean;
  138521. /**
  138522. * Returns true if the mesh should render, otherwise false.
  138523. * @param mesh The mesh to render
  138524. * @returns true if it should render otherwise false
  138525. */
  138526. protected _shouldRenderMesh(mesh: Mesh): boolean;
  138527. /**
  138528. * Returns true if the mesh can be rendered, otherwise false.
  138529. * @param mesh The mesh to render
  138530. * @param material The material used on the mesh
  138531. * @returns true if it can be rendered otherwise false
  138532. */
  138533. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  138534. /**
  138535. * Adds specific effects defines.
  138536. * @param defines The defines to add specifics to.
  138537. */
  138538. protected _addCustomEffectDefines(defines: string[]): void;
  138539. /**
  138540. * Sets the required values for both the emissive texture and and the main color.
  138541. */
  138542. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  138543. /**
  138544. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the highlight layer.
  138545. * @param mesh The mesh to exclude from the highlight layer
  138546. */
  138547. addExcludedMesh(mesh: Mesh): void;
  138548. /**
  138549. * Remove a mesh from the exclusion list to let it impact or being impacted by the highlight layer.
  138550. * @param mesh The mesh to highlight
  138551. */
  138552. removeExcludedMesh(mesh: Mesh): void;
  138553. /**
  138554. * Determine if a given mesh will be highlighted by the current HighlightLayer
  138555. * @param mesh mesh to test
  138556. * @returns true if the mesh will be highlighted by the current HighlightLayer
  138557. */
  138558. hasMesh(mesh: AbstractMesh): boolean;
  138559. /**
  138560. * Add a mesh in the highlight layer in order to make it glow with the chosen color.
  138561. * @param mesh The mesh to highlight
  138562. * @param color The color of the highlight
  138563. * @param glowEmissiveOnly Extract the glow from the emissive texture
  138564. */
  138565. addMesh(mesh: Mesh, color: Color3, glowEmissiveOnly?: boolean): void;
  138566. /**
  138567. * Remove a mesh from the highlight layer in order to make it stop glowing.
  138568. * @param mesh The mesh to highlight
  138569. */
  138570. removeMesh(mesh: Mesh): void;
  138571. /**
  138572. * Remove all the meshes currently referenced in the highlight layer
  138573. */
  138574. removeAllMeshes(): void;
  138575. /**
  138576. * Force the stencil to the normal expected value for none glowing parts
  138577. */
  138578. private _defaultStencilReference;
  138579. /**
  138580. * Free any resources and references associated to a mesh.
  138581. * Internal use
  138582. * @param mesh The mesh to free.
  138583. * @hidden
  138584. */
  138585. _disposeMesh(mesh: Mesh): void;
  138586. /**
  138587. * Dispose the highlight layer and free resources.
  138588. */
  138589. dispose(): void;
  138590. /**
  138591. * Gets the class name of the effect layer
  138592. * @returns the string with the class name of the effect layer
  138593. */
  138594. getClassName(): string;
  138595. /**
  138596. * Serializes this Highlight layer
  138597. * @returns a serialized Highlight layer object
  138598. */
  138599. serialize(): any;
  138600. /**
  138601. * Creates a Highlight layer from parsed Highlight layer data
  138602. * @param parsedHightlightLayer defines the Highlight layer data
  138603. * @param scene defines the current scene
  138604. * @param rootUrl defines the root URL containing the Highlight layer information
  138605. * @returns a parsed Highlight layer
  138606. */
  138607. static Parse(parsedHightlightLayer: any, scene: Scene, rootUrl: string): HighlightLayer;
  138608. }
  138609. }
  138610. declare module BABYLON {
  138611. interface AbstractScene {
  138612. /**
  138613. * The list of layers (background and foreground) of the scene
  138614. */
  138615. layers: Array<Layer>;
  138616. }
  138617. /**
  138618. * Defines the layer scene component responsible to manage any layers
  138619. * in a given scene.
  138620. */
  138621. export class LayerSceneComponent implements ISceneComponent {
  138622. /**
  138623. * The component name helpfull to identify the component in the list of scene components.
  138624. */
  138625. readonly name: string;
  138626. /**
  138627. * The scene the component belongs to.
  138628. */
  138629. scene: Scene;
  138630. private _engine;
  138631. /**
  138632. * Creates a new instance of the component for the given scene
  138633. * @param scene Defines the scene to register the component in
  138634. */
  138635. constructor(scene: Scene);
  138636. /**
  138637. * Registers the component in a given scene
  138638. */
  138639. register(): void;
  138640. /**
  138641. * Rebuilds the elements related to this component in case of
  138642. * context lost for instance.
  138643. */
  138644. rebuild(): void;
  138645. /**
  138646. * Disposes the component and the associated ressources.
  138647. */
  138648. dispose(): void;
  138649. private _draw;
  138650. private _drawCameraPredicate;
  138651. private _drawCameraBackground;
  138652. private _drawCameraForeground;
  138653. private _drawRenderTargetPredicate;
  138654. private _drawRenderTargetBackground;
  138655. private _drawRenderTargetForeground;
  138656. /**
  138657. * Adds all the elements from the container to the scene
  138658. * @param container the container holding the elements
  138659. */
  138660. addFromContainer(container: AbstractScene): void;
  138661. /**
  138662. * Removes all the elements in the container from the scene
  138663. * @param container contains the elements to remove
  138664. * @param dispose if the removed element should be disposed (default: false)
  138665. */
  138666. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  138667. }
  138668. }
  138669. declare module BABYLON {
  138670. /** @hidden */
  138671. export var layerPixelShader: {
  138672. name: string;
  138673. shader: string;
  138674. };
  138675. }
  138676. declare module BABYLON {
  138677. /** @hidden */
  138678. export var layerVertexShader: {
  138679. name: string;
  138680. shader: string;
  138681. };
  138682. }
  138683. declare module BABYLON {
  138684. /**
  138685. * This represents a full screen 2d layer.
  138686. * This can be useful to display a picture in the background of your scene for instance.
  138687. * @see https://www.babylonjs-playground.com/#08A2BS#1
  138688. */
  138689. export class Layer {
  138690. /**
  138691. * Define the name of the layer.
  138692. */
  138693. name: string;
  138694. /**
  138695. * Define the texture the layer should display.
  138696. */
  138697. texture: Nullable<Texture>;
  138698. /**
  138699. * Is the layer in background or foreground.
  138700. */
  138701. isBackground: boolean;
  138702. /**
  138703. * Define the color of the layer (instead of texture).
  138704. */
  138705. color: Color4;
  138706. /**
  138707. * Define the scale of the layer in order to zoom in out of the texture.
  138708. */
  138709. scale: Vector2;
  138710. /**
  138711. * Define an offset for the layer in order to shift the texture.
  138712. */
  138713. offset: Vector2;
  138714. /**
  138715. * Define the alpha blending mode used in the layer in case the texture or color has an alpha.
  138716. */
  138717. alphaBlendingMode: number;
  138718. /**
  138719. * Define if the layer should alpha test or alpha blend with the rest of the scene.
  138720. * Alpha test will not mix with the background color in case of transparency.
  138721. * It will either use the texture color or the background depending on the alpha value of the current pixel.
  138722. */
  138723. alphaTest: boolean;
  138724. /**
  138725. * Define a mask to restrict the layer to only some of the scene cameras.
  138726. */
  138727. layerMask: number;
  138728. /**
  138729. * Define the list of render target the layer is visible into.
  138730. */
  138731. renderTargetTextures: RenderTargetTexture[];
  138732. /**
  138733. * Define if the layer is only used in renderTarget or if it also
  138734. * renders in the main frame buffer of the canvas.
  138735. */
  138736. renderOnlyInRenderTargetTextures: boolean;
  138737. private _scene;
  138738. private _vertexBuffers;
  138739. private _indexBuffer;
  138740. private _effect;
  138741. private _previousDefines;
  138742. /**
  138743. * An event triggered when the layer is disposed.
  138744. */
  138745. onDisposeObservable: Observable<Layer>;
  138746. private _onDisposeObserver;
  138747. /**
  138748. * Back compatibility with callback before the onDisposeObservable existed.
  138749. * The set callback will be triggered when the layer has been disposed.
  138750. */
  138751. set onDispose(callback: () => void);
  138752. /**
  138753. * An event triggered before rendering the scene
  138754. */
  138755. onBeforeRenderObservable: Observable<Layer>;
  138756. private _onBeforeRenderObserver;
  138757. /**
  138758. * Back compatibility with callback before the onBeforeRenderObservable existed.
  138759. * The set callback will be triggered just before rendering the layer.
  138760. */
  138761. set onBeforeRender(callback: () => void);
  138762. /**
  138763. * An event triggered after rendering the scene
  138764. */
  138765. onAfterRenderObservable: Observable<Layer>;
  138766. private _onAfterRenderObserver;
  138767. /**
  138768. * Back compatibility with callback before the onAfterRenderObservable existed.
  138769. * The set callback will be triggered just after rendering the layer.
  138770. */
  138771. set onAfterRender(callback: () => void);
  138772. /**
  138773. * Instantiates a new layer.
  138774. * This represents a full screen 2d layer.
  138775. * This can be useful to display a picture in the background of your scene for instance.
  138776. * @see https://www.babylonjs-playground.com/#08A2BS#1
  138777. * @param name Define the name of the layer in the scene
  138778. * @param imgUrl Define the url of the texture to display in the layer
  138779. * @param scene Define the scene the layer belongs to
  138780. * @param isBackground Defines whether the layer is displayed in front or behind the scene
  138781. * @param color Defines a color for the layer
  138782. */
  138783. constructor(
  138784. /**
  138785. * Define the name of the layer.
  138786. */
  138787. name: string, imgUrl: Nullable<string>, scene: Nullable<Scene>, isBackground?: boolean, color?: Color4);
  138788. private _createIndexBuffer;
  138789. /** @hidden */
  138790. _rebuild(): void;
  138791. /**
  138792. * Renders the layer in the scene.
  138793. */
  138794. render(): void;
  138795. /**
  138796. * Disposes and releases the associated ressources.
  138797. */
  138798. dispose(): void;
  138799. }
  138800. }
  138801. declare module BABYLON {
  138802. /** @hidden */
  138803. export var lensFlarePixelShader: {
  138804. name: string;
  138805. shader: string;
  138806. };
  138807. }
  138808. declare module BABYLON {
  138809. /** @hidden */
  138810. export var lensFlareVertexShader: {
  138811. name: string;
  138812. shader: string;
  138813. };
  138814. }
  138815. declare module BABYLON {
  138816. /**
  138817. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  138818. * It is usually composed of several `lensFlare`.
  138819. * @see https://doc.babylonjs.com/how_to/how_to_use_lens_flares
  138820. */
  138821. export class LensFlareSystem {
  138822. /**
  138823. * Define the name of the lens flare system
  138824. */
  138825. name: string;
  138826. /**
  138827. * List of lens flares used in this system.
  138828. */
  138829. lensFlares: LensFlare[];
  138830. /**
  138831. * Define a limit from the border the lens flare can be visible.
  138832. */
  138833. borderLimit: number;
  138834. /**
  138835. * Define a viewport border we do not want to see the lens flare in.
  138836. */
  138837. viewportBorder: number;
  138838. /**
  138839. * Define a predicate which could limit the list of meshes able to occlude the effect.
  138840. */
  138841. meshesSelectionPredicate: (mesh: AbstractMesh) => boolean;
  138842. /**
  138843. * Restricts the rendering of the effect to only the camera rendering this layer mask.
  138844. */
  138845. layerMask: number;
  138846. /**
  138847. * Define the id of the lens flare system in the scene.
  138848. * (equal to name by default)
  138849. */
  138850. id: string;
  138851. private _scene;
  138852. private _emitter;
  138853. private _vertexBuffers;
  138854. private _indexBuffer;
  138855. private _effect;
  138856. private _positionX;
  138857. private _positionY;
  138858. private _isEnabled;
  138859. /** @hidden */
  138860. static _SceneComponentInitialization: (scene: Scene) => void;
  138861. /**
  138862. * Instantiates a lens flare system.
  138863. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  138864. * It is usually composed of several `lensFlare`.
  138865. * @see https://doc.babylonjs.com/how_to/how_to_use_lens_flares
  138866. * @param name Define the name of the lens flare system in the scene
  138867. * @param emitter Define the source (the emitter) of the lens flares (it can be a camera, a light or a mesh).
  138868. * @param scene Define the scene the lens flare system belongs to
  138869. */
  138870. constructor(
  138871. /**
  138872. * Define the name of the lens flare system
  138873. */
  138874. name: string, emitter: any, scene: Scene);
  138875. /**
  138876. * Define if the lens flare system is enabled.
  138877. */
  138878. get isEnabled(): boolean;
  138879. set isEnabled(value: boolean);
  138880. /**
  138881. * Get the scene the effects belongs to.
  138882. * @returns the scene holding the lens flare system
  138883. */
  138884. getScene(): Scene;
  138885. /**
  138886. * Get the emitter of the lens flare system.
  138887. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  138888. * @returns the emitter of the lens flare system
  138889. */
  138890. getEmitter(): any;
  138891. /**
  138892. * Set the emitter of the lens flare system.
  138893. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  138894. * @param newEmitter Define the new emitter of the system
  138895. */
  138896. setEmitter(newEmitter: any): void;
  138897. /**
  138898. * Get the lens flare system emitter position.
  138899. * The emitter defines the source of the lens flares (it can be a camera, a light or a mesh).
  138900. * @returns the position
  138901. */
  138902. getEmitterPosition(): Vector3;
  138903. /**
  138904. * @hidden
  138905. */
  138906. computeEffectivePosition(globalViewport: Viewport): boolean;
  138907. /** @hidden */
  138908. _isVisible(): boolean;
  138909. /**
  138910. * @hidden
  138911. */
  138912. render(): boolean;
  138913. /**
  138914. * Dispose and release the lens flare with its associated resources.
  138915. */
  138916. dispose(): void;
  138917. /**
  138918. * Parse a lens flare system from a JSON repressentation
  138919. * @param parsedLensFlareSystem Define the JSON to parse
  138920. * @param scene Define the scene the parsed system should be instantiated in
  138921. * @param rootUrl Define the rootUrl of the load sequence to easily find a load relative dependencies such as textures
  138922. * @returns the parsed system
  138923. */
  138924. static Parse(parsedLensFlareSystem: any, scene: Scene, rootUrl: string): LensFlareSystem;
  138925. /**
  138926. * Serialize the current Lens Flare System into a JSON representation.
  138927. * @returns the serialized JSON
  138928. */
  138929. serialize(): any;
  138930. }
  138931. }
  138932. declare module BABYLON {
  138933. /**
  138934. * This represents one of the lens effect in a `lensFlareSystem`.
  138935. * It controls one of the indiviual texture used in the effect.
  138936. * @see https://doc.babylonjs.com/how_to/how_to_use_lens_flares
  138937. */
  138938. export class LensFlare {
  138939. /**
  138940. * Define the size of the lens flare in the system (a floating value between 0 and 1)
  138941. */
  138942. size: number;
  138943. /**
  138944. * 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.
  138945. */
  138946. position: number;
  138947. /**
  138948. * Define the lens color.
  138949. */
  138950. color: Color3;
  138951. /**
  138952. * Define the lens texture.
  138953. */
  138954. texture: Nullable<Texture>;
  138955. /**
  138956. * Define the alpha mode to render this particular lens.
  138957. */
  138958. alphaMode: number;
  138959. private _system;
  138960. /**
  138961. * Creates a new Lens Flare.
  138962. * This represents one of the lens effect in a `lensFlareSystem`.
  138963. * It controls one of the indiviual texture used in the effect.
  138964. * @see https://doc.babylonjs.com/how_to/how_to_use_lens_flares
  138965. * @param size Define the size of the lens flare (a floating value between 0 and 1)
  138966. * @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.
  138967. * @param color Define the lens color
  138968. * @param imgUrl Define the lens texture url
  138969. * @param system Define the `lensFlareSystem` this flare is part of
  138970. * @returns The newly created Lens Flare
  138971. */
  138972. static AddFlare(size: number, position: number, color: Color3, imgUrl: string, system: LensFlareSystem): LensFlare;
  138973. /**
  138974. * Instantiates a new Lens Flare.
  138975. * This represents one of the lens effect in a `lensFlareSystem`.
  138976. * It controls one of the indiviual texture used in the effect.
  138977. * @see https://doc.babylonjs.com/how_to/how_to_use_lens_flares
  138978. * @param size Define the size of the lens flare in the system (a floating value between 0 and 1)
  138979. * @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.
  138980. * @param color Define the lens color
  138981. * @param imgUrl Define the lens texture url
  138982. * @param system Define the `lensFlareSystem` this flare is part of
  138983. */
  138984. constructor(
  138985. /**
  138986. * Define the size of the lens flare in the system (a floating value between 0 and 1)
  138987. */
  138988. size: number,
  138989. /**
  138990. * 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.
  138991. */
  138992. position: number, color: Color3, imgUrl: string, system: LensFlareSystem);
  138993. /**
  138994. * Dispose and release the lens flare with its associated resources.
  138995. */
  138996. dispose(): void;
  138997. }
  138998. }
  138999. declare module BABYLON {
  139000. interface AbstractScene {
  139001. /**
  139002. * The list of lens flare system added to the scene
  139003. * @see https://doc.babylonjs.com/how_to/how_to_use_lens_flares
  139004. */
  139005. lensFlareSystems: Array<LensFlareSystem>;
  139006. /**
  139007. * Removes the given lens flare system from this scene.
  139008. * @param toRemove The lens flare system to remove
  139009. * @returns The index of the removed lens flare system
  139010. */
  139011. removeLensFlareSystem(toRemove: LensFlareSystem): number;
  139012. /**
  139013. * Adds the given lens flare system to this scene
  139014. * @param newLensFlareSystem The lens flare system to add
  139015. */
  139016. addLensFlareSystem(newLensFlareSystem: LensFlareSystem): void;
  139017. /**
  139018. * Gets a lens flare system using its name
  139019. * @param name defines the name to look for
  139020. * @returns the lens flare system or null if not found
  139021. */
  139022. getLensFlareSystemByName(name: string): Nullable<LensFlareSystem>;
  139023. /**
  139024. * Gets a lens flare system using its id
  139025. * @param id defines the id to look for
  139026. * @returns the lens flare system or null if not found
  139027. */
  139028. getLensFlareSystemByID(id: string): Nullable<LensFlareSystem>;
  139029. }
  139030. /**
  139031. * Defines the lens flare scene component responsible to manage any lens flares
  139032. * in a given scene.
  139033. */
  139034. export class LensFlareSystemSceneComponent implements ISceneSerializableComponent {
  139035. /**
  139036. * The component name helpfull to identify the component in the list of scene components.
  139037. */
  139038. readonly name: string;
  139039. /**
  139040. * The scene the component belongs to.
  139041. */
  139042. scene: Scene;
  139043. /**
  139044. * Creates a new instance of the component for the given scene
  139045. * @param scene Defines the scene to register the component in
  139046. */
  139047. constructor(scene: Scene);
  139048. /**
  139049. * Registers the component in a given scene
  139050. */
  139051. register(): void;
  139052. /**
  139053. * Rebuilds the elements related to this component in case of
  139054. * context lost for instance.
  139055. */
  139056. rebuild(): void;
  139057. /**
  139058. * Adds all the elements from the container to the scene
  139059. * @param container the container holding the elements
  139060. */
  139061. addFromContainer(container: AbstractScene): void;
  139062. /**
  139063. * Removes all the elements in the container from the scene
  139064. * @param container contains the elements to remove
  139065. * @param dispose if the removed element should be disposed (default: false)
  139066. */
  139067. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  139068. /**
  139069. * Serializes the component data to the specified json object
  139070. * @param serializationObject The object to serialize to
  139071. */
  139072. serialize(serializationObject: any): void;
  139073. /**
  139074. * Disposes the component and the associated ressources.
  139075. */
  139076. dispose(): void;
  139077. private _draw;
  139078. }
  139079. }
  139080. declare module BABYLON {
  139081. /** @hidden */
  139082. export var depthPixelShader: {
  139083. name: string;
  139084. shader: string;
  139085. };
  139086. }
  139087. declare module BABYLON {
  139088. /** @hidden */
  139089. export var depthVertexShader: {
  139090. name: string;
  139091. shader: string;
  139092. };
  139093. }
  139094. declare module BABYLON {
  139095. /**
  139096. * This represents a depth renderer in Babylon.
  139097. * A depth renderer will render to it's depth map every frame which can be displayed or used in post processing
  139098. */
  139099. export class DepthRenderer {
  139100. private _scene;
  139101. private _depthMap;
  139102. private _effect;
  139103. private readonly _storeNonLinearDepth;
  139104. private readonly _clearColor;
  139105. /** Get if the depth renderer is using packed depth or not */
  139106. readonly isPacked: boolean;
  139107. private _cachedDefines;
  139108. private _camera;
  139109. /** Enable or disable the depth renderer. When disabled, the depth texture is not updated */
  139110. enabled: boolean;
  139111. /**
  139112. * Specifiess that the depth renderer will only be used within
  139113. * the camera it is created for.
  139114. * This can help forcing its rendering during the camera processing.
  139115. */
  139116. useOnlyInActiveCamera: boolean;
  139117. /** @hidden */
  139118. static _SceneComponentInitialization: (scene: Scene) => void;
  139119. /**
  139120. * Instantiates a depth renderer
  139121. * @param scene The scene the renderer belongs to
  139122. * @param type The texture type of the depth map (default: Engine.TEXTURETYPE_FLOAT)
  139123. * @param camera The camera to be used to render the depth map (default: scene's active camera)
  139124. * @param storeNonLinearDepth Defines whether the depth is stored linearly like in Babylon Shadows or directly like glFragCoord.z
  139125. */
  139126. constructor(scene: Scene, type?: number, camera?: Nullable<Camera>, storeNonLinearDepth?: boolean);
  139127. /**
  139128. * Creates the depth rendering effect and checks if the effect is ready.
  139129. * @param subMesh The submesh to be used to render the depth map of
  139130. * @param useInstances If multiple world instances should be used
  139131. * @returns if the depth renderer is ready to render the depth map
  139132. */
  139133. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  139134. /**
  139135. * Gets the texture which the depth map will be written to.
  139136. * @returns The depth map texture
  139137. */
  139138. getDepthMap(): RenderTargetTexture;
  139139. /**
  139140. * Disposes of the depth renderer.
  139141. */
  139142. dispose(): void;
  139143. }
  139144. }
  139145. declare module BABYLON {
  139146. /** @hidden */
  139147. export var minmaxReduxPixelShader: {
  139148. name: string;
  139149. shader: string;
  139150. };
  139151. }
  139152. declare module BABYLON {
  139153. /**
  139154. * This class computes a min/max reduction from a texture: it means it computes the minimum
  139155. * and maximum values from all values of the texture.
  139156. * It is performed on the GPU for better performances, thanks to a succession of post processes.
  139157. * The source values are read from the red channel of the texture.
  139158. */
  139159. export class MinMaxReducer {
  139160. /**
  139161. * Observable triggered when the computation has been performed
  139162. */
  139163. onAfterReductionPerformed: Observable<{
  139164. min: number;
  139165. max: number;
  139166. }>;
  139167. protected _camera: Camera;
  139168. protected _sourceTexture: Nullable<RenderTargetTexture>;
  139169. protected _reductionSteps: Nullable<Array<PostProcess>>;
  139170. protected _postProcessManager: PostProcessManager;
  139171. protected _onAfterUnbindObserver: Nullable<Observer<RenderTargetTexture>>;
  139172. protected _forceFullscreenViewport: boolean;
  139173. /**
  139174. * Creates a min/max reducer
  139175. * @param camera The camera to use for the post processes
  139176. */
  139177. constructor(camera: Camera);
  139178. /**
  139179. * Gets the texture used to read the values from.
  139180. */
  139181. get sourceTexture(): Nullable<RenderTargetTexture>;
  139182. /**
  139183. * Sets the source texture to read the values from.
  139184. * One must indicate if the texture is a depth texture or not through the depthRedux parameter
  139185. * because in such textures '1' value must not be taken into account to compute the maximum
  139186. * as this value is used to clear the texture.
  139187. * Note that the computation is not activated by calling this function, you must call activate() for that!
  139188. * @param sourceTexture The texture to read the values from. The values should be in the red channel.
  139189. * @param depthRedux Indicates if the texture is a depth texture or not
  139190. * @param type The type of the textures created for the reduction (defaults to TEXTURETYPE_HALF_FLOAT)
  139191. * @param forceFullscreenViewport Forces the post processes used for the reduction to be applied without taking into account viewport (defaults to true)
  139192. */
  139193. setSourceTexture(sourceTexture: RenderTargetTexture, depthRedux: boolean, type?: number, forceFullscreenViewport?: boolean): void;
  139194. /**
  139195. * Defines the refresh rate of the computation.
  139196. * Use 0 to compute just once, 1 to compute on every frame, 2 to compute every two frames and so on...
  139197. */
  139198. get refreshRate(): number;
  139199. set refreshRate(value: number);
  139200. protected _activated: boolean;
  139201. /**
  139202. * Gets the activation status of the reducer
  139203. */
  139204. get activated(): boolean;
  139205. /**
  139206. * Activates the reduction computation.
  139207. * When activated, the observers registered in onAfterReductionPerformed are
  139208. * called after the compuation is performed
  139209. */
  139210. activate(): void;
  139211. /**
  139212. * Deactivates the reduction computation.
  139213. */
  139214. deactivate(): void;
  139215. /**
  139216. * Disposes the min/max reducer
  139217. * @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.
  139218. */
  139219. dispose(disposeAll?: boolean): void;
  139220. }
  139221. }
  139222. declare module BABYLON {
  139223. /**
  139224. * This class is a small wrapper around the MinMaxReducer class to compute the min/max values of a depth texture
  139225. */
  139226. export class DepthReducer extends MinMaxReducer {
  139227. private _depthRenderer;
  139228. private _depthRendererId;
  139229. /**
  139230. * Gets the depth renderer used for the computation.
  139231. * Note that the result is null if you provide your own renderer when calling setDepthRenderer.
  139232. */
  139233. get depthRenderer(): Nullable<DepthRenderer>;
  139234. /**
  139235. * Creates a depth reducer
  139236. * @param camera The camera used to render the depth texture
  139237. */
  139238. constructor(camera: Camera);
  139239. /**
  139240. * Sets the depth renderer to use to generate the depth map
  139241. * @param depthRenderer The depth renderer to use. If not provided, a new one will be created automatically
  139242. * @param type The texture type of the depth map (default: TEXTURETYPE_HALF_FLOAT)
  139243. * @param forceFullscreenViewport Forces the post processes used for the reduction to be applied without taking into account viewport (defaults to true)
  139244. */
  139245. setDepthRenderer(depthRenderer?: Nullable<DepthRenderer>, type?: number, forceFullscreenViewport?: boolean): void;
  139246. /** @hidden */
  139247. setSourceTexture(sourceTexture: RenderTargetTexture, depthRedux: boolean, type?: number, forceFullscreenViewport?: boolean): void;
  139248. /**
  139249. * Activates the reduction computation.
  139250. * When activated, the observers registered in onAfterReductionPerformed are
  139251. * called after the compuation is performed
  139252. */
  139253. activate(): void;
  139254. /**
  139255. * Deactivates the reduction computation.
  139256. */
  139257. deactivate(): void;
  139258. /**
  139259. * Disposes the depth reducer
  139260. * @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.
  139261. */
  139262. dispose(disposeAll?: boolean): void;
  139263. }
  139264. }
  139265. declare module BABYLON {
  139266. /**
  139267. * A CSM implementation allowing casting shadows on large scenes.
  139268. * Documentation : https://doc.babylonjs.com/babylon101/cascadedShadows
  139269. * Based on: https://github.com/TheRealMJP/Shadows and https://johanmedestrom.wordpress.com/2016/03/18/opengl-cascaded-shadow-maps/
  139270. */
  139271. export class CascadedShadowGenerator extends ShadowGenerator {
  139272. private static readonly frustumCornersNDCSpace;
  139273. /**
  139274. * Name of the CSM class
  139275. */
  139276. static CLASSNAME: string;
  139277. /**
  139278. * Defines the default number of cascades used by the CSM.
  139279. */
  139280. static readonly DEFAULT_CASCADES_COUNT: number;
  139281. /**
  139282. * Defines the minimum number of cascades used by the CSM.
  139283. */
  139284. static readonly MIN_CASCADES_COUNT: number;
  139285. /**
  139286. * Defines the maximum number of cascades used by the CSM.
  139287. */
  139288. static readonly MAX_CASCADES_COUNT: number;
  139289. protected _validateFilter(filter: number): number;
  139290. /**
  139291. * Gets or sets the actual darkness of the soft shadows while using PCSS filtering (value between 0. and 1.)
  139292. */
  139293. penumbraDarkness: number;
  139294. private _numCascades;
  139295. /**
  139296. * Gets or set the number of cascades used by the CSM.
  139297. */
  139298. get numCascades(): number;
  139299. set numCascades(value: number);
  139300. /**
  139301. * Sets this to true if you want that the edges of the shadows don't "swimm" / "shimmer" when rotating the camera.
  139302. * The trade off is that you lose some precision in the shadow rendering when enabling this setting.
  139303. */
  139304. stabilizeCascades: boolean;
  139305. private _freezeShadowCastersBoundingInfo;
  139306. private _freezeShadowCastersBoundingInfoObservable;
  139307. /**
  139308. * Enables or disables the shadow casters bounding info computation.
  139309. * If your shadow casters don't move, you can disable this feature.
  139310. * If it is enabled, the bounding box computation is done every frame.
  139311. */
  139312. get freezeShadowCastersBoundingInfo(): boolean;
  139313. set freezeShadowCastersBoundingInfo(freeze: boolean);
  139314. private _scbiMin;
  139315. private _scbiMax;
  139316. protected _computeShadowCastersBoundingInfo(): void;
  139317. protected _shadowCastersBoundingInfo: BoundingInfo;
  139318. /**
  139319. * Gets or sets the shadow casters bounding info.
  139320. * If you provide your own shadow casters bounding info, first enable freezeShadowCastersBoundingInfo
  139321. * so that the system won't overwrite the bounds you provide
  139322. */
  139323. get shadowCastersBoundingInfo(): BoundingInfo;
  139324. set shadowCastersBoundingInfo(boundingInfo: BoundingInfo);
  139325. protected _breaksAreDirty: boolean;
  139326. protected _minDistance: number;
  139327. protected _maxDistance: number;
  139328. /**
  139329. * Sets the minimal and maximal distances to use when computing the cascade breaks.
  139330. *
  139331. * The values of min / max are typically the depth zmin and zmax values of your scene, for a given frame.
  139332. * If you don't know these values, simply leave them to their defaults and don't call this function.
  139333. * @param min minimal distance for the breaks (default to 0.)
  139334. * @param max maximal distance for the breaks (default to 1.)
  139335. */
  139336. setMinMaxDistance(min: number, max: number): void;
  139337. /** Gets the minimal distance used in the cascade break computation */
  139338. get minDistance(): number;
  139339. /** Gets the maximal distance used in the cascade break computation */
  139340. get maxDistance(): number;
  139341. /**
  139342. * Gets the class name of that object
  139343. * @returns "CascadedShadowGenerator"
  139344. */
  139345. getClassName(): string;
  139346. private _cascadeMinExtents;
  139347. private _cascadeMaxExtents;
  139348. /**
  139349. * Gets a cascade minimum extents
  139350. * @param cascadeIndex index of the cascade
  139351. * @returns the minimum cascade extents
  139352. */
  139353. getCascadeMinExtents(cascadeIndex: number): Nullable<Vector3>;
  139354. /**
  139355. * Gets a cascade maximum extents
  139356. * @param cascadeIndex index of the cascade
  139357. * @returns the maximum cascade extents
  139358. */
  139359. getCascadeMaxExtents(cascadeIndex: number): Nullable<Vector3>;
  139360. private _cascades;
  139361. private _currentLayer;
  139362. private _viewSpaceFrustumsZ;
  139363. private _viewMatrices;
  139364. private _projectionMatrices;
  139365. private _transformMatrices;
  139366. private _transformMatricesAsArray;
  139367. private _frustumLengths;
  139368. private _lightSizeUVCorrection;
  139369. private _depthCorrection;
  139370. private _frustumCornersWorldSpace;
  139371. private _frustumCenter;
  139372. private _shadowCameraPos;
  139373. private _shadowMaxZ;
  139374. /**
  139375. * Gets the shadow max z distance. It's the limit beyond which shadows are not displayed.
  139376. * It defaults to camera.maxZ
  139377. */
  139378. get shadowMaxZ(): number;
  139379. /**
  139380. * Sets the shadow max z distance.
  139381. */
  139382. set shadowMaxZ(value: number);
  139383. protected _debug: boolean;
  139384. /**
  139385. * Gets or sets the debug flag.
  139386. * When enabled, the cascades are materialized by different colors on the screen.
  139387. */
  139388. get debug(): boolean;
  139389. set debug(dbg: boolean);
  139390. private _depthClamp;
  139391. /**
  139392. * Gets or sets the depth clamping value.
  139393. *
  139394. * When enabled, it improves the shadow quality because the near z plane of the light frustum don't need to be adjusted
  139395. * to account for the shadow casters far away.
  139396. *
  139397. * Note that this property is incompatible with PCSS filtering, so it won't be used in that case.
  139398. */
  139399. get depthClamp(): boolean;
  139400. set depthClamp(value: boolean);
  139401. private _cascadeBlendPercentage;
  139402. /**
  139403. * Gets or sets the percentage of blending between two cascades (value between 0. and 1.).
  139404. * It defaults to 0.1 (10% blending).
  139405. */
  139406. get cascadeBlendPercentage(): number;
  139407. set cascadeBlendPercentage(value: number);
  139408. private _lambda;
  139409. /**
  139410. * Gets or set the lambda parameter.
  139411. * This parameter is used to split the camera frustum and create the cascades.
  139412. * 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.
  139413. * For all values in-between, it's a linear combination of the uniform and logarithm split algorithm.
  139414. */
  139415. get lambda(): number;
  139416. set lambda(value: number);
  139417. /**
  139418. * Gets the view matrix corresponding to a given cascade
  139419. * @param cascadeNum cascade to retrieve the view matrix from
  139420. * @returns the cascade view matrix
  139421. */
  139422. getCascadeViewMatrix(cascadeNum: number): Nullable<Matrix>;
  139423. /**
  139424. * Gets the projection matrix corresponding to a given cascade
  139425. * @param cascadeNum cascade to retrieve the projection matrix from
  139426. * @returns the cascade projection matrix
  139427. */
  139428. getCascadeProjectionMatrix(cascadeNum: number): Nullable<Matrix>;
  139429. /**
  139430. * Gets the transformation matrix corresponding to a given cascade
  139431. * @param cascadeNum cascade to retrieve the transformation matrix from
  139432. * @returns the cascade transformation matrix
  139433. */
  139434. getCascadeTransformMatrix(cascadeNum: number): Nullable<Matrix>;
  139435. private _depthRenderer;
  139436. /**
  139437. * Sets the depth renderer to use when autoCalcDepthBounds is enabled.
  139438. *
  139439. * Note that if no depth renderer is set, a new one will be automatically created internally when necessary.
  139440. *
  139441. * You should call this function if you already have a depth renderer enabled in your scene, to avoid
  139442. * doing multiple depth rendering each frame. If you provide your own depth renderer, make sure it stores linear depth!
  139443. * @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
  139444. */
  139445. setDepthRenderer(depthRenderer: Nullable<DepthRenderer>): void;
  139446. private _depthReducer;
  139447. private _autoCalcDepthBounds;
  139448. /**
  139449. * Gets or sets the autoCalcDepthBounds property.
  139450. *
  139451. * When enabled, a depth rendering pass is first performed (with an internally created depth renderer or with the one
  139452. * you provide by calling setDepthRenderer). Then, a min/max reducing is applied on the depth map to compute the
  139453. * minimal and maximal depth of the map and those values are used as inputs for the setMinMaxDistance() function.
  139454. * It can greatly enhance the shadow quality, at the expense of more GPU works.
  139455. * When using this option, you should increase the value of the lambda parameter, and even set it to 1 for best results.
  139456. */
  139457. get autoCalcDepthBounds(): boolean;
  139458. set autoCalcDepthBounds(value: boolean);
  139459. /**
  139460. * Defines the refresh rate of the min/max computation used when autoCalcDepthBounds is set to true
  139461. * Use 0 to compute just once, 1 to compute on every frame, 2 to compute every two frames and so on...
  139462. * Note that if you provided your own depth renderer through a call to setDepthRenderer, you are responsible
  139463. * for setting the refresh rate on the renderer yourself!
  139464. */
  139465. get autoCalcDepthBoundsRefreshRate(): number;
  139466. set autoCalcDepthBoundsRefreshRate(value: number);
  139467. /**
  139468. * Create the cascade breaks according to the lambda, shadowMaxZ and min/max distance properties, as well as the camera near and far planes.
  139469. * This function is automatically called when updating lambda, shadowMaxZ and min/max distances, however you should call it yourself if
  139470. * you change the camera near/far planes!
  139471. */
  139472. splitFrustum(): void;
  139473. private _splitFrustum;
  139474. private _computeMatrices;
  139475. private _computeFrustumInWorldSpace;
  139476. private _computeCascadeFrustum;
  139477. /**
  139478. * Support test.
  139479. */
  139480. static get IsSupported(): boolean;
  139481. /** @hidden */
  139482. static _SceneComponentInitialization: (scene: Scene) => void;
  139483. /**
  139484. * Creates a Cascaded Shadow Generator object.
  139485. * A ShadowGenerator is the required tool to use the shadows.
  139486. * Each directional light casting shadows needs to use its own ShadowGenerator.
  139487. * Documentation : https://doc.babylonjs.com/babylon101/cascadedShadows
  139488. * @param mapSize The size of the texture what stores the shadows. Example : 1024.
  139489. * @param light The directional light object generating the shadows.
  139490. * @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.
  139491. */
  139492. constructor(mapSize: number, light: DirectionalLight, usefulFloatFirst?: boolean);
  139493. protected _initializeGenerator(): void;
  139494. protected _createTargetRenderTexture(): void;
  139495. protected _initializeShadowMap(): void;
  139496. protected _bindCustomEffectForRenderSubMeshForShadowMap(subMesh: SubMesh, effect: Effect, matriceNames: any, mesh: AbstractMesh): void;
  139497. protected _isReadyCustomDefines(defines: any, subMesh: SubMesh, useInstances: boolean): void;
  139498. /**
  139499. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  139500. * @param defines Defines of the material we want to update
  139501. * @param lightIndex Index of the light in the enabled light list of the material
  139502. */
  139503. prepareDefines(defines: any, lightIndex: number): void;
  139504. /**
  139505. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  139506. * defined in the generator but impacting the effect).
  139507. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  139508. * @param effect The effect we are binfing the information for
  139509. */
  139510. bindShadowLight(lightIndex: string, effect: Effect): void;
  139511. /**
  139512. * Gets the transformation matrix of the first cascade used to project the meshes into the map from the light point of view.
  139513. * (eq to view projection * shadow projection matrices)
  139514. * @returns The transform matrix used to create the shadow map
  139515. */
  139516. getTransformMatrix(): Matrix;
  139517. /**
  139518. * Disposes the ShadowGenerator.
  139519. * Returns nothing.
  139520. */
  139521. dispose(): void;
  139522. /**
  139523. * Serializes the shadow generator setup to a json object.
  139524. * @returns The serialized JSON object
  139525. */
  139526. serialize(): any;
  139527. /**
  139528. * Parses a serialized ShadowGenerator and returns a new ShadowGenerator.
  139529. * @param parsedShadowGenerator The JSON object to parse
  139530. * @param scene The scene to create the shadow map for
  139531. * @returns The parsed shadow generator
  139532. */
  139533. static Parse(parsedShadowGenerator: any, scene: Scene): ShadowGenerator;
  139534. }
  139535. }
  139536. declare module BABYLON {
  139537. /**
  139538. * Defines the shadow generator component responsible to manage any shadow generators
  139539. * in a given scene.
  139540. */
  139541. export class ShadowGeneratorSceneComponent implements ISceneSerializableComponent {
  139542. /**
  139543. * The component name helpfull to identify the component in the list of scene components.
  139544. */
  139545. readonly name: string;
  139546. /**
  139547. * The scene the component belongs to.
  139548. */
  139549. scene: Scene;
  139550. /**
  139551. * Creates a new instance of the component for the given scene
  139552. * @param scene Defines the scene to register the component in
  139553. */
  139554. constructor(scene: Scene);
  139555. /**
  139556. * Registers the component in a given scene
  139557. */
  139558. register(): void;
  139559. /**
  139560. * Rebuilds the elements related to this component in case of
  139561. * context lost for instance.
  139562. */
  139563. rebuild(): void;
  139564. /**
  139565. * Serializes the component data to the specified json object
  139566. * @param serializationObject The object to serialize to
  139567. */
  139568. serialize(serializationObject: any): void;
  139569. /**
  139570. * Adds all the elements from the container to the scene
  139571. * @param container the container holding the elements
  139572. */
  139573. addFromContainer(container: AbstractScene): void;
  139574. /**
  139575. * Removes all the elements in the container from the scene
  139576. * @param container contains the elements to remove
  139577. * @param dispose if the removed element should be disposed (default: false)
  139578. */
  139579. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  139580. /**
  139581. * Rebuilds the elements related to this component in case of
  139582. * context lost for instance.
  139583. */
  139584. dispose(): void;
  139585. private _gatherRenderTargets;
  139586. }
  139587. }
  139588. declare module BABYLON {
  139589. /**
  139590. * A point light is a light defined by an unique point in world space.
  139591. * The light is emitted in every direction from this point.
  139592. * A good example of a point light is a standard light bulb.
  139593. * Documentation: https://doc.babylonjs.com/babylon101/lights
  139594. */
  139595. export class PointLight extends ShadowLight {
  139596. private _shadowAngle;
  139597. /**
  139598. * Getter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  139599. * This specifies what angle the shadow will use to be created.
  139600. *
  139601. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  139602. */
  139603. get shadowAngle(): number;
  139604. /**
  139605. * Setter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  139606. * This specifies what angle the shadow will use to be created.
  139607. *
  139608. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  139609. */
  139610. set shadowAngle(value: number);
  139611. /**
  139612. * Gets the direction if it has been set.
  139613. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  139614. */
  139615. get direction(): Vector3;
  139616. /**
  139617. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  139618. */
  139619. set direction(value: Vector3);
  139620. /**
  139621. * Creates a PointLight object from the passed name and position (Vector3) and adds it in the scene.
  139622. * A PointLight emits the light in every direction.
  139623. * It can cast shadows.
  139624. * If the scene camera is already defined and you want to set your PointLight at the camera position, just set it :
  139625. * ```javascript
  139626. * var pointLight = new PointLight("pl", camera.position, scene);
  139627. * ```
  139628. * Documentation : https://doc.babylonjs.com/babylon101/lights
  139629. * @param name The light friendly name
  139630. * @param position The position of the point light in the scene
  139631. * @param scene The scene the lights belongs to
  139632. */
  139633. constructor(name: string, position: Vector3, scene: Scene);
  139634. /**
  139635. * Returns the string "PointLight"
  139636. * @returns the class name
  139637. */
  139638. getClassName(): string;
  139639. /**
  139640. * Returns the integer 0.
  139641. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  139642. */
  139643. getTypeID(): number;
  139644. /**
  139645. * Specifies wether or not the shadowmap should be a cube texture.
  139646. * @returns true if the shadowmap needs to be a cube texture.
  139647. */
  139648. needCube(): boolean;
  139649. /**
  139650. * Returns a new Vector3 aligned with the PointLight cube system according to the passed cube face index (integer).
  139651. * @param faceIndex The index of the face we are computed the direction to generate shadow
  139652. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  139653. */
  139654. getShadowDirection(faceIndex?: number): Vector3;
  139655. /**
  139656. * Sets the passed matrix "matrix" as a left-handed perspective projection matrix with the following settings :
  139657. * - fov = PI / 2
  139658. * - aspect ratio : 1.0
  139659. * - z-near and far equal to the active camera minZ and maxZ.
  139660. * Returns the PointLight.
  139661. */
  139662. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  139663. protected _buildUniformLayout(): void;
  139664. /**
  139665. * Sets the passed Effect "effect" with the PointLight transformed position (or position, if none) and passed name (string).
  139666. * @param effect The effect to update
  139667. * @param lightIndex The index of the light in the effect to update
  139668. * @returns The point light
  139669. */
  139670. transferToEffect(effect: Effect, lightIndex: string): PointLight;
  139671. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): this;
  139672. /**
  139673. * Prepares the list of defines specific to the light type.
  139674. * @param defines the list of defines
  139675. * @param lightIndex defines the index of the light for the effect
  139676. */
  139677. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  139678. }
  139679. }
  139680. declare module BABYLON {
  139681. /**
  139682. * Header information of HDR texture files.
  139683. */
  139684. export interface HDRInfo {
  139685. /**
  139686. * The height of the texture in pixels.
  139687. */
  139688. height: number;
  139689. /**
  139690. * The width of the texture in pixels.
  139691. */
  139692. width: number;
  139693. /**
  139694. * The index of the beginning of the data in the binary file.
  139695. */
  139696. dataPosition: number;
  139697. }
  139698. /**
  139699. * This groups tools to convert HDR texture to native colors array.
  139700. */
  139701. export class HDRTools {
  139702. private static Ldexp;
  139703. private static Rgbe2float;
  139704. private static readStringLine;
  139705. /**
  139706. * Reads header information from an RGBE texture stored in a native array.
  139707. * More information on this format are available here:
  139708. * https://en.wikipedia.org/wiki/RGBE_image_format
  139709. *
  139710. * @param uint8array The binary file stored in native array.
  139711. * @return The header information.
  139712. */
  139713. static RGBE_ReadHeader(uint8array: Uint8Array): HDRInfo;
  139714. /**
  139715. * Returns the cubemap information (each faces texture data) extracted from an RGBE texture.
  139716. * This RGBE texture needs to store the information as a panorama.
  139717. *
  139718. * More information on this format are available here:
  139719. * https://en.wikipedia.org/wiki/RGBE_image_format
  139720. *
  139721. * @param buffer The binary file stored in an array buffer.
  139722. * @param size The expected size of the extracted cubemap.
  139723. * @return The Cube Map information.
  139724. */
  139725. static GetCubeMapTextureData(buffer: ArrayBuffer, size: number): CubeMapInfo;
  139726. /**
  139727. * Returns the pixels data extracted from an RGBE texture.
  139728. * This pixels will be stored left to right up to down in the R G B order in one array.
  139729. *
  139730. * More information on this format are available here:
  139731. * https://en.wikipedia.org/wiki/RGBE_image_format
  139732. *
  139733. * @param uint8array The binary file stored in an array buffer.
  139734. * @param hdrInfo The header information of the file.
  139735. * @return The pixels data in RGB right to left up to down order.
  139736. */
  139737. static RGBE_ReadPixels(uint8array: Uint8Array, hdrInfo: HDRInfo): Float32Array;
  139738. private static RGBE_ReadPixels_RLE;
  139739. private static RGBE_ReadPixels_NOT_RLE;
  139740. }
  139741. }
  139742. declare module BABYLON {
  139743. /**
  139744. * Effect Render Options
  139745. */
  139746. export interface IEffectRendererOptions {
  139747. /**
  139748. * Defines the vertices positions.
  139749. */
  139750. positions?: number[];
  139751. /**
  139752. * Defines the indices.
  139753. */
  139754. indices?: number[];
  139755. }
  139756. /**
  139757. * Helper class to render one or more effects.
  139758. * You can access the previous rendering in your shader by declaring a sampler named textureSampler
  139759. */
  139760. export class EffectRenderer {
  139761. private engine;
  139762. private static _DefaultOptions;
  139763. private _vertexBuffers;
  139764. private _indexBuffer;
  139765. private _fullscreenViewport;
  139766. /**
  139767. * Creates an effect renderer
  139768. * @param engine the engine to use for rendering
  139769. * @param options defines the options of the effect renderer
  139770. */
  139771. constructor(engine: ThinEngine, options?: IEffectRendererOptions);
  139772. /**
  139773. * Sets the current viewport in normalized coordinates 0-1
  139774. * @param viewport Defines the viewport to set (defaults to 0 0 1 1)
  139775. */
  139776. setViewport(viewport?: Viewport): void;
  139777. /**
  139778. * Binds the embedded attributes buffer to the effect.
  139779. * @param effect Defines the effect to bind the attributes for
  139780. */
  139781. bindBuffers(effect: Effect): void;
  139782. /**
  139783. * Sets the current effect wrapper to use during draw.
  139784. * The effect needs to be ready before calling this api.
  139785. * This also sets the default full screen position attribute.
  139786. * @param effectWrapper Defines the effect to draw with
  139787. */
  139788. applyEffectWrapper(effectWrapper: EffectWrapper): void;
  139789. /**
  139790. * Restores engine states
  139791. */
  139792. restoreStates(): void;
  139793. /**
  139794. * Draws a full screen quad.
  139795. */
  139796. draw(): void;
  139797. private isRenderTargetTexture;
  139798. /**
  139799. * renders one or more effects to a specified texture
  139800. * @param effectWrapper the effect to renderer
  139801. * @param outputTexture texture to draw to, if null it will render to the screen.
  139802. */
  139803. render(effectWrapper: EffectWrapper, outputTexture?: Nullable<InternalTexture | RenderTargetTexture>): void;
  139804. /**
  139805. * Disposes of the effect renderer
  139806. */
  139807. dispose(): void;
  139808. }
  139809. /**
  139810. * Options to create an EffectWrapper
  139811. */
  139812. interface EffectWrapperCreationOptions {
  139813. /**
  139814. * Engine to use to create the effect
  139815. */
  139816. engine: ThinEngine;
  139817. /**
  139818. * Fragment shader for the effect
  139819. */
  139820. fragmentShader: string;
  139821. /**
  139822. * Use the shader store instead of direct source code
  139823. */
  139824. useShaderStore?: boolean;
  139825. /**
  139826. * Vertex shader for the effect
  139827. */
  139828. vertexShader?: string;
  139829. /**
  139830. * Attributes to use in the shader
  139831. */
  139832. attributeNames?: Array<string>;
  139833. /**
  139834. * Uniforms to use in the shader
  139835. */
  139836. uniformNames?: Array<string>;
  139837. /**
  139838. * Texture sampler names to use in the shader
  139839. */
  139840. samplerNames?: Array<string>;
  139841. /**
  139842. * Defines to use in the shader
  139843. */
  139844. defines?: Array<string>;
  139845. /**
  139846. * Callback when effect is compiled
  139847. */
  139848. onCompiled?: Nullable<(effect: Effect) => void>;
  139849. /**
  139850. * The friendly name of the effect displayed in Spector.
  139851. */
  139852. name?: string;
  139853. }
  139854. /**
  139855. * Wraps an effect to be used for rendering
  139856. */
  139857. export class EffectWrapper {
  139858. /**
  139859. * Event that is fired right before the effect is drawn (should be used to update uniforms)
  139860. */
  139861. onApplyObservable: Observable<{}>;
  139862. /**
  139863. * The underlying effect
  139864. */
  139865. effect: Effect;
  139866. /**
  139867. * Creates an effect to be renderer
  139868. * @param creationOptions options to create the effect
  139869. */
  139870. constructor(creationOptions: EffectWrapperCreationOptions);
  139871. /**
  139872. * Disposes of the effect wrapper
  139873. */
  139874. dispose(): void;
  139875. }
  139876. }
  139877. declare module BABYLON {
  139878. /** @hidden */
  139879. export var hdrFilteringVertexShader: {
  139880. name: string;
  139881. shader: string;
  139882. };
  139883. }
  139884. declare module BABYLON {
  139885. /** @hidden */
  139886. export var hdrFilteringPixelShader: {
  139887. name: string;
  139888. shader: string;
  139889. };
  139890. }
  139891. declare module BABYLON {
  139892. /**
  139893. * Options for texture filtering
  139894. */
  139895. interface IHDRFilteringOptions {
  139896. /**
  139897. * Scales pixel intensity for the input HDR map.
  139898. */
  139899. hdrScale?: number;
  139900. /**
  139901. * Quality of the filter. Should be `Constants.TEXTURE_FILTERING_QUALITY_OFFLINE` for prefiltering
  139902. */
  139903. quality?: number;
  139904. }
  139905. /**
  139906. * Filters HDR maps to get correct renderings of PBR reflections
  139907. */
  139908. export class HDRFiltering {
  139909. private _engine;
  139910. private _effectRenderer;
  139911. private _effectWrapper;
  139912. private _lodGenerationOffset;
  139913. private _lodGenerationScale;
  139914. /**
  139915. * Quality switch for prefiltering. Should be set to `Constants.TEXTURE_FILTERING_QUALITY_OFFLINE` unless
  139916. * you care about baking speed.
  139917. */
  139918. quality: number;
  139919. /**
  139920. * Scales pixel intensity for the input HDR map.
  139921. */
  139922. hdrScale: number;
  139923. /**
  139924. * Instantiates HDR filter for reflection maps
  139925. *
  139926. * @param engine Thin engine
  139927. * @param options Options
  139928. */
  139929. constructor(engine: ThinEngine, options?: IHDRFilteringOptions);
  139930. private _createRenderTarget;
  139931. private _prefilterInternal;
  139932. private _createEffect;
  139933. /**
  139934. * Get a value indicating if the filter is ready to be used
  139935. * @param texture Texture to filter
  139936. * @returns true if the filter is ready
  139937. */
  139938. isReady(texture: BaseTexture): boolean;
  139939. /**
  139940. * Prefilters a cube texture to have mipmap levels representing roughness values.
  139941. * Prefiltering will be invoked at the end of next rendering pass.
  139942. * This has to be done once the map is loaded, and has not been prefiltered by a third party software.
  139943. * See http://blog.selfshadow.com/publications/s2013-shading-course/karis/s2013_pbs_epic_notes_v2.pdf for more information
  139944. * @param texture Texture to filter
  139945. * @param onFinished Callback when filtering is done
  139946. * @return Promise called when prefiltering is done
  139947. */
  139948. prefilter(texture: BaseTexture, onFinished?: Nullable<() => void>): Promise<unknown> | undefined;
  139949. }
  139950. }
  139951. declare module BABYLON {
  139952. /**
  139953. * This represents a texture coming from an HDR input.
  139954. *
  139955. * The only supported format is currently panorama picture stored in RGBE format.
  139956. * Example of such files can be found on HDRLib: http://hdrlib.com/
  139957. */
  139958. export class HDRCubeTexture extends BaseTexture {
  139959. private static _facesMapping;
  139960. private _generateHarmonics;
  139961. private _noMipmap;
  139962. private _prefilterOnLoad;
  139963. private _textureMatrix;
  139964. private _size;
  139965. private _onLoad;
  139966. private _onError;
  139967. /**
  139968. * The texture URL.
  139969. */
  139970. url: string;
  139971. protected _isBlocking: boolean;
  139972. /**
  139973. * Sets wether or not the texture is blocking during loading.
  139974. */
  139975. set isBlocking(value: boolean);
  139976. /**
  139977. * Gets wether or not the texture is blocking during loading.
  139978. */
  139979. get isBlocking(): boolean;
  139980. protected _rotationY: number;
  139981. /**
  139982. * Sets texture matrix rotation angle around Y axis in radians.
  139983. */
  139984. set rotationY(value: number);
  139985. /**
  139986. * Gets texture matrix rotation angle around Y axis radians.
  139987. */
  139988. get rotationY(): number;
  139989. /**
  139990. * Gets or sets the center of the bounding box associated with the cube texture
  139991. * It must define where the camera used to render the texture was set
  139992. */
  139993. boundingBoxPosition: Vector3;
  139994. private _boundingBoxSize;
  139995. /**
  139996. * Gets or sets the size of the bounding box associated with the cube texture
  139997. * When defined, the cubemap will switch to local mode
  139998. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  139999. * @example https://www.babylonjs-playground.com/#RNASML
  140000. */
  140001. set boundingBoxSize(value: Vector3);
  140002. get boundingBoxSize(): Vector3;
  140003. /**
  140004. * Instantiates an HDRTexture from the following parameters.
  140005. *
  140006. * @param url The location of the HDR raw data (Panorama stored in RGBE format)
  140007. * @param sceneOrEngine The scene or engine the texture will be used in
  140008. * @param size The cubemap desired size (the more it increases the longer the generation will be)
  140009. * @param noMipmap Forces to not generate the mipmap if true
  140010. * @param generateHarmonics Specifies whether you want to extract the polynomial harmonics during the generation process
  140011. * @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)
  140012. * @param prefilterOnLoad Prefilters HDR texture to allow use of this texture as a PBR reflection texture.
  140013. */
  140014. 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>);
  140015. /**
  140016. * Get the current class name of the texture useful for serialization or dynamic coding.
  140017. * @returns "HDRCubeTexture"
  140018. */
  140019. getClassName(): string;
  140020. /**
  140021. * Occurs when the file is raw .hdr file.
  140022. */
  140023. private loadTexture;
  140024. clone(): HDRCubeTexture;
  140025. delayLoad(): void;
  140026. /**
  140027. * Get the texture reflection matrix used to rotate/transform the reflection.
  140028. * @returns the reflection matrix
  140029. */
  140030. getReflectionTextureMatrix(): Matrix;
  140031. /**
  140032. * Set the texture reflection matrix used to rotate/transform the reflection.
  140033. * @param value Define the reflection matrix to set
  140034. */
  140035. setReflectionTextureMatrix(value: Matrix): void;
  140036. /**
  140037. * Parses a JSON representation of an HDR Texture in order to create the texture
  140038. * @param parsedTexture Define the JSON representation
  140039. * @param scene Define the scene the texture should be created in
  140040. * @param rootUrl Define the root url in case we need to load relative dependencies
  140041. * @returns the newly created texture after parsing
  140042. */
  140043. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<HDRCubeTexture>;
  140044. serialize(): any;
  140045. }
  140046. }
  140047. declare module BABYLON {
  140048. /**
  140049. * Class used to control physics engine
  140050. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  140051. */
  140052. export class PhysicsEngine implements IPhysicsEngine {
  140053. private _physicsPlugin;
  140054. /**
  140055. * Global value used to control the smallest number supported by the simulation
  140056. */
  140057. static Epsilon: number;
  140058. private _impostors;
  140059. private _joints;
  140060. private _subTimeStep;
  140061. /**
  140062. * Gets the gravity vector used by the simulation
  140063. */
  140064. gravity: Vector3;
  140065. /**
  140066. * Factory used to create the default physics plugin.
  140067. * @returns The default physics plugin
  140068. */
  140069. static DefaultPluginFactory(): IPhysicsEnginePlugin;
  140070. /**
  140071. * Creates a new Physics Engine
  140072. * @param gravity defines the gravity vector used by the simulation
  140073. * @param _physicsPlugin defines the plugin to use (CannonJS by default)
  140074. */
  140075. constructor(gravity: Nullable<Vector3>, _physicsPlugin?: IPhysicsEnginePlugin);
  140076. /**
  140077. * Sets the gravity vector used by the simulation
  140078. * @param gravity defines the gravity vector to use
  140079. */
  140080. setGravity(gravity: Vector3): void;
  140081. /**
  140082. * Set the time step of the physics engine.
  140083. * Default is 1/60.
  140084. * To slow it down, enter 1/600 for example.
  140085. * To speed it up, 1/30
  140086. * @param newTimeStep defines the new timestep to apply to this world.
  140087. */
  140088. setTimeStep(newTimeStep?: number): void;
  140089. /**
  140090. * Get the time step of the physics engine.
  140091. * @returns the current time step
  140092. */
  140093. getTimeStep(): number;
  140094. /**
  140095. * Set the sub time step of the physics engine.
  140096. * Default is 0 meaning there is no sub steps
  140097. * To increase physics resolution precision, set a small value (like 1 ms)
  140098. * @param subTimeStep defines the new sub timestep used for physics resolution.
  140099. */
  140100. setSubTimeStep(subTimeStep?: number): void;
  140101. /**
  140102. * Get the sub time step of the physics engine.
  140103. * @returns the current sub time step
  140104. */
  140105. getSubTimeStep(): number;
  140106. /**
  140107. * Release all resources
  140108. */
  140109. dispose(): void;
  140110. /**
  140111. * Gets the name of the current physics plugin
  140112. * @returns the name of the plugin
  140113. */
  140114. getPhysicsPluginName(): string;
  140115. /**
  140116. * Adding a new impostor for the impostor tracking.
  140117. * This will be done by the impostor itself.
  140118. * @param impostor the impostor to add
  140119. */
  140120. addImpostor(impostor: PhysicsImpostor): void;
  140121. /**
  140122. * Remove an impostor from the engine.
  140123. * This impostor and its mesh will not longer be updated by the physics engine.
  140124. * @param impostor the impostor to remove
  140125. */
  140126. removeImpostor(impostor: PhysicsImpostor): void;
  140127. /**
  140128. * Add a joint to the physics engine
  140129. * @param mainImpostor defines the main impostor to which the joint is added.
  140130. * @param connectedImpostor defines the impostor that is connected to the main impostor using this joint
  140131. * @param joint defines the joint that will connect both impostors.
  140132. */
  140133. addJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  140134. /**
  140135. * Removes a joint from the simulation
  140136. * @param mainImpostor defines the impostor used with the joint
  140137. * @param connectedImpostor defines the other impostor connected to the main one by the joint
  140138. * @param joint defines the joint to remove
  140139. */
  140140. removeJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  140141. /**
  140142. * Called by the scene. No need to call it.
  140143. * @param delta defines the timespam between frames
  140144. */
  140145. _step(delta: number): void;
  140146. /**
  140147. * Gets the current plugin used to run the simulation
  140148. * @returns current plugin
  140149. */
  140150. getPhysicsPlugin(): IPhysicsEnginePlugin;
  140151. /**
  140152. * Gets the list of physic impostors
  140153. * @returns an array of PhysicsImpostor
  140154. */
  140155. getImpostors(): Array<PhysicsImpostor>;
  140156. /**
  140157. * Gets the impostor for a physics enabled object
  140158. * @param object defines the object impersonated by the impostor
  140159. * @returns the PhysicsImpostor or null if not found
  140160. */
  140161. getImpostorForPhysicsObject(object: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  140162. /**
  140163. * Gets the impostor for a physics body object
  140164. * @param body defines physics body used by the impostor
  140165. * @returns the PhysicsImpostor or null if not found
  140166. */
  140167. getImpostorWithPhysicsBody(body: any): Nullable<PhysicsImpostor>;
  140168. /**
  140169. * Does a raycast in the physics world
  140170. * @param from when should the ray start?
  140171. * @param to when should the ray end?
  140172. * @returns PhysicsRaycastResult
  140173. */
  140174. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  140175. }
  140176. }
  140177. declare module BABYLON {
  140178. /** @hidden */
  140179. export class CannonJSPlugin implements IPhysicsEnginePlugin {
  140180. private _useDeltaForWorldStep;
  140181. world: any;
  140182. name: string;
  140183. private _physicsMaterials;
  140184. private _fixedTimeStep;
  140185. private _cannonRaycastResult;
  140186. private _raycastResult;
  140187. private _physicsBodysToRemoveAfterStep;
  140188. private _firstFrame;
  140189. BJSCANNON: any;
  140190. constructor(_useDeltaForWorldStep?: boolean, iterations?: number, cannonInjection?: any);
  140191. setGravity(gravity: Vector3): void;
  140192. setTimeStep(timeStep: number): void;
  140193. getTimeStep(): number;
  140194. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  140195. private _removeMarkedPhysicsBodiesFromWorld;
  140196. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  140197. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  140198. generatePhysicsBody(impostor: PhysicsImpostor): void;
  140199. private _processChildMeshes;
  140200. removePhysicsBody(impostor: PhysicsImpostor): void;
  140201. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  140202. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  140203. private _addMaterial;
  140204. private _checkWithEpsilon;
  140205. private _createShape;
  140206. private _createHeightmap;
  140207. private _minus90X;
  140208. private _plus90X;
  140209. private _tmpPosition;
  140210. private _tmpDeltaPosition;
  140211. private _tmpUnityRotation;
  140212. private _updatePhysicsBodyTransformation;
  140213. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  140214. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  140215. isSupported(): boolean;
  140216. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  140217. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  140218. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  140219. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  140220. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  140221. getBodyMass(impostor: PhysicsImpostor): number;
  140222. getBodyFriction(impostor: PhysicsImpostor): number;
  140223. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  140224. getBodyRestitution(impostor: PhysicsImpostor): number;
  140225. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  140226. sleepBody(impostor: PhysicsImpostor): void;
  140227. wakeUpBody(impostor: PhysicsImpostor): void;
  140228. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number): void;
  140229. setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number): void;
  140230. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number): void;
  140231. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  140232. getRadius(impostor: PhysicsImpostor): number;
  140233. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  140234. dispose(): void;
  140235. private _extendNamespace;
  140236. /**
  140237. * Does a raycast in the physics world
  140238. * @param from when should the ray start?
  140239. * @param to when should the ray end?
  140240. * @returns PhysicsRaycastResult
  140241. */
  140242. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  140243. }
  140244. }
  140245. declare module BABYLON {
  140246. /** @hidden */
  140247. export class OimoJSPlugin implements IPhysicsEnginePlugin {
  140248. private _useDeltaForWorldStep;
  140249. world: any;
  140250. name: string;
  140251. BJSOIMO: any;
  140252. private _raycastResult;
  140253. private _fixedTimeStep;
  140254. constructor(_useDeltaForWorldStep?: boolean, iterations?: number, oimoInjection?: any);
  140255. setGravity(gravity: Vector3): void;
  140256. setTimeStep(timeStep: number): void;
  140257. getTimeStep(): number;
  140258. private _tmpImpostorsArray;
  140259. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  140260. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  140261. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  140262. generatePhysicsBody(impostor: PhysicsImpostor): void;
  140263. private _tmpPositionVector;
  140264. removePhysicsBody(impostor: PhysicsImpostor): void;
  140265. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  140266. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  140267. isSupported(): boolean;
  140268. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  140269. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  140270. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  140271. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  140272. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  140273. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  140274. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  140275. getBodyMass(impostor: PhysicsImpostor): number;
  140276. getBodyFriction(impostor: PhysicsImpostor): number;
  140277. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  140278. getBodyRestitution(impostor: PhysicsImpostor): number;
  140279. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  140280. sleepBody(impostor: PhysicsImpostor): void;
  140281. wakeUpBody(impostor: PhysicsImpostor): void;
  140282. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  140283. setMotor(joint: IMotorEnabledJoint, speed: number, force?: number, motorIndex?: number): void;
  140284. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  140285. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  140286. getRadius(impostor: PhysicsImpostor): number;
  140287. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  140288. dispose(): void;
  140289. /**
  140290. * Does a raycast in the physics world
  140291. * @param from when should the ray start?
  140292. * @param to when should the ray end?
  140293. * @returns PhysicsRaycastResult
  140294. */
  140295. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  140296. }
  140297. }
  140298. declare module BABYLON {
  140299. /**
  140300. * AmmoJS Physics plugin
  140301. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  140302. * @see https://github.com/kripken/ammo.js/
  140303. */
  140304. export class AmmoJSPlugin implements IPhysicsEnginePlugin {
  140305. private _useDeltaForWorldStep;
  140306. /**
  140307. * Reference to the Ammo library
  140308. */
  140309. bjsAMMO: any;
  140310. /**
  140311. * Created ammoJS world which physics bodies are added to
  140312. */
  140313. world: any;
  140314. /**
  140315. * Name of the plugin
  140316. */
  140317. name: string;
  140318. private _timeStep;
  140319. private _fixedTimeStep;
  140320. private _maxSteps;
  140321. private _tmpQuaternion;
  140322. private _tmpAmmoTransform;
  140323. private _tmpAmmoQuaternion;
  140324. private _tmpAmmoConcreteContactResultCallback;
  140325. private _collisionConfiguration;
  140326. private _dispatcher;
  140327. private _overlappingPairCache;
  140328. private _solver;
  140329. private _softBodySolver;
  140330. private _tmpAmmoVectorA;
  140331. private _tmpAmmoVectorB;
  140332. private _tmpAmmoVectorC;
  140333. private _tmpAmmoVectorD;
  140334. private _tmpContactCallbackResult;
  140335. private _tmpAmmoVectorRCA;
  140336. private _tmpAmmoVectorRCB;
  140337. private _raycastResult;
  140338. private static readonly DISABLE_COLLISION_FLAG;
  140339. private static readonly KINEMATIC_FLAG;
  140340. private static readonly DISABLE_DEACTIVATION_FLAG;
  140341. /**
  140342. * Initializes the ammoJS plugin
  140343. * @param _useDeltaForWorldStep if the time between frames should be used when calculating physics steps (Default: true)
  140344. * @param ammoInjection can be used to inject your own ammo reference
  140345. * @param overlappingPairCache can be used to specify your own overlapping pair cache
  140346. */
  140347. constructor(_useDeltaForWorldStep?: boolean, ammoInjection?: any, overlappingPairCache?: any);
  140348. /**
  140349. * Sets the gravity of the physics world (m/(s^2))
  140350. * @param gravity Gravity to set
  140351. */
  140352. setGravity(gravity: Vector3): void;
  140353. /**
  140354. * Amount of time to step forward on each frame (only used if useDeltaForWorldStep is false in the constructor)
  140355. * @param timeStep timestep to use in seconds
  140356. */
  140357. setTimeStep(timeStep: number): void;
  140358. /**
  140359. * 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)
  140360. * @param fixedTimeStep fixedTimeStep to use in seconds
  140361. */
  140362. setFixedTimeStep(fixedTimeStep: number): void;
  140363. /**
  140364. * Sets the maximum number of steps by the physics engine per frame (Default: 5)
  140365. * @param maxSteps the maximum number of steps by the physics engine per frame
  140366. */
  140367. setMaxSteps(maxSteps: number): void;
  140368. /**
  140369. * Gets the current timestep (only used if useDeltaForWorldStep is false in the constructor)
  140370. * @returns the current timestep in seconds
  140371. */
  140372. getTimeStep(): number;
  140373. /**
  140374. * The create custom shape handler function to be called when using BABYLON.PhysicsImposter.CustomImpostor
  140375. */
  140376. onCreateCustomShape: (impostor: PhysicsImpostor) => any;
  140377. private _isImpostorInContact;
  140378. private _isImpostorPairInContact;
  140379. private _stepSimulation;
  140380. /**
  140381. * Moves the physics simulation forward delta seconds and updates the given physics imposters
  140382. * Prior to the step the imposters physics location is set to the position of the babylon meshes
  140383. * After the step the babylon meshes are set to the position of the physics imposters
  140384. * @param delta amount of time to step forward
  140385. * @param impostors array of imposters to update before/after the step
  140386. */
  140387. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  140388. /**
  140389. * Update babylon mesh to match physics world object
  140390. * @param impostor imposter to match
  140391. */
  140392. private _afterSoftStep;
  140393. /**
  140394. * Update babylon mesh vertices vertices to match physics world softbody or cloth
  140395. * @param impostor imposter to match
  140396. */
  140397. private _ropeStep;
  140398. /**
  140399. * Update babylon mesh vertices vertices to match physics world softbody or cloth
  140400. * @param impostor imposter to match
  140401. */
  140402. private _softbodyOrClothStep;
  140403. private _tmpMatrix;
  140404. /**
  140405. * Applies an impulse on the imposter
  140406. * @param impostor imposter to apply impulse to
  140407. * @param force amount of force to be applied to the imposter
  140408. * @param contactPoint the location to apply the impulse on the imposter
  140409. */
  140410. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  140411. /**
  140412. * Applies a force on the imposter
  140413. * @param impostor imposter to apply force
  140414. * @param force amount of force to be applied to the imposter
  140415. * @param contactPoint the location to apply the force on the imposter
  140416. */
  140417. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  140418. /**
  140419. * Creates a physics body using the plugin
  140420. * @param impostor the imposter to create the physics body on
  140421. */
  140422. generatePhysicsBody(impostor: PhysicsImpostor): void;
  140423. /**
  140424. * Removes the physics body from the imposter and disposes of the body's memory
  140425. * @param impostor imposter to remove the physics body from
  140426. */
  140427. removePhysicsBody(impostor: PhysicsImpostor): void;
  140428. /**
  140429. * Generates a joint
  140430. * @param impostorJoint the imposter joint to create the joint with
  140431. */
  140432. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  140433. /**
  140434. * Removes a joint
  140435. * @param impostorJoint the imposter joint to remove the joint from
  140436. */
  140437. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  140438. private _addMeshVerts;
  140439. /**
  140440. * Initialise the soft body vertices to match its object's (mesh) vertices
  140441. * Softbody vertices (nodes) are in world space and to match this
  140442. * The object's position and rotation is set to zero and so its vertices are also then set in world space
  140443. * @param impostor to create the softbody for
  140444. */
  140445. private _softVertexData;
  140446. /**
  140447. * Create an impostor's soft body
  140448. * @param impostor to create the softbody for
  140449. */
  140450. private _createSoftbody;
  140451. /**
  140452. * Create cloth for an impostor
  140453. * @param impostor to create the softbody for
  140454. */
  140455. private _createCloth;
  140456. /**
  140457. * Create rope for an impostor
  140458. * @param impostor to create the softbody for
  140459. */
  140460. private _createRope;
  140461. /**
  140462. * Create a custom physics impostor shape using the plugin's onCreateCustomShape handler
  140463. * @param impostor to create the custom physics shape for
  140464. */
  140465. private _createCustom;
  140466. private _addHullVerts;
  140467. private _createShape;
  140468. /**
  140469. * Sets the physics body position/rotation from the babylon mesh's position/rotation
  140470. * @param impostor imposter containing the physics body and babylon object
  140471. */
  140472. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  140473. /**
  140474. * Sets the babylon object's position/rotation from the physics body's position/rotation
  140475. * @param impostor imposter containing the physics body and babylon object
  140476. * @param newPosition new position
  140477. * @param newRotation new rotation
  140478. */
  140479. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  140480. /**
  140481. * If this plugin is supported
  140482. * @returns true if its supported
  140483. */
  140484. isSupported(): boolean;
  140485. /**
  140486. * Sets the linear velocity of the physics body
  140487. * @param impostor imposter to set the velocity on
  140488. * @param velocity velocity to set
  140489. */
  140490. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  140491. /**
  140492. * Sets the angular velocity of the physics body
  140493. * @param impostor imposter to set the velocity on
  140494. * @param velocity velocity to set
  140495. */
  140496. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  140497. /**
  140498. * gets the linear velocity
  140499. * @param impostor imposter to get linear velocity from
  140500. * @returns linear velocity
  140501. */
  140502. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  140503. /**
  140504. * gets the angular velocity
  140505. * @param impostor imposter to get angular velocity from
  140506. * @returns angular velocity
  140507. */
  140508. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  140509. /**
  140510. * Sets the mass of physics body
  140511. * @param impostor imposter to set the mass on
  140512. * @param mass mass to set
  140513. */
  140514. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  140515. /**
  140516. * Gets the mass of the physics body
  140517. * @param impostor imposter to get the mass from
  140518. * @returns mass
  140519. */
  140520. getBodyMass(impostor: PhysicsImpostor): number;
  140521. /**
  140522. * Gets friction of the impostor
  140523. * @param impostor impostor to get friction from
  140524. * @returns friction value
  140525. */
  140526. getBodyFriction(impostor: PhysicsImpostor): number;
  140527. /**
  140528. * Sets friction of the impostor
  140529. * @param impostor impostor to set friction on
  140530. * @param friction friction value
  140531. */
  140532. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  140533. /**
  140534. * Gets restitution of the impostor
  140535. * @param impostor impostor to get restitution from
  140536. * @returns restitution value
  140537. */
  140538. getBodyRestitution(impostor: PhysicsImpostor): number;
  140539. /**
  140540. * Sets resitution of the impostor
  140541. * @param impostor impostor to set resitution on
  140542. * @param restitution resitution value
  140543. */
  140544. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  140545. /**
  140546. * Gets pressure inside the impostor
  140547. * @param impostor impostor to get pressure from
  140548. * @returns pressure value
  140549. */
  140550. getBodyPressure(impostor: PhysicsImpostor): number;
  140551. /**
  140552. * Sets pressure inside a soft body impostor
  140553. * Cloth and rope must remain 0 pressure
  140554. * @param impostor impostor to set pressure on
  140555. * @param pressure pressure value
  140556. */
  140557. setBodyPressure(impostor: PhysicsImpostor, pressure: number): void;
  140558. /**
  140559. * Gets stiffness of the impostor
  140560. * @param impostor impostor to get stiffness from
  140561. * @returns pressure value
  140562. */
  140563. getBodyStiffness(impostor: PhysicsImpostor): number;
  140564. /**
  140565. * Sets stiffness of the impostor
  140566. * @param impostor impostor to set stiffness on
  140567. * @param stiffness stiffness value from 0 to 1
  140568. */
  140569. setBodyStiffness(impostor: PhysicsImpostor, stiffness: number): void;
  140570. /**
  140571. * Gets velocityIterations of the impostor
  140572. * @param impostor impostor to get velocity iterations from
  140573. * @returns velocityIterations value
  140574. */
  140575. getBodyVelocityIterations(impostor: PhysicsImpostor): number;
  140576. /**
  140577. * Sets velocityIterations of the impostor
  140578. * @param impostor impostor to set velocity iterations on
  140579. * @param velocityIterations velocityIterations value
  140580. */
  140581. setBodyVelocityIterations(impostor: PhysicsImpostor, velocityIterations: number): void;
  140582. /**
  140583. * Gets positionIterations of the impostor
  140584. * @param impostor impostor to get position iterations from
  140585. * @returns positionIterations value
  140586. */
  140587. getBodyPositionIterations(impostor: PhysicsImpostor): number;
  140588. /**
  140589. * Sets positionIterations of the impostor
  140590. * @param impostor impostor to set position on
  140591. * @param positionIterations positionIterations value
  140592. */
  140593. setBodyPositionIterations(impostor: PhysicsImpostor, positionIterations: number): void;
  140594. /**
  140595. * Append an anchor to a cloth object
  140596. * @param impostor is the cloth impostor to add anchor to
  140597. * @param otherImpostor is the rigid impostor to anchor to
  140598. * @param width ratio across width from 0 to 1
  140599. * @param height ratio up height from 0 to 1
  140600. * @param influence the elasticity between cloth impostor and anchor from 0, very stretchy to 1, little strech
  140601. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  140602. */
  140603. appendAnchor(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, width: number, height: number, influence?: number, noCollisionBetweenLinkedBodies?: boolean): void;
  140604. /**
  140605. * Append an hook to a rope object
  140606. * @param impostor is the rope impostor to add hook to
  140607. * @param otherImpostor is the rigid impostor to hook to
  140608. * @param length ratio along the rope from 0 to 1
  140609. * @param influence the elasticity between soft impostor and anchor from 0, very stretchy to 1, little strech
  140610. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  140611. */
  140612. appendHook(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, length: number, influence?: number, noCollisionBetweenLinkedBodies?: boolean): void;
  140613. /**
  140614. * Sleeps the physics body and stops it from being active
  140615. * @param impostor impostor to sleep
  140616. */
  140617. sleepBody(impostor: PhysicsImpostor): void;
  140618. /**
  140619. * Activates the physics body
  140620. * @param impostor impostor to activate
  140621. */
  140622. wakeUpBody(impostor: PhysicsImpostor): void;
  140623. /**
  140624. * Updates the distance parameters of the joint
  140625. * @param joint joint to update
  140626. * @param maxDistance maximum distance of the joint
  140627. * @param minDistance minimum distance of the joint
  140628. */
  140629. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  140630. /**
  140631. * Sets a motor on the joint
  140632. * @param joint joint to set motor on
  140633. * @param speed speed of the motor
  140634. * @param maxForce maximum force of the motor
  140635. * @param motorIndex index of the motor
  140636. */
  140637. setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number): void;
  140638. /**
  140639. * Sets the motors limit
  140640. * @param joint joint to set limit on
  140641. * @param upperLimit upper limit
  140642. * @param lowerLimit lower limit
  140643. */
  140644. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number): void;
  140645. /**
  140646. * Syncs the position and rotation of a mesh with the impostor
  140647. * @param mesh mesh to sync
  140648. * @param impostor impostor to update the mesh with
  140649. */
  140650. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  140651. /**
  140652. * Gets the radius of the impostor
  140653. * @param impostor impostor to get radius from
  140654. * @returns the radius
  140655. */
  140656. getRadius(impostor: PhysicsImpostor): number;
  140657. /**
  140658. * Gets the box size of the impostor
  140659. * @param impostor impostor to get box size from
  140660. * @param result the resulting box size
  140661. */
  140662. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  140663. /**
  140664. * Disposes of the impostor
  140665. */
  140666. dispose(): void;
  140667. /**
  140668. * Does a raycast in the physics world
  140669. * @param from when should the ray start?
  140670. * @param to when should the ray end?
  140671. * @returns PhysicsRaycastResult
  140672. */
  140673. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  140674. }
  140675. }
  140676. declare module BABYLON {
  140677. interface AbstractScene {
  140678. /**
  140679. * The list of reflection probes added to the scene
  140680. * @see https://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  140681. */
  140682. reflectionProbes: Array<ReflectionProbe>;
  140683. /**
  140684. * Removes the given reflection probe from this scene.
  140685. * @param toRemove The reflection probe to remove
  140686. * @returns The index of the removed reflection probe
  140687. */
  140688. removeReflectionProbe(toRemove: ReflectionProbe): number;
  140689. /**
  140690. * Adds the given reflection probe to this scene.
  140691. * @param newReflectionProbe The reflection probe to add
  140692. */
  140693. addReflectionProbe(newReflectionProbe: ReflectionProbe): void;
  140694. }
  140695. /**
  140696. * Class used to generate realtime reflection / refraction cube textures
  140697. * @see https://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  140698. */
  140699. export class ReflectionProbe {
  140700. /** defines the name of the probe */
  140701. name: string;
  140702. private _scene;
  140703. private _renderTargetTexture;
  140704. private _projectionMatrix;
  140705. private _viewMatrix;
  140706. private _target;
  140707. private _add;
  140708. private _attachedMesh;
  140709. private _invertYAxis;
  140710. /** Gets or sets probe position (center of the cube map) */
  140711. position: Vector3;
  140712. /**
  140713. * Creates a new reflection probe
  140714. * @param name defines the name of the probe
  140715. * @param size defines the texture resolution (for each face)
  140716. * @param scene defines the hosting scene
  140717. * @param generateMipMaps defines if mip maps should be generated automatically (true by default)
  140718. * @param useFloat defines if HDR data (flaot data) should be used to store colors (false by default)
  140719. */
  140720. constructor(
  140721. /** defines the name of the probe */
  140722. name: string, size: number, scene: Scene, generateMipMaps?: boolean, useFloat?: boolean);
  140723. /** Gets or sets the number of samples to use for multi-sampling (0 by default). Required WebGL2 */
  140724. get samples(): number;
  140725. set samples(value: number);
  140726. /** Gets or sets the refresh rate to use (on every frame by default) */
  140727. get refreshRate(): number;
  140728. set refreshRate(value: number);
  140729. /**
  140730. * Gets the hosting scene
  140731. * @returns a Scene
  140732. */
  140733. getScene(): Scene;
  140734. /** Gets the internal CubeTexture used to render to */
  140735. get cubeTexture(): RenderTargetTexture;
  140736. /** Gets the list of meshes to render */
  140737. get renderList(): Nullable<AbstractMesh[]>;
  140738. /**
  140739. * Attach the probe to a specific mesh (Rendering will be done from attached mesh's position)
  140740. * @param mesh defines the mesh to attach to
  140741. */
  140742. attachToMesh(mesh: Nullable<AbstractMesh>): void;
  140743. /**
  140744. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups
  140745. * @param renderingGroupId The rendering group id corresponding to its index
  140746. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  140747. */
  140748. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  140749. /**
  140750. * Clean all associated resources
  140751. */
  140752. dispose(): void;
  140753. /**
  140754. * Converts the reflection probe information to a readable string for debug purpose.
  140755. * @param fullDetails Supports for multiple levels of logging within scene loading
  140756. * @returns the human readable reflection probe info
  140757. */
  140758. toString(fullDetails?: boolean): string;
  140759. /**
  140760. * Get the class name of the relfection probe.
  140761. * @returns "ReflectionProbe"
  140762. */
  140763. getClassName(): string;
  140764. /**
  140765. * Serialize the reflection probe to a JSON representation we can easily use in the resepective Parse function.
  140766. * @returns The JSON representation of the texture
  140767. */
  140768. serialize(): any;
  140769. /**
  140770. * Parse the JSON representation of a reflection probe in order to recreate the reflection probe in the given scene.
  140771. * @param parsedReflectionProbe Define the JSON representation of the reflection probe
  140772. * @param scene Define the scene the parsed reflection probe should be instantiated in
  140773. * @param rootUrl Define the root url of the parsing sequence in the case of relative dependencies
  140774. * @returns The parsed reflection probe if successful
  140775. */
  140776. static Parse(parsedReflectionProbe: any, scene: Scene, rootUrl: string): Nullable<ReflectionProbe>;
  140777. }
  140778. }
  140779. declare module BABYLON {
  140780. /** @hidden */
  140781. export var _BabylonLoaderRegistered: boolean;
  140782. /**
  140783. * Helps setting up some configuration for the babylon file loader.
  140784. */
  140785. export class BabylonFileLoaderConfiguration {
  140786. /**
  140787. * The loader does not allow injecting custom physix engine into the plugins.
  140788. * Unfortunately in ES6, we need to manually inject them into the plugin.
  140789. * So you could set this variable to your engine import to make it work.
  140790. */
  140791. static LoaderInjectedPhysicsEngine: any;
  140792. }
  140793. }
  140794. declare module BABYLON {
  140795. /**
  140796. * The Physically based simple base material of BJS.
  140797. *
  140798. * This enables better naming and convention enforcements on top of the pbrMaterial.
  140799. * It is used as the base class for both the specGloss and metalRough conventions.
  140800. */
  140801. export abstract class PBRBaseSimpleMaterial extends PBRBaseMaterial {
  140802. /**
  140803. * Number of Simultaneous lights allowed on the material.
  140804. */
  140805. maxSimultaneousLights: number;
  140806. /**
  140807. * If sets to true, disables all the lights affecting the material.
  140808. */
  140809. disableLighting: boolean;
  140810. /**
  140811. * Environment Texture used in the material (this is use for both reflection and environment lighting).
  140812. */
  140813. environmentTexture: BaseTexture;
  140814. /**
  140815. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  140816. */
  140817. invertNormalMapX: boolean;
  140818. /**
  140819. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  140820. */
  140821. invertNormalMapY: boolean;
  140822. /**
  140823. * Normal map used in the model.
  140824. */
  140825. normalTexture: BaseTexture;
  140826. /**
  140827. * Emissivie color used to self-illuminate the model.
  140828. */
  140829. emissiveColor: Color3;
  140830. /**
  140831. * Emissivie texture used to self-illuminate the model.
  140832. */
  140833. emissiveTexture: BaseTexture;
  140834. /**
  140835. * Occlusion Channel Strenght.
  140836. */
  140837. occlusionStrength: number;
  140838. /**
  140839. * Occlusion Texture of the material (adding extra occlusion effects).
  140840. */
  140841. occlusionTexture: BaseTexture;
  140842. /**
  140843. * Defines the alpha limits in alpha test mode.
  140844. */
  140845. alphaCutOff: number;
  140846. /**
  140847. * Gets the current double sided mode.
  140848. */
  140849. get doubleSided(): boolean;
  140850. /**
  140851. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  140852. */
  140853. set doubleSided(value: boolean);
  140854. /**
  140855. * Stores the pre-calculated light information of a mesh in a texture.
  140856. */
  140857. lightmapTexture: BaseTexture;
  140858. /**
  140859. * If true, the light map contains occlusion information instead of lighting info.
  140860. */
  140861. useLightmapAsShadowmap: boolean;
  140862. /**
  140863. * Instantiates a new PBRMaterial instance.
  140864. *
  140865. * @param name The material name
  140866. * @param scene The scene the material will be use in.
  140867. */
  140868. constructor(name: string, scene: Scene);
  140869. getClassName(): string;
  140870. }
  140871. }
  140872. declare module BABYLON {
  140873. /**
  140874. * The PBR material of BJS following the metal roughness convention.
  140875. *
  140876. * This fits to the PBR convention in the GLTF definition:
  140877. * https://github.com/KhronosGroup/glTF/tree/2.0/specification/2.0
  140878. */
  140879. export class PBRMetallicRoughnessMaterial extends PBRBaseSimpleMaterial {
  140880. /**
  140881. * The base color has two different interpretations depending on the value of metalness.
  140882. * When the material is a metal, the base color is the specific measured reflectance value
  140883. * at normal incidence (F0). For a non-metal the base color represents the reflected diffuse color
  140884. * of the material.
  140885. */
  140886. baseColor: Color3;
  140887. /**
  140888. * Base texture of the metallic workflow. It contains both the baseColor information in RGB as
  140889. * well as opacity information in the alpha channel.
  140890. */
  140891. baseTexture: BaseTexture;
  140892. /**
  140893. * Specifies the metallic scalar value of the material.
  140894. * Can also be used to scale the metalness values of the metallic texture.
  140895. */
  140896. metallic: number;
  140897. /**
  140898. * Specifies the roughness scalar value of the material.
  140899. * Can also be used to scale the roughness values of the metallic texture.
  140900. */
  140901. roughness: number;
  140902. /**
  140903. * Texture containing both the metallic value in the B channel and the
  140904. * roughness value in the G channel to keep better precision.
  140905. */
  140906. metallicRoughnessTexture: BaseTexture;
  140907. /**
  140908. * Instantiates a new PBRMetalRoughnessMaterial instance.
  140909. *
  140910. * @param name The material name
  140911. * @param scene The scene the material will be use in.
  140912. */
  140913. constructor(name: string, scene: Scene);
  140914. /**
  140915. * Return the currrent class name of the material.
  140916. */
  140917. getClassName(): string;
  140918. /**
  140919. * Makes a duplicate of the current material.
  140920. * @param name - name to use for the new material.
  140921. */
  140922. clone(name: string): PBRMetallicRoughnessMaterial;
  140923. /**
  140924. * Serialize the material to a parsable JSON object.
  140925. */
  140926. serialize(): any;
  140927. /**
  140928. * Parses a JSON object correponding to the serialize function.
  140929. */
  140930. static Parse(source: any, scene: Scene, rootUrl: string): PBRMetallicRoughnessMaterial;
  140931. }
  140932. }
  140933. declare module BABYLON {
  140934. /**
  140935. * The PBR material of BJS following the specular glossiness convention.
  140936. *
  140937. * This fits to the PBR convention in the GLTF definition:
  140938. * https://github.com/KhronosGroup/glTF/tree/2.0/extensions/Khronos/KHR_materials_pbrSpecularGlossiness
  140939. */
  140940. export class PBRSpecularGlossinessMaterial extends PBRBaseSimpleMaterial {
  140941. /**
  140942. * Specifies the diffuse color of the material.
  140943. */
  140944. diffuseColor: Color3;
  140945. /**
  140946. * Specifies the diffuse texture of the material. This can also contains the opcity value in its alpha
  140947. * channel.
  140948. */
  140949. diffuseTexture: BaseTexture;
  140950. /**
  140951. * Specifies the specular color of the material. This indicates how reflective is the material (none to mirror).
  140952. */
  140953. specularColor: Color3;
  140954. /**
  140955. * Specifies the glossiness of the material. This indicates "how sharp is the reflection".
  140956. */
  140957. glossiness: number;
  140958. /**
  140959. * Specifies both the specular color RGB and the glossiness A of the material per pixels.
  140960. */
  140961. specularGlossinessTexture: BaseTexture;
  140962. /**
  140963. * Instantiates a new PBRSpecularGlossinessMaterial instance.
  140964. *
  140965. * @param name The material name
  140966. * @param scene The scene the material will be use in.
  140967. */
  140968. constructor(name: string, scene: Scene);
  140969. /**
  140970. * Return the currrent class name of the material.
  140971. */
  140972. getClassName(): string;
  140973. /**
  140974. * Makes a duplicate of the current material.
  140975. * @param name - name to use for the new material.
  140976. */
  140977. clone(name: string): PBRSpecularGlossinessMaterial;
  140978. /**
  140979. * Serialize the material to a parsable JSON object.
  140980. */
  140981. serialize(): any;
  140982. /**
  140983. * Parses a JSON object correponding to the serialize function.
  140984. */
  140985. static Parse(source: any, scene: Scene, rootUrl: string): PBRSpecularGlossinessMaterial;
  140986. }
  140987. }
  140988. declare module BABYLON {
  140989. /**
  140990. * This represents a color grading texture. This acts as a lookup table LUT, useful during post process
  140991. * It can help converting any input color in a desired output one. This can then be used to create effects
  140992. * from sepia, black and white to sixties or futuristic rendering...
  140993. *
  140994. * The only supported format is currently 3dl.
  140995. * More information on LUT: https://en.wikipedia.org/wiki/3D_lookup_table
  140996. */
  140997. export class ColorGradingTexture extends BaseTexture {
  140998. /**
  140999. * The texture URL.
  141000. */
  141001. url: string;
  141002. /**
  141003. * Empty line regex stored for GC.
  141004. */
  141005. private static _noneEmptyLineRegex;
  141006. private _textureMatrix;
  141007. private _onLoad;
  141008. /**
  141009. * Instantiates a ColorGradingTexture from the following parameters.
  141010. *
  141011. * @param url The location of the color gradind data (currently only supporting 3dl)
  141012. * @param sceneOrEngine The scene or engine the texture will be used in
  141013. * @param onLoad defines a callback triggered when the texture has been loaded
  141014. */
  141015. constructor(url: string, sceneOrEngine: Scene | ThinEngine, onLoad?: Nullable<() => void>);
  141016. /**
  141017. * Fires the onload event from the constructor if requested.
  141018. */
  141019. private _triggerOnLoad;
  141020. /**
  141021. * Returns the texture matrix used in most of the material.
  141022. * This is not used in color grading but keep for troubleshooting purpose (easily swap diffuse by colorgrading to look in).
  141023. */
  141024. getTextureMatrix(): Matrix;
  141025. /**
  141026. * Occurs when the file being loaded is a .3dl LUT file.
  141027. */
  141028. private load3dlTexture;
  141029. /**
  141030. * Starts the loading process of the texture.
  141031. */
  141032. private loadTexture;
  141033. /**
  141034. * Clones the color gradind texture.
  141035. */
  141036. clone(): ColorGradingTexture;
  141037. /**
  141038. * Called during delayed load for textures.
  141039. */
  141040. delayLoad(): void;
  141041. /**
  141042. * Parses a color grading texture serialized by Babylon.
  141043. * @param parsedTexture The texture information being parsedTexture
  141044. * @param scene The scene to load the texture in
  141045. * @param rootUrl The root url of the data assets to load
  141046. * @return A color gradind texture
  141047. */
  141048. static Parse(parsedTexture: any, scene: Scene): Nullable<ColorGradingTexture>;
  141049. /**
  141050. * Serializes the LUT texture to json format.
  141051. */
  141052. serialize(): any;
  141053. }
  141054. }
  141055. declare module BABYLON {
  141056. /**
  141057. * This represents a texture coming from an equirectangular image supported by the web browser canvas.
  141058. */
  141059. export class EquiRectangularCubeTexture extends BaseTexture {
  141060. /** The six faces of the cube. */
  141061. private static _FacesMapping;
  141062. private _noMipmap;
  141063. private _onLoad;
  141064. private _onError;
  141065. /** The size of the cubemap. */
  141066. private _size;
  141067. /** The buffer of the image. */
  141068. private _buffer;
  141069. /** The width of the input image. */
  141070. private _width;
  141071. /** The height of the input image. */
  141072. private _height;
  141073. /** The URL to the image. */
  141074. url: string;
  141075. /**
  141076. * Instantiates an EquiRectangularCubeTexture from the following parameters.
  141077. * @param url The location of the image
  141078. * @param scene The scene the texture will be used in
  141079. * @param size The cubemap desired size (the more it increases the longer the generation will be)
  141080. * @param noMipmap Forces to not generate the mipmap if true
  141081. * @param gammaSpace Specifies if the texture will be used in gamma or linear space
  141082. * (the PBR material requires those textures in linear space, but the standard material would require them in Gamma space)
  141083. * @param onLoad — defines a callback called when texture is loaded
  141084. * @param onError — defines a callback called if there is an error
  141085. */
  141086. constructor(url: string, scene: Scene, size: number, noMipmap?: boolean, gammaSpace?: boolean, onLoad?: Nullable<() => void>, onError?: Nullable<(message?: string, exception?: any) => void>);
  141087. /**
  141088. * Load the image data, by putting the image on a canvas and extracting its buffer.
  141089. */
  141090. private loadImage;
  141091. /**
  141092. * Convert the image buffer into a cubemap and create a CubeTexture.
  141093. */
  141094. private loadTexture;
  141095. /**
  141096. * Convert the ArrayBuffer into a Float32Array and drop the transparency channel.
  141097. * @param buffer The ArrayBuffer that should be converted.
  141098. * @returns The buffer as Float32Array.
  141099. */
  141100. private getFloat32ArrayFromArrayBuffer;
  141101. /**
  141102. * Get the current class name of the texture useful for serialization or dynamic coding.
  141103. * @returns "EquiRectangularCubeTexture"
  141104. */
  141105. getClassName(): string;
  141106. /**
  141107. * Create a clone of the current EquiRectangularCubeTexture and return it.
  141108. * @returns A clone of the current EquiRectangularCubeTexture.
  141109. */
  141110. clone(): EquiRectangularCubeTexture;
  141111. }
  141112. }
  141113. declare module BABYLON {
  141114. /**
  141115. * Defines the options related to the creation of an HtmlElementTexture
  141116. */
  141117. export interface IHtmlElementTextureOptions {
  141118. /**
  141119. * Defines wether mip maps should be created or not.
  141120. */
  141121. generateMipMaps?: boolean;
  141122. /**
  141123. * Defines the sampling mode of the texture.
  141124. */
  141125. samplingMode?: number;
  141126. /**
  141127. * Defines the engine instance to use the texture with. It is not mandatory if you define a scene.
  141128. */
  141129. engine: Nullable<ThinEngine>;
  141130. /**
  141131. * Defines the scene the texture belongs to. It is not mandatory if you define an engine.
  141132. */
  141133. scene: Nullable<Scene>;
  141134. }
  141135. /**
  141136. * This represents the smallest workload to use an already existing element (Canvas or Video) as a texture.
  141137. * To be as efficient as possible depending on your constraints nothing aside the first upload
  141138. * is automatically managed.
  141139. * It is a cheap VideoTexture or DynamicTexture if you prefer to keep full control of the elements
  141140. * in your application.
  141141. *
  141142. * As the update is not automatic, you need to call them manually.
  141143. */
  141144. export class HtmlElementTexture extends BaseTexture {
  141145. /**
  141146. * The texture URL.
  141147. */
  141148. element: HTMLVideoElement | HTMLCanvasElement;
  141149. private static readonly DefaultOptions;
  141150. private _textureMatrix;
  141151. private _isVideo;
  141152. private _generateMipMaps;
  141153. private _samplingMode;
  141154. /**
  141155. * Instantiates a HtmlElementTexture from the following parameters.
  141156. *
  141157. * @param name Defines the name of the texture
  141158. * @param element Defines the video or canvas the texture is filled with
  141159. * @param options Defines the other none mandatory texture creation options
  141160. */
  141161. constructor(name: string, element: HTMLVideoElement | HTMLCanvasElement, options: IHtmlElementTextureOptions);
  141162. private _createInternalTexture;
  141163. /**
  141164. * Returns the texture matrix used in most of the material.
  141165. */
  141166. getTextureMatrix(): Matrix;
  141167. /**
  141168. * Updates the content of the texture.
  141169. * @param invertY Defines wether the texture should be inverted on Y (false by default on video and true on canvas)
  141170. */
  141171. update(invertY?: Nullable<boolean>): void;
  141172. }
  141173. }
  141174. declare module BABYLON {
  141175. /**
  141176. * Based on jsTGALoader - Javascript loader for TGA file
  141177. * By Vincent Thibault
  141178. * @see http://blog.robrowser.com/javascript-tga-loader.html
  141179. */
  141180. export class TGATools {
  141181. private static _TYPE_INDEXED;
  141182. private static _TYPE_RGB;
  141183. private static _TYPE_GREY;
  141184. private static _TYPE_RLE_INDEXED;
  141185. private static _TYPE_RLE_RGB;
  141186. private static _TYPE_RLE_GREY;
  141187. private static _ORIGIN_MASK;
  141188. private static _ORIGIN_SHIFT;
  141189. private static _ORIGIN_BL;
  141190. private static _ORIGIN_BR;
  141191. private static _ORIGIN_UL;
  141192. private static _ORIGIN_UR;
  141193. /**
  141194. * Gets the header of a TGA file
  141195. * @param data defines the TGA data
  141196. * @returns the header
  141197. */
  141198. static GetTGAHeader(data: Uint8Array): any;
  141199. /**
  141200. * Uploads TGA content to a Babylon Texture
  141201. * @hidden
  141202. */
  141203. static UploadContent(texture: InternalTexture, data: Uint8Array): void;
  141204. /** @hidden */
  141205. 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;
  141206. /** @hidden */
  141207. 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;
  141208. /** @hidden */
  141209. 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;
  141210. /** @hidden */
  141211. 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;
  141212. /** @hidden */
  141213. 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;
  141214. /** @hidden */
  141215. 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;
  141216. }
  141217. }
  141218. declare module BABYLON {
  141219. /**
  141220. * Implementation of the TGA Texture Loader.
  141221. * @hidden
  141222. */
  141223. export class _TGATextureLoader implements IInternalTextureLoader {
  141224. /**
  141225. * Defines wether the loader supports cascade loading the different faces.
  141226. */
  141227. readonly supportCascades: boolean;
  141228. /**
  141229. * This returns if the loader support the current file information.
  141230. * @param extension defines the file extension of the file being loaded
  141231. * @returns true if the loader can load the specified file
  141232. */
  141233. canLoad(extension: string): boolean;
  141234. /**
  141235. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  141236. * @param data contains the texture data
  141237. * @param texture defines the BabylonJS internal texture
  141238. * @param createPolynomials will be true if polynomials have been requested
  141239. * @param onLoad defines the callback to trigger once the texture is ready
  141240. * @param onError defines the callback to trigger in case of error
  141241. */
  141242. loadCubeData(data: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  141243. /**
  141244. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  141245. * @param data contains the texture data
  141246. * @param texture defines the BabylonJS internal texture
  141247. * @param callback defines the method to call once ready to upload
  141248. */
  141249. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  141250. }
  141251. }
  141252. declare module BABYLON {
  141253. /**
  141254. * Info about the .basis files
  141255. */
  141256. class BasisFileInfo {
  141257. /**
  141258. * If the file has alpha
  141259. */
  141260. hasAlpha: boolean;
  141261. /**
  141262. * Info about each image of the basis file
  141263. */
  141264. images: Array<{
  141265. levels: Array<{
  141266. width: number;
  141267. height: number;
  141268. transcodedPixels: ArrayBufferView;
  141269. }>;
  141270. }>;
  141271. }
  141272. /**
  141273. * Result of transcoding a basis file
  141274. */
  141275. class TranscodeResult {
  141276. /**
  141277. * Info about the .basis file
  141278. */
  141279. fileInfo: BasisFileInfo;
  141280. /**
  141281. * Format to use when loading the file
  141282. */
  141283. format: number;
  141284. }
  141285. /**
  141286. * Configuration options for the Basis transcoder
  141287. */
  141288. export class BasisTranscodeConfiguration {
  141289. /**
  141290. * Supported compression formats used to determine the supported output format of the transcoder
  141291. */
  141292. supportedCompressionFormats?: {
  141293. /**
  141294. * etc1 compression format
  141295. */
  141296. etc1?: boolean;
  141297. /**
  141298. * s3tc compression format
  141299. */
  141300. s3tc?: boolean;
  141301. /**
  141302. * pvrtc compression format
  141303. */
  141304. pvrtc?: boolean;
  141305. /**
  141306. * etc2 compression format
  141307. */
  141308. etc2?: boolean;
  141309. };
  141310. /**
  141311. * If mipmap levels should be loaded for transcoded images (Default: true)
  141312. */
  141313. loadMipmapLevels?: boolean;
  141314. /**
  141315. * Index of a single image to load (Default: all images)
  141316. */
  141317. loadSingleImage?: number;
  141318. }
  141319. /**
  141320. * Used to load .Basis files
  141321. * See https://github.com/BinomialLLC/basis_universal/tree/master/webgl
  141322. */
  141323. export class BasisTools {
  141324. private static _IgnoreSupportedFormats;
  141325. /**
  141326. * URL to use when loading the basis transcoder
  141327. */
  141328. static JSModuleURL: string;
  141329. /**
  141330. * URL to use when loading the wasm module for the transcoder
  141331. */
  141332. static WasmModuleURL: string;
  141333. /**
  141334. * Get the internal format to be passed to texImage2D corresponding to the .basis format value
  141335. * @param basisFormat format chosen from GetSupportedTranscodeFormat
  141336. * @returns internal format corresponding to the Basis format
  141337. */
  141338. static GetInternalFormatFromBasisFormat(basisFormat: number): number;
  141339. private static _WorkerPromise;
  141340. private static _Worker;
  141341. private static _actionId;
  141342. private static _CreateWorkerAsync;
  141343. /**
  141344. * Transcodes a loaded image file to compressed pixel data
  141345. * @param data image data to transcode
  141346. * @param config configuration options for the transcoding
  141347. * @returns a promise resulting in the transcoded image
  141348. */
  141349. static TranscodeAsync(data: ArrayBuffer | ArrayBufferView, config: BasisTranscodeConfiguration): Promise<TranscodeResult>;
  141350. /**
  141351. * Loads a texture from the transcode result
  141352. * @param texture texture load to
  141353. * @param transcodeResult the result of transcoding the basis file to load from
  141354. */
  141355. static LoadTextureFromTranscodeResult(texture: InternalTexture, transcodeResult: TranscodeResult): void;
  141356. }
  141357. }
  141358. declare module BABYLON {
  141359. /**
  141360. * Loader for .basis file format
  141361. */
  141362. export class _BasisTextureLoader implements IInternalTextureLoader {
  141363. /**
  141364. * Defines whether the loader supports cascade loading the different faces.
  141365. */
  141366. readonly supportCascades: boolean;
  141367. /**
  141368. * This returns if the loader support the current file information.
  141369. * @param extension defines the file extension of the file being loaded
  141370. * @returns true if the loader can load the specified file
  141371. */
  141372. canLoad(extension: string): boolean;
  141373. /**
  141374. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  141375. * @param data contains the texture data
  141376. * @param texture defines the BabylonJS internal texture
  141377. * @param createPolynomials will be true if polynomials have been requested
  141378. * @param onLoad defines the callback to trigger once the texture is ready
  141379. * @param onError defines the callback to trigger in case of error
  141380. */
  141381. loadCubeData(data: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  141382. /**
  141383. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  141384. * @param data contains the texture data
  141385. * @param texture defines the BabylonJS internal texture
  141386. * @param callback defines the method to call once ready to upload
  141387. */
  141388. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  141389. }
  141390. }
  141391. declare module BABYLON {
  141392. /**
  141393. * Defines the basic options interface of a TexturePacker Frame
  141394. */
  141395. export interface ITexturePackerFrame {
  141396. /**
  141397. * The frame ID
  141398. */
  141399. id: number;
  141400. /**
  141401. * The frames Scale
  141402. */
  141403. scale: Vector2;
  141404. /**
  141405. * The Frames offset
  141406. */
  141407. offset: Vector2;
  141408. }
  141409. /**
  141410. * This is a support class for frame Data on texture packer sets.
  141411. */
  141412. export class TexturePackerFrame implements ITexturePackerFrame {
  141413. /**
  141414. * The frame ID
  141415. */
  141416. id: number;
  141417. /**
  141418. * The frames Scale
  141419. */
  141420. scale: Vector2;
  141421. /**
  141422. * The Frames offset
  141423. */
  141424. offset: Vector2;
  141425. /**
  141426. * Initializes a texture package frame.
  141427. * @param id The numerical frame identifier
  141428. * @param scale Scalar Vector2 for UV frame
  141429. * @param offset Vector2 for the frame position in UV units.
  141430. * @returns TexturePackerFrame
  141431. */
  141432. constructor(id: number, scale: Vector2, offset: Vector2);
  141433. }
  141434. }
  141435. declare module BABYLON {
  141436. /**
  141437. * Defines the basic options interface of a TexturePacker
  141438. */
  141439. export interface ITexturePackerOptions {
  141440. /**
  141441. * Custom targets for the channels of a texture packer. Default is all the channels of the Standard Material
  141442. */
  141443. map?: string[];
  141444. /**
  141445. * the UV input targets, as a single value for all meshes. Defaults to VertexBuffer.UVKind
  141446. */
  141447. uvsIn?: string;
  141448. /**
  141449. * the UV output targets, as a single value for all meshes. Defaults to VertexBuffer.UVKind
  141450. */
  141451. uvsOut?: string;
  141452. /**
  141453. * number representing the layout style. Defaults to LAYOUT_STRIP
  141454. */
  141455. layout?: number;
  141456. /**
  141457. * number of columns if using custom column count layout(2). This defaults to 4.
  141458. */
  141459. colnum?: number;
  141460. /**
  141461. * flag to update the input meshes to the new packed texture after compilation. Defaults to true.
  141462. */
  141463. updateInputMeshes?: boolean;
  141464. /**
  141465. * boolean flag to dispose all the source textures. Defaults to true.
  141466. */
  141467. disposeSources?: boolean;
  141468. /**
  141469. * Fills the blank cells in a set to the customFillColor. Defaults to true.
  141470. */
  141471. fillBlanks?: boolean;
  141472. /**
  141473. * string value representing the context fill style color. Defaults to 'black'.
  141474. */
  141475. customFillColor?: string;
  141476. /**
  141477. * Width and Height Value of each Frame in the TexturePacker Sets
  141478. */
  141479. frameSize?: number;
  141480. /**
  141481. * Ratio of the value to add padding wise to each cell. Defaults to 0.0115
  141482. */
  141483. paddingRatio?: number;
  141484. /**
  141485. * Number that declares the fill method for the padding gutter.
  141486. */
  141487. paddingMode?: number;
  141488. /**
  141489. * If in SUBUV_COLOR padding mode what color to use.
  141490. */
  141491. paddingColor?: Color3 | Color4;
  141492. }
  141493. /**
  141494. * Defines the basic interface of a TexturePacker JSON File
  141495. */
  141496. export interface ITexturePackerJSON {
  141497. /**
  141498. * The frame ID
  141499. */
  141500. name: string;
  141501. /**
  141502. * The base64 channel data
  141503. */
  141504. sets: any;
  141505. /**
  141506. * The options of the Packer
  141507. */
  141508. options: ITexturePackerOptions;
  141509. /**
  141510. * The frame data of the Packer
  141511. */
  141512. frames: Array<number>;
  141513. }
  141514. /**
  141515. * This is a support class that generates a series of packed texture sets.
  141516. * @see https://doc.babylonjs.com/babylon101/materials
  141517. */
  141518. export class TexturePacker {
  141519. /** Packer Layout Constant 0 */
  141520. static readonly LAYOUT_STRIP: number;
  141521. /** Packer Layout Constant 1 */
  141522. static readonly LAYOUT_POWER2: number;
  141523. /** Packer Layout Constant 2 */
  141524. static readonly LAYOUT_COLNUM: number;
  141525. /** Packer Layout Constant 0 */
  141526. static readonly SUBUV_WRAP: number;
  141527. /** Packer Layout Constant 1 */
  141528. static readonly SUBUV_EXTEND: number;
  141529. /** Packer Layout Constant 2 */
  141530. static readonly SUBUV_COLOR: number;
  141531. /** The Name of the Texture Package */
  141532. name: string;
  141533. /** The scene scope of the TexturePacker */
  141534. scene: Scene;
  141535. /** The Meshes to target */
  141536. meshes: AbstractMesh[];
  141537. /** Arguments passed with the Constructor */
  141538. options: ITexturePackerOptions;
  141539. /** The promise that is started upon initialization */
  141540. promise: Nullable<Promise<TexturePacker | string>>;
  141541. /** The Container object for the channel sets that are generated */
  141542. sets: object;
  141543. /** The Container array for the frames that are generated */
  141544. frames: TexturePackerFrame[];
  141545. /** The expected number of textures the system is parsing. */
  141546. private _expecting;
  141547. /** The padding value from Math.ceil(frameSize * paddingRatio) */
  141548. private _paddingValue;
  141549. /**
  141550. * Initializes a texture package series from an array of meshes or a single mesh.
  141551. * @param name The name of the package
  141552. * @param meshes The target meshes to compose the package from
  141553. * @param options The arguments that texture packer should follow while building.
  141554. * @param scene The scene which the textures are scoped to.
  141555. * @returns TexturePacker
  141556. */
  141557. constructor(name: string, meshes: AbstractMesh[], options: ITexturePackerOptions, scene: Scene);
  141558. /**
  141559. * Starts the package process
  141560. * @param resolve The promises resolution function
  141561. * @returns TexturePacker
  141562. */
  141563. private _createFrames;
  141564. /**
  141565. * Calculates the Size of the Channel Sets
  141566. * @returns Vector2
  141567. */
  141568. private _calculateSize;
  141569. /**
  141570. * Calculates the UV data for the frames.
  141571. * @param baseSize the base frameSize
  141572. * @param padding the base frame padding
  141573. * @param dtSize size of the Dynamic Texture for that channel
  141574. * @param dtUnits is 1/dtSize
  141575. * @param update flag to update the input meshes
  141576. */
  141577. private _calculateMeshUVFrames;
  141578. /**
  141579. * Calculates the frames Offset.
  141580. * @param index of the frame
  141581. * @returns Vector2
  141582. */
  141583. private _getFrameOffset;
  141584. /**
  141585. * Updates a Mesh to the frame data
  141586. * @param mesh that is the target
  141587. * @param frameID or the frame index
  141588. */
  141589. private _updateMeshUV;
  141590. /**
  141591. * Updates a Meshes materials to use the texture packer channels
  141592. * @param m is the mesh to target
  141593. * @param force all channels on the packer to be set.
  141594. */
  141595. private _updateTextureReferences;
  141596. /**
  141597. * Public method to set a Mesh to a frame
  141598. * @param m that is the target
  141599. * @param frameID or the frame index
  141600. * @param updateMaterial trigger for if the Meshes attached Material be updated?
  141601. */
  141602. setMeshToFrame(m: AbstractMesh, frameID: number, updateMaterial?: boolean): void;
  141603. /**
  141604. * Starts the async promise to compile the texture packer.
  141605. * @returns Promise<void>
  141606. */
  141607. processAsync(): Promise<void>;
  141608. /**
  141609. * Disposes all textures associated with this packer
  141610. */
  141611. dispose(): void;
  141612. /**
  141613. * Starts the download process for all the channels converting them to base64 data and embedding it all in a JSON file.
  141614. * @param imageType is the image type to use.
  141615. * @param quality of the image if downloading as jpeg, Ranges from >0 to 1.
  141616. */
  141617. download(imageType?: string, quality?: number): void;
  141618. /**
  141619. * Public method to load a texturePacker JSON file.
  141620. * @param data of the JSON file in string format.
  141621. */
  141622. updateFromJSON(data: string): void;
  141623. }
  141624. }
  141625. declare module BABYLON {
  141626. /**
  141627. * 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.
  141628. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  141629. * @see https://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  141630. */
  141631. export class CustomProceduralTexture extends ProceduralTexture {
  141632. private _animate;
  141633. private _time;
  141634. private _config;
  141635. private _texturePath;
  141636. /**
  141637. * Instantiates a new Custom Procedural Texture.
  141638. * 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.
  141639. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  141640. * @see https://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  141641. * @param name Define the name of the texture
  141642. * @param texturePath Define the folder path containing all the cutom texture related files (config, shaders...)
  141643. * @param size Define the size of the texture to create
  141644. * @param scene Define the scene the texture belongs to
  141645. * @param fallbackTexture Define a fallback texture in case there were issues to create the custom texture
  141646. * @param generateMipMaps Define if the texture should creates mip maps or not
  141647. */
  141648. constructor(name: string, texturePath: string, size: number, scene: Scene, fallbackTexture?: Texture, generateMipMaps?: boolean);
  141649. private _loadJson;
  141650. /**
  141651. * Is the texture ready to be used ? (rendered at least once)
  141652. * @returns true if ready, otherwise, false.
  141653. */
  141654. isReady(): boolean;
  141655. /**
  141656. * Render the texture to its associated render target.
  141657. * @param useCameraPostProcess Define if camera post process should be applied to the texture
  141658. */
  141659. render(useCameraPostProcess?: boolean): void;
  141660. /**
  141661. * Update the list of dependant textures samplers in the shader.
  141662. */
  141663. updateTextures(): void;
  141664. /**
  141665. * Update the uniform values of the procedural texture in the shader.
  141666. */
  141667. updateShaderUniforms(): void;
  141668. /**
  141669. * Define if the texture animates or not.
  141670. */
  141671. get animate(): boolean;
  141672. set animate(value: boolean);
  141673. }
  141674. }
  141675. declare module BABYLON {
  141676. /** @hidden */
  141677. export var noisePixelShader: {
  141678. name: string;
  141679. shader: string;
  141680. };
  141681. }
  141682. declare module BABYLON {
  141683. /**
  141684. * Class used to generate noise procedural textures
  141685. */
  141686. export class NoiseProceduralTexture extends ProceduralTexture {
  141687. /** Gets or sets the start time (default is 0) */
  141688. time: number;
  141689. /** Gets or sets a value between 0 and 1 indicating the overall brightness of the texture (default is 0.2) */
  141690. brightness: number;
  141691. /** Defines the number of octaves to process */
  141692. octaves: number;
  141693. /** Defines the level of persistence (0.8 by default) */
  141694. persistence: number;
  141695. /** Gets or sets animation speed factor (default is 1) */
  141696. animationSpeedFactor: number;
  141697. /**
  141698. * Creates a new NoiseProceduralTexture
  141699. * @param name defines the name fo the texture
  141700. * @param size defines the size of the texture (default is 256)
  141701. * @param scene defines the hosting scene
  141702. * @param fallbackTexture defines the texture to use if the NoiseProceduralTexture can't be created
  141703. * @param generateMipMaps defines if mipmaps must be generated (true by default)
  141704. */
  141705. constructor(name: string, size?: number, scene?: Nullable<Scene>, fallbackTexture?: Texture, generateMipMaps?: boolean);
  141706. private _updateShaderUniforms;
  141707. protected _getDefines(): string;
  141708. /** Generate the current state of the procedural texture */
  141709. render(useCameraPostProcess?: boolean): void;
  141710. /**
  141711. * Serializes this noise procedural texture
  141712. * @returns a serialized noise procedural texture object
  141713. */
  141714. serialize(): any;
  141715. /**
  141716. * Clone the texture.
  141717. * @returns the cloned texture
  141718. */
  141719. clone(): NoiseProceduralTexture;
  141720. /**
  141721. * Creates a NoiseProceduralTexture from parsed noise procedural texture data
  141722. * @param parsedTexture defines parsed texture data
  141723. * @param scene defines the current scene
  141724. * @param rootUrl defines the root URL containing noise procedural texture information
  141725. * @returns a parsed NoiseProceduralTexture
  141726. */
  141727. static Parse(parsedTexture: any, scene: Scene): NoiseProceduralTexture;
  141728. }
  141729. }
  141730. declare module BABYLON {
  141731. /**
  141732. * Raw cube texture where the raw buffers are passed in
  141733. */
  141734. export class RawCubeTexture extends CubeTexture {
  141735. /**
  141736. * Creates a cube texture where the raw buffers are passed in.
  141737. * @param scene defines the scene the texture is attached to
  141738. * @param data defines the array of data to use to create each face
  141739. * @param size defines the size of the textures
  141740. * @param format defines the format of the data
  141741. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  141742. * @param generateMipMaps defines if the engine should generate the mip levels
  141743. * @param invertY defines if data must be stored with Y axis inverted
  141744. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  141745. * @param compression defines the compression used (null by default)
  141746. */
  141747. constructor(scene: Scene, data: Nullable<ArrayBufferView[]>, size: number, format?: number, type?: number, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, compression?: Nullable<string>);
  141748. /**
  141749. * Updates the raw cube texture.
  141750. * @param data defines the data to store
  141751. * @param format defines the data format
  141752. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  141753. * @param invertY defines if data must be stored with Y axis inverted
  141754. * @param compression defines the compression used (null by default)
  141755. * @param level defines which level of the texture to update
  141756. */
  141757. update(data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression?: Nullable<string>): void;
  141758. /**
  141759. * Updates a raw cube texture with RGBD encoded data.
  141760. * @param data defines the array of data [mipmap][face] to use to create each face
  141761. * @param sphericalPolynomial defines the spherical polynomial for irradiance
  141762. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  141763. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  141764. * @returns a promsie that resolves when the operation is complete
  141765. */
  141766. updateRGBDAsync(data: ArrayBufferView[][], sphericalPolynomial?: Nullable<SphericalPolynomial>, lodScale?: number, lodOffset?: number): Promise<void>;
  141767. /**
  141768. * Clones the raw cube texture.
  141769. * @return a new cube texture
  141770. */
  141771. clone(): CubeTexture;
  141772. /** @hidden */
  141773. static _UpdateRGBDAsync(internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number): Promise<void>;
  141774. }
  141775. }
  141776. declare module BABYLON {
  141777. /**
  141778. * Class used to store 2D array textures containing user data
  141779. */
  141780. export class RawTexture2DArray extends Texture {
  141781. /** Gets or sets the texture format to use */
  141782. format: number;
  141783. /**
  141784. * Create a new RawTexture2DArray
  141785. * @param data defines the data of the texture
  141786. * @param width defines the width of the texture
  141787. * @param height defines the height of the texture
  141788. * @param depth defines the number of layers of the texture
  141789. * @param format defines the texture format to use
  141790. * @param scene defines the hosting scene
  141791. * @param generateMipMaps defines a boolean indicating if mip levels should be generated (true by default)
  141792. * @param invertY defines if texture must be stored with Y axis inverted
  141793. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  141794. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  141795. */
  141796. constructor(data: ArrayBufferView, width: number, height: number, depth: number,
  141797. /** Gets or sets the texture format to use */
  141798. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, textureType?: number);
  141799. /**
  141800. * Update the texture with new data
  141801. * @param data defines the data to store in the texture
  141802. */
  141803. update(data: ArrayBufferView): void;
  141804. }
  141805. }
  141806. declare module BABYLON {
  141807. /**
  141808. * Class used to store 3D textures containing user data
  141809. */
  141810. export class RawTexture3D extends Texture {
  141811. /** Gets or sets the texture format to use */
  141812. format: number;
  141813. /**
  141814. * Create a new RawTexture3D
  141815. * @param data defines the data of the texture
  141816. * @param width defines the width of the texture
  141817. * @param height defines the height of the texture
  141818. * @param depth defines the depth of the texture
  141819. * @param format defines the texture format to use
  141820. * @param scene defines the hosting scene
  141821. * @param generateMipMaps defines a boolean indicating if mip levels should be generated (true by default)
  141822. * @param invertY defines if texture must be stored with Y axis inverted
  141823. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  141824. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  141825. */
  141826. constructor(data: ArrayBufferView, width: number, height: number, depth: number,
  141827. /** Gets or sets the texture format to use */
  141828. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, textureType?: number);
  141829. /**
  141830. * Update the texture with new data
  141831. * @param data defines the data to store in the texture
  141832. */
  141833. update(data: ArrayBufferView): void;
  141834. }
  141835. }
  141836. declare module BABYLON {
  141837. /**
  141838. * Creates a refraction texture used by refraction channel of the standard material.
  141839. * It is like a mirror but to see through a material.
  141840. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  141841. */
  141842. export class RefractionTexture extends RenderTargetTexture {
  141843. /**
  141844. * Define the reflection plane we want to use. The refractionPlane is usually set to the constructed refractor.
  141845. * 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.
  141846. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  141847. */
  141848. refractionPlane: Plane;
  141849. /**
  141850. * Define how deep under the surface we should see.
  141851. */
  141852. depth: number;
  141853. /**
  141854. * Creates a refraction texture used by refraction channel of the standard material.
  141855. * It is like a mirror but to see through a material.
  141856. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  141857. * @param name Define the texture name
  141858. * @param size Define the size of the underlying texture
  141859. * @param scene Define the scene the refraction belongs to
  141860. * @param generateMipMaps Define if we need to generate mips level for the refraction
  141861. */
  141862. constructor(name: string, size: number, scene: Scene, generateMipMaps?: boolean);
  141863. /**
  141864. * Clone the refraction texture.
  141865. * @returns the cloned texture
  141866. */
  141867. clone(): RefractionTexture;
  141868. /**
  141869. * Serialize the texture to a JSON representation you could use in Parse later on
  141870. * @returns the serialized JSON representation
  141871. */
  141872. serialize(): any;
  141873. }
  141874. }
  141875. declare module BABYLON {
  141876. /**
  141877. * Block used to add support for vertex skinning (bones)
  141878. */
  141879. export class BonesBlock extends NodeMaterialBlock {
  141880. /**
  141881. * Creates a new BonesBlock
  141882. * @param name defines the block name
  141883. */
  141884. constructor(name: string);
  141885. /**
  141886. * Initialize the block and prepare the context for build
  141887. * @param state defines the state that will be used for the build
  141888. */
  141889. initialize(state: NodeMaterialBuildState): void;
  141890. /**
  141891. * Gets the current class name
  141892. * @returns the class name
  141893. */
  141894. getClassName(): string;
  141895. /**
  141896. * Gets the matrix indices input component
  141897. */
  141898. get matricesIndices(): NodeMaterialConnectionPoint;
  141899. /**
  141900. * Gets the matrix weights input component
  141901. */
  141902. get matricesWeights(): NodeMaterialConnectionPoint;
  141903. /**
  141904. * Gets the extra matrix indices input component
  141905. */
  141906. get matricesIndicesExtra(): NodeMaterialConnectionPoint;
  141907. /**
  141908. * Gets the extra matrix weights input component
  141909. */
  141910. get matricesWeightsExtra(): NodeMaterialConnectionPoint;
  141911. /**
  141912. * Gets the world input component
  141913. */
  141914. get world(): NodeMaterialConnectionPoint;
  141915. /**
  141916. * Gets the output component
  141917. */
  141918. get output(): NodeMaterialConnectionPoint;
  141919. autoConfigure(material: NodeMaterial): void;
  141920. provideFallbacks(mesh: AbstractMesh, fallbacks: EffectFallbacks): void;
  141921. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  141922. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  141923. protected _buildBlock(state: NodeMaterialBuildState): this;
  141924. }
  141925. }
  141926. declare module BABYLON {
  141927. /**
  141928. * Block used to add support for instances
  141929. * @see https://doc.babylonjs.com/how_to/how_to_use_instances
  141930. */
  141931. export class InstancesBlock extends NodeMaterialBlock {
  141932. /**
  141933. * Creates a new InstancesBlock
  141934. * @param name defines the block name
  141935. */
  141936. constructor(name: string);
  141937. /**
  141938. * Gets the current class name
  141939. * @returns the class name
  141940. */
  141941. getClassName(): string;
  141942. /**
  141943. * Gets the first world row input component
  141944. */
  141945. get world0(): NodeMaterialConnectionPoint;
  141946. /**
  141947. * Gets the second world row input component
  141948. */
  141949. get world1(): NodeMaterialConnectionPoint;
  141950. /**
  141951. * Gets the third world row input component
  141952. */
  141953. get world2(): NodeMaterialConnectionPoint;
  141954. /**
  141955. * Gets the forth world row input component
  141956. */
  141957. get world3(): NodeMaterialConnectionPoint;
  141958. /**
  141959. * Gets the world input component
  141960. */
  141961. get world(): NodeMaterialConnectionPoint;
  141962. /**
  141963. * Gets the output component
  141964. */
  141965. get output(): NodeMaterialConnectionPoint;
  141966. /**
  141967. * Gets the isntanceID component
  141968. */
  141969. get instanceID(): NodeMaterialConnectionPoint;
  141970. autoConfigure(material: NodeMaterial): void;
  141971. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean, subMesh?: SubMesh): void;
  141972. protected _buildBlock(state: NodeMaterialBuildState): this;
  141973. }
  141974. }
  141975. declare module BABYLON {
  141976. /**
  141977. * Block used to add morph targets support to vertex shader
  141978. */
  141979. export class MorphTargetsBlock extends NodeMaterialBlock {
  141980. private _repeatableContentAnchor;
  141981. /**
  141982. * Create a new MorphTargetsBlock
  141983. * @param name defines the block name
  141984. */
  141985. constructor(name: string);
  141986. /**
  141987. * Gets the current class name
  141988. * @returns the class name
  141989. */
  141990. getClassName(): string;
  141991. /**
  141992. * Gets the position input component
  141993. */
  141994. get position(): NodeMaterialConnectionPoint;
  141995. /**
  141996. * Gets the normal input component
  141997. */
  141998. get normal(): NodeMaterialConnectionPoint;
  141999. /**
  142000. * Gets the tangent input component
  142001. */
  142002. get tangent(): NodeMaterialConnectionPoint;
  142003. /**
  142004. * Gets the tangent input component
  142005. */
  142006. get uv(): NodeMaterialConnectionPoint;
  142007. /**
  142008. * Gets the position output component
  142009. */
  142010. get positionOutput(): NodeMaterialConnectionPoint;
  142011. /**
  142012. * Gets the normal output component
  142013. */
  142014. get normalOutput(): NodeMaterialConnectionPoint;
  142015. /**
  142016. * Gets the tangent output component
  142017. */
  142018. get tangentOutput(): NodeMaterialConnectionPoint;
  142019. /**
  142020. * Gets the tangent output component
  142021. */
  142022. get uvOutput(): NodeMaterialConnectionPoint;
  142023. initialize(state: NodeMaterialBuildState): void;
  142024. autoConfigure(material: NodeMaterial): void;
  142025. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  142026. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  142027. replaceRepeatableContent(vertexShaderState: NodeMaterialBuildState, fragmentShaderState: NodeMaterialBuildState, mesh: AbstractMesh, defines: NodeMaterialDefines): void;
  142028. protected _buildBlock(state: NodeMaterialBuildState): this;
  142029. }
  142030. }
  142031. declare module BABYLON {
  142032. /**
  142033. * Block used to get data information from a light
  142034. */
  142035. export class LightInformationBlock extends NodeMaterialBlock {
  142036. private _lightDataUniformName;
  142037. private _lightColorUniformName;
  142038. private _lightTypeDefineName;
  142039. /**
  142040. * Gets or sets the light associated with this block
  142041. */
  142042. light: Nullable<Light>;
  142043. /**
  142044. * Creates a new LightInformationBlock
  142045. * @param name defines the block name
  142046. */
  142047. constructor(name: string);
  142048. /**
  142049. * Gets the current class name
  142050. * @returns the class name
  142051. */
  142052. getClassName(): string;
  142053. /**
  142054. * Gets the world position input component
  142055. */
  142056. get worldPosition(): NodeMaterialConnectionPoint;
  142057. /**
  142058. * Gets the direction output component
  142059. */
  142060. get direction(): NodeMaterialConnectionPoint;
  142061. /**
  142062. * Gets the direction output component
  142063. */
  142064. get color(): NodeMaterialConnectionPoint;
  142065. /**
  142066. * Gets the direction output component
  142067. */
  142068. get intensity(): NodeMaterialConnectionPoint;
  142069. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  142070. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  142071. protected _buildBlock(state: NodeMaterialBuildState): this;
  142072. serialize(): any;
  142073. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  142074. }
  142075. }
  142076. declare module BABYLON {
  142077. /**
  142078. * Block used to add image processing support to fragment shader
  142079. */
  142080. export class ImageProcessingBlock extends NodeMaterialBlock {
  142081. /**
  142082. * Create a new ImageProcessingBlock
  142083. * @param name defines the block name
  142084. */
  142085. constructor(name: string);
  142086. /**
  142087. * Gets the current class name
  142088. * @returns the class name
  142089. */
  142090. getClassName(): string;
  142091. /**
  142092. * Gets the color input component
  142093. */
  142094. get color(): NodeMaterialConnectionPoint;
  142095. /**
  142096. * Gets the output component
  142097. */
  142098. get output(): NodeMaterialConnectionPoint;
  142099. /**
  142100. * Initialize the block and prepare the context for build
  142101. * @param state defines the state that will be used for the build
  142102. */
  142103. initialize(state: NodeMaterialBuildState): void;
  142104. isReady(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): boolean;
  142105. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  142106. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  142107. protected _buildBlock(state: NodeMaterialBuildState): this;
  142108. }
  142109. }
  142110. declare module BABYLON {
  142111. /**
  142112. * Block used to pertub normals based on a normal map
  142113. */
  142114. export class PerturbNormalBlock extends NodeMaterialBlock {
  142115. private _tangentSpaceParameterName;
  142116. /** Gets or sets a boolean indicating that normal should be inverted on X axis */
  142117. invertX: boolean;
  142118. /** Gets or sets a boolean indicating that normal should be inverted on Y axis */
  142119. invertY: boolean;
  142120. /**
  142121. * Create a new PerturbNormalBlock
  142122. * @param name defines the block name
  142123. */
  142124. constructor(name: string);
  142125. /**
  142126. * Gets the current class name
  142127. * @returns the class name
  142128. */
  142129. getClassName(): string;
  142130. /**
  142131. * Gets the world position input component
  142132. */
  142133. get worldPosition(): NodeMaterialConnectionPoint;
  142134. /**
  142135. * Gets the world normal input component
  142136. */
  142137. get worldNormal(): NodeMaterialConnectionPoint;
  142138. /**
  142139. * Gets the world tangent input component
  142140. */
  142141. get worldTangent(): NodeMaterialConnectionPoint;
  142142. /**
  142143. * Gets the uv input component
  142144. */
  142145. get uv(): NodeMaterialConnectionPoint;
  142146. /**
  142147. * Gets the normal map color input component
  142148. */
  142149. get normalMapColor(): NodeMaterialConnectionPoint;
  142150. /**
  142151. * Gets the strength input component
  142152. */
  142153. get strength(): NodeMaterialConnectionPoint;
  142154. /**
  142155. * Gets the output component
  142156. */
  142157. get output(): NodeMaterialConnectionPoint;
  142158. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  142159. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  142160. autoConfigure(material: NodeMaterial): void;
  142161. protected _buildBlock(state: NodeMaterialBuildState): this;
  142162. protected _dumpPropertiesCode(): string;
  142163. serialize(): any;
  142164. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  142165. }
  142166. }
  142167. declare module BABYLON {
  142168. /**
  142169. * Block used to discard a pixel if a value is smaller than a cutoff
  142170. */
  142171. export class DiscardBlock extends NodeMaterialBlock {
  142172. /**
  142173. * Create a new DiscardBlock
  142174. * @param name defines the block name
  142175. */
  142176. constructor(name: string);
  142177. /**
  142178. * Gets the current class name
  142179. * @returns the class name
  142180. */
  142181. getClassName(): string;
  142182. /**
  142183. * Gets the color input component
  142184. */
  142185. get value(): NodeMaterialConnectionPoint;
  142186. /**
  142187. * Gets the cutoff input component
  142188. */
  142189. get cutoff(): NodeMaterialConnectionPoint;
  142190. protected _buildBlock(state: NodeMaterialBuildState): this;
  142191. }
  142192. }
  142193. declare module BABYLON {
  142194. /**
  142195. * Block used to test if the fragment shader is front facing
  142196. */
  142197. export class FrontFacingBlock extends NodeMaterialBlock {
  142198. /**
  142199. * Creates a new FrontFacingBlock
  142200. * @param name defines the block name
  142201. */
  142202. constructor(name: string);
  142203. /**
  142204. * Gets the current class name
  142205. * @returns the class name
  142206. */
  142207. getClassName(): string;
  142208. /**
  142209. * Gets the output component
  142210. */
  142211. get output(): NodeMaterialConnectionPoint;
  142212. protected _buildBlock(state: NodeMaterialBuildState): this;
  142213. }
  142214. }
  142215. declare module BABYLON {
  142216. /**
  142217. * Block used to get the derivative value on x and y of a given input
  142218. */
  142219. export class DerivativeBlock extends NodeMaterialBlock {
  142220. /**
  142221. * Create a new DerivativeBlock
  142222. * @param name defines the block name
  142223. */
  142224. constructor(name: string);
  142225. /**
  142226. * Gets the current class name
  142227. * @returns the class name
  142228. */
  142229. getClassName(): string;
  142230. /**
  142231. * Gets the input component
  142232. */
  142233. get input(): NodeMaterialConnectionPoint;
  142234. /**
  142235. * Gets the derivative output on x
  142236. */
  142237. get dx(): NodeMaterialConnectionPoint;
  142238. /**
  142239. * Gets the derivative output on y
  142240. */
  142241. get dy(): NodeMaterialConnectionPoint;
  142242. protected _buildBlock(state: NodeMaterialBuildState): this;
  142243. }
  142244. }
  142245. declare module BABYLON {
  142246. /**
  142247. * Block used to make gl_FragCoord available
  142248. */
  142249. export class FragCoordBlock extends NodeMaterialBlock {
  142250. /**
  142251. * Creates a new FragCoordBlock
  142252. * @param name defines the block name
  142253. */
  142254. constructor(name: string);
  142255. /**
  142256. * Gets the current class name
  142257. * @returns the class name
  142258. */
  142259. getClassName(): string;
  142260. /**
  142261. * Gets the xy component
  142262. */
  142263. get xy(): NodeMaterialConnectionPoint;
  142264. /**
  142265. * Gets the xyz component
  142266. */
  142267. get xyz(): NodeMaterialConnectionPoint;
  142268. /**
  142269. * Gets the xyzw component
  142270. */
  142271. get xyzw(): NodeMaterialConnectionPoint;
  142272. /**
  142273. * Gets the x component
  142274. */
  142275. get x(): NodeMaterialConnectionPoint;
  142276. /**
  142277. * Gets the y component
  142278. */
  142279. get y(): NodeMaterialConnectionPoint;
  142280. /**
  142281. * Gets the z component
  142282. */
  142283. get z(): NodeMaterialConnectionPoint;
  142284. /**
  142285. * Gets the w component
  142286. */
  142287. get output(): NodeMaterialConnectionPoint;
  142288. protected writeOutputs(state: NodeMaterialBuildState): string;
  142289. protected _buildBlock(state: NodeMaterialBuildState): this;
  142290. }
  142291. }
  142292. declare module BABYLON {
  142293. /**
  142294. * Block used to get the screen sizes
  142295. */
  142296. export class ScreenSizeBlock extends NodeMaterialBlock {
  142297. private _varName;
  142298. private _scene;
  142299. /**
  142300. * Creates a new ScreenSizeBlock
  142301. * @param name defines the block name
  142302. */
  142303. constructor(name: string);
  142304. /**
  142305. * Gets the current class name
  142306. * @returns the class name
  142307. */
  142308. getClassName(): string;
  142309. /**
  142310. * Gets the xy component
  142311. */
  142312. get xy(): NodeMaterialConnectionPoint;
  142313. /**
  142314. * Gets the x component
  142315. */
  142316. get x(): NodeMaterialConnectionPoint;
  142317. /**
  142318. * Gets the y component
  142319. */
  142320. get y(): NodeMaterialConnectionPoint;
  142321. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  142322. protected writeOutputs(state: NodeMaterialBuildState, varName: string): string;
  142323. protected _buildBlock(state: NodeMaterialBuildState): this;
  142324. }
  142325. }
  142326. declare module BABYLON {
  142327. /**
  142328. * Block used to add support for scene fog
  142329. */
  142330. export class FogBlock extends NodeMaterialBlock {
  142331. private _fogDistanceName;
  142332. private _fogParameters;
  142333. /**
  142334. * Create a new FogBlock
  142335. * @param name defines the block name
  142336. */
  142337. constructor(name: string);
  142338. /**
  142339. * Gets the current class name
  142340. * @returns the class name
  142341. */
  142342. getClassName(): string;
  142343. /**
  142344. * Gets the world position input component
  142345. */
  142346. get worldPosition(): NodeMaterialConnectionPoint;
  142347. /**
  142348. * Gets the view input component
  142349. */
  142350. get view(): NodeMaterialConnectionPoint;
  142351. /**
  142352. * Gets the color input component
  142353. */
  142354. get input(): NodeMaterialConnectionPoint;
  142355. /**
  142356. * Gets the fog color input component
  142357. */
  142358. get fogColor(): NodeMaterialConnectionPoint;
  142359. /**
  142360. * Gets the output component
  142361. */
  142362. get output(): NodeMaterialConnectionPoint;
  142363. autoConfigure(material: NodeMaterial): void;
  142364. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  142365. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  142366. protected _buildBlock(state: NodeMaterialBuildState): this;
  142367. }
  142368. }
  142369. declare module BABYLON {
  142370. /**
  142371. * Block used to add light in the fragment shader
  142372. */
  142373. export class LightBlock extends NodeMaterialBlock {
  142374. private _lightId;
  142375. /**
  142376. * Gets or sets the light associated with this block
  142377. */
  142378. light: Nullable<Light>;
  142379. /**
  142380. * Create a new LightBlock
  142381. * @param name defines the block name
  142382. */
  142383. constructor(name: string);
  142384. /**
  142385. * Gets the current class name
  142386. * @returns the class name
  142387. */
  142388. getClassName(): string;
  142389. /**
  142390. * Gets the world position input component
  142391. */
  142392. get worldPosition(): NodeMaterialConnectionPoint;
  142393. /**
  142394. * Gets the world normal input component
  142395. */
  142396. get worldNormal(): NodeMaterialConnectionPoint;
  142397. /**
  142398. * Gets the camera (or eye) position component
  142399. */
  142400. get cameraPosition(): NodeMaterialConnectionPoint;
  142401. /**
  142402. * Gets the glossiness component
  142403. */
  142404. get glossiness(): NodeMaterialConnectionPoint;
  142405. /**
  142406. * Gets the glossinness power component
  142407. */
  142408. get glossPower(): NodeMaterialConnectionPoint;
  142409. /**
  142410. * Gets the diffuse color component
  142411. */
  142412. get diffuseColor(): NodeMaterialConnectionPoint;
  142413. /**
  142414. * Gets the specular color component
  142415. */
  142416. get specularColor(): NodeMaterialConnectionPoint;
  142417. /**
  142418. * Gets the diffuse output component
  142419. */
  142420. get diffuseOutput(): NodeMaterialConnectionPoint;
  142421. /**
  142422. * Gets the specular output component
  142423. */
  142424. get specularOutput(): NodeMaterialConnectionPoint;
  142425. /**
  142426. * Gets the shadow output component
  142427. */
  142428. get shadow(): NodeMaterialConnectionPoint;
  142429. autoConfigure(material: NodeMaterial): void;
  142430. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  142431. updateUniformsAndSamples(state: NodeMaterialBuildState, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, uniformBuffers: string[]): void;
  142432. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  142433. private _injectVertexCode;
  142434. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  142435. serialize(): any;
  142436. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  142437. }
  142438. }
  142439. declare module BABYLON {
  142440. /**
  142441. * Block used to read a reflection texture from a sampler
  142442. */
  142443. export class ReflectionTextureBlock extends ReflectionTextureBaseBlock {
  142444. /**
  142445. * Create a new ReflectionTextureBlock
  142446. * @param name defines the block name
  142447. */
  142448. constructor(name: string);
  142449. /**
  142450. * Gets the current class name
  142451. * @returns the class name
  142452. */
  142453. getClassName(): string;
  142454. /**
  142455. * Gets the world position input component
  142456. */
  142457. get position(): NodeMaterialConnectionPoint;
  142458. /**
  142459. * Gets the world position input component
  142460. */
  142461. get worldPosition(): NodeMaterialConnectionPoint;
  142462. /**
  142463. * Gets the world normal input component
  142464. */
  142465. get worldNormal(): NodeMaterialConnectionPoint;
  142466. /**
  142467. * Gets the world input component
  142468. */
  142469. get world(): NodeMaterialConnectionPoint;
  142470. /**
  142471. * Gets the camera (or eye) position component
  142472. */
  142473. get cameraPosition(): NodeMaterialConnectionPoint;
  142474. /**
  142475. * Gets the view input component
  142476. */
  142477. get view(): NodeMaterialConnectionPoint;
  142478. /**
  142479. * Gets the rgb output component
  142480. */
  142481. get rgb(): NodeMaterialConnectionPoint;
  142482. /**
  142483. * Gets the rgba output component
  142484. */
  142485. get rgba(): NodeMaterialConnectionPoint;
  142486. /**
  142487. * Gets the r output component
  142488. */
  142489. get r(): NodeMaterialConnectionPoint;
  142490. /**
  142491. * Gets the g output component
  142492. */
  142493. get g(): NodeMaterialConnectionPoint;
  142494. /**
  142495. * Gets the b output component
  142496. */
  142497. get b(): NodeMaterialConnectionPoint;
  142498. /**
  142499. * Gets the a output component
  142500. */
  142501. get a(): NodeMaterialConnectionPoint;
  142502. autoConfigure(material: NodeMaterial): void;
  142503. protected _buildBlock(state: NodeMaterialBuildState): this;
  142504. }
  142505. }
  142506. declare module BABYLON {
  142507. /**
  142508. * Block used to add 2 vectors
  142509. */
  142510. export class AddBlock extends NodeMaterialBlock {
  142511. /**
  142512. * Creates a new AddBlock
  142513. * @param name defines the block name
  142514. */
  142515. constructor(name: string);
  142516. /**
  142517. * Gets the current class name
  142518. * @returns the class name
  142519. */
  142520. getClassName(): string;
  142521. /**
  142522. * Gets the left operand input component
  142523. */
  142524. get left(): NodeMaterialConnectionPoint;
  142525. /**
  142526. * Gets the right operand input component
  142527. */
  142528. get right(): NodeMaterialConnectionPoint;
  142529. /**
  142530. * Gets the output component
  142531. */
  142532. get output(): NodeMaterialConnectionPoint;
  142533. protected _buildBlock(state: NodeMaterialBuildState): this;
  142534. }
  142535. }
  142536. declare module BABYLON {
  142537. /**
  142538. * Block used to scale a vector by a float
  142539. */
  142540. export class ScaleBlock extends NodeMaterialBlock {
  142541. /**
  142542. * Creates a new ScaleBlock
  142543. * @param name defines the block name
  142544. */
  142545. constructor(name: string);
  142546. /**
  142547. * Gets the current class name
  142548. * @returns the class name
  142549. */
  142550. getClassName(): string;
  142551. /**
  142552. * Gets the input component
  142553. */
  142554. get input(): NodeMaterialConnectionPoint;
  142555. /**
  142556. * Gets the factor input component
  142557. */
  142558. get factor(): NodeMaterialConnectionPoint;
  142559. /**
  142560. * Gets the output component
  142561. */
  142562. get output(): NodeMaterialConnectionPoint;
  142563. protected _buildBlock(state: NodeMaterialBuildState): this;
  142564. }
  142565. }
  142566. declare module BABYLON {
  142567. /**
  142568. * Block used to clamp a float
  142569. */
  142570. export class ClampBlock extends NodeMaterialBlock {
  142571. /** Gets or sets the minimum range */
  142572. minimum: number;
  142573. /** Gets or sets the maximum range */
  142574. maximum: number;
  142575. /**
  142576. * Creates a new ClampBlock
  142577. * @param name defines the block name
  142578. */
  142579. constructor(name: string);
  142580. /**
  142581. * Gets the current class name
  142582. * @returns the class name
  142583. */
  142584. getClassName(): string;
  142585. /**
  142586. * Gets the value input component
  142587. */
  142588. get value(): NodeMaterialConnectionPoint;
  142589. /**
  142590. * Gets the output component
  142591. */
  142592. get output(): NodeMaterialConnectionPoint;
  142593. protected _buildBlock(state: NodeMaterialBuildState): this;
  142594. protected _dumpPropertiesCode(): string;
  142595. serialize(): any;
  142596. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  142597. }
  142598. }
  142599. declare module BABYLON {
  142600. /**
  142601. * Block used to apply a cross product between 2 vectors
  142602. */
  142603. export class CrossBlock extends NodeMaterialBlock {
  142604. /**
  142605. * Creates a new CrossBlock
  142606. * @param name defines the block name
  142607. */
  142608. constructor(name: string);
  142609. /**
  142610. * Gets the current class name
  142611. * @returns the class name
  142612. */
  142613. getClassName(): string;
  142614. /**
  142615. * Gets the left operand input component
  142616. */
  142617. get left(): NodeMaterialConnectionPoint;
  142618. /**
  142619. * Gets the right operand input component
  142620. */
  142621. get right(): NodeMaterialConnectionPoint;
  142622. /**
  142623. * Gets the output component
  142624. */
  142625. get output(): NodeMaterialConnectionPoint;
  142626. protected _buildBlock(state: NodeMaterialBuildState): this;
  142627. }
  142628. }
  142629. declare module BABYLON {
  142630. /**
  142631. * Block used to apply a dot product between 2 vectors
  142632. */
  142633. export class DotBlock extends NodeMaterialBlock {
  142634. /**
  142635. * Creates a new DotBlock
  142636. * @param name defines the block name
  142637. */
  142638. constructor(name: string);
  142639. /**
  142640. * Gets the current class name
  142641. * @returns the class name
  142642. */
  142643. getClassName(): string;
  142644. /**
  142645. * Gets the left operand input component
  142646. */
  142647. get left(): NodeMaterialConnectionPoint;
  142648. /**
  142649. * Gets the right operand input component
  142650. */
  142651. get right(): NodeMaterialConnectionPoint;
  142652. /**
  142653. * Gets the output component
  142654. */
  142655. get output(): NodeMaterialConnectionPoint;
  142656. protected _buildBlock(state: NodeMaterialBuildState): this;
  142657. }
  142658. }
  142659. declare module BABYLON {
  142660. /**
  142661. * Block used to normalize a vector
  142662. */
  142663. export class NormalizeBlock extends NodeMaterialBlock {
  142664. /**
  142665. * Creates a new NormalizeBlock
  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 input component
  142676. */
  142677. get input(): NodeMaterialConnectionPoint;
  142678. /**
  142679. * Gets the output component
  142680. */
  142681. get output(): NodeMaterialConnectionPoint;
  142682. protected _buildBlock(state: NodeMaterialBuildState): this;
  142683. }
  142684. }
  142685. declare module BABYLON {
  142686. /**
  142687. * Operations supported by the Trigonometry block
  142688. */
  142689. export enum TrigonometryBlockOperations {
  142690. /** Cos */
  142691. Cos = 0,
  142692. /** Sin */
  142693. Sin = 1,
  142694. /** Abs */
  142695. Abs = 2,
  142696. /** Exp */
  142697. Exp = 3,
  142698. /** Exp2 */
  142699. Exp2 = 4,
  142700. /** Round */
  142701. Round = 5,
  142702. /** Floor */
  142703. Floor = 6,
  142704. /** Ceiling */
  142705. Ceiling = 7,
  142706. /** Square root */
  142707. Sqrt = 8,
  142708. /** Log */
  142709. Log = 9,
  142710. /** Tangent */
  142711. Tan = 10,
  142712. /** Arc tangent */
  142713. ArcTan = 11,
  142714. /** Arc cosinus */
  142715. ArcCos = 12,
  142716. /** Arc sinus */
  142717. ArcSin = 13,
  142718. /** Fraction */
  142719. Fract = 14,
  142720. /** Sign */
  142721. Sign = 15,
  142722. /** To radians (from degrees) */
  142723. Radians = 16,
  142724. /** To degrees (from radians) */
  142725. Degrees = 17
  142726. }
  142727. /**
  142728. * Block used to apply trigonometry operation to floats
  142729. */
  142730. export class TrigonometryBlock extends NodeMaterialBlock {
  142731. /**
  142732. * Gets or sets the operation applied by the block
  142733. */
  142734. operation: TrigonometryBlockOperations;
  142735. /**
  142736. * Creates a new TrigonometryBlock
  142737. * @param name defines the block name
  142738. */
  142739. constructor(name: string);
  142740. /**
  142741. * Gets the current class name
  142742. * @returns the class name
  142743. */
  142744. getClassName(): string;
  142745. /**
  142746. * Gets the input component
  142747. */
  142748. get input(): NodeMaterialConnectionPoint;
  142749. /**
  142750. * Gets the output component
  142751. */
  142752. get output(): NodeMaterialConnectionPoint;
  142753. protected _buildBlock(state: NodeMaterialBuildState): this;
  142754. serialize(): any;
  142755. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  142756. protected _dumpPropertiesCode(): string;
  142757. }
  142758. }
  142759. declare module BABYLON {
  142760. /**
  142761. * Block used to create a Color3/4 out of individual inputs (one for each component)
  142762. */
  142763. export class ColorMergerBlock extends NodeMaterialBlock {
  142764. /**
  142765. * Create a new ColorMergerBlock
  142766. * @param name defines the block name
  142767. */
  142768. constructor(name: string);
  142769. /**
  142770. * Gets the current class name
  142771. * @returns the class name
  142772. */
  142773. getClassName(): string;
  142774. /**
  142775. * Gets the rgb component (input)
  142776. */
  142777. get rgbIn(): NodeMaterialConnectionPoint;
  142778. /**
  142779. * Gets the r component (input)
  142780. */
  142781. get r(): NodeMaterialConnectionPoint;
  142782. /**
  142783. * Gets the g component (input)
  142784. */
  142785. get g(): NodeMaterialConnectionPoint;
  142786. /**
  142787. * Gets the b component (input)
  142788. */
  142789. get b(): NodeMaterialConnectionPoint;
  142790. /**
  142791. * Gets the a component (input)
  142792. */
  142793. get a(): NodeMaterialConnectionPoint;
  142794. /**
  142795. * Gets the rgba component (output)
  142796. */
  142797. get rgba(): NodeMaterialConnectionPoint;
  142798. /**
  142799. * Gets the rgb component (output)
  142800. */
  142801. get rgbOut(): NodeMaterialConnectionPoint;
  142802. /**
  142803. * Gets the rgb component (output)
  142804. * @deprecated Please use rgbOut instead.
  142805. */
  142806. get rgb(): NodeMaterialConnectionPoint;
  142807. protected _buildBlock(state: NodeMaterialBuildState): this;
  142808. }
  142809. }
  142810. declare module BABYLON {
  142811. /**
  142812. * Block used to expand a Vector3/4 into 4 outputs (one for each component)
  142813. */
  142814. export class VectorSplitterBlock extends NodeMaterialBlock {
  142815. /**
  142816. * Create a new VectorSplitterBlock
  142817. * @param name defines the block name
  142818. */
  142819. constructor(name: string);
  142820. /**
  142821. * Gets the current class name
  142822. * @returns the class name
  142823. */
  142824. getClassName(): string;
  142825. /**
  142826. * Gets the xyzw component (input)
  142827. */
  142828. get xyzw(): NodeMaterialConnectionPoint;
  142829. /**
  142830. * Gets the xyz component (input)
  142831. */
  142832. get xyzIn(): NodeMaterialConnectionPoint;
  142833. /**
  142834. * Gets the xy component (input)
  142835. */
  142836. get xyIn(): NodeMaterialConnectionPoint;
  142837. /**
  142838. * Gets the xyz component (output)
  142839. */
  142840. get xyzOut(): NodeMaterialConnectionPoint;
  142841. /**
  142842. * Gets the xy component (output)
  142843. */
  142844. get xyOut(): NodeMaterialConnectionPoint;
  142845. /**
  142846. * Gets the x component (output)
  142847. */
  142848. get x(): NodeMaterialConnectionPoint;
  142849. /**
  142850. * Gets the y component (output)
  142851. */
  142852. get y(): NodeMaterialConnectionPoint;
  142853. /**
  142854. * Gets the z component (output)
  142855. */
  142856. get z(): NodeMaterialConnectionPoint;
  142857. /**
  142858. * Gets the w component (output)
  142859. */
  142860. get w(): NodeMaterialConnectionPoint;
  142861. protected _inputRename(name: string): string;
  142862. protected _outputRename(name: string): string;
  142863. protected _buildBlock(state: NodeMaterialBuildState): this;
  142864. }
  142865. }
  142866. declare module BABYLON {
  142867. /**
  142868. * Block used to lerp between 2 values
  142869. */
  142870. export class LerpBlock extends NodeMaterialBlock {
  142871. /**
  142872. * Creates a new LerpBlock
  142873. * @param name defines the block name
  142874. */
  142875. constructor(name: string);
  142876. /**
  142877. * Gets the current class name
  142878. * @returns the class name
  142879. */
  142880. getClassName(): string;
  142881. /**
  142882. * Gets the left operand input component
  142883. */
  142884. get left(): NodeMaterialConnectionPoint;
  142885. /**
  142886. * Gets the right operand input component
  142887. */
  142888. get right(): NodeMaterialConnectionPoint;
  142889. /**
  142890. * Gets the gradient operand input component
  142891. */
  142892. get gradient(): NodeMaterialConnectionPoint;
  142893. /**
  142894. * Gets the output component
  142895. */
  142896. get output(): NodeMaterialConnectionPoint;
  142897. protected _buildBlock(state: NodeMaterialBuildState): this;
  142898. }
  142899. }
  142900. declare module BABYLON {
  142901. /**
  142902. * Block used to divide 2 vectors
  142903. */
  142904. export class DivideBlock extends NodeMaterialBlock {
  142905. /**
  142906. * Creates a new DivideBlock
  142907. * @param name defines the block name
  142908. */
  142909. constructor(name: string);
  142910. /**
  142911. * Gets the current class name
  142912. * @returns the class name
  142913. */
  142914. getClassName(): string;
  142915. /**
  142916. * Gets the left operand input component
  142917. */
  142918. get left(): NodeMaterialConnectionPoint;
  142919. /**
  142920. * Gets the right operand input component
  142921. */
  142922. get right(): NodeMaterialConnectionPoint;
  142923. /**
  142924. * Gets the output component
  142925. */
  142926. get output(): NodeMaterialConnectionPoint;
  142927. protected _buildBlock(state: NodeMaterialBuildState): this;
  142928. }
  142929. }
  142930. declare module BABYLON {
  142931. /**
  142932. * Block used to subtract 2 vectors
  142933. */
  142934. export class SubtractBlock extends NodeMaterialBlock {
  142935. /**
  142936. * Creates a new SubtractBlock
  142937. * @param name defines the block name
  142938. */
  142939. constructor(name: string);
  142940. /**
  142941. * Gets the current class name
  142942. * @returns the class name
  142943. */
  142944. getClassName(): string;
  142945. /**
  142946. * Gets the left operand input component
  142947. */
  142948. get left(): NodeMaterialConnectionPoint;
  142949. /**
  142950. * Gets the right operand input component
  142951. */
  142952. get right(): NodeMaterialConnectionPoint;
  142953. /**
  142954. * Gets the output component
  142955. */
  142956. get output(): NodeMaterialConnectionPoint;
  142957. protected _buildBlock(state: NodeMaterialBuildState): this;
  142958. }
  142959. }
  142960. declare module BABYLON {
  142961. /**
  142962. * Block used to step a value
  142963. */
  142964. export class StepBlock extends NodeMaterialBlock {
  142965. /**
  142966. * Creates a new StepBlock
  142967. * @param name defines the block name
  142968. */
  142969. constructor(name: string);
  142970. /**
  142971. * Gets the current class name
  142972. * @returns the class name
  142973. */
  142974. getClassName(): string;
  142975. /**
  142976. * Gets the value operand input component
  142977. */
  142978. get value(): NodeMaterialConnectionPoint;
  142979. /**
  142980. * Gets the edge operand input component
  142981. */
  142982. get edge(): NodeMaterialConnectionPoint;
  142983. /**
  142984. * Gets the output component
  142985. */
  142986. get output(): NodeMaterialConnectionPoint;
  142987. protected _buildBlock(state: NodeMaterialBuildState): this;
  142988. }
  142989. }
  142990. declare module BABYLON {
  142991. /**
  142992. * Block used to get the opposite (1 - x) of a value
  142993. */
  142994. export class OneMinusBlock extends NodeMaterialBlock {
  142995. /**
  142996. * Creates a new OneMinusBlock
  142997. * @param name defines the block name
  142998. */
  142999. constructor(name: string);
  143000. /**
  143001. * Gets the current class name
  143002. * @returns the class name
  143003. */
  143004. getClassName(): string;
  143005. /**
  143006. * Gets the input component
  143007. */
  143008. get input(): NodeMaterialConnectionPoint;
  143009. /**
  143010. * Gets the output component
  143011. */
  143012. get output(): NodeMaterialConnectionPoint;
  143013. protected _buildBlock(state: NodeMaterialBuildState): this;
  143014. }
  143015. }
  143016. declare module BABYLON {
  143017. /**
  143018. * Block used to get the view direction
  143019. */
  143020. export class ViewDirectionBlock extends NodeMaterialBlock {
  143021. /**
  143022. * Creates a new ViewDirectionBlock
  143023. * @param name defines the block name
  143024. */
  143025. constructor(name: string);
  143026. /**
  143027. * Gets the current class name
  143028. * @returns the class name
  143029. */
  143030. getClassName(): string;
  143031. /**
  143032. * Gets the world position component
  143033. */
  143034. get worldPosition(): NodeMaterialConnectionPoint;
  143035. /**
  143036. * Gets the camera position component
  143037. */
  143038. get cameraPosition(): NodeMaterialConnectionPoint;
  143039. /**
  143040. * Gets the output component
  143041. */
  143042. get output(): NodeMaterialConnectionPoint;
  143043. autoConfigure(material: NodeMaterial): void;
  143044. protected _buildBlock(state: NodeMaterialBuildState): this;
  143045. }
  143046. }
  143047. declare module BABYLON {
  143048. /**
  143049. * Block used to compute fresnel value
  143050. */
  143051. export class FresnelBlock extends NodeMaterialBlock {
  143052. /**
  143053. * Create a new FresnelBlock
  143054. * @param name defines the block name
  143055. */
  143056. constructor(name: string);
  143057. /**
  143058. * Gets the current class name
  143059. * @returns the class name
  143060. */
  143061. getClassName(): string;
  143062. /**
  143063. * Gets the world normal input component
  143064. */
  143065. get worldNormal(): NodeMaterialConnectionPoint;
  143066. /**
  143067. * Gets the view direction input component
  143068. */
  143069. get viewDirection(): NodeMaterialConnectionPoint;
  143070. /**
  143071. * Gets the bias input component
  143072. */
  143073. get bias(): NodeMaterialConnectionPoint;
  143074. /**
  143075. * Gets the camera (or eye) position component
  143076. */
  143077. get power(): NodeMaterialConnectionPoint;
  143078. /**
  143079. * Gets the fresnel output component
  143080. */
  143081. get fresnel(): NodeMaterialConnectionPoint;
  143082. autoConfigure(material: NodeMaterial): void;
  143083. protected _buildBlock(state: NodeMaterialBuildState): this;
  143084. }
  143085. }
  143086. declare module BABYLON {
  143087. /**
  143088. * Block used to get the max of 2 values
  143089. */
  143090. export class MaxBlock extends NodeMaterialBlock {
  143091. /**
  143092. * Creates a new MaxBlock
  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 output component
  143111. */
  143112. get output(): NodeMaterialConnectionPoint;
  143113. protected _buildBlock(state: NodeMaterialBuildState): this;
  143114. }
  143115. }
  143116. declare module BABYLON {
  143117. /**
  143118. * Block used to get the min of 2 values
  143119. */
  143120. export class MinBlock extends NodeMaterialBlock {
  143121. /**
  143122. * Creates a new MinBlock
  143123. * @param name defines the block name
  143124. */
  143125. constructor(name: string);
  143126. /**
  143127. * Gets the current class name
  143128. * @returns the class name
  143129. */
  143130. getClassName(): string;
  143131. /**
  143132. * Gets the left operand input component
  143133. */
  143134. get left(): NodeMaterialConnectionPoint;
  143135. /**
  143136. * Gets the right operand input component
  143137. */
  143138. get right(): NodeMaterialConnectionPoint;
  143139. /**
  143140. * Gets the output component
  143141. */
  143142. get output(): NodeMaterialConnectionPoint;
  143143. protected _buildBlock(state: NodeMaterialBuildState): this;
  143144. }
  143145. }
  143146. declare module BABYLON {
  143147. /**
  143148. * Block used to get the distance between 2 values
  143149. */
  143150. export class DistanceBlock extends NodeMaterialBlock {
  143151. /**
  143152. * Creates a new DistanceBlock
  143153. * @param name defines the block name
  143154. */
  143155. constructor(name: string);
  143156. /**
  143157. * Gets the current class name
  143158. * @returns the class name
  143159. */
  143160. getClassName(): string;
  143161. /**
  143162. * Gets the left operand input component
  143163. */
  143164. get left(): NodeMaterialConnectionPoint;
  143165. /**
  143166. * Gets the right operand input component
  143167. */
  143168. get right(): NodeMaterialConnectionPoint;
  143169. /**
  143170. * Gets the output component
  143171. */
  143172. get output(): NodeMaterialConnectionPoint;
  143173. protected _buildBlock(state: NodeMaterialBuildState): this;
  143174. }
  143175. }
  143176. declare module BABYLON {
  143177. /**
  143178. * Block used to get the length of a vector
  143179. */
  143180. export class LengthBlock extends NodeMaterialBlock {
  143181. /**
  143182. * Creates a new LengthBlock
  143183. * @param name defines the block name
  143184. */
  143185. constructor(name: string);
  143186. /**
  143187. * Gets the current class name
  143188. * @returns the class name
  143189. */
  143190. getClassName(): string;
  143191. /**
  143192. * Gets the value input component
  143193. */
  143194. get value(): NodeMaterialConnectionPoint;
  143195. /**
  143196. * Gets the output component
  143197. */
  143198. get output(): NodeMaterialConnectionPoint;
  143199. protected _buildBlock(state: NodeMaterialBuildState): this;
  143200. }
  143201. }
  143202. declare module BABYLON {
  143203. /**
  143204. * Block used to get negative version of a value (i.e. x * -1)
  143205. */
  143206. export class NegateBlock extends NodeMaterialBlock {
  143207. /**
  143208. * Creates a new NegateBlock
  143209. * @param name defines the block name
  143210. */
  143211. constructor(name: string);
  143212. /**
  143213. * Gets the current class name
  143214. * @returns the class name
  143215. */
  143216. getClassName(): string;
  143217. /**
  143218. * Gets the value input component
  143219. */
  143220. get value(): NodeMaterialConnectionPoint;
  143221. /**
  143222. * Gets the output component
  143223. */
  143224. get output(): NodeMaterialConnectionPoint;
  143225. protected _buildBlock(state: NodeMaterialBuildState): this;
  143226. }
  143227. }
  143228. declare module BABYLON {
  143229. /**
  143230. * Block used to get the value of the first parameter raised to the power of the second
  143231. */
  143232. export class PowBlock extends NodeMaterialBlock {
  143233. /**
  143234. * Creates a new PowBlock
  143235. * @param name defines the block name
  143236. */
  143237. constructor(name: string);
  143238. /**
  143239. * Gets the current class name
  143240. * @returns the class name
  143241. */
  143242. getClassName(): string;
  143243. /**
  143244. * Gets the value operand input component
  143245. */
  143246. get value(): NodeMaterialConnectionPoint;
  143247. /**
  143248. * Gets the power operand input component
  143249. */
  143250. get power(): NodeMaterialConnectionPoint;
  143251. /**
  143252. * Gets the output component
  143253. */
  143254. get output(): NodeMaterialConnectionPoint;
  143255. protected _buildBlock(state: NodeMaterialBuildState): this;
  143256. }
  143257. }
  143258. declare module BABYLON {
  143259. /**
  143260. * Block used to get a random number
  143261. */
  143262. export class RandomNumberBlock extends NodeMaterialBlock {
  143263. /**
  143264. * Creates a new RandomNumberBlock
  143265. * @param name defines the block name
  143266. */
  143267. constructor(name: string);
  143268. /**
  143269. * Gets the current class name
  143270. * @returns the class name
  143271. */
  143272. getClassName(): string;
  143273. /**
  143274. * Gets the seed input component
  143275. */
  143276. get seed(): NodeMaterialConnectionPoint;
  143277. /**
  143278. * Gets the output component
  143279. */
  143280. get output(): NodeMaterialConnectionPoint;
  143281. protected _buildBlock(state: NodeMaterialBuildState): this;
  143282. }
  143283. }
  143284. declare module BABYLON {
  143285. /**
  143286. * Block used to compute arc tangent of 2 values
  143287. */
  143288. export class ArcTan2Block extends NodeMaterialBlock {
  143289. /**
  143290. * Creates a new ArcTan2Block
  143291. * @param name defines the block name
  143292. */
  143293. constructor(name: string);
  143294. /**
  143295. * Gets the current class name
  143296. * @returns the class name
  143297. */
  143298. getClassName(): string;
  143299. /**
  143300. * Gets the x operand input component
  143301. */
  143302. get x(): NodeMaterialConnectionPoint;
  143303. /**
  143304. * Gets the y operand input component
  143305. */
  143306. get y(): NodeMaterialConnectionPoint;
  143307. /**
  143308. * Gets the output component
  143309. */
  143310. get output(): NodeMaterialConnectionPoint;
  143311. protected _buildBlock(state: NodeMaterialBuildState): this;
  143312. }
  143313. }
  143314. declare module BABYLON {
  143315. /**
  143316. * Block used to smooth step a value
  143317. */
  143318. export class SmoothStepBlock extends NodeMaterialBlock {
  143319. /**
  143320. * Creates a new SmoothStepBlock
  143321. * @param name defines the block name
  143322. */
  143323. constructor(name: string);
  143324. /**
  143325. * Gets the current class name
  143326. * @returns the class name
  143327. */
  143328. getClassName(): string;
  143329. /**
  143330. * Gets the value operand input component
  143331. */
  143332. get value(): NodeMaterialConnectionPoint;
  143333. /**
  143334. * Gets the first edge operand input component
  143335. */
  143336. get edge0(): NodeMaterialConnectionPoint;
  143337. /**
  143338. * Gets the second edge operand input component
  143339. */
  143340. get edge1(): NodeMaterialConnectionPoint;
  143341. /**
  143342. * Gets the output component
  143343. */
  143344. get output(): NodeMaterialConnectionPoint;
  143345. protected _buildBlock(state: NodeMaterialBuildState): this;
  143346. }
  143347. }
  143348. declare module BABYLON {
  143349. /**
  143350. * Block used to get the reciprocal (1 / x) of a value
  143351. */
  143352. export class ReciprocalBlock extends NodeMaterialBlock {
  143353. /**
  143354. * Creates a new ReciprocalBlock
  143355. * @param name defines the block name
  143356. */
  143357. constructor(name: string);
  143358. /**
  143359. * Gets the current class name
  143360. * @returns the class name
  143361. */
  143362. getClassName(): string;
  143363. /**
  143364. * Gets the input component
  143365. */
  143366. get input(): NodeMaterialConnectionPoint;
  143367. /**
  143368. * Gets the output component
  143369. */
  143370. get output(): NodeMaterialConnectionPoint;
  143371. protected _buildBlock(state: NodeMaterialBuildState): this;
  143372. }
  143373. }
  143374. declare module BABYLON {
  143375. /**
  143376. * Block used to replace a color by another one
  143377. */
  143378. export class ReplaceColorBlock extends NodeMaterialBlock {
  143379. /**
  143380. * Creates a new ReplaceColorBlock
  143381. * @param name defines the block name
  143382. */
  143383. constructor(name: string);
  143384. /**
  143385. * Gets the current class name
  143386. * @returns the class name
  143387. */
  143388. getClassName(): string;
  143389. /**
  143390. * Gets the value input component
  143391. */
  143392. get value(): NodeMaterialConnectionPoint;
  143393. /**
  143394. * Gets the reference input component
  143395. */
  143396. get reference(): NodeMaterialConnectionPoint;
  143397. /**
  143398. * Gets the distance input component
  143399. */
  143400. get distance(): NodeMaterialConnectionPoint;
  143401. /**
  143402. * Gets the replacement input component
  143403. */
  143404. get replacement(): NodeMaterialConnectionPoint;
  143405. /**
  143406. * Gets the output component
  143407. */
  143408. get output(): NodeMaterialConnectionPoint;
  143409. protected _buildBlock(state: NodeMaterialBuildState): this;
  143410. }
  143411. }
  143412. declare module BABYLON {
  143413. /**
  143414. * Block used to posterize a value
  143415. * @see https://en.wikipedia.org/wiki/Posterization
  143416. */
  143417. export class PosterizeBlock extends NodeMaterialBlock {
  143418. /**
  143419. * Creates a new PosterizeBlock
  143420. * @param name defines the block name
  143421. */
  143422. constructor(name: string);
  143423. /**
  143424. * Gets the current class name
  143425. * @returns the class name
  143426. */
  143427. getClassName(): string;
  143428. /**
  143429. * Gets the value input component
  143430. */
  143431. get value(): NodeMaterialConnectionPoint;
  143432. /**
  143433. * Gets the steps input component
  143434. */
  143435. get steps(): NodeMaterialConnectionPoint;
  143436. /**
  143437. * Gets the output component
  143438. */
  143439. get output(): NodeMaterialConnectionPoint;
  143440. protected _buildBlock(state: NodeMaterialBuildState): this;
  143441. }
  143442. }
  143443. declare module BABYLON {
  143444. /**
  143445. * Operations supported by the Wave block
  143446. */
  143447. export enum WaveBlockKind {
  143448. /** SawTooth */
  143449. SawTooth = 0,
  143450. /** Square */
  143451. Square = 1,
  143452. /** Triangle */
  143453. Triangle = 2
  143454. }
  143455. /**
  143456. * Block used to apply wave operation to floats
  143457. */
  143458. export class WaveBlock extends NodeMaterialBlock {
  143459. /**
  143460. * Gets or sets the kibnd of wave to be applied by the block
  143461. */
  143462. kind: WaveBlockKind;
  143463. /**
  143464. * Creates a new WaveBlock
  143465. * @param name defines the block name
  143466. */
  143467. constructor(name: string);
  143468. /**
  143469. * Gets the current class name
  143470. * @returns the class name
  143471. */
  143472. getClassName(): string;
  143473. /**
  143474. * Gets the input component
  143475. */
  143476. get input(): NodeMaterialConnectionPoint;
  143477. /**
  143478. * Gets the output component
  143479. */
  143480. get output(): NodeMaterialConnectionPoint;
  143481. protected _buildBlock(state: NodeMaterialBuildState): this;
  143482. serialize(): any;
  143483. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  143484. }
  143485. }
  143486. declare module BABYLON {
  143487. /**
  143488. * Class used to store a color step for the GradientBlock
  143489. */
  143490. export class GradientBlockColorStep {
  143491. /**
  143492. * Gets or sets a value indicating which step this color is associated with (between 0 and 1)
  143493. */
  143494. step: number;
  143495. /**
  143496. * Gets or sets the color associated with this step
  143497. */
  143498. color: Color3;
  143499. /**
  143500. * Creates a new GradientBlockColorStep
  143501. * @param step defines a value indicating which step this color is associated with (between 0 and 1)
  143502. * @param color defines the color associated with this step
  143503. */
  143504. constructor(
  143505. /**
  143506. * Gets or sets a value indicating which step this color is associated with (between 0 and 1)
  143507. */
  143508. step: number,
  143509. /**
  143510. * Gets or sets the color associated with this step
  143511. */
  143512. color: Color3);
  143513. }
  143514. /**
  143515. * Block used to return a color from a gradient based on an input value between 0 and 1
  143516. */
  143517. export class GradientBlock extends NodeMaterialBlock {
  143518. /**
  143519. * Gets or sets the list of color steps
  143520. */
  143521. colorSteps: GradientBlockColorStep[];
  143522. /**
  143523. * Creates a new GradientBlock
  143524. * @param name defines the block name
  143525. */
  143526. constructor(name: string);
  143527. /**
  143528. * Gets the current class name
  143529. * @returns the class name
  143530. */
  143531. getClassName(): string;
  143532. /**
  143533. * Gets the gradient input component
  143534. */
  143535. get gradient(): NodeMaterialConnectionPoint;
  143536. /**
  143537. * Gets the output component
  143538. */
  143539. get output(): NodeMaterialConnectionPoint;
  143540. private _writeColorConstant;
  143541. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  143542. serialize(): any;
  143543. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  143544. protected _dumpPropertiesCode(): string;
  143545. }
  143546. }
  143547. declare module BABYLON {
  143548. /**
  143549. * Block used to normalize lerp between 2 values
  143550. */
  143551. export class NLerpBlock extends NodeMaterialBlock {
  143552. /**
  143553. * Creates a new NLerpBlock
  143554. * @param name defines the block name
  143555. */
  143556. constructor(name: string);
  143557. /**
  143558. * Gets the current class name
  143559. * @returns the class name
  143560. */
  143561. getClassName(): string;
  143562. /**
  143563. * Gets the left operand input component
  143564. */
  143565. get left(): NodeMaterialConnectionPoint;
  143566. /**
  143567. * Gets the right operand input component
  143568. */
  143569. get right(): NodeMaterialConnectionPoint;
  143570. /**
  143571. * Gets the gradient operand input component
  143572. */
  143573. get gradient(): NodeMaterialConnectionPoint;
  143574. /**
  143575. * Gets the output component
  143576. */
  143577. get output(): NodeMaterialConnectionPoint;
  143578. protected _buildBlock(state: NodeMaterialBuildState): this;
  143579. }
  143580. }
  143581. declare module BABYLON {
  143582. /**
  143583. * block used to Generate a Worley Noise 3D Noise Pattern
  143584. */
  143585. export class WorleyNoise3DBlock extends NodeMaterialBlock {
  143586. /** Gets or sets a boolean indicating that normal should be inverted on X axis */
  143587. manhattanDistance: boolean;
  143588. /**
  143589. * Creates a new WorleyNoise3DBlock
  143590. * @param name defines the block name
  143591. */
  143592. constructor(name: string);
  143593. /**
  143594. * Gets the current class name
  143595. * @returns the class name
  143596. */
  143597. getClassName(): string;
  143598. /**
  143599. * Gets the seed input component
  143600. */
  143601. get seed(): NodeMaterialConnectionPoint;
  143602. /**
  143603. * Gets the jitter input component
  143604. */
  143605. get jitter(): NodeMaterialConnectionPoint;
  143606. /**
  143607. * Gets the output component
  143608. */
  143609. get output(): NodeMaterialConnectionPoint;
  143610. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  143611. /**
  143612. * Exposes the properties to the UI?
  143613. */
  143614. protected _dumpPropertiesCode(): string;
  143615. /**
  143616. * Exposes the properties to the Seralize?
  143617. */
  143618. serialize(): any;
  143619. /**
  143620. * Exposes the properties to the deseralize?
  143621. */
  143622. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  143623. }
  143624. }
  143625. declare module BABYLON {
  143626. /**
  143627. * block used to Generate a Simplex Perlin 3d Noise Pattern
  143628. */
  143629. export class SimplexPerlin3DBlock extends NodeMaterialBlock {
  143630. /**
  143631. * Creates a new SimplexPerlin3DBlock
  143632. * @param name defines the block name
  143633. */
  143634. constructor(name: string);
  143635. /**
  143636. * Gets the current class name
  143637. * @returns the class name
  143638. */
  143639. getClassName(): string;
  143640. /**
  143641. * Gets the seed operand input component
  143642. */
  143643. get seed(): NodeMaterialConnectionPoint;
  143644. /**
  143645. * Gets the output component
  143646. */
  143647. get output(): NodeMaterialConnectionPoint;
  143648. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  143649. }
  143650. }
  143651. declare module BABYLON {
  143652. /**
  143653. * Block used to blend normals
  143654. */
  143655. export class NormalBlendBlock extends NodeMaterialBlock {
  143656. /**
  143657. * Creates a new NormalBlendBlock
  143658. * @param name defines the block name
  143659. */
  143660. constructor(name: string);
  143661. /**
  143662. * Gets the current class name
  143663. * @returns the class name
  143664. */
  143665. getClassName(): string;
  143666. /**
  143667. * Gets the first input component
  143668. */
  143669. get normalMap0(): NodeMaterialConnectionPoint;
  143670. /**
  143671. * Gets the second input component
  143672. */
  143673. get normalMap1(): NodeMaterialConnectionPoint;
  143674. /**
  143675. * Gets the output component
  143676. */
  143677. get output(): NodeMaterialConnectionPoint;
  143678. protected _buildBlock(state: NodeMaterialBuildState): this;
  143679. }
  143680. }
  143681. declare module BABYLON {
  143682. /**
  143683. * Block used to rotate a 2d vector by a given angle
  143684. */
  143685. export class Rotate2dBlock extends NodeMaterialBlock {
  143686. /**
  143687. * Creates a new Rotate2dBlock
  143688. * @param name defines the block name
  143689. */
  143690. constructor(name: string);
  143691. /**
  143692. * Gets the current class name
  143693. * @returns the class name
  143694. */
  143695. getClassName(): string;
  143696. /**
  143697. * Gets the input vector
  143698. */
  143699. get input(): NodeMaterialConnectionPoint;
  143700. /**
  143701. * Gets the input angle
  143702. */
  143703. get angle(): NodeMaterialConnectionPoint;
  143704. /**
  143705. * Gets the output component
  143706. */
  143707. get output(): NodeMaterialConnectionPoint;
  143708. autoConfigure(material: NodeMaterial): void;
  143709. protected _buildBlock(state: NodeMaterialBuildState): this;
  143710. }
  143711. }
  143712. declare module BABYLON {
  143713. /**
  143714. * Block used to get the reflected vector from a direction and a normal
  143715. */
  143716. export class ReflectBlock extends NodeMaterialBlock {
  143717. /**
  143718. * Creates a new ReflectBlock
  143719. * @param name defines the block name
  143720. */
  143721. constructor(name: string);
  143722. /**
  143723. * Gets the current class name
  143724. * @returns the class name
  143725. */
  143726. getClassName(): string;
  143727. /**
  143728. * Gets the incident component
  143729. */
  143730. get incident(): NodeMaterialConnectionPoint;
  143731. /**
  143732. * Gets the normal component
  143733. */
  143734. get normal(): NodeMaterialConnectionPoint;
  143735. /**
  143736. * Gets the output component
  143737. */
  143738. get output(): NodeMaterialConnectionPoint;
  143739. protected _buildBlock(state: NodeMaterialBuildState): this;
  143740. }
  143741. }
  143742. declare module BABYLON {
  143743. /**
  143744. * Block used to get the refracted vector from a direction and a normal
  143745. */
  143746. export class RefractBlock extends NodeMaterialBlock {
  143747. /**
  143748. * Creates a new RefractBlock
  143749. * @param name defines the block name
  143750. */
  143751. constructor(name: string);
  143752. /**
  143753. * Gets the current class name
  143754. * @returns the class name
  143755. */
  143756. getClassName(): string;
  143757. /**
  143758. * Gets the incident component
  143759. */
  143760. get incident(): NodeMaterialConnectionPoint;
  143761. /**
  143762. * Gets the normal component
  143763. */
  143764. get normal(): NodeMaterialConnectionPoint;
  143765. /**
  143766. * Gets the index of refraction component
  143767. */
  143768. get ior(): NodeMaterialConnectionPoint;
  143769. /**
  143770. * Gets the output component
  143771. */
  143772. get output(): NodeMaterialConnectionPoint;
  143773. protected _buildBlock(state: NodeMaterialBuildState): this;
  143774. }
  143775. }
  143776. declare module BABYLON {
  143777. /**
  143778. * Block used to desaturate a color
  143779. */
  143780. export class DesaturateBlock extends NodeMaterialBlock {
  143781. /**
  143782. * Creates a new DesaturateBlock
  143783. * @param name defines the block name
  143784. */
  143785. constructor(name: string);
  143786. /**
  143787. * Gets the current class name
  143788. * @returns the class name
  143789. */
  143790. getClassName(): string;
  143791. /**
  143792. * Gets the color operand input component
  143793. */
  143794. get color(): NodeMaterialConnectionPoint;
  143795. /**
  143796. * Gets the level operand input component
  143797. */
  143798. get level(): NodeMaterialConnectionPoint;
  143799. /**
  143800. * Gets the output component
  143801. */
  143802. get output(): NodeMaterialConnectionPoint;
  143803. protected _buildBlock(state: NodeMaterialBuildState): this;
  143804. }
  143805. }
  143806. declare module BABYLON {
  143807. /**
  143808. * Block used to implement the ambient occlusion module of the PBR material
  143809. */
  143810. export class AmbientOcclusionBlock extends NodeMaterialBlock {
  143811. /**
  143812. * Create a new AmbientOcclusionBlock
  143813. * @param name defines the block name
  143814. */
  143815. constructor(name: string);
  143816. /**
  143817. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  143818. */
  143819. useAmbientInGrayScale: boolean;
  143820. /**
  143821. * Initialize the block and prepare the context for build
  143822. * @param state defines the state that will be used for the build
  143823. */
  143824. initialize(state: NodeMaterialBuildState): void;
  143825. /**
  143826. * Gets the current class name
  143827. * @returns the class name
  143828. */
  143829. getClassName(): string;
  143830. /**
  143831. * Gets the texture input component
  143832. */
  143833. get texture(): NodeMaterialConnectionPoint;
  143834. /**
  143835. * Gets the texture intensity component
  143836. */
  143837. get intensity(): NodeMaterialConnectionPoint;
  143838. /**
  143839. * Gets the direct light intensity input component
  143840. */
  143841. get directLightIntensity(): NodeMaterialConnectionPoint;
  143842. /**
  143843. * Gets the ambient occlusion object output component
  143844. */
  143845. get ambientOcclusion(): NodeMaterialConnectionPoint;
  143846. /**
  143847. * Gets the main code of the block (fragment side)
  143848. * @param block instance of an AmbientOcclusionBlock or null if the code must be generated without an active ambient occlusion module
  143849. * @returns the shader code
  143850. */
  143851. static GetCode(block: Nullable<AmbientOcclusionBlock>): string;
  143852. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  143853. protected _buildBlock(state: NodeMaterialBuildState): this;
  143854. protected _dumpPropertiesCode(): string;
  143855. serialize(): any;
  143856. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  143857. }
  143858. }
  143859. declare module BABYLON {
  143860. /**
  143861. * Block used to implement the reflection module of the PBR material
  143862. */
  143863. export class ReflectionBlock extends ReflectionTextureBaseBlock {
  143864. /** @hidden */
  143865. _defineLODReflectionAlpha: string;
  143866. /** @hidden */
  143867. _defineLinearSpecularReflection: string;
  143868. private _vEnvironmentIrradianceName;
  143869. /** @hidden */
  143870. _vReflectionMicrosurfaceInfosName: string;
  143871. /** @hidden */
  143872. _vReflectionInfosName: string;
  143873. /** @hidden */
  143874. _vReflectionFilteringInfoName: string;
  143875. private _scene;
  143876. /**
  143877. * The three properties below are set by the main PBR block prior to calling methods of this class.
  143878. * This is to avoid having to add them as inputs here whereas they are already inputs of the main block, so already known.
  143879. * It's less burden on the user side in the editor part.
  143880. */
  143881. /** @hidden */
  143882. worldPositionConnectionPoint: NodeMaterialConnectionPoint;
  143883. /** @hidden */
  143884. worldNormalConnectionPoint: NodeMaterialConnectionPoint;
  143885. /** @hidden */
  143886. cameraPositionConnectionPoint: NodeMaterialConnectionPoint;
  143887. /**
  143888. * Defines if the material uses spherical harmonics vs spherical polynomials for the
  143889. * diffuse part of the IBL.
  143890. */
  143891. useSphericalHarmonics: boolean;
  143892. /**
  143893. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  143894. */
  143895. forceIrradianceInFragment: boolean;
  143896. /**
  143897. * Create a new ReflectionBlock
  143898. * @param name defines the block name
  143899. */
  143900. constructor(name: string);
  143901. /**
  143902. * Gets the current class name
  143903. * @returns the class name
  143904. */
  143905. getClassName(): string;
  143906. /**
  143907. * Gets the position input component
  143908. */
  143909. get position(): NodeMaterialConnectionPoint;
  143910. /**
  143911. * Gets the world position input component
  143912. */
  143913. get worldPosition(): NodeMaterialConnectionPoint;
  143914. /**
  143915. * Gets the world normal input component
  143916. */
  143917. get worldNormal(): NodeMaterialConnectionPoint;
  143918. /**
  143919. * Gets the world input component
  143920. */
  143921. get world(): NodeMaterialConnectionPoint;
  143922. /**
  143923. * Gets the camera (or eye) position component
  143924. */
  143925. get cameraPosition(): NodeMaterialConnectionPoint;
  143926. /**
  143927. * Gets the view input component
  143928. */
  143929. get view(): NodeMaterialConnectionPoint;
  143930. /**
  143931. * Gets the color input component
  143932. */
  143933. get color(): NodeMaterialConnectionPoint;
  143934. /**
  143935. * Gets the reflection object output component
  143936. */
  143937. get reflection(): NodeMaterialConnectionPoint;
  143938. /**
  143939. * Returns true if the block has a texture (either its own texture or the environment texture from the scene, if set)
  143940. */
  143941. get hasTexture(): boolean;
  143942. /**
  143943. * Gets the reflection color (either the name of the variable if the color input is connected, else a default value)
  143944. */
  143945. get reflectionColor(): string;
  143946. protected _getTexture(): Nullable<BaseTexture>;
  143947. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  143948. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh, subMesh?: SubMesh): void;
  143949. /**
  143950. * Gets the code to inject in the vertex shader
  143951. * @param state current state of the node material building
  143952. * @returns the shader code
  143953. */
  143954. handleVertexSide(state: NodeMaterialBuildState): string;
  143955. /**
  143956. * Gets the main code of the block (fragment side)
  143957. * @param state current state of the node material building
  143958. * @param normalVarName name of the existing variable corresponding to the normal
  143959. * @returns the shader code
  143960. */
  143961. getCode(state: NodeMaterialBuildState, normalVarName: string): string;
  143962. protected _buildBlock(state: NodeMaterialBuildState): this;
  143963. protected _dumpPropertiesCode(): string;
  143964. serialize(): any;
  143965. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  143966. }
  143967. }
  143968. declare module BABYLON {
  143969. /**
  143970. * Block used to implement the sheen module of the PBR material
  143971. */
  143972. export class SheenBlock extends NodeMaterialBlock {
  143973. /**
  143974. * Create a new SheenBlock
  143975. * @param name defines the block name
  143976. */
  143977. constructor(name: string);
  143978. /**
  143979. * If true, the sheen effect is layered above the base BRDF with the albedo-scaling technique.
  143980. * It allows the strength of the sheen effect to not depend on the base color of the material,
  143981. * making it easier to setup and tweak the effect
  143982. */
  143983. albedoScaling: boolean;
  143984. /**
  143985. * Defines if the sheen is linked to the sheen color.
  143986. */
  143987. linkSheenWithAlbedo: boolean;
  143988. /**
  143989. * Initialize the block and prepare the context for build
  143990. * @param state defines the state that will be used for the build
  143991. */
  143992. initialize(state: NodeMaterialBuildState): void;
  143993. /**
  143994. * Gets the current class name
  143995. * @returns the class name
  143996. */
  143997. getClassName(): string;
  143998. /**
  143999. * Gets the intensity input component
  144000. */
  144001. get intensity(): NodeMaterialConnectionPoint;
  144002. /**
  144003. * Gets the color input component
  144004. */
  144005. get color(): NodeMaterialConnectionPoint;
  144006. /**
  144007. * Gets the roughness input component
  144008. */
  144009. get roughness(): NodeMaterialConnectionPoint;
  144010. /**
  144011. * Gets the sheen object output component
  144012. */
  144013. get sheen(): NodeMaterialConnectionPoint;
  144014. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  144015. /**
  144016. * Gets the main code of the block (fragment side)
  144017. * @param reflectionBlock instance of a ReflectionBlock null if the code must be generated without an active reflection module
  144018. * @returns the shader code
  144019. */
  144020. getCode(reflectionBlock: Nullable<ReflectionBlock>): string;
  144021. protected _buildBlock(state: NodeMaterialBuildState): this;
  144022. protected _dumpPropertiesCode(): string;
  144023. serialize(): any;
  144024. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  144025. }
  144026. }
  144027. declare module BABYLON {
  144028. /**
  144029. * Block used to implement the reflectivity module of the PBR material
  144030. */
  144031. export class ReflectivityBlock extends NodeMaterialBlock {
  144032. private _metallicReflectanceColor;
  144033. private _metallicF0Factor;
  144034. /** @hidden */
  144035. _vMetallicReflectanceFactorsName: string;
  144036. /**
  144037. * The property below is set by the main PBR block prior to calling methods of this class.
  144038. */
  144039. /** @hidden */
  144040. indexOfRefractionConnectionPoint: Nullable<NodeMaterialConnectionPoint>;
  144041. /**
  144042. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  144043. */
  144044. useAmbientOcclusionFromMetallicTextureRed: boolean;
  144045. /**
  144046. * Specifies if the metallic texture contains the metallness information in its blue channel.
  144047. */
  144048. useMetallnessFromMetallicTextureBlue: boolean;
  144049. /**
  144050. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  144051. */
  144052. useRoughnessFromMetallicTextureAlpha: boolean;
  144053. /**
  144054. * Specifies if the metallic texture contains the roughness information in its green channel.
  144055. */
  144056. useRoughnessFromMetallicTextureGreen: boolean;
  144057. /**
  144058. * Create a new ReflectivityBlock
  144059. * @param name defines the block name
  144060. */
  144061. constructor(name: string);
  144062. /**
  144063. * Initialize the block and prepare the context for build
  144064. * @param state defines the state that will be used for the build
  144065. */
  144066. initialize(state: NodeMaterialBuildState): void;
  144067. /**
  144068. * Gets the current class name
  144069. * @returns the class name
  144070. */
  144071. getClassName(): string;
  144072. /**
  144073. * Gets the metallic input component
  144074. */
  144075. get metallic(): NodeMaterialConnectionPoint;
  144076. /**
  144077. * Gets the roughness input component
  144078. */
  144079. get roughness(): NodeMaterialConnectionPoint;
  144080. /**
  144081. * Gets the texture input component
  144082. */
  144083. get texture(): NodeMaterialConnectionPoint;
  144084. /**
  144085. * Gets the reflectivity object output component
  144086. */
  144087. get reflectivity(): NodeMaterialConnectionPoint;
  144088. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh, subMesh?: SubMesh): void;
  144089. /**
  144090. * Gets the main code of the block (fragment side)
  144091. * @param state current state of the node material building
  144092. * @param aoIntensityVarName name of the variable with the ambient occlusion intensity
  144093. * @returns the shader code
  144094. */
  144095. getCode(state: NodeMaterialBuildState, aoIntensityVarName: string): string;
  144096. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  144097. protected _buildBlock(state: NodeMaterialBuildState): this;
  144098. protected _dumpPropertiesCode(): string;
  144099. serialize(): any;
  144100. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  144101. }
  144102. }
  144103. declare module BABYLON {
  144104. /**
  144105. * Block used to implement the anisotropy module of the PBR material
  144106. */
  144107. export class AnisotropyBlock extends NodeMaterialBlock {
  144108. /**
  144109. * The two properties below are set by the main PBR block prior to calling methods of this class.
  144110. * This is to avoid having to add them as inputs here whereas they are already inputs of the main block, so already known.
  144111. * It's less burden on the user side in the editor part.
  144112. */
  144113. /** @hidden */
  144114. worldPositionConnectionPoint: NodeMaterialConnectionPoint;
  144115. /** @hidden */
  144116. worldNormalConnectionPoint: NodeMaterialConnectionPoint;
  144117. /**
  144118. * Create a new AnisotropyBlock
  144119. * @param name defines the block name
  144120. */
  144121. constructor(name: string);
  144122. /**
  144123. * Initialize the block and prepare the context for build
  144124. * @param state defines the state that will be used for the build
  144125. */
  144126. initialize(state: NodeMaterialBuildState): void;
  144127. /**
  144128. * Gets the current class name
  144129. * @returns the class name
  144130. */
  144131. getClassName(): string;
  144132. /**
  144133. * Gets the intensity input component
  144134. */
  144135. get intensity(): NodeMaterialConnectionPoint;
  144136. /**
  144137. * Gets the direction input component
  144138. */
  144139. get direction(): NodeMaterialConnectionPoint;
  144140. /**
  144141. * Gets the texture input component
  144142. */
  144143. get texture(): NodeMaterialConnectionPoint;
  144144. /**
  144145. * Gets the uv input component
  144146. */
  144147. get uv(): NodeMaterialConnectionPoint;
  144148. /**
  144149. * Gets the worldTangent input component
  144150. */
  144151. get worldTangent(): NodeMaterialConnectionPoint;
  144152. /**
  144153. * Gets the anisotropy object output component
  144154. */
  144155. get anisotropy(): NodeMaterialConnectionPoint;
  144156. private _generateTBNSpace;
  144157. /**
  144158. * Gets the main code of the block (fragment side)
  144159. * @param state current state of the node material building
  144160. * @param generateTBNSpace if true, the code needed to create the TBN coordinate space is generated
  144161. * @returns the shader code
  144162. */
  144163. getCode(state: NodeMaterialBuildState, generateTBNSpace?: boolean): string;
  144164. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  144165. protected _buildBlock(state: NodeMaterialBuildState): this;
  144166. }
  144167. }
  144168. declare module BABYLON {
  144169. /**
  144170. * Block used to implement the clear coat module of the PBR material
  144171. */
  144172. export class ClearCoatBlock extends NodeMaterialBlock {
  144173. private _scene;
  144174. /**
  144175. * Create a new ClearCoatBlock
  144176. * @param name defines the block name
  144177. */
  144178. constructor(name: string);
  144179. /**
  144180. * Initialize the block and prepare the context for build
  144181. * @param state defines the state that will be used for the build
  144182. */
  144183. initialize(state: NodeMaterialBuildState): void;
  144184. /**
  144185. * Gets the current class name
  144186. * @returns the class name
  144187. */
  144188. getClassName(): string;
  144189. /**
  144190. * Gets the intensity input component
  144191. */
  144192. get intensity(): NodeMaterialConnectionPoint;
  144193. /**
  144194. * Gets the roughness input component
  144195. */
  144196. get roughness(): NodeMaterialConnectionPoint;
  144197. /**
  144198. * Gets the ior input component
  144199. */
  144200. get ior(): NodeMaterialConnectionPoint;
  144201. /**
  144202. * Gets the texture input component
  144203. */
  144204. get texture(): NodeMaterialConnectionPoint;
  144205. /**
  144206. * Gets the bump texture input component
  144207. */
  144208. get bumpTexture(): NodeMaterialConnectionPoint;
  144209. /**
  144210. * Gets the uv input component
  144211. */
  144212. get uv(): NodeMaterialConnectionPoint;
  144213. /**
  144214. * Gets the tint color input component
  144215. */
  144216. get tintColor(): NodeMaterialConnectionPoint;
  144217. /**
  144218. * Gets the tint "at distance" input component
  144219. */
  144220. get tintAtDistance(): NodeMaterialConnectionPoint;
  144221. /**
  144222. * Gets the tint thickness input component
  144223. */
  144224. get tintThickness(): NodeMaterialConnectionPoint;
  144225. /**
  144226. * Gets the world tangent input component
  144227. */
  144228. get worldTangent(): NodeMaterialConnectionPoint;
  144229. /**
  144230. * Gets the clear coat object output component
  144231. */
  144232. get clearcoat(): NodeMaterialConnectionPoint;
  144233. autoConfigure(material: NodeMaterial): void;
  144234. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  144235. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh, subMesh?: SubMesh): void;
  144236. private _generateTBNSpace;
  144237. /**
  144238. * Gets the main code of the block (fragment side)
  144239. * @param state current state of the node material building
  144240. * @param ccBlock instance of a ClearCoatBlock or null if the code must be generated without an active clear coat module
  144241. * @param reflectionBlock instance of a ReflectionBlock null if the code must be generated without an active reflection module
  144242. * @param worldPosVarName name of the variable holding the world position
  144243. * @param generateTBNSpace if true, the code needed to create the TBN coordinate space is generated
  144244. * @param vTBNAvailable indicate that the vTBN variable is already existing because it has already been generated by another block (PerturbNormal or Anisotropy)
  144245. * @param worldNormalVarName name of the variable holding the world normal
  144246. * @returns the shader code
  144247. */
  144248. static GetCode(state: NodeMaterialBuildState, ccBlock: Nullable<ClearCoatBlock>, reflectionBlock: Nullable<ReflectionBlock>, worldPosVarName: string, generateTBNSpace: boolean, vTBNAvailable: boolean, worldNormalVarName: string): string;
  144249. protected _buildBlock(state: NodeMaterialBuildState): this;
  144250. }
  144251. }
  144252. declare module BABYLON {
  144253. /**
  144254. * Block used to implement the sub surface module of the PBR material
  144255. */
  144256. export class SubSurfaceBlock extends NodeMaterialBlock {
  144257. /**
  144258. * Create a new SubSurfaceBlock
  144259. * @param name defines the block name
  144260. */
  144261. constructor(name: string);
  144262. /**
  144263. * Stores the intensity of the different subsurface effects in the thickness texture.
  144264. * * the green channel is the translucency intensity.
  144265. * * the blue channel is the scattering intensity.
  144266. * * the alpha channel is the refraction intensity.
  144267. */
  144268. useMaskFromThicknessTexture: boolean;
  144269. /**
  144270. * Initialize the block and prepare the context for build
  144271. * @param state defines the state that will be used for the build
  144272. */
  144273. initialize(state: NodeMaterialBuildState): void;
  144274. /**
  144275. * Gets the current class name
  144276. * @returns the class name
  144277. */
  144278. getClassName(): string;
  144279. /**
  144280. * Gets the min thickness input component
  144281. */
  144282. get minThickness(): NodeMaterialConnectionPoint;
  144283. /**
  144284. * Gets the max thickness input component
  144285. */
  144286. get maxThickness(): NodeMaterialConnectionPoint;
  144287. /**
  144288. * Gets the thickness texture component
  144289. */
  144290. get thicknessTexture(): NodeMaterialConnectionPoint;
  144291. /**
  144292. * Gets the tint color input component
  144293. */
  144294. get tintColor(): NodeMaterialConnectionPoint;
  144295. /**
  144296. * Gets the translucency intensity input component
  144297. */
  144298. get translucencyIntensity(): NodeMaterialConnectionPoint;
  144299. /**
  144300. * Gets the translucency diffusion distance input component
  144301. */
  144302. get translucencyDiffusionDistance(): NodeMaterialConnectionPoint;
  144303. /**
  144304. * Gets the refraction object parameters
  144305. */
  144306. get refraction(): NodeMaterialConnectionPoint;
  144307. /**
  144308. * Gets the sub surface object output component
  144309. */
  144310. get subsurface(): NodeMaterialConnectionPoint;
  144311. autoConfigure(material: NodeMaterial): void;
  144312. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  144313. /**
  144314. * Gets the main code of the block (fragment side)
  144315. * @param state current state of the node material building
  144316. * @param ssBlock instance of a SubSurfaceBlock or null if the code must be generated without an active sub surface module
  144317. * @param reflectionBlock instance of a ReflectionBlock null if the code must be generated without an active reflection module
  144318. * @param worldPosVarName name of the variable holding the world position
  144319. * @returns the shader code
  144320. */
  144321. static GetCode(state: NodeMaterialBuildState, ssBlock: Nullable<SubSurfaceBlock>, reflectionBlock: Nullable<ReflectionBlock>, worldPosVarName: string): string;
  144322. protected _buildBlock(state: NodeMaterialBuildState): this;
  144323. }
  144324. }
  144325. declare module BABYLON {
  144326. /**
  144327. * Block used to implement the PBR metallic/roughness model
  144328. */
  144329. export class PBRMetallicRoughnessBlock extends NodeMaterialBlock {
  144330. /**
  144331. * Gets or sets the light associated with this block
  144332. */
  144333. light: Nullable<Light>;
  144334. private _lightId;
  144335. private _scene;
  144336. private _environmentBRDFTexture;
  144337. private _environmentBrdfSamplerName;
  144338. private _vNormalWName;
  144339. private _invertNormalName;
  144340. /**
  144341. * Create a new ReflectionBlock
  144342. * @param name defines the block name
  144343. */
  144344. constructor(name: string);
  144345. /**
  144346. * Intensity of the direct lights e.g. the four lights available in your scene.
  144347. * This impacts both the direct diffuse and specular highlights.
  144348. */
  144349. directIntensity: number;
  144350. /**
  144351. * Intensity of the environment e.g. how much the environment will light the object
  144352. * either through harmonics for rough material or through the refelction for shiny ones.
  144353. */
  144354. environmentIntensity: number;
  144355. /**
  144356. * This is a special control allowing the reduction of the specular highlights coming from the
  144357. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  144358. */
  144359. specularIntensity: number;
  144360. /**
  144361. * Defines the falloff type used in this material.
  144362. * It by default is Physical.
  144363. */
  144364. lightFalloff: number;
  144365. /**
  144366. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  144367. */
  144368. useAlphaFromAlbedoTexture: boolean;
  144369. /**
  144370. * Specifies that alpha test should be used
  144371. */
  144372. useAlphaTest: boolean;
  144373. /**
  144374. * Defines the alpha limits in alpha test mode.
  144375. */
  144376. alphaTestCutoff: number;
  144377. /**
  144378. * Specifies that alpha blending should be used
  144379. */
  144380. useAlphaBlending: boolean;
  144381. /**
  144382. * Defines if the alpha value should be determined via the rgb values.
  144383. * If true the luminance of the pixel might be used to find the corresponding alpha value.
  144384. */
  144385. opacityRGB: boolean;
  144386. /**
  144387. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most luminous ones).
  144388. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  144389. */
  144390. useRadianceOverAlpha: boolean;
  144391. /**
  144392. * Specifies that the material will keeps the specular highlights over a transparent surface (only the most luminous ones).
  144393. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  144394. */
  144395. useSpecularOverAlpha: boolean;
  144396. /**
  144397. * Enables specular anti aliasing in the PBR shader.
  144398. * It will both interacts on the Geometry for analytical and IBL lighting.
  144399. * It also prefilter the roughness map based on the bump values.
  144400. */
  144401. enableSpecularAntiAliasing: boolean;
  144402. /**
  144403. * Enables realtime filtering on the texture.
  144404. */
  144405. realTimeFiltering: boolean;
  144406. /**
  144407. * Quality switch for realtime filtering
  144408. */
  144409. realTimeFilteringQuality: number;
  144410. /**
  144411. * Defines if the material uses energy conservation.
  144412. */
  144413. useEnergyConservation: boolean;
  144414. /**
  144415. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  144416. * too much the area relying on ambient texture to define their ambient occlusion.
  144417. */
  144418. useRadianceOcclusion: boolean;
  144419. /**
  144420. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  144421. * makes the reflect vector face the model (under horizon).
  144422. */
  144423. useHorizonOcclusion: boolean;
  144424. /**
  144425. * If set to true, no lighting calculations will be applied.
  144426. */
  144427. unlit: boolean;
  144428. /**
  144429. * Force normal to face away from face.
  144430. */
  144431. forceNormalForward: boolean;
  144432. /**
  144433. * Defines the material debug mode.
  144434. * It helps seeing only some components of the material while troubleshooting.
  144435. */
  144436. debugMode: number;
  144437. /**
  144438. * Specify from where on screen the debug mode should start.
  144439. * The value goes from -1 (full screen) to 1 (not visible)
  144440. * It helps with side by side comparison against the final render
  144441. * This defaults to 0
  144442. */
  144443. debugLimit: number;
  144444. /**
  144445. * As the default viewing range might not be enough (if the ambient is really small for instance)
  144446. * You can use the factor to better multiply the final value.
  144447. */
  144448. debugFactor: number;
  144449. /**
  144450. * Initialize the block and prepare the context for build
  144451. * @param state defines the state that will be used for the build
  144452. */
  144453. initialize(state: NodeMaterialBuildState): void;
  144454. /**
  144455. * Gets the current class name
  144456. * @returns the class name
  144457. */
  144458. getClassName(): string;
  144459. /**
  144460. * Gets the world position input component
  144461. */
  144462. get worldPosition(): NodeMaterialConnectionPoint;
  144463. /**
  144464. * Gets the world normal input component
  144465. */
  144466. get worldNormal(): NodeMaterialConnectionPoint;
  144467. /**
  144468. * Gets the perturbed normal input component
  144469. */
  144470. get perturbedNormal(): NodeMaterialConnectionPoint;
  144471. /**
  144472. * Gets the camera position input component
  144473. */
  144474. get cameraPosition(): NodeMaterialConnectionPoint;
  144475. /**
  144476. * Gets the base color input component
  144477. */
  144478. get baseColor(): NodeMaterialConnectionPoint;
  144479. /**
  144480. * Gets the opacity texture input component
  144481. */
  144482. get opacityTexture(): NodeMaterialConnectionPoint;
  144483. /**
  144484. * Gets the ambient color input component
  144485. */
  144486. get ambientColor(): NodeMaterialConnectionPoint;
  144487. /**
  144488. * Gets the reflectivity object parameters
  144489. */
  144490. get reflectivity(): NodeMaterialConnectionPoint;
  144491. /**
  144492. * Gets the ambient occlusion object parameters
  144493. */
  144494. get ambientOcclusion(): NodeMaterialConnectionPoint;
  144495. /**
  144496. * Gets the reflection object parameters
  144497. */
  144498. get reflection(): NodeMaterialConnectionPoint;
  144499. /**
  144500. * Gets the sheen object parameters
  144501. */
  144502. get sheen(): NodeMaterialConnectionPoint;
  144503. /**
  144504. * Gets the clear coat object parameters
  144505. */
  144506. get clearcoat(): NodeMaterialConnectionPoint;
  144507. /**
  144508. * Gets the sub surface object parameters
  144509. */
  144510. get subsurface(): NodeMaterialConnectionPoint;
  144511. /**
  144512. * Gets the anisotropy object parameters
  144513. */
  144514. get anisotropy(): NodeMaterialConnectionPoint;
  144515. /**
  144516. * Gets the ambient output component
  144517. */
  144518. get ambient(): NodeMaterialConnectionPoint;
  144519. /**
  144520. * Gets the diffuse output component
  144521. */
  144522. get diffuse(): NodeMaterialConnectionPoint;
  144523. /**
  144524. * Gets the specular output component
  144525. */
  144526. get specular(): NodeMaterialConnectionPoint;
  144527. /**
  144528. * Gets the sheen output component
  144529. */
  144530. get sheenDir(): NodeMaterialConnectionPoint;
  144531. /**
  144532. * Gets the clear coat output component
  144533. */
  144534. get clearcoatDir(): NodeMaterialConnectionPoint;
  144535. /**
  144536. * Gets the indirect diffuse output component
  144537. */
  144538. get diffuseIndirect(): NodeMaterialConnectionPoint;
  144539. /**
  144540. * Gets the indirect specular output component
  144541. */
  144542. get specularIndirect(): NodeMaterialConnectionPoint;
  144543. /**
  144544. * Gets the indirect sheen output component
  144545. */
  144546. get sheenIndirect(): NodeMaterialConnectionPoint;
  144547. /**
  144548. * Gets the indirect clear coat output component
  144549. */
  144550. get clearcoatIndirect(): NodeMaterialConnectionPoint;
  144551. /**
  144552. * Gets the refraction output component
  144553. */
  144554. get refraction(): NodeMaterialConnectionPoint;
  144555. /**
  144556. * Gets the global lighting output component
  144557. */
  144558. get lighting(): NodeMaterialConnectionPoint;
  144559. /**
  144560. * Gets the shadow output component
  144561. */
  144562. get shadow(): NodeMaterialConnectionPoint;
  144563. /**
  144564. * Gets the alpha output component
  144565. */
  144566. get alpha(): NodeMaterialConnectionPoint;
  144567. autoConfigure(material: NodeMaterial): void;
  144568. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  144569. updateUniformsAndSamples(state: NodeMaterialBuildState, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, uniformBuffers: string[]): void;
  144570. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  144571. private _injectVertexCode;
  144572. /**
  144573. * Gets the code corresponding to the albedo/opacity module
  144574. * @returns the shader code
  144575. */
  144576. getAlbedoOpacityCode(): string;
  144577. protected _buildBlock(state: NodeMaterialBuildState): this;
  144578. protected _dumpPropertiesCode(): string;
  144579. serialize(): any;
  144580. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  144581. }
  144582. }
  144583. declare module BABYLON {
  144584. /**
  144585. * Block used to compute value of one parameter modulo another
  144586. */
  144587. export class ModBlock extends NodeMaterialBlock {
  144588. /**
  144589. * Creates a new ModBlock
  144590. * @param name defines the block name
  144591. */
  144592. constructor(name: string);
  144593. /**
  144594. * Gets the current class name
  144595. * @returns the class name
  144596. */
  144597. getClassName(): string;
  144598. /**
  144599. * Gets the left operand input component
  144600. */
  144601. get left(): NodeMaterialConnectionPoint;
  144602. /**
  144603. * Gets the right operand input component
  144604. */
  144605. get right(): NodeMaterialConnectionPoint;
  144606. /**
  144607. * Gets the output component
  144608. */
  144609. get output(): NodeMaterialConnectionPoint;
  144610. protected _buildBlock(state: NodeMaterialBuildState): this;
  144611. }
  144612. }
  144613. declare module BABYLON {
  144614. /**
  144615. * Helper class to push actions to a pool of workers.
  144616. */
  144617. export class WorkerPool implements IDisposable {
  144618. private _workerInfos;
  144619. private _pendingActions;
  144620. /**
  144621. * Constructor
  144622. * @param workers Array of workers to use for actions
  144623. */
  144624. constructor(workers: Array<Worker>);
  144625. /**
  144626. * Terminates all workers and clears any pending actions.
  144627. */
  144628. dispose(): void;
  144629. /**
  144630. * Pushes an action to the worker pool. If all the workers are active, the action will be
  144631. * pended until a worker has completed its action.
  144632. * @param action The action to perform. Call onComplete when the action is complete.
  144633. */
  144634. push(action: (worker: Worker, onComplete: () => void) => void): void;
  144635. private _execute;
  144636. }
  144637. }
  144638. declare module BABYLON {
  144639. /**
  144640. * Configuration for Draco compression
  144641. */
  144642. export interface IDracoCompressionConfiguration {
  144643. /**
  144644. * Configuration for the decoder.
  144645. */
  144646. decoder: {
  144647. /**
  144648. * The url to the WebAssembly module.
  144649. */
  144650. wasmUrl?: string;
  144651. /**
  144652. * The url to the WebAssembly binary.
  144653. */
  144654. wasmBinaryUrl?: string;
  144655. /**
  144656. * The url to the fallback JavaScript module.
  144657. */
  144658. fallbackUrl?: string;
  144659. };
  144660. }
  144661. /**
  144662. * Draco compression (https://google.github.io/draco/)
  144663. *
  144664. * This class wraps the Draco module.
  144665. *
  144666. * **Encoder**
  144667. *
  144668. * The encoder is not currently implemented.
  144669. *
  144670. * **Decoder**
  144671. *
  144672. * 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.
  144673. *
  144674. * To update the configuration, use the following code:
  144675. * ```javascript
  144676. * DracoCompression.Configuration = {
  144677. * decoder: {
  144678. * wasmUrl: "<url to the WebAssembly library>",
  144679. * wasmBinaryUrl: "<url to the WebAssembly binary>",
  144680. * fallbackUrl: "<url to the fallback JavaScript library>",
  144681. * }
  144682. * };
  144683. * ```
  144684. *
  144685. * 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.
  144686. * Decoding will automatically fallback to the JavaScript version if WebAssembly version is not configured or if WebAssembly is not supported by the browser.
  144687. * Use `DracoCompression.DecoderAvailable` to determine if the decoder configuration is available for the current context.
  144688. *
  144689. * To decode Draco compressed data, get the default DracoCompression object and call decodeMeshAsync:
  144690. * ```javascript
  144691. * var vertexData = await DracoCompression.Default.decodeMeshAsync(data);
  144692. * ```
  144693. *
  144694. * @see https://www.babylonjs-playground.com/#N3EK4B#0
  144695. */
  144696. export class DracoCompression implements IDisposable {
  144697. private _workerPoolPromise?;
  144698. private _decoderModulePromise?;
  144699. /**
  144700. * The configuration. Defaults to the following urls:
  144701. * - wasmUrl: "https://preview.babylonjs.com/draco_wasm_wrapper_gltf.js"
  144702. * - wasmBinaryUrl: "https://preview.babylonjs.com/draco_decoder_gltf.wasm"
  144703. * - fallbackUrl: "https://preview.babylonjs.com/draco_decoder_gltf.js"
  144704. */
  144705. static Configuration: IDracoCompressionConfiguration;
  144706. /**
  144707. * Returns true if the decoder configuration is available.
  144708. */
  144709. static get DecoderAvailable(): boolean;
  144710. /**
  144711. * Default number of workers to create when creating the draco compression object.
  144712. */
  144713. static DefaultNumWorkers: number;
  144714. private static GetDefaultNumWorkers;
  144715. private static _Default;
  144716. /**
  144717. * Default instance for the draco compression object.
  144718. */
  144719. static get Default(): DracoCompression;
  144720. /**
  144721. * Constructor
  144722. * @param numWorkers The number of workers for async operations. Specify `0` to disable web workers and run synchronously in the current context.
  144723. */
  144724. constructor(numWorkers?: number);
  144725. /**
  144726. * Stop all async operations and release resources.
  144727. */
  144728. dispose(): void;
  144729. /**
  144730. * Returns a promise that resolves when ready. Call this manually to ensure draco compression is ready before use.
  144731. * @returns a promise that resolves when ready
  144732. */
  144733. whenReadyAsync(): Promise<void>;
  144734. /**
  144735. * Decode Draco compressed mesh data to vertex data.
  144736. * @param data The ArrayBuffer or ArrayBufferView for the Draco compression data
  144737. * @param attributes A map of attributes from vertex buffer kinds to Draco unique ids
  144738. * @returns A promise that resolves with the decoded vertex data
  144739. */
  144740. decodeMeshAsync(data: ArrayBuffer | ArrayBufferView, attributes?: {
  144741. [kind: string]: number;
  144742. }): Promise<VertexData>;
  144743. }
  144744. }
  144745. declare module BABYLON {
  144746. /**
  144747. * Class for building Constructive Solid Geometry
  144748. */
  144749. export class CSG {
  144750. private polygons;
  144751. /**
  144752. * The world matrix
  144753. */
  144754. matrix: Matrix;
  144755. /**
  144756. * Stores the position
  144757. */
  144758. position: Vector3;
  144759. /**
  144760. * Stores the rotation
  144761. */
  144762. rotation: Vector3;
  144763. /**
  144764. * Stores the rotation quaternion
  144765. */
  144766. rotationQuaternion: Nullable<Quaternion>;
  144767. /**
  144768. * Stores the scaling vector
  144769. */
  144770. scaling: Vector3;
  144771. /**
  144772. * Convert the Mesh to CSG
  144773. * @param mesh The Mesh to convert to CSG
  144774. * @returns A new CSG from the Mesh
  144775. */
  144776. static FromMesh(mesh: Mesh): CSG;
  144777. /**
  144778. * Construct a CSG solid from a list of `CSG.Polygon` instances.
  144779. * @param polygons Polygons used to construct a CSG solid
  144780. */
  144781. private static FromPolygons;
  144782. /**
  144783. * Clones, or makes a deep copy, of the CSG
  144784. * @returns A new CSG
  144785. */
  144786. clone(): CSG;
  144787. /**
  144788. * Unions this CSG with another CSG
  144789. * @param csg The CSG to union against this CSG
  144790. * @returns The unioned CSG
  144791. */
  144792. union(csg: CSG): CSG;
  144793. /**
  144794. * Unions this CSG with another CSG in place
  144795. * @param csg The CSG to union against this CSG
  144796. */
  144797. unionInPlace(csg: CSG): void;
  144798. /**
  144799. * Subtracts this CSG with another CSG
  144800. * @param csg The CSG to subtract against this CSG
  144801. * @returns A new CSG
  144802. */
  144803. subtract(csg: CSG): CSG;
  144804. /**
  144805. * Subtracts this CSG with another CSG in place
  144806. * @param csg The CSG to subtact against this CSG
  144807. */
  144808. subtractInPlace(csg: CSG): void;
  144809. /**
  144810. * Intersect this CSG with another CSG
  144811. * @param csg The CSG to intersect against this CSG
  144812. * @returns A new CSG
  144813. */
  144814. intersect(csg: CSG): CSG;
  144815. /**
  144816. * Intersects this CSG with another CSG in place
  144817. * @param csg The CSG to intersect against this CSG
  144818. */
  144819. intersectInPlace(csg: CSG): void;
  144820. /**
  144821. * Return a new CSG solid with solid and empty space switched. This solid is
  144822. * not modified.
  144823. * @returns A new CSG solid with solid and empty space switched
  144824. */
  144825. inverse(): CSG;
  144826. /**
  144827. * Inverses the CSG in place
  144828. */
  144829. inverseInPlace(): void;
  144830. /**
  144831. * This is used to keep meshes transformations so they can be restored
  144832. * when we build back a Babylon Mesh
  144833. * NB : All CSG operations are performed in world coordinates
  144834. * @param csg The CSG to copy the transform attributes from
  144835. * @returns This CSG
  144836. */
  144837. copyTransformAttributes(csg: CSG): CSG;
  144838. /**
  144839. * Build Raw mesh from CSG
  144840. * Coordinates here are in world space
  144841. * @param name The name of the mesh geometry
  144842. * @param scene The Scene
  144843. * @param keepSubMeshes Specifies if the submeshes should be kept
  144844. * @returns A new Mesh
  144845. */
  144846. buildMeshGeometry(name: string, scene?: Scene, keepSubMeshes?: boolean): Mesh;
  144847. /**
  144848. * Build Mesh from CSG taking material and transforms into account
  144849. * @param name The name of the Mesh
  144850. * @param material The material of the Mesh
  144851. * @param scene The Scene
  144852. * @param keepSubMeshes Specifies if submeshes should be kept
  144853. * @returns The new Mesh
  144854. */
  144855. toMesh(name: string, material?: Nullable<Material>, scene?: Scene, keepSubMeshes?: boolean): Mesh;
  144856. }
  144857. }
  144858. declare module BABYLON {
  144859. /**
  144860. * Class used to create a trail following a mesh
  144861. */
  144862. export class TrailMesh extends Mesh {
  144863. private _generator;
  144864. private _autoStart;
  144865. private _running;
  144866. private _diameter;
  144867. private _length;
  144868. private _sectionPolygonPointsCount;
  144869. private _sectionVectors;
  144870. private _sectionNormalVectors;
  144871. private _beforeRenderObserver;
  144872. /**
  144873. * @constructor
  144874. * @param name The value used by scene.getMeshByName() to do a lookup.
  144875. * @param generator The mesh or transform node to generate a trail.
  144876. * @param scene The scene to add this mesh to.
  144877. * @param diameter Diameter of trailing mesh. Default is 1.
  144878. * @param length Length of trailing mesh. Default is 60.
  144879. * @param autoStart Automatically start trailing mesh. Default true.
  144880. */
  144881. constructor(name: string, generator: TransformNode, scene: Scene, diameter?: number, length?: number, autoStart?: boolean);
  144882. /**
  144883. * "TrailMesh"
  144884. * @returns "TrailMesh"
  144885. */
  144886. getClassName(): string;
  144887. private _createMesh;
  144888. /**
  144889. * Start trailing mesh.
  144890. */
  144891. start(): void;
  144892. /**
  144893. * Stop trailing mesh.
  144894. */
  144895. stop(): void;
  144896. /**
  144897. * Update trailing mesh geometry.
  144898. */
  144899. update(): void;
  144900. /**
  144901. * Returns a new TrailMesh object.
  144902. * @param name is a string, the name given to the new mesh
  144903. * @param newGenerator use new generator object for cloned trail mesh
  144904. * @returns a new mesh
  144905. */
  144906. clone(name: string | undefined, newGenerator: TransformNode): TrailMesh;
  144907. /**
  144908. * Serializes this trail mesh
  144909. * @param serializationObject object to write serialization to
  144910. */
  144911. serialize(serializationObject: any): void;
  144912. /**
  144913. * Parses a serialized trail mesh
  144914. * @param parsedMesh the serialized mesh
  144915. * @param scene the scene to create the trail mesh in
  144916. * @returns the created trail mesh
  144917. */
  144918. static Parse(parsedMesh: any, scene: Scene): TrailMesh;
  144919. }
  144920. }
  144921. declare module BABYLON {
  144922. /**
  144923. * Class containing static functions to help procedurally build meshes
  144924. */
  144925. export class TiledBoxBuilder {
  144926. /**
  144927. * Creates a box mesh
  144928. * 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)
  144929. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  144930. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  144931. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  144932. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  144933. * @param name defines the name of the mesh
  144934. * @param options defines the options used to create the mesh
  144935. * @param scene defines the hosting scene
  144936. * @returns the box mesh
  144937. */
  144938. static CreateTiledBox(name: string, options: {
  144939. pattern?: number;
  144940. width?: number;
  144941. height?: number;
  144942. depth?: number;
  144943. tileSize?: number;
  144944. tileWidth?: number;
  144945. tileHeight?: number;
  144946. alignHorizontal?: number;
  144947. alignVertical?: number;
  144948. faceUV?: Vector4[];
  144949. faceColors?: Color4[];
  144950. sideOrientation?: number;
  144951. updatable?: boolean;
  144952. }, scene?: Nullable<Scene>): Mesh;
  144953. }
  144954. }
  144955. declare module BABYLON {
  144956. /**
  144957. * Class containing static functions to help procedurally build meshes
  144958. */
  144959. export class TorusKnotBuilder {
  144960. /**
  144961. * Creates a torus knot mesh
  144962. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  144963. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  144964. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  144965. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  144966. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  144967. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  144968. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  144969. * @param name defines the name of the mesh
  144970. * @param options defines the options used to create the mesh
  144971. * @param scene defines the hosting scene
  144972. * @returns the torus knot mesh
  144973. * @see https://doc.babylonjs.com/how_to/set_shapes#torus-knot
  144974. */
  144975. static CreateTorusKnot(name: string, options: {
  144976. radius?: number;
  144977. tube?: number;
  144978. radialSegments?: number;
  144979. tubularSegments?: number;
  144980. p?: number;
  144981. q?: number;
  144982. updatable?: boolean;
  144983. sideOrientation?: number;
  144984. frontUVs?: Vector4;
  144985. backUVs?: Vector4;
  144986. }, scene: any): Mesh;
  144987. }
  144988. }
  144989. declare module BABYLON {
  144990. /**
  144991. * Polygon
  144992. * @see https://doc.babylonjs.com/how_to/parametric_shapes#non-regular-polygon
  144993. */
  144994. export class Polygon {
  144995. /**
  144996. * Creates a rectangle
  144997. * @param xmin bottom X coord
  144998. * @param ymin bottom Y coord
  144999. * @param xmax top X coord
  145000. * @param ymax top Y coord
  145001. * @returns points that make the resulting rectation
  145002. */
  145003. static Rectangle(xmin: number, ymin: number, xmax: number, ymax: number): Vector2[];
  145004. /**
  145005. * Creates a circle
  145006. * @param radius radius of circle
  145007. * @param cx scale in x
  145008. * @param cy scale in y
  145009. * @param numberOfSides number of sides that make up the circle
  145010. * @returns points that make the resulting circle
  145011. */
  145012. static Circle(radius: number, cx?: number, cy?: number, numberOfSides?: number): Vector2[];
  145013. /**
  145014. * Creates a polygon from input string
  145015. * @param input Input polygon data
  145016. * @returns the parsed points
  145017. */
  145018. static Parse(input: string): Vector2[];
  145019. /**
  145020. * Starts building a polygon from x and y coordinates
  145021. * @param x x coordinate
  145022. * @param y y coordinate
  145023. * @returns the started path2
  145024. */
  145025. static StartingAt(x: number, y: number): Path2;
  145026. }
  145027. /**
  145028. * Builds a polygon
  145029. * @see https://doc.babylonjs.com/how_to/polygonmeshbuilder
  145030. */
  145031. export class PolygonMeshBuilder {
  145032. private _points;
  145033. private _outlinepoints;
  145034. private _holes;
  145035. private _name;
  145036. private _scene;
  145037. private _epoints;
  145038. private _eholes;
  145039. private _addToepoint;
  145040. /**
  145041. * Babylon reference to the earcut plugin.
  145042. */
  145043. bjsEarcut: any;
  145044. /**
  145045. * Creates a PolygonMeshBuilder
  145046. * @param name name of the builder
  145047. * @param contours Path of the polygon
  145048. * @param scene scene to add to when creating the mesh
  145049. * @param earcutInjection can be used to inject your own earcut reference
  145050. */
  145051. constructor(name: string, contours: Path2 | Vector2[] | any, scene?: Scene, earcutInjection?: any);
  145052. /**
  145053. * Adds a whole within the polygon
  145054. * @param hole Array of points defining the hole
  145055. * @returns this
  145056. */
  145057. addHole(hole: Vector2[]): PolygonMeshBuilder;
  145058. /**
  145059. * Creates the polygon
  145060. * @param updatable If the mesh should be updatable
  145061. * @param depth The depth of the mesh created
  145062. * @returns the created mesh
  145063. */
  145064. build(updatable?: boolean, depth?: number): Mesh;
  145065. /**
  145066. * Creates the polygon
  145067. * @param depth The depth of the mesh created
  145068. * @returns the created VertexData
  145069. */
  145070. buildVertexData(depth?: number): VertexData;
  145071. /**
  145072. * Adds a side to the polygon
  145073. * @param positions points that make the polygon
  145074. * @param normals normals of the polygon
  145075. * @param uvs uvs of the polygon
  145076. * @param indices indices of the polygon
  145077. * @param bounds bounds of the polygon
  145078. * @param points points of the polygon
  145079. * @param depth depth of the polygon
  145080. * @param flip flip of the polygon
  145081. */
  145082. private addSide;
  145083. }
  145084. }
  145085. declare module BABYLON {
  145086. /**
  145087. * Class containing static functions to help procedurally build meshes
  145088. */
  145089. export class PolygonBuilder {
  145090. /**
  145091. * Creates a polygon mesh
  145092. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  145093. * * 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
  145094. * * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  145095. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  145096. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4)
  145097. * * Remember you can only change the shape positions, not their number when updating a polygon
  145098. * @param name defines the name of the mesh
  145099. * @param options defines the options used to create the mesh
  145100. * @param scene defines the hosting scene
  145101. * @param earcutInjection can be used to inject your own earcut reference
  145102. * @returns the polygon mesh
  145103. */
  145104. static CreatePolygon(name: string, options: {
  145105. shape: Vector3[];
  145106. holes?: Vector3[][];
  145107. depth?: number;
  145108. faceUV?: Vector4[];
  145109. faceColors?: Color4[];
  145110. updatable?: boolean;
  145111. sideOrientation?: number;
  145112. frontUVs?: Vector4;
  145113. backUVs?: Vector4;
  145114. wrap?: boolean;
  145115. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  145116. /**
  145117. * Creates an extruded polygon mesh, with depth in the Y direction.
  145118. * * 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)
  145119. * @see https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  145120. * @param name defines the name of the mesh
  145121. * @param options defines the options used to create the mesh
  145122. * @param scene defines the hosting scene
  145123. * @param earcutInjection can be used to inject your own earcut reference
  145124. * @returns the polygon mesh
  145125. */
  145126. static ExtrudePolygon(name: string, options: {
  145127. shape: Vector3[];
  145128. holes?: Vector3[][];
  145129. depth?: number;
  145130. faceUV?: Vector4[];
  145131. faceColors?: Color4[];
  145132. updatable?: boolean;
  145133. sideOrientation?: number;
  145134. frontUVs?: Vector4;
  145135. backUVs?: Vector4;
  145136. wrap?: boolean;
  145137. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  145138. }
  145139. }
  145140. declare module BABYLON {
  145141. /**
  145142. * Class containing static functions to help procedurally build meshes
  145143. */
  145144. export class LatheBuilder {
  145145. /**
  145146. * Creates lathe mesh.
  145147. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe
  145148. * * 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
  145149. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  145150. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  145151. * * The parameter `clip` (positive integer, default 0) is the number of sides to not create without effecting the general shape of the sides
  145152. * * 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
  145153. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  145154. * * 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
  145155. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  145156. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  145157. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  145158. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  145159. * @param name defines the name of the mesh
  145160. * @param options defines the options used to create the mesh
  145161. * @param scene defines the hosting scene
  145162. * @returns the lathe mesh
  145163. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lathe
  145164. */
  145165. static CreateLathe(name: string, options: {
  145166. shape: Vector3[];
  145167. radius?: number;
  145168. tessellation?: number;
  145169. clip?: number;
  145170. arc?: number;
  145171. closed?: boolean;
  145172. updatable?: boolean;
  145173. sideOrientation?: number;
  145174. frontUVs?: Vector4;
  145175. backUVs?: Vector4;
  145176. cap?: number;
  145177. invertUV?: boolean;
  145178. }, scene?: Nullable<Scene>): Mesh;
  145179. }
  145180. }
  145181. declare module BABYLON {
  145182. /**
  145183. * Class containing static functions to help procedurally build meshes
  145184. */
  145185. export class TiledPlaneBuilder {
  145186. /**
  145187. * Creates a tiled plane mesh
  145188. * * The parameter `pattern` will, depending on value, do nothing or
  145189. * * * flip (reflect about central vertical) alternate tiles across and up
  145190. * * * flip every tile on alternate rows
  145191. * * * rotate (180 degs) alternate tiles across and up
  145192. * * * rotate every tile on alternate rows
  145193. * * * flip and rotate alternate tiles across and up
  145194. * * * flip and rotate every tile on alternate rows
  145195. * * The parameter `tileSize` sets the size (float) of each tile side (default 1)
  145196. * * You can set some different tile dimensions by using the parameters `tileWidth` and `tileHeight` (both by default have the same value of `tileSize`)
  145197. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  145198. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  145199. * * 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)
  145200. * * 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)
  145201. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  145202. * @param name defines the name of the mesh
  145203. * @param options defines the options used to create the mesh
  145204. * @param scene defines the hosting scene
  145205. * @returns the box mesh
  145206. */
  145207. static CreateTiledPlane(name: string, options: {
  145208. pattern?: number;
  145209. tileSize?: number;
  145210. tileWidth?: number;
  145211. tileHeight?: number;
  145212. size?: number;
  145213. width?: number;
  145214. height?: number;
  145215. alignHorizontal?: number;
  145216. alignVertical?: number;
  145217. sideOrientation?: number;
  145218. frontUVs?: Vector4;
  145219. backUVs?: Vector4;
  145220. updatable?: boolean;
  145221. }, scene?: Nullable<Scene>): Mesh;
  145222. }
  145223. }
  145224. declare module BABYLON {
  145225. /**
  145226. * Class containing static functions to help procedurally build meshes
  145227. */
  145228. export class TubeBuilder {
  145229. /**
  145230. * Creates a tube mesh.
  145231. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  145232. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  145233. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  145234. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  145235. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`
  145236. * * 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)
  145237. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  145238. * * 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
  145239. * * 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
  145240. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  145241. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  145242. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  145243. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  145244. * @param name defines the name of the mesh
  145245. * @param options defines the options used to create the mesh
  145246. * @param scene defines the hosting scene
  145247. * @returns the tube mesh
  145248. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  145249. * @see https://doc.babylonjs.com/how_to/set_shapes#tube
  145250. */
  145251. static CreateTube(name: string, options: {
  145252. path: Vector3[];
  145253. radius?: number;
  145254. tessellation?: number;
  145255. radiusFunction?: {
  145256. (i: number, distance: number): number;
  145257. };
  145258. cap?: number;
  145259. arc?: number;
  145260. updatable?: boolean;
  145261. sideOrientation?: number;
  145262. frontUVs?: Vector4;
  145263. backUVs?: Vector4;
  145264. instance?: Mesh;
  145265. invertUV?: boolean;
  145266. }, scene?: Nullable<Scene>): Mesh;
  145267. }
  145268. }
  145269. declare module BABYLON {
  145270. /**
  145271. * Class containing static functions to help procedurally build meshes
  145272. */
  145273. export class IcoSphereBuilder {
  145274. /**
  145275. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  145276. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  145277. * * 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`)
  145278. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  145279. * * 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
  145280. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  145281. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  145282. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  145283. * @param name defines the name of the mesh
  145284. * @param options defines the options used to create the mesh
  145285. * @param scene defines the hosting scene
  145286. * @returns the icosahedron mesh
  145287. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  145288. */
  145289. static CreateIcoSphere(name: string, options: {
  145290. radius?: number;
  145291. radiusX?: number;
  145292. radiusY?: number;
  145293. radiusZ?: number;
  145294. flat?: boolean;
  145295. subdivisions?: number;
  145296. sideOrientation?: number;
  145297. frontUVs?: Vector4;
  145298. backUVs?: Vector4;
  145299. updatable?: boolean;
  145300. }, scene?: Nullable<Scene>): Mesh;
  145301. }
  145302. }
  145303. declare module BABYLON {
  145304. /**
  145305. * Class containing static functions to help procedurally build meshes
  145306. */
  145307. export class DecalBuilder {
  145308. /**
  145309. * Creates a decal mesh.
  145310. * 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
  145311. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  145312. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  145313. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  145314. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  145315. * @param name defines the name of the mesh
  145316. * @param sourceMesh defines the mesh where the decal must be applied
  145317. * @param options defines the options used to create the mesh
  145318. * @param scene defines the hosting scene
  145319. * @returns the decal mesh
  145320. * @see https://doc.babylonjs.com/how_to/decals
  145321. */
  145322. static CreateDecal(name: string, sourceMesh: AbstractMesh, options: {
  145323. position?: Vector3;
  145324. normal?: Vector3;
  145325. size?: Vector3;
  145326. angle?: number;
  145327. }): Mesh;
  145328. }
  145329. }
  145330. declare module BABYLON {
  145331. /**
  145332. * Class containing static functions to help procedurally build meshes
  145333. */
  145334. export class MeshBuilder {
  145335. /**
  145336. * Creates a box mesh
  145337. * * The parameter `size` sets the size (float) of each box side (default 1)
  145338. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value of `size`)
  145339. * * 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)
  145340. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  145341. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  145342. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  145343. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  145344. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  145345. * @param name defines the name of the mesh
  145346. * @param options defines the options used to create the mesh
  145347. * @param scene defines the hosting scene
  145348. * @returns the box mesh
  145349. */
  145350. static CreateBox(name: string, options: {
  145351. size?: number;
  145352. width?: number;
  145353. height?: number;
  145354. depth?: number;
  145355. faceUV?: Vector4[];
  145356. faceColors?: Color4[];
  145357. sideOrientation?: number;
  145358. frontUVs?: Vector4;
  145359. backUVs?: Vector4;
  145360. wrap?: boolean;
  145361. topBaseAt?: number;
  145362. bottomBaseAt?: number;
  145363. updatable?: boolean;
  145364. }, scene?: Nullable<Scene>): Mesh;
  145365. /**
  145366. * Creates a tiled box mesh
  145367. * * faceTiles sets the pattern, tile size and number of tiles for a face
  145368. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  145369. * @param name defines the name of the mesh
  145370. * @param options defines the options used to create the mesh
  145371. * @param scene defines the hosting scene
  145372. * @returns the tiled box mesh
  145373. */
  145374. static CreateTiledBox(name: string, options: {
  145375. pattern?: number;
  145376. size?: number;
  145377. width?: number;
  145378. height?: number;
  145379. depth: number;
  145380. tileSize?: number;
  145381. tileWidth?: number;
  145382. tileHeight?: number;
  145383. faceUV?: Vector4[];
  145384. faceColors?: Color4[];
  145385. alignHorizontal?: number;
  145386. alignVertical?: number;
  145387. sideOrientation?: number;
  145388. updatable?: boolean;
  145389. }, scene?: Nullable<Scene>): Mesh;
  145390. /**
  145391. * Creates a sphere mesh
  145392. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  145393. * * 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`)
  145394. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  145395. * * 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
  145396. * * 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)
  145397. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  145398. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  145399. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  145400. * @param name defines the name of the mesh
  145401. * @param options defines the options used to create the mesh
  145402. * @param scene defines the hosting scene
  145403. * @returns the sphere mesh
  145404. * @see https://doc.babylonjs.com/how_to/set_shapes#sphere
  145405. */
  145406. static CreateSphere(name: string, options: {
  145407. segments?: number;
  145408. diameter?: number;
  145409. diameterX?: number;
  145410. diameterY?: number;
  145411. diameterZ?: number;
  145412. arc?: number;
  145413. slice?: number;
  145414. sideOrientation?: number;
  145415. frontUVs?: Vector4;
  145416. backUVs?: Vector4;
  145417. updatable?: boolean;
  145418. }, scene?: Nullable<Scene>): Mesh;
  145419. /**
  145420. * Creates a plane polygonal mesh. By default, this is a disc
  145421. * * The parameter `radius` sets the radius size (float) of the polygon (default 0.5)
  145422. * * 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
  145423. * * 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
  145424. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  145425. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  145426. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  145427. * @param name defines the name of the mesh
  145428. * @param options defines the options used to create the mesh
  145429. * @param scene defines the hosting scene
  145430. * @returns the plane polygonal mesh
  145431. * @see https://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  145432. */
  145433. static CreateDisc(name: string, options: {
  145434. radius?: number;
  145435. tessellation?: number;
  145436. arc?: number;
  145437. updatable?: boolean;
  145438. sideOrientation?: number;
  145439. frontUVs?: Vector4;
  145440. backUVs?: Vector4;
  145441. }, scene?: Nullable<Scene>): Mesh;
  145442. /**
  145443. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  145444. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  145445. * * 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`)
  145446. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  145447. * * 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
  145448. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  145449. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  145450. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  145451. * @param name defines the name of the mesh
  145452. * @param options defines the options used to create the mesh
  145453. * @param scene defines the hosting scene
  145454. * @returns the icosahedron mesh
  145455. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  145456. */
  145457. static CreateIcoSphere(name: string, options: {
  145458. radius?: number;
  145459. radiusX?: number;
  145460. radiusY?: number;
  145461. radiusZ?: number;
  145462. flat?: boolean;
  145463. subdivisions?: number;
  145464. sideOrientation?: number;
  145465. frontUVs?: Vector4;
  145466. backUVs?: Vector4;
  145467. updatable?: boolean;
  145468. }, scene?: Nullable<Scene>): Mesh;
  145469. /**
  145470. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  145471. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  145472. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  145473. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  145474. * * 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
  145475. * * 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
  145476. * * 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
  145477. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  145478. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  145479. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  145480. * * 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
  145481. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  145482. * * 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
  145483. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  145484. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  145485. * @param name defines the name of the mesh
  145486. * @param options defines the options used to create the mesh
  145487. * @param scene defines the hosting scene
  145488. * @returns the ribbon mesh
  145489. * @see https://doc.babylonjs.com/how_to/ribbon_tutorial
  145490. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  145491. */
  145492. static CreateRibbon(name: string, options: {
  145493. pathArray: Vector3[][];
  145494. closeArray?: boolean;
  145495. closePath?: boolean;
  145496. offset?: number;
  145497. updatable?: boolean;
  145498. sideOrientation?: number;
  145499. frontUVs?: Vector4;
  145500. backUVs?: Vector4;
  145501. instance?: Mesh;
  145502. invertUV?: boolean;
  145503. uvs?: Vector2[];
  145504. colors?: Color4[];
  145505. }, scene?: Nullable<Scene>): Mesh;
  145506. /**
  145507. * Creates a cylinder or a cone mesh
  145508. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  145509. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  145510. * * 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.
  145511. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  145512. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  145513. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  145514. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  145515. * * 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).
  145516. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  145517. * * 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).
  145518. * * 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
  145519. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  145520. * * 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
  145521. * * 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.
  145522. * * If `enclose` is false, a ring surface is one element.
  145523. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  145524. * * 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
  145525. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  145526. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  145527. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  145528. * @param name defines the name of the mesh
  145529. * @param options defines the options used to create the mesh
  145530. * @param scene defines the hosting scene
  145531. * @returns the cylinder mesh
  145532. * @see https://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  145533. */
  145534. static CreateCylinder(name: string, options: {
  145535. height?: number;
  145536. diameterTop?: number;
  145537. diameterBottom?: number;
  145538. diameter?: number;
  145539. tessellation?: number;
  145540. subdivisions?: number;
  145541. arc?: number;
  145542. faceColors?: Color4[];
  145543. faceUV?: Vector4[];
  145544. updatable?: boolean;
  145545. hasRings?: boolean;
  145546. enclose?: boolean;
  145547. cap?: number;
  145548. sideOrientation?: number;
  145549. frontUVs?: Vector4;
  145550. backUVs?: Vector4;
  145551. }, scene?: Nullable<Scene>): Mesh;
  145552. /**
  145553. * Creates a torus mesh
  145554. * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
  145555. * * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5)
  145556. * * The parameter `tessellation` sets the number of torus sides (postive integer, default 16)
  145557. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  145558. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  145559. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  145560. * @param name defines the name of the mesh
  145561. * @param options defines the options used to create the mesh
  145562. * @param scene defines the hosting scene
  145563. * @returns the torus mesh
  145564. * @see https://doc.babylonjs.com/how_to/set_shapes#torus
  145565. */
  145566. static CreateTorus(name: string, options: {
  145567. diameter?: number;
  145568. thickness?: number;
  145569. tessellation?: number;
  145570. updatable?: boolean;
  145571. sideOrientation?: number;
  145572. frontUVs?: Vector4;
  145573. backUVs?: Vector4;
  145574. }, scene?: Nullable<Scene>): Mesh;
  145575. /**
  145576. * Creates a torus knot mesh
  145577. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  145578. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  145579. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  145580. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  145581. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  145582. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  145583. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  145584. * @param name defines the name of the mesh
  145585. * @param options defines the options used to create the mesh
  145586. * @param scene defines the hosting scene
  145587. * @returns the torus knot mesh
  145588. * @see https://doc.babylonjs.com/how_to/set_shapes#torus-knot
  145589. */
  145590. static CreateTorusKnot(name: string, options: {
  145591. radius?: number;
  145592. tube?: number;
  145593. radialSegments?: number;
  145594. tubularSegments?: number;
  145595. p?: number;
  145596. q?: number;
  145597. updatable?: boolean;
  145598. sideOrientation?: number;
  145599. frontUVs?: Vector4;
  145600. backUVs?: Vector4;
  145601. }, scene?: Nullable<Scene>): Mesh;
  145602. /**
  145603. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  145604. * * 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
  145605. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  145606. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  145607. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  145608. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  145609. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  145610. * * 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
  145611. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  145612. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  145613. * @see https://doc.babylonjs.com/how_to/parametric_shapes#line-system
  145614. * @param name defines the name of the new line system
  145615. * @param options defines the options used to create the line system
  145616. * @param scene defines the hosting scene
  145617. * @returns a new line system mesh
  145618. */
  145619. static CreateLineSystem(name: string, options: {
  145620. lines: Vector3[][];
  145621. updatable?: boolean;
  145622. instance?: Nullable<LinesMesh>;
  145623. colors?: Nullable<Color4[][]>;
  145624. useVertexAlpha?: boolean;
  145625. }, scene: Nullable<Scene>): LinesMesh;
  145626. /**
  145627. * Creates a line mesh
  145628. * 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
  145629. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  145630. * * The parameter `points` is an array successive Vector3
  145631. * * 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
  145632. * * The optional parameter `colors` is an array of successive Color4, one per line point
  145633. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  145634. * * When updating an instance, remember that only point positions can change, not the number of points
  145635. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  145636. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lines
  145637. * @param name defines the name of the new line system
  145638. * @param options defines the options used to create the line system
  145639. * @param scene defines the hosting scene
  145640. * @returns a new line mesh
  145641. */
  145642. static CreateLines(name: string, options: {
  145643. points: Vector3[];
  145644. updatable?: boolean;
  145645. instance?: Nullable<LinesMesh>;
  145646. colors?: Color4[];
  145647. useVertexAlpha?: boolean;
  145648. }, scene?: Nullable<Scene>): LinesMesh;
  145649. /**
  145650. * Creates a dashed line mesh
  145651. * * 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
  145652. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  145653. * * The parameter `points` is an array successive Vector3
  145654. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  145655. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  145656. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  145657. * * 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
  145658. * * When updating an instance, remember that only point positions can change, not the number of points
  145659. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  145660. * @param name defines the name of the mesh
  145661. * @param options defines the options used to create the mesh
  145662. * @param scene defines the hosting scene
  145663. * @returns the dashed line mesh
  145664. * @see https://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  145665. */
  145666. static CreateDashedLines(name: string, options: {
  145667. points: Vector3[];
  145668. dashSize?: number;
  145669. gapSize?: number;
  145670. dashNb?: number;
  145671. updatable?: boolean;
  145672. instance?: LinesMesh;
  145673. }, scene?: Nullable<Scene>): LinesMesh;
  145674. /**
  145675. * 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.
  145676. * * 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.
  145677. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  145678. * * 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.
  145679. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  145680. * * 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
  145681. * * 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
  145682. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  145683. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  145684. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  145685. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  145686. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  145687. * @param name defines the name of the mesh
  145688. * @param options defines the options used to create the mesh
  145689. * @param scene defines the hosting scene
  145690. * @returns the extruded shape mesh
  145691. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  145692. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  145693. */
  145694. static ExtrudeShape(name: string, options: {
  145695. shape: Vector3[];
  145696. path: Vector3[];
  145697. scale?: number;
  145698. rotation?: number;
  145699. cap?: number;
  145700. updatable?: boolean;
  145701. sideOrientation?: number;
  145702. frontUVs?: Vector4;
  145703. backUVs?: Vector4;
  145704. instance?: Mesh;
  145705. invertUV?: boolean;
  145706. }, scene?: Nullable<Scene>): Mesh;
  145707. /**
  145708. * Creates an custom extruded shape mesh.
  145709. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  145710. * * 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.
  145711. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  145712. * * 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
  145713. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  145714. * * 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
  145715. * * It must returns a float value that will be the scale value applied to the shape on each path point
  145716. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  145717. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  145718. * * 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
  145719. * * 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
  145720. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  145721. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  145722. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  145723. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  145724. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  145725. * @param name defines the name of the mesh
  145726. * @param options defines the options used to create the mesh
  145727. * @param scene defines the hosting scene
  145728. * @returns the custom extruded shape mesh
  145729. * @see https://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  145730. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  145731. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  145732. */
  145733. static ExtrudeShapeCustom(name: string, options: {
  145734. shape: Vector3[];
  145735. path: Vector3[];
  145736. scaleFunction?: any;
  145737. rotationFunction?: any;
  145738. ribbonCloseArray?: boolean;
  145739. ribbonClosePath?: boolean;
  145740. cap?: number;
  145741. updatable?: boolean;
  145742. sideOrientation?: number;
  145743. frontUVs?: Vector4;
  145744. backUVs?: Vector4;
  145745. instance?: Mesh;
  145746. invertUV?: boolean;
  145747. }, scene?: Nullable<Scene>): Mesh;
  145748. /**
  145749. * Creates lathe mesh.
  145750. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe
  145751. * * 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
  145752. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  145753. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  145754. * * The parameter `clip` (positive integer, default 0) is the number of sides to not create without effecting the general shape of the sides
  145755. * * 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
  145756. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  145757. * * 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
  145758. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  145759. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  145760. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  145761. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  145762. * @param name defines the name of the mesh
  145763. * @param options defines the options used to create the mesh
  145764. * @param scene defines the hosting scene
  145765. * @returns the lathe mesh
  145766. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lathe
  145767. */
  145768. static CreateLathe(name: string, options: {
  145769. shape: Vector3[];
  145770. radius?: number;
  145771. tessellation?: number;
  145772. clip?: number;
  145773. arc?: number;
  145774. closed?: boolean;
  145775. updatable?: boolean;
  145776. sideOrientation?: number;
  145777. frontUVs?: Vector4;
  145778. backUVs?: Vector4;
  145779. cap?: number;
  145780. invertUV?: boolean;
  145781. }, scene?: Nullable<Scene>): Mesh;
  145782. /**
  145783. * Creates a tiled plane mesh
  145784. * * You can set a limited pattern arrangement with the tiles
  145785. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  145786. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  145787. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  145788. * @param name defines the name of the mesh
  145789. * @param options defines the options used to create the mesh
  145790. * @param scene defines the hosting scene
  145791. * @returns the plane mesh
  145792. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  145793. */
  145794. static CreateTiledPlane(name: string, options: {
  145795. pattern?: number;
  145796. tileSize?: number;
  145797. tileWidth?: number;
  145798. tileHeight?: number;
  145799. size?: number;
  145800. width?: number;
  145801. height?: number;
  145802. alignHorizontal?: number;
  145803. alignVertical?: number;
  145804. sideOrientation?: number;
  145805. frontUVs?: Vector4;
  145806. backUVs?: Vector4;
  145807. updatable?: boolean;
  145808. }, scene?: Nullable<Scene>): Mesh;
  145809. /**
  145810. * Creates a plane mesh
  145811. * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
  145812. * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value of `size`)
  145813. * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane
  145814. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  145815. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  145816. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  145817. * @param name defines the name of the mesh
  145818. * @param options defines the options used to create the mesh
  145819. * @param scene defines the hosting scene
  145820. * @returns the plane mesh
  145821. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  145822. */
  145823. static CreatePlane(name: string, options: {
  145824. size?: number;
  145825. width?: number;
  145826. height?: number;
  145827. sideOrientation?: number;
  145828. frontUVs?: Vector4;
  145829. backUVs?: Vector4;
  145830. updatable?: boolean;
  145831. sourcePlane?: Plane;
  145832. }, scene?: Nullable<Scene>): Mesh;
  145833. /**
  145834. * Creates a ground mesh
  145835. * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
  145836. * * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side
  145837. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  145838. * @param name defines the name of the mesh
  145839. * @param options defines the options used to create the mesh
  145840. * @param scene defines the hosting scene
  145841. * @returns the ground mesh
  145842. * @see https://doc.babylonjs.com/how_to/set_shapes#ground
  145843. */
  145844. static CreateGround(name: string, options: {
  145845. width?: number;
  145846. height?: number;
  145847. subdivisions?: number;
  145848. subdivisionsX?: number;
  145849. subdivisionsY?: number;
  145850. updatable?: boolean;
  145851. }, scene?: Nullable<Scene>): Mesh;
  145852. /**
  145853. * Creates a tiled ground mesh
  145854. * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
  145855. * * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates
  145856. * * 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
  145857. * * 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
  145858. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  145859. * @param name defines the name of the mesh
  145860. * @param options defines the options used to create the mesh
  145861. * @param scene defines the hosting scene
  145862. * @returns the tiled ground mesh
  145863. * @see https://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  145864. */
  145865. static CreateTiledGround(name: string, options: {
  145866. xmin: number;
  145867. zmin: number;
  145868. xmax: number;
  145869. zmax: number;
  145870. subdivisions?: {
  145871. w: number;
  145872. h: number;
  145873. };
  145874. precision?: {
  145875. w: number;
  145876. h: number;
  145877. };
  145878. updatable?: boolean;
  145879. }, scene?: Nullable<Scene>): Mesh;
  145880. /**
  145881. * Creates a ground mesh from a height map
  145882. * * The parameter `url` sets the URL of the height map image resource.
  145883. * * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  145884. * * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  145885. * * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  145886. * * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  145887. * * 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.
  145888. * * 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).
  145889. * * The parameter `alphaFilter` will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  145890. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  145891. * @param name defines the name of the mesh
  145892. * @param url defines the url to the height map
  145893. * @param options defines the options used to create the mesh
  145894. * @param scene defines the hosting scene
  145895. * @returns the ground mesh
  145896. * @see https://doc.babylonjs.com/babylon101/height_map
  145897. * @see https://doc.babylonjs.com/how_to/set_shapes#ground-from-a-height-map
  145898. */
  145899. static CreateGroundFromHeightMap(name: string, url: string, options: {
  145900. width?: number;
  145901. height?: number;
  145902. subdivisions?: number;
  145903. minHeight?: number;
  145904. maxHeight?: number;
  145905. colorFilter?: Color3;
  145906. alphaFilter?: number;
  145907. updatable?: boolean;
  145908. onReady?: (mesh: GroundMesh) => void;
  145909. }, scene?: Nullable<Scene>): GroundMesh;
  145910. /**
  145911. * Creates a polygon mesh
  145912. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  145913. * * 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
  145914. * * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  145915. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  145916. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4)
  145917. * * Remember you can only change the shape positions, not their number when updating a polygon
  145918. * @param name defines the name of the mesh
  145919. * @param options defines the options used to create the mesh
  145920. * @param scene defines the hosting scene
  145921. * @param earcutInjection can be used to inject your own earcut reference
  145922. * @returns the polygon mesh
  145923. */
  145924. static CreatePolygon(name: string, options: {
  145925. shape: Vector3[];
  145926. holes?: Vector3[][];
  145927. depth?: number;
  145928. faceUV?: Vector4[];
  145929. faceColors?: Color4[];
  145930. updatable?: boolean;
  145931. sideOrientation?: number;
  145932. frontUVs?: Vector4;
  145933. backUVs?: Vector4;
  145934. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  145935. /**
  145936. * Creates an extruded polygon mesh, with depth in the Y direction.
  145937. * * 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)
  145938. * @see https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  145939. * @param name defines the name of the mesh
  145940. * @param options defines the options used to create the mesh
  145941. * @param scene defines the hosting scene
  145942. * @param earcutInjection can be used to inject your own earcut reference
  145943. * @returns the polygon mesh
  145944. */
  145945. static ExtrudePolygon(name: string, options: {
  145946. shape: Vector3[];
  145947. holes?: Vector3[][];
  145948. depth?: number;
  145949. faceUV?: Vector4[];
  145950. faceColors?: Color4[];
  145951. updatable?: boolean;
  145952. sideOrientation?: number;
  145953. frontUVs?: Vector4;
  145954. backUVs?: Vector4;
  145955. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  145956. /**
  145957. * Creates a tube mesh.
  145958. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  145959. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  145960. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  145961. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  145962. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`
  145963. * * 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)
  145964. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  145965. * * 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
  145966. * * 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
  145967. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  145968. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  145969. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  145970. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  145971. * @param name defines the name of the mesh
  145972. * @param options defines the options used to create the mesh
  145973. * @param scene defines the hosting scene
  145974. * @returns the tube mesh
  145975. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  145976. * @see https://doc.babylonjs.com/how_to/set_shapes#tube
  145977. */
  145978. static CreateTube(name: string, options: {
  145979. path: Vector3[];
  145980. radius?: number;
  145981. tessellation?: number;
  145982. radiusFunction?: {
  145983. (i: number, distance: number): number;
  145984. };
  145985. cap?: number;
  145986. arc?: number;
  145987. updatable?: boolean;
  145988. sideOrientation?: number;
  145989. frontUVs?: Vector4;
  145990. backUVs?: Vector4;
  145991. instance?: Mesh;
  145992. invertUV?: boolean;
  145993. }, scene?: Nullable<Scene>): Mesh;
  145994. /**
  145995. * Creates a polyhedron mesh
  145996. * * 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
  145997. * * The parameter `size` (positive float, default 1) sets the polygon size
  145998. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  145999. * * 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`
  146000. * * 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
  146001. * * 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)`)
  146002. * * 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
  146003. * * 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
  146004. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  146005. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  146006. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  146007. * @param name defines the name of the mesh
  146008. * @param options defines the options used to create the mesh
  146009. * @param scene defines the hosting scene
  146010. * @returns the polyhedron mesh
  146011. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes
  146012. */
  146013. static CreatePolyhedron(name: string, options: {
  146014. type?: number;
  146015. size?: number;
  146016. sizeX?: number;
  146017. sizeY?: number;
  146018. sizeZ?: number;
  146019. custom?: any;
  146020. faceUV?: Vector4[];
  146021. faceColors?: Color4[];
  146022. flat?: boolean;
  146023. updatable?: boolean;
  146024. sideOrientation?: number;
  146025. frontUVs?: Vector4;
  146026. backUVs?: Vector4;
  146027. }, scene?: Nullable<Scene>): Mesh;
  146028. /**
  146029. * Creates a decal mesh.
  146030. * 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
  146031. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  146032. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  146033. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  146034. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  146035. * @param name defines the name of the mesh
  146036. * @param sourceMesh defines the mesh where the decal must be applied
  146037. * @param options defines the options used to create the mesh
  146038. * @param scene defines the hosting scene
  146039. * @returns the decal mesh
  146040. * @see https://doc.babylonjs.com/how_to/decals
  146041. */
  146042. static CreateDecal(name: string, sourceMesh: AbstractMesh, options: {
  146043. position?: Vector3;
  146044. normal?: Vector3;
  146045. size?: Vector3;
  146046. angle?: number;
  146047. }): Mesh;
  146048. }
  146049. }
  146050. declare module BABYLON {
  146051. /**
  146052. * A simplifier interface for future simplification implementations
  146053. * @see https://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  146054. */
  146055. export interface ISimplifier {
  146056. /**
  146057. * Simplification of a given mesh according to the given settings.
  146058. * Since this requires computation, it is assumed that the function runs async.
  146059. * @param settings The settings of the simplification, including quality and distance
  146060. * @param successCallback A callback that will be called after the mesh was simplified.
  146061. * @param errorCallback in case of an error, this callback will be called. optional.
  146062. */
  146063. simplify(settings: ISimplificationSettings, successCallback: (simplifiedMeshes: Mesh) => void, errorCallback?: () => void): void;
  146064. }
  146065. /**
  146066. * Expected simplification settings.
  146067. * Quality should be between 0 and 1 (1 being 100%, 0 being 0%)
  146068. * @see https://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  146069. */
  146070. export interface ISimplificationSettings {
  146071. /**
  146072. * Gets or sets the expected quality
  146073. */
  146074. quality: number;
  146075. /**
  146076. * Gets or sets the distance when this optimized version should be used
  146077. */
  146078. distance: number;
  146079. /**
  146080. * Gets an already optimized mesh
  146081. */
  146082. optimizeMesh?: boolean;
  146083. }
  146084. /**
  146085. * Class used to specify simplification options
  146086. * @see https://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  146087. */
  146088. export class SimplificationSettings implements ISimplificationSettings {
  146089. /** expected quality */
  146090. quality: number;
  146091. /** distance when this optimized version should be used */
  146092. distance: number;
  146093. /** already optimized mesh */
  146094. optimizeMesh?: boolean | undefined;
  146095. /**
  146096. * Creates a SimplificationSettings
  146097. * @param quality expected quality
  146098. * @param distance distance when this optimized version should be used
  146099. * @param optimizeMesh already optimized mesh
  146100. */
  146101. constructor(
  146102. /** expected quality */
  146103. quality: number,
  146104. /** distance when this optimized version should be used */
  146105. distance: number,
  146106. /** already optimized mesh */
  146107. optimizeMesh?: boolean | undefined);
  146108. }
  146109. /**
  146110. * Interface used to define a simplification task
  146111. */
  146112. export interface ISimplificationTask {
  146113. /**
  146114. * Array of settings
  146115. */
  146116. settings: Array<ISimplificationSettings>;
  146117. /**
  146118. * Simplification type
  146119. */
  146120. simplificationType: SimplificationType;
  146121. /**
  146122. * Mesh to simplify
  146123. */
  146124. mesh: Mesh;
  146125. /**
  146126. * Callback called on success
  146127. */
  146128. successCallback?: () => void;
  146129. /**
  146130. * Defines if parallel processing can be used
  146131. */
  146132. parallelProcessing: boolean;
  146133. }
  146134. /**
  146135. * Queue used to order the simplification tasks
  146136. * @see https://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  146137. */
  146138. export class SimplificationQueue {
  146139. private _simplificationArray;
  146140. /**
  146141. * Gets a boolean indicating that the process is still running
  146142. */
  146143. running: boolean;
  146144. /**
  146145. * Creates a new queue
  146146. */
  146147. constructor();
  146148. /**
  146149. * Adds a new simplification task
  146150. * @param task defines a task to add
  146151. */
  146152. addTask(task: ISimplificationTask): void;
  146153. /**
  146154. * Execute next task
  146155. */
  146156. executeNext(): void;
  146157. /**
  146158. * Execute a simplification task
  146159. * @param task defines the task to run
  146160. */
  146161. runSimplification(task: ISimplificationTask): void;
  146162. private getSimplifier;
  146163. }
  146164. /**
  146165. * The implemented types of simplification
  146166. * At the moment only Quadratic Error Decimation is implemented
  146167. * @see https://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  146168. */
  146169. export enum SimplificationType {
  146170. /** Quadratic error decimation */
  146171. QUADRATIC = 0
  146172. }
  146173. /**
  146174. * An implementation of the Quadratic Error simplification algorithm.
  146175. * Original paper : http://www1.cs.columbia.edu/~cs4162/html05s/garland97.pdf
  146176. * Ported mostly from QSlim and http://voxels.blogspot.de/2014/05/quadric-mesh-simplification-with-source.html to babylon JS
  146177. * @author RaananW
  146178. * @see https://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  146179. */
  146180. export class QuadraticErrorSimplification implements ISimplifier {
  146181. private _mesh;
  146182. private triangles;
  146183. private vertices;
  146184. private references;
  146185. private _reconstructedMesh;
  146186. /** Gets or sets the number pf sync interations */
  146187. syncIterations: number;
  146188. /** Gets or sets the aggressiveness of the simplifier */
  146189. aggressiveness: number;
  146190. /** Gets or sets the number of allowed iterations for decimation */
  146191. decimationIterations: number;
  146192. /** Gets or sets the espilon to use for bounding box computation */
  146193. boundingBoxEpsilon: number;
  146194. /**
  146195. * Creates a new QuadraticErrorSimplification
  146196. * @param _mesh defines the target mesh
  146197. */
  146198. constructor(_mesh: Mesh);
  146199. /**
  146200. * Simplification of a given mesh according to the given settings.
  146201. * Since this requires computation, it is assumed that the function runs async.
  146202. * @param settings The settings of the simplification, including quality and distance
  146203. * @param successCallback A callback that will be called after the mesh was simplified.
  146204. */
  146205. simplify(settings: ISimplificationSettings, successCallback: (simplifiedMesh: Mesh) => void): void;
  146206. private runDecimation;
  146207. private initWithMesh;
  146208. private init;
  146209. private reconstructMesh;
  146210. private initDecimatedMesh;
  146211. private isFlipped;
  146212. private updateTriangles;
  146213. private identifyBorder;
  146214. private updateMesh;
  146215. private vertexError;
  146216. private calculateError;
  146217. }
  146218. }
  146219. declare module BABYLON {
  146220. interface Scene {
  146221. /** @hidden (Backing field) */
  146222. _simplificationQueue: SimplificationQueue;
  146223. /**
  146224. * Gets or sets the simplification queue attached to the scene
  146225. * @see https://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  146226. */
  146227. simplificationQueue: SimplificationQueue;
  146228. }
  146229. interface Mesh {
  146230. /**
  146231. * Simplify the mesh according to the given array of settings.
  146232. * Function will return immediately and will simplify async
  146233. * @param settings a collection of simplification settings
  146234. * @param parallelProcessing should all levels calculate parallel or one after the other
  146235. * @param simplificationType the type of simplification to run
  146236. * @param successCallback optional success callback to be called after the simplification finished processing all settings
  146237. * @returns the current mesh
  146238. */
  146239. simplify(settings: Array<ISimplificationSettings>, parallelProcessing?: boolean, simplificationType?: SimplificationType, successCallback?: (mesh?: Mesh, submeshIndex?: number) => void): Mesh;
  146240. }
  146241. /**
  146242. * Defines the simplification queue scene component responsible to help scheduling the various simplification task
  146243. * created in a scene
  146244. */
  146245. export class SimplicationQueueSceneComponent implements ISceneComponent {
  146246. /**
  146247. * The component name helpfull to identify the component in the list of scene components.
  146248. */
  146249. readonly name: string;
  146250. /**
  146251. * The scene the component belongs to.
  146252. */
  146253. scene: Scene;
  146254. /**
  146255. * Creates a new instance of the component for the given scene
  146256. * @param scene Defines the scene to register the component in
  146257. */
  146258. constructor(scene: Scene);
  146259. /**
  146260. * Registers the component in a given scene
  146261. */
  146262. register(): void;
  146263. /**
  146264. * Rebuilds the elements related to this component in case of
  146265. * context lost for instance.
  146266. */
  146267. rebuild(): void;
  146268. /**
  146269. * Disposes the component and the associated ressources
  146270. */
  146271. dispose(): void;
  146272. private _beforeCameraUpdate;
  146273. }
  146274. }
  146275. declare module BABYLON {
  146276. interface Mesh {
  146277. /**
  146278. * Gets or sets a boolean defining if we want picking to pick thin instances as well
  146279. */
  146280. thinInstanceEnablePicking: boolean;
  146281. /**
  146282. * Creates a new thin instance
  146283. * @param matrix the matrix or array of matrices (position, rotation, scale) of the thin instance(s) to create
  146284. * @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
  146285. * @returns the thin instance index number. If you pass an array of matrices, other instance indexes are index+1, index+2, etc
  146286. */
  146287. thinInstanceAdd(matrix: DeepImmutableObject<Matrix> | Array<DeepImmutableObject<Matrix>>, refresh: boolean): number;
  146288. /**
  146289. * Adds the transformation (matrix) of the current mesh as a thin instance
  146290. * @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
  146291. * @returns the thin instance index number
  146292. */
  146293. thinInstanceAddSelf(refresh: boolean): number;
  146294. /**
  146295. * Registers a custom attribute to be used with thin instances
  146296. * @param kind name of the attribute
  146297. * @param stride size in floats of the attribute
  146298. */
  146299. thinInstanceRegisterAttribute(kind: string, stride: number): void;
  146300. /**
  146301. * Sets the matrix of a thin instance
  146302. * @param index index of the thin instance
  146303. * @param matrix matrix to set
  146304. * @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
  146305. */
  146306. thinInstanceSetMatrixAt(index: number, matrix: DeepImmutableObject<Matrix>, refresh: boolean): void;
  146307. /**
  146308. * Sets the value of a custom attribute for a thin instance
  146309. * @param kind name of the attribute
  146310. * @param index index of the thin instance
  146311. * @param value value to set
  146312. * @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
  146313. */
  146314. thinInstanceSetAttributeAt(kind: string, index: number, value: Array<number>, refresh: boolean): void;
  146315. /**
  146316. * 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.
  146317. */
  146318. thinInstanceCount: number;
  146319. /**
  146320. * Sets a buffer to be used with thin instances. This method is a faster way to setup multiple instances than calling thinInstanceAdd repeatedly
  146321. * @param kind name of the attribute. Use "matrix" to setup the buffer of matrices
  146322. * @param buffer buffer to set
  146323. * @param stride size in floats of each value of the buffer
  146324. * @param staticBuffer indicates that the buffer is static, so that you won't change it after it is set (better performances - false by default)
  146325. */
  146326. thinInstanceSetBuffer(kind: string, buffer: Nullable<Float32Array>, stride: number, staticBuffer: boolean): void;
  146327. /**
  146328. * Gets the list of world matrices
  146329. * @return an array containing all the world matrices from the thin instances
  146330. */
  146331. thinInstanceGetWorldMatrices(): Matrix[];
  146332. /**
  146333. * Synchronize the gpu buffers with a thin instance buffer. Call this method if you update later on the buffers passed to thinInstanceSetBuffer
  146334. * @param kind name of the attribute to update. Use "matrix" to update the buffer of matrices
  146335. */
  146336. thinInstanceBufferUpdated(kind: string): void;
  146337. /**
  146338. * Applies a partial update to a buffer directly on the GPU
  146339. * 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
  146340. * @param kind name of the attribute to update. Use "matrix" to update the buffer of matrices
  146341. * @param data the data to set in the GPU buffer
  146342. * @param offset the offset in the GPU buffer where to update the data
  146343. */
  146344. thinInstancePartialBufferUpdate(kind: string, data: Float32Array, offset: number): void;
  146345. /**
  146346. * Refreshes the bounding info, taking into account all the thin instances defined
  146347. * @param forceRefreshParentInfo true to force recomputing the mesh bounding info and use it to compute the aggregated bounding info
  146348. */
  146349. thinInstanceRefreshBoundingInfo(forceRefreshParentInfo: boolean): void;
  146350. /** @hidden */
  146351. _thinInstanceInitializeUserStorage(): void;
  146352. /** @hidden */
  146353. _thinInstanceUpdateBufferSize(kind: string, numInstances: number): void;
  146354. /** @hidden */
  146355. _userThinInstanceBuffersStorage: {
  146356. data: {
  146357. [key: string]: Float32Array;
  146358. };
  146359. sizes: {
  146360. [key: string]: number;
  146361. };
  146362. vertexBuffers: {
  146363. [key: string]: Nullable<VertexBuffer>;
  146364. };
  146365. strides: {
  146366. [key: string]: number;
  146367. };
  146368. };
  146369. }
  146370. }
  146371. declare module BABYLON {
  146372. /**
  146373. * Navigation plugin interface to add navigation constrained by a navigation mesh
  146374. */
  146375. export interface INavigationEnginePlugin {
  146376. /**
  146377. * plugin name
  146378. */
  146379. name: string;
  146380. /**
  146381. * Creates a navigation mesh
  146382. * @param meshes array of all the geometry used to compute the navigatio mesh
  146383. * @param parameters bunch of parameters used to filter geometry
  146384. */
  146385. createNavMesh(meshes: Array<Mesh>, parameters: INavMeshParameters): void;
  146386. /**
  146387. * Create a navigation mesh debug mesh
  146388. * @param scene is where the mesh will be added
  146389. * @returns debug display mesh
  146390. */
  146391. createDebugNavMesh(scene: Scene): Mesh;
  146392. /**
  146393. * Get a navigation mesh constrained position, closest to the parameter position
  146394. * @param position world position
  146395. * @returns the closest point to position constrained by the navigation mesh
  146396. */
  146397. getClosestPoint(position: Vector3): Vector3;
  146398. /**
  146399. * Get a navigation mesh constrained position, closest to the parameter position
  146400. * @param position world position
  146401. * @param result output the closest point to position constrained by the navigation mesh
  146402. */
  146403. getClosestPointToRef(position: Vector3, result: Vector3): void;
  146404. /**
  146405. * Get a navigation mesh constrained position, within a particular radius
  146406. * @param position world position
  146407. * @param maxRadius the maximum distance to the constrained world position
  146408. * @returns the closest point to position constrained by the navigation mesh
  146409. */
  146410. getRandomPointAround(position: Vector3, maxRadius: number): Vector3;
  146411. /**
  146412. * Get a navigation mesh constrained position, within a particular radius
  146413. * @param position world position
  146414. * @param maxRadius the maximum distance to the constrained world position
  146415. * @param result output the closest point to position constrained by the navigation mesh
  146416. */
  146417. getRandomPointAroundToRef(position: Vector3, maxRadius: number, result: Vector3): void;
  146418. /**
  146419. * Compute the final position from a segment made of destination-position
  146420. * @param position world position
  146421. * @param destination world position
  146422. * @returns the resulting point along the navmesh
  146423. */
  146424. moveAlong(position: Vector3, destination: Vector3): Vector3;
  146425. /**
  146426. * Compute the final position from a segment made of destination-position
  146427. * @param position world position
  146428. * @param destination world position
  146429. * @param result output the resulting point along the navmesh
  146430. */
  146431. moveAlongToRef(position: Vector3, destination: Vector3, result: Vector3): void;
  146432. /**
  146433. * Compute a navigation path from start to end. Returns an empty array if no path can be computed
  146434. * @param start world position
  146435. * @param end world position
  146436. * @returns array containing world position composing the path
  146437. */
  146438. computePath(start: Vector3, end: Vector3): Vector3[];
  146439. /**
  146440. * If this plugin is supported
  146441. * @returns true if plugin is supported
  146442. */
  146443. isSupported(): boolean;
  146444. /**
  146445. * Create a new Crowd so you can add agents
  146446. * @param maxAgents the maximum agent count in the crowd
  146447. * @param maxAgentRadius the maximum radius an agent can have
  146448. * @param scene to attach the crowd to
  146449. * @returns the crowd you can add agents to
  146450. */
  146451. createCrowd(maxAgents: number, maxAgentRadius: number, scene: Scene): ICrowd;
  146452. /**
  146453. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  146454. * The queries will try to find a solution within those bounds
  146455. * default is (1,1,1)
  146456. * @param extent x,y,z value that define the extent around the queries point of reference
  146457. */
  146458. setDefaultQueryExtent(extent: Vector3): void;
  146459. /**
  146460. * Get the Bounding box extent specified by setDefaultQueryExtent
  146461. * @returns the box extent values
  146462. */
  146463. getDefaultQueryExtent(): Vector3;
  146464. /**
  146465. * build the navmesh from a previously saved state using getNavmeshData
  146466. * @param data the Uint8Array returned by getNavmeshData
  146467. */
  146468. buildFromNavmeshData(data: Uint8Array): void;
  146469. /**
  146470. * returns the navmesh data that can be used later. The navmesh must be built before retrieving the data
  146471. * @returns data the Uint8Array that can be saved and reused
  146472. */
  146473. getNavmeshData(): Uint8Array;
  146474. /**
  146475. * Get the Bounding box extent result specified by setDefaultQueryExtent
  146476. * @param result output the box extent values
  146477. */
  146478. getDefaultQueryExtentToRef(result: Vector3): void;
  146479. /**
  146480. * Release all resources
  146481. */
  146482. dispose(): void;
  146483. }
  146484. /**
  146485. * Crowd Interface. A Crowd is a collection of moving agents constrained by a navigation mesh
  146486. */
  146487. export interface ICrowd {
  146488. /**
  146489. * Add a new agent to the crowd with the specified parameter a corresponding transformNode.
  146490. * You can attach anything to that node. The node position is updated in the scene update tick.
  146491. * @param pos world position that will be constrained by the navigation mesh
  146492. * @param parameters agent parameters
  146493. * @param transform hooked to the agent that will be update by the scene
  146494. * @returns agent index
  146495. */
  146496. addAgent(pos: Vector3, parameters: IAgentParameters, transform: TransformNode): number;
  146497. /**
  146498. * Returns the agent position in world space
  146499. * @param index agent index returned by addAgent
  146500. * @returns world space position
  146501. */
  146502. getAgentPosition(index: number): Vector3;
  146503. /**
  146504. * Gets the agent position result in world space
  146505. * @param index agent index returned by addAgent
  146506. * @param result output world space position
  146507. */
  146508. getAgentPositionToRef(index: number, result: Vector3): void;
  146509. /**
  146510. * Gets the agent velocity in world space
  146511. * @param index agent index returned by addAgent
  146512. * @returns world space velocity
  146513. */
  146514. getAgentVelocity(index: number): Vector3;
  146515. /**
  146516. * Gets the agent velocity result in world space
  146517. * @param index agent index returned by addAgent
  146518. * @param result output world space velocity
  146519. */
  146520. getAgentVelocityToRef(index: number, result: Vector3): void;
  146521. /**
  146522. * remove a particular agent previously created
  146523. * @param index agent index returned by addAgent
  146524. */
  146525. removeAgent(index: number): void;
  146526. /**
  146527. * get the list of all agents attached to this crowd
  146528. * @returns list of agent indices
  146529. */
  146530. getAgents(): number[];
  146531. /**
  146532. * Tick update done by the Scene. Agent position/velocity/acceleration is updated by this function
  146533. * @param deltaTime in seconds
  146534. */
  146535. update(deltaTime: number): void;
  146536. /**
  146537. * Asks a particular agent to go to a destination. That destination is constrained by the navigation mesh
  146538. * @param index agent index returned by addAgent
  146539. * @param destination targeted world position
  146540. */
  146541. agentGoto(index: number, destination: Vector3): void;
  146542. /**
  146543. * Teleport the agent to a new position
  146544. * @param index agent index returned by addAgent
  146545. * @param destination targeted world position
  146546. */
  146547. agentTeleport(index: number, destination: Vector3): void;
  146548. /**
  146549. * Update agent parameters
  146550. * @param index agent index returned by addAgent
  146551. * @param parameters agent parameters
  146552. */
  146553. updateAgentParameters(index: number, parameters: IAgentParameters): void;
  146554. /**
  146555. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  146556. * The queries will try to find a solution within those bounds
  146557. * default is (1,1,1)
  146558. * @param extent x,y,z value that define the extent around the queries point of reference
  146559. */
  146560. setDefaultQueryExtent(extent: Vector3): void;
  146561. /**
  146562. * Get the Bounding box extent specified by setDefaultQueryExtent
  146563. * @returns the box extent values
  146564. */
  146565. getDefaultQueryExtent(): Vector3;
  146566. /**
  146567. * Get the Bounding box extent result specified by setDefaultQueryExtent
  146568. * @param result output the box extent values
  146569. */
  146570. getDefaultQueryExtentToRef(result: Vector3): void;
  146571. /**
  146572. * Release all resources
  146573. */
  146574. dispose(): void;
  146575. }
  146576. /**
  146577. * Configures an agent
  146578. */
  146579. export interface IAgentParameters {
  146580. /**
  146581. * Agent radius. [Limit: >= 0]
  146582. */
  146583. radius: number;
  146584. /**
  146585. * Agent height. [Limit: > 0]
  146586. */
  146587. height: number;
  146588. /**
  146589. * Maximum allowed acceleration. [Limit: >= 0]
  146590. */
  146591. maxAcceleration: number;
  146592. /**
  146593. * Maximum allowed speed. [Limit: >= 0]
  146594. */
  146595. maxSpeed: number;
  146596. /**
  146597. * Defines how close a collision element must be before it is considered for steering behaviors. [Limits: > 0]
  146598. */
  146599. collisionQueryRange: number;
  146600. /**
  146601. * The path visibility optimization range. [Limit: > 0]
  146602. */
  146603. pathOptimizationRange: number;
  146604. /**
  146605. * How aggresive the agent manager should be at avoiding collisions with this agent. [Limit: >= 0]
  146606. */
  146607. separationWeight: number;
  146608. }
  146609. /**
  146610. * Configures the navigation mesh creation
  146611. */
  146612. export interface INavMeshParameters {
  146613. /**
  146614. * The xz-plane cell size to use for fields. [Limit: > 0] [Units: wu]
  146615. */
  146616. cs: number;
  146617. /**
  146618. * The y-axis cell size to use for fields. [Limit: > 0] [Units: wu]
  146619. */
  146620. ch: number;
  146621. /**
  146622. * The maximum slope that is considered walkable. [Limits: 0 <= value < 90] [Units: Degrees]
  146623. */
  146624. walkableSlopeAngle: number;
  146625. /**
  146626. * Minimum floor to 'ceiling' height that will still allow the floor area to
  146627. * be considered walkable. [Limit: >= 3] [Units: vx]
  146628. */
  146629. walkableHeight: number;
  146630. /**
  146631. * Maximum ledge height that is considered to still be traversable. [Limit: >=0] [Units: vx]
  146632. */
  146633. walkableClimb: number;
  146634. /**
  146635. * The distance to erode/shrink the walkable area of the heightfield away from
  146636. * obstructions. [Limit: >=0] [Units: vx]
  146637. */
  146638. walkableRadius: number;
  146639. /**
  146640. * The maximum allowed length for contour edges along the border of the mesh. [Limit: >=0] [Units: vx]
  146641. */
  146642. maxEdgeLen: number;
  146643. /**
  146644. * The maximum distance a simplfied contour's border edges should deviate
  146645. * the original raw contour. [Limit: >=0] [Units: vx]
  146646. */
  146647. maxSimplificationError: number;
  146648. /**
  146649. * The minimum number of cells allowed to form isolated island areas. [Limit: >=0] [Units: vx]
  146650. */
  146651. minRegionArea: number;
  146652. /**
  146653. * Any regions with a span count smaller than this value will, if possible,
  146654. * be merged with larger regions. [Limit: >=0] [Units: vx]
  146655. */
  146656. mergeRegionArea: number;
  146657. /**
  146658. * The maximum number of vertices allowed for polygons generated during the
  146659. * contour to polygon conversion process. [Limit: >= 3]
  146660. */
  146661. maxVertsPerPoly: number;
  146662. /**
  146663. * Sets the sampling distance to use when generating the detail mesh.
  146664. * (For height detail only.) [Limits: 0 or >= 0.9] [Units: wu]
  146665. */
  146666. detailSampleDist: number;
  146667. /**
  146668. * The maximum distance the detail mesh surface should deviate from heightfield
  146669. * data. (For height detail only.) [Limit: >=0] [Units: wu]
  146670. */
  146671. detailSampleMaxError: number;
  146672. }
  146673. }
  146674. declare module BABYLON {
  146675. /**
  146676. * RecastJS navigation plugin
  146677. */
  146678. export class RecastJSPlugin implements INavigationEnginePlugin {
  146679. /**
  146680. * Reference to the Recast library
  146681. */
  146682. bjsRECAST: any;
  146683. /**
  146684. * plugin name
  146685. */
  146686. name: string;
  146687. /**
  146688. * the first navmesh created. We might extend this to support multiple navmeshes
  146689. */
  146690. navMesh: any;
  146691. /**
  146692. * Initializes the recastJS plugin
  146693. * @param recastInjection can be used to inject your own recast reference
  146694. */
  146695. constructor(recastInjection?: any);
  146696. /**
  146697. * Creates a navigation mesh
  146698. * @param meshes array of all the geometry used to compute the navigatio mesh
  146699. * @param parameters bunch of parameters used to filter geometry
  146700. */
  146701. createNavMesh(meshes: Array<Mesh>, parameters: INavMeshParameters): void;
  146702. /**
  146703. * Create a navigation mesh debug mesh
  146704. * @param scene is where the mesh will be added
  146705. * @returns debug display mesh
  146706. */
  146707. createDebugNavMesh(scene: Scene): Mesh;
  146708. /**
  146709. * Get a navigation mesh constrained position, closest to the parameter position
  146710. * @param position world position
  146711. * @returns the closest point to position constrained by the navigation mesh
  146712. */
  146713. getClosestPoint(position: Vector3): Vector3;
  146714. /**
  146715. * Get a navigation mesh constrained position, closest to the parameter position
  146716. * @param position world position
  146717. * @param result output the closest point to position constrained by the navigation mesh
  146718. */
  146719. getClosestPointToRef(position: Vector3, result: Vector3): void;
  146720. /**
  146721. * Get a navigation mesh constrained position, within a particular radius
  146722. * @param position world position
  146723. * @param maxRadius the maximum distance to the constrained world position
  146724. * @returns the closest point to position constrained by the navigation mesh
  146725. */
  146726. getRandomPointAround(position: Vector3, maxRadius: number): Vector3;
  146727. /**
  146728. * Get a navigation mesh constrained position, within a particular radius
  146729. * @param position world position
  146730. * @param maxRadius the maximum distance to the constrained world position
  146731. * @param result output the closest point to position constrained by the navigation mesh
  146732. */
  146733. getRandomPointAroundToRef(position: Vector3, maxRadius: number, result: Vector3): void;
  146734. /**
  146735. * Compute the final position from a segment made of destination-position
  146736. * @param position world position
  146737. * @param destination world position
  146738. * @returns the resulting point along the navmesh
  146739. */
  146740. moveAlong(position: Vector3, destination: Vector3): Vector3;
  146741. /**
  146742. * Compute the final position from a segment made of destination-position
  146743. * @param position world position
  146744. * @param destination world position
  146745. * @param result output the resulting point along the navmesh
  146746. */
  146747. moveAlongToRef(position: Vector3, destination: Vector3, result: Vector3): void;
  146748. /**
  146749. * Compute a navigation path from start to end. Returns an empty array if no path can be computed
  146750. * @param start world position
  146751. * @param end world position
  146752. * @returns array containing world position composing the path
  146753. */
  146754. computePath(start: Vector3, end: Vector3): Vector3[];
  146755. /**
  146756. * Create a new Crowd so you can add agents
  146757. * @param maxAgents the maximum agent count in the crowd
  146758. * @param maxAgentRadius the maximum radius an agent can have
  146759. * @param scene to attach the crowd to
  146760. * @returns the crowd you can add agents to
  146761. */
  146762. createCrowd(maxAgents: number, maxAgentRadius: number, scene: Scene): ICrowd;
  146763. /**
  146764. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  146765. * The queries will try to find a solution within those bounds
  146766. * default is (1,1,1)
  146767. * @param extent x,y,z value that define the extent around the queries point of reference
  146768. */
  146769. setDefaultQueryExtent(extent: Vector3): void;
  146770. /**
  146771. * Get the Bounding box extent specified by setDefaultQueryExtent
  146772. * @returns the box extent values
  146773. */
  146774. getDefaultQueryExtent(): Vector3;
  146775. /**
  146776. * build the navmesh from a previously saved state using getNavmeshData
  146777. * @param data the Uint8Array returned by getNavmeshData
  146778. */
  146779. buildFromNavmeshData(data: Uint8Array): void;
  146780. /**
  146781. * returns the navmesh data that can be used later. The navmesh must be built before retrieving the data
  146782. * @returns data the Uint8Array that can be saved and reused
  146783. */
  146784. getNavmeshData(): Uint8Array;
  146785. /**
  146786. * Get the Bounding box extent result specified by setDefaultQueryExtent
  146787. * @param result output the box extent values
  146788. */
  146789. getDefaultQueryExtentToRef(result: Vector3): void;
  146790. /**
  146791. * Disposes
  146792. */
  146793. dispose(): void;
  146794. /**
  146795. * If this plugin is supported
  146796. * @returns true if plugin is supported
  146797. */
  146798. isSupported(): boolean;
  146799. }
  146800. /**
  146801. * Recast detour crowd implementation
  146802. */
  146803. export class RecastJSCrowd implements ICrowd {
  146804. /**
  146805. * Recast/detour plugin
  146806. */
  146807. bjsRECASTPlugin: RecastJSPlugin;
  146808. /**
  146809. * Link to the detour crowd
  146810. */
  146811. recastCrowd: any;
  146812. /**
  146813. * One transform per agent
  146814. */
  146815. transforms: TransformNode[];
  146816. /**
  146817. * All agents created
  146818. */
  146819. agents: number[];
  146820. /**
  146821. * Link to the scene is kept to unregister the crowd from the scene
  146822. */
  146823. private _scene;
  146824. /**
  146825. * Observer for crowd updates
  146826. */
  146827. private _onBeforeAnimationsObserver;
  146828. /**
  146829. * Constructor
  146830. * @param plugin recastJS plugin
  146831. * @param maxAgents the maximum agent count in the crowd
  146832. * @param maxAgentRadius the maximum radius an agent can have
  146833. * @param scene to attach the crowd to
  146834. * @returns the crowd you can add agents to
  146835. */
  146836. constructor(plugin: RecastJSPlugin, maxAgents: number, maxAgentRadius: number, scene: Scene);
  146837. /**
  146838. * Add a new agent to the crowd with the specified parameter a corresponding transformNode.
  146839. * You can attach anything to that node. The node position is updated in the scene update tick.
  146840. * @param pos world position that will be constrained by the navigation mesh
  146841. * @param parameters agent parameters
  146842. * @param transform hooked to the agent that will be update by the scene
  146843. * @returns agent index
  146844. */
  146845. addAgent(pos: Vector3, parameters: IAgentParameters, transform: TransformNode): number;
  146846. /**
  146847. * Returns the agent position in world space
  146848. * @param index agent index returned by addAgent
  146849. * @returns world space position
  146850. */
  146851. getAgentPosition(index: number): Vector3;
  146852. /**
  146853. * Returns the agent position result in world space
  146854. * @param index agent index returned by addAgent
  146855. * @param result output world space position
  146856. */
  146857. getAgentPositionToRef(index: number, result: Vector3): void;
  146858. /**
  146859. * Returns the agent velocity in world space
  146860. * @param index agent index returned by addAgent
  146861. * @returns world space velocity
  146862. */
  146863. getAgentVelocity(index: number): Vector3;
  146864. /**
  146865. * Returns the agent velocity result in world space
  146866. * @param index agent index returned by addAgent
  146867. * @param result output world space velocity
  146868. */
  146869. getAgentVelocityToRef(index: number, result: Vector3): void;
  146870. /**
  146871. * Asks a particular agent to go to a destination. That destination is constrained by the navigation mesh
  146872. * @param index agent index returned by addAgent
  146873. * @param destination targeted world position
  146874. */
  146875. agentGoto(index: number, destination: Vector3): void;
  146876. /**
  146877. * Teleport the agent to a new position
  146878. * @param index agent index returned by addAgent
  146879. * @param destination targeted world position
  146880. */
  146881. agentTeleport(index: number, destination: Vector3): void;
  146882. /**
  146883. * Update agent parameters
  146884. * @param index agent index returned by addAgent
  146885. * @param parameters agent parameters
  146886. */
  146887. updateAgentParameters(index: number, parameters: IAgentParameters): void;
  146888. /**
  146889. * remove a particular agent previously created
  146890. * @param index agent index returned by addAgent
  146891. */
  146892. removeAgent(index: number): void;
  146893. /**
  146894. * get the list of all agents attached to this crowd
  146895. * @returns list of agent indices
  146896. */
  146897. getAgents(): number[];
  146898. /**
  146899. * Tick update done by the Scene. Agent position/velocity/acceleration is updated by this function
  146900. * @param deltaTime in seconds
  146901. */
  146902. update(deltaTime: number): void;
  146903. /**
  146904. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  146905. * The queries will try to find a solution within those bounds
  146906. * default is (1,1,1)
  146907. * @param extent x,y,z value that define the extent around the queries point of reference
  146908. */
  146909. setDefaultQueryExtent(extent: Vector3): void;
  146910. /**
  146911. * Get the Bounding box extent specified by setDefaultQueryExtent
  146912. * @returns the box extent values
  146913. */
  146914. getDefaultQueryExtent(): Vector3;
  146915. /**
  146916. * Get the Bounding box extent result specified by setDefaultQueryExtent
  146917. * @param result output the box extent values
  146918. */
  146919. getDefaultQueryExtentToRef(result: Vector3): void;
  146920. /**
  146921. * Release all resources
  146922. */
  146923. dispose(): void;
  146924. }
  146925. }
  146926. declare module BABYLON {
  146927. /**
  146928. * Class used to enable access to IndexedDB
  146929. * @see https://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  146930. */
  146931. export class Database implements IOfflineProvider {
  146932. private _callbackManifestChecked;
  146933. private _currentSceneUrl;
  146934. private _db;
  146935. private _enableSceneOffline;
  146936. private _enableTexturesOffline;
  146937. private _manifestVersionFound;
  146938. private _mustUpdateRessources;
  146939. private _hasReachedQuota;
  146940. private _isSupported;
  146941. private _idbFactory;
  146942. /** Gets a boolean indicating if the user agent supports blob storage (this value will be updated after creating the first Database object) */
  146943. private static IsUASupportingBlobStorage;
  146944. /**
  146945. * Gets a boolean indicating if Database storate is enabled (off by default)
  146946. */
  146947. static IDBStorageEnabled: boolean;
  146948. /**
  146949. * Gets a boolean indicating if scene must be saved in the database
  146950. */
  146951. get enableSceneOffline(): boolean;
  146952. /**
  146953. * Gets a boolean indicating if textures must be saved in the database
  146954. */
  146955. get enableTexturesOffline(): boolean;
  146956. /**
  146957. * Creates a new Database
  146958. * @param urlToScene defines the url to load the scene
  146959. * @param callbackManifestChecked defines the callback to use when manifest is checked
  146960. * @param disableManifestCheck defines a boolean indicating that we want to skip the manifest validation (it will be considered validated and up to date)
  146961. */
  146962. constructor(urlToScene: string, callbackManifestChecked: (checked: boolean) => any, disableManifestCheck?: boolean);
  146963. private static _ParseURL;
  146964. private static _ReturnFullUrlLocation;
  146965. private _checkManifestFile;
  146966. /**
  146967. * Open the database and make it available
  146968. * @param successCallback defines the callback to call on success
  146969. * @param errorCallback defines the callback to call on error
  146970. */
  146971. open(successCallback: () => void, errorCallback: () => void): void;
  146972. /**
  146973. * Loads an image from the database
  146974. * @param url defines the url to load from
  146975. * @param image defines the target DOM image
  146976. */
  146977. loadImage(url: string, image: HTMLImageElement): void;
  146978. private _loadImageFromDBAsync;
  146979. private _saveImageIntoDBAsync;
  146980. private _checkVersionFromDB;
  146981. private _loadVersionFromDBAsync;
  146982. private _saveVersionIntoDBAsync;
  146983. /**
  146984. * Loads a file from database
  146985. * @param url defines the URL to load from
  146986. * @param sceneLoaded defines a callback to call on success
  146987. * @param progressCallBack defines a callback to call when progress changed
  146988. * @param errorCallback defines a callback to call on error
  146989. * @param useArrayBuffer defines a boolean to use array buffer instead of text string
  146990. */
  146991. loadFile(url: string, sceneLoaded: (data: any) => void, progressCallBack?: (data: any) => void, errorCallback?: () => void, useArrayBuffer?: boolean): void;
  146992. private _loadFileAsync;
  146993. private _saveFileAsync;
  146994. /**
  146995. * Validates if xhr data is correct
  146996. * @param xhr defines the request to validate
  146997. * @param dataType defines the expected data type
  146998. * @returns true if data is correct
  146999. */
  147000. private static _ValidateXHRData;
  147001. }
  147002. }
  147003. declare module BABYLON {
  147004. /** @hidden */
  147005. export var gpuUpdateParticlesPixelShader: {
  147006. name: string;
  147007. shader: string;
  147008. };
  147009. }
  147010. declare module BABYLON {
  147011. /** @hidden */
  147012. export var gpuUpdateParticlesVertexShader: {
  147013. name: string;
  147014. shader: string;
  147015. };
  147016. }
  147017. declare module BABYLON {
  147018. /** @hidden */
  147019. export var clipPlaneFragmentDeclaration2: {
  147020. name: string;
  147021. shader: string;
  147022. };
  147023. }
  147024. declare module BABYLON {
  147025. /** @hidden */
  147026. export var gpuRenderParticlesPixelShader: {
  147027. name: string;
  147028. shader: string;
  147029. };
  147030. }
  147031. declare module BABYLON {
  147032. /** @hidden */
  147033. export var clipPlaneVertexDeclaration2: {
  147034. name: string;
  147035. shader: string;
  147036. };
  147037. }
  147038. declare module BABYLON {
  147039. /** @hidden */
  147040. export var gpuRenderParticlesVertexShader: {
  147041. name: string;
  147042. shader: string;
  147043. };
  147044. }
  147045. declare module BABYLON {
  147046. /**
  147047. * This represents a GPU particle system in Babylon
  147048. * This is the fastest particle system in Babylon as it uses the GPU to update the individual particle data
  147049. * @see https://www.babylonjs-playground.com/#PU4WYI#4
  147050. */
  147051. export class GPUParticleSystem extends BaseParticleSystem implements IDisposable, IParticleSystem, IAnimatable {
  147052. /**
  147053. * The layer mask we are rendering the particles through.
  147054. */
  147055. layerMask: number;
  147056. private _capacity;
  147057. private _activeCount;
  147058. private _currentActiveCount;
  147059. private _accumulatedCount;
  147060. private _renderEffect;
  147061. private _updateEffect;
  147062. private _buffer0;
  147063. private _buffer1;
  147064. private _spriteBuffer;
  147065. private _updateVAO;
  147066. private _renderVAO;
  147067. private _targetIndex;
  147068. private _sourceBuffer;
  147069. private _targetBuffer;
  147070. private _currentRenderId;
  147071. private _started;
  147072. private _stopped;
  147073. private _timeDelta;
  147074. private _randomTexture;
  147075. private _randomTexture2;
  147076. private _attributesStrideSize;
  147077. private _updateEffectOptions;
  147078. private _randomTextureSize;
  147079. private _actualFrame;
  147080. private _customEffect;
  147081. private readonly _rawTextureWidth;
  147082. /**
  147083. * Gets a boolean indicating if the GPU particles can be rendered on current browser
  147084. */
  147085. static get IsSupported(): boolean;
  147086. /**
  147087. * An event triggered when the system is disposed.
  147088. */
  147089. onDisposeObservable: Observable<IParticleSystem>;
  147090. /**
  147091. * Gets the maximum number of particles active at the same time.
  147092. * @returns The max number of active particles.
  147093. */
  147094. getCapacity(): number;
  147095. /**
  147096. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  147097. * to override the particles.
  147098. */
  147099. forceDepthWrite: boolean;
  147100. /**
  147101. * Gets or set the number of active particles
  147102. */
  147103. get activeParticleCount(): number;
  147104. set activeParticleCount(value: number);
  147105. private _preWarmDone;
  147106. /**
  147107. * Specifies if the particles are updated in emitter local space or world space.
  147108. */
  147109. isLocal: boolean;
  147110. /** Gets or sets a matrix to use to compute projection */
  147111. defaultProjectionMatrix: Matrix;
  147112. /**
  147113. * Is this system ready to be used/rendered
  147114. * @return true if the system is ready
  147115. */
  147116. isReady(): boolean;
  147117. /**
  147118. * Gets if the system has been started. (Note: this will still be true after stop is called)
  147119. * @returns True if it has been started, otherwise false.
  147120. */
  147121. isStarted(): boolean;
  147122. /**
  147123. * Gets if the system has been stopped. (Note: rendering is still happening but the system is frozen)
  147124. * @returns True if it has been stopped, otherwise false.
  147125. */
  147126. isStopped(): boolean;
  147127. /**
  147128. * Gets a boolean indicating that the system is stopping
  147129. * @returns true if the system is currently stopping
  147130. */
  147131. isStopping(): boolean;
  147132. /**
  147133. * Gets the number of particles active at the same time.
  147134. * @returns The number of active particles.
  147135. */
  147136. getActiveCount(): number;
  147137. /**
  147138. * Starts the particle system and begins to emit
  147139. * @param delay defines the delay in milliseconds before starting the system (this.startDelay by default)
  147140. */
  147141. start(delay?: number): void;
  147142. /**
  147143. * Stops the particle system.
  147144. */
  147145. stop(): void;
  147146. /**
  147147. * Remove all active particles
  147148. */
  147149. reset(): void;
  147150. /**
  147151. * Returns the string "GPUParticleSystem"
  147152. * @returns a string containing the class name
  147153. */
  147154. getClassName(): string;
  147155. /**
  147156. * Gets the custom effect used to render the particles
  147157. * @param blendMode Blend mode for which the effect should be retrieved
  147158. * @returns The effect
  147159. */
  147160. getCustomEffect(blendMode?: number): Nullable<Effect>;
  147161. /**
  147162. * Sets the custom effect used to render the particles
  147163. * @param effect The effect to set
  147164. * @param blendMode Blend mode for which the effect should be set
  147165. */
  147166. setCustomEffect(effect: Nullable<Effect>, blendMode?: number): void;
  147167. /** @hidden */
  147168. protected _onBeforeDrawParticlesObservable: Nullable<Observable<Nullable<Effect>>>;
  147169. /**
  147170. * Observable that will be called just before the particles are drawn
  147171. */
  147172. get onBeforeDrawParticlesObservable(): Observable<Nullable<Effect>>;
  147173. /**
  147174. * Gets the name of the particle vertex shader
  147175. */
  147176. get vertexShaderName(): string;
  147177. private _colorGradientsTexture;
  147178. protected _removeGradientAndTexture(gradient: number, gradients: Nullable<IValueGradient[]>, texture: RawTexture): BaseParticleSystem;
  147179. /**
  147180. * Adds a new color gradient
  147181. * @param gradient defines the gradient to use (between 0 and 1)
  147182. * @param color1 defines the color to affect to the specified gradient
  147183. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  147184. * @returns the current particle system
  147185. */
  147186. addColorGradient(gradient: number, color1: Color4, color2?: Color4): GPUParticleSystem;
  147187. private _refreshColorGradient;
  147188. /** Force the system to rebuild all gradients that need to be resync */
  147189. forceRefreshGradients(): void;
  147190. /**
  147191. * Remove a specific color gradient
  147192. * @param gradient defines the gradient to remove
  147193. * @returns the current particle system
  147194. */
  147195. removeColorGradient(gradient: number): GPUParticleSystem;
  147196. private _angularSpeedGradientsTexture;
  147197. private _sizeGradientsTexture;
  147198. private _velocityGradientsTexture;
  147199. private _limitVelocityGradientsTexture;
  147200. private _dragGradientsTexture;
  147201. private _addFactorGradient;
  147202. /**
  147203. * Adds a new size gradient
  147204. * @param gradient defines the gradient to use (between 0 and 1)
  147205. * @param factor defines the size factor to affect to the specified gradient
  147206. * @returns the current particle system
  147207. */
  147208. addSizeGradient(gradient: number, factor: number): GPUParticleSystem;
  147209. /**
  147210. * Remove a specific size gradient
  147211. * @param gradient defines the gradient to remove
  147212. * @returns the current particle system
  147213. */
  147214. removeSizeGradient(gradient: number): GPUParticleSystem;
  147215. private _refreshFactorGradient;
  147216. /**
  147217. * Adds a new angular speed gradient
  147218. * @param gradient defines the gradient to use (between 0 and 1)
  147219. * @param factor defines the angular speed to affect to the specified gradient
  147220. * @returns the current particle system
  147221. */
  147222. addAngularSpeedGradient(gradient: number, factor: number): GPUParticleSystem;
  147223. /**
  147224. * Remove a specific angular speed gradient
  147225. * @param gradient defines the gradient to remove
  147226. * @returns the current particle system
  147227. */
  147228. removeAngularSpeedGradient(gradient: number): GPUParticleSystem;
  147229. /**
  147230. * Adds a new velocity gradient
  147231. * @param gradient defines the gradient to use (between 0 and 1)
  147232. * @param factor defines the velocity to affect to the specified gradient
  147233. * @returns the current particle system
  147234. */
  147235. addVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  147236. /**
  147237. * Remove a specific velocity gradient
  147238. * @param gradient defines the gradient to remove
  147239. * @returns the current particle system
  147240. */
  147241. removeVelocityGradient(gradient: number): GPUParticleSystem;
  147242. /**
  147243. * Adds a new limit velocity gradient
  147244. * @param gradient defines the gradient to use (between 0 and 1)
  147245. * @param factor defines the limit velocity value to affect to the specified gradient
  147246. * @returns the current particle system
  147247. */
  147248. addLimitVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  147249. /**
  147250. * Remove a specific limit velocity gradient
  147251. * @param gradient defines the gradient to remove
  147252. * @returns the current particle system
  147253. */
  147254. removeLimitVelocityGradient(gradient: number): GPUParticleSystem;
  147255. /**
  147256. * Adds a new drag gradient
  147257. * @param gradient defines the gradient to use (between 0 and 1)
  147258. * @param factor defines the drag value to affect to the specified gradient
  147259. * @returns the current particle system
  147260. */
  147261. addDragGradient(gradient: number, factor: number): GPUParticleSystem;
  147262. /**
  147263. * Remove a specific drag gradient
  147264. * @param gradient defines the gradient to remove
  147265. * @returns the current particle system
  147266. */
  147267. removeDragGradient(gradient: number): GPUParticleSystem;
  147268. /**
  147269. * Not supported by GPUParticleSystem
  147270. * @param gradient defines the gradient to use (between 0 and 1)
  147271. * @param factor defines the emit rate value to affect to the specified gradient
  147272. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  147273. * @returns the current particle system
  147274. */
  147275. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  147276. /**
  147277. * Not supported by GPUParticleSystem
  147278. * @param gradient defines the gradient to remove
  147279. * @returns the current particle system
  147280. */
  147281. removeEmitRateGradient(gradient: number): IParticleSystem;
  147282. /**
  147283. * Not supported by GPUParticleSystem
  147284. * @param gradient defines the gradient to use (between 0 and 1)
  147285. * @param factor defines the start size value to affect to the specified gradient
  147286. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  147287. * @returns the current particle system
  147288. */
  147289. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  147290. /**
  147291. * Not supported by GPUParticleSystem
  147292. * @param gradient defines the gradient to remove
  147293. * @returns the current particle system
  147294. */
  147295. removeStartSizeGradient(gradient: number): IParticleSystem;
  147296. /**
  147297. * Not supported by GPUParticleSystem
  147298. * @param gradient defines the gradient to use (between 0 and 1)
  147299. * @param min defines the color remap minimal range
  147300. * @param max defines the color remap maximal range
  147301. * @returns the current particle system
  147302. */
  147303. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  147304. /**
  147305. * Not supported by GPUParticleSystem
  147306. * @param gradient defines the gradient to remove
  147307. * @returns the current particle system
  147308. */
  147309. removeColorRemapGradient(): IParticleSystem;
  147310. /**
  147311. * Not supported by GPUParticleSystem
  147312. * @param gradient defines the gradient to use (between 0 and 1)
  147313. * @param min defines the alpha remap minimal range
  147314. * @param max defines the alpha remap maximal range
  147315. * @returns the current particle system
  147316. */
  147317. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  147318. /**
  147319. * Not supported by GPUParticleSystem
  147320. * @param gradient defines the gradient to remove
  147321. * @returns the current particle system
  147322. */
  147323. removeAlphaRemapGradient(): IParticleSystem;
  147324. /**
  147325. * Not supported by GPUParticleSystem
  147326. * @param gradient defines the gradient to use (between 0 and 1)
  147327. * @param color defines the color to affect to the specified gradient
  147328. * @returns the current particle system
  147329. */
  147330. addRampGradient(gradient: number, color: Color3): IParticleSystem;
  147331. /**
  147332. * Not supported by GPUParticleSystem
  147333. * @param gradient defines the gradient to remove
  147334. * @returns the current particle system
  147335. */
  147336. removeRampGradient(): IParticleSystem;
  147337. /**
  147338. * Not supported by GPUParticleSystem
  147339. * @returns the list of ramp gradients
  147340. */
  147341. getRampGradients(): Nullable<Array<Color3Gradient>>;
  147342. /**
  147343. * Not supported by GPUParticleSystem
  147344. * Gets or sets a boolean indicating that ramp gradients must be used
  147345. * @see https://doc.babylonjs.com/babylon101/particles#ramp-gradients
  147346. */
  147347. get useRampGradients(): boolean;
  147348. set useRampGradients(value: boolean);
  147349. /**
  147350. * Not supported by GPUParticleSystem
  147351. * @param gradient defines the gradient to use (between 0 and 1)
  147352. * @param factor defines the life time factor to affect to the specified gradient
  147353. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  147354. * @returns the current particle system
  147355. */
  147356. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  147357. /**
  147358. * Not supported by GPUParticleSystem
  147359. * @param gradient defines the gradient to remove
  147360. * @returns the current particle system
  147361. */
  147362. removeLifeTimeGradient(gradient: number): IParticleSystem;
  147363. /**
  147364. * Instantiates a GPU particle system.
  147365. * 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.
  147366. * @param name The name of the particle system
  147367. * @param options The options used to create the system
  147368. * @param sceneOrEngine The scene the particle system belongs to or the engine to use if no scene
  147369. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  147370. * @param customEffect a custom effect used to change the way particles are rendered by default
  147371. */
  147372. constructor(name: string, options: Partial<{
  147373. capacity: number;
  147374. randomTextureSize: number;
  147375. }>, sceneOrEngine: Scene | ThinEngine, isAnimationSheetEnabled?: boolean, customEffect?: Nullable<Effect>);
  147376. protected _reset(): void;
  147377. private _createUpdateVAO;
  147378. private _createRenderVAO;
  147379. private _initialize;
  147380. /** @hidden */
  147381. _recreateUpdateEffect(): void;
  147382. private _getEffect;
  147383. /**
  147384. * Fill the defines array according to the current settings of the particle system
  147385. * @param defines Array to be updated
  147386. * @param blendMode blend mode to take into account when updating the array
  147387. */
  147388. fillDefines(defines: Array<string>, blendMode?: number): void;
  147389. /**
  147390. * Fill the uniforms, attributes and samplers arrays according to the current settings of the particle system
  147391. * @param uniforms Uniforms array to fill
  147392. * @param attributes Attributes array to fill
  147393. * @param samplers Samplers array to fill
  147394. */
  147395. fillUniformsAttributesAndSamplerNames(uniforms: Array<string>, attributes: Array<string>, samplers: Array<string>): void;
  147396. /** @hidden */
  147397. _recreateRenderEffect(): Effect;
  147398. /**
  147399. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  147400. * @param preWarm defines if we are in the pre-warmimg phase
  147401. */
  147402. animate(preWarm?: boolean): void;
  147403. private _createFactorGradientTexture;
  147404. private _createSizeGradientTexture;
  147405. private _createAngularSpeedGradientTexture;
  147406. private _createVelocityGradientTexture;
  147407. private _createLimitVelocityGradientTexture;
  147408. private _createDragGradientTexture;
  147409. private _createColorGradientTexture;
  147410. /**
  147411. * Renders the particle system in its current state
  147412. * @param preWarm defines if the system should only update the particles but not render them
  147413. * @returns the current number of particles
  147414. */
  147415. render(preWarm?: boolean): number;
  147416. /**
  147417. * Rebuilds the particle system
  147418. */
  147419. rebuild(): void;
  147420. private _releaseBuffers;
  147421. private _releaseVAOs;
  147422. /**
  147423. * Disposes the particle system and free the associated resources
  147424. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  147425. */
  147426. dispose(disposeTexture?: boolean): void;
  147427. /**
  147428. * Clones the particle system.
  147429. * @param name The name of the cloned object
  147430. * @param newEmitter The new emitter to use
  147431. * @returns the cloned particle system
  147432. */
  147433. clone(name: string, newEmitter: any): GPUParticleSystem;
  147434. /**
  147435. * Serializes the particle system to a JSON object
  147436. * @param serializeTexture defines if the texture must be serialized as well
  147437. * @returns the JSON object
  147438. */
  147439. serialize(serializeTexture?: boolean): any;
  147440. /**
  147441. * Parses a JSON object to create a GPU particle system.
  147442. * @param parsedParticleSystem The JSON object to parse
  147443. * @param sceneOrEngine The scene or the engine to create the particle system in
  147444. * @param rootUrl The root url to use to load external dependencies like texture
  147445. * @param doNotStart Ignore the preventAutoStart attribute and does not start
  147446. * @returns the parsed GPU particle system
  147447. */
  147448. static Parse(parsedParticleSystem: any, sceneOrEngine: Scene | ThinEngine, rootUrl: string, doNotStart?: boolean): GPUParticleSystem;
  147449. }
  147450. }
  147451. declare module BABYLON {
  147452. /**
  147453. * Represents a set of particle systems working together to create a specific effect
  147454. */
  147455. export class ParticleSystemSet implements IDisposable {
  147456. /**
  147457. * Gets or sets base Assets URL
  147458. */
  147459. static BaseAssetsUrl: string;
  147460. private _emitterCreationOptions;
  147461. private _emitterNode;
  147462. /**
  147463. * Gets the particle system list
  147464. */
  147465. systems: IParticleSystem[];
  147466. /**
  147467. * Gets the emitter node used with this set
  147468. */
  147469. get emitterNode(): Nullable<TransformNode>;
  147470. /**
  147471. * Creates a new emitter mesh as a sphere
  147472. * @param options defines the options used to create the sphere
  147473. * @param renderingGroupId defines the renderingGroupId to use for the sphere
  147474. * @param scene defines the hosting scene
  147475. */
  147476. setEmitterAsSphere(options: {
  147477. diameter: number;
  147478. segments: number;
  147479. color: Color3;
  147480. }, renderingGroupId: number, scene: Scene): void;
  147481. /**
  147482. * Starts all particle systems of the set
  147483. * @param emitter defines an optional mesh to use as emitter for the particle systems
  147484. */
  147485. start(emitter?: AbstractMesh): void;
  147486. /**
  147487. * Release all associated resources
  147488. */
  147489. dispose(): void;
  147490. /**
  147491. * Serialize the set into a JSON compatible object
  147492. * @param serializeTexture defines if the texture must be serialized as well
  147493. * @returns a JSON compatible representation of the set
  147494. */
  147495. serialize(serializeTexture?: boolean): any;
  147496. /**
  147497. * Parse a new ParticleSystemSet from a serialized source
  147498. * @param data defines a JSON compatible representation of the set
  147499. * @param scene defines the hosting scene
  147500. * @param gpu defines if we want GPU particles or CPU particles
  147501. * @returns a new ParticleSystemSet
  147502. */
  147503. static Parse(data: any, scene: Scene, gpu?: boolean): ParticleSystemSet;
  147504. }
  147505. }
  147506. declare module BABYLON {
  147507. /**
  147508. * This class is made for on one-liner static method to help creating particle system set.
  147509. */
  147510. export class ParticleHelper {
  147511. /**
  147512. * Gets or sets base Assets URL
  147513. */
  147514. static BaseAssetsUrl: string;
  147515. /** Define the Url to load snippets */
  147516. static SnippetUrl: string;
  147517. /**
  147518. * Create a default particle system that you can tweak
  147519. * @param emitter defines the emitter to use
  147520. * @param capacity defines the system capacity (default is 500 particles)
  147521. * @param scene defines the hosting scene
  147522. * @param useGPU defines if a GPUParticleSystem must be created (default is false)
  147523. * @returns the new Particle system
  147524. */
  147525. static CreateDefault(emitter: Nullable<AbstractMesh | Vector3>, capacity?: number, scene?: Scene, useGPU?: boolean): IParticleSystem;
  147526. /**
  147527. * This is the main static method (one-liner) of this helper to create different particle systems
  147528. * @param type This string represents the type to the particle system to create
  147529. * @param scene The scene where the particle system should live
  147530. * @param gpu If the system will use gpu
  147531. * @returns the ParticleSystemSet created
  147532. */
  147533. static CreateAsync(type: string, scene: Nullable<Scene>, gpu?: boolean): Promise<ParticleSystemSet>;
  147534. /**
  147535. * Static function used to export a particle system to a ParticleSystemSet variable.
  147536. * Please note that the emitter shape is not exported
  147537. * @param systems defines the particle systems to export
  147538. * @returns the created particle system set
  147539. */
  147540. static ExportSet(systems: IParticleSystem[]): ParticleSystemSet;
  147541. /**
  147542. * Creates a particle system from a snippet saved in a remote file
  147543. * @param name defines the name of the particle system to create (can be null or empty to use the one from the json data)
  147544. * @param url defines the url to load from
  147545. * @param scene defines the hosting scene
  147546. * @param gpu If the system will use gpu
  147547. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  147548. * @returns a promise that will resolve to the new particle system
  147549. */
  147550. static ParseFromFileAsync(name: Nullable<string>, url: string, scene: Scene, gpu?: boolean, rootUrl?: string): Promise<IParticleSystem>;
  147551. /**
  147552. * Creates a particle system from a snippet saved by the particle system editor
  147553. * @param snippetId defines the snippet to load (can be set to _BLANK to create a default one)
  147554. * @param scene defines the hosting scene
  147555. * @param gpu If the system will use gpu
  147556. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  147557. * @returns a promise that will resolve to the new particle system
  147558. */
  147559. static CreateFromSnippetAsync(snippetId: string, scene: Scene, gpu?: boolean, rootUrl?: string): Promise<IParticleSystem>;
  147560. }
  147561. }
  147562. declare module BABYLON {
  147563. interface Engine {
  147564. /**
  147565. * Create an effect to use with particle systems.
  147566. * Please note that some parameters like animation sheets or not being billboard are not supported in this configuration, except if you pass
  147567. * the particle system for which you want to create a custom effect in the last parameter
  147568. * @param fragmentName defines the base name of the effect (The name of file without .fragment.fx)
  147569. * @param uniformsNames defines a list of attribute names
  147570. * @param samplers defines an array of string used to represent textures
  147571. * @param defines defines the string containing the defines to use to compile the shaders
  147572. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  147573. * @param onCompiled defines a function to call when the effect creation is successful
  147574. * @param onError defines a function to call when the effect creation has failed
  147575. * @param particleSystem the particle system you want to create the effect for
  147576. * @returns the new Effect
  147577. */
  147578. createEffectForParticles(fragmentName: string, uniformsNames: string[], samplers: string[], defines: string, fallbacks?: EffectFallbacks, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void, particleSystem?: IParticleSystem): Effect;
  147579. }
  147580. interface Mesh {
  147581. /**
  147582. * Returns an array populated with IParticleSystem objects whose the mesh is the emitter
  147583. * @returns an array of IParticleSystem
  147584. */
  147585. getEmittedParticleSystems(): IParticleSystem[];
  147586. /**
  147587. * Returns an array populated with IParticleSystem objects whose the mesh or its children are the emitter
  147588. * @returns an array of IParticleSystem
  147589. */
  147590. getHierarchyEmittedParticleSystems(): IParticleSystem[];
  147591. }
  147592. }
  147593. declare module BABYLON {
  147594. /** Defines the 4 color options */
  147595. export enum PointColor {
  147596. /** color value */
  147597. Color = 2,
  147598. /** uv value */
  147599. UV = 1,
  147600. /** random value */
  147601. Random = 0,
  147602. /** stated value */
  147603. Stated = 3
  147604. }
  147605. /**
  147606. * The PointCloudSystem (PCS) is a single updatable mesh. The points corresponding to the vertices of this big mesh.
  147607. * 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.
  147608. * The PointCloudSytem is also a particle system, with each point being a particle. It provides some methods to manage the particles.
  147609. * However it is behavior agnostic. This means it has no emitter, no particle physics, no particle recycler. You have to implement your own behavior.
  147610. *
  147611. * Full documentation here : TO BE ENTERED
  147612. */
  147613. export class PointsCloudSystem implements IDisposable {
  147614. /**
  147615. * The PCS array of cloud point objects. Just access each particle as with any classic array.
  147616. * Example : var p = SPS.particles[i];
  147617. */
  147618. particles: CloudPoint[];
  147619. /**
  147620. * The PCS total number of particles. Read only. Use PCS.counter instead if you need to set your own value.
  147621. */
  147622. nbParticles: number;
  147623. /**
  147624. * This a counter for your own usage. It's not set by any SPS functions.
  147625. */
  147626. counter: number;
  147627. /**
  147628. * The PCS name. This name is also given to the underlying mesh.
  147629. */
  147630. name: string;
  147631. /**
  147632. * The PCS mesh. It's a standard BJS Mesh, so all the methods from the Mesh class are avalaible.
  147633. */
  147634. mesh: Mesh;
  147635. /**
  147636. * This empty object is intended to store some PCS specific or temporary values in order to lower the Garbage Collector activity.
  147637. * Please read :
  147638. */
  147639. vars: any;
  147640. /**
  147641. * @hidden
  147642. */
  147643. _size: number;
  147644. private _scene;
  147645. private _promises;
  147646. private _positions;
  147647. private _indices;
  147648. private _normals;
  147649. private _colors;
  147650. private _uvs;
  147651. private _indices32;
  147652. private _positions32;
  147653. private _colors32;
  147654. private _uvs32;
  147655. private _updatable;
  147656. private _isVisibilityBoxLocked;
  147657. private _alwaysVisible;
  147658. private _groups;
  147659. private _groupCounter;
  147660. private _computeParticleColor;
  147661. private _computeParticleTexture;
  147662. private _computeParticleRotation;
  147663. private _computeBoundingBox;
  147664. private _isReady;
  147665. /**
  147666. * Creates a PCS (Points Cloud System) object
  147667. * @param name (String) is the PCS name, this will be the underlying mesh name
  147668. * @param pointSize (number) is the size for each point
  147669. * @param scene (Scene) is the scene in which the PCS is added
  147670. * @param options defines the options of the PCS e.g.
  147671. * * updatable (optional boolean, default true) : if the PCS must be updatable or immutable
  147672. */
  147673. constructor(name: string, pointSize: number, scene: Scene, options?: {
  147674. updatable?: boolean;
  147675. });
  147676. /**
  147677. * Builds the PCS underlying mesh. Returns a standard Mesh.
  147678. * If no points were added to the PCS, the returned mesh is just a single point.
  147679. * @returns a promise for the created mesh
  147680. */
  147681. buildMeshAsync(): Promise<Mesh>;
  147682. /**
  147683. * @hidden
  147684. */
  147685. private _buildMesh;
  147686. private _addParticle;
  147687. private _randomUnitVector;
  147688. private _getColorIndicesForCoord;
  147689. private _setPointsColorOrUV;
  147690. private _colorFromTexture;
  147691. private _calculateDensity;
  147692. /**
  147693. * Adds points to the PCS in random positions within a unit sphere
  147694. * @param nb (positive integer) the number of particles to be created from this model
  147695. * @param pointFunction is an optional javascript function to be called for each particle on PCS creation
  147696. * @returns the number of groups in the system
  147697. */
  147698. addPoints(nb: number, pointFunction?: any): number;
  147699. /**
  147700. * Adds points to the PCS from the surface of the model shape
  147701. * @param mesh is any Mesh object that will be used as a surface model for the points
  147702. * @param nb (positive integer) the number of particles to be created from this model
  147703. * @param colorWith determines whether a point is colored using color (default), uv, random, stated or none (invisible)
  147704. * @param color (color4) to be used when colorWith is stated or color (number) when used to specify texture position
  147705. * @param range (number from 0 to 1) to determine the variation in shape and tone for a stated color
  147706. * @returns the number of groups in the system
  147707. */
  147708. addSurfacePoints(mesh: Mesh, nb: number, colorWith?: number, color?: Color4 | number, range?: number): number;
  147709. /**
  147710. * Adds points to the PCS inside the model shape
  147711. * @param mesh is any Mesh object that will be used as a surface model for the points
  147712. * @param nb (positive integer) the number of particles to be created from this model
  147713. * @param colorWith determines whether a point is colored using color (default), uv, random, stated or none (invisible)
  147714. * @param color (color4) to be used when colorWith is stated or color (number) when used to specify texture position
  147715. * @param range (number from 0 to 1) to determine the variation in shape and tone for a stated color
  147716. * @returns the number of groups in the system
  147717. */
  147718. addVolumePoints(mesh: Mesh, nb: number, colorWith?: number, color?: Color4 | number, range?: number): number;
  147719. /**
  147720. * Sets all the particles : this method actually really updates the mesh according to the particle positions, rotations, colors, textures, etc.
  147721. * This method calls `updateParticle()` for each particle of the SPS.
  147722. * For an animated SPS, it is usually called within the render loop.
  147723. * @param start The particle index in the particle array where to start to compute the particle property values _(default 0)_
  147724. * @param end The particle index in the particle array where to stop to compute the particle property values _(default nbParticle - 1)_
  147725. * @param update If the mesh must be finally updated on this call after all the particle computations _(default true)_
  147726. * @returns the PCS.
  147727. */
  147728. setParticles(start?: number, end?: number, update?: boolean): PointsCloudSystem;
  147729. /**
  147730. * Disposes the PCS.
  147731. */
  147732. dispose(): void;
  147733. /**
  147734. * Visibilty helper : Recomputes the visible size according to the mesh bounding box
  147735. * doc :
  147736. * @returns the PCS.
  147737. */
  147738. refreshVisibleSize(): PointsCloudSystem;
  147739. /**
  147740. * Visibility helper : Sets the size of a visibility box, this sets the underlying mesh bounding box.
  147741. * @param size the size (float) of the visibility box
  147742. * note : this doesn't lock the PCS mesh bounding box.
  147743. * doc :
  147744. */
  147745. setVisibilityBox(size: number): void;
  147746. /**
  147747. * Gets whether the PCS is always visible or not
  147748. * doc :
  147749. */
  147750. get isAlwaysVisible(): boolean;
  147751. /**
  147752. * Sets the PCS as always visible or not
  147753. * doc :
  147754. */
  147755. set isAlwaysVisible(val: boolean);
  147756. /**
  147757. * Tells to `setParticles()` to compute the particle rotations or not
  147758. * Default value : false. The PCS is faster when it's set to false
  147759. * Note : particle rotations are only applied to parent particles
  147760. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate
  147761. */
  147762. set computeParticleRotation(val: boolean);
  147763. /**
  147764. * Tells to `setParticles()` to compute the particle colors or not.
  147765. * Default value : true. The PCS is faster when it's set to false.
  147766. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  147767. */
  147768. set computeParticleColor(val: boolean);
  147769. set computeParticleTexture(val: boolean);
  147770. /**
  147771. * Gets if `setParticles()` computes the particle colors or not.
  147772. * Default value : false. The PCS is faster when it's set to false.
  147773. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  147774. */
  147775. get computeParticleColor(): boolean;
  147776. /**
  147777. * Gets if `setParticles()` computes the particle textures or not.
  147778. * Default value : false. The PCS is faster when it's set to false.
  147779. * Note : the particle textures are stored values, so setting `computeParticleTexture` to false will keep yet the last colors set.
  147780. */
  147781. get computeParticleTexture(): boolean;
  147782. /**
  147783. * Tells to `setParticles()` to compute or not the mesh bounding box when computing the particle positions.
  147784. */
  147785. set computeBoundingBox(val: boolean);
  147786. /**
  147787. * Gets if `setParticles()` computes or not the mesh bounding box when computing the particle positions.
  147788. */
  147789. get computeBoundingBox(): boolean;
  147790. /**
  147791. * This function does nothing. It may be overwritten to set all the particle first values.
  147792. * The PCS doesn't call this function, you may have to call it by your own.
  147793. * doc :
  147794. */
  147795. initParticles(): void;
  147796. /**
  147797. * This function does nothing. It may be overwritten to recycle a particle
  147798. * The PCS doesn't call this function, you can to call it
  147799. * doc :
  147800. * @param particle The particle to recycle
  147801. * @returns the recycled particle
  147802. */
  147803. recycleParticle(particle: CloudPoint): CloudPoint;
  147804. /**
  147805. * Updates a particle : this function should be overwritten by the user.
  147806. * It is called on each particle by `setParticles()`. This is the place to code each particle behavior.
  147807. * doc :
  147808. * @example : just set a particle position or velocity and recycle conditions
  147809. * @param particle The particle to update
  147810. * @returns the updated particle
  147811. */
  147812. updateParticle(particle: CloudPoint): CloudPoint;
  147813. /**
  147814. * This will be called before any other treatment by `setParticles()` and will be passed three parameters.
  147815. * This does nothing and may be overwritten by the user.
  147816. * @param start the particle index in the particle array where to start to iterate, same than the value passed to setParticle()
  147817. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  147818. * @param update the boolean update value actually passed to setParticles()
  147819. */
  147820. beforeUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  147821. /**
  147822. * This will be called by `setParticles()` after all the other treatments and just before the actual mesh update.
  147823. * This will be passed three parameters.
  147824. * This does nothing and may be overwritten by the user.
  147825. * @param start the particle index in the particle array where to start to iterate, same than the value passed to setParticle()
  147826. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  147827. * @param update the boolean update value actually passed to setParticles()
  147828. */
  147829. afterUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  147830. }
  147831. }
  147832. declare module BABYLON {
  147833. /**
  147834. * Represents one particle of a points cloud system.
  147835. */
  147836. export class CloudPoint {
  147837. /**
  147838. * particle global index
  147839. */
  147840. idx: number;
  147841. /**
  147842. * The color of the particle
  147843. */
  147844. color: Nullable<Color4>;
  147845. /**
  147846. * The world space position of the particle.
  147847. */
  147848. position: Vector3;
  147849. /**
  147850. * The world space rotation of the particle. (Not use if rotationQuaternion is set)
  147851. */
  147852. rotation: Vector3;
  147853. /**
  147854. * The world space rotation quaternion of the particle.
  147855. */
  147856. rotationQuaternion: Nullable<Quaternion>;
  147857. /**
  147858. * The uv of the particle.
  147859. */
  147860. uv: Nullable<Vector2>;
  147861. /**
  147862. * The current speed of the particle.
  147863. */
  147864. velocity: Vector3;
  147865. /**
  147866. * The pivot point in the particle local space.
  147867. */
  147868. pivot: Vector3;
  147869. /**
  147870. * Must the particle be translated from its pivot point in its local space ?
  147871. * In this case, the pivot point is set at the origin of the particle local space and the particle is translated.
  147872. * Default : false
  147873. */
  147874. translateFromPivot: boolean;
  147875. /**
  147876. * Index of this particle in the global "positions" array (Internal use)
  147877. * @hidden
  147878. */
  147879. _pos: number;
  147880. /**
  147881. * @hidden Index of this particle in the global "indices" array (Internal use)
  147882. */
  147883. _ind: number;
  147884. /**
  147885. * Group this particle belongs to
  147886. */
  147887. _group: PointsGroup;
  147888. /**
  147889. * Group id of this particle
  147890. */
  147891. groupId: number;
  147892. /**
  147893. * Index of the particle in its group id (Internal use)
  147894. */
  147895. idxInGroup: number;
  147896. /**
  147897. * @hidden Particle BoundingInfo object (Internal use)
  147898. */
  147899. _boundingInfo: BoundingInfo;
  147900. /**
  147901. * @hidden Reference to the PCS that the particle belongs to (Internal use)
  147902. */
  147903. _pcs: PointsCloudSystem;
  147904. /**
  147905. * @hidden Still set as invisible in order to skip useless computations (Internal use)
  147906. */
  147907. _stillInvisible: boolean;
  147908. /**
  147909. * @hidden Last computed particle rotation matrix
  147910. */
  147911. _rotationMatrix: number[];
  147912. /**
  147913. * Parent particle Id, if any.
  147914. * Default null.
  147915. */
  147916. parentId: Nullable<number>;
  147917. /**
  147918. * @hidden Internal global position in the PCS.
  147919. */
  147920. _globalPosition: Vector3;
  147921. /**
  147922. * Creates a Point Cloud object.
  147923. * Don't create particles manually, use instead the PCS internal tools like _addParticle()
  147924. * @param particleIndex (integer) is the particle index in the PCS pool. It's also the particle identifier.
  147925. * @param group (PointsGroup) is the group the particle belongs to
  147926. * @param groupId (integer) is the group identifier in the PCS.
  147927. * @param idxInGroup (integer) is the index of the particle in the current point group (ex: the 10th point of addPoints(30))
  147928. * @param pcs defines the PCS it is associated to
  147929. */
  147930. constructor(particleIndex: number, group: PointsGroup, groupId: number, idxInGroup: number, pcs: PointsCloudSystem);
  147931. /**
  147932. * get point size
  147933. */
  147934. get size(): Vector3;
  147935. /**
  147936. * Set point size
  147937. */
  147938. set size(scale: Vector3);
  147939. /**
  147940. * Legacy support, changed quaternion to rotationQuaternion
  147941. */
  147942. get quaternion(): Nullable<Quaternion>;
  147943. /**
  147944. * Legacy support, changed quaternion to rotationQuaternion
  147945. */
  147946. set quaternion(q: Nullable<Quaternion>);
  147947. /**
  147948. * Returns a boolean. True if the particle intersects a mesh, else false
  147949. * The intersection is computed on the particle position and Axis Aligned Bounding Box (AABB) or Sphere
  147950. * @param target is the object (point or mesh) what the intersection is computed against
  147951. * @param isSphere is boolean flag when false (default) bounding box of mesh is used, when true the bouding sphere is used
  147952. * @returns true if it intersects
  147953. */
  147954. intersectsMesh(target: Mesh, isSphere: boolean): boolean;
  147955. /**
  147956. * get the rotation matrix of the particle
  147957. * @hidden
  147958. */
  147959. getRotationMatrix(m: Matrix): void;
  147960. }
  147961. /**
  147962. * Represents a group of points in a points cloud system
  147963. * * PCS internal tool, don't use it manually.
  147964. */
  147965. export class PointsGroup {
  147966. /**
  147967. * The group id
  147968. * @hidden
  147969. */
  147970. groupID: number;
  147971. /**
  147972. * image data for group (internal use)
  147973. * @hidden
  147974. */
  147975. _groupImageData: Nullable<ArrayBufferView>;
  147976. /**
  147977. * Image Width (internal use)
  147978. * @hidden
  147979. */
  147980. _groupImgWidth: number;
  147981. /**
  147982. * Image Height (internal use)
  147983. * @hidden
  147984. */
  147985. _groupImgHeight: number;
  147986. /**
  147987. * Custom position function (internal use)
  147988. * @hidden
  147989. */
  147990. _positionFunction: Nullable<(particle: CloudPoint, i?: number, s?: number) => void>;
  147991. /**
  147992. * density per facet for surface points
  147993. * @hidden
  147994. */
  147995. _groupDensity: number[];
  147996. /**
  147997. * Only when points are colored by texture carries pointer to texture list array
  147998. * @hidden
  147999. */
  148000. _textureNb: number;
  148001. /**
  148002. * Creates a points group object. This is an internal reference to produce particles for the PCS.
  148003. * PCS internal tool, don't use it manually.
  148004. * @hidden
  148005. */
  148006. constructor(id: number, posFunction: Nullable<(particle: CloudPoint, i?: number, s?: number) => void>);
  148007. }
  148008. }
  148009. declare module BABYLON {
  148010. interface Scene {
  148011. /** @hidden (Backing field) */
  148012. _physicsEngine: Nullable<IPhysicsEngine>;
  148013. /** @hidden */
  148014. _physicsTimeAccumulator: number;
  148015. /**
  148016. * Gets the current physics engine
  148017. * @returns a IPhysicsEngine or null if none attached
  148018. */
  148019. getPhysicsEngine(): Nullable<IPhysicsEngine>;
  148020. /**
  148021. * Enables physics to the current scene
  148022. * @param gravity defines the scene's gravity for the physics engine
  148023. * @param plugin defines the physics engine to be used. defaults to OimoJS.
  148024. * @return a boolean indicating if the physics engine was initialized
  148025. */
  148026. enablePhysics(gravity: Nullable<Vector3>, plugin?: IPhysicsEnginePlugin): boolean;
  148027. /**
  148028. * Disables and disposes the physics engine associated with the scene
  148029. */
  148030. disablePhysicsEngine(): void;
  148031. /**
  148032. * Gets a boolean indicating if there is an active physics engine
  148033. * @returns a boolean indicating if there is an active physics engine
  148034. */
  148035. isPhysicsEnabled(): boolean;
  148036. /**
  148037. * Deletes a physics compound impostor
  148038. * @param compound defines the compound to delete
  148039. */
  148040. deleteCompoundImpostor(compound: any): void;
  148041. /**
  148042. * An event triggered when physic simulation is about to be run
  148043. */
  148044. onBeforePhysicsObservable: Observable<Scene>;
  148045. /**
  148046. * An event triggered when physic simulation has been done
  148047. */
  148048. onAfterPhysicsObservable: Observable<Scene>;
  148049. }
  148050. interface AbstractMesh {
  148051. /** @hidden */
  148052. _physicsImpostor: Nullable<PhysicsImpostor>;
  148053. /**
  148054. * Gets or sets impostor used for physic simulation
  148055. * @see https://doc.babylonjs.com/features/physics_engine
  148056. */
  148057. physicsImpostor: Nullable<PhysicsImpostor>;
  148058. /**
  148059. * Gets the current physics impostor
  148060. * @see https://doc.babylonjs.com/features/physics_engine
  148061. * @returns a physics impostor or null
  148062. */
  148063. getPhysicsImpostor(): Nullable<PhysicsImpostor>;
  148064. /** Apply a physic impulse to the mesh
  148065. * @param force defines the force to apply
  148066. * @param contactPoint defines where to apply the force
  148067. * @returns the current mesh
  148068. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  148069. */
  148070. applyImpulse(force: Vector3, contactPoint: Vector3): AbstractMesh;
  148071. /**
  148072. * Creates a physic joint between two meshes
  148073. * @param otherMesh defines the other mesh to use
  148074. * @param pivot1 defines the pivot to use on this mesh
  148075. * @param pivot2 defines the pivot to use on the other mesh
  148076. * @param options defines additional options (can be plugin dependent)
  148077. * @returns the current mesh
  148078. * @see https://www.babylonjs-playground.com/#0BS5U0#0
  148079. */
  148080. setPhysicsLinkWith(otherMesh: Mesh, pivot1: Vector3, pivot2: Vector3, options?: any): AbstractMesh;
  148081. /** @hidden */
  148082. _disposePhysicsObserver: Nullable<Observer<Node>>;
  148083. }
  148084. /**
  148085. * Defines the physics engine scene component responsible to manage a physics engine
  148086. */
  148087. export class PhysicsEngineSceneComponent implements ISceneComponent {
  148088. /**
  148089. * The component name helpful to identify the component in the list of scene components.
  148090. */
  148091. readonly name: string;
  148092. /**
  148093. * The scene the component belongs to.
  148094. */
  148095. scene: Scene;
  148096. /**
  148097. * Creates a new instance of the component for the given scene
  148098. * @param scene Defines the scene to register the component in
  148099. */
  148100. constructor(scene: Scene);
  148101. /**
  148102. * Registers the component in a given scene
  148103. */
  148104. register(): void;
  148105. /**
  148106. * Rebuilds the elements related to this component in case of
  148107. * context lost for instance.
  148108. */
  148109. rebuild(): void;
  148110. /**
  148111. * Disposes the component and the associated ressources
  148112. */
  148113. dispose(): void;
  148114. }
  148115. }
  148116. declare module BABYLON {
  148117. /**
  148118. * A helper for physics simulations
  148119. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  148120. */
  148121. export class PhysicsHelper {
  148122. private _scene;
  148123. private _physicsEngine;
  148124. /**
  148125. * Initializes the Physics helper
  148126. * @param scene Babylon.js scene
  148127. */
  148128. constructor(scene: Scene);
  148129. /**
  148130. * Applies a radial explosion impulse
  148131. * @param origin the origin of the explosion
  148132. * @param radiusOrEventOptions the radius or the options of radial explosion
  148133. * @param strength the explosion strength
  148134. * @param falloff possible options: Constant & Linear. Defaults to Constant
  148135. * @returns A physics radial explosion event, or null
  148136. */
  148137. applyRadialExplosionImpulse(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  148138. /**
  148139. * Applies a radial explosion force
  148140. * @param origin the origin of the explosion
  148141. * @param radiusOrEventOptions the radius or the options of radial explosion
  148142. * @param strength the explosion strength
  148143. * @param falloff possible options: Constant & Linear. Defaults to Constant
  148144. * @returns A physics radial explosion event, or null
  148145. */
  148146. applyRadialExplosionForce(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  148147. /**
  148148. * Creates a gravitational field
  148149. * @param origin the origin of the explosion
  148150. * @param radiusOrEventOptions the radius or the options of radial explosion
  148151. * @param strength the explosion strength
  148152. * @param falloff possible options: Constant & Linear. Defaults to Constant
  148153. * @returns A physics gravitational field event, or null
  148154. */
  148155. gravitationalField(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsGravitationalFieldEvent>;
  148156. /**
  148157. * Creates a physics updraft event
  148158. * @param origin the origin of the updraft
  148159. * @param radiusOrEventOptions the radius or the options of the updraft
  148160. * @param strength the strength of the updraft
  148161. * @param height the height of the updraft
  148162. * @param updraftMode possible options: Center & Perpendicular. Defaults to Center
  148163. * @returns A physics updraft event, or null
  148164. */
  148165. updraft(origin: Vector3, radiusOrEventOptions: number | PhysicsUpdraftEventOptions, strength?: number, height?: number, updraftMode?: PhysicsUpdraftMode): Nullable<PhysicsUpdraftEvent>;
  148166. /**
  148167. * Creates a physics vortex event
  148168. * @param origin the of the vortex
  148169. * @param radiusOrEventOptions the radius or the options of the vortex
  148170. * @param strength the strength of the vortex
  148171. * @param height the height of the vortex
  148172. * @returns a Physics vortex event, or null
  148173. * A physics vortex event or null
  148174. */
  148175. vortex(origin: Vector3, radiusOrEventOptions: number | PhysicsVortexEventOptions, strength?: number, height?: number): Nullable<PhysicsVortexEvent>;
  148176. }
  148177. /**
  148178. * Represents a physics radial explosion event
  148179. */
  148180. class PhysicsRadialExplosionEvent {
  148181. private _scene;
  148182. private _options;
  148183. private _sphere;
  148184. private _dataFetched;
  148185. /**
  148186. * Initializes a radial explosioin event
  148187. * @param _scene BabylonJS scene
  148188. * @param _options The options for the vortex event
  148189. */
  148190. constructor(_scene: Scene, _options: PhysicsRadialExplosionEventOptions);
  148191. /**
  148192. * Returns the data related to the radial explosion event (sphere).
  148193. * @returns The radial explosion event data
  148194. */
  148195. getData(): PhysicsRadialExplosionEventData;
  148196. /**
  148197. * Returns the force and contact point of the impostor or false, if the impostor is not affected by the force/impulse.
  148198. * @param impostor A physics imposter
  148199. * @param origin the origin of the explosion
  148200. * @returns {Nullable<PhysicsHitData>} A physics force and contact point, or null
  148201. */
  148202. getImpostorHitData(impostor: PhysicsImpostor, origin: Vector3): Nullable<PhysicsHitData>;
  148203. /**
  148204. * Triggers affecterd impostors callbacks
  148205. * @param affectedImpostorsWithData defines the list of affected impostors (including associated data)
  148206. */
  148207. triggerAffectedImpostorsCallback(affectedImpostorsWithData: Array<PhysicsAffectedImpostorWithData>): void;
  148208. /**
  148209. * Disposes the sphere.
  148210. * @param force Specifies if the sphere should be disposed by force
  148211. */
  148212. dispose(force?: boolean): void;
  148213. /*** Helpers ***/
  148214. private _prepareSphere;
  148215. private _intersectsWithSphere;
  148216. }
  148217. /**
  148218. * Represents a gravitational field event
  148219. */
  148220. class PhysicsGravitationalFieldEvent {
  148221. private _physicsHelper;
  148222. private _scene;
  148223. private _origin;
  148224. private _options;
  148225. private _tickCallback;
  148226. private _sphere;
  148227. private _dataFetched;
  148228. /**
  148229. * Initializes the physics gravitational field event
  148230. * @param _physicsHelper A physics helper
  148231. * @param _scene BabylonJS scene
  148232. * @param _origin The origin position of the gravitational field event
  148233. * @param _options The options for the vortex event
  148234. */
  148235. constructor(_physicsHelper: PhysicsHelper, _scene: Scene, _origin: Vector3, _options: PhysicsRadialExplosionEventOptions);
  148236. /**
  148237. * Returns the data related to the gravitational field event (sphere).
  148238. * @returns A gravitational field event
  148239. */
  148240. getData(): PhysicsGravitationalFieldEventData;
  148241. /**
  148242. * Enables the gravitational field.
  148243. */
  148244. enable(): void;
  148245. /**
  148246. * Disables the gravitational field.
  148247. */
  148248. disable(): void;
  148249. /**
  148250. * Disposes the sphere.
  148251. * @param force The force to dispose from the gravitational field event
  148252. */
  148253. dispose(force?: boolean): void;
  148254. private _tick;
  148255. }
  148256. /**
  148257. * Represents a physics updraft event
  148258. */
  148259. class PhysicsUpdraftEvent {
  148260. private _scene;
  148261. private _origin;
  148262. private _options;
  148263. private _physicsEngine;
  148264. private _originTop;
  148265. private _originDirection;
  148266. private _tickCallback;
  148267. private _cylinder;
  148268. private _cylinderPosition;
  148269. private _dataFetched;
  148270. /**
  148271. * Initializes the physics updraft event
  148272. * @param _scene BabylonJS scene
  148273. * @param _origin The origin position of the updraft
  148274. * @param _options The options for the updraft event
  148275. */
  148276. constructor(_scene: Scene, _origin: Vector3, _options: PhysicsUpdraftEventOptions);
  148277. /**
  148278. * Returns the data related to the updraft event (cylinder).
  148279. * @returns A physics updraft event
  148280. */
  148281. getData(): PhysicsUpdraftEventData;
  148282. /**
  148283. * Enables the updraft.
  148284. */
  148285. enable(): void;
  148286. /**
  148287. * Disables the updraft.
  148288. */
  148289. disable(): void;
  148290. /**
  148291. * Disposes the cylinder.
  148292. * @param force Specifies if the updraft should be disposed by force
  148293. */
  148294. dispose(force?: boolean): void;
  148295. private getImpostorHitData;
  148296. private _tick;
  148297. /*** Helpers ***/
  148298. private _prepareCylinder;
  148299. private _intersectsWithCylinder;
  148300. }
  148301. /**
  148302. * Represents a physics vortex event
  148303. */
  148304. class PhysicsVortexEvent {
  148305. private _scene;
  148306. private _origin;
  148307. private _options;
  148308. private _physicsEngine;
  148309. private _originTop;
  148310. private _tickCallback;
  148311. private _cylinder;
  148312. private _cylinderPosition;
  148313. private _dataFetched;
  148314. /**
  148315. * Initializes the physics vortex event
  148316. * @param _scene The BabylonJS scene
  148317. * @param _origin The origin position of the vortex
  148318. * @param _options The options for the vortex event
  148319. */
  148320. constructor(_scene: Scene, _origin: Vector3, _options: PhysicsVortexEventOptions);
  148321. /**
  148322. * Returns the data related to the vortex event (cylinder).
  148323. * @returns The physics vortex event data
  148324. */
  148325. getData(): PhysicsVortexEventData;
  148326. /**
  148327. * Enables the vortex.
  148328. */
  148329. enable(): void;
  148330. /**
  148331. * Disables the cortex.
  148332. */
  148333. disable(): void;
  148334. /**
  148335. * Disposes the sphere.
  148336. * @param force
  148337. */
  148338. dispose(force?: boolean): void;
  148339. private getImpostorHitData;
  148340. private _tick;
  148341. /*** Helpers ***/
  148342. private _prepareCylinder;
  148343. private _intersectsWithCylinder;
  148344. }
  148345. /**
  148346. * Options fot the radial explosion event
  148347. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  148348. */
  148349. export class PhysicsRadialExplosionEventOptions {
  148350. /**
  148351. * The radius of the sphere for the radial explosion.
  148352. */
  148353. radius: number;
  148354. /**
  148355. * The strenth of the explosion.
  148356. */
  148357. strength: number;
  148358. /**
  148359. * The strenght of the force in correspondence to the distance of the affected object
  148360. */
  148361. falloff: PhysicsRadialImpulseFalloff;
  148362. /**
  148363. * Sphere options for the radial explosion.
  148364. */
  148365. sphere: {
  148366. segments: number;
  148367. diameter: number;
  148368. };
  148369. /**
  148370. * Sphere options for the radial explosion.
  148371. */
  148372. affectedImpostorsCallback: (affectedImpostorsWithData: Array<PhysicsAffectedImpostorWithData>) => void;
  148373. }
  148374. /**
  148375. * Options fot the updraft event
  148376. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  148377. */
  148378. export class PhysicsUpdraftEventOptions {
  148379. /**
  148380. * The radius of the cylinder for the vortex
  148381. */
  148382. radius: number;
  148383. /**
  148384. * The strenth of the updraft.
  148385. */
  148386. strength: number;
  148387. /**
  148388. * The height of the cylinder for the updraft.
  148389. */
  148390. height: number;
  148391. /**
  148392. * The mode for the the updraft.
  148393. */
  148394. updraftMode: PhysicsUpdraftMode;
  148395. }
  148396. /**
  148397. * Options fot the vortex event
  148398. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  148399. */
  148400. export class PhysicsVortexEventOptions {
  148401. /**
  148402. * The radius of the cylinder for the vortex
  148403. */
  148404. radius: number;
  148405. /**
  148406. * The strenth of the vortex.
  148407. */
  148408. strength: number;
  148409. /**
  148410. * The height of the cylinder for the vortex.
  148411. */
  148412. height: number;
  148413. /**
  148414. * At which distance, relative to the radius the centripetal forces should kick in? Range: 0-1
  148415. */
  148416. centripetalForceThreshold: number;
  148417. /**
  148418. * This multiplier determines with how much force the objects will be pushed sideways/around the vortex, when below the treshold.
  148419. */
  148420. centripetalForceMultiplier: number;
  148421. /**
  148422. * This multiplier determines with how much force the objects will be pushed sideways/around the vortex, when above the treshold.
  148423. */
  148424. centrifugalForceMultiplier: number;
  148425. /**
  148426. * This multiplier determines with how much force the objects will be pushed upwards, when in the vortex.
  148427. */
  148428. updraftForceMultiplier: number;
  148429. }
  148430. /**
  148431. * The strenght of the force in correspondence to the distance of the affected object
  148432. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  148433. */
  148434. export enum PhysicsRadialImpulseFalloff {
  148435. /** Defines that impulse is constant in strength across it's whole radius */
  148436. Constant = 0,
  148437. /** Defines that impulse gets weaker if it's further from the origin */
  148438. Linear = 1
  148439. }
  148440. /**
  148441. * The strength of the force in correspondence to the distance of the affected object
  148442. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  148443. */
  148444. export enum PhysicsUpdraftMode {
  148445. /** Defines that the upstream forces will pull towards the top center of the cylinder */
  148446. Center = 0,
  148447. /** Defines that once a impostor is inside the cylinder, it will shoot out perpendicular from the ground of the cylinder */
  148448. Perpendicular = 1
  148449. }
  148450. /**
  148451. * Interface for a physics hit data
  148452. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  148453. */
  148454. export interface PhysicsHitData {
  148455. /**
  148456. * The force applied at the contact point
  148457. */
  148458. force: Vector3;
  148459. /**
  148460. * The contact point
  148461. */
  148462. contactPoint: Vector3;
  148463. /**
  148464. * The distance from the origin to the contact point
  148465. */
  148466. distanceFromOrigin: number;
  148467. }
  148468. /**
  148469. * Interface for radial explosion event data
  148470. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  148471. */
  148472. export interface PhysicsRadialExplosionEventData {
  148473. /**
  148474. * A sphere used for the radial explosion event
  148475. */
  148476. sphere: Mesh;
  148477. }
  148478. /**
  148479. * Interface for gravitational field event data
  148480. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  148481. */
  148482. export interface PhysicsGravitationalFieldEventData {
  148483. /**
  148484. * A sphere mesh used for the gravitational field event
  148485. */
  148486. sphere: Mesh;
  148487. }
  148488. /**
  148489. * Interface for updraft event data
  148490. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  148491. */
  148492. export interface PhysicsUpdraftEventData {
  148493. /**
  148494. * A cylinder used for the updraft event
  148495. */
  148496. cylinder: Mesh;
  148497. }
  148498. /**
  148499. * Interface for vortex event data
  148500. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  148501. */
  148502. export interface PhysicsVortexEventData {
  148503. /**
  148504. * A cylinder used for the vortex event
  148505. */
  148506. cylinder: Mesh;
  148507. }
  148508. /**
  148509. * Interface for an affected physics impostor
  148510. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  148511. */
  148512. export interface PhysicsAffectedImpostorWithData {
  148513. /**
  148514. * The impostor affected by the effect
  148515. */
  148516. impostor: PhysicsImpostor;
  148517. /**
  148518. * The data about the hit/horce from the explosion
  148519. */
  148520. hitData: PhysicsHitData;
  148521. }
  148522. }
  148523. declare module BABYLON {
  148524. /** @hidden */
  148525. export var blackAndWhitePixelShader: {
  148526. name: string;
  148527. shader: string;
  148528. };
  148529. }
  148530. declare module BABYLON {
  148531. /**
  148532. * Post process used to render in black and white
  148533. */
  148534. export class BlackAndWhitePostProcess extends PostProcess {
  148535. /**
  148536. * Linear about to convert he result to black and white (default: 1)
  148537. */
  148538. degree: number;
  148539. /**
  148540. * Gets a string identifying the name of the class
  148541. * @returns "BlackAndWhitePostProcess" string
  148542. */
  148543. getClassName(): string;
  148544. /**
  148545. * Creates a black and white post process
  148546. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#black-and-white
  148547. * @param name The name of the effect.
  148548. * @param options The required width/height ratio to downsize to before computing the render pass.
  148549. * @param camera The camera to apply the render pass to.
  148550. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  148551. * @param engine The engine which the post process will be applied. (default: current engine)
  148552. * @param reusable If the post process can be reused on the same frame. (default: false)
  148553. */
  148554. constructor(name: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  148555. /** @hidden */
  148556. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): Nullable<BlackAndWhitePostProcess>;
  148557. }
  148558. }
  148559. declare module BABYLON {
  148560. /**
  148561. * This represents a set of one or more post processes in Babylon.
  148562. * A post process can be used to apply a shader to a texture after it is rendered.
  148563. * @example https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  148564. */
  148565. export class PostProcessRenderEffect {
  148566. private _postProcesses;
  148567. private _getPostProcesses;
  148568. private _singleInstance;
  148569. private _cameras;
  148570. private _indicesForCamera;
  148571. /**
  148572. * Name of the effect
  148573. * @hidden
  148574. */
  148575. _name: string;
  148576. /**
  148577. * Instantiates a post process render effect.
  148578. * A post process can be used to apply a shader to a texture after it is rendered.
  148579. * @param engine The engine the effect is tied to
  148580. * @param name The name of the effect
  148581. * @param getPostProcesses A function that returns a set of post processes which the effect will run in order to be run.
  148582. * @param singleInstance False if this post process can be run on multiple cameras. (default: true)
  148583. */
  148584. constructor(engine: Engine, name: string, getPostProcesses: () => Nullable<PostProcess | Array<PostProcess>>, singleInstance?: boolean);
  148585. /**
  148586. * Checks if all the post processes in the effect are supported.
  148587. */
  148588. get isSupported(): boolean;
  148589. /**
  148590. * Updates the current state of the effect
  148591. * @hidden
  148592. */
  148593. _update(): void;
  148594. /**
  148595. * Attaches the effect on cameras
  148596. * @param cameras The camera to attach to.
  148597. * @hidden
  148598. */
  148599. _attachCameras(cameras: Camera): void;
  148600. /**
  148601. * Attaches the effect on cameras
  148602. * @param cameras The camera to attach to.
  148603. * @hidden
  148604. */
  148605. _attachCameras(cameras: Camera[]): void;
  148606. /**
  148607. * Detaches the effect on cameras
  148608. * @param cameras The camera to detatch from.
  148609. * @hidden
  148610. */
  148611. _detachCameras(cameras: Camera): void;
  148612. /**
  148613. * Detatches the effect on cameras
  148614. * @param cameras The camera to detatch from.
  148615. * @hidden
  148616. */
  148617. _detachCameras(cameras: Camera[]): void;
  148618. /**
  148619. * Enables the effect on given cameras
  148620. * @param cameras The camera to enable.
  148621. * @hidden
  148622. */
  148623. _enable(cameras: Camera): void;
  148624. /**
  148625. * Enables the effect on given cameras
  148626. * @param cameras The camera to enable.
  148627. * @hidden
  148628. */
  148629. _enable(cameras: Nullable<Camera[]>): void;
  148630. /**
  148631. * Disables the effect on the given cameras
  148632. * @param cameras The camera to disable.
  148633. * @hidden
  148634. */
  148635. _disable(cameras: Camera): void;
  148636. /**
  148637. * Disables the effect on the given cameras
  148638. * @param cameras The camera to disable.
  148639. * @hidden
  148640. */
  148641. _disable(cameras: Nullable<Camera[]>): void;
  148642. /**
  148643. * Gets a list of the post processes contained in the effect.
  148644. * @param camera The camera to get the post processes on.
  148645. * @returns The list of the post processes in the effect.
  148646. */
  148647. getPostProcesses(camera?: Camera): Nullable<Array<PostProcess>>;
  148648. }
  148649. }
  148650. declare module BABYLON {
  148651. /** @hidden */
  148652. export var extractHighlightsPixelShader: {
  148653. name: string;
  148654. shader: string;
  148655. };
  148656. }
  148657. declare module BABYLON {
  148658. /**
  148659. * 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.
  148660. */
  148661. export class ExtractHighlightsPostProcess extends PostProcess {
  148662. /**
  148663. * The luminance threshold, pixels below this value will be set to black.
  148664. */
  148665. threshold: number;
  148666. /** @hidden */
  148667. _exposure: number;
  148668. /**
  148669. * Post process which has the input texture to be used when performing highlight extraction
  148670. * @hidden
  148671. */
  148672. _inputPostProcess: Nullable<PostProcess>;
  148673. /**
  148674. * Gets a string identifying the name of the class
  148675. * @returns "ExtractHighlightsPostProcess" string
  148676. */
  148677. getClassName(): string;
  148678. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  148679. }
  148680. }
  148681. declare module BABYLON {
  148682. /** @hidden */
  148683. export var bloomMergePixelShader: {
  148684. name: string;
  148685. shader: string;
  148686. };
  148687. }
  148688. declare module BABYLON {
  148689. /**
  148690. * The BloomMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  148691. */
  148692. export class BloomMergePostProcess extends PostProcess {
  148693. /** Weight of the bloom to be added to the original input. */
  148694. weight: number;
  148695. /**
  148696. * Gets a string identifying the name of the class
  148697. * @returns "BloomMergePostProcess" string
  148698. */
  148699. getClassName(): string;
  148700. /**
  148701. * Creates a new instance of @see BloomMergePostProcess
  148702. * @param name The name of the effect.
  148703. * @param originalFromInput Post process which's input will be used for the merge.
  148704. * @param blurred Blurred highlights post process which's output will be used.
  148705. * @param weight Weight of the bloom to be added to the original input.
  148706. * @param options The required width/height ratio to downsize to before computing the render pass.
  148707. * @param camera The camera to apply the render pass to.
  148708. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  148709. * @param engine The engine which the post process will be applied. (default: current engine)
  148710. * @param reusable If the post process can be reused on the same frame. (default: false)
  148711. * @param textureType Type of textures used when performing the post process. (default: 0)
  148712. * @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)
  148713. */
  148714. constructor(name: string, originalFromInput: PostProcess, blurred: PostProcess,
  148715. /** Weight of the bloom to be added to the original input. */
  148716. weight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  148717. }
  148718. }
  148719. declare module BABYLON {
  148720. /**
  148721. * The bloom effect spreads bright areas of an image to simulate artifacts seen in cameras
  148722. */
  148723. export class BloomEffect extends PostProcessRenderEffect {
  148724. private bloomScale;
  148725. /**
  148726. * @hidden Internal
  148727. */
  148728. _effects: Array<PostProcess>;
  148729. /**
  148730. * @hidden Internal
  148731. */
  148732. _downscale: ExtractHighlightsPostProcess;
  148733. private _blurX;
  148734. private _blurY;
  148735. private _merge;
  148736. /**
  148737. * The luminance threshold to find bright areas of the image to bloom.
  148738. */
  148739. get threshold(): number;
  148740. set threshold(value: number);
  148741. /**
  148742. * The strength of the bloom.
  148743. */
  148744. get weight(): number;
  148745. set weight(value: number);
  148746. /**
  148747. * Specifies the size of the bloom blur kernel, relative to the final output size
  148748. */
  148749. get kernel(): number;
  148750. set kernel(value: number);
  148751. /**
  148752. * Creates a new instance of @see BloomEffect
  148753. * @param scene The scene the effect belongs to.
  148754. * @param bloomScale The ratio of the blur texture to the input texture that should be used to compute the bloom.
  148755. * @param bloomKernel The size of the kernel to be used when applying the blur.
  148756. * @param bloomWeight The the strength of bloom.
  148757. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  148758. * @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)
  148759. */
  148760. constructor(scene: Scene, bloomScale: number, bloomWeight: number, bloomKernel: number, pipelineTextureType?: number, blockCompilation?: boolean);
  148761. /**
  148762. * Disposes each of the internal effects for a given camera.
  148763. * @param camera The camera to dispose the effect on.
  148764. */
  148765. disposeEffects(camera: Camera): void;
  148766. /**
  148767. * @hidden Internal
  148768. */
  148769. _updateEffects(): void;
  148770. /**
  148771. * Internal
  148772. * @returns if all the contained post processes are ready.
  148773. * @hidden
  148774. */
  148775. _isReady(): boolean;
  148776. }
  148777. }
  148778. declare module BABYLON {
  148779. /** @hidden */
  148780. export var chromaticAberrationPixelShader: {
  148781. name: string;
  148782. shader: string;
  148783. };
  148784. }
  148785. declare module BABYLON {
  148786. /**
  148787. * The ChromaticAberrationPostProcess separates the rgb channels in an image to produce chromatic distortion around the edges of the screen
  148788. */
  148789. export class ChromaticAberrationPostProcess extends PostProcess {
  148790. /**
  148791. * The amount of seperation of rgb channels (default: 30)
  148792. */
  148793. aberrationAmount: number;
  148794. /**
  148795. * The amount the effect will increase for pixels closer to the edge of the screen. (default: 0)
  148796. */
  148797. radialIntensity: number;
  148798. /**
  148799. * 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))
  148800. */
  148801. direction: Vector2;
  148802. /**
  148803. * 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))
  148804. */
  148805. centerPosition: Vector2;
  148806. /** The width of the screen to apply the effect on */
  148807. screenWidth: number;
  148808. /** The height of the screen to apply the effect on */
  148809. screenHeight: number;
  148810. /**
  148811. * Gets a string identifying the name of the class
  148812. * @returns "ChromaticAberrationPostProcess" string
  148813. */
  148814. getClassName(): string;
  148815. /**
  148816. * Creates a new instance ChromaticAberrationPostProcess
  148817. * @param name The name of the effect.
  148818. * @param screenWidth The width of the screen to apply the effect on.
  148819. * @param screenHeight The height of the screen to apply the effect on.
  148820. * @param options The required width/height ratio to downsize to before computing the render pass.
  148821. * @param camera The camera to apply the render pass to.
  148822. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  148823. * @param engine The engine which the post process will be applied. (default: current engine)
  148824. * @param reusable If the post process can be reused on the same frame. (default: false)
  148825. * @param textureType Type of textures used when performing the post process. (default: 0)
  148826. * @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)
  148827. */
  148828. constructor(name: string, screenWidth: number, screenHeight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  148829. /** @hidden */
  148830. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): Nullable<ChromaticAberrationPostProcess>;
  148831. }
  148832. }
  148833. declare module BABYLON {
  148834. /** @hidden */
  148835. export var circleOfConfusionPixelShader: {
  148836. name: string;
  148837. shader: string;
  148838. };
  148839. }
  148840. declare module BABYLON {
  148841. /**
  148842. * The CircleOfConfusionPostProcess computes the circle of confusion value for each pixel given required lens parameters. See https://en.wikipedia.org/wiki/Circle_of_confusion
  148843. */
  148844. export class CircleOfConfusionPostProcess extends PostProcess {
  148845. /**
  148846. * 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.
  148847. */
  148848. lensSize: number;
  148849. /**
  148850. * F-Stop of the effect's camera. The diamater of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  148851. */
  148852. fStop: number;
  148853. /**
  148854. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  148855. */
  148856. focusDistance: number;
  148857. /**
  148858. * Focal length of the effect's camera in scene units/1000 (eg. millimeter). (default: 50)
  148859. */
  148860. focalLength: number;
  148861. /**
  148862. * Gets a string identifying the name of the class
  148863. * @returns "CircleOfConfusionPostProcess" string
  148864. */
  148865. getClassName(): string;
  148866. private _depthTexture;
  148867. /**
  148868. * Creates a new instance CircleOfConfusionPostProcess
  148869. * @param name The name of the effect.
  148870. * @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.
  148871. * @param options The required width/height ratio to downsize to before computing the render pass.
  148872. * @param camera The camera to apply the render pass to.
  148873. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  148874. * @param engine The engine which the post process will be applied. (default: current engine)
  148875. * @param reusable If the post process can be reused on the same frame. (default: false)
  148876. * @param textureType Type of textures used when performing the post process. (default: 0)
  148877. * @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)
  148878. */
  148879. constructor(name: string, depthTexture: Nullable<RenderTargetTexture>, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  148880. /**
  148881. * 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.
  148882. */
  148883. set depthTexture(value: RenderTargetTexture);
  148884. }
  148885. }
  148886. declare module BABYLON {
  148887. /** @hidden */
  148888. export var colorCorrectionPixelShader: {
  148889. name: string;
  148890. shader: string;
  148891. };
  148892. }
  148893. declare module BABYLON {
  148894. /**
  148895. *
  148896. * This post-process allows the modification of rendered colors by using
  148897. * a 'look-up table' (LUT). This effect is also called Color Grading.
  148898. *
  148899. * The object needs to be provided an url to a texture containing the color
  148900. * look-up table: the texture must be 256 pixels wide and 16 pixels high.
  148901. * Use an image editing software to tweak the LUT to match your needs.
  148902. *
  148903. * For an example of a color LUT, see here:
  148904. * @see http://udn.epicgames.com/Three/rsrc/Three/ColorGrading/RGBTable16x1.png
  148905. * For explanations on color grading, see here:
  148906. * @see http://udn.epicgames.com/Three/ColorGrading.html
  148907. *
  148908. */
  148909. export class ColorCorrectionPostProcess extends PostProcess {
  148910. private _colorTableTexture;
  148911. /**
  148912. * Gets the color table url used to create the LUT texture
  148913. */
  148914. colorTableUrl: string;
  148915. /**
  148916. * Gets a string identifying the name of the class
  148917. * @returns "ColorCorrectionPostProcess" string
  148918. */
  148919. getClassName(): string;
  148920. constructor(name: string, colorTableUrl: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  148921. /** @hidden */
  148922. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): Nullable<ColorCorrectionPostProcess>;
  148923. }
  148924. }
  148925. declare module BABYLON {
  148926. /** @hidden */
  148927. export var convolutionPixelShader: {
  148928. name: string;
  148929. shader: string;
  148930. };
  148931. }
  148932. declare module BABYLON {
  148933. /**
  148934. * The ConvolutionPostProcess applies a 3x3 kernel to every pixel of the
  148935. * input texture to perform effects such as edge detection or sharpening
  148936. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  148937. */
  148938. export class ConvolutionPostProcess extends PostProcess {
  148939. /** Array of 9 values corresponding to the 3x3 kernel to be applied */
  148940. kernel: number[];
  148941. /**
  148942. * Gets a string identifying the name of the class
  148943. * @returns "ConvolutionPostProcess" string
  148944. */
  148945. getClassName(): string;
  148946. /**
  148947. * Creates a new instance ConvolutionPostProcess
  148948. * @param name The name of the effect.
  148949. * @param kernel Array of 9 values corresponding to the 3x3 kernel to be applied
  148950. * @param options The required width/height ratio to downsize to before computing the render pass.
  148951. * @param camera The camera to apply the render pass to.
  148952. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  148953. * @param engine The engine which the post process will be applied. (default: current engine)
  148954. * @param reusable If the post process can be reused on the same frame. (default: false)
  148955. * @param textureType Type of textures used when performing the post process. (default: 0)
  148956. */
  148957. constructor(name: string, kernel: number[], options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  148958. /** @hidden */
  148959. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): Nullable<ConvolutionPostProcess>;
  148960. /**
  148961. * Edge detection 0 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  148962. */
  148963. static EdgeDetect0Kernel: number[];
  148964. /**
  148965. * Edge detection 1 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  148966. */
  148967. static EdgeDetect1Kernel: number[];
  148968. /**
  148969. * Edge detection 2 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  148970. */
  148971. static EdgeDetect2Kernel: number[];
  148972. /**
  148973. * Kernel to sharpen an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  148974. */
  148975. static SharpenKernel: number[];
  148976. /**
  148977. * Kernel to emboss an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  148978. */
  148979. static EmbossKernel: number[];
  148980. /**
  148981. * Kernel to blur an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  148982. */
  148983. static GaussianKernel: number[];
  148984. }
  148985. }
  148986. declare module BABYLON {
  148987. /**
  148988. * The DepthOfFieldBlurPostProcess applied a blur in a give direction.
  148989. * This blur differs from the standard BlurPostProcess as it attempts to avoid blurring pixels
  148990. * based on samples that have a large difference in distance than the center pixel.
  148991. * See section 2.6.2 http://fileadmin.cs.lth.se/cs/education/edan35/lectures/12dof.pdf
  148992. */
  148993. export class DepthOfFieldBlurPostProcess extends BlurPostProcess {
  148994. /**
  148995. * The direction the blur should be applied
  148996. */
  148997. direction: Vector2;
  148998. /**
  148999. * Gets a string identifying the name of the class
  149000. * @returns "DepthOfFieldBlurPostProcess" string
  149001. */
  149002. getClassName(): string;
  149003. /**
  149004. * Creates a new instance CircleOfConfusionPostProcess
  149005. * @param name The name of the effect.
  149006. * @param scene The scene the effect belongs to.
  149007. * @param direction The direction the blur should be applied.
  149008. * @param kernel The size of the kernel used to blur.
  149009. * @param options The required width/height ratio to downsize to before computing the render pass.
  149010. * @param camera The camera to apply the render pass to.
  149011. * @param circleOfConfusion The circle of confusion + depth map to be used to avoid blurring accross edges
  149012. * @param imageToBlur The image to apply the blur to (default: Current rendered frame)
  149013. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  149014. * @param engine The engine which the post process will be applied. (default: current engine)
  149015. * @param reusable If the post process can be reused on the same frame. (default: false)
  149016. * @param textureType Type of textures used when performing the post process. (default: 0)
  149017. * @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)
  149018. */
  149019. 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);
  149020. }
  149021. }
  149022. declare module BABYLON {
  149023. /** @hidden */
  149024. export var depthOfFieldMergePixelShader: {
  149025. name: string;
  149026. shader: string;
  149027. };
  149028. }
  149029. declare module BABYLON {
  149030. /**
  149031. * Options to be set when merging outputs from the default pipeline.
  149032. */
  149033. export class DepthOfFieldMergePostProcessOptions {
  149034. /**
  149035. * The original image to merge on top of
  149036. */
  149037. originalFromInput: PostProcess;
  149038. /**
  149039. * Parameters to perform the merge of the depth of field effect
  149040. */
  149041. depthOfField?: {
  149042. circleOfConfusion: PostProcess;
  149043. blurSteps: Array<PostProcess>;
  149044. };
  149045. /**
  149046. * Parameters to perform the merge of bloom effect
  149047. */
  149048. bloom?: {
  149049. blurred: PostProcess;
  149050. weight: number;
  149051. };
  149052. }
  149053. /**
  149054. * The DepthOfFieldMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  149055. */
  149056. export class DepthOfFieldMergePostProcess extends PostProcess {
  149057. private blurSteps;
  149058. /**
  149059. * Gets a string identifying the name of the class
  149060. * @returns "DepthOfFieldMergePostProcess" string
  149061. */
  149062. getClassName(): string;
  149063. /**
  149064. * Creates a new instance of DepthOfFieldMergePostProcess
  149065. * @param name The name of the effect.
  149066. * @param originalFromInput Post process which's input will be used for the merge.
  149067. * @param circleOfConfusion Circle of confusion post process which's output will be used to blur each pixel.
  149068. * @param blurSteps Blur post processes from low to high which will be mixed with the original image.
  149069. * @param options The required width/height ratio to downsize to before computing the render pass.
  149070. * @param camera The camera to apply the render pass to.
  149071. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  149072. * @param engine The engine which the post process will be applied. (default: current engine)
  149073. * @param reusable If the post process can be reused on the same frame. (default: false)
  149074. * @param textureType Type of textures used when performing the post process. (default: 0)
  149075. * @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)
  149076. */
  149077. 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);
  149078. /**
  149079. * Updates the effect with the current post process compile time values and recompiles the shader.
  149080. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  149081. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  149082. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  149083. * @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
  149084. * @param onCompiled Called when the shader has been compiled.
  149085. * @param onError Called if there is an error when compiling a shader.
  149086. */
  149087. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  149088. }
  149089. }
  149090. declare module BABYLON {
  149091. /**
  149092. * Specifies the level of max blur that should be applied when using the depth of field effect
  149093. */
  149094. export enum DepthOfFieldEffectBlurLevel {
  149095. /**
  149096. * Subtle blur
  149097. */
  149098. Low = 0,
  149099. /**
  149100. * Medium blur
  149101. */
  149102. Medium = 1,
  149103. /**
  149104. * Large blur
  149105. */
  149106. High = 2
  149107. }
  149108. /**
  149109. * The depth of field effect applies a blur to objects that are closer or further from where the camera is focusing.
  149110. */
  149111. export class DepthOfFieldEffect extends PostProcessRenderEffect {
  149112. private _circleOfConfusion;
  149113. /**
  149114. * @hidden Internal, blurs from high to low
  149115. */
  149116. _depthOfFieldBlurX: Array<DepthOfFieldBlurPostProcess>;
  149117. private _depthOfFieldBlurY;
  149118. private _dofMerge;
  149119. /**
  149120. * @hidden Internal post processes in depth of field effect
  149121. */
  149122. _effects: Array<PostProcess>;
  149123. /**
  149124. * The focal the length of the camera used in the effect in scene units/1000 (eg. millimeter)
  149125. */
  149126. set focalLength(value: number);
  149127. get focalLength(): number;
  149128. /**
  149129. * F-Stop of the effect's camera. The diameter of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  149130. */
  149131. set fStop(value: number);
  149132. get fStop(): number;
  149133. /**
  149134. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  149135. */
  149136. set focusDistance(value: number);
  149137. get focusDistance(): number;
  149138. /**
  149139. * 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.
  149140. */
  149141. set lensSize(value: number);
  149142. get lensSize(): number;
  149143. /**
  149144. * Creates a new instance DepthOfFieldEffect
  149145. * @param scene The scene the effect belongs to.
  149146. * @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.
  149147. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  149148. * @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)
  149149. */
  149150. constructor(scene: Scene, depthTexture: Nullable<RenderTargetTexture>, blurLevel?: DepthOfFieldEffectBlurLevel, pipelineTextureType?: number, blockCompilation?: boolean);
  149151. /**
  149152. * Get the current class name of the current effet
  149153. * @returns "DepthOfFieldEffect"
  149154. */
  149155. getClassName(): string;
  149156. /**
  149157. * 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.
  149158. */
  149159. set depthTexture(value: RenderTargetTexture);
  149160. /**
  149161. * Disposes each of the internal effects for a given camera.
  149162. * @param camera The camera to dispose the effect on.
  149163. */
  149164. disposeEffects(camera: Camera): void;
  149165. /**
  149166. * @hidden Internal
  149167. */
  149168. _updateEffects(): void;
  149169. /**
  149170. * Internal
  149171. * @returns if all the contained post processes are ready.
  149172. * @hidden
  149173. */
  149174. _isReady(): boolean;
  149175. }
  149176. }
  149177. declare module BABYLON {
  149178. /** @hidden */
  149179. export var displayPassPixelShader: {
  149180. name: string;
  149181. shader: string;
  149182. };
  149183. }
  149184. declare module BABYLON {
  149185. /**
  149186. * DisplayPassPostProcess which produces an output the same as it's input
  149187. */
  149188. export class DisplayPassPostProcess extends PostProcess {
  149189. /**
  149190. * Gets a string identifying the name of the class
  149191. * @returns "DisplayPassPostProcess" string
  149192. */
  149193. getClassName(): string;
  149194. /**
  149195. * Creates the DisplayPassPostProcess
  149196. * @param name The name of the effect.
  149197. * @param options The required width/height ratio to downsize to before computing the render pass.
  149198. * @param camera The camera to apply the render pass to.
  149199. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  149200. * @param engine The engine which the post process will be applied. (default: current engine)
  149201. * @param reusable If the post process can be reused on the same frame. (default: false)
  149202. */
  149203. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  149204. /** @hidden */
  149205. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): Nullable<DisplayPassPostProcess>;
  149206. }
  149207. }
  149208. declare module BABYLON {
  149209. /** @hidden */
  149210. export var filterPixelShader: {
  149211. name: string;
  149212. shader: string;
  149213. };
  149214. }
  149215. declare module BABYLON {
  149216. /**
  149217. * Applies a kernel filter to the image
  149218. */
  149219. export class FilterPostProcess extends PostProcess {
  149220. /** The matrix to be applied to the image */
  149221. kernelMatrix: Matrix;
  149222. /**
  149223. * Gets a string identifying the name of the class
  149224. * @returns "FilterPostProcess" string
  149225. */
  149226. getClassName(): string;
  149227. /**
  149228. *
  149229. * @param name The name of the effect.
  149230. * @param kernelMatrix The matrix to be applied to the image
  149231. * @param options The required width/height ratio to downsize to before computing the render pass.
  149232. * @param camera The camera to apply the render pass to.
  149233. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  149234. * @param engine The engine which the post process will be applied. (default: current engine)
  149235. * @param reusable If the post process can be reused on the same frame. (default: false)
  149236. */
  149237. constructor(name: string, kernelMatrix: Matrix, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  149238. /** @hidden */
  149239. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): Nullable<FilterPostProcess>;
  149240. }
  149241. }
  149242. declare module BABYLON {
  149243. /** @hidden */
  149244. export var fxaaPixelShader: {
  149245. name: string;
  149246. shader: string;
  149247. };
  149248. }
  149249. declare module BABYLON {
  149250. /** @hidden */
  149251. export var fxaaVertexShader: {
  149252. name: string;
  149253. shader: string;
  149254. };
  149255. }
  149256. declare module BABYLON {
  149257. /**
  149258. * Fxaa post process
  149259. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#fxaa
  149260. */
  149261. export class FxaaPostProcess extends PostProcess {
  149262. /**
  149263. * Gets a string identifying the name of the class
  149264. * @returns "FxaaPostProcess" string
  149265. */
  149266. getClassName(): string;
  149267. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  149268. private _getDefines;
  149269. /** @hidden */
  149270. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): FxaaPostProcess;
  149271. }
  149272. }
  149273. declare module BABYLON {
  149274. /** @hidden */
  149275. export var grainPixelShader: {
  149276. name: string;
  149277. shader: string;
  149278. };
  149279. }
  149280. declare module BABYLON {
  149281. /**
  149282. * The GrainPostProcess adds noise to the image at mid luminance levels
  149283. */
  149284. export class GrainPostProcess extends PostProcess {
  149285. /**
  149286. * The intensity of the grain added (default: 30)
  149287. */
  149288. intensity: number;
  149289. /**
  149290. * If the grain should be randomized on every frame
  149291. */
  149292. animated: boolean;
  149293. /**
  149294. * Gets a string identifying the name of the class
  149295. * @returns "GrainPostProcess" string
  149296. */
  149297. getClassName(): string;
  149298. /**
  149299. * Creates a new instance of @see GrainPostProcess
  149300. * @param name The name of the effect.
  149301. * @param options The required width/height ratio to downsize to before computing the render pass.
  149302. * @param camera The camera to apply the render pass to.
  149303. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  149304. * @param engine The engine which the post process will be applied. (default: current engine)
  149305. * @param reusable If the post process can be reused on the same frame. (default: false)
  149306. * @param textureType Type of textures used when performing the post process. (default: 0)
  149307. * @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)
  149308. */
  149309. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  149310. /** @hidden */
  149311. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): GrainPostProcess;
  149312. }
  149313. }
  149314. declare module BABYLON {
  149315. /** @hidden */
  149316. export var highlightsPixelShader: {
  149317. name: string;
  149318. shader: string;
  149319. };
  149320. }
  149321. declare module BABYLON {
  149322. /**
  149323. * Extracts highlights from the image
  149324. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  149325. */
  149326. export class HighlightsPostProcess extends PostProcess {
  149327. /**
  149328. * Gets a string identifying the name of the class
  149329. * @returns "HighlightsPostProcess" string
  149330. */
  149331. getClassName(): string;
  149332. /**
  149333. * Extracts highlights from the image
  149334. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  149335. * @param name The name of the effect.
  149336. * @param options The required width/height ratio to downsize to before computing the render pass.
  149337. * @param camera The camera to apply the render pass to.
  149338. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  149339. * @param engine The engine which the post process will be applied. (default: current engine)
  149340. * @param reusable If the post process can be reused on the same frame. (default: false)
  149341. * @param textureType Type of texture for the post process (default: Engine.TEXTURETYPE_UNSIGNED_INT)
  149342. */
  149343. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  149344. }
  149345. }
  149346. declare module BABYLON {
  149347. /** @hidden */
  149348. export var mrtFragmentDeclaration: {
  149349. name: string;
  149350. shader: string;
  149351. };
  149352. }
  149353. declare module BABYLON {
  149354. /** @hidden */
  149355. export var geometryPixelShader: {
  149356. name: string;
  149357. shader: string;
  149358. };
  149359. }
  149360. declare module BABYLON {
  149361. /** @hidden */
  149362. export var geometryVertexShader: {
  149363. name: string;
  149364. shader: string;
  149365. };
  149366. }
  149367. declare module BABYLON {
  149368. /** @hidden */
  149369. interface ISavedTransformationMatrix {
  149370. world: Matrix;
  149371. viewProjection: Matrix;
  149372. }
  149373. /**
  149374. * This renderer is helpfull to fill one of the render target with a geometry buffer.
  149375. */
  149376. export class GeometryBufferRenderer {
  149377. /**
  149378. * Constant used to retrieve the position texture index in the G-Buffer textures array
  149379. * using getIndex(GeometryBufferRenderer.POSITION_TEXTURE_INDEX)
  149380. */
  149381. static readonly POSITION_TEXTURE_TYPE: number;
  149382. /**
  149383. * Constant used to retrieve the velocity texture index in the G-Buffer textures array
  149384. * using getIndex(GeometryBufferRenderer.VELOCITY_TEXTURE_INDEX)
  149385. */
  149386. static readonly VELOCITY_TEXTURE_TYPE: number;
  149387. /**
  149388. * Constant used to retrieve the reflectivity texture index in the G-Buffer textures array
  149389. * using the getIndex(GeometryBufferRenderer.REFLECTIVITY_TEXTURE_TYPE)
  149390. */
  149391. static readonly REFLECTIVITY_TEXTURE_TYPE: number;
  149392. /**
  149393. * Dictionary used to store the previous transformation matrices of each rendered mesh
  149394. * in order to compute objects velocities when enableVelocity is set to "true"
  149395. * @hidden
  149396. */
  149397. _previousTransformationMatrices: {
  149398. [index: number]: ISavedTransformationMatrix;
  149399. };
  149400. /**
  149401. * Dictionary used to store the previous bones transformation matrices of each rendered mesh
  149402. * in order to compute objects velocities when enableVelocity is set to "true"
  149403. * @hidden
  149404. */
  149405. _previousBonesTransformationMatrices: {
  149406. [index: number]: Float32Array;
  149407. };
  149408. /**
  149409. * Array used to store the ignored skinned meshes while computing velocity map (typically used by the motion blur post-process).
  149410. * Avoids computing bones velocities and computes only mesh's velocity itself (position, rotation, scaling).
  149411. */
  149412. excludedSkinnedMeshesFromVelocity: AbstractMesh[];
  149413. /** Gets or sets a boolean indicating if transparent meshes should be rendered */
  149414. renderTransparentMeshes: boolean;
  149415. private _scene;
  149416. private _resizeObserver;
  149417. private _multiRenderTarget;
  149418. private _ratio;
  149419. private _enablePosition;
  149420. private _enableVelocity;
  149421. private _enableReflectivity;
  149422. private _positionIndex;
  149423. private _velocityIndex;
  149424. private _reflectivityIndex;
  149425. protected _effect: Effect;
  149426. protected _cachedDefines: string;
  149427. /**
  149428. * Set the render list (meshes to be rendered) used in the G buffer.
  149429. */
  149430. set renderList(meshes: Mesh[]);
  149431. /**
  149432. * Gets wether or not G buffer are supported by the running hardware.
  149433. * This requires draw buffer supports
  149434. */
  149435. get isSupported(): boolean;
  149436. /**
  149437. * Returns the index of the given texture type in the G-Buffer textures array
  149438. * @param textureType The texture type constant. For example GeometryBufferRenderer.POSITION_TEXTURE_INDEX
  149439. * @returns the index of the given texture type in the G-Buffer textures array
  149440. */
  149441. getTextureIndex(textureType: number): number;
  149442. /**
  149443. * Gets a boolean indicating if objects positions are enabled for the G buffer.
  149444. */
  149445. get enablePosition(): boolean;
  149446. /**
  149447. * Sets whether or not objects positions are enabled for the G buffer.
  149448. */
  149449. set enablePosition(enable: boolean);
  149450. /**
  149451. * Gets a boolean indicating if objects velocities are enabled for the G buffer.
  149452. */
  149453. get enableVelocity(): boolean;
  149454. /**
  149455. * Sets wether or not objects velocities are enabled for the G buffer.
  149456. */
  149457. set enableVelocity(enable: boolean);
  149458. /**
  149459. * Gets a boolean indicating if objects roughness are enabled in the G buffer.
  149460. */
  149461. get enableReflectivity(): boolean;
  149462. /**
  149463. * Sets wether or not objects roughness are enabled for the G buffer.
  149464. */
  149465. set enableReflectivity(enable: boolean);
  149466. /**
  149467. * Gets the scene associated with the buffer.
  149468. */
  149469. get scene(): Scene;
  149470. /**
  149471. * Gets the ratio used by the buffer during its creation.
  149472. * How big is the buffer related to the main canvas.
  149473. */
  149474. get ratio(): number;
  149475. /** @hidden */
  149476. static _SceneComponentInitialization: (scene: Scene) => void;
  149477. /**
  149478. * Creates a new G Buffer for the scene
  149479. * @param scene The scene the buffer belongs to
  149480. * @param ratio How big is the buffer related to the main canvas.
  149481. */
  149482. constructor(scene: Scene, ratio?: number);
  149483. /**
  149484. * Checks wether everything is ready to render a submesh to the G buffer.
  149485. * @param subMesh the submesh to check readiness for
  149486. * @param useInstances is the mesh drawn using instance or not
  149487. * @returns true if ready otherwise false
  149488. */
  149489. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  149490. /**
  149491. * Gets the current underlying G Buffer.
  149492. * @returns the buffer
  149493. */
  149494. getGBuffer(): MultiRenderTarget;
  149495. /**
  149496. * Gets the number of samples used to render the buffer (anti aliasing).
  149497. */
  149498. get samples(): number;
  149499. /**
  149500. * Sets the number of samples used to render the buffer (anti aliasing).
  149501. */
  149502. set samples(value: number);
  149503. /**
  149504. * Disposes the renderer and frees up associated resources.
  149505. */
  149506. dispose(): void;
  149507. protected _createRenderTargets(): void;
  149508. private _copyBonesTransformationMatrices;
  149509. }
  149510. }
  149511. declare module BABYLON {
  149512. interface Scene {
  149513. /** @hidden (Backing field) */
  149514. _geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  149515. /**
  149516. * Gets or Sets the current geometry buffer associated to the scene.
  149517. */
  149518. geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  149519. /**
  149520. * Enables a GeometryBufferRender and associates it with the scene
  149521. * @param ratio defines the scaling ratio to apply to the renderer (1 by default which means same resolution)
  149522. * @returns the GeometryBufferRenderer
  149523. */
  149524. enableGeometryBufferRenderer(ratio?: number): Nullable<GeometryBufferRenderer>;
  149525. /**
  149526. * Disables the GeometryBufferRender associated with the scene
  149527. */
  149528. disableGeometryBufferRenderer(): void;
  149529. }
  149530. /**
  149531. * Defines the Geometry Buffer scene component responsible to manage a G-Buffer useful
  149532. * in several rendering techniques.
  149533. */
  149534. export class GeometryBufferRendererSceneComponent implements ISceneComponent {
  149535. /**
  149536. * The component name helpful to identify the component in the list of scene components.
  149537. */
  149538. readonly name: string;
  149539. /**
  149540. * The scene the component belongs to.
  149541. */
  149542. scene: Scene;
  149543. /**
  149544. * Creates a new instance of the component for the given scene
  149545. * @param scene Defines the scene to register the component in
  149546. */
  149547. constructor(scene: Scene);
  149548. /**
  149549. * Registers the component in a given scene
  149550. */
  149551. register(): void;
  149552. /**
  149553. * Rebuilds the elements related to this component in case of
  149554. * context lost for instance.
  149555. */
  149556. rebuild(): void;
  149557. /**
  149558. * Disposes the component and the associated ressources
  149559. */
  149560. dispose(): void;
  149561. private _gatherRenderTargets;
  149562. }
  149563. }
  149564. declare module BABYLON {
  149565. /** @hidden */
  149566. export var motionBlurPixelShader: {
  149567. name: string;
  149568. shader: string;
  149569. };
  149570. }
  149571. declare module BABYLON {
  149572. /**
  149573. * The Motion Blur Post Process which blurs an image based on the objects velocity in scene.
  149574. * Velocity can be affected by each object's rotation, position and scale depending on the transformation speed.
  149575. * As an example, all you have to do is to create the post-process:
  149576. * var mb = new BABYLON.MotionBlurPostProcess(
  149577. * 'mb', // The name of the effect.
  149578. * scene, // The scene containing the objects to blur according to their velocity.
  149579. * 1.0, // The required width/height ratio to downsize to before computing the render pass.
  149580. * camera // The camera to apply the render pass to.
  149581. * );
  149582. * Then, all objects moving, rotating and/or scaling will be blurred depending on the transformation speed.
  149583. */
  149584. export class MotionBlurPostProcess extends PostProcess {
  149585. /**
  149586. * Defines how much the image is blurred by the movement. Default value is equal to 1
  149587. */
  149588. motionStrength: number;
  149589. /**
  149590. * Gets the number of iterations are used for motion blur quality. Default value is equal to 32
  149591. */
  149592. get motionBlurSamples(): number;
  149593. /**
  149594. * Sets the number of iterations to be used for motion blur quality
  149595. */
  149596. set motionBlurSamples(samples: number);
  149597. private _motionBlurSamples;
  149598. private _geometryBufferRenderer;
  149599. /**
  149600. * Gets a string identifying the name of the class
  149601. * @returns "MotionBlurPostProcess" string
  149602. */
  149603. getClassName(): string;
  149604. /**
  149605. * Creates a new instance MotionBlurPostProcess
  149606. * @param name The name of the effect.
  149607. * @param scene The scene containing the objects to blur according to their velocity.
  149608. * @param options The required width/height ratio to downsize to before computing the render pass.
  149609. * @param camera The camera to apply the render pass to.
  149610. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  149611. * @param engine The engine which the post process will be applied. (default: current engine)
  149612. * @param reusable If the post process can be reused on the same frame. (default: false)
  149613. * @param textureType Type of textures used when performing the post process. (default: 0)
  149614. * @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)
  149615. */
  149616. constructor(name: string, scene: Scene, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  149617. /**
  149618. * Excludes the given skinned mesh from computing bones velocities.
  149619. * 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.
  149620. * @param skinnedMesh The mesh containing the skeleton to ignore when computing the velocity map.
  149621. */
  149622. excludeSkinnedMesh(skinnedMesh: AbstractMesh): void;
  149623. /**
  149624. * Removes the given skinned mesh from the excluded meshes to integrate bones velocities while rendering the velocity map.
  149625. * @param skinnedMesh The mesh containing the skeleton that has been ignored previously.
  149626. * @see excludeSkinnedMesh to exclude a skinned mesh from bones velocity computation.
  149627. */
  149628. removeExcludedSkinnedMesh(skinnedMesh: AbstractMesh): void;
  149629. /**
  149630. * Disposes the post process.
  149631. * @param camera The camera to dispose the post process on.
  149632. */
  149633. dispose(camera?: Camera): void;
  149634. /** @hidden */
  149635. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): Nullable<MotionBlurPostProcess>;
  149636. }
  149637. }
  149638. declare module BABYLON {
  149639. /** @hidden */
  149640. export var refractionPixelShader: {
  149641. name: string;
  149642. shader: string;
  149643. };
  149644. }
  149645. declare module BABYLON {
  149646. /**
  149647. * Post process which applies a refractin texture
  149648. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  149649. */
  149650. export class RefractionPostProcess extends PostProcess {
  149651. private _refTexture;
  149652. private _ownRefractionTexture;
  149653. /** the base color of the refraction (used to taint the rendering) */
  149654. color: Color3;
  149655. /** simulated refraction depth */
  149656. depth: number;
  149657. /** the coefficient of the base color (0 to remove base color tainting) */
  149658. colorLevel: number;
  149659. /** Gets the url used to load the refraction texture */
  149660. refractionTextureUrl: string;
  149661. /**
  149662. * Gets or sets the refraction texture
  149663. * Please note that you are responsible for disposing the texture if you set it manually
  149664. */
  149665. get refractionTexture(): Texture;
  149666. set refractionTexture(value: Texture);
  149667. /**
  149668. * Gets a string identifying the name of the class
  149669. * @returns "RefractionPostProcess" string
  149670. */
  149671. getClassName(): string;
  149672. /**
  149673. * Initializes the RefractionPostProcess
  149674. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  149675. * @param name The name of the effect.
  149676. * @param refractionTextureUrl Url of the refraction texture to use
  149677. * @param color the base color of the refraction (used to taint the rendering)
  149678. * @param depth simulated refraction depth
  149679. * @param colorLevel the coefficient of the base color (0 to remove base color tainting)
  149680. * @param camera The camera to apply the render pass to.
  149681. * @param options The required width/height ratio to downsize to before computing the render pass.
  149682. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  149683. * @param engine The engine which the post process will be applied. (default: current engine)
  149684. * @param reusable If the post process can be reused on the same frame. (default: false)
  149685. */
  149686. constructor(name: string, refractionTextureUrl: string, color: Color3, depth: number, colorLevel: number, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  149687. /**
  149688. * Disposes of the post process
  149689. * @param camera Camera to dispose post process on
  149690. */
  149691. dispose(camera: Camera): void;
  149692. /** @hidden */
  149693. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): RefractionPostProcess;
  149694. }
  149695. }
  149696. declare module BABYLON {
  149697. /** @hidden */
  149698. export var sharpenPixelShader: {
  149699. name: string;
  149700. shader: string;
  149701. };
  149702. }
  149703. declare module BABYLON {
  149704. /**
  149705. * The SharpenPostProcess applies a sharpen kernel to every pixel
  149706. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  149707. */
  149708. export class SharpenPostProcess extends PostProcess {
  149709. /**
  149710. * How much of the original color should be applied. Setting this to 0 will display edge detection. (default: 1)
  149711. */
  149712. colorAmount: number;
  149713. /**
  149714. * How much sharpness should be applied (default: 0.3)
  149715. */
  149716. edgeAmount: number;
  149717. /**
  149718. * Gets a string identifying the name of the class
  149719. * @returns "SharpenPostProcess" string
  149720. */
  149721. getClassName(): string;
  149722. /**
  149723. * Creates a new instance ConvolutionPostProcess
  149724. * @param name The name of the effect.
  149725. * @param options The required width/height ratio to downsize to before computing the render pass.
  149726. * @param camera The camera to apply the render pass to.
  149727. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  149728. * @param engine The engine which the post process will be applied. (default: current engine)
  149729. * @param reusable If the post process can be reused on the same frame. (default: false)
  149730. * @param textureType Type of textures used when performing the post process. (default: 0)
  149731. * @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)
  149732. */
  149733. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  149734. /** @hidden */
  149735. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): SharpenPostProcess;
  149736. }
  149737. }
  149738. declare module BABYLON {
  149739. /**
  149740. * PostProcessRenderPipeline
  149741. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  149742. */
  149743. export class PostProcessRenderPipeline {
  149744. private engine;
  149745. private _renderEffects;
  149746. private _renderEffectsForIsolatedPass;
  149747. /**
  149748. * List of inspectable custom properties (used by the Inspector)
  149749. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  149750. */
  149751. inspectableCustomProperties: IInspectable[];
  149752. /**
  149753. * @hidden
  149754. */
  149755. protected _cameras: Camera[];
  149756. /** @hidden */
  149757. _name: string;
  149758. /**
  149759. * Gets pipeline name
  149760. */
  149761. get name(): string;
  149762. /** Gets the list of attached cameras */
  149763. get cameras(): Camera[];
  149764. /**
  149765. * Initializes a PostProcessRenderPipeline
  149766. * @param engine engine to add the pipeline to
  149767. * @param name name of the pipeline
  149768. */
  149769. constructor(engine: Engine, name: string);
  149770. /**
  149771. * Gets the class name
  149772. * @returns "PostProcessRenderPipeline"
  149773. */
  149774. getClassName(): string;
  149775. /**
  149776. * If all the render effects in the pipeline are supported
  149777. */
  149778. get isSupported(): boolean;
  149779. /**
  149780. * Adds an effect to the pipeline
  149781. * @param renderEffect the effect to add
  149782. */
  149783. addEffect(renderEffect: PostProcessRenderEffect): void;
  149784. /** @hidden */
  149785. _rebuild(): void;
  149786. /** @hidden */
  149787. _enableEffect(renderEffectName: string, cameras: Camera): void;
  149788. /** @hidden */
  149789. _enableEffect(renderEffectName: string, cameras: Camera[]): void;
  149790. /** @hidden */
  149791. _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  149792. /** @hidden */
  149793. _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  149794. /** @hidden */
  149795. _attachCameras(cameras: Camera, unique: boolean): void;
  149796. /** @hidden */
  149797. _attachCameras(cameras: Camera[], unique: boolean): void;
  149798. /** @hidden */
  149799. _detachCameras(cameras: Camera): void;
  149800. /** @hidden */
  149801. _detachCameras(cameras: Nullable<Camera[]>): void;
  149802. /** @hidden */
  149803. _update(): void;
  149804. /** @hidden */
  149805. _reset(): void;
  149806. protected _enableMSAAOnFirstPostProcess(sampleCount: number): boolean;
  149807. /**
  149808. * Sets the required values to the prepass renderer.
  149809. * @param prePassRenderer defines the prepass renderer to setup.
  149810. * @returns true if the pre pass is needed.
  149811. */
  149812. setPrePassRenderer(prePassRenderer: PrePassRenderer): boolean;
  149813. /**
  149814. * Disposes of the pipeline
  149815. */
  149816. dispose(): void;
  149817. }
  149818. }
  149819. declare module BABYLON {
  149820. /**
  149821. * PostProcessRenderPipelineManager class
  149822. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  149823. */
  149824. export class PostProcessRenderPipelineManager {
  149825. private _renderPipelines;
  149826. /**
  149827. * Initializes a PostProcessRenderPipelineManager
  149828. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  149829. */
  149830. constructor();
  149831. /**
  149832. * Gets the list of supported render pipelines
  149833. */
  149834. get supportedPipelines(): PostProcessRenderPipeline[];
  149835. /**
  149836. * Adds a pipeline to the manager
  149837. * @param renderPipeline The pipeline to add
  149838. */
  149839. addPipeline(renderPipeline: PostProcessRenderPipeline): void;
  149840. /**
  149841. * Attaches a camera to the pipeline
  149842. * @param renderPipelineName The name of the pipeline to attach to
  149843. * @param cameras the camera to attach
  149844. * @param unique if the camera can be attached multiple times to the pipeline
  149845. */
  149846. attachCamerasToRenderPipeline(renderPipelineName: string, cameras: any | Camera[] | Camera, unique?: boolean): void;
  149847. /**
  149848. * Detaches a camera from the pipeline
  149849. * @param renderPipelineName The name of the pipeline to detach from
  149850. * @param cameras the camera to detach
  149851. */
  149852. detachCamerasFromRenderPipeline(renderPipelineName: string, cameras: any | Camera[] | Camera): void;
  149853. /**
  149854. * Enables an effect by name on a pipeline
  149855. * @param renderPipelineName the name of the pipeline to enable the effect in
  149856. * @param renderEffectName the name of the effect to enable
  149857. * @param cameras the cameras that the effect should be enabled on
  149858. */
  149859. enableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: any | Camera[] | Camera): void;
  149860. /**
  149861. * Disables an effect by name on a pipeline
  149862. * @param renderPipelineName the name of the pipeline to disable the effect in
  149863. * @param renderEffectName the name of the effect to disable
  149864. * @param cameras the cameras that the effect should be disabled on
  149865. */
  149866. disableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: any | Camera[] | Camera): void;
  149867. /**
  149868. * Updates the state of all contained render pipelines and disposes of any non supported pipelines
  149869. */
  149870. update(): void;
  149871. /** @hidden */
  149872. _rebuild(): void;
  149873. /**
  149874. * Disposes of the manager and pipelines
  149875. */
  149876. dispose(): void;
  149877. }
  149878. }
  149879. declare module BABYLON {
  149880. interface Scene {
  149881. /** @hidden (Backing field) */
  149882. _postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  149883. /**
  149884. * Gets the postprocess render pipeline manager
  149885. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  149886. * @see https://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  149887. */
  149888. readonly postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  149889. }
  149890. /**
  149891. * Defines the Render Pipeline scene component responsible to rendering pipelines
  149892. */
  149893. export class PostProcessRenderPipelineManagerSceneComponent implements ISceneComponent {
  149894. /**
  149895. * The component name helpfull to identify the component in the list of scene components.
  149896. */
  149897. readonly name: string;
  149898. /**
  149899. * The scene the component belongs to.
  149900. */
  149901. scene: Scene;
  149902. /**
  149903. * Creates a new instance of the component for the given scene
  149904. * @param scene Defines the scene to register the component in
  149905. */
  149906. constructor(scene: Scene);
  149907. /**
  149908. * Registers the component in a given scene
  149909. */
  149910. register(): void;
  149911. /**
  149912. * Rebuilds the elements related to this component in case of
  149913. * context lost for instance.
  149914. */
  149915. rebuild(): void;
  149916. /**
  149917. * Disposes the component and the associated ressources
  149918. */
  149919. dispose(): void;
  149920. private _gatherRenderTargets;
  149921. }
  149922. }
  149923. declare module BABYLON {
  149924. /**
  149925. * The default rendering pipeline can be added to a scene to apply common post processing effects such as anti-aliasing or depth of field.
  149926. * See https://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  149927. */
  149928. export class DefaultRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  149929. private _scene;
  149930. private _camerasToBeAttached;
  149931. /**
  149932. * ID of the sharpen post process,
  149933. */
  149934. private readonly SharpenPostProcessId;
  149935. /**
  149936. * @ignore
  149937. * ID of the image processing post process;
  149938. */
  149939. readonly ImageProcessingPostProcessId: string;
  149940. /**
  149941. * @ignore
  149942. * ID of the Fast Approximate Anti-Aliasing post process;
  149943. */
  149944. readonly FxaaPostProcessId: string;
  149945. /**
  149946. * ID of the chromatic aberration post process,
  149947. */
  149948. private readonly ChromaticAberrationPostProcessId;
  149949. /**
  149950. * ID of the grain post process
  149951. */
  149952. private readonly GrainPostProcessId;
  149953. /**
  149954. * Sharpen post process which will apply a sharpen convolution to enhance edges
  149955. */
  149956. sharpen: SharpenPostProcess;
  149957. private _sharpenEffect;
  149958. private bloom;
  149959. /**
  149960. * Depth of field effect, applies a blur based on how far away objects are from the focus distance.
  149961. */
  149962. depthOfField: DepthOfFieldEffect;
  149963. /**
  149964. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  149965. */
  149966. fxaa: FxaaPostProcess;
  149967. /**
  149968. * Image post processing pass used to perform operations such as tone mapping or color grading.
  149969. */
  149970. imageProcessing: ImageProcessingPostProcess;
  149971. /**
  149972. * Chromatic aberration post process which will shift rgb colors in the image
  149973. */
  149974. chromaticAberration: ChromaticAberrationPostProcess;
  149975. private _chromaticAberrationEffect;
  149976. /**
  149977. * Grain post process which add noise to the image
  149978. */
  149979. grain: GrainPostProcess;
  149980. private _grainEffect;
  149981. /**
  149982. * Glow post process which adds a glow to emissive areas of the image
  149983. */
  149984. private _glowLayer;
  149985. /**
  149986. * Animations which can be used to tweak settings over a period of time
  149987. */
  149988. animations: Animation[];
  149989. private _imageProcessingConfigurationObserver;
  149990. private _sharpenEnabled;
  149991. private _bloomEnabled;
  149992. private _depthOfFieldEnabled;
  149993. private _depthOfFieldBlurLevel;
  149994. private _fxaaEnabled;
  149995. private _imageProcessingEnabled;
  149996. private _defaultPipelineTextureType;
  149997. private _bloomScale;
  149998. private _chromaticAberrationEnabled;
  149999. private _grainEnabled;
  150000. private _buildAllowed;
  150001. /**
  150002. * Gets active scene
  150003. */
  150004. get scene(): Scene;
  150005. /**
  150006. * Enable or disable the sharpen process from the pipeline
  150007. */
  150008. set sharpenEnabled(enabled: boolean);
  150009. get sharpenEnabled(): boolean;
  150010. private _resizeObserver;
  150011. private _hardwareScaleLevel;
  150012. private _bloomKernel;
  150013. /**
  150014. * Specifies the size of the bloom blur kernel, relative to the final output size
  150015. */
  150016. get bloomKernel(): number;
  150017. set bloomKernel(value: number);
  150018. /**
  150019. * Specifies the weight of the bloom in the final rendering
  150020. */
  150021. private _bloomWeight;
  150022. /**
  150023. * Specifies the luma threshold for the area that will be blurred by the bloom
  150024. */
  150025. private _bloomThreshold;
  150026. private _hdr;
  150027. /**
  150028. * The strength of the bloom.
  150029. */
  150030. set bloomWeight(value: number);
  150031. get bloomWeight(): number;
  150032. /**
  150033. * The strength of the bloom.
  150034. */
  150035. set bloomThreshold(value: number);
  150036. get bloomThreshold(): number;
  150037. /**
  150038. * The scale of the bloom, lower value will provide better performance.
  150039. */
  150040. set bloomScale(value: number);
  150041. get bloomScale(): number;
  150042. /**
  150043. * Enable or disable the bloom from the pipeline
  150044. */
  150045. set bloomEnabled(enabled: boolean);
  150046. get bloomEnabled(): boolean;
  150047. private _rebuildBloom;
  150048. /**
  150049. * If the depth of field is enabled.
  150050. */
  150051. get depthOfFieldEnabled(): boolean;
  150052. set depthOfFieldEnabled(enabled: boolean);
  150053. /**
  150054. * Blur level of the depth of field effect. (Higher blur will effect performance)
  150055. */
  150056. get depthOfFieldBlurLevel(): DepthOfFieldEffectBlurLevel;
  150057. set depthOfFieldBlurLevel(value: DepthOfFieldEffectBlurLevel);
  150058. /**
  150059. * If the anti aliasing is enabled.
  150060. */
  150061. set fxaaEnabled(enabled: boolean);
  150062. get fxaaEnabled(): boolean;
  150063. private _samples;
  150064. /**
  150065. * MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  150066. */
  150067. set samples(sampleCount: number);
  150068. get samples(): number;
  150069. /**
  150070. * If image processing is enabled.
  150071. */
  150072. set imageProcessingEnabled(enabled: boolean);
  150073. get imageProcessingEnabled(): boolean;
  150074. /**
  150075. * If glow layer is enabled. (Adds a glow effect to emmissive materials)
  150076. */
  150077. set glowLayerEnabled(enabled: boolean);
  150078. get glowLayerEnabled(): boolean;
  150079. /**
  150080. * Gets the glow layer (or null if not defined)
  150081. */
  150082. get glowLayer(): Nullable<GlowLayer>;
  150083. /**
  150084. * Enable or disable the chromaticAberration process from the pipeline
  150085. */
  150086. set chromaticAberrationEnabled(enabled: boolean);
  150087. get chromaticAberrationEnabled(): boolean;
  150088. /**
  150089. * Enable or disable the grain process from the pipeline
  150090. */
  150091. set grainEnabled(enabled: boolean);
  150092. get grainEnabled(): boolean;
  150093. /**
  150094. * @constructor
  150095. * @param name - The rendering pipeline name (default: "")
  150096. * @param hdr - If high dynamic range textures should be used (default: true)
  150097. * @param scene - The scene linked to this pipeline (default: the last created scene)
  150098. * @param cameras - The array of cameras that the rendering pipeline will be attached to (default: scene.cameras)
  150099. * @param automaticBuild - if false, you will have to manually call prepare() to update the pipeline (default: true)
  150100. */
  150101. constructor(name?: string, hdr?: boolean, scene?: Scene, cameras?: Camera[], automaticBuild?: boolean);
  150102. /**
  150103. * Get the class name
  150104. * @returns "DefaultRenderingPipeline"
  150105. */
  150106. getClassName(): string;
  150107. /**
  150108. * Force the compilation of the entire pipeline.
  150109. */
  150110. prepare(): void;
  150111. private _hasCleared;
  150112. private _prevPostProcess;
  150113. private _prevPrevPostProcess;
  150114. private _setAutoClearAndTextureSharing;
  150115. private _depthOfFieldSceneObserver;
  150116. private _buildPipeline;
  150117. private _disposePostProcesses;
  150118. /**
  150119. * Adds a camera to the pipeline
  150120. * @param camera the camera to be added
  150121. */
  150122. addCamera(camera: Camera): void;
  150123. /**
  150124. * Removes a camera from the pipeline
  150125. * @param camera the camera to remove
  150126. */
  150127. removeCamera(camera: Camera): void;
  150128. /**
  150129. * Dispose of the pipeline and stop all post processes
  150130. */
  150131. dispose(): void;
  150132. /**
  150133. * Serialize the rendering pipeline (Used when exporting)
  150134. * @returns the serialized object
  150135. */
  150136. serialize(): any;
  150137. /**
  150138. * Parse the serialized pipeline
  150139. * @param source Source pipeline.
  150140. * @param scene The scene to load the pipeline to.
  150141. * @param rootUrl The URL of the serialized pipeline.
  150142. * @returns An instantiated pipeline from the serialized object.
  150143. */
  150144. static Parse(source: any, scene: Scene, rootUrl: string): DefaultRenderingPipeline;
  150145. }
  150146. }
  150147. declare module BABYLON {
  150148. /** @hidden */
  150149. export var lensHighlightsPixelShader: {
  150150. name: string;
  150151. shader: string;
  150152. };
  150153. }
  150154. declare module BABYLON {
  150155. /** @hidden */
  150156. export var depthOfFieldPixelShader: {
  150157. name: string;
  150158. shader: string;
  150159. };
  150160. }
  150161. declare module BABYLON {
  150162. /**
  150163. * BABYLON.JS Chromatic Aberration GLSL Shader
  150164. * Author: Olivier Guyot
  150165. * Separates very slightly R, G and B colors on the edges of the screen
  150166. * Inspired by Francois Tarlier & Martins Upitis
  150167. */
  150168. export class LensRenderingPipeline extends PostProcessRenderPipeline {
  150169. /**
  150170. * @ignore
  150171. * The chromatic aberration PostProcess id in the pipeline
  150172. */
  150173. LensChromaticAberrationEffect: string;
  150174. /**
  150175. * @ignore
  150176. * The highlights enhancing PostProcess id in the pipeline
  150177. */
  150178. HighlightsEnhancingEffect: string;
  150179. /**
  150180. * @ignore
  150181. * The depth-of-field PostProcess id in the pipeline
  150182. */
  150183. LensDepthOfFieldEffect: string;
  150184. private _scene;
  150185. private _depthTexture;
  150186. private _grainTexture;
  150187. private _chromaticAberrationPostProcess;
  150188. private _highlightsPostProcess;
  150189. private _depthOfFieldPostProcess;
  150190. private _edgeBlur;
  150191. private _grainAmount;
  150192. private _chromaticAberration;
  150193. private _distortion;
  150194. private _highlightsGain;
  150195. private _highlightsThreshold;
  150196. private _dofDistance;
  150197. private _dofAperture;
  150198. private _dofDarken;
  150199. private _dofPentagon;
  150200. private _blurNoise;
  150201. /**
  150202. * @constructor
  150203. *
  150204. * Effect parameters are as follow:
  150205. * {
  150206. * chromatic_aberration: number; // from 0 to x (1 for realism)
  150207. * edge_blur: number; // from 0 to x (1 for realism)
  150208. * distortion: number; // from 0 to x (1 for realism)
  150209. * grain_amount: number; // from 0 to 1
  150210. * grain_texture: BABYLON.Texture; // texture to use for grain effect; if unset, use random B&W noise
  150211. * dof_focus_distance: number; // depth-of-field: focus distance; unset to disable (disabled by default)
  150212. * dof_aperture: number; // depth-of-field: focus blur bias (default: 1)
  150213. * dof_darken: number; // depth-of-field: darken that which is out of focus (from 0 to 1, disabled by default)
  150214. * dof_pentagon: boolean; // depth-of-field: makes a pentagon-like "bokeh" effect
  150215. * dof_gain: number; // depth-of-field: highlights gain; unset to disable (disabled by default)
  150216. * dof_threshold: number; // depth-of-field: highlights threshold (default: 1)
  150217. * blur_noise: boolean; // add a little bit of noise to the blur (default: true)
  150218. * }
  150219. * Note: if an effect parameter is unset, effect is disabled
  150220. *
  150221. * @param name The rendering pipeline name
  150222. * @param parameters - An object containing all parameters (see above)
  150223. * @param scene The scene linked to this pipeline
  150224. * @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)
  150225. * @param cameras The array of cameras that the rendering pipeline will be attached to
  150226. */
  150227. constructor(name: string, parameters: any, scene: Scene, ratio?: number, cameras?: Camera[]);
  150228. /**
  150229. * Get the class name
  150230. * @returns "LensRenderingPipeline"
  150231. */
  150232. getClassName(): string;
  150233. /**
  150234. * Gets associated scene
  150235. */
  150236. get scene(): Scene;
  150237. /**
  150238. * Gets or sets the edge blur
  150239. */
  150240. get edgeBlur(): number;
  150241. set edgeBlur(value: number);
  150242. /**
  150243. * Gets or sets the grain amount
  150244. */
  150245. get grainAmount(): number;
  150246. set grainAmount(value: number);
  150247. /**
  150248. * Gets or sets the chromatic aberration amount
  150249. */
  150250. get chromaticAberration(): number;
  150251. set chromaticAberration(value: number);
  150252. /**
  150253. * Gets or sets the depth of field aperture
  150254. */
  150255. get dofAperture(): number;
  150256. set dofAperture(value: number);
  150257. /**
  150258. * Gets or sets the edge distortion
  150259. */
  150260. get edgeDistortion(): number;
  150261. set edgeDistortion(value: number);
  150262. /**
  150263. * Gets or sets the depth of field distortion
  150264. */
  150265. get dofDistortion(): number;
  150266. set dofDistortion(value: number);
  150267. /**
  150268. * Gets or sets the darken out of focus amount
  150269. */
  150270. get darkenOutOfFocus(): number;
  150271. set darkenOutOfFocus(value: number);
  150272. /**
  150273. * Gets or sets a boolean indicating if blur noise is enabled
  150274. */
  150275. get blurNoise(): boolean;
  150276. set blurNoise(value: boolean);
  150277. /**
  150278. * Gets or sets a boolean indicating if pentagon bokeh is enabled
  150279. */
  150280. get pentagonBokeh(): boolean;
  150281. set pentagonBokeh(value: boolean);
  150282. /**
  150283. * Gets or sets the highlight grain amount
  150284. */
  150285. get highlightsGain(): number;
  150286. set highlightsGain(value: number);
  150287. /**
  150288. * Gets or sets the highlight threshold
  150289. */
  150290. get highlightsThreshold(): number;
  150291. set highlightsThreshold(value: number);
  150292. /**
  150293. * Sets the amount of blur at the edges
  150294. * @param amount blur amount
  150295. */
  150296. setEdgeBlur(amount: number): void;
  150297. /**
  150298. * Sets edge blur to 0
  150299. */
  150300. disableEdgeBlur(): void;
  150301. /**
  150302. * Sets the amout of grain
  150303. * @param amount Amount of grain
  150304. */
  150305. setGrainAmount(amount: number): void;
  150306. /**
  150307. * Set grain amount to 0
  150308. */
  150309. disableGrain(): void;
  150310. /**
  150311. * Sets the chromatic aberration amount
  150312. * @param amount amount of chromatic aberration
  150313. */
  150314. setChromaticAberration(amount: number): void;
  150315. /**
  150316. * Sets chromatic aberration amount to 0
  150317. */
  150318. disableChromaticAberration(): void;
  150319. /**
  150320. * Sets the EdgeDistortion amount
  150321. * @param amount amount of EdgeDistortion
  150322. */
  150323. setEdgeDistortion(amount: number): void;
  150324. /**
  150325. * Sets edge distortion to 0
  150326. */
  150327. disableEdgeDistortion(): void;
  150328. /**
  150329. * Sets the FocusDistance amount
  150330. * @param amount amount of FocusDistance
  150331. */
  150332. setFocusDistance(amount: number): void;
  150333. /**
  150334. * Disables depth of field
  150335. */
  150336. disableDepthOfField(): void;
  150337. /**
  150338. * Sets the Aperture amount
  150339. * @param amount amount of Aperture
  150340. */
  150341. setAperture(amount: number): void;
  150342. /**
  150343. * Sets the DarkenOutOfFocus amount
  150344. * @param amount amount of DarkenOutOfFocus
  150345. */
  150346. setDarkenOutOfFocus(amount: number): void;
  150347. private _pentagonBokehIsEnabled;
  150348. /**
  150349. * Creates a pentagon bokeh effect
  150350. */
  150351. enablePentagonBokeh(): void;
  150352. /**
  150353. * Disables the pentagon bokeh effect
  150354. */
  150355. disablePentagonBokeh(): void;
  150356. /**
  150357. * Enables noise blur
  150358. */
  150359. enableNoiseBlur(): void;
  150360. /**
  150361. * Disables noise blur
  150362. */
  150363. disableNoiseBlur(): void;
  150364. /**
  150365. * Sets the HighlightsGain amount
  150366. * @param amount amount of HighlightsGain
  150367. */
  150368. setHighlightsGain(amount: number): void;
  150369. /**
  150370. * Sets the HighlightsThreshold amount
  150371. * @param amount amount of HighlightsThreshold
  150372. */
  150373. setHighlightsThreshold(amount: number): void;
  150374. /**
  150375. * Disables highlights
  150376. */
  150377. disableHighlights(): void;
  150378. /**
  150379. * Removes the internal pipeline assets and detaches the pipeline from the scene cameras
  150380. * @param disableDepthRender If the scens depth rendering should be disabled (default: false)
  150381. */
  150382. dispose(disableDepthRender?: boolean): void;
  150383. private _createChromaticAberrationPostProcess;
  150384. private _createHighlightsPostProcess;
  150385. private _createDepthOfFieldPostProcess;
  150386. private _createGrainTexture;
  150387. }
  150388. }
  150389. declare module BABYLON {
  150390. /** @hidden */
  150391. export var ssao2PixelShader: {
  150392. name: string;
  150393. shader: string;
  150394. };
  150395. }
  150396. declare module BABYLON {
  150397. /** @hidden */
  150398. export var ssaoCombinePixelShader: {
  150399. name: string;
  150400. shader: string;
  150401. };
  150402. }
  150403. declare module BABYLON {
  150404. /**
  150405. * Render pipeline to produce ssao effect
  150406. */
  150407. export class SSAO2RenderingPipeline extends PostProcessRenderPipeline {
  150408. /**
  150409. * @ignore
  150410. * The PassPostProcess id in the pipeline that contains the original scene color
  150411. */
  150412. SSAOOriginalSceneColorEffect: string;
  150413. /**
  150414. * @ignore
  150415. * The SSAO PostProcess id in the pipeline
  150416. */
  150417. SSAORenderEffect: string;
  150418. /**
  150419. * @ignore
  150420. * The horizontal blur PostProcess id in the pipeline
  150421. */
  150422. SSAOBlurHRenderEffect: string;
  150423. /**
  150424. * @ignore
  150425. * The vertical blur PostProcess id in the pipeline
  150426. */
  150427. SSAOBlurVRenderEffect: string;
  150428. /**
  150429. * @ignore
  150430. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  150431. */
  150432. SSAOCombineRenderEffect: string;
  150433. /**
  150434. * The output strength of the SSAO post-process. Default value is 1.0.
  150435. */
  150436. totalStrength: number;
  150437. /**
  150438. * Maximum depth value to still render AO. A smooth falloff makes the dimming more natural, so there will be no abrupt shading change.
  150439. */
  150440. maxZ: number;
  150441. /**
  150442. * In order to save performances, SSAO radius is clamped on close geometry. This ratio changes by how much
  150443. */
  150444. minZAspect: number;
  150445. private _samples;
  150446. /**
  150447. * Number of samples used for the SSAO calculations. Default value is 8
  150448. */
  150449. set samples(n: number);
  150450. get samples(): number;
  150451. private _textureSamples;
  150452. /**
  150453. * Number of samples to use for antialiasing
  150454. */
  150455. set textureSamples(n: number);
  150456. get textureSamples(): number;
  150457. /**
  150458. * Force rendering the geometry through geometry buffer
  150459. */
  150460. private _forceGeometryBuffer;
  150461. /**
  150462. * Ratio object used for SSAO ratio and blur ratio
  150463. */
  150464. private _ratio;
  150465. /**
  150466. * Dynamically generated sphere sampler.
  150467. */
  150468. private _sampleSphere;
  150469. /**
  150470. * Blur filter offsets
  150471. */
  150472. private _samplerOffsets;
  150473. private _expensiveBlur;
  150474. /**
  150475. * If bilateral blur should be used
  150476. */
  150477. set expensiveBlur(b: boolean);
  150478. get expensiveBlur(): boolean;
  150479. /**
  150480. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 2.0
  150481. */
  150482. radius: number;
  150483. /**
  150484. * The base color of the SSAO post-process
  150485. * The final result is "base + ssao" between [0, 1]
  150486. */
  150487. base: number;
  150488. /**
  150489. * Support test.
  150490. */
  150491. static get IsSupported(): boolean;
  150492. private _scene;
  150493. private _randomTexture;
  150494. private _originalColorPostProcess;
  150495. private _ssaoPostProcess;
  150496. private _blurHPostProcess;
  150497. private _blurVPostProcess;
  150498. private _ssaoCombinePostProcess;
  150499. private _prePassRenderer;
  150500. /**
  150501. * Gets active scene
  150502. */
  150503. get scene(): Scene;
  150504. /**
  150505. * @constructor
  150506. * @param name The rendering pipeline name
  150507. * @param scene The scene linked to this pipeline
  150508. * @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 }
  150509. * @param cameras The array of cameras that the rendering pipeline will be attached to
  150510. * @param forceGeometryBuffer Set to true if you want to use the legacy geometry buffer renderer
  150511. */
  150512. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[], forceGeometryBuffer?: boolean);
  150513. /**
  150514. * Get the class name
  150515. * @returns "SSAO2RenderingPipeline"
  150516. */
  150517. getClassName(): string;
  150518. /**
  150519. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  150520. */
  150521. dispose(disableGeometryBufferRenderer?: boolean): void;
  150522. private _createBlurPostProcess;
  150523. /** @hidden */
  150524. _rebuild(): void;
  150525. private _bits;
  150526. private _radicalInverse_VdC;
  150527. private _hammersley;
  150528. private _hemisphereSample_uniform;
  150529. private _generateHemisphere;
  150530. private _getDefinesForSSAO;
  150531. private _createSSAOPostProcess;
  150532. private _createSSAOCombinePostProcess;
  150533. private _createRandomTexture;
  150534. /**
  150535. * Serialize the rendering pipeline (Used when exporting)
  150536. * @returns the serialized object
  150537. */
  150538. serialize(): any;
  150539. /**
  150540. * Parse the serialized pipeline
  150541. * @param source Source pipeline.
  150542. * @param scene The scene to load the pipeline to.
  150543. * @param rootUrl The URL of the serialized pipeline.
  150544. * @returns An instantiated pipeline from the serialized object.
  150545. */
  150546. static Parse(source: any, scene: Scene, rootUrl: string): SSAO2RenderingPipeline;
  150547. /**
  150548. * Sets the required values to the prepass renderer.
  150549. * @param prePassRenderer defines the prepass renderer to setup
  150550. * @returns true if the pre pass is needed.
  150551. */
  150552. setPrePassRenderer(prePassRenderer: PrePassRenderer): boolean;
  150553. }
  150554. }
  150555. declare module BABYLON {
  150556. /** @hidden */
  150557. export var ssaoPixelShader: {
  150558. name: string;
  150559. shader: string;
  150560. };
  150561. }
  150562. declare module BABYLON {
  150563. /**
  150564. * Render pipeline to produce ssao effect
  150565. */
  150566. export class SSAORenderingPipeline extends PostProcessRenderPipeline {
  150567. /**
  150568. * @ignore
  150569. * The PassPostProcess id in the pipeline that contains the original scene color
  150570. */
  150571. SSAOOriginalSceneColorEffect: string;
  150572. /**
  150573. * @ignore
  150574. * The SSAO PostProcess id in the pipeline
  150575. */
  150576. SSAORenderEffect: string;
  150577. /**
  150578. * @ignore
  150579. * The horizontal blur PostProcess id in the pipeline
  150580. */
  150581. SSAOBlurHRenderEffect: string;
  150582. /**
  150583. * @ignore
  150584. * The vertical blur PostProcess id in the pipeline
  150585. */
  150586. SSAOBlurVRenderEffect: string;
  150587. /**
  150588. * @ignore
  150589. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  150590. */
  150591. SSAOCombineRenderEffect: string;
  150592. /**
  150593. * The output strength of the SSAO post-process. Default value is 1.0.
  150594. */
  150595. totalStrength: number;
  150596. /**
  150597. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 0.0006
  150598. */
  150599. radius: number;
  150600. /**
  150601. * Related to fallOff, used to interpolate SSAO samples (first interpolate function input) based on the occlusion difference of each pixel
  150602. * Must not be equal to fallOff and superior to fallOff.
  150603. * Default value is 0.0075
  150604. */
  150605. area: number;
  150606. /**
  150607. * Related to area, used to interpolate SSAO samples (second interpolate function input) based on the occlusion difference of each pixel
  150608. * Must not be equal to area and inferior to area.
  150609. * Default value is 0.000001
  150610. */
  150611. fallOff: number;
  150612. /**
  150613. * The base color of the SSAO post-process
  150614. * The final result is "base + ssao" between [0, 1]
  150615. */
  150616. base: number;
  150617. private _scene;
  150618. private _depthTexture;
  150619. private _randomTexture;
  150620. private _originalColorPostProcess;
  150621. private _ssaoPostProcess;
  150622. private _blurHPostProcess;
  150623. private _blurVPostProcess;
  150624. private _ssaoCombinePostProcess;
  150625. private _firstUpdate;
  150626. /**
  150627. * Gets active scene
  150628. */
  150629. get scene(): Scene;
  150630. /**
  150631. * @constructor
  150632. * @param name - The rendering pipeline name
  150633. * @param scene - The scene linked to this pipeline
  150634. * @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 }
  150635. * @param cameras - The array of cameras that the rendering pipeline will be attached to
  150636. */
  150637. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[]);
  150638. /**
  150639. * Get the class name
  150640. * @returns "SSAORenderingPipeline"
  150641. */
  150642. getClassName(): string;
  150643. /**
  150644. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  150645. */
  150646. dispose(disableDepthRender?: boolean): void;
  150647. private _createBlurPostProcess;
  150648. /** @hidden */
  150649. _rebuild(): void;
  150650. private _createSSAOPostProcess;
  150651. private _createSSAOCombinePostProcess;
  150652. private _createRandomTexture;
  150653. }
  150654. }
  150655. declare module BABYLON {
  150656. /** @hidden */
  150657. export var screenSpaceReflectionPixelShader: {
  150658. name: string;
  150659. shader: string;
  150660. };
  150661. }
  150662. declare module BABYLON {
  150663. /**
  150664. * The ScreenSpaceReflectionPostProcess performs realtime reflections using only and only the available informations on the screen (positions and normals).
  150665. * Basically, the screen space reflection post-process will compute reflections according the material's reflectivity.
  150666. */
  150667. export class ScreenSpaceReflectionPostProcess extends PostProcess {
  150668. /**
  150669. * Gets or sets a reflection threshold mainly used to adjust the reflection's height.
  150670. */
  150671. threshold: number;
  150672. /**
  150673. * Gets or sets the current reflection strength. 1.0 is an ideal value but can be increased/decreased for particular results.
  150674. */
  150675. strength: number;
  150676. /**
  150677. * Gets or sets the falloff exponent used while computing fresnel. More the exponent is high, more the reflections will be discrete.
  150678. */
  150679. reflectionSpecularFalloffExponent: number;
  150680. /**
  150681. * 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]
  150682. */
  150683. step: number;
  150684. /**
  150685. * Gets or sets the factor applied when computing roughness. Default value is 0.2.
  150686. */
  150687. roughnessFactor: number;
  150688. private _geometryBufferRenderer;
  150689. private _enableSmoothReflections;
  150690. private _reflectionSamples;
  150691. private _smoothSteps;
  150692. /**
  150693. * Gets a string identifying the name of the class
  150694. * @returns "ScreenSpaceReflectionPostProcess" string
  150695. */
  150696. getClassName(): string;
  150697. /**
  150698. * Creates a new instance of ScreenSpaceReflectionPostProcess.
  150699. * @param name The name of the effect.
  150700. * @param scene The scene containing the objects to calculate reflections.
  150701. * @param options The required width/height ratio to downsize to before computing the render pass.
  150702. * @param camera The camera to apply the render pass to.
  150703. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  150704. * @param engine The engine which the post process will be applied. (default: current engine)
  150705. * @param reusable If the post process can be reused on the same frame. (default: false)
  150706. * @param textureType Type of textures used when performing the post process. (default: 0)
  150707. * @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)
  150708. */
  150709. constructor(name: string, scene: Scene, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  150710. /**
  150711. * Gets wether or not smoothing reflections is enabled.
  150712. * Enabling smoothing will require more GPU power and can generate a drop in FPS.
  150713. */
  150714. get enableSmoothReflections(): boolean;
  150715. /**
  150716. * Sets wether or not smoothing reflections is enabled.
  150717. * Enabling smoothing will require more GPU power and can generate a drop in FPS.
  150718. */
  150719. set enableSmoothReflections(enabled: boolean);
  150720. /**
  150721. * Gets the number of samples taken while computing reflections. More samples count is high,
  150722. * more the post-process wil require GPU power and can generate a drop in FPS. Basically in interval [25, 100].
  150723. */
  150724. get reflectionSamples(): number;
  150725. /**
  150726. * Sets the number of samples taken while computing reflections. More samples count is high,
  150727. * more the post-process wil require GPU power and can generate a drop in FPS. Basically in interval [25, 100].
  150728. */
  150729. set reflectionSamples(samples: number);
  150730. /**
  150731. * Gets the number of samples taken while smoothing reflections. More samples count is high,
  150732. * more the post-process will require GPU power and can generate a drop in FPS.
  150733. * Default value (5.0) work pretty well in all cases but can be adjusted.
  150734. */
  150735. get smoothSteps(): number;
  150736. set smoothSteps(steps: number);
  150737. private _updateEffectDefines;
  150738. /** @hidden */
  150739. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): ScreenSpaceReflectionPostProcess;
  150740. }
  150741. }
  150742. declare module BABYLON {
  150743. /** @hidden */
  150744. export var standardPixelShader: {
  150745. name: string;
  150746. shader: string;
  150747. };
  150748. }
  150749. declare module BABYLON {
  150750. /**
  150751. * Standard rendering pipeline
  150752. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  150753. * @see https://doc.babylonjs.com/how_to/using_standard_rendering_pipeline
  150754. */
  150755. export class StandardRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  150756. /**
  150757. * Public members
  150758. */
  150759. /**
  150760. * Post-process which contains the original scene color before the pipeline applies all the effects
  150761. */
  150762. originalPostProcess: Nullable<PostProcess>;
  150763. /**
  150764. * Post-process used to down scale an image x4
  150765. */
  150766. downSampleX4PostProcess: Nullable<PostProcess>;
  150767. /**
  150768. * Post-process used to calculate the illuminated surfaces controlled by a threshold
  150769. */
  150770. brightPassPostProcess: Nullable<PostProcess>;
  150771. /**
  150772. * Post-process array storing all the horizontal blur post-processes used by the pipeline
  150773. */
  150774. blurHPostProcesses: PostProcess[];
  150775. /**
  150776. * Post-process array storing all the vertical blur post-processes used by the pipeline
  150777. */
  150778. blurVPostProcesses: PostProcess[];
  150779. /**
  150780. * Post-process used to add colors of 2 textures (typically brightness + real scene color)
  150781. */
  150782. textureAdderPostProcess: Nullable<PostProcess>;
  150783. /**
  150784. * Post-process used to create volumetric lighting effect
  150785. */
  150786. volumetricLightPostProcess: Nullable<PostProcess>;
  150787. /**
  150788. * Post-process used to smooth the previous volumetric light post-process on the X axis
  150789. */
  150790. volumetricLightSmoothXPostProcess: Nullable<BlurPostProcess>;
  150791. /**
  150792. * Post-process used to smooth the previous volumetric light post-process on the Y axis
  150793. */
  150794. volumetricLightSmoothYPostProcess: Nullable<BlurPostProcess>;
  150795. /**
  150796. * Post-process used to merge the volumetric light effect and the real scene color
  150797. */
  150798. volumetricLightMergePostProces: Nullable<PostProcess>;
  150799. /**
  150800. * Post-process used to store the final volumetric light post-process (attach/detach for debug purpose)
  150801. */
  150802. volumetricLightFinalPostProcess: Nullable<PostProcess>;
  150803. /**
  150804. * Base post-process used to calculate the average luminance of the final image for HDR
  150805. */
  150806. luminancePostProcess: Nullable<PostProcess>;
  150807. /**
  150808. * Post-processes used to create down sample post-processes in order to get
  150809. * the average luminance of the final image for HDR
  150810. * Array of length "StandardRenderingPipeline.LuminanceSteps"
  150811. */
  150812. luminanceDownSamplePostProcesses: PostProcess[];
  150813. /**
  150814. * Post-process used to create a HDR effect (light adaptation)
  150815. */
  150816. hdrPostProcess: Nullable<PostProcess>;
  150817. /**
  150818. * Post-process used to store the final texture adder post-process (attach/detach for debug purpose)
  150819. */
  150820. textureAdderFinalPostProcess: Nullable<PostProcess>;
  150821. /**
  150822. * Post-process used to store the final lens flare post-process (attach/detach for debug purpose)
  150823. */
  150824. lensFlareFinalPostProcess: Nullable<PostProcess>;
  150825. /**
  150826. * Post-process used to merge the final HDR post-process and the real scene color
  150827. */
  150828. hdrFinalPostProcess: Nullable<PostProcess>;
  150829. /**
  150830. * Post-process used to create a lens flare effect
  150831. */
  150832. lensFlarePostProcess: Nullable<PostProcess>;
  150833. /**
  150834. * Post-process that merges the result of the lens flare post-process and the real scene color
  150835. */
  150836. lensFlareComposePostProcess: Nullable<PostProcess>;
  150837. /**
  150838. * Post-process used to create a motion blur effect
  150839. */
  150840. motionBlurPostProcess: Nullable<PostProcess>;
  150841. /**
  150842. * Post-process used to create a depth of field effect
  150843. */
  150844. depthOfFieldPostProcess: Nullable<PostProcess>;
  150845. /**
  150846. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  150847. */
  150848. fxaaPostProcess: Nullable<FxaaPostProcess>;
  150849. /**
  150850. * Post-process used to simulate realtime reflections using the screen space and geometry renderer.
  150851. */
  150852. screenSpaceReflectionPostProcess: Nullable<ScreenSpaceReflectionPostProcess>;
  150853. /**
  150854. * Represents the brightness threshold in order to configure the illuminated surfaces
  150855. */
  150856. brightThreshold: number;
  150857. /**
  150858. * Configures the blur intensity used for surexposed surfaces are highlighted surfaces (light halo)
  150859. */
  150860. blurWidth: number;
  150861. /**
  150862. * Sets if the blur for highlighted surfaces must be only horizontal
  150863. */
  150864. horizontalBlur: boolean;
  150865. /**
  150866. * Gets the overall exposure used by the pipeline
  150867. */
  150868. get exposure(): number;
  150869. /**
  150870. * Sets the overall exposure used by the pipeline
  150871. */
  150872. set exposure(value: number);
  150873. /**
  150874. * Texture used typically to simulate "dirty" on camera lens
  150875. */
  150876. lensTexture: Nullable<Texture>;
  150877. /**
  150878. * Represents the offset coefficient based on Rayleigh principle. Typically in interval [-0.2, 0.2]
  150879. */
  150880. volumetricLightCoefficient: number;
  150881. /**
  150882. * The overall power of volumetric lights, typically in interval [0, 10] maximum
  150883. */
  150884. volumetricLightPower: number;
  150885. /**
  150886. * Used the set the blur intensity to smooth the volumetric lights
  150887. */
  150888. volumetricLightBlurScale: number;
  150889. /**
  150890. * Light (spot or directional) used to generate the volumetric lights rays
  150891. * The source light must have a shadow generate so the pipeline can get its
  150892. * depth map
  150893. */
  150894. sourceLight: Nullable<SpotLight | DirectionalLight>;
  150895. /**
  150896. * For eye adaptation, represents the minimum luminance the eye can see
  150897. */
  150898. hdrMinimumLuminance: number;
  150899. /**
  150900. * For eye adaptation, represents the decrease luminance speed
  150901. */
  150902. hdrDecreaseRate: number;
  150903. /**
  150904. * For eye adaptation, represents the increase luminance speed
  150905. */
  150906. hdrIncreaseRate: number;
  150907. /**
  150908. * Gets wether or not the exposure of the overall pipeline should be automatically adjusted by the HDR post-process
  150909. */
  150910. get hdrAutoExposure(): boolean;
  150911. /**
  150912. * Sets wether or not the exposure of the overall pipeline should be automatically adjusted by the HDR post-process
  150913. */
  150914. set hdrAutoExposure(value: boolean);
  150915. /**
  150916. * Lens color texture used by the lens flare effect. Mandatory if lens flare effect enabled
  150917. */
  150918. lensColorTexture: Nullable<Texture>;
  150919. /**
  150920. * The overall strengh for the lens flare effect
  150921. */
  150922. lensFlareStrength: number;
  150923. /**
  150924. * Dispersion coefficient for lens flare ghosts
  150925. */
  150926. lensFlareGhostDispersal: number;
  150927. /**
  150928. * Main lens flare halo width
  150929. */
  150930. lensFlareHaloWidth: number;
  150931. /**
  150932. * Based on the lens distortion effect, defines how much the lens flare result
  150933. * is distorted
  150934. */
  150935. lensFlareDistortionStrength: number;
  150936. /**
  150937. * Configures the blur intensity used for for lens flare (halo)
  150938. */
  150939. lensFlareBlurWidth: number;
  150940. /**
  150941. * Lens star texture must be used to simulate rays on the flares and is available
  150942. * in the documentation
  150943. */
  150944. lensStarTexture: Nullable<Texture>;
  150945. /**
  150946. * As the "lensTexture" (can be the same texture or different), it is used to apply the lens
  150947. * flare effect by taking account of the dirt texture
  150948. */
  150949. lensFlareDirtTexture: Nullable<Texture>;
  150950. /**
  150951. * Represents the focal length for the depth of field effect
  150952. */
  150953. depthOfFieldDistance: number;
  150954. /**
  150955. * Represents the blur intensity for the blurred part of the depth of field effect
  150956. */
  150957. depthOfFieldBlurWidth: number;
  150958. /**
  150959. * Gets how much the image is blurred by the movement while using the motion blur post-process
  150960. */
  150961. get motionStrength(): number;
  150962. /**
  150963. * Sets how much the image is blurred by the movement while using the motion blur post-process
  150964. */
  150965. set motionStrength(strength: number);
  150966. /**
  150967. * Gets wether or not the motion blur post-process is object based or screen based.
  150968. */
  150969. get objectBasedMotionBlur(): boolean;
  150970. /**
  150971. * Sets wether or not the motion blur post-process should be object based or screen based
  150972. */
  150973. set objectBasedMotionBlur(value: boolean);
  150974. /**
  150975. * List of animations for the pipeline (IAnimatable implementation)
  150976. */
  150977. animations: Animation[];
  150978. /**
  150979. * Private members
  150980. */
  150981. private _scene;
  150982. private _currentDepthOfFieldSource;
  150983. private _basePostProcess;
  150984. private _fixedExposure;
  150985. private _currentExposure;
  150986. private _hdrAutoExposure;
  150987. private _hdrCurrentLuminance;
  150988. private _motionStrength;
  150989. private _isObjectBasedMotionBlur;
  150990. private _floatTextureType;
  150991. private _camerasToBeAttached;
  150992. private _ratio;
  150993. private _bloomEnabled;
  150994. private _depthOfFieldEnabled;
  150995. private _vlsEnabled;
  150996. private _lensFlareEnabled;
  150997. private _hdrEnabled;
  150998. private _motionBlurEnabled;
  150999. private _fxaaEnabled;
  151000. private _screenSpaceReflectionsEnabled;
  151001. private _motionBlurSamples;
  151002. private _volumetricLightStepsCount;
  151003. private _samples;
  151004. /**
  151005. * @ignore
  151006. * Specifies if the bloom pipeline is enabled
  151007. */
  151008. get BloomEnabled(): boolean;
  151009. set BloomEnabled(enabled: boolean);
  151010. /**
  151011. * @ignore
  151012. * Specifies if the depth of field pipeline is enabed
  151013. */
  151014. get DepthOfFieldEnabled(): boolean;
  151015. set DepthOfFieldEnabled(enabled: boolean);
  151016. /**
  151017. * @ignore
  151018. * Specifies if the lens flare pipeline is enabed
  151019. */
  151020. get LensFlareEnabled(): boolean;
  151021. set LensFlareEnabled(enabled: boolean);
  151022. /**
  151023. * @ignore
  151024. * Specifies if the HDR pipeline is enabled
  151025. */
  151026. get HDREnabled(): boolean;
  151027. set HDREnabled(enabled: boolean);
  151028. /**
  151029. * @ignore
  151030. * Specifies if the volumetric lights scattering effect is enabled
  151031. */
  151032. get VLSEnabled(): boolean;
  151033. set VLSEnabled(enabled: boolean);
  151034. /**
  151035. * @ignore
  151036. * Specifies if the motion blur effect is enabled
  151037. */
  151038. get MotionBlurEnabled(): boolean;
  151039. set MotionBlurEnabled(enabled: boolean);
  151040. /**
  151041. * Specifies if anti-aliasing is enabled
  151042. */
  151043. get fxaaEnabled(): boolean;
  151044. set fxaaEnabled(enabled: boolean);
  151045. /**
  151046. * Specifies if screen space reflections are enabled.
  151047. */
  151048. get screenSpaceReflectionsEnabled(): boolean;
  151049. set screenSpaceReflectionsEnabled(enabled: boolean);
  151050. /**
  151051. * Specifies the number of steps used to calculate the volumetric lights
  151052. * Typically in interval [50, 200]
  151053. */
  151054. get volumetricLightStepsCount(): number;
  151055. set volumetricLightStepsCount(count: number);
  151056. /**
  151057. * Specifies the number of samples used for the motion blur effect
  151058. * Typically in interval [16, 64]
  151059. */
  151060. get motionBlurSamples(): number;
  151061. set motionBlurSamples(samples: number);
  151062. /**
  151063. * Specifies MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  151064. */
  151065. get samples(): number;
  151066. set samples(sampleCount: number);
  151067. /**
  151068. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  151069. * @constructor
  151070. * @param name The rendering pipeline name
  151071. * @param scene The scene linked to this pipeline
  151072. * @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)
  151073. * @param originalPostProcess the custom original color post-process. Must be "reusable". Can be null.
  151074. * @param cameras The array of cameras that the rendering pipeline will be attached to
  151075. */
  151076. constructor(name: string, scene: Scene, ratio: number, originalPostProcess?: Nullable<PostProcess>, cameras?: Camera[]);
  151077. private _buildPipeline;
  151078. private _createDownSampleX4PostProcess;
  151079. private _createBrightPassPostProcess;
  151080. private _createBlurPostProcesses;
  151081. private _createTextureAdderPostProcess;
  151082. private _createVolumetricLightPostProcess;
  151083. private _createLuminancePostProcesses;
  151084. private _createHdrPostProcess;
  151085. private _createLensFlarePostProcess;
  151086. private _createDepthOfFieldPostProcess;
  151087. private _createMotionBlurPostProcess;
  151088. private _getDepthTexture;
  151089. private _disposePostProcesses;
  151090. /**
  151091. * Dispose of the pipeline and stop all post processes
  151092. */
  151093. dispose(): void;
  151094. /**
  151095. * Serialize the rendering pipeline (Used when exporting)
  151096. * @returns the serialized object
  151097. */
  151098. serialize(): any;
  151099. /**
  151100. * Parse the serialized pipeline
  151101. * @param source Source pipeline.
  151102. * @param scene The scene to load the pipeline to.
  151103. * @param rootUrl The URL of the serialized pipeline.
  151104. * @returns An instantiated pipeline from the serialized object.
  151105. */
  151106. static Parse(source: any, scene: Scene, rootUrl: string): StandardRenderingPipeline;
  151107. /**
  151108. * Luminance steps
  151109. */
  151110. static LuminanceSteps: number;
  151111. }
  151112. }
  151113. declare module BABYLON {
  151114. /** @hidden */
  151115. export var stereoscopicInterlacePixelShader: {
  151116. name: string;
  151117. shader: string;
  151118. };
  151119. }
  151120. declare module BABYLON {
  151121. /**
  151122. * StereoscopicInterlacePostProcessI used to render stereo views from a rigged camera with support for alternate line interlacing
  151123. */
  151124. export class StereoscopicInterlacePostProcessI extends PostProcess {
  151125. private _stepSize;
  151126. private _passedProcess;
  151127. /**
  151128. * Gets a string identifying the name of the class
  151129. * @returns "StereoscopicInterlacePostProcessI" string
  151130. */
  151131. getClassName(): string;
  151132. /**
  151133. * Initializes a StereoscopicInterlacePostProcessI
  151134. * @param name The name of the effect.
  151135. * @param rigCameras The rig cameras to be appled to the post process
  151136. * @param isStereoscopicHoriz If the rendered results are horizontal or vertical
  151137. * @param isStereoscopicInterlaced If the rendered results are alternate line interlaced
  151138. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  151139. * @param engine The engine which the post process will be applied. (default: current engine)
  151140. * @param reusable If the post process can be reused on the same frame. (default: false)
  151141. */
  151142. constructor(name: string, rigCameras: Camera[], isStereoscopicHoriz: boolean, isStereoscopicInterlaced: boolean, samplingMode?: number, engine?: Engine, reusable?: boolean);
  151143. }
  151144. /**
  151145. * StereoscopicInterlacePostProcess used to render stereo views from a rigged camera
  151146. */
  151147. export class StereoscopicInterlacePostProcess extends PostProcess {
  151148. private _stepSize;
  151149. private _passedProcess;
  151150. /**
  151151. * Gets a string identifying the name of the class
  151152. * @returns "StereoscopicInterlacePostProcess" string
  151153. */
  151154. getClassName(): string;
  151155. /**
  151156. * Initializes a StereoscopicInterlacePostProcess
  151157. * @param name The name of the effect.
  151158. * @param rigCameras The rig cameras to be appled to the post process
  151159. * @param isStereoscopicHoriz If the rendered results are horizontal or verticle
  151160. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  151161. * @param engine The engine which the post process will be applied. (default: current engine)
  151162. * @param reusable If the post process can be reused on the same frame. (default: false)
  151163. */
  151164. constructor(name: string, rigCameras: Camera[], isStereoscopicHoriz: boolean, samplingMode?: number, engine?: Engine, reusable?: boolean);
  151165. }
  151166. }
  151167. declare module BABYLON {
  151168. /** @hidden */
  151169. export var tonemapPixelShader: {
  151170. name: string;
  151171. shader: string;
  151172. };
  151173. }
  151174. declare module BABYLON {
  151175. /** Defines operator used for tonemapping */
  151176. export enum TonemappingOperator {
  151177. /** Hable */
  151178. Hable = 0,
  151179. /** Reinhard */
  151180. Reinhard = 1,
  151181. /** HejiDawson */
  151182. HejiDawson = 2,
  151183. /** Photographic */
  151184. Photographic = 3
  151185. }
  151186. /**
  151187. * Defines a post process to apply tone mapping
  151188. */
  151189. export class TonemapPostProcess extends PostProcess {
  151190. private _operator;
  151191. /** Defines the required exposure adjustement */
  151192. exposureAdjustment: number;
  151193. /**
  151194. * Gets a string identifying the name of the class
  151195. * @returns "TonemapPostProcess" string
  151196. */
  151197. getClassName(): string;
  151198. /**
  151199. * Creates a new TonemapPostProcess
  151200. * @param name defines the name of the postprocess
  151201. * @param _operator defines the operator to use
  151202. * @param exposureAdjustment defines the required exposure adjustement
  151203. * @param camera defines the camera to use (can be null)
  151204. * @param samplingMode defines the required sampling mode (BABYLON.Texture.BILINEAR_SAMPLINGMODE by default)
  151205. * @param engine defines the hosting engine (can be ignore if camera is set)
  151206. * @param textureFormat defines the texture format to use (BABYLON.Engine.TEXTURETYPE_UNSIGNED_INT by default)
  151207. */
  151208. constructor(name: string, _operator: TonemappingOperator,
  151209. /** Defines the required exposure adjustement */
  151210. exposureAdjustment: number, camera: Camera, samplingMode?: number, engine?: Engine, textureFormat?: number);
  151211. }
  151212. }
  151213. declare module BABYLON {
  151214. /** @hidden */
  151215. export var volumetricLightScatteringPixelShader: {
  151216. name: string;
  151217. shader: string;
  151218. };
  151219. }
  151220. declare module BABYLON {
  151221. /** @hidden */
  151222. export var volumetricLightScatteringPassVertexShader: {
  151223. name: string;
  151224. shader: string;
  151225. };
  151226. }
  151227. declare module BABYLON {
  151228. /** @hidden */
  151229. export var volumetricLightScatteringPassPixelShader: {
  151230. name: string;
  151231. shader: string;
  151232. };
  151233. }
  151234. declare module BABYLON {
  151235. /**
  151236. * Inspired by http://http.developer.nvidia.com/GPUGems3/gpugems3_ch13.html
  151237. */
  151238. export class VolumetricLightScatteringPostProcess extends PostProcess {
  151239. private _volumetricLightScatteringPass;
  151240. private _volumetricLightScatteringRTT;
  151241. private _viewPort;
  151242. private _screenCoordinates;
  151243. private _cachedDefines;
  151244. /**
  151245. * If not undefined, the mesh position is computed from the attached node position
  151246. */
  151247. attachedNode: {
  151248. position: Vector3;
  151249. };
  151250. /**
  151251. * Custom position of the mesh. Used if "useCustomMeshPosition" is set to "true"
  151252. */
  151253. customMeshPosition: Vector3;
  151254. /**
  151255. * Set if the post-process should use a custom position for the light source (true) or the internal mesh position (false)
  151256. */
  151257. useCustomMeshPosition: boolean;
  151258. /**
  151259. * If the post-process should inverse the light scattering direction
  151260. */
  151261. invert: boolean;
  151262. /**
  151263. * The internal mesh used by the post-process
  151264. */
  151265. mesh: Mesh;
  151266. /**
  151267. * @hidden
  151268. * VolumetricLightScatteringPostProcess.useDiffuseColor is no longer used, use the mesh material directly instead
  151269. */
  151270. get useDiffuseColor(): boolean;
  151271. set useDiffuseColor(useDiffuseColor: boolean);
  151272. /**
  151273. * Array containing the excluded meshes not rendered in the internal pass
  151274. */
  151275. excludedMeshes: AbstractMesh[];
  151276. /**
  151277. * Controls the overall intensity of the post-process
  151278. */
  151279. exposure: number;
  151280. /**
  151281. * Dissipates each sample's contribution in range [0, 1]
  151282. */
  151283. decay: number;
  151284. /**
  151285. * Controls the overall intensity of each sample
  151286. */
  151287. weight: number;
  151288. /**
  151289. * Controls the density of each sample
  151290. */
  151291. density: number;
  151292. /**
  151293. * @constructor
  151294. * @param name The post-process name
  151295. * @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)
  151296. * @param camera The camera that the post-process will be attached to
  151297. * @param mesh The mesh used to create the light scattering
  151298. * @param samples The post-process quality, default 100
  151299. * @param samplingModeThe post-process filtering mode
  151300. * @param engine The babylon engine
  151301. * @param reusable If the post-process is reusable
  151302. * @param scene The constructor needs a scene reference to initialize internal components. If "camera" is null a "scene" must be provided
  151303. */
  151304. constructor(name: string, ratio: any, camera: Camera, mesh?: Mesh, samples?: number, samplingMode?: number, engine?: Engine, reusable?: boolean, scene?: Scene);
  151305. /**
  151306. * Returns the string "VolumetricLightScatteringPostProcess"
  151307. * @returns "VolumetricLightScatteringPostProcess"
  151308. */
  151309. getClassName(): string;
  151310. private _isReady;
  151311. /**
  151312. * Sets the new light position for light scattering effect
  151313. * @param position The new custom light position
  151314. */
  151315. setCustomMeshPosition(position: Vector3): void;
  151316. /**
  151317. * Returns the light position for light scattering effect
  151318. * @return Vector3 The custom light position
  151319. */
  151320. getCustomMeshPosition(): Vector3;
  151321. /**
  151322. * Disposes the internal assets and detaches the post-process from the camera
  151323. */
  151324. dispose(camera: Camera): void;
  151325. /**
  151326. * Returns the render target texture used by the post-process
  151327. * @return the render target texture used by the post-process
  151328. */
  151329. getPass(): RenderTargetTexture;
  151330. private _meshExcluded;
  151331. private _createPass;
  151332. private _updateMeshScreenCoordinates;
  151333. /**
  151334. * Creates a default mesh for the Volumeric Light Scattering post-process
  151335. * @param name The mesh name
  151336. * @param scene The scene where to create the mesh
  151337. * @return the default mesh
  151338. */
  151339. static CreateDefaultMesh(name: string, scene: Scene): Mesh;
  151340. }
  151341. }
  151342. declare module BABYLON {
  151343. /** @hidden */
  151344. export var screenSpaceCurvaturePixelShader: {
  151345. name: string;
  151346. shader: string;
  151347. };
  151348. }
  151349. declare module BABYLON {
  151350. /**
  151351. * The Screen Space curvature effect can help highlighting ridge and valley of a model.
  151352. */
  151353. export class ScreenSpaceCurvaturePostProcess extends PostProcess {
  151354. /**
  151355. * Defines how much ridge the curvature effect displays.
  151356. */
  151357. ridge: number;
  151358. /**
  151359. * Defines how much valley the curvature effect displays.
  151360. */
  151361. valley: number;
  151362. private _geometryBufferRenderer;
  151363. /**
  151364. * Gets a string identifying the name of the class
  151365. * @returns "ScreenSpaceCurvaturePostProcess" string
  151366. */
  151367. getClassName(): string;
  151368. /**
  151369. * Creates a new instance ScreenSpaceCurvaturePostProcess
  151370. * @param name The name of the effect.
  151371. * @param scene The scene containing the objects to blur according to their velocity.
  151372. * @param options The required width/height ratio to downsize to before computing the render pass.
  151373. * @param camera The camera to apply the render pass to.
  151374. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  151375. * @param engine The engine which the post process will be applied. (default: current engine)
  151376. * @param reusable If the post process can be reused on the same frame. (default: false)
  151377. * @param textureType Type of textures used when performing the post process. (default: 0)
  151378. * @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)
  151379. */
  151380. constructor(name: string, scene: Scene, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  151381. /**
  151382. * Support test.
  151383. */
  151384. static get IsSupported(): boolean;
  151385. /** @hidden */
  151386. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): ScreenSpaceCurvaturePostProcess;
  151387. }
  151388. }
  151389. declare module BABYLON {
  151390. interface Scene {
  151391. /** @hidden (Backing field) */
  151392. _boundingBoxRenderer: BoundingBoxRenderer;
  151393. /** @hidden (Backing field) */
  151394. _forceShowBoundingBoxes: boolean;
  151395. /**
  151396. * Gets or sets a boolean indicating if all bounding boxes must be rendered
  151397. */
  151398. forceShowBoundingBoxes: boolean;
  151399. /**
  151400. * Gets the bounding box renderer associated with the scene
  151401. * @returns a BoundingBoxRenderer
  151402. */
  151403. getBoundingBoxRenderer(): BoundingBoxRenderer;
  151404. }
  151405. interface AbstractMesh {
  151406. /** @hidden (Backing field) */
  151407. _showBoundingBox: boolean;
  151408. /**
  151409. * Gets or sets a boolean indicating if the bounding box must be rendered as well (false by default)
  151410. */
  151411. showBoundingBox: boolean;
  151412. }
  151413. /**
  151414. * Component responsible of rendering the bounding box of the meshes in a scene.
  151415. * This is usually used through the mesh.showBoundingBox or the scene.forceShowBoundingBoxes properties
  151416. */
  151417. export class BoundingBoxRenderer implements ISceneComponent {
  151418. /**
  151419. * The component name helpfull to identify the component in the list of scene components.
  151420. */
  151421. readonly name: string;
  151422. /**
  151423. * The scene the component belongs to.
  151424. */
  151425. scene: Scene;
  151426. /**
  151427. * Color of the bounding box lines placed in front of an object
  151428. */
  151429. frontColor: Color3;
  151430. /**
  151431. * Color of the bounding box lines placed behind an object
  151432. */
  151433. backColor: Color3;
  151434. /**
  151435. * Defines if the renderer should show the back lines or not
  151436. */
  151437. showBackLines: boolean;
  151438. /**
  151439. * Observable raised before rendering a bounding box
  151440. */
  151441. onBeforeBoxRenderingObservable: Observable<BoundingBox>;
  151442. /**
  151443. * Observable raised after rendering a bounding box
  151444. */
  151445. onAfterBoxRenderingObservable: Observable<BoundingBox>;
  151446. /**
  151447. * @hidden
  151448. */
  151449. renderList: SmartArray<BoundingBox>;
  151450. private _colorShader;
  151451. private _vertexBuffers;
  151452. private _indexBuffer;
  151453. private _fillIndexBuffer;
  151454. private _fillIndexData;
  151455. /**
  151456. * Instantiates a new bounding box renderer in a scene.
  151457. * @param scene the scene the renderer renders in
  151458. */
  151459. constructor(scene: Scene);
  151460. /**
  151461. * Registers the component in a given scene
  151462. */
  151463. register(): void;
  151464. private _evaluateSubMesh;
  151465. private _activeMesh;
  151466. private _prepareRessources;
  151467. private _createIndexBuffer;
  151468. /**
  151469. * Rebuilds the elements related to this component in case of
  151470. * context lost for instance.
  151471. */
  151472. rebuild(): void;
  151473. /**
  151474. * @hidden
  151475. */
  151476. reset(): void;
  151477. /**
  151478. * Render the bounding boxes of a specific rendering group
  151479. * @param renderingGroupId defines the rendering group to render
  151480. */
  151481. render(renderingGroupId: number): void;
  151482. /**
  151483. * In case of occlusion queries, we can render the occlusion bounding box through this method
  151484. * @param mesh Define the mesh to render the occlusion bounding box for
  151485. */
  151486. renderOcclusionBoundingBox(mesh: AbstractMesh): void;
  151487. /**
  151488. * Dispose and release the resources attached to this renderer.
  151489. */
  151490. dispose(): void;
  151491. }
  151492. }
  151493. declare module BABYLON {
  151494. interface Scene {
  151495. /** @hidden (Backing field) */
  151496. _depthRenderer: {
  151497. [id: string]: DepthRenderer;
  151498. };
  151499. /**
  151500. * Creates a depth renderer a given camera which contains a depth map which can be used for post processing.
  151501. * @param camera The camera to create the depth renderer on (default: scene's active camera)
  151502. * @param storeNonLinearDepth Defines whether the depth is stored linearly like in Babylon Shadows or directly like glFragCoord.z
  151503. * @returns the created depth renderer
  151504. */
  151505. enableDepthRenderer(camera?: Nullable<Camera>, storeNonLinearDepth?: boolean): DepthRenderer;
  151506. /**
  151507. * Disables a depth renderer for a given camera
  151508. * @param camera The camera to disable the depth renderer on (default: scene's active camera)
  151509. */
  151510. disableDepthRenderer(camera?: Nullable<Camera>): void;
  151511. }
  151512. /**
  151513. * Defines the Depth Renderer scene component responsible to manage a depth buffer useful
  151514. * in several rendering techniques.
  151515. */
  151516. export class DepthRendererSceneComponent implements ISceneComponent {
  151517. /**
  151518. * The component name helpfull to identify the component in the list of scene components.
  151519. */
  151520. readonly name: string;
  151521. /**
  151522. * The scene the component belongs to.
  151523. */
  151524. scene: Scene;
  151525. /**
  151526. * Creates a new instance of the component for the given scene
  151527. * @param scene Defines the scene to register the component in
  151528. */
  151529. constructor(scene: Scene);
  151530. /**
  151531. * Registers the component in a given scene
  151532. */
  151533. register(): void;
  151534. /**
  151535. * Rebuilds the elements related to this component in case of
  151536. * context lost for instance.
  151537. */
  151538. rebuild(): void;
  151539. /**
  151540. * Disposes the component and the associated ressources
  151541. */
  151542. dispose(): void;
  151543. private _gatherRenderTargets;
  151544. private _gatherActiveCameraRenderTargets;
  151545. }
  151546. }
  151547. declare module BABYLON {
  151548. interface AbstractScene {
  151549. /** @hidden (Backing field) */
  151550. _prePassRenderer: Nullable<PrePassRenderer>;
  151551. /**
  151552. * Gets or Sets the current prepass renderer associated to the scene.
  151553. */
  151554. prePassRenderer: Nullable<PrePassRenderer>;
  151555. /**
  151556. * Enables the prepass and associates it with the scene
  151557. * @returns the PrePassRenderer
  151558. */
  151559. enablePrePassRenderer(): Nullable<PrePassRenderer>;
  151560. /**
  151561. * Disables the prepass associated with the scene
  151562. */
  151563. disablePrePassRenderer(): void;
  151564. }
  151565. /**
  151566. * Defines the Geometry Buffer scene component responsible to manage a G-Buffer useful
  151567. * in several rendering techniques.
  151568. */
  151569. export class PrePassRendererSceneComponent implements ISceneSerializableComponent {
  151570. /**
  151571. * The component name helpful to identify the component in the list of scene components.
  151572. */
  151573. readonly name: string;
  151574. /**
  151575. * The scene the component belongs to.
  151576. */
  151577. scene: Scene;
  151578. /**
  151579. * Creates a new instance of the component for the given scene
  151580. * @param scene Defines the scene to register the component in
  151581. */
  151582. constructor(scene: Scene);
  151583. /**
  151584. * Registers the component in a given scene
  151585. */
  151586. register(): void;
  151587. private _beforeCameraDraw;
  151588. private _afterCameraDraw;
  151589. private _beforeClearStage;
  151590. /**
  151591. * Serializes the component data to the specified json object
  151592. * @param serializationObject The object to serialize to
  151593. */
  151594. serialize(serializationObject: any): void;
  151595. /**
  151596. * Adds all the elements from the container to the scene
  151597. * @param container the container holding the elements
  151598. */
  151599. addFromContainer(container: AbstractScene): void;
  151600. /**
  151601. * Removes all the elements in the container from the scene
  151602. * @param container contains the elements to remove
  151603. * @param dispose if the removed element should be disposed (default: false)
  151604. */
  151605. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  151606. /**
  151607. * Rebuilds the elements related to this component in case of
  151608. * context lost for instance.
  151609. */
  151610. rebuild(): void;
  151611. /**
  151612. * Disposes the component and the associated ressources
  151613. */
  151614. dispose(): void;
  151615. }
  151616. }
  151617. declare module BABYLON {
  151618. /** @hidden */
  151619. export var outlinePixelShader: {
  151620. name: string;
  151621. shader: string;
  151622. };
  151623. }
  151624. declare module BABYLON {
  151625. /** @hidden */
  151626. export var outlineVertexShader: {
  151627. name: string;
  151628. shader: string;
  151629. };
  151630. }
  151631. declare module BABYLON {
  151632. interface Scene {
  151633. /** @hidden */
  151634. _outlineRenderer: OutlineRenderer;
  151635. /**
  151636. * Gets the outline renderer associated with the scene
  151637. * @returns a OutlineRenderer
  151638. */
  151639. getOutlineRenderer(): OutlineRenderer;
  151640. }
  151641. interface AbstractMesh {
  151642. /** @hidden (Backing field) */
  151643. _renderOutline: boolean;
  151644. /**
  151645. * Gets or sets a boolean indicating if the outline must be rendered as well
  151646. * @see https://www.babylonjs-playground.com/#10WJ5S#3
  151647. */
  151648. renderOutline: boolean;
  151649. /** @hidden (Backing field) */
  151650. _renderOverlay: boolean;
  151651. /**
  151652. * Gets or sets a boolean indicating if the overlay must be rendered as well
  151653. * @see https://www.babylonjs-playground.com/#10WJ5S#2
  151654. */
  151655. renderOverlay: boolean;
  151656. }
  151657. /**
  151658. * This class is responsible to draw bothe outline/overlay of meshes.
  151659. * It should not be used directly but through the available method on mesh.
  151660. */
  151661. export class OutlineRenderer implements ISceneComponent {
  151662. /**
  151663. * Stencil value used to avoid outline being seen within the mesh when the mesh is transparent
  151664. */
  151665. private static _StencilReference;
  151666. /**
  151667. * The name of the component. Each component must have a unique name.
  151668. */
  151669. name: string;
  151670. /**
  151671. * The scene the component belongs to.
  151672. */
  151673. scene: Scene;
  151674. /**
  151675. * Defines a zOffset to prevent zFighting between the overlay and the mesh.
  151676. */
  151677. zOffset: number;
  151678. private _engine;
  151679. private _effect;
  151680. private _cachedDefines;
  151681. private _savedDepthWrite;
  151682. /**
  151683. * Instantiates a new outline renderer. (There could be only one per scene).
  151684. * @param scene Defines the scene it belongs to
  151685. */
  151686. constructor(scene: Scene);
  151687. /**
  151688. * Register the component to one instance of a scene.
  151689. */
  151690. register(): void;
  151691. /**
  151692. * Rebuilds the elements related to this component in case of
  151693. * context lost for instance.
  151694. */
  151695. rebuild(): void;
  151696. /**
  151697. * Disposes the component and the associated ressources.
  151698. */
  151699. dispose(): void;
  151700. /**
  151701. * Renders the outline in the canvas.
  151702. * @param subMesh Defines the sumesh to render
  151703. * @param batch Defines the batch of meshes in case of instances
  151704. * @param useOverlay Defines if the rendering is for the overlay or the outline
  151705. */
  151706. render(subMesh: SubMesh, batch: _InstancesBatch, useOverlay?: boolean): void;
  151707. /**
  151708. * Returns whether or not the outline renderer is ready for a given submesh.
  151709. * All the dependencies e.g. submeshes, texture, effect... mus be ready
  151710. * @param subMesh Defines the submesh to check readyness for
  151711. * @param useInstances Defines wheter wee are trying to render instances or not
  151712. * @returns true if ready otherwise false
  151713. */
  151714. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  151715. private _beforeRenderingMesh;
  151716. private _afterRenderingMesh;
  151717. }
  151718. }
  151719. declare module BABYLON {
  151720. /**
  151721. * Defines the basic options interface of a Sprite Frame Source Size.
  151722. */
  151723. export interface ISpriteJSONSpriteSourceSize {
  151724. /**
  151725. * number of the original width of the Frame
  151726. */
  151727. w: number;
  151728. /**
  151729. * number of the original height of the Frame
  151730. */
  151731. h: number;
  151732. }
  151733. /**
  151734. * Defines the basic options interface of a Sprite Frame Data.
  151735. */
  151736. export interface ISpriteJSONSpriteFrameData {
  151737. /**
  151738. * number of the x offset of the Frame
  151739. */
  151740. x: number;
  151741. /**
  151742. * number of the y offset of the Frame
  151743. */
  151744. y: number;
  151745. /**
  151746. * number of the width of the Frame
  151747. */
  151748. w: number;
  151749. /**
  151750. * number of the height of the Frame
  151751. */
  151752. h: number;
  151753. }
  151754. /**
  151755. * Defines the basic options interface of a JSON Sprite.
  151756. */
  151757. export interface ISpriteJSONSprite {
  151758. /**
  151759. * string name of the Frame
  151760. */
  151761. filename: string;
  151762. /**
  151763. * ISpriteJSONSpriteFrame basic object of the frame data
  151764. */
  151765. frame: ISpriteJSONSpriteFrameData;
  151766. /**
  151767. * boolean to flag is the frame was rotated.
  151768. */
  151769. rotated: boolean;
  151770. /**
  151771. * boolean to flag is the frame was trimmed.
  151772. */
  151773. trimmed: boolean;
  151774. /**
  151775. * ISpriteJSONSpriteFrame basic object of the source data
  151776. */
  151777. spriteSourceSize: ISpriteJSONSpriteFrameData;
  151778. /**
  151779. * ISpriteJSONSpriteFrame basic object of the source data
  151780. */
  151781. sourceSize: ISpriteJSONSpriteSourceSize;
  151782. }
  151783. /**
  151784. * Defines the basic options interface of a JSON atlas.
  151785. */
  151786. export interface ISpriteJSONAtlas {
  151787. /**
  151788. * Array of objects that contain the frame data.
  151789. */
  151790. frames: Array<ISpriteJSONSprite>;
  151791. /**
  151792. * object basic object containing the sprite meta data.
  151793. */
  151794. meta?: object;
  151795. }
  151796. }
  151797. declare module BABYLON {
  151798. /** @hidden */
  151799. export var spriteMapPixelShader: {
  151800. name: string;
  151801. shader: string;
  151802. };
  151803. }
  151804. declare module BABYLON {
  151805. /** @hidden */
  151806. export var spriteMapVertexShader: {
  151807. name: string;
  151808. shader: string;
  151809. };
  151810. }
  151811. declare module BABYLON {
  151812. /**
  151813. * Defines the basic options interface of a SpriteMap
  151814. */
  151815. export interface ISpriteMapOptions {
  151816. /**
  151817. * Vector2 of the number of cells in the grid.
  151818. */
  151819. stageSize?: Vector2;
  151820. /**
  151821. * Vector2 of the size of the output plane in World Units.
  151822. */
  151823. outputSize?: Vector2;
  151824. /**
  151825. * Vector3 of the position of the output plane in World Units.
  151826. */
  151827. outputPosition?: Vector3;
  151828. /**
  151829. * Vector3 of the rotation of the output plane.
  151830. */
  151831. outputRotation?: Vector3;
  151832. /**
  151833. * number of layers that the system will reserve in resources.
  151834. */
  151835. layerCount?: number;
  151836. /**
  151837. * number of max animation frames a single cell will reserve in resources.
  151838. */
  151839. maxAnimationFrames?: number;
  151840. /**
  151841. * number cell index of the base tile when the system compiles.
  151842. */
  151843. baseTile?: number;
  151844. /**
  151845. * boolean flip the sprite after its been repositioned by the framing data.
  151846. */
  151847. flipU?: boolean;
  151848. /**
  151849. * Vector3 scalar of the global RGB values of the SpriteMap.
  151850. */
  151851. colorMultiply?: Vector3;
  151852. }
  151853. /**
  151854. * Defines the IDisposable interface in order to be cleanable from resources.
  151855. */
  151856. export interface ISpriteMap extends IDisposable {
  151857. /**
  151858. * String name of the SpriteMap.
  151859. */
  151860. name: string;
  151861. /**
  151862. * The JSON Array file from a https://www.codeandweb.com/texturepacker export. Or similar structure.
  151863. */
  151864. atlasJSON: ISpriteJSONAtlas;
  151865. /**
  151866. * Texture of the SpriteMap.
  151867. */
  151868. spriteSheet: Texture;
  151869. /**
  151870. * The parameters to initialize the SpriteMap with.
  151871. */
  151872. options: ISpriteMapOptions;
  151873. }
  151874. /**
  151875. * Class used to manage a grid restricted sprite deployment on an Output plane.
  151876. */
  151877. export class SpriteMap implements ISpriteMap {
  151878. /** The Name of the spriteMap */
  151879. name: string;
  151880. /** The JSON file with the frame and meta data */
  151881. atlasJSON: ISpriteJSONAtlas;
  151882. /** The systems Sprite Sheet Texture */
  151883. spriteSheet: Texture;
  151884. /** Arguments passed with the Constructor */
  151885. options: ISpriteMapOptions;
  151886. /** Public Sprite Storage array, parsed from atlasJSON */
  151887. sprites: Array<ISpriteJSONSprite>;
  151888. /** Returns the Number of Sprites in the System */
  151889. get spriteCount(): number;
  151890. /** Returns the Position of Output Plane*/
  151891. get position(): Vector3;
  151892. /** Returns the Position of Output Plane*/
  151893. set position(v: Vector3);
  151894. /** Returns the Rotation of Output Plane*/
  151895. get rotation(): Vector3;
  151896. /** Returns the Rotation of Output Plane*/
  151897. set rotation(v: Vector3);
  151898. /** Sets the AnimationMap*/
  151899. get animationMap(): RawTexture;
  151900. /** Sets the AnimationMap*/
  151901. set animationMap(v: RawTexture);
  151902. /** Scene that the SpriteMap was created in */
  151903. private _scene;
  151904. /** Texture Buffer of Float32 that holds tile frame data*/
  151905. private _frameMap;
  151906. /** Texture Buffers of Float32 that holds tileMap data*/
  151907. private _tileMaps;
  151908. /** Texture Buffer of Float32 that holds Animation Data*/
  151909. private _animationMap;
  151910. /** Custom ShaderMaterial Central to the System*/
  151911. private _material;
  151912. /** Custom ShaderMaterial Central to the System*/
  151913. private _output;
  151914. /** Systems Time Ticker*/
  151915. private _time;
  151916. /**
  151917. * Creates a new SpriteMap
  151918. * @param name defines the SpriteMaps Name
  151919. * @param atlasJSON is the JSON file that controls the Sprites Frames and Meta
  151920. * @param spriteSheet is the Texture that the Sprites are on.
  151921. * @param options a basic deployment configuration
  151922. * @param scene The Scene that the map is deployed on
  151923. */
  151924. constructor(name: string, atlasJSON: ISpriteJSONAtlas, spriteSheet: Texture, options: ISpriteMapOptions, scene: Scene);
  151925. /**
  151926. * Returns tileID location
  151927. * @returns Vector2 the cell position ID
  151928. */
  151929. getTileID(): Vector2;
  151930. /**
  151931. * Gets the UV location of the mouse over the SpriteMap.
  151932. * @returns Vector2 the UV position of the mouse interaction
  151933. */
  151934. getMousePosition(): Vector2;
  151935. /**
  151936. * Creates the "frame" texture Buffer
  151937. * -------------------------------------
  151938. * Structure of frames
  151939. * "filename": "Falling-Water-2.png",
  151940. * "frame": {"x":69,"y":103,"w":24,"h":32},
  151941. * "rotated": true,
  151942. * "trimmed": true,
  151943. * "spriteSourceSize": {"x":4,"y":0,"w":24,"h":32},
  151944. * "sourceSize": {"w":32,"h":32}
  151945. * @returns RawTexture of the frameMap
  151946. */
  151947. private _createFrameBuffer;
  151948. /**
  151949. * Creates the tileMap texture Buffer
  151950. * @param buffer normally and array of numbers, or a false to generate from scratch
  151951. * @param _layer indicates what layer for a logic trigger dealing with the baseTile. The system uses this
  151952. * @returns RawTexture of the tileMap
  151953. */
  151954. private _createTileBuffer;
  151955. /**
  151956. * Modifies the data of the tileMaps
  151957. * @param _layer is the ID of the layer you want to edit on the SpriteMap
  151958. * @param pos is the iVector2 Coordinates of the Tile
  151959. * @param tile The SpriteIndex of the new Tile
  151960. */
  151961. changeTiles(_layer: number | undefined, pos: Vector2 | Vector2[], tile?: number): void;
  151962. /**
  151963. * Creates the animationMap texture Buffer
  151964. * @param buffer normally and array of numbers, or a false to generate from scratch
  151965. * @returns RawTexture of the animationMap
  151966. */
  151967. private _createTileAnimationBuffer;
  151968. /**
  151969. * Modifies the data of the animationMap
  151970. * @param cellID is the Index of the Sprite
  151971. * @param _frame is the target Animation frame
  151972. * @param toCell is the Target Index of the next frame of the animation
  151973. * @param time is a value between 0-1 that is the trigger for when the frame should change tiles
  151974. * @param speed is a global scalar of the time variable on the map.
  151975. */
  151976. addAnimationToTile(cellID?: number, _frame?: number, toCell?: number, time?: number, speed?: number): void;
  151977. /**
  151978. * Exports the .tilemaps file
  151979. */
  151980. saveTileMaps(): void;
  151981. /**
  151982. * Imports the .tilemaps file
  151983. * @param url of the .tilemaps file
  151984. */
  151985. loadTileMaps(url: string): void;
  151986. /**
  151987. * Release associated resources
  151988. */
  151989. dispose(): void;
  151990. }
  151991. }
  151992. declare module BABYLON {
  151993. /**
  151994. * Class used to manage multiple sprites of different sizes on the same spritesheet
  151995. * @see https://doc.babylonjs.com/babylon101/sprites
  151996. */
  151997. export class SpritePackedManager extends SpriteManager {
  151998. /** defines the packed manager's name */
  151999. name: string;
  152000. /**
  152001. * Creates a new sprite manager from a packed sprite sheet
  152002. * @param name defines the manager's name
  152003. * @param imgUrl defines the sprite sheet url
  152004. * @param capacity defines the maximum allowed number of sprites
  152005. * @param scene defines the hosting scene
  152006. * @param spriteJSON null otherwise a JSON object defining sprite sheet data
  152007. * @param epsilon defines the epsilon value to align texture (0.01 by default)
  152008. * @param samplingMode defines the smapling mode to use with spritesheet
  152009. * @param fromPacked set to true; do not alter
  152010. */
  152011. constructor(
  152012. /** defines the packed manager's name */
  152013. name: string, imgUrl: string, capacity: number, scene: Scene, spriteJSON?: string | null, epsilon?: number, samplingMode?: number);
  152014. }
  152015. }
  152016. declare module BABYLON {
  152017. /**
  152018. * Defines the list of states available for a task inside a AssetsManager
  152019. */
  152020. export enum AssetTaskState {
  152021. /**
  152022. * Initialization
  152023. */
  152024. INIT = 0,
  152025. /**
  152026. * Running
  152027. */
  152028. RUNNING = 1,
  152029. /**
  152030. * Done
  152031. */
  152032. DONE = 2,
  152033. /**
  152034. * Error
  152035. */
  152036. ERROR = 3
  152037. }
  152038. /**
  152039. * Define an abstract asset task used with a AssetsManager class to load assets into a scene
  152040. */
  152041. export abstract class AbstractAssetTask {
  152042. /**
  152043. * Task name
  152044. */ name: string;
  152045. /**
  152046. * Callback called when the task is successful
  152047. */
  152048. onSuccess: (task: any) => void;
  152049. /**
  152050. * Callback called when the task is not successful
  152051. */
  152052. onError: (task: any, message?: string, exception?: any) => void;
  152053. /**
  152054. * Creates a new AssetsManager
  152055. * @param name defines the name of the task
  152056. */
  152057. constructor(
  152058. /**
  152059. * Task name
  152060. */ name: string);
  152061. private _isCompleted;
  152062. private _taskState;
  152063. private _errorObject;
  152064. /**
  152065. * Get if the task is completed
  152066. */
  152067. get isCompleted(): boolean;
  152068. /**
  152069. * Gets the current state of the task
  152070. */
  152071. get taskState(): AssetTaskState;
  152072. /**
  152073. * Gets the current error object (if task is in error)
  152074. */
  152075. get errorObject(): {
  152076. message?: string;
  152077. exception?: any;
  152078. };
  152079. /**
  152080. * Internal only
  152081. * @hidden
  152082. */
  152083. _setErrorObject(message?: string, exception?: any): void;
  152084. /**
  152085. * Execute the current task
  152086. * @param scene defines the scene where you want your assets to be loaded
  152087. * @param onSuccess is a callback called when the task is successfully executed
  152088. * @param onError is a callback called if an error occurs
  152089. */
  152090. run(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  152091. /**
  152092. * Execute the current task
  152093. * @param scene defines the scene where you want your assets to be loaded
  152094. * @param onSuccess is a callback called when the task is successfully executed
  152095. * @param onError is a callback called if an error occurs
  152096. */
  152097. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  152098. /**
  152099. * Reset will set the task state back to INIT, so the next load call of the assets manager will execute this task again.
  152100. * This can be used with failed tasks that have the reason for failure fixed.
  152101. */
  152102. reset(): void;
  152103. private onErrorCallback;
  152104. private onDoneCallback;
  152105. }
  152106. /**
  152107. * Define the interface used by progress events raised during assets loading
  152108. */
  152109. export interface IAssetsProgressEvent {
  152110. /**
  152111. * Defines the number of remaining tasks to process
  152112. */
  152113. remainingCount: number;
  152114. /**
  152115. * Defines the total number of tasks
  152116. */
  152117. totalCount: number;
  152118. /**
  152119. * Defines the task that was just processed
  152120. */
  152121. task: AbstractAssetTask;
  152122. }
  152123. /**
  152124. * Class used to share progress information about assets loading
  152125. */
  152126. export class AssetsProgressEvent implements IAssetsProgressEvent {
  152127. /**
  152128. * Defines the number of remaining tasks to process
  152129. */
  152130. remainingCount: number;
  152131. /**
  152132. * Defines the total number of tasks
  152133. */
  152134. totalCount: number;
  152135. /**
  152136. * Defines the task that was just processed
  152137. */
  152138. task: AbstractAssetTask;
  152139. /**
  152140. * Creates a AssetsProgressEvent
  152141. * @param remainingCount defines the number of remaining tasks to process
  152142. * @param totalCount defines the total number of tasks
  152143. * @param task defines the task that was just processed
  152144. */
  152145. constructor(remainingCount: number, totalCount: number, task: AbstractAssetTask);
  152146. }
  152147. /**
  152148. * Define a task used by AssetsManager to load assets into a container
  152149. */
  152150. export class ContainerAssetTask extends AbstractAssetTask {
  152151. /**
  152152. * Defines the name of the task
  152153. */
  152154. name: string;
  152155. /**
  152156. * Defines the list of mesh's names you want to load
  152157. */
  152158. meshesNames: any;
  152159. /**
  152160. * Defines the root url to use as a base to load your meshes and associated resources
  152161. */
  152162. rootUrl: string;
  152163. /**
  152164. * Defines the filename or File of the scene to load from
  152165. */
  152166. sceneFilename: string | File;
  152167. /**
  152168. * Get the loaded asset container
  152169. */
  152170. loadedContainer: AssetContainer;
  152171. /**
  152172. * Gets the list of loaded meshes
  152173. */
  152174. loadedMeshes: Array<AbstractMesh>;
  152175. /**
  152176. * Gets the list of loaded particle systems
  152177. */
  152178. loadedParticleSystems: Array<IParticleSystem>;
  152179. /**
  152180. * Gets the list of loaded skeletons
  152181. */
  152182. loadedSkeletons: Array<Skeleton>;
  152183. /**
  152184. * Gets the list of loaded animation groups
  152185. */
  152186. loadedAnimationGroups: Array<AnimationGroup>;
  152187. /**
  152188. * Callback called when the task is successful
  152189. */
  152190. onSuccess: (task: ContainerAssetTask) => void;
  152191. /**
  152192. * Callback called when the task is successful
  152193. */
  152194. onError: (task: ContainerAssetTask, message?: string, exception?: any) => void;
  152195. /**
  152196. * Creates a new ContainerAssetTask
  152197. * @param name defines the name of the task
  152198. * @param meshesNames defines the list of mesh's names you want to load
  152199. * @param rootUrl defines the root url to use as a base to load your meshes and associated resources
  152200. * @param sceneFilename defines the filename or File of the scene to load from
  152201. */
  152202. constructor(
  152203. /**
  152204. * Defines the name of the task
  152205. */
  152206. name: string,
  152207. /**
  152208. * Defines the list of mesh's names you want to load
  152209. */
  152210. meshesNames: any,
  152211. /**
  152212. * Defines the root url to use as a base to load your meshes and associated resources
  152213. */
  152214. rootUrl: string,
  152215. /**
  152216. * Defines the filename or File of the scene to load from
  152217. */
  152218. sceneFilename: string | File);
  152219. /**
  152220. * Execute the current task
  152221. * @param scene defines the scene where you want your assets to be loaded
  152222. * @param onSuccess is a callback called when the task is successfully executed
  152223. * @param onError is a callback called if an error occurs
  152224. */
  152225. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  152226. }
  152227. /**
  152228. * Define a task used by AssetsManager to load meshes
  152229. */
  152230. export class MeshAssetTask extends AbstractAssetTask {
  152231. /**
  152232. * Defines the name of the task
  152233. */
  152234. name: string;
  152235. /**
  152236. * Defines the list of mesh's names you want to load
  152237. */
  152238. meshesNames: any;
  152239. /**
  152240. * Defines the root url to use as a base to load your meshes and associated resources
  152241. */
  152242. rootUrl: string;
  152243. /**
  152244. * Defines the filename or File of the scene to load from
  152245. */
  152246. sceneFilename: string | File;
  152247. /**
  152248. * Gets the list of loaded meshes
  152249. */
  152250. loadedMeshes: Array<AbstractMesh>;
  152251. /**
  152252. * Gets the list of loaded particle systems
  152253. */
  152254. loadedParticleSystems: Array<IParticleSystem>;
  152255. /**
  152256. * Gets the list of loaded skeletons
  152257. */
  152258. loadedSkeletons: Array<Skeleton>;
  152259. /**
  152260. * Gets the list of loaded animation groups
  152261. */
  152262. loadedAnimationGroups: Array<AnimationGroup>;
  152263. /**
  152264. * Callback called when the task is successful
  152265. */
  152266. onSuccess: (task: MeshAssetTask) => void;
  152267. /**
  152268. * Callback called when the task is successful
  152269. */
  152270. onError: (task: MeshAssetTask, message?: string, exception?: any) => void;
  152271. /**
  152272. * Creates a new MeshAssetTask
  152273. * @param name defines the name of the task
  152274. * @param meshesNames defines the list of mesh's names you want to load
  152275. * @param rootUrl defines the root url to use as a base to load your meshes and associated resources
  152276. * @param sceneFilename defines the filename or File of the scene to load from
  152277. */
  152278. constructor(
  152279. /**
  152280. * Defines the name of the task
  152281. */
  152282. name: string,
  152283. /**
  152284. * Defines the list of mesh's names you want to load
  152285. */
  152286. meshesNames: any,
  152287. /**
  152288. * Defines the root url to use as a base to load your meshes and associated resources
  152289. */
  152290. rootUrl: string,
  152291. /**
  152292. * Defines the filename or File of the scene to load from
  152293. */
  152294. sceneFilename: string | File);
  152295. /**
  152296. * Execute the current task
  152297. * @param scene defines the scene where you want your assets to be loaded
  152298. * @param onSuccess is a callback called when the task is successfully executed
  152299. * @param onError is a callback called if an error occurs
  152300. */
  152301. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  152302. }
  152303. /**
  152304. * Define a task used by AssetsManager to load text content
  152305. */
  152306. export class TextFileAssetTask extends AbstractAssetTask {
  152307. /**
  152308. * Defines the name of the task
  152309. */
  152310. name: string;
  152311. /**
  152312. * Defines the location of the file to load
  152313. */
  152314. url: string;
  152315. /**
  152316. * Gets the loaded text string
  152317. */
  152318. text: string;
  152319. /**
  152320. * Callback called when the task is successful
  152321. */
  152322. onSuccess: (task: TextFileAssetTask) => void;
  152323. /**
  152324. * Callback called when the task is successful
  152325. */
  152326. onError: (task: TextFileAssetTask, message?: string, exception?: any) => void;
  152327. /**
  152328. * Creates a new TextFileAssetTask object
  152329. * @param name defines the name of the task
  152330. * @param url defines the location of the file to load
  152331. */
  152332. constructor(
  152333. /**
  152334. * Defines the name of the task
  152335. */
  152336. name: string,
  152337. /**
  152338. * Defines the location of the file to load
  152339. */
  152340. url: string);
  152341. /**
  152342. * Execute the current task
  152343. * @param scene defines the scene where you want your assets to be loaded
  152344. * @param onSuccess is a callback called when the task is successfully executed
  152345. * @param onError is a callback called if an error occurs
  152346. */
  152347. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  152348. }
  152349. /**
  152350. * Define a task used by AssetsManager to load binary data
  152351. */
  152352. export class BinaryFileAssetTask extends AbstractAssetTask {
  152353. /**
  152354. * Defines the name of the task
  152355. */
  152356. name: string;
  152357. /**
  152358. * Defines the location of the file to load
  152359. */
  152360. url: string;
  152361. /**
  152362. * Gets the lodaded data (as an array buffer)
  152363. */
  152364. data: ArrayBuffer;
  152365. /**
  152366. * Callback called when the task is successful
  152367. */
  152368. onSuccess: (task: BinaryFileAssetTask) => void;
  152369. /**
  152370. * Callback called when the task is successful
  152371. */
  152372. onError: (task: BinaryFileAssetTask, message?: string, exception?: any) => void;
  152373. /**
  152374. * Creates a new BinaryFileAssetTask object
  152375. * @param name defines the name of the new task
  152376. * @param url defines the location of the file to load
  152377. */
  152378. constructor(
  152379. /**
  152380. * Defines the name of the task
  152381. */
  152382. name: string,
  152383. /**
  152384. * Defines the location of the file to load
  152385. */
  152386. url: string);
  152387. /**
  152388. * Execute the current task
  152389. * @param scene defines the scene where you want your assets to be loaded
  152390. * @param onSuccess is a callback called when the task is successfully executed
  152391. * @param onError is a callback called if an error occurs
  152392. */
  152393. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  152394. }
  152395. /**
  152396. * Define a task used by AssetsManager to load images
  152397. */
  152398. export class ImageAssetTask extends AbstractAssetTask {
  152399. /**
  152400. * Defines the name of the task
  152401. */
  152402. name: string;
  152403. /**
  152404. * Defines the location of the image to load
  152405. */
  152406. url: string;
  152407. /**
  152408. * Gets the loaded images
  152409. */
  152410. image: HTMLImageElement;
  152411. /**
  152412. * Callback called when the task is successful
  152413. */
  152414. onSuccess: (task: ImageAssetTask) => void;
  152415. /**
  152416. * Callback called when the task is successful
  152417. */
  152418. onError: (task: ImageAssetTask, message?: string, exception?: any) => void;
  152419. /**
  152420. * Creates a new ImageAssetTask
  152421. * @param name defines the name of the task
  152422. * @param url defines the location of the image to load
  152423. */
  152424. constructor(
  152425. /**
  152426. * Defines the name of the task
  152427. */
  152428. name: string,
  152429. /**
  152430. * Defines the location of the image to load
  152431. */
  152432. url: string);
  152433. /**
  152434. * Execute the current task
  152435. * @param scene defines the scene where you want your assets to be loaded
  152436. * @param onSuccess is a callback called when the task is successfully executed
  152437. * @param onError is a callback called if an error occurs
  152438. */
  152439. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  152440. }
  152441. /**
  152442. * Defines the interface used by texture loading tasks
  152443. */
  152444. export interface ITextureAssetTask<TEX extends BaseTexture> {
  152445. /**
  152446. * Gets the loaded texture
  152447. */
  152448. texture: TEX;
  152449. }
  152450. /**
  152451. * Define a task used by AssetsManager to load 2D textures
  152452. */
  152453. export class TextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<Texture> {
  152454. /**
  152455. * Defines the name of the task
  152456. */
  152457. name: string;
  152458. /**
  152459. * Defines the location of the file to load
  152460. */
  152461. url: string;
  152462. /**
  152463. * Defines if mipmap should not be generated (default is false)
  152464. */
  152465. noMipmap?: boolean | undefined;
  152466. /**
  152467. * Defines if texture must be inverted on Y axis (default is true)
  152468. */
  152469. invertY: boolean;
  152470. /**
  152471. * Defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  152472. */
  152473. samplingMode: number;
  152474. /**
  152475. * Gets the loaded texture
  152476. */
  152477. texture: Texture;
  152478. /**
  152479. * Callback called when the task is successful
  152480. */
  152481. onSuccess: (task: TextureAssetTask) => void;
  152482. /**
  152483. * Callback called when the task is successful
  152484. */
  152485. onError: (task: TextureAssetTask, message?: string, exception?: any) => void;
  152486. /**
  152487. * Creates a new TextureAssetTask object
  152488. * @param name defines the name of the task
  152489. * @param url defines the location of the file to load
  152490. * @param noMipmap defines if mipmap should not be generated (default is false)
  152491. * @param invertY defines if texture must be inverted on Y axis (default is true)
  152492. * @param samplingMode defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  152493. */
  152494. constructor(
  152495. /**
  152496. * Defines the name of the task
  152497. */
  152498. name: string,
  152499. /**
  152500. * Defines the location of the file to load
  152501. */
  152502. url: string,
  152503. /**
  152504. * Defines if mipmap should not be generated (default is false)
  152505. */
  152506. noMipmap?: boolean | undefined,
  152507. /**
  152508. * Defines if texture must be inverted on Y axis (default is true)
  152509. */
  152510. invertY?: boolean,
  152511. /**
  152512. * Defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  152513. */
  152514. samplingMode?: number);
  152515. /**
  152516. * Execute the current task
  152517. * @param scene defines the scene where you want your assets to be loaded
  152518. * @param onSuccess is a callback called when the task is successfully executed
  152519. * @param onError is a callback called if an error occurs
  152520. */
  152521. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  152522. }
  152523. /**
  152524. * Define a task used by AssetsManager to load cube textures
  152525. */
  152526. export class CubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<CubeTexture> {
  152527. /**
  152528. * Defines the name of the task
  152529. */
  152530. name: string;
  152531. /**
  152532. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  152533. */
  152534. url: string;
  152535. /**
  152536. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  152537. */
  152538. extensions?: string[] | undefined;
  152539. /**
  152540. * Defines if mipmaps should not be generated (default is false)
  152541. */
  152542. noMipmap?: boolean | undefined;
  152543. /**
  152544. * Defines the explicit list of files (undefined by default)
  152545. */
  152546. files?: string[] | undefined;
  152547. /**
  152548. * Gets the loaded texture
  152549. */
  152550. texture: CubeTexture;
  152551. /**
  152552. * Callback called when the task is successful
  152553. */
  152554. onSuccess: (task: CubeTextureAssetTask) => void;
  152555. /**
  152556. * Callback called when the task is successful
  152557. */
  152558. onError: (task: CubeTextureAssetTask, message?: string, exception?: any) => void;
  152559. /**
  152560. * Creates a new CubeTextureAssetTask
  152561. * @param name defines the name of the task
  152562. * @param url defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  152563. * @param extensions defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  152564. * @param noMipmap defines if mipmaps should not be generated (default is false)
  152565. * @param files defines the explicit list of files (undefined by default)
  152566. */
  152567. constructor(
  152568. /**
  152569. * Defines the name of the task
  152570. */
  152571. name: string,
  152572. /**
  152573. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  152574. */
  152575. url: string,
  152576. /**
  152577. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  152578. */
  152579. extensions?: string[] | undefined,
  152580. /**
  152581. * Defines if mipmaps should not be generated (default is false)
  152582. */
  152583. noMipmap?: boolean | undefined,
  152584. /**
  152585. * Defines the explicit list of files (undefined by default)
  152586. */
  152587. files?: string[] | undefined);
  152588. /**
  152589. * Execute the current task
  152590. * @param scene defines the scene where you want your assets to be loaded
  152591. * @param onSuccess is a callback called when the task is successfully executed
  152592. * @param onError is a callback called if an error occurs
  152593. */
  152594. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  152595. }
  152596. /**
  152597. * Define a task used by AssetsManager to load HDR cube textures
  152598. */
  152599. export class HDRCubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<HDRCubeTexture> {
  152600. /**
  152601. * Defines the name of the task
  152602. */
  152603. name: string;
  152604. /**
  152605. * Defines the location of the file to load
  152606. */
  152607. url: string;
  152608. /**
  152609. * Defines the desired size (the more it increases the longer the generation will be)
  152610. */
  152611. size: number;
  152612. /**
  152613. * Defines if mipmaps should not be generated (default is false)
  152614. */
  152615. noMipmap: boolean;
  152616. /**
  152617. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  152618. */
  152619. generateHarmonics: boolean;
  152620. /**
  152621. * 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)
  152622. */
  152623. gammaSpace: boolean;
  152624. /**
  152625. * Internal Use Only
  152626. */
  152627. reserved: boolean;
  152628. /**
  152629. * Gets the loaded texture
  152630. */
  152631. texture: HDRCubeTexture;
  152632. /**
  152633. * Callback called when the task is successful
  152634. */
  152635. onSuccess: (task: HDRCubeTextureAssetTask) => void;
  152636. /**
  152637. * Callback called when the task is successful
  152638. */
  152639. onError: (task: HDRCubeTextureAssetTask, message?: string, exception?: any) => void;
  152640. /**
  152641. * Creates a new HDRCubeTextureAssetTask object
  152642. * @param name defines the name of the task
  152643. * @param url defines the location of the file to load
  152644. * @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.
  152645. * @param noMipmap defines if mipmaps should not be generated (default is false)
  152646. * @param generateHarmonics specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  152647. * @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)
  152648. * @param reserved Internal use only
  152649. */
  152650. constructor(
  152651. /**
  152652. * Defines the name of the task
  152653. */
  152654. name: string,
  152655. /**
  152656. * Defines the location of the file to load
  152657. */
  152658. url: string,
  152659. /**
  152660. * Defines the desired size (the more it increases the longer the generation will be)
  152661. */
  152662. size: number,
  152663. /**
  152664. * Defines if mipmaps should not be generated (default is false)
  152665. */
  152666. noMipmap?: boolean,
  152667. /**
  152668. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  152669. */
  152670. generateHarmonics?: boolean,
  152671. /**
  152672. * 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)
  152673. */
  152674. gammaSpace?: boolean,
  152675. /**
  152676. * Internal Use Only
  152677. */
  152678. reserved?: boolean);
  152679. /**
  152680. * Execute the current task
  152681. * @param scene defines the scene where you want your assets to be loaded
  152682. * @param onSuccess is a callback called when the task is successfully executed
  152683. * @param onError is a callback called if an error occurs
  152684. */
  152685. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  152686. }
  152687. /**
  152688. * Define a task used by AssetsManager to load Equirectangular cube textures
  152689. */
  152690. export class EquiRectangularCubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<EquiRectangularCubeTexture> {
  152691. /**
  152692. * Defines the name of the task
  152693. */
  152694. name: string;
  152695. /**
  152696. * Defines the location of the file to load
  152697. */
  152698. url: string;
  152699. /**
  152700. * Defines the desired size (the more it increases the longer the generation will be)
  152701. */
  152702. size: number;
  152703. /**
  152704. * Defines if mipmaps should not be generated (default is false)
  152705. */
  152706. noMipmap: boolean;
  152707. /**
  152708. * Specifies if the texture will be use in gamma or linear space (the PBR material requires those texture in linear space,
  152709. * but the standard material would require them in Gamma space) (default is true)
  152710. */
  152711. gammaSpace: boolean;
  152712. /**
  152713. * Gets the loaded texture
  152714. */
  152715. texture: EquiRectangularCubeTexture;
  152716. /**
  152717. * Callback called when the task is successful
  152718. */
  152719. onSuccess: (task: EquiRectangularCubeTextureAssetTask) => void;
  152720. /**
  152721. * Callback called when the task is successful
  152722. */
  152723. onError: (task: EquiRectangularCubeTextureAssetTask, message?: string, exception?: any) => void;
  152724. /**
  152725. * Creates a new EquiRectangularCubeTextureAssetTask object
  152726. * @param name defines the name of the task
  152727. * @param url defines the location of the file to load
  152728. * @param size defines the desired size (the more it increases the longer the generation will be)
  152729. * If the size is omitted this implies you are using a preprocessed cubemap.
  152730. * @param noMipmap defines if mipmaps should not be generated (default is false)
  152731. * @param gammaSpace specifies if the texture will be used in gamma or linear space
  152732. * (the PBR material requires those texture in linear space, but the standard material would require them in Gamma space)
  152733. * (default is true)
  152734. */
  152735. constructor(
  152736. /**
  152737. * Defines the name of the task
  152738. */
  152739. name: string,
  152740. /**
  152741. * Defines the location of the file to load
  152742. */
  152743. url: string,
  152744. /**
  152745. * Defines the desired size (the more it increases the longer the generation will be)
  152746. */
  152747. size: number,
  152748. /**
  152749. * Defines if mipmaps should not be generated (default is false)
  152750. */
  152751. noMipmap?: boolean,
  152752. /**
  152753. * Specifies if the texture will be use in gamma or linear space (the PBR material requires those texture in linear space,
  152754. * but the standard material would require them in Gamma space) (default is true)
  152755. */
  152756. gammaSpace?: boolean);
  152757. /**
  152758. * Execute the current task
  152759. * @param scene defines the scene where you want your assets to be loaded
  152760. * @param onSuccess is a callback called when the task is successfully executed
  152761. * @param onError is a callback called if an error occurs
  152762. */
  152763. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  152764. }
  152765. /**
  152766. * This class can be used to easily import assets into a scene
  152767. * @see https://doc.babylonjs.com/how_to/how_to_use_assetsmanager
  152768. */
  152769. export class AssetsManager {
  152770. private _scene;
  152771. private _isLoading;
  152772. protected _tasks: AbstractAssetTask[];
  152773. protected _waitingTasksCount: number;
  152774. protected _totalTasksCount: number;
  152775. /**
  152776. * Callback called when all tasks are processed
  152777. */
  152778. onFinish: (tasks: AbstractAssetTask[]) => void;
  152779. /**
  152780. * Callback called when a task is successful
  152781. */
  152782. onTaskSuccess: (task: AbstractAssetTask) => void;
  152783. /**
  152784. * Callback called when a task had an error
  152785. */
  152786. onTaskError: (task: AbstractAssetTask) => void;
  152787. /**
  152788. * Callback called when a task is done (whatever the result is)
  152789. */
  152790. onProgress: (remainingCount: number, totalCount: number, task: AbstractAssetTask) => void;
  152791. /**
  152792. * Observable called when all tasks are processed
  152793. */
  152794. onTaskSuccessObservable: Observable<AbstractAssetTask>;
  152795. /**
  152796. * Observable called when a task had an error
  152797. */
  152798. onTaskErrorObservable: Observable<AbstractAssetTask>;
  152799. /**
  152800. * Observable called when all tasks were executed
  152801. */
  152802. onTasksDoneObservable: Observable<AbstractAssetTask[]>;
  152803. /**
  152804. * Observable called when a task is done (whatever the result is)
  152805. */
  152806. onProgressObservable: Observable<IAssetsProgressEvent>;
  152807. /**
  152808. * Gets or sets a boolean defining if the AssetsManager should use the default loading screen
  152809. * @see https://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  152810. */
  152811. useDefaultLoadingScreen: boolean;
  152812. /**
  152813. * Gets or sets a boolean defining if the AssetsManager should automatically hide the loading screen
  152814. * when all assets have been downloaded.
  152815. * If set to false, you need to manually call in hideLoadingUI() once your scene is ready.
  152816. */
  152817. autoHideLoadingUI: boolean;
  152818. /**
  152819. * Creates a new AssetsManager
  152820. * @param scene defines the scene to work on
  152821. */
  152822. constructor(scene: Scene);
  152823. /**
  152824. * Add a ContainerAssetTask to the list of active tasks
  152825. * @param taskName defines the name of the new task
  152826. * @param meshesNames defines the name of meshes to load
  152827. * @param rootUrl defines the root url to use to locate files
  152828. * @param sceneFilename defines the filename of the scene file
  152829. * @returns a new ContainerAssetTask object
  152830. */
  152831. addContainerTask(taskName: string, meshesNames: any, rootUrl: string, sceneFilename: string): ContainerAssetTask;
  152832. /**
  152833. * Add a MeshAssetTask to the list of active tasks
  152834. * @param taskName defines the name of the new task
  152835. * @param meshesNames defines the name of meshes to load
  152836. * @param rootUrl defines the root url to use to locate files
  152837. * @param sceneFilename defines the filename of the scene file
  152838. * @returns a new MeshAssetTask object
  152839. */
  152840. addMeshTask(taskName: string, meshesNames: any, rootUrl: string, sceneFilename: string): MeshAssetTask;
  152841. /**
  152842. * Add a TextFileAssetTask to the list of active tasks
  152843. * @param taskName defines the name of the new task
  152844. * @param url defines the url of the file to load
  152845. * @returns a new TextFileAssetTask object
  152846. */
  152847. addTextFileTask(taskName: string, url: string): TextFileAssetTask;
  152848. /**
  152849. * Add a BinaryFileAssetTask to the list of active tasks
  152850. * @param taskName defines the name of the new task
  152851. * @param url defines the url of the file to load
  152852. * @returns a new BinaryFileAssetTask object
  152853. */
  152854. addBinaryFileTask(taskName: string, url: string): BinaryFileAssetTask;
  152855. /**
  152856. * Add a ImageAssetTask to the list of active tasks
  152857. * @param taskName defines the name of the new task
  152858. * @param url defines the url of the file to load
  152859. * @returns a new ImageAssetTask object
  152860. */
  152861. addImageTask(taskName: string, url: string): ImageAssetTask;
  152862. /**
  152863. * Add a TextureAssetTask to the list of active tasks
  152864. * @param taskName defines the name of the new task
  152865. * @param url defines the url of the file to load
  152866. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  152867. * @param invertY defines if you want to invert Y axis of the loaded texture (false by default)
  152868. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  152869. * @returns a new TextureAssetTask object
  152870. */
  152871. addTextureTask(taskName: string, url: string, noMipmap?: boolean, invertY?: boolean, samplingMode?: number): TextureAssetTask;
  152872. /**
  152873. * Add a CubeTextureAssetTask to the list of active tasks
  152874. * @param taskName defines the name of the new task
  152875. * @param url defines the url of the file to load
  152876. * @param extensions defines the extension to use to load the cube map (can be null)
  152877. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  152878. * @param files defines the list of files to load (can be null)
  152879. * @returns a new CubeTextureAssetTask object
  152880. */
  152881. addCubeTextureTask(taskName: string, url: string, extensions?: string[], noMipmap?: boolean, files?: string[]): CubeTextureAssetTask;
  152882. /**
  152883. *
  152884. * Add a HDRCubeTextureAssetTask to the list of active tasks
  152885. * @param taskName defines the name of the new task
  152886. * @param url defines the url of the file to load
  152887. * @param size defines the size you want for the cubemap (can be null)
  152888. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  152889. * @param generateHarmonics defines if you want to automatically generate (true by default)
  152890. * @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)
  152891. * @param reserved Internal use only
  152892. * @returns a new HDRCubeTextureAssetTask object
  152893. */
  152894. addHDRCubeTextureTask(taskName: string, url: string, size: number, noMipmap?: boolean, generateHarmonics?: boolean, gammaSpace?: boolean, reserved?: boolean): HDRCubeTextureAssetTask;
  152895. /**
  152896. *
  152897. * Add a EquiRectangularCubeTextureAssetTask to the list of active tasks
  152898. * @param taskName defines the name of the new task
  152899. * @param url defines the url of the file to load
  152900. * @param size defines the size you want for the cubemap (can be null)
  152901. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  152902. * @param gammaSpace Specifies if the texture will be used in gamma or linear space
  152903. * (the PBR material requires those textures in linear space, but the standard material would require them in Gamma space)
  152904. * @returns a new EquiRectangularCubeTextureAssetTask object
  152905. */
  152906. addEquiRectangularCubeTextureAssetTask(taskName: string, url: string, size: number, noMipmap?: boolean, gammaSpace?: boolean): EquiRectangularCubeTextureAssetTask;
  152907. /**
  152908. * Remove a task from the assets manager.
  152909. * @param task the task to remove
  152910. */
  152911. removeTask(task: AbstractAssetTask): void;
  152912. private _decreaseWaitingTasksCount;
  152913. private _runTask;
  152914. /**
  152915. * Reset the AssetsManager and remove all tasks
  152916. * @return the current instance of the AssetsManager
  152917. */
  152918. reset(): AssetsManager;
  152919. /**
  152920. * Start the loading process
  152921. * @return the current instance of the AssetsManager
  152922. */
  152923. load(): AssetsManager;
  152924. /**
  152925. * Start the loading process as an async operation
  152926. * @return a promise returning the list of failed tasks
  152927. */
  152928. loadAsync(): Promise<void>;
  152929. }
  152930. }
  152931. declare module BABYLON {
  152932. /**
  152933. * Wrapper class for promise with external resolve and reject.
  152934. */
  152935. export class Deferred<T> {
  152936. /**
  152937. * The promise associated with this deferred object.
  152938. */
  152939. readonly promise: Promise<T>;
  152940. private _resolve;
  152941. private _reject;
  152942. /**
  152943. * The resolve method of the promise associated with this deferred object.
  152944. */
  152945. get resolve(): (value?: T | PromiseLike<T> | undefined) => void;
  152946. /**
  152947. * The reject method of the promise associated with this deferred object.
  152948. */
  152949. get reject(): (reason?: any) => void;
  152950. /**
  152951. * Constructor for this deferred object.
  152952. */
  152953. constructor();
  152954. }
  152955. }
  152956. declare module BABYLON {
  152957. /**
  152958. * Class used to explode meshes (ie. to have a center and move them away from that center to better see the overall organization)
  152959. */
  152960. export class MeshExploder {
  152961. private _centerMesh;
  152962. private _meshes;
  152963. private _meshesOrigins;
  152964. private _toCenterVectors;
  152965. private _scaledDirection;
  152966. private _newPosition;
  152967. private _centerPosition;
  152968. /**
  152969. * Explodes meshes from a center mesh.
  152970. * @param meshes The meshes to explode.
  152971. * @param centerMesh The mesh to be center of explosion.
  152972. */
  152973. constructor(meshes: Array<Mesh>, centerMesh?: Mesh);
  152974. private _setCenterMesh;
  152975. /**
  152976. * Get class name
  152977. * @returns "MeshExploder"
  152978. */
  152979. getClassName(): string;
  152980. /**
  152981. * "Exploded meshes"
  152982. * @returns Array of meshes with the centerMesh at index 0.
  152983. */
  152984. getMeshes(): Array<Mesh>;
  152985. /**
  152986. * Explodes meshes giving a specific direction
  152987. * @param direction Number to multiply distance of each mesh's origin from center. Use a negative number to implode, or zero to reset.
  152988. */
  152989. explode(direction?: number): void;
  152990. }
  152991. }
  152992. declare module BABYLON {
  152993. /**
  152994. * Class used to help managing file picking and drag'n'drop
  152995. */
  152996. export class FilesInput {
  152997. /**
  152998. * List of files ready to be loaded
  152999. */
  153000. static get FilesToLoad(): {
  153001. [key: string]: File;
  153002. };
  153003. /**
  153004. * Callback called when a file is processed
  153005. */
  153006. onProcessFileCallback: (file: File, name: string, extension: string) => boolean;
  153007. private _engine;
  153008. private _currentScene;
  153009. private _sceneLoadedCallback;
  153010. private _progressCallback;
  153011. private _additionalRenderLoopLogicCallback;
  153012. private _textureLoadingCallback;
  153013. private _startingProcessingFilesCallback;
  153014. private _onReloadCallback;
  153015. private _errorCallback;
  153016. private _elementToMonitor;
  153017. private _sceneFileToLoad;
  153018. private _filesToLoad;
  153019. /**
  153020. * Creates a new FilesInput
  153021. * @param engine defines the rendering engine
  153022. * @param scene defines the hosting scene
  153023. * @param sceneLoadedCallback callback called when scene is loaded
  153024. * @param progressCallback callback called to track progress
  153025. * @param additionalRenderLoopLogicCallback callback called to add user logic to the rendering loop
  153026. * @param textureLoadingCallback callback called when a texture is loading
  153027. * @param startingProcessingFilesCallback callback called when the system is about to process all files
  153028. * @param onReloadCallback callback called when a reload is requested
  153029. * @param errorCallback callback call if an error occurs
  153030. */
  153031. 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>);
  153032. private _dragEnterHandler;
  153033. private _dragOverHandler;
  153034. private _dropHandler;
  153035. /**
  153036. * Calls this function to listen to drag'n'drop events on a specific DOM element
  153037. * @param elementToMonitor defines the DOM element to track
  153038. */
  153039. monitorElementForDragNDrop(elementToMonitor: HTMLElement): void;
  153040. /** Gets the current list of files to load */
  153041. get filesToLoad(): File[];
  153042. /**
  153043. * Release all associated resources
  153044. */
  153045. dispose(): void;
  153046. private renderFunction;
  153047. private drag;
  153048. private drop;
  153049. private _traverseFolder;
  153050. private _processFiles;
  153051. /**
  153052. * Load files from a drop event
  153053. * @param event defines the drop event to use as source
  153054. */
  153055. loadFiles(event: any): void;
  153056. private _processReload;
  153057. /**
  153058. * Reload the current scene from the loaded files
  153059. */
  153060. reload(): void;
  153061. }
  153062. }
  153063. declare module BABYLON {
  153064. /**
  153065. * Defines the root class used to create scene optimization to use with SceneOptimizer
  153066. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  153067. */
  153068. export class SceneOptimization {
  153069. /**
  153070. * Defines the priority of this optimization (0 by default which means first in the list)
  153071. */
  153072. priority: number;
  153073. /**
  153074. * Gets a string describing the action executed by the current optimization
  153075. * @returns description string
  153076. */
  153077. getDescription(): string;
  153078. /**
  153079. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  153080. * @param scene defines the current scene where to apply this optimization
  153081. * @param optimizer defines the current optimizer
  153082. * @returns true if everything that can be done was applied
  153083. */
  153084. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  153085. /**
  153086. * Creates the SceneOptimization object
  153087. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  153088. * @param desc defines the description associated with the optimization
  153089. */
  153090. constructor(
  153091. /**
  153092. * Defines the priority of this optimization (0 by default which means first in the list)
  153093. */
  153094. priority?: number);
  153095. }
  153096. /**
  153097. * Defines an optimization used to reduce the size of render target textures
  153098. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  153099. */
  153100. export class TextureOptimization extends SceneOptimization {
  153101. /**
  153102. * Defines the priority of this optimization (0 by default which means first in the list)
  153103. */
  153104. priority: number;
  153105. /**
  153106. * 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
  153107. */
  153108. maximumSize: number;
  153109. /**
  153110. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  153111. */
  153112. step: number;
  153113. /**
  153114. * Gets a string describing the action executed by the current optimization
  153115. * @returns description string
  153116. */
  153117. getDescription(): string;
  153118. /**
  153119. * Creates the TextureOptimization object
  153120. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  153121. * @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
  153122. * @param step defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  153123. */
  153124. constructor(
  153125. /**
  153126. * Defines the priority of this optimization (0 by default which means first in the list)
  153127. */
  153128. priority?: number,
  153129. /**
  153130. * 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
  153131. */
  153132. maximumSize?: number,
  153133. /**
  153134. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  153135. */
  153136. step?: number);
  153137. /**
  153138. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  153139. * @param scene defines the current scene where to apply this optimization
  153140. * @param optimizer defines the current optimizer
  153141. * @returns true if everything that can be done was applied
  153142. */
  153143. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  153144. }
  153145. /**
  153146. * Defines an optimization used to increase or decrease the rendering resolution
  153147. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  153148. */
  153149. export class HardwareScalingOptimization extends SceneOptimization {
  153150. /**
  153151. * Defines the priority of this optimization (0 by default which means first in the list)
  153152. */
  153153. priority: number;
  153154. /**
  153155. * Defines the maximum scale to use (2 by default)
  153156. */
  153157. maximumScale: number;
  153158. /**
  153159. * Defines the step to use between two passes (0.5 by default)
  153160. */
  153161. step: number;
  153162. private _currentScale;
  153163. private _directionOffset;
  153164. /**
  153165. * Gets a string describing the action executed by the current optimization
  153166. * @return description string
  153167. */
  153168. getDescription(): string;
  153169. /**
  153170. * Creates the HardwareScalingOptimization object
  153171. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  153172. * @param maximumScale defines the maximum scale to use (2 by default)
  153173. * @param step defines the step to use between two passes (0.5 by default)
  153174. */
  153175. constructor(
  153176. /**
  153177. * Defines the priority of this optimization (0 by default which means first in the list)
  153178. */
  153179. priority?: number,
  153180. /**
  153181. * Defines the maximum scale to use (2 by default)
  153182. */
  153183. maximumScale?: number,
  153184. /**
  153185. * Defines the step to use between two passes (0.5 by default)
  153186. */
  153187. step?: number);
  153188. /**
  153189. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  153190. * @param scene defines the current scene where to apply this optimization
  153191. * @param optimizer defines the current optimizer
  153192. * @returns true if everything that can be done was applied
  153193. */
  153194. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  153195. }
  153196. /**
  153197. * Defines an optimization used to remove shadows
  153198. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  153199. */
  153200. export class ShadowsOptimization extends SceneOptimization {
  153201. /**
  153202. * Gets a string describing the action executed by the current optimization
  153203. * @return description string
  153204. */
  153205. getDescription(): string;
  153206. /**
  153207. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  153208. * @param scene defines the current scene where to apply this optimization
  153209. * @param optimizer defines the current optimizer
  153210. * @returns true if everything that can be done was applied
  153211. */
  153212. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  153213. }
  153214. /**
  153215. * Defines an optimization used to turn post-processes off
  153216. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  153217. */
  153218. export class PostProcessesOptimization extends SceneOptimization {
  153219. /**
  153220. * Gets a string describing the action executed by the current optimization
  153221. * @return description string
  153222. */
  153223. getDescription(): string;
  153224. /**
  153225. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  153226. * @param scene defines the current scene where to apply this optimization
  153227. * @param optimizer defines the current optimizer
  153228. * @returns true if everything that can be done was applied
  153229. */
  153230. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  153231. }
  153232. /**
  153233. * Defines an optimization used to turn lens flares off
  153234. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  153235. */
  153236. export class LensFlaresOptimization extends SceneOptimization {
  153237. /**
  153238. * Gets a string describing the action executed by the current optimization
  153239. * @return description string
  153240. */
  153241. getDescription(): string;
  153242. /**
  153243. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  153244. * @param scene defines the current scene where to apply this optimization
  153245. * @param optimizer defines the current optimizer
  153246. * @returns true if everything that can be done was applied
  153247. */
  153248. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  153249. }
  153250. /**
  153251. * Defines an optimization based on user defined callback.
  153252. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  153253. */
  153254. export class CustomOptimization extends SceneOptimization {
  153255. /**
  153256. * Callback called to apply the custom optimization.
  153257. */
  153258. onApply: (scene: Scene, optimizer: SceneOptimizer) => boolean;
  153259. /**
  153260. * Callback called to get custom description
  153261. */
  153262. onGetDescription: () => string;
  153263. /**
  153264. * Gets a string describing the action executed by the current optimization
  153265. * @returns description string
  153266. */
  153267. getDescription(): string;
  153268. /**
  153269. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  153270. * @param scene defines the current scene where to apply this optimization
  153271. * @param optimizer defines the current optimizer
  153272. * @returns true if everything that can be done was applied
  153273. */
  153274. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  153275. }
  153276. /**
  153277. * Defines an optimization used to turn particles off
  153278. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  153279. */
  153280. export class ParticlesOptimization extends SceneOptimization {
  153281. /**
  153282. * Gets a string describing the action executed by the current optimization
  153283. * @return description string
  153284. */
  153285. getDescription(): string;
  153286. /**
  153287. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  153288. * @param scene defines the current scene where to apply this optimization
  153289. * @param optimizer defines the current optimizer
  153290. * @returns true if everything that can be done was applied
  153291. */
  153292. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  153293. }
  153294. /**
  153295. * Defines an optimization used to turn render targets off
  153296. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  153297. */
  153298. export class RenderTargetsOptimization extends SceneOptimization {
  153299. /**
  153300. * Gets a string describing the action executed by the current optimization
  153301. * @return description string
  153302. */
  153303. getDescription(): string;
  153304. /**
  153305. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  153306. * @param scene defines the current scene where to apply this optimization
  153307. * @param optimizer defines the current optimizer
  153308. * @returns true if everything that can be done was applied
  153309. */
  153310. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  153311. }
  153312. /**
  153313. * Defines an optimization used to merge meshes with compatible materials
  153314. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  153315. */
  153316. export class MergeMeshesOptimization extends SceneOptimization {
  153317. private static _UpdateSelectionTree;
  153318. /**
  153319. * Gets or sets a boolean which defines if optimization octree has to be updated
  153320. */
  153321. static get UpdateSelectionTree(): boolean;
  153322. /**
  153323. * Gets or sets a boolean which defines if optimization octree has to be updated
  153324. */
  153325. static set UpdateSelectionTree(value: boolean);
  153326. /**
  153327. * Gets a string describing the action executed by the current optimization
  153328. * @return description string
  153329. */
  153330. getDescription(): string;
  153331. private _canBeMerged;
  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. * @param updateSelectionTree defines that the selection octree has to be updated (false by default)
  153337. * @returns true if everything that can be done was applied
  153338. */
  153339. apply(scene: Scene, optimizer: SceneOptimizer, updateSelectionTree?: boolean): boolean;
  153340. }
  153341. /**
  153342. * Defines a list of options used by SceneOptimizer
  153343. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  153344. */
  153345. export class SceneOptimizerOptions {
  153346. /**
  153347. * Defines the target frame rate to reach (60 by default)
  153348. */
  153349. targetFrameRate: number;
  153350. /**
  153351. * Defines the interval between two checkes (2000ms by default)
  153352. */
  153353. trackerDuration: number;
  153354. /**
  153355. * Gets the list of optimizations to apply
  153356. */
  153357. optimizations: SceneOptimization[];
  153358. /**
  153359. * Creates a new list of options used by SceneOptimizer
  153360. * @param targetFrameRate defines the target frame rate to reach (60 by default)
  153361. * @param trackerDuration defines the interval between two checkes (2000ms by default)
  153362. */
  153363. constructor(
  153364. /**
  153365. * Defines the target frame rate to reach (60 by default)
  153366. */
  153367. targetFrameRate?: number,
  153368. /**
  153369. * Defines the interval between two checkes (2000ms by default)
  153370. */
  153371. trackerDuration?: number);
  153372. /**
  153373. * Add a new optimization
  153374. * @param optimization defines the SceneOptimization to add to the list of active optimizations
  153375. * @returns the current SceneOptimizerOptions
  153376. */
  153377. addOptimization(optimization: SceneOptimization): SceneOptimizerOptions;
  153378. /**
  153379. * Add a new custom optimization
  153380. * @param onApply defines the callback called to apply the custom optimization (true if everything that can be done was applied)
  153381. * @param onGetDescription defines the callback called to get the description attached with the optimization.
  153382. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  153383. * @returns the current SceneOptimizerOptions
  153384. */
  153385. addCustomOptimization(onApply: (scene: Scene) => boolean, onGetDescription: () => string, priority?: number): SceneOptimizerOptions;
  153386. /**
  153387. * Creates a list of pre-defined optimizations aimed to reduce the visual impact on the scene
  153388. * @param targetFrameRate defines the target frame rate (60 by default)
  153389. * @returns a SceneOptimizerOptions object
  153390. */
  153391. static LowDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  153392. /**
  153393. * Creates a list of pre-defined optimizations aimed to have a moderate impact on the scene visual
  153394. * @param targetFrameRate defines the target frame rate (60 by default)
  153395. * @returns a SceneOptimizerOptions object
  153396. */
  153397. static ModerateDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  153398. /**
  153399. * Creates a list of pre-defined optimizations aimed to have a big impact on the scene visual
  153400. * @param targetFrameRate defines the target frame rate (60 by default)
  153401. * @returns a SceneOptimizerOptions object
  153402. */
  153403. static HighDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  153404. }
  153405. /**
  153406. * Class used to run optimizations in order to reach a target frame rate
  153407. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  153408. */
  153409. export class SceneOptimizer implements IDisposable {
  153410. private _isRunning;
  153411. private _options;
  153412. private _scene;
  153413. private _currentPriorityLevel;
  153414. private _targetFrameRate;
  153415. private _trackerDuration;
  153416. private _currentFrameRate;
  153417. private _sceneDisposeObserver;
  153418. private _improvementMode;
  153419. /**
  153420. * Defines an observable called when the optimizer reaches the target frame rate
  153421. */
  153422. onSuccessObservable: Observable<SceneOptimizer>;
  153423. /**
  153424. * Defines an observable called when the optimizer enables an optimization
  153425. */
  153426. onNewOptimizationAppliedObservable: Observable<SceneOptimization>;
  153427. /**
  153428. * Defines an observable called when the optimizer is not able to reach the target frame rate
  153429. */
  153430. onFailureObservable: Observable<SceneOptimizer>;
  153431. /**
  153432. * Gets a boolean indicating if the optimizer is in improvement mode
  153433. */
  153434. get isInImprovementMode(): boolean;
  153435. /**
  153436. * Gets the current priority level (0 at start)
  153437. */
  153438. get currentPriorityLevel(): number;
  153439. /**
  153440. * Gets the current frame rate checked by the SceneOptimizer
  153441. */
  153442. get currentFrameRate(): number;
  153443. /**
  153444. * Gets or sets the current target frame rate (60 by default)
  153445. */
  153446. get targetFrameRate(): number;
  153447. /**
  153448. * Gets or sets the current target frame rate (60 by default)
  153449. */
  153450. set targetFrameRate(value: number);
  153451. /**
  153452. * Gets or sets the current interval between two checks (every 2000ms by default)
  153453. */
  153454. get trackerDuration(): number;
  153455. /**
  153456. * Gets or sets the current interval between two checks (every 2000ms by default)
  153457. */
  153458. set trackerDuration(value: number);
  153459. /**
  153460. * Gets the list of active optimizations
  153461. */
  153462. get optimizations(): SceneOptimization[];
  153463. /**
  153464. * Creates a new SceneOptimizer
  153465. * @param scene defines the scene to work on
  153466. * @param options defines the options to use with the SceneOptimizer
  153467. * @param autoGeneratePriorities defines if priorities must be generated and not read from SceneOptimization property (true by default)
  153468. * @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)
  153469. */
  153470. constructor(scene: Scene, options?: SceneOptimizerOptions, autoGeneratePriorities?: boolean, improvementMode?: boolean);
  153471. /**
  153472. * Stops the current optimizer
  153473. */
  153474. stop(): void;
  153475. /**
  153476. * Reset the optimizer to initial step (current priority level = 0)
  153477. */
  153478. reset(): void;
  153479. /**
  153480. * Start the optimizer. By default it will try to reach a specific framerate
  153481. * but if the optimizer is set with improvementMode === true then it will run all optimiatiation while frame rate is above the target frame rate
  153482. */
  153483. start(): void;
  153484. private _checkCurrentState;
  153485. /**
  153486. * Release all resources
  153487. */
  153488. dispose(): void;
  153489. /**
  153490. * Helper function to create a SceneOptimizer with one single line of code
  153491. * @param scene defines the scene to work on
  153492. * @param options defines the options to use with the SceneOptimizer
  153493. * @param onSuccess defines a callback to call on success
  153494. * @param onFailure defines a callback to call on failure
  153495. * @returns the new SceneOptimizer object
  153496. */
  153497. static OptimizeAsync(scene: Scene, options?: SceneOptimizerOptions, onSuccess?: () => void, onFailure?: () => void): SceneOptimizer;
  153498. }
  153499. }
  153500. declare module BABYLON {
  153501. /**
  153502. * Class used to serialize a scene into a string
  153503. */
  153504. export class SceneSerializer {
  153505. /**
  153506. * Clear cache used by a previous serialization
  153507. */
  153508. static ClearCache(): void;
  153509. /**
  153510. * Serialize a scene into a JSON compatible object
  153511. * @param scene defines the scene to serialize
  153512. * @returns a JSON compatible object
  153513. */
  153514. static Serialize(scene: Scene): any;
  153515. /**
  153516. * Serialize a mesh into a JSON compatible object
  153517. * @param toSerialize defines the mesh to serialize
  153518. * @param withParents defines if parents must be serialized as well
  153519. * @param withChildren defines if children must be serialized as well
  153520. * @returns a JSON compatible object
  153521. */
  153522. static SerializeMesh(toSerialize: any, withParents?: boolean, withChildren?: boolean): any;
  153523. }
  153524. }
  153525. declare module BABYLON {
  153526. /**
  153527. * Class used to host texture specific utilities
  153528. */
  153529. export class TextureTools {
  153530. /**
  153531. * Uses the GPU to create a copy texture rescaled at a given size
  153532. * @param texture Texture to copy from
  153533. * @param width defines the desired width
  153534. * @param height defines the desired height
  153535. * @param useBilinearMode defines if bilinear mode has to be used
  153536. * @return the generated texture
  153537. */
  153538. static CreateResizedCopy(texture: Texture, width: number, height: number, useBilinearMode?: boolean): Texture;
  153539. }
  153540. }
  153541. declare module BABYLON {
  153542. /**
  153543. * This represents the different options available for the video capture.
  153544. */
  153545. export interface VideoRecorderOptions {
  153546. /** Defines the mime type of the video. */
  153547. mimeType: string;
  153548. /** Defines the FPS the video should be recorded at. */
  153549. fps: number;
  153550. /** Defines the chunk size for the recording data. */
  153551. recordChunckSize: number;
  153552. /** The audio tracks to attach to the recording. */
  153553. audioTracks?: MediaStreamTrack[];
  153554. }
  153555. /**
  153556. * This can help with recording videos from BabylonJS.
  153557. * This is based on the available WebRTC functionalities of the browser.
  153558. *
  153559. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_video
  153560. */
  153561. export class VideoRecorder {
  153562. private static readonly _defaultOptions;
  153563. /**
  153564. * Returns whether or not the VideoRecorder is available in your browser.
  153565. * @param engine Defines the Babylon Engine.
  153566. * @returns true if supported otherwise false.
  153567. */
  153568. static IsSupported(engine: Engine): boolean;
  153569. private readonly _options;
  153570. private _canvas;
  153571. private _mediaRecorder;
  153572. private _recordedChunks;
  153573. private _fileName;
  153574. private _resolve;
  153575. private _reject;
  153576. /**
  153577. * True when a recording is already in progress.
  153578. */
  153579. get isRecording(): boolean;
  153580. /**
  153581. * Create a new VideoCapture object which can help converting what you see in Babylon to a video file.
  153582. * @param engine Defines the BabylonJS Engine you wish to record.
  153583. * @param options Defines options that can be used to customize the capture.
  153584. */
  153585. constructor(engine: Engine, options?: Nullable<VideoRecorderOptions>);
  153586. /**
  153587. * Stops the current recording before the default capture timeout passed in the startRecording function.
  153588. */
  153589. stopRecording(): void;
  153590. /**
  153591. * Starts recording the canvas for a max duration specified in parameters.
  153592. * @param fileName Defines the name of the file to be downloaded when the recording stop.
  153593. * If null no automatic download will start and you can rely on the promise to get the data back.
  153594. * @param maxDuration Defines the maximum recording time in seconds.
  153595. * It defaults to 7 seconds. A value of zero will not stop automatically, you would need to call stopRecording manually.
  153596. * @return A promise callback at the end of the recording with the video data in Blob.
  153597. */
  153598. startRecording(fileName?: Nullable<string>, maxDuration?: number): Promise<Blob>;
  153599. /**
  153600. * Releases internal resources used during the recording.
  153601. */
  153602. dispose(): void;
  153603. private _handleDataAvailable;
  153604. private _handleError;
  153605. private _handleStop;
  153606. }
  153607. }
  153608. declare module BABYLON {
  153609. /**
  153610. * Class containing a set of static utilities functions for screenshots
  153611. */
  153612. export class ScreenshotTools {
  153613. /**
  153614. * Captures a screenshot of the current rendering
  153615. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_png
  153616. * @param engine defines the rendering engine
  153617. * @param camera defines the source camera
  153618. * @param size This parameter can be set to a single number or to an object with the
  153619. * following (optional) properties: precision, width, height. If a single number is passed,
  153620. * it will be used for both width and height. If an object is passed, the screenshot size
  153621. * will be derived from the parameters. The precision property is a multiplier allowing
  153622. * rendering at a higher or lower resolution
  153623. * @param successCallback defines the callback receives a single parameter which contains the
  153624. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  153625. * src parameter of an <img> to display it
  153626. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  153627. * Check your browser for supported MIME types
  153628. */
  153629. static CreateScreenshot(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string): void;
  153630. /**
  153631. * Captures a screenshot of the current rendering
  153632. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_png
  153633. * @param engine defines the rendering engine
  153634. * @param camera defines the source camera
  153635. * @param size This parameter can be set to a single number or to an object with the
  153636. * following (optional) properties: precision, width, height. If a single number is passed,
  153637. * it will be used for both width and height. If an object is passed, the screenshot size
  153638. * will be derived from the parameters. The precision property is a multiplier allowing
  153639. * rendering at a higher or lower resolution
  153640. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  153641. * Check your browser for supported MIME types
  153642. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  153643. * to the src parameter of an <img> to display it
  153644. */
  153645. static CreateScreenshotAsync(engine: Engine, camera: Camera, size: any, mimeType?: string): Promise<string>;
  153646. /**
  153647. * Generates an image screenshot from the specified camera.
  153648. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_png
  153649. * @param engine The engine to use for rendering
  153650. * @param camera The camera to use for rendering
  153651. * @param size This parameter can be set to a single number or to an object with the
  153652. * following (optional) properties: precision, width, height. If a single number is passed,
  153653. * it will be used for both width and height. If an object is passed, the screenshot size
  153654. * will be derived from the parameters. The precision property is a multiplier allowing
  153655. * rendering at a higher or lower resolution
  153656. * @param successCallback The callback receives a single parameter which contains the
  153657. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  153658. * src parameter of an <img> to display it
  153659. * @param mimeType The MIME type of the screenshot image (default: image/png).
  153660. * Check your browser for supported MIME types
  153661. * @param samples Texture samples (default: 1)
  153662. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  153663. * @param fileName A name for for the downloaded file.
  153664. * @param renderSprites Whether the sprites should be rendered or not (default: false)
  153665. * @param enableStencilBuffer Whether the stencil buffer should be enabled or not (default: false)
  153666. */
  153667. 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;
  153668. /**
  153669. * Generates an image screenshot from the specified camera.
  153670. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_png
  153671. * @param engine The engine to use for rendering
  153672. * @param camera The camera to use for rendering
  153673. * @param size This parameter can be set to a single number or to an object with the
  153674. * following (optional) properties: precision, width, height. If a single number is passed,
  153675. * it will be used for both width and height. If an object is passed, the screenshot size
  153676. * will be derived from the parameters. The precision property is a multiplier allowing
  153677. * rendering at a higher or lower resolution
  153678. * @param mimeType The MIME type of the screenshot image (default: image/png).
  153679. * Check your browser for supported MIME types
  153680. * @param samples Texture samples (default: 1)
  153681. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  153682. * @param fileName A name for for the downloaded file.
  153683. * @param renderSprites Whether the sprites should be rendered or not (default: false)
  153684. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  153685. * to the src parameter of an <img> to display it
  153686. */
  153687. static CreateScreenshotUsingRenderTargetAsync(engine: Engine, camera: Camera, size: any, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string, renderSprites?: boolean): Promise<string>;
  153688. /**
  153689. * Gets height and width for screenshot size
  153690. * @private
  153691. */
  153692. private static _getScreenshotSize;
  153693. }
  153694. }
  153695. declare module BABYLON {
  153696. /**
  153697. * Interface for a data buffer
  153698. */
  153699. export interface IDataBuffer {
  153700. /**
  153701. * Reads bytes from the data buffer.
  153702. * @param byteOffset The byte offset to read
  153703. * @param byteLength The byte length to read
  153704. * @returns A promise that resolves when the bytes are read
  153705. */
  153706. readAsync(byteOffset: number, byteLength: number): Promise<ArrayBufferView>;
  153707. /**
  153708. * The byte length of the buffer.
  153709. */
  153710. readonly byteLength: number;
  153711. }
  153712. /**
  153713. * Utility class for reading from a data buffer
  153714. */
  153715. export class DataReader {
  153716. /**
  153717. * The data buffer associated with this data reader.
  153718. */
  153719. readonly buffer: IDataBuffer;
  153720. /**
  153721. * The current byte offset from the beginning of the data buffer.
  153722. */
  153723. byteOffset: number;
  153724. private _dataView;
  153725. private _dataByteOffset;
  153726. /**
  153727. * Constructor
  153728. * @param buffer The buffer to read
  153729. */
  153730. constructor(buffer: IDataBuffer);
  153731. /**
  153732. * Loads the given byte length.
  153733. * @param byteLength The byte length to load
  153734. * @returns A promise that resolves when the load is complete
  153735. */
  153736. loadAsync(byteLength: number): Promise<void>;
  153737. /**
  153738. * Read a unsigned 32-bit integer from the currently loaded data range.
  153739. * @returns The 32-bit integer read
  153740. */
  153741. readUint32(): number;
  153742. /**
  153743. * Read a byte array from the currently loaded data range.
  153744. * @param byteLength The byte length to read
  153745. * @returns The byte array read
  153746. */
  153747. readUint8Array(byteLength: number): Uint8Array;
  153748. /**
  153749. * Read a string from the currently loaded data range.
  153750. * @param byteLength The byte length to read
  153751. * @returns The string read
  153752. */
  153753. readString(byteLength: number): string;
  153754. /**
  153755. * Skips the given byte length the currently loaded data range.
  153756. * @param byteLength The byte length to skip
  153757. */
  153758. skipBytes(byteLength: number): void;
  153759. }
  153760. }
  153761. declare module BABYLON {
  153762. /**
  153763. * Class for storing data to local storage if available or in-memory storage otherwise
  153764. */
  153765. export class DataStorage {
  153766. private static _Storage;
  153767. private static _GetStorage;
  153768. /**
  153769. * Reads a string from the data storage
  153770. * @param key The key to read
  153771. * @param defaultValue The value if the key doesn't exist
  153772. * @returns The string value
  153773. */
  153774. static ReadString(key: string, defaultValue: string): string;
  153775. /**
  153776. * Writes a string to the data storage
  153777. * @param key The key to write
  153778. * @param value The value to write
  153779. */
  153780. static WriteString(key: string, value: string): void;
  153781. /**
  153782. * Reads a boolean from the data storage
  153783. * @param key The key to read
  153784. * @param defaultValue The value if the key doesn't exist
  153785. * @returns The boolean value
  153786. */
  153787. static ReadBoolean(key: string, defaultValue: boolean): boolean;
  153788. /**
  153789. * Writes a boolean to the data storage
  153790. * @param key The key to write
  153791. * @param value The value to write
  153792. */
  153793. static WriteBoolean(key: string, value: boolean): void;
  153794. /**
  153795. * Reads a number from the data storage
  153796. * @param key The key to read
  153797. * @param defaultValue The value if the key doesn't exist
  153798. * @returns The number value
  153799. */
  153800. static ReadNumber(key: string, defaultValue: number): number;
  153801. /**
  153802. * Writes a number to the data storage
  153803. * @param key The key to write
  153804. * @param value The value to write
  153805. */
  153806. static WriteNumber(key: string, value: number): void;
  153807. }
  153808. }
  153809. declare module BABYLON {
  153810. /**
  153811. * Class used to record delta files between 2 scene states
  153812. */
  153813. export class SceneRecorder {
  153814. private _trackedScene;
  153815. private _savedJSON;
  153816. /**
  153817. * Track a given scene. This means the current scene state will be considered the original state
  153818. * @param scene defines the scene to track
  153819. */
  153820. track(scene: Scene): void;
  153821. /**
  153822. * Get the delta between current state and original state
  153823. * @returns a string containing the delta
  153824. */
  153825. getDelta(): any;
  153826. private _compareArray;
  153827. private _compareObjects;
  153828. private _compareCollections;
  153829. private static GetShadowGeneratorById;
  153830. /**
  153831. * Apply a given delta to a given scene
  153832. * @param deltaJSON defines the JSON containing the delta
  153833. * @param scene defines the scene to apply the delta to
  153834. */
  153835. static ApplyDelta(deltaJSON: any | string, scene: Scene): void;
  153836. private static _ApplyPropertiesToEntity;
  153837. private static _ApplyDeltaForEntity;
  153838. }
  153839. }
  153840. declare module BABYLON {
  153841. /**
  153842. * An interface for all Hit test features
  153843. */
  153844. export interface IWebXRHitTestFeature<T extends IWebXRLegacyHitResult> extends IWebXRFeature {
  153845. /**
  153846. * Triggered when new babylon (transformed) hit test results are available
  153847. */
  153848. onHitTestResultObservable: Observable<T[]>;
  153849. }
  153850. /**
  153851. * Options used for hit testing
  153852. */
  153853. export interface IWebXRLegacyHitTestOptions {
  153854. /**
  153855. * Only test when user interacted with the scene. Default - hit test every frame
  153856. */
  153857. testOnPointerDownOnly?: boolean;
  153858. /**
  153859. * The node to use to transform the local results to world coordinates
  153860. */
  153861. worldParentNode?: TransformNode;
  153862. }
  153863. /**
  153864. * Interface defining the babylon result of raycasting/hit-test
  153865. */
  153866. export interface IWebXRLegacyHitResult {
  153867. /**
  153868. * Transformation matrix that can be applied to a node that will put it in the hit point location
  153869. */
  153870. transformationMatrix: Matrix;
  153871. /**
  153872. * The native hit test result
  153873. */
  153874. xrHitResult: XRHitResult | XRHitTestResult;
  153875. }
  153876. /**
  153877. * The currently-working hit-test module.
  153878. * Hit test (or Ray-casting) is used to interact with the real world.
  153879. * For further information read here - https://github.com/immersive-web/hit-test
  153880. */
  153881. export class WebXRHitTestLegacy extends WebXRAbstractFeature implements IWebXRHitTestFeature<IWebXRLegacyHitResult> {
  153882. /**
  153883. * options to use when constructing this feature
  153884. */
  153885. readonly options: IWebXRLegacyHitTestOptions;
  153886. private _direction;
  153887. private _mat;
  153888. private _onSelectEnabled;
  153889. private _origin;
  153890. /**
  153891. * The module's name
  153892. */
  153893. static readonly Name: string;
  153894. /**
  153895. * The (Babylon) version of this module.
  153896. * This is an integer representing the implementation version.
  153897. * This number does not correspond to the WebXR specs version
  153898. */
  153899. static readonly Version: number;
  153900. /**
  153901. * Populated with the last native XR Hit Results
  153902. */
  153903. lastNativeXRHitResults: XRHitResult[];
  153904. /**
  153905. * Triggered when new babylon (transformed) hit test results are available
  153906. */
  153907. onHitTestResultObservable: Observable<IWebXRLegacyHitResult[]>;
  153908. /**
  153909. * Creates a new instance of the (legacy version) hit test feature
  153910. * @param _xrSessionManager an instance of WebXRSessionManager
  153911. * @param options options to use when constructing this feature
  153912. */
  153913. constructor(_xrSessionManager: WebXRSessionManager,
  153914. /**
  153915. * options to use when constructing this feature
  153916. */
  153917. options?: IWebXRLegacyHitTestOptions);
  153918. /**
  153919. * execute a hit test with an XR Ray
  153920. *
  153921. * @param xrSession a native xrSession that will execute this hit test
  153922. * @param xrRay the ray (position and direction) to use for ray-casting
  153923. * @param referenceSpace native XR reference space to use for the hit-test
  153924. * @param filter filter function that will filter the results
  153925. * @returns a promise that resolves with an array of native XR hit result in xr coordinates system
  153926. */
  153927. static XRHitTestWithRay(xrSession: XRSession, xrRay: XRRay, referenceSpace: XRReferenceSpace, filter?: (result: XRHitResult) => boolean): Promise<XRHitResult[]>;
  153928. /**
  153929. * Execute a hit test on the current running session using a select event returned from a transient input (such as touch)
  153930. * @param event the (select) event to use to select with
  153931. * @param referenceSpace the reference space to use for this hit test
  153932. * @returns a promise that resolves with an array of native XR hit result in xr coordinates system
  153933. */
  153934. static XRHitTestWithSelectEvent(event: XRInputSourceEvent, referenceSpace: XRReferenceSpace): Promise<XRHitResult[]>;
  153935. /**
  153936. * attach this feature
  153937. * Will usually be called by the features manager
  153938. *
  153939. * @returns true if successful.
  153940. */
  153941. attach(): boolean;
  153942. /**
  153943. * detach this feature.
  153944. * Will usually be called by the features manager
  153945. *
  153946. * @returns true if successful.
  153947. */
  153948. detach(): boolean;
  153949. /**
  153950. * Dispose this feature and all of the resources attached
  153951. */
  153952. dispose(): void;
  153953. protected _onXRFrame(frame: XRFrame): void;
  153954. private _onHitTestResults;
  153955. private _onSelect;
  153956. }
  153957. }
  153958. declare module BABYLON {
  153959. /**
  153960. * Options used for hit testing (version 2)
  153961. */
  153962. export interface IWebXRHitTestOptions extends IWebXRLegacyHitTestOptions {
  153963. /**
  153964. * Do not create a permanent hit test. Will usually be used when only
  153965. * transient inputs are needed.
  153966. */
  153967. disablePermanentHitTest?: boolean;
  153968. /**
  153969. * Enable transient (for example touch-based) hit test inspections
  153970. */
  153971. enableTransientHitTest?: boolean;
  153972. /**
  153973. * Offset ray for the permanent hit test
  153974. */
  153975. offsetRay?: Vector3;
  153976. /**
  153977. * Offset ray for the transient hit test
  153978. */
  153979. transientOffsetRay?: Vector3;
  153980. /**
  153981. * Instead of using viewer space for hit tests, use the reference space defined in the session manager
  153982. */
  153983. useReferenceSpace?: boolean;
  153984. /**
  153985. * Override the default entity type(s) of the hit-test result
  153986. */
  153987. entityTypes?: XRHitTestTrackableType[];
  153988. }
  153989. /**
  153990. * Interface defining the babylon result of hit-test
  153991. */
  153992. export interface IWebXRHitResult extends IWebXRLegacyHitResult {
  153993. /**
  153994. * The input source that generated this hit test (if transient)
  153995. */
  153996. inputSource?: XRInputSource;
  153997. /**
  153998. * Is this a transient hit test
  153999. */
  154000. isTransient?: boolean;
  154001. /**
  154002. * Position of the hit test result
  154003. */
  154004. position: Vector3;
  154005. /**
  154006. * Rotation of the hit test result
  154007. */
  154008. rotationQuaternion: Quaternion;
  154009. /**
  154010. * The native hit test result
  154011. */
  154012. xrHitResult: XRHitTestResult;
  154013. }
  154014. /**
  154015. * The currently-working hit-test module.
  154016. * Hit test (or Ray-casting) is used to interact with the real world.
  154017. * For further information read here - https://github.com/immersive-web/hit-test
  154018. *
  154019. * Tested on chrome (mobile) 80.
  154020. */
  154021. export class WebXRHitTest extends WebXRAbstractFeature implements IWebXRHitTestFeature<IWebXRHitResult> {
  154022. /**
  154023. * options to use when constructing this feature
  154024. */
  154025. readonly options: IWebXRHitTestOptions;
  154026. private _tmpMat;
  154027. private _tmpPos;
  154028. private _tmpQuat;
  154029. private _transientXrHitTestSource;
  154030. private _xrHitTestSource;
  154031. private initHitTestSource;
  154032. /**
  154033. * The module's name
  154034. */
  154035. static readonly Name: string;
  154036. /**
  154037. * The (Babylon) version of this module.
  154038. * This is an integer representing the implementation version.
  154039. * This number does not correspond to the WebXR specs version
  154040. */
  154041. static readonly Version: number;
  154042. /**
  154043. * When set to true, each hit test will have its own position/rotation objects
  154044. * When set to false, position and rotation objects will be reused for each hit test. It is expected that
  154045. * the developers will clone them or copy them as they see fit.
  154046. */
  154047. autoCloneTransformation: boolean;
  154048. /**
  154049. * Triggered when new babylon (transformed) hit test results are available
  154050. */
  154051. onHitTestResultObservable: Observable<IWebXRHitResult[]>;
  154052. /**
  154053. * Use this to temporarily pause hit test checks.
  154054. */
  154055. paused: boolean;
  154056. /**
  154057. * Creates a new instance of the hit test feature
  154058. * @param _xrSessionManager an instance of WebXRSessionManager
  154059. * @param options options to use when constructing this feature
  154060. */
  154061. constructor(_xrSessionManager: WebXRSessionManager,
  154062. /**
  154063. * options to use when constructing this feature
  154064. */
  154065. options?: IWebXRHitTestOptions);
  154066. /**
  154067. * attach this feature
  154068. * Will usually be called by the features manager
  154069. *
  154070. * @returns true if successful.
  154071. */
  154072. attach(): boolean;
  154073. /**
  154074. * detach this feature.
  154075. * Will usually be called by the features manager
  154076. *
  154077. * @returns true if successful.
  154078. */
  154079. detach(): boolean;
  154080. /**
  154081. * Dispose this feature and all of the resources attached
  154082. */
  154083. dispose(): void;
  154084. protected _onXRFrame(frame: XRFrame): void;
  154085. private _processWebXRHitTestResult;
  154086. }
  154087. }
  154088. declare module BABYLON {
  154089. /**
  154090. * Configuration options of the anchor system
  154091. */
  154092. export interface IWebXRAnchorSystemOptions {
  154093. /**
  154094. * a node that will be used to convert local to world coordinates
  154095. */
  154096. worldParentNode?: TransformNode;
  154097. /**
  154098. * If set to true a reference of the created anchors will be kept until the next session starts
  154099. * If not defined, anchors will be removed from the array when the feature is detached or the session ended.
  154100. */
  154101. doNotRemoveAnchorsOnSessionEnded?: boolean;
  154102. }
  154103. /**
  154104. * A babylon container for an XR Anchor
  154105. */
  154106. export interface IWebXRAnchor {
  154107. /**
  154108. * A babylon-assigned ID for this anchor
  154109. */
  154110. id: number;
  154111. /**
  154112. * Transformation matrix to apply to an object attached to this anchor
  154113. */
  154114. transformationMatrix: Matrix;
  154115. /**
  154116. * The native anchor object
  154117. */
  154118. xrAnchor: XRAnchor;
  154119. /**
  154120. * if defined, this object will be constantly updated by the anchor's position and rotation
  154121. */
  154122. attachedNode?: TransformNode;
  154123. }
  154124. /**
  154125. * An implementation of the anchor system for WebXR.
  154126. * For further information see https://github.com/immersive-web/anchors/
  154127. */
  154128. export class WebXRAnchorSystem extends WebXRAbstractFeature {
  154129. private _options;
  154130. private _lastFrameDetected;
  154131. private _trackedAnchors;
  154132. private _referenceSpaceForFrameAnchors;
  154133. private _futureAnchors;
  154134. /**
  154135. * The module's name
  154136. */
  154137. static readonly Name: string;
  154138. /**
  154139. * The (Babylon) version of this module.
  154140. * This is an integer representing the implementation version.
  154141. * This number does not correspond to the WebXR specs version
  154142. */
  154143. static readonly Version: number;
  154144. /**
  154145. * Observers registered here will be executed when a new anchor was added to the session
  154146. */
  154147. onAnchorAddedObservable: Observable<IWebXRAnchor>;
  154148. /**
  154149. * Observers registered here will be executed when an anchor was removed from the session
  154150. */
  154151. onAnchorRemovedObservable: Observable<IWebXRAnchor>;
  154152. /**
  154153. * Observers registered here will be executed when an existing anchor updates
  154154. * This can execute N times every frame
  154155. */
  154156. onAnchorUpdatedObservable: Observable<IWebXRAnchor>;
  154157. /**
  154158. * Set the reference space to use for anchor creation, when not using a hit test.
  154159. * Will default to the session's reference space if not defined
  154160. */
  154161. set referenceSpaceForFrameAnchors(referenceSpace: XRReferenceSpace);
  154162. /**
  154163. * constructs a new anchor system
  154164. * @param _xrSessionManager an instance of WebXRSessionManager
  154165. * @param _options configuration object for this feature
  154166. */
  154167. constructor(_xrSessionManager: WebXRSessionManager, _options?: IWebXRAnchorSystemOptions);
  154168. private _tmpVector;
  154169. private _tmpQuaternion;
  154170. private _populateTmpTransformation;
  154171. /**
  154172. * Create a new anchor point using a hit test result at a specific point in the scene
  154173. * An anchor is tracked only after it is added to the trackerAnchors in xrFrame. The promise returned here does not yet guaranty that.
  154174. * Use onAnchorAddedObservable to get newly added anchors if you require tracking guaranty.
  154175. *
  154176. * @param hitTestResult The hit test result to use for this anchor creation
  154177. * @param position an optional position offset for this anchor
  154178. * @param rotationQuaternion an optional rotation offset for this anchor
  154179. * @returns A promise that fulfills when the XR anchor was registered in the system (but not necessarily added to the tracked anchors)
  154180. */
  154181. addAnchorPointUsingHitTestResultAsync(hitTestResult: IWebXRHitResult, position?: Vector3, rotationQuaternion?: Quaternion): Promise<XRAnchor>;
  154182. /**
  154183. * Add a new anchor at a specific position and rotation
  154184. * This function will add a new anchor per default in the next available frame. Unless forced, the createAnchor function
  154185. * will be called in the next xrFrame loop to make sure that the anchor can be created correctly.
  154186. * An anchor is tracked only after it is added to the trackerAnchors in xrFrame. The promise returned here does not yet guaranty that.
  154187. * Use onAnchorAddedObservable to get newly added anchors if you require tracking guaranty.
  154188. *
  154189. * @param position the position in which to add an anchor
  154190. * @param rotationQuaternion an optional rotation for the anchor transformation
  154191. * @param forceCreateInCurrentFrame force the creation of this anchor in the current frame. Must be called inside xrFrame loop!
  154192. * @returns A promise that fulfills when the XR anchor was registered in the system (but not necessarily added to the tracked anchors)
  154193. */
  154194. addAnchorAtPositionAndRotationAsync(position: Vector3, rotationQuaternion?: Quaternion, forceCreateInCurrentFrame?: boolean): Promise<XRAnchor>;
  154195. /**
  154196. * detach this feature.
  154197. * Will usually be called by the features manager
  154198. *
  154199. * @returns true if successful.
  154200. */
  154201. detach(): boolean;
  154202. /**
  154203. * Dispose this feature and all of the resources attached
  154204. */
  154205. dispose(): void;
  154206. protected _onXRFrame(frame: XRFrame): void;
  154207. /**
  154208. * avoiding using Array.find for global support.
  154209. * @param xrAnchor the plane to find in the array
  154210. */
  154211. private _findIndexInAnchorArray;
  154212. private _updateAnchorWithXRFrame;
  154213. private _createAnchorAtTransformation;
  154214. }
  154215. }
  154216. declare module BABYLON {
  154217. /**
  154218. * Options used in the plane detector module
  154219. */
  154220. export interface IWebXRPlaneDetectorOptions {
  154221. /**
  154222. * The node to use to transform the local results to world coordinates
  154223. */
  154224. worldParentNode?: TransformNode;
  154225. /**
  154226. * If set to true a reference of the created planes will be kept until the next session starts
  154227. * If not defined, planes will be removed from the array when the feature is detached or the session ended.
  154228. */
  154229. doNotRemovePlanesOnSessionEnded?: boolean;
  154230. }
  154231. /**
  154232. * A babylon interface for a WebXR plane.
  154233. * A Plane is actually a polygon, built from N points in space
  154234. *
  154235. * Supported in chrome 79, not supported in canary 81 ATM
  154236. */
  154237. export interface IWebXRPlane {
  154238. /**
  154239. * a babylon-assigned ID for this polygon
  154240. */
  154241. id: number;
  154242. /**
  154243. * an array of vector3 points in babylon space. right/left hand system is taken into account.
  154244. */
  154245. polygonDefinition: Array<Vector3>;
  154246. /**
  154247. * A transformation matrix to apply on the mesh that will be built using the polygonDefinition
  154248. * Local vs. World are decided if worldParentNode was provided or not in the options when constructing the module
  154249. */
  154250. transformationMatrix: Matrix;
  154251. /**
  154252. * the native xr-plane object
  154253. */
  154254. xrPlane: XRPlane;
  154255. }
  154256. /**
  154257. * The plane detector is used to detect planes in the real world when in AR
  154258. * For more information see https://github.com/immersive-web/real-world-geometry/
  154259. */
  154260. export class WebXRPlaneDetector extends WebXRAbstractFeature {
  154261. private _options;
  154262. private _detectedPlanes;
  154263. private _enabled;
  154264. private _lastFrameDetected;
  154265. /**
  154266. * The module's name
  154267. */
  154268. static readonly Name: string;
  154269. /**
  154270. * The (Babylon) version of this module.
  154271. * This is an integer representing the implementation version.
  154272. * This number does not correspond to the WebXR specs version
  154273. */
  154274. static readonly Version: number;
  154275. /**
  154276. * Observers registered here will be executed when a new plane was added to the session
  154277. */
  154278. onPlaneAddedObservable: Observable<IWebXRPlane>;
  154279. /**
  154280. * Observers registered here will be executed when a plane is no longer detected in the session
  154281. */
  154282. onPlaneRemovedObservable: Observable<IWebXRPlane>;
  154283. /**
  154284. * Observers registered here will be executed when an existing plane updates (for example - expanded)
  154285. * This can execute N times every frame
  154286. */
  154287. onPlaneUpdatedObservable: Observable<IWebXRPlane>;
  154288. /**
  154289. * construct a new Plane Detector
  154290. * @param _xrSessionManager an instance of xr Session manager
  154291. * @param _options configuration to use when constructing this feature
  154292. */
  154293. constructor(_xrSessionManager: WebXRSessionManager, _options?: IWebXRPlaneDetectorOptions);
  154294. /**
  154295. * detach this feature.
  154296. * Will usually be called by the features manager
  154297. *
  154298. * @returns true if successful.
  154299. */
  154300. detach(): boolean;
  154301. /**
  154302. * Dispose this feature and all of the resources attached
  154303. */
  154304. dispose(): void;
  154305. protected _onXRFrame(frame: XRFrame): void;
  154306. private _init;
  154307. private _updatePlaneWithXRPlane;
  154308. /**
  154309. * avoiding using Array.find for global support.
  154310. * @param xrPlane the plane to find in the array
  154311. */
  154312. private findIndexInPlaneArray;
  154313. }
  154314. }
  154315. declare module BABYLON {
  154316. /**
  154317. * Options interface for the background remover plugin
  154318. */
  154319. export interface IWebXRBackgroundRemoverOptions {
  154320. /**
  154321. * Further background meshes to disable when entering AR
  154322. */
  154323. backgroundMeshes?: AbstractMesh[];
  154324. /**
  154325. * flags to configure the removal of the environment helper.
  154326. * If not set, the entire background will be removed. If set, flags should be set as well.
  154327. */
  154328. environmentHelperRemovalFlags?: {
  154329. /**
  154330. * Should the skybox be removed (default false)
  154331. */
  154332. skyBox?: boolean;
  154333. /**
  154334. * Should the ground be removed (default false)
  154335. */
  154336. ground?: boolean;
  154337. };
  154338. /**
  154339. * don't disable the environment helper
  154340. */
  154341. ignoreEnvironmentHelper?: boolean;
  154342. }
  154343. /**
  154344. * A module that will automatically disable background meshes when entering AR and will enable them when leaving AR.
  154345. */
  154346. export class WebXRBackgroundRemover extends WebXRAbstractFeature {
  154347. /**
  154348. * read-only options to be used in this module
  154349. */
  154350. readonly options: IWebXRBackgroundRemoverOptions;
  154351. /**
  154352. * The module's name
  154353. */
  154354. static readonly Name: string;
  154355. /**
  154356. * The (Babylon) version of this module.
  154357. * This is an integer representing the implementation version.
  154358. * This number does not correspond to the WebXR specs version
  154359. */
  154360. static readonly Version: number;
  154361. /**
  154362. * registered observers will be triggered when the background state changes
  154363. */
  154364. onBackgroundStateChangedObservable: Observable<boolean>;
  154365. /**
  154366. * constructs a new background remover module
  154367. * @param _xrSessionManager the session manager for this module
  154368. * @param options read-only options to be used in this module
  154369. */
  154370. constructor(_xrSessionManager: WebXRSessionManager,
  154371. /**
  154372. * read-only options to be used in this module
  154373. */
  154374. options?: IWebXRBackgroundRemoverOptions);
  154375. /**
  154376. * attach this feature
  154377. * Will usually be called by the features manager
  154378. *
  154379. * @returns true if successful.
  154380. */
  154381. attach(): boolean;
  154382. /**
  154383. * detach this feature.
  154384. * Will usually be called by the features manager
  154385. *
  154386. * @returns true if successful.
  154387. */
  154388. detach(): boolean;
  154389. /**
  154390. * Dispose this feature and all of the resources attached
  154391. */
  154392. dispose(): void;
  154393. protected _onXRFrame(_xrFrame: XRFrame): void;
  154394. private _setBackgroundState;
  154395. }
  154396. }
  154397. declare module BABYLON {
  154398. /**
  154399. * Options for the controller physics feature
  154400. */
  154401. export class IWebXRControllerPhysicsOptions {
  154402. /**
  154403. * Should the headset get its own impostor
  154404. */
  154405. enableHeadsetImpostor?: boolean;
  154406. /**
  154407. * Optional parameters for the headset impostor
  154408. */
  154409. headsetImpostorParams?: {
  154410. /**
  154411. * The type of impostor to create. Default is sphere
  154412. */
  154413. impostorType: number;
  154414. /**
  154415. * the size of the impostor. Defaults to 10cm
  154416. */
  154417. impostorSize?: number | {
  154418. width: number;
  154419. height: number;
  154420. depth: number;
  154421. };
  154422. /**
  154423. * Friction definitions
  154424. */
  154425. friction?: number;
  154426. /**
  154427. * Restitution
  154428. */
  154429. restitution?: number;
  154430. };
  154431. /**
  154432. * The physics properties of the future impostors
  154433. */
  154434. physicsProperties?: {
  154435. /**
  154436. * If set to true, a mesh impostor will be created when the controller mesh was loaded
  154437. * Note that this requires a physics engine that supports mesh impostors!
  154438. */
  154439. useControllerMesh?: boolean;
  154440. /**
  154441. * The type of impostor to create. Default is sphere
  154442. */
  154443. impostorType?: number;
  154444. /**
  154445. * the size of the impostor. Defaults to 10cm
  154446. */
  154447. impostorSize?: number | {
  154448. width: number;
  154449. height: number;
  154450. depth: number;
  154451. };
  154452. /**
  154453. * Friction definitions
  154454. */
  154455. friction?: number;
  154456. /**
  154457. * Restitution
  154458. */
  154459. restitution?: number;
  154460. };
  154461. /**
  154462. * the xr input to use with this pointer selection
  154463. */
  154464. xrInput: WebXRInput;
  154465. }
  154466. /**
  154467. * Add physics impostor to your webxr controllers,
  154468. * including naive calculation of their linear and angular velocity
  154469. */
  154470. export class WebXRControllerPhysics extends WebXRAbstractFeature {
  154471. private readonly _options;
  154472. private _attachController;
  154473. private _controllers;
  154474. private _debugMode;
  154475. private _delta;
  154476. private _headsetImpostor?;
  154477. private _headsetMesh?;
  154478. private _lastTimestamp;
  154479. private _tmpQuaternion;
  154480. private _tmpVector;
  154481. /**
  154482. * The module's name
  154483. */
  154484. static readonly Name: string;
  154485. /**
  154486. * The (Babylon) version of this module.
  154487. * This is an integer representing the implementation version.
  154488. * This number does not correspond to the webxr specs version
  154489. */
  154490. static readonly Version: number;
  154491. /**
  154492. * Construct a new Controller Physics Feature
  154493. * @param _xrSessionManager the corresponding xr session manager
  154494. * @param _options options to create this feature with
  154495. */
  154496. constructor(_xrSessionManager: WebXRSessionManager, _options: IWebXRControllerPhysicsOptions);
  154497. /**
  154498. * @hidden
  154499. * enable debugging - will show console outputs and the impostor mesh
  154500. */
  154501. _enablePhysicsDebug(): void;
  154502. /**
  154503. * Manually add a controller (if no xrInput was provided or physics engine was not enabled)
  154504. * @param xrController the controller to add
  154505. */
  154506. addController(xrController: WebXRInputSource): void;
  154507. /**
  154508. * attach this feature
  154509. * Will usually be called by the features manager
  154510. *
  154511. * @returns true if successful.
  154512. */
  154513. attach(): boolean;
  154514. /**
  154515. * detach this feature.
  154516. * Will usually be called by the features manager
  154517. *
  154518. * @returns true if successful.
  154519. */
  154520. detach(): boolean;
  154521. /**
  154522. * Get the headset impostor, if enabled
  154523. * @returns the impostor
  154524. */
  154525. getHeadsetImpostor(): PhysicsImpostor | undefined;
  154526. /**
  154527. * Get the physics impostor of a specific controller.
  154528. * The impostor is not attached to a mesh because a mesh for each controller is not obligatory
  154529. * @param controller the controller or the controller id of which to get the impostor
  154530. * @returns the impostor or null
  154531. */
  154532. getImpostorForController(controller: WebXRInputSource | string): Nullable<PhysicsImpostor>;
  154533. /**
  154534. * Update the physics properties provided in the constructor
  154535. * @param newProperties the new properties object
  154536. */
  154537. setPhysicsProperties(newProperties: {
  154538. impostorType?: number;
  154539. impostorSize?: number | {
  154540. width: number;
  154541. height: number;
  154542. depth: number;
  154543. };
  154544. friction?: number;
  154545. restitution?: number;
  154546. }): void;
  154547. protected _onXRFrame(_xrFrame: any): void;
  154548. private _detachController;
  154549. }
  154550. }
  154551. declare module BABYLON {
  154552. /**
  154553. * A babylon interface for a "WebXR" feature point.
  154554. * Represents the position and confidence value of a given feature point.
  154555. */
  154556. export interface IWebXRFeaturePoint {
  154557. /**
  154558. * Represents the position of the feature point in world space.
  154559. */
  154560. position: Vector3;
  154561. /**
  154562. * Represents the confidence value of the feature point in world space. 0 being least confident, and 1 being most confident.
  154563. */
  154564. confidenceValue: number;
  154565. }
  154566. /**
  154567. * The feature point system is used to detect feature points from real world geometry.
  154568. * This feature is currently experimental and only supported on BabylonNative, and should not be used in the browser.
  154569. * The newly introduced API can be seen in webxr.nativeextensions.d.ts and described in FeaturePoints.md.
  154570. */
  154571. export class WebXRFeaturePointSystem extends WebXRAbstractFeature {
  154572. private _enabled;
  154573. private _featurePointCloud;
  154574. /**
  154575. * The module's name
  154576. */
  154577. static readonly Name: string;
  154578. /**
  154579. * The (Babylon) version of this module.
  154580. * This is an integer representing the implementation version.
  154581. * This number does not correspond to the WebXR specs version
  154582. */
  154583. static readonly Version: number;
  154584. /**
  154585. * Observers registered here will be executed whenever new feature points are added (on XRFrame while the session is tracking).
  154586. * Will notify the observers about which feature points have been added.
  154587. */
  154588. readonly onFeaturePointsAddedObservable: Observable<number[]>;
  154589. /**
  154590. * Observers registered here will be executed whenever a feature point has been updated (on XRFrame while the session is tracking).
  154591. * Will notify the observers about which feature points have been updated.
  154592. */
  154593. readonly onFeaturePointsUpdatedObservable: Observable<number[]>;
  154594. /**
  154595. * The current feature point cloud maintained across frames.
  154596. */
  154597. get featurePointCloud(): Array<IWebXRFeaturePoint>;
  154598. /**
  154599. * construct the feature point system
  154600. * @param _xrSessionManager an instance of xr Session manager
  154601. */
  154602. constructor(_xrSessionManager: WebXRSessionManager);
  154603. /**
  154604. * Detach this feature.
  154605. * Will usually be called by the features manager
  154606. *
  154607. * @returns true if successful.
  154608. */
  154609. detach(): boolean;
  154610. /**
  154611. * Dispose this feature and all of the resources attached
  154612. */
  154613. dispose(): void;
  154614. /**
  154615. * On receiving a new XR frame if this feature is attached notify observers new feature point data is available.
  154616. */
  154617. protected _onXRFrame(frame: XRFrame): void;
  154618. /**
  154619. * Initializes the feature. If the feature point feature is not available for this environment do not mark the feature as enabled.
  154620. */
  154621. private _init;
  154622. }
  154623. }
  154624. declare module BABYLON {
  154625. /**
  154626. * Configuration interface for the hand tracking feature
  154627. */
  154628. export interface IWebXRHandTrackingOptions {
  154629. /**
  154630. * The xrInput that will be used as source for new hands
  154631. */
  154632. xrInput: WebXRInput;
  154633. /**
  154634. * Configuration object for the joint meshes
  154635. */
  154636. jointMeshes?: {
  154637. /**
  154638. * Should the meshes created be invisible (defaults to false)
  154639. */
  154640. invisible?: boolean;
  154641. /**
  154642. * A source mesh to be used to create instances. Defaults to a sphere.
  154643. * This mesh will be the source for all other (25) meshes.
  154644. * It should have the general size of a single unit, as the instances will be scaled according to the provided radius
  154645. */
  154646. sourceMesh?: Mesh;
  154647. /**
  154648. * Should the source mesh stay visible. Defaults to false
  154649. */
  154650. keepOriginalVisible?: boolean;
  154651. /**
  154652. * Scale factor for all instances (defaults to 2)
  154653. */
  154654. scaleFactor?: number;
  154655. /**
  154656. * Should each instance have its own physics impostor
  154657. */
  154658. enablePhysics?: boolean;
  154659. /**
  154660. * If enabled, override default physics properties
  154661. */
  154662. physicsProps?: {
  154663. friction?: number;
  154664. restitution?: number;
  154665. impostorType?: number;
  154666. };
  154667. /**
  154668. * For future use - a single hand-mesh that will be updated according to the XRHand data provided
  154669. */
  154670. handMesh?: AbstractMesh;
  154671. };
  154672. }
  154673. /**
  154674. * Parts of the hands divided to writs and finger names
  154675. */
  154676. export const enum HandPart {
  154677. /**
  154678. * HandPart - Wrist
  154679. */
  154680. WRIST = "wrist",
  154681. /**
  154682. * HandPart - The THumb
  154683. */
  154684. THUMB = "thumb",
  154685. /**
  154686. * HandPart - Index finger
  154687. */
  154688. INDEX = "index",
  154689. /**
  154690. * HandPart - Middle finger
  154691. */
  154692. MIDDLE = "middle",
  154693. /**
  154694. * HandPart - Ring finger
  154695. */
  154696. RING = "ring",
  154697. /**
  154698. * HandPart - Little finger
  154699. */
  154700. LITTLE = "little"
  154701. }
  154702. /**
  154703. * Representing a single hand (with its corresponding native XRHand object)
  154704. */
  154705. export class WebXRHand implements IDisposable {
  154706. /** the controller to which the hand correlates */
  154707. readonly xrController: WebXRInputSource;
  154708. /** the meshes to be used to track the hand joints */
  154709. readonly trackedMeshes: AbstractMesh[];
  154710. /**
  154711. * Hand-parts definition (key is HandPart)
  154712. */
  154713. static HandPartsDefinition: {
  154714. [key: string]: number[];
  154715. };
  154716. /**
  154717. * Populate the HandPartsDefinition object.
  154718. * This is called as a side effect since certain browsers don't have XRHand defined.
  154719. */
  154720. static _PopulateHandPartsDefinition(): void;
  154721. /**
  154722. * Construct a new hand object
  154723. * @param xrController the controller to which the hand correlates
  154724. * @param trackedMeshes the meshes to be used to track the hand joints
  154725. */
  154726. constructor(
  154727. /** the controller to which the hand correlates */
  154728. xrController: WebXRInputSource,
  154729. /** the meshes to be used to track the hand joints */
  154730. trackedMeshes: AbstractMesh[]);
  154731. /**
  154732. * Update this hand from the latest xr frame
  154733. * @param xrFrame xrFrame to update from
  154734. * @param referenceSpace The current viewer reference space
  154735. * @param scaleFactor optional scale factor for the meshes
  154736. */
  154737. updateFromXRFrame(xrFrame: XRFrame, referenceSpace: XRReferenceSpace, scaleFactor?: number): void;
  154738. /**
  154739. * Get meshes of part of the hand
  154740. * @param part the part of hand to get
  154741. * @returns An array of meshes that correlate to the hand part requested
  154742. */
  154743. getHandPartMeshes(part: HandPart): AbstractMesh[];
  154744. /**
  154745. * Dispose this Hand object
  154746. */
  154747. dispose(): void;
  154748. }
  154749. /**
  154750. * WebXR Hand Joint tracking feature, available for selected browsers and devices
  154751. */
  154752. export class WebXRHandTracking extends WebXRAbstractFeature {
  154753. /**
  154754. * options to use when constructing this feature
  154755. */
  154756. readonly options: IWebXRHandTrackingOptions;
  154757. private static _idCounter;
  154758. /**
  154759. * The module's name
  154760. */
  154761. static readonly Name: string;
  154762. /**
  154763. * The (Babylon) version of this module.
  154764. * This is an integer representing the implementation version.
  154765. * This number does not correspond to the WebXR specs version
  154766. */
  154767. static readonly Version: number;
  154768. /**
  154769. * This observable will notify registered observers when a new hand object was added and initialized
  154770. */
  154771. onHandAddedObservable: Observable<WebXRHand>;
  154772. /**
  154773. * This observable will notify its observers right before the hand object is disposed
  154774. */
  154775. onHandRemovedObservable: Observable<WebXRHand>;
  154776. private _hands;
  154777. /**
  154778. * Creates a new instance of the hit test feature
  154779. * @param _xrSessionManager an instance of WebXRSessionManager
  154780. * @param options options to use when constructing this feature
  154781. */
  154782. constructor(_xrSessionManager: WebXRSessionManager,
  154783. /**
  154784. * options to use when constructing this feature
  154785. */
  154786. options: IWebXRHandTrackingOptions);
  154787. /**
  154788. * Check if the needed objects are defined.
  154789. * This does not mean that the feature is enabled, but that the objects needed are well defined.
  154790. */
  154791. isCompatible(): boolean;
  154792. /**
  154793. * attach this feature
  154794. * Will usually be called by the features manager
  154795. *
  154796. * @returns true if successful.
  154797. */
  154798. attach(): boolean;
  154799. /**
  154800. * detach this feature.
  154801. * Will usually be called by the features manager
  154802. *
  154803. * @returns true if successful.
  154804. */
  154805. detach(): boolean;
  154806. /**
  154807. * Dispose this feature and all of the resources attached
  154808. */
  154809. dispose(): void;
  154810. /**
  154811. * Get the hand object according to the controller id
  154812. * @param controllerId the controller id to which we want to get the hand
  154813. * @returns null if not found or the WebXRHand object if found
  154814. */
  154815. getHandByControllerId(controllerId: string): Nullable<WebXRHand>;
  154816. /**
  154817. * Get a hand object according to the requested handedness
  154818. * @param handedness the handedness to request
  154819. * @returns null if not found or the WebXRHand object if found
  154820. */
  154821. getHandByHandedness(handedness: XRHandedness): Nullable<WebXRHand>;
  154822. protected _onXRFrame(_xrFrame: XRFrame): void;
  154823. private _attachHand;
  154824. private _detachHand;
  154825. }
  154826. }
  154827. declare module BABYLON {
  154828. /**
  154829. * The motion controller class for all microsoft mixed reality controllers
  154830. */
  154831. export class WebXRMicrosoftMixedRealityController extends WebXRAbstractMotionController {
  154832. protected readonly _mapping: {
  154833. defaultButton: {
  154834. valueNodeName: string;
  154835. unpressedNodeName: string;
  154836. pressedNodeName: string;
  154837. };
  154838. defaultAxis: {
  154839. valueNodeName: string;
  154840. minNodeName: string;
  154841. maxNodeName: string;
  154842. };
  154843. buttons: {
  154844. "xr-standard-trigger": {
  154845. rootNodeName: string;
  154846. componentProperty: string;
  154847. states: string[];
  154848. };
  154849. "xr-standard-squeeze": {
  154850. rootNodeName: string;
  154851. componentProperty: string;
  154852. states: string[];
  154853. };
  154854. "xr-standard-touchpad": {
  154855. rootNodeName: string;
  154856. labelAnchorNodeName: string;
  154857. touchPointNodeName: string;
  154858. };
  154859. "xr-standard-thumbstick": {
  154860. rootNodeName: string;
  154861. componentProperty: string;
  154862. states: string[];
  154863. };
  154864. };
  154865. axes: {
  154866. "xr-standard-touchpad": {
  154867. "x-axis": {
  154868. rootNodeName: string;
  154869. };
  154870. "y-axis": {
  154871. rootNodeName: string;
  154872. };
  154873. };
  154874. "xr-standard-thumbstick": {
  154875. "x-axis": {
  154876. rootNodeName: string;
  154877. };
  154878. "y-axis": {
  154879. rootNodeName: string;
  154880. };
  154881. };
  154882. };
  154883. };
  154884. /**
  154885. * The base url used to load the left and right controller models
  154886. */
  154887. static MODEL_BASE_URL: string;
  154888. /**
  154889. * The name of the left controller model file
  154890. */
  154891. static MODEL_LEFT_FILENAME: string;
  154892. /**
  154893. * The name of the right controller model file
  154894. */
  154895. static MODEL_RIGHT_FILENAME: string;
  154896. profileId: string;
  154897. constructor(scene: Scene, gamepadObject: IMinimalMotionControllerObject, handedness: MotionControllerHandedness);
  154898. protected _getFilenameAndPath(): {
  154899. filename: string;
  154900. path: string;
  154901. };
  154902. protected _getModelLoadingConstraints(): boolean;
  154903. protected _processLoadedModel(_meshes: AbstractMesh[]): void;
  154904. protected _setRootMesh(meshes: AbstractMesh[]): void;
  154905. protected _updateModel(): void;
  154906. }
  154907. }
  154908. declare module BABYLON {
  154909. /**
  154910. * The motion controller class for oculus touch (quest, rift).
  154911. * This class supports legacy mapping as well the standard xr mapping
  154912. */
  154913. export class WebXROculusTouchMotionController extends WebXRAbstractMotionController {
  154914. private _forceLegacyControllers;
  154915. private _modelRootNode;
  154916. /**
  154917. * The base url used to load the left and right controller models
  154918. */
  154919. static MODEL_BASE_URL: string;
  154920. /**
  154921. * The name of the left controller model file
  154922. */
  154923. static MODEL_LEFT_FILENAME: string;
  154924. /**
  154925. * The name of the right controller model file
  154926. */
  154927. static MODEL_RIGHT_FILENAME: string;
  154928. /**
  154929. * Base Url for the Quest controller model.
  154930. */
  154931. static QUEST_MODEL_BASE_URL: string;
  154932. profileId: string;
  154933. constructor(scene: Scene, gamepadObject: IMinimalMotionControllerObject, handedness: MotionControllerHandedness, legacyMapping?: boolean, _forceLegacyControllers?: boolean);
  154934. protected _getFilenameAndPath(): {
  154935. filename: string;
  154936. path: string;
  154937. };
  154938. protected _getModelLoadingConstraints(): boolean;
  154939. protected _processLoadedModel(_meshes: AbstractMesh[]): void;
  154940. protected _setRootMesh(meshes: AbstractMesh[]): void;
  154941. protected _updateModel(): void;
  154942. /**
  154943. * Is this the new type of oculus touch. At the moment both have the same profile and it is impossible to differentiate
  154944. * between the touch and touch 2.
  154945. */
  154946. private _isQuest;
  154947. }
  154948. }
  154949. declare module BABYLON {
  154950. /**
  154951. * The motion controller class for the standard HTC-Vive controllers
  154952. */
  154953. export class WebXRHTCViveMotionController extends WebXRAbstractMotionController {
  154954. private _modelRootNode;
  154955. /**
  154956. * The base url used to load the left and right controller models
  154957. */
  154958. static MODEL_BASE_URL: string;
  154959. /**
  154960. * File name for the controller model.
  154961. */
  154962. static MODEL_FILENAME: string;
  154963. profileId: string;
  154964. /**
  154965. * Create a new Vive motion controller object
  154966. * @param scene the scene to use to create this controller
  154967. * @param gamepadObject the corresponding gamepad object
  154968. * @param handedness the handedness of the controller
  154969. */
  154970. constructor(scene: Scene, gamepadObject: IMinimalMotionControllerObject, handedness: MotionControllerHandedness);
  154971. protected _getFilenameAndPath(): {
  154972. filename: string;
  154973. path: string;
  154974. };
  154975. protected _getModelLoadingConstraints(): boolean;
  154976. protected _processLoadedModel(_meshes: AbstractMesh[]): void;
  154977. protected _setRootMesh(meshes: AbstractMesh[]): void;
  154978. protected _updateModel(): void;
  154979. }
  154980. }
  154981. declare module BABYLON {
  154982. /**
  154983. * A cursor which tracks a point on a path
  154984. */
  154985. export class PathCursor {
  154986. private path;
  154987. /**
  154988. * Stores path cursor callbacks for when an onchange event is triggered
  154989. */
  154990. private _onchange;
  154991. /**
  154992. * The value of the path cursor
  154993. */
  154994. value: number;
  154995. /**
  154996. * The animation array of the path cursor
  154997. */
  154998. animations: Animation[];
  154999. /**
  155000. * Initializes the path cursor
  155001. * @param path The path to track
  155002. */
  155003. constructor(path: Path2);
  155004. /**
  155005. * Gets the cursor point on the path
  155006. * @returns A point on the path cursor at the cursor location
  155007. */
  155008. getPoint(): Vector3;
  155009. /**
  155010. * Moves the cursor ahead by the step amount
  155011. * @param step The amount to move the cursor forward
  155012. * @returns This path cursor
  155013. */
  155014. moveAhead(step?: number): PathCursor;
  155015. /**
  155016. * Moves the cursor behind by the step amount
  155017. * @param step The amount to move the cursor back
  155018. * @returns This path cursor
  155019. */
  155020. moveBack(step?: number): PathCursor;
  155021. /**
  155022. * Moves the cursor by the step amount
  155023. * If the step amount is greater than one, an exception is thrown
  155024. * @param step The amount to move the cursor
  155025. * @returns This path cursor
  155026. */
  155027. move(step: number): PathCursor;
  155028. /**
  155029. * Ensures that the value is limited between zero and one
  155030. * @returns This path cursor
  155031. */
  155032. private ensureLimits;
  155033. /**
  155034. * Runs onchange callbacks on change (used by the animation engine)
  155035. * @returns This path cursor
  155036. */
  155037. private raiseOnChange;
  155038. /**
  155039. * Executes a function on change
  155040. * @param f A path cursor onchange callback
  155041. * @returns This path cursor
  155042. */
  155043. onchange(f: (cursor: PathCursor) => void): PathCursor;
  155044. }
  155045. }
  155046. declare module BABYLON {
  155047. /** @hidden */
  155048. export var blurPixelShader: {
  155049. name: string;
  155050. shader: string;
  155051. };
  155052. }
  155053. declare module BABYLON {
  155054. /** @hidden */
  155055. export var pointCloudVertexDeclaration: {
  155056. name: string;
  155057. shader: string;
  155058. };
  155059. }
  155060. // Mixins
  155061. interface Window {
  155062. mozIndexedDB: IDBFactory;
  155063. webkitIndexedDB: IDBFactory;
  155064. msIndexedDB: IDBFactory;
  155065. webkitURL: typeof URL;
  155066. mozRequestAnimationFrame(callback: FrameRequestCallback): number;
  155067. oRequestAnimationFrame(callback: FrameRequestCallback): number;
  155068. WebGLRenderingContext: WebGLRenderingContext;
  155069. MSGesture: MSGesture;
  155070. CANNON: any;
  155071. AudioContext: AudioContext;
  155072. webkitAudioContext: AudioContext;
  155073. PointerEvent: any;
  155074. Math: Math;
  155075. Uint8Array: Uint8ArrayConstructor;
  155076. Float32Array: Float32ArrayConstructor;
  155077. mozURL: typeof URL;
  155078. msURL: typeof URL;
  155079. VRFrameData: any; // WebVR, from specs 1.1
  155080. DracoDecoderModule: any;
  155081. setImmediate(handler: (...args: any[]) => void): number;
  155082. }
  155083. interface HTMLCanvasElement {
  155084. requestPointerLock(): void;
  155085. msRequestPointerLock?(): void;
  155086. mozRequestPointerLock?(): void;
  155087. webkitRequestPointerLock?(): void;
  155088. /** Track wether a record is in progress */
  155089. isRecording: boolean;
  155090. /** Capture Stream method defined by some browsers */
  155091. captureStream(fps?: number): MediaStream;
  155092. }
  155093. interface CanvasRenderingContext2D {
  155094. msImageSmoothingEnabled: boolean;
  155095. }
  155096. interface MouseEvent {
  155097. mozMovementX: number;
  155098. mozMovementY: number;
  155099. webkitMovementX: number;
  155100. webkitMovementY: number;
  155101. msMovementX: number;
  155102. msMovementY: number;
  155103. }
  155104. interface Navigator {
  155105. mozGetVRDevices: (any: any) => any;
  155106. webkitGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  155107. mozGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  155108. msGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  155109. webkitGetGamepads(): Gamepad[];
  155110. msGetGamepads(): Gamepad[];
  155111. webkitGamepads(): Gamepad[];
  155112. }
  155113. interface HTMLVideoElement {
  155114. mozSrcObject: any;
  155115. }
  155116. interface Math {
  155117. fround(x: number): number;
  155118. imul(a: number, b: number): number;
  155119. }
  155120. interface WebGLRenderingContext {
  155121. drawArraysInstanced(mode: number, first: number, count: number, primcount: number): void;
  155122. drawElementsInstanced(mode: number, count: number, type: number, offset: number, primcount: number): void;
  155123. vertexAttribDivisor(index: number, divisor: number): void;
  155124. createVertexArray(): any;
  155125. bindVertexArray(vao?: WebGLVertexArrayObject | null): void;
  155126. deleteVertexArray(vao: WebGLVertexArrayObject): void;
  155127. blitFramebuffer(srcX0: number, srcY0: number, srcX1: number, srcY1: number, dstX0: number, dstY0: number, dstX1: number, dstY1: number, mask: number, filter: number): void;
  155128. renderbufferStorageMultisample?(target: number, samples: number, internalformat: number, width: number, height: number): void;
  155129. bindBufferBase(target: number, index: number, buffer: WebGLBuffer | null): void;
  155130. getUniformBlockIndex(program: WebGLProgram, uniformBlockName: string): number;
  155131. uniformBlockBinding(program: WebGLProgram, uniformBlockIndex: number, uniformBlockBinding: number): void;
  155132. // Queries
  155133. createQuery(): WebGLQuery;
  155134. deleteQuery(query: WebGLQuery): void;
  155135. beginQuery(target: number, query: WebGLQuery): void;
  155136. endQuery(target: number): void;
  155137. getQueryParameter(query: WebGLQuery, pname: number): any;
  155138. getQuery(target: number, pname: number): any;
  155139. MAX_SAMPLES: number;
  155140. RGBA8: number;
  155141. READ_FRAMEBUFFER: number;
  155142. DRAW_FRAMEBUFFER: number;
  155143. UNIFORM_BUFFER: number;
  155144. HALF_FLOAT_OES: number;
  155145. RGBA16F: number;
  155146. RGBA32F: number;
  155147. R32F: number;
  155148. RG32F: number;
  155149. RGB32F: number;
  155150. R16F: number;
  155151. RG16F: number;
  155152. RGB16F: number;
  155153. RED: number;
  155154. RG: number;
  155155. R8: number;
  155156. RG8: number;
  155157. UNSIGNED_INT_24_8: number;
  155158. DEPTH24_STENCIL8: number;
  155159. MIN: number;
  155160. MAX: number;
  155161. /* Multiple Render Targets */
  155162. drawBuffers(buffers: number[]): void;
  155163. readBuffer(src: number): void;
  155164. readonly COLOR_ATTACHMENT0: number; // 0x8CE1
  155165. readonly COLOR_ATTACHMENT1: number; // 0x8CE2
  155166. readonly COLOR_ATTACHMENT2: number; // 0x8CE3
  155167. readonly COLOR_ATTACHMENT3: number; // 0x8CE4
  155168. // Occlusion Query
  155169. ANY_SAMPLES_PASSED_CONSERVATIVE: number;
  155170. ANY_SAMPLES_PASSED: number;
  155171. QUERY_RESULT_AVAILABLE: number;
  155172. QUERY_RESULT: number;
  155173. }
  155174. interface WebGLProgram {
  155175. __SPECTOR_rebuildProgram?: ((vertexSourceCode: string, fragmentSourceCode: string, onCompiled: (program: WebGLProgram) => void, onError: (message: string) => void) => void) | null;
  155176. }
  155177. interface EXT_disjoint_timer_query {
  155178. QUERY_COUNTER_BITS_EXT: number;
  155179. TIME_ELAPSED_EXT: number;
  155180. TIMESTAMP_EXT: number;
  155181. GPU_DISJOINT_EXT: number;
  155182. QUERY_RESULT_EXT: number;
  155183. QUERY_RESULT_AVAILABLE_EXT: number;
  155184. queryCounterEXT(query: WebGLQuery, target: number): void;
  155185. createQueryEXT(): WebGLQuery;
  155186. beginQueryEXT(target: number, query: WebGLQuery): void;
  155187. endQueryEXT(target: number): void;
  155188. getQueryObjectEXT(query: WebGLQuery, target: number): any;
  155189. deleteQueryEXT(query: WebGLQuery): void;
  155190. }
  155191. interface WebGLUniformLocation {
  155192. _currentState: any;
  155193. }
  155194. // Type definitions for WebGL 2, Editor's Draft Fri Feb 24 16:10:18 2017 -0800
  155195. // Project: https://www.khronos.org/registry/webgl/specs/latest/2.0/
  155196. // Definitions by: Nico Kemnitz <https://github.com/nkemnitz/>
  155197. // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
  155198. interface WebGLRenderingContext {
  155199. readonly RASTERIZER_DISCARD: number;
  155200. readonly DEPTH_COMPONENT24: number;
  155201. readonly TEXTURE_3D: number;
  155202. readonly TEXTURE_2D_ARRAY: number;
  155203. readonly TEXTURE_COMPARE_FUNC: number;
  155204. readonly TEXTURE_COMPARE_MODE: number;
  155205. readonly COMPARE_REF_TO_TEXTURE: number;
  155206. readonly TEXTURE_WRAP_R: number;
  155207. readonly HALF_FLOAT: number;
  155208. readonly RGB8: number;
  155209. readonly RED_INTEGER: number;
  155210. readonly RG_INTEGER: number;
  155211. readonly RGB_INTEGER: number;
  155212. readonly RGBA_INTEGER: number;
  155213. readonly R8_SNORM: number;
  155214. readonly RG8_SNORM: number;
  155215. readonly RGB8_SNORM: number;
  155216. readonly RGBA8_SNORM: number;
  155217. readonly R8I: number;
  155218. readonly RG8I: number;
  155219. readonly RGB8I: number;
  155220. readonly RGBA8I: number;
  155221. readonly R8UI: number;
  155222. readonly RG8UI: number;
  155223. readonly RGB8UI: number;
  155224. readonly RGBA8UI: number;
  155225. readonly R16I: number;
  155226. readonly RG16I: number;
  155227. readonly RGB16I: number;
  155228. readonly RGBA16I: number;
  155229. readonly R16UI: number;
  155230. readonly RG16UI: number;
  155231. readonly RGB16UI: number;
  155232. readonly RGBA16UI: number;
  155233. readonly R32I: number;
  155234. readonly RG32I: number;
  155235. readonly RGB32I: number;
  155236. readonly RGBA32I: number;
  155237. readonly R32UI: number;
  155238. readonly RG32UI: number;
  155239. readonly RGB32UI: number;
  155240. readonly RGBA32UI: number;
  155241. readonly RGB10_A2UI: number;
  155242. readonly R11F_G11F_B10F: number;
  155243. readonly RGB9_E5: number;
  155244. readonly RGB10_A2: number;
  155245. readonly UNSIGNED_INT_2_10_10_10_REV: number;
  155246. readonly UNSIGNED_INT_10F_11F_11F_REV: number;
  155247. readonly UNSIGNED_INT_5_9_9_9_REV: number;
  155248. readonly FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  155249. readonly DEPTH_COMPONENT32F: number;
  155250. texImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, format: number, type: number, pixels: ArrayBufferView | null): void;
  155251. texImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, format: number, type: number, pixels: ArrayBufferView, offset: number): void;
  155252. 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;
  155253. framebufferTextureLayer(target: number, attachment: number, texture: WebGLTexture | null, level: number, layer: number): void;
  155254. compressedTexImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, data: ArrayBufferView, offset?: number, length?: number): void;
  155255. readonly TRANSFORM_FEEDBACK: number;
  155256. readonly INTERLEAVED_ATTRIBS: number;
  155257. readonly TRANSFORM_FEEDBACK_BUFFER: number;
  155258. createTransformFeedback(): WebGLTransformFeedback;
  155259. deleteTransformFeedback(transformFeedbac: WebGLTransformFeedback): void;
  155260. bindTransformFeedback(target: number, transformFeedback: WebGLTransformFeedback | null): void;
  155261. beginTransformFeedback(primitiveMode: number): void;
  155262. endTransformFeedback(): void;
  155263. transformFeedbackVaryings(program: WebGLProgram, varyings: string[], bufferMode: number): void;
  155264. clearBufferfv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  155265. clearBufferiv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  155266. clearBufferuiv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  155267. clearBufferfi(buffer: number, drawbuffer: number, depth: number, stencil: number): void;
  155268. }
  155269. interface ImageBitmap {
  155270. readonly width: number;
  155271. readonly height: number;
  155272. close(): void;
  155273. }
  155274. interface WebGLQuery extends WebGLObject {
  155275. }
  155276. declare var WebGLQuery: {
  155277. prototype: WebGLQuery;
  155278. new(): WebGLQuery;
  155279. };
  155280. interface WebGLSampler extends WebGLObject {
  155281. }
  155282. declare var WebGLSampler: {
  155283. prototype: WebGLSampler;
  155284. new(): WebGLSampler;
  155285. };
  155286. interface WebGLSync extends WebGLObject {
  155287. }
  155288. declare var WebGLSync: {
  155289. prototype: WebGLSync;
  155290. new(): WebGLSync;
  155291. };
  155292. interface WebGLTransformFeedback extends WebGLObject {
  155293. }
  155294. declare var WebGLTransformFeedback: {
  155295. prototype: WebGLTransformFeedback;
  155296. new(): WebGLTransformFeedback;
  155297. };
  155298. interface WebGLVertexArrayObject extends WebGLObject {
  155299. }
  155300. declare var WebGLVertexArrayObject: {
  155301. prototype: WebGLVertexArrayObject;
  155302. new(): WebGLVertexArrayObject;
  155303. };
  155304. // Type definitions for WebVR API
  155305. // Project: https://w3c.github.io/webvr/
  155306. // Definitions by: six a <https://github.com/lostfictions>
  155307. // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
  155308. interface VRDisplay extends EventTarget {
  155309. /**
  155310. * Dictionary of capabilities describing the VRDisplay.
  155311. */
  155312. readonly capabilities: VRDisplayCapabilities;
  155313. /**
  155314. * z-depth defining the far plane of the eye view frustum
  155315. * enables mapping of values in the render target depth
  155316. * attachment to scene coordinates. Initially set to 10000.0.
  155317. */
  155318. depthFar: number;
  155319. /**
  155320. * z-depth defining the near plane of the eye view frustum
  155321. * enables mapping of values in the render target depth
  155322. * attachment to scene coordinates. Initially set to 0.01.
  155323. */
  155324. depthNear: number;
  155325. /**
  155326. * An identifier for this distinct VRDisplay. Used as an
  155327. * association point in the Gamepad API.
  155328. */
  155329. readonly displayId: number;
  155330. /**
  155331. * A display name, a user-readable name identifying it.
  155332. */
  155333. readonly displayName: string;
  155334. readonly isConnected: boolean;
  155335. readonly isPresenting: boolean;
  155336. /**
  155337. * If this VRDisplay supports room-scale experiences, the optional
  155338. * stage attribute contains details on the room-scale parameters.
  155339. */
  155340. readonly stageParameters: VRStageParameters | null;
  155341. /**
  155342. * Passing the value returned by `requestAnimationFrame` to
  155343. * `cancelAnimationFrame` will unregister the callback.
  155344. * @param handle Define the hanle of the request to cancel
  155345. */
  155346. cancelAnimationFrame(handle: number): void;
  155347. /**
  155348. * Stops presenting to the VRDisplay.
  155349. * @returns a promise to know when it stopped
  155350. */
  155351. exitPresent(): Promise<void>;
  155352. /**
  155353. * Return the current VREyeParameters for the given eye.
  155354. * @param whichEye Define the eye we want the parameter for
  155355. * @returns the eye parameters
  155356. */
  155357. getEyeParameters(whichEye: string): VREyeParameters;
  155358. /**
  155359. * Populates the passed VRFrameData with the information required to render
  155360. * the current frame.
  155361. * @param frameData Define the data structure to populate
  155362. * @returns true if ok otherwise false
  155363. */
  155364. getFrameData(frameData: VRFrameData): boolean;
  155365. /**
  155366. * Get the layers currently being presented.
  155367. * @returns the list of VR layers
  155368. */
  155369. getLayers(): VRLayer[];
  155370. /**
  155371. * Return a VRPose containing the future predicted pose of the VRDisplay
  155372. * when the current frame will be presented. The value returned will not
  155373. * change until JavaScript has returned control to the browser.
  155374. *
  155375. * The VRPose will contain the position, orientation, velocity,
  155376. * and acceleration of each of these properties.
  155377. * @returns the pose object
  155378. */
  155379. getPose(): VRPose;
  155380. /**
  155381. * Return the current instantaneous pose of the VRDisplay, with no
  155382. * prediction applied.
  155383. * @returns the current instantaneous pose
  155384. */
  155385. getImmediatePose(): VRPose;
  155386. /**
  155387. * The callback passed to `requestAnimationFrame` will be called
  155388. * any time a new frame should be rendered. When the VRDisplay is
  155389. * presenting the callback will be called at the native refresh
  155390. * rate of the HMD. When not presenting this function acts
  155391. * identically to how window.requestAnimationFrame acts. Content should
  155392. * make no assumptions of frame rate or vsync behavior as the HMD runs
  155393. * asynchronously from other displays and at differing refresh rates.
  155394. * @param callback Define the eaction to run next frame
  155395. * @returns the request handle it
  155396. */
  155397. requestAnimationFrame(callback: FrameRequestCallback): number;
  155398. /**
  155399. * Begin presenting to the VRDisplay. Must be called in response to a user gesture.
  155400. * Repeat calls while already presenting will update the VRLayers being displayed.
  155401. * @param layers Define the list of layer to present
  155402. * @returns a promise to know when the request has been fulfilled
  155403. */
  155404. requestPresent(layers: VRLayer[]): Promise<void>;
  155405. /**
  155406. * Reset the pose for this display, treating its current position and
  155407. * orientation as the "origin/zero" values. VRPose.position,
  155408. * VRPose.orientation, and VRStageParameters.sittingToStandingTransform may be
  155409. * updated when calling resetPose(). This should be called in only
  155410. * sitting-space experiences.
  155411. */
  155412. resetPose(): void;
  155413. /**
  155414. * The VRLayer provided to the VRDisplay will be captured and presented
  155415. * in the HMD. Calling this function has the same effect on the source
  155416. * canvas as any other operation that uses its source image, and canvases
  155417. * created without preserveDrawingBuffer set to true will be cleared.
  155418. * @param pose Define the pose to submit
  155419. */
  155420. submitFrame(pose?: VRPose): void;
  155421. }
  155422. declare var VRDisplay: {
  155423. prototype: VRDisplay;
  155424. new(): VRDisplay;
  155425. };
  155426. interface VRLayer {
  155427. leftBounds?: number[] | Float32Array | null;
  155428. rightBounds?: number[] | Float32Array | null;
  155429. source?: HTMLCanvasElement | null;
  155430. }
  155431. interface VRDisplayCapabilities {
  155432. readonly canPresent: boolean;
  155433. readonly hasExternalDisplay: boolean;
  155434. readonly hasOrientation: boolean;
  155435. readonly hasPosition: boolean;
  155436. readonly maxLayers: number;
  155437. }
  155438. interface VREyeParameters {
  155439. /** @deprecated */
  155440. readonly fieldOfView: VRFieldOfView;
  155441. readonly offset: Float32Array;
  155442. readonly renderHeight: number;
  155443. readonly renderWidth: number;
  155444. }
  155445. interface VRFieldOfView {
  155446. readonly downDegrees: number;
  155447. readonly leftDegrees: number;
  155448. readonly rightDegrees: number;
  155449. readonly upDegrees: number;
  155450. }
  155451. interface VRFrameData {
  155452. readonly leftProjectionMatrix: Float32Array;
  155453. readonly leftViewMatrix: Float32Array;
  155454. readonly pose: VRPose;
  155455. readonly rightProjectionMatrix: Float32Array;
  155456. readonly rightViewMatrix: Float32Array;
  155457. readonly timestamp: number;
  155458. }
  155459. interface VRPose {
  155460. readonly angularAcceleration: Float32Array | null;
  155461. readonly angularVelocity: Float32Array | null;
  155462. readonly linearAcceleration: Float32Array | null;
  155463. readonly linearVelocity: Float32Array | null;
  155464. readonly orientation: Float32Array | null;
  155465. readonly position: Float32Array | null;
  155466. readonly timestamp: number;
  155467. }
  155468. interface VRStageParameters {
  155469. sittingToStandingTransform?: Float32Array;
  155470. sizeX?: number;
  155471. sizeY?: number;
  155472. }
  155473. interface Navigator {
  155474. getVRDisplays(): Promise<VRDisplay[]>;
  155475. readonly activeVRDisplays: ReadonlyArray<VRDisplay>;
  155476. }
  155477. interface Window {
  155478. onvrdisplayconnected: ((this: Window, ev: Event) => any) | null;
  155479. onvrdisplaydisconnected: ((this: Window, ev: Event) => any) | null;
  155480. onvrdisplaypresentchange: ((this: Window, ev: Event) => any) | null;
  155481. addEventListener(type: "vrdisplayconnected", listener: (ev: Event) => any, useCapture?: boolean): void;
  155482. addEventListener(type: "vrdisplaydisconnected", listener: (ev: Event) => any, useCapture?: boolean): void;
  155483. addEventListener(type: "vrdisplaypresentchange", listener: (ev: Event) => any, useCapture?: boolean): void;
  155484. }
  155485. interface Gamepad {
  155486. readonly displayId: number;
  155487. }
  155488. type XRSessionMode = "inline" | "immersive-vr" | "immersive-ar";
  155489. type XRReferenceSpaceType = "viewer" | "local" | "local-floor" | "bounded-floor" | "unbounded";
  155490. type XREnvironmentBlendMode = "opaque" | "additive" | "alpha-blend";
  155491. type XRVisibilityState = "visible" | "visible-blurred" | "hidden";
  155492. type XRHandedness = "none" | "left" | "right";
  155493. type XRTargetRayMode = "gaze" | "tracked-pointer" | "screen";
  155494. type XREye = "none" | "left" | "right";
  155495. type XREventType = "devicechange" | "visibilitychange" | "end" | "inputsourceschange" | "select" | "selectstart" | "selectend" | "squeeze" | "squeezestart" | "squeezeend" | "reset";
  155496. interface XRSpace extends EventTarget {}
  155497. interface XRRenderState {
  155498. depthNear?: number;
  155499. depthFar?: number;
  155500. inlineVerticalFieldOfView?: number;
  155501. baseLayer?: XRWebGLLayer;
  155502. }
  155503. interface XRInputSource {
  155504. handedness: XRHandedness;
  155505. targetRayMode: XRTargetRayMode;
  155506. targetRaySpace: XRSpace;
  155507. gripSpace: XRSpace | undefined;
  155508. gamepad: Gamepad | undefined;
  155509. profiles: Array<string>;
  155510. hand: XRHand | undefined;
  155511. }
  155512. interface XRSessionInit {
  155513. optionalFeatures?: string[];
  155514. requiredFeatures?: string[];
  155515. }
  155516. interface XRSession {
  155517. addEventListener: Function;
  155518. removeEventListener: Function;
  155519. requestReferenceSpace(type: XRReferenceSpaceType): Promise<XRReferenceSpace>;
  155520. updateRenderState(XRRenderStateInit: XRRenderState): Promise<void>;
  155521. requestAnimationFrame: Function;
  155522. end(): Promise<void>;
  155523. renderState: XRRenderState;
  155524. inputSources: Array<XRInputSource>;
  155525. // hit test
  155526. requestHitTestSource(options: XRHitTestOptionsInit): Promise<XRHitTestSource>;
  155527. requestHitTestSourceForTransientInput(options: XRTransientInputHitTestOptionsInit): Promise<XRTransientInputHitTestSource>;
  155528. // legacy AR hit test
  155529. requestHitTest(ray: XRRay, referenceSpace: XRReferenceSpace): Promise<XRHitResult[]>;
  155530. // legacy plane detection
  155531. updateWorldTrackingState(options: { planeDetectionState?: { enabled: boolean } }): void;
  155532. }
  155533. interface XRReferenceSpace extends XRSpace {
  155534. getOffsetReferenceSpace(originOffset: XRRigidTransform): XRReferenceSpace;
  155535. onreset: any;
  155536. }
  155537. type XRPlaneSet = Set<XRPlane>;
  155538. type XRAnchorSet = Set<XRAnchor>;
  155539. interface XRFrame {
  155540. session: XRSession;
  155541. getViewerPose(referenceSpace: XRReferenceSpace): XRViewerPose | undefined;
  155542. getPose(space: XRSpace, baseSpace: XRSpace): XRPose | undefined;
  155543. // AR
  155544. getHitTestResults(hitTestSource: XRHitTestSource): Array<XRHitTestResult>;
  155545. getHitTestResultsForTransientInput(hitTestSource: XRTransientInputHitTestSource): Array<XRTransientInputHitTestResult>;
  155546. // Anchors
  155547. trackedAnchors?: XRAnchorSet;
  155548. createAnchor(pose: XRRigidTransform, space: XRSpace): Promise<XRAnchor>;
  155549. // Planes
  155550. worldInformation: {
  155551. detectedPlanes?: XRPlaneSet;
  155552. };
  155553. // Hand tracking
  155554. getJointPose(joint: XRJointSpace, baseSpace: XRSpace): XRJointPose;
  155555. }
  155556. interface XRViewerPose extends XRPose {
  155557. views: Array<XRView>;
  155558. }
  155559. interface XRPose {
  155560. transform: XRRigidTransform;
  155561. emulatedPosition: boolean;
  155562. }
  155563. interface XRWebGLLayerOptions {
  155564. antialias?: boolean;
  155565. depth?: boolean;
  155566. stencil?: boolean;
  155567. alpha?: boolean;
  155568. multiview?: boolean;
  155569. framebufferScaleFactor?: number;
  155570. }
  155571. declare var XRWebGLLayer: {
  155572. prototype: XRWebGLLayer;
  155573. new (session: XRSession, context: WebGLRenderingContext | undefined, options?: XRWebGLLayerOptions): XRWebGLLayer;
  155574. };
  155575. interface XRWebGLLayer {
  155576. framebuffer: WebGLFramebuffer;
  155577. framebufferWidth: number;
  155578. framebufferHeight: number;
  155579. getViewport: Function;
  155580. }
  155581. declare class XRRigidTransform {
  155582. constructor(matrix: Float32Array | DOMPointInit, direction?: DOMPointInit);
  155583. position: DOMPointReadOnly;
  155584. orientation: DOMPointReadOnly;
  155585. matrix: Float32Array;
  155586. inverse: XRRigidTransform;
  155587. }
  155588. interface XRView {
  155589. eye: XREye;
  155590. projectionMatrix: Float32Array;
  155591. transform: XRRigidTransform;
  155592. }
  155593. interface XRInputSourceChangeEvent {
  155594. session: XRSession;
  155595. removed: Array<XRInputSource>;
  155596. added: Array<XRInputSource>;
  155597. }
  155598. interface XRInputSourceEvent extends Event {
  155599. readonly frame: XRFrame;
  155600. readonly inputSource: XRInputSource;
  155601. }
  155602. // Experimental(er) features
  155603. declare class XRRay {
  155604. constructor(transformOrOrigin: XRRigidTransform | DOMPointInit, direction?: DOMPointInit);
  155605. origin: DOMPointReadOnly;
  155606. direction: DOMPointReadOnly;
  155607. matrix: Float32Array;
  155608. }
  155609. declare enum XRHitTestTrackableType {
  155610. "point",
  155611. "plane",
  155612. "mesh",
  155613. }
  155614. interface XRHitResult {
  155615. hitMatrix: Float32Array;
  155616. }
  155617. interface XRTransientInputHitTestResult {
  155618. readonly inputSource: XRInputSource;
  155619. readonly results: Array<XRHitTestResult>;
  155620. }
  155621. interface XRHitTestResult {
  155622. getPose(baseSpace: XRSpace): XRPose | undefined;
  155623. // When anchor system is enabled
  155624. createAnchor?(pose: XRRigidTransform): Promise<XRAnchor>;
  155625. }
  155626. interface XRHitTestSource {
  155627. cancel(): void;
  155628. }
  155629. interface XRTransientInputHitTestSource {
  155630. cancel(): void;
  155631. }
  155632. interface XRHitTestOptionsInit {
  155633. space: XRSpace;
  155634. entityTypes?: Array<XRHitTestTrackableType>;
  155635. offsetRay?: XRRay;
  155636. }
  155637. interface XRTransientInputHitTestOptionsInit {
  155638. profile: string;
  155639. entityTypes?: Array<XRHitTestTrackableType>;
  155640. offsetRay?: XRRay;
  155641. }
  155642. interface XRAnchor {
  155643. anchorSpace: XRSpace;
  155644. delete(): void;
  155645. }
  155646. interface XRPlane {
  155647. orientation: "Horizontal" | "Vertical";
  155648. planeSpace: XRSpace;
  155649. polygon: Array<DOMPointReadOnly>;
  155650. lastChangedTime: number;
  155651. }
  155652. interface XRJointSpace extends XRSpace {}
  155653. interface XRJointPose extends XRPose {
  155654. radius: number | undefined;
  155655. }
  155656. declare class XRHand extends Array<XRJointSpace> {
  155657. readonly length: number;
  155658. static readonly WRIST = 0;
  155659. static readonly THUMB_METACARPAL = 1;
  155660. static readonly THUMB_PHALANX_PROXIMAL = 2;
  155661. static readonly THUMB_PHALANX_DISTAL = 3;
  155662. static readonly THUMB_PHALANX_TIP = 4;
  155663. static readonly INDEX_METACARPAL = 5;
  155664. static readonly INDEX_PHALANX_PROXIMAL = 6;
  155665. static readonly INDEX_PHALANX_INTERMEDIATE = 7;
  155666. static readonly INDEX_PHALANX_DISTAL = 8;
  155667. static readonly INDEX_PHALANX_TIP = 9;
  155668. static readonly MIDDLE_METACARPAL = 10;
  155669. static readonly MIDDLE_PHALANX_PROXIMAL = 11;
  155670. static readonly MIDDLE_PHALANX_INTERMEDIATE = 12;
  155671. static readonly MIDDLE_PHALANX_DISTAL = 13;
  155672. static readonly MIDDLE_PHALANX_TIP = 14;
  155673. static readonly RING_METACARPAL = 15;
  155674. static readonly RING_PHALANX_PROXIMAL = 16;
  155675. static readonly RING_PHALANX_INTERMEDIATE = 17;
  155676. static readonly RING_PHALANX_DISTAL = 18;
  155677. static readonly RING_PHALANX_TIP = 19;
  155678. static readonly LITTLE_METACARPAL = 20;
  155679. static readonly LITTLE_PHALANX_PROXIMAL = 21;
  155680. static readonly LITTLE_PHALANX_INTERMEDIATE = 22;
  155681. static readonly LITTLE_PHALANX_DISTAL = 23;
  155682. static readonly LITTLE_PHALANX_TIP = 24;
  155683. }
  155684. // This file contains native only extensions for WebXR These APIs are not supported in the browser yet.
  155685. // They are intended for use with either Babylon Native https://github.com/BabylonJS/BabylonNative or
  155686. // Babylon React Native: https://github.com/BabylonJS/BabylonReactNative
  155687. interface XRSession {
  155688. trySetFeaturePointCloudEnabled(enabled: boolean): boolean;
  155689. }
  155690. interface XRFrame {
  155691. featurePointCloud? : Array<number>;
  155692. }